From 5dae1717157da4fcd5523a9cf113f9673990722c Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 26 Sep 1996 22:31:22 +0000 Subject: [PATCH] Add -g and -w options. --- deal.c | 5 +++-- deal.xml | 27 +++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/deal.c b/deal.c index 2ed7c8b..db66431 100644 --- a/deal.c +++ b/deal.c @@ -1,12 +1,13 @@ /* * deal -- compute combination probabilities for card draws * - * ($Id: deal.c,v 1.20 1995/04/17 11:44:49 esr Exp esr $) + * ($Id: deal.c,v 1.21 1996/09/26 22:30:35 esr Exp esr $) * * Based on the `cardprobs' program written by Jeremy C. York * in September 1993; cleanup, comments, * generalization, and interface improvements by Eric Raymond - * in April 1995. + * in April 1995. The -g and -w options + * were added by esr September 1996. * * If I have M special cards in my deck, and N total cards in my deck, * and I draw k cards from that deck (*without replacement* -- the diff --git a/deal.xml b/deal.xml index d380f1d..7ae5384 100644 --- a/deal.xml +++ b/deal.xml @@ -1,8 +1,8 @@ -.TH DEAL 1 "April 12, 1995" +.TH DEAL 1 "September 27, 1996" .SH NAME deal \- compute and display deal probabilities .SH SYNOPSIS -.B deal [-h] [-b base] [-t turns] [-c columns] specials total +.B deal [-h] [-b base] [-t turns] [-c columns] [-g] [-w] specials total .SH DESCRIPTION This program prints out tables of non-replacement draw probabilities, rounded to the nearest percent. @@ -26,6 +26,8 @@ formula for the binomial coefficient is: B(n,m) = n!/(m! * (n-m)!) +where n! is the factorial function n! = 1 * 2 * 3 * ... * n. +.PP This program prints out tables of these probabilities. The `specials' and `total' arguments specify M and N. The table displays values for ranges of k and i. @@ -39,8 +41,19 @@ The program accepts the following options to control its output: Number of cards to assume in the initial hand. Note: this defaults to 7, \fBnot\fB to 0! .TP 10 +-g +Normally, the program displays the probability that you will have +\fIexactly\fR a given number of specials. With this option, it +displays the odds that you will have the given number of specials +\fIor more\fR. This option also forces -w on, to accomodate 100% +probabilities which will show up in column 0 if nowhere else. +.TP 10 +-w +Force wide display (3 chars per percentage) to accommodate 100% probabilities. +.TP 10 -c -Number of columns to generate in the report. +Number of table columns to generate in the report. Defaults to the +number of specials plus one additional to accommodate the zero column. .TP 10 -h Suppress table headers and legends. @@ -81,8 +94,14 @@ To compute your chances of having the 4 aces on the nth draw in deal -b 5 4 52 .SH BUGS -100% probabilities can mess up the table formatting. +The -w and -g options widen the column width of the tables to +accommodate 100% probabilities, at the cost of making the table too +wide to display on an 80-column terminal when the number of specials +is more than 17. When wide display is off, on the other hand, 23 +specials will fit in 80 colums, but 100% probabilities can mess up the +table formatting. .SH AUTHOR Eric S. Raymond . Based on the `cardprobs' program by Jeremy York. See my home page at http://www.ccil.org/~esr/home.html for updates and other resources. + -- 2.43.0