From @tis.llnl.gov:celia!tpg!dickson@tis.llnl.gov Mon Jan 23 22:08:58 1989 Received: from tis.llnl.gov by antares.mcs.anl.gov (4.0/SMI-DDN) id AA04448; Mon, 23 Jan 89 22:08:37 CST Return-Path: Received: by tis.llnl.gov (4.0/1.14.5-TIS) id AA16845; Mon, 23 Jan 89 20:12:50 PST Received: by celia; Mon, 23 Jan 89 18:06:05 PST Received: by tpg.POSTGRP (3.2/2.0.UCSB-sdp/dhe/sas) id AA23248; Mon, 23 Jan 89 17:45:12 PST Date: Mon, 23 Jan 89 17:45:12 PST From: Stewart Dickson Posted-Date: Mon, 23 Jan 89 17:45:12 PST Message-Id: <8901240145.AA23248@tpg.POSTGRP> Organization: The Post Group Address: 6335 Homewood Ave. Hollywood, Ca 90028 Phone: (213) 462-2300 To: celia!mcs.anl.gov!dongarra Subject: Lottery Game Program Enclosed Status: RO # The following is a shar archive. Extract using 'sh filename' not 'csh'. # The rest of this file will extract: # cal_lotto.in cal_lotto7.dat cal_lotto7.doc cal_lottodat.doc ill_lotto.in ill_lotto6.dat ill_lotto6.doc ill_lotto7.doc ill_lottodat.doc lotto.README lotto.c lotto.h lottodata.c makefile rd_lotto.c echo extracting cal_lotto.in sed 's/^X//' > cal_lotto.in << '!EOR!' Xse 7/49 Xre cal_lotto7.dat >game.out Xhi >>game.out Xgr >>game.out X Xco >>game.out Xge 57 >>game.out Xhi >>game.out X Xecho >>game.out X Xgr >>game.out X Xpr >>game.out X !EOR! echo extracting cal_lotto7.dat sed 's/^X//' > cal_lotto7.dat << '!EOR!' X08/01/87 02 31 49 12 41 16 03 X08/08/87 35 16 33 20 24 36 12 X08/15/87 19 06 45 11 03 20 23 X08/22/87 18 32 37 26 28 12 09 X08/29/87 35 03 06 01 42 31 24 X09/05/87 32 16 13 47 05 42 39 X09/12/87 23 49 08 03 25 48 19 X09/19/87 31 45 02 20 19 22 01 X09/26/87 41 42 24 27 13 35 14 X09/30/87 26 01 10 35 47 21 02 X10/03/87 31 18 04 25 38 35 28 X10/07/87 07 32 44 23 36 09 42 X10/10/87 45 40 22 36 23 35 14 X10/14/87 47 09 25 36 17 19 29 X10/17/87 42 31 39 34 13 17 30 X10/21/87 45 04 11 21 47 17 36 X10/24/87 26 42 04 32 22 09 15 X10/28/87 16 41 14 13 43 17 47 X10/31/87 20 31 42 17 46 33 05 X11/04/87 30 27 39 33 47 24 08 X11/07/87 17 45 09 38 29 15 47 X11/11/87 26 49 06 15 07 04 23 X11/14/87 08 44 14 10 35 38 26 X11/18/87 44 12 39 36 02 47 22 X11/21/87 36 08 34 35 48 13 30 X11/25/87 16 05 32 45 35 42 46 X11/28/87 39 18 02 10 22 05 07 X12/02/87 12 41 36 48 22 40 28 X12/05/87 03 28 38 08 40 31 02 X12/09/87 23 07 45 28 21 12 29 X12/12/87 25 17 01 34 12 18 42 X12/16/87 25 15 24 16 48 31 37 X12/17/87 18 11 46 48 10 30 19 X12/23/87 37 18 02 46 03 24 13 X12/26/87 03 08 45 19 23 04 48 X12/30/87 28 03 36 19 35 31 05 X01/02/88 40 14 18 29 39 34 25 X01/06/88 22 38 11 12 19 43 28 X01/09/88 32 26 37 04 30 13 11 X01/13/88 20 41 14 10 15 34 22 X01/16/88 16 44 20 07 45 46 26 X01/20/88 22 09 03 05 32 30 19 X01/23/88 16 13 43 07 23 03 38 X01/27/88 11 14 20 01 30 10 43 X01/30/88 07 49 22 47 46 48 42 X02/03/88 36 21 26 33 40 22 17 X02/06/88 28 39 33 15 19 48 20 X02/10/88 40 43 30 47 38 29 34 X02/13/88 06 28 37 39 46 13 20 X02/17/88 11 37 33 22 24 49 39 X02/20/88 32 36 06 08 31 05 28 X02/20/88 32 36 06 08 31 05 28 X02/24/88 04 08 29 23 11 49 44 X02/27/88 46 41 08 37 17 22 23 X03/02/88 20 29 24 31 46 30 06 X03/05/88 14 17 34 12 48 02 25 X03/09/88 37 16 49 03 28 12 01 X03/12/88 18 15 39 10 43 20 16 X03/16/88 20 05 09 22 07 33 29 X03/19/88 26 37 25 22 43 40 45 X03/23/88 03 36 27 31 01 10 34 X03/26/88 23 39 11 35 01 18 31 X03/30/88 10 47 35 30 16 06 36 X04/02/88 13 41 21 36 17 43 10 X04/06/88 19 30 46 09 44 11 21 X04/09/88 06 47 34 49 39 28 10 X04/13/88 19 46 27 30 15 35 45 X04/16/88 41 35 40 48 06 13 36 X04/20/88 31 32 22 13 07 21 34 X04/23/88 48 25 22 40 20 44 46 X04/27/88 07 08 38 17 25 44 16 X04/30/88 42 17 48 34 11 23 22 X05/04/88 21 08 46 07 15 30 24 X05/07/88 30 33 08 43 28 23 12 X05/11/88 19 01 13 28 44 37 17 X05/14/88 46 13 25 03 21 20 12 X05/18/88 20 35 38 29 04 11 25 X05/21/88 36 37 14 42 28 25 17 X05/25/88 43 07 06 10 04 14 39 X05/28/88 28 31 07 47 34 01 39 X06/01/88 16 25 30 39 29 41 01 X06/04/88 48 42 09 14 19 31 37 X06/08/88 09 03 24 31 48 25 07 X06/11/88 18 01 37 38 16 10 12 X06/15/88 32 20 10 17 40 01 31 X06/18/88 08 14 40 27 36 32 07 X06/22/88 47 06 33 37 43 19 22 X06/25/88 27 25 05 08 01 44 31 X06/29/88 19 02 25 09 24 20 36 X07/02/88 24 45 37 47 46 26 01 X07/06/88 10 48 02 19 25 37 21 X07/09/88 21 11 04 39 44 40 31 X07/13/88 08 20 48 28 29 39 42 X07/16/88 08 38 01 15 05 06 35 X07/20/88 01 34 07 26 47 37 18 X07/23/88 35 18 09 41 10 06 08 X07/27/88 08 04 41 09 18 44 07 X07/30/88 11 36 39 45 32 16 47 X08/03/88 02 24 46 05 03 16 15 X08/06/88 10 31 17 42 49 02 14 X08/10/88 39 43 27 11 41 18 05 X08/13/88 15 13 04 06 26 14 18 X08/17/88 14 13 11 22 46 40 04 X08/20/88 01 17 11 32 04 27 49 X08/24/88 25 14 19 33 46 41 37 X08/27/88 36 34 24 12 33 19 29 X08/31/88 40 14 47 04 42 31 36 X09/03/88 30 18 44 09 48 41 22 X09/07/88 03 10 24 41 32 26 27 X09/28/88 21 29 30 34 35 47 25 X10/05/88 02 06 07 10 33 39 30 !EOR! echo extracting cal_lotto7.doc sed 's/^X//' > cal_lotto7.doc << '!EOR!' X XThis is the continuation of an amusing study in number theory. The product is Xa set of numbers for the California Lottery Lotto game. The numbers are chosen Xso as to yield forty-nine games of six numbers each which are guaranteed to Xbe unique. The numbers were represented as forty-nine rows of six columns Xeach. They were generated using a pseudo-random number generator then sorted Xso that each number in the range one to forty-nine appears at most once in Xeach column and also at most once in each row. This set of games will maximize Xthe chances of winning to the statistical limit. X XIf this page has not been copied, this set of games is guranteed to be unique. XThis means that the theoretical chances of winning are further extended by Xa number of people playing games from several of these pages on the same day. X X !EOR! echo extracting cal_lottodat.doc sed 's/^X//' > cal_lottodat.doc << '!EOR!' X X X X X X Stewart Dickson X October 3, 1988 X X X X X Attached is a refinement of the casual study of six-of-forty-nine Xlottery games begun a over two years ago. The previous study attempted to Xmaximize number coverage in a set of forty-nine games assuming a uniform random Xdistribution of drawn numbers. To date, the previous study has succeeded Xquite well at proving just how closely theory has characterized the drawings -- Xand just how astronomical the theoretical chances of winning really are! X X The present study alters its view by recognizing that lottery Xdrawings approach a uniform distribution only as the number of drawings Xapproaches infinity. To date there have been only a few hundred drawings. XThus, the approach is to assume that until an infinite number of drawings Xhave been made, the histogram of drawn numbers will exhibit spectral Xoddities. X X Spectral oddities are numbers which have come up too often or have Xnot come up often enough to satisfy the theoretical uniform distribution. XThe numbers which have not come up often enough are the ones to play X(contrary to popular belief) because they are the ones which have more Xoccurrences due them in the future to satisfy statistics. ANY DEVIATION FROM XTHIS ASSUMPTION MEANS THE LOTTERY IS RIGGED!!!! X X The future drawings can be viewed as the histogram which, added to Xthe histogram of the drawings to date, yields the uniform random distribution. XA set of games can then be generated from the inverted, compliment histogram Xwhich will appropriately "aim" for the numbers whose time is due. X X The games generated from this program are still only a tiny sub-sampling Xof all possible drawings (approximately 1347135462000000000000000000000000000 Xcombinations). However, odds of winning are theoretically maximized! XMoreover, the more people who play unique sets of unique games, such as appear Xin the attached analysis, the greater the chances of someone winning! X X X !EOR! echo extracting ill_lotto.in sed 's/^X//' > ill_lotto.in << '!EOR!' Xse 6/44 Xre ill_lotto6.dat >game.out Xhi >>game.out Xgr >>game.out X Xco >>game.out Xge 44 >>game.out Xhi >>game.out X Xecho >>game.out X Xgr >>game.out X Xpr >>game.out X !EOR! echo extracting ill_lotto6.dat sed 's/^X//' > ill_lotto6.dat << '!EOR!' X05/19/84 20 16 27 15 19 43 X05/26/84 29 28 23 20 12 19 X06/02/84 13 39 37 41 40 11 X06/09/84 01 19 22 38 04 36 X06/16/84 32 03 39 30 02 26 X06/23/84 12 13 39 44 01 23 X06/30/84 23 20 37 12 10 21 X07/07/84 24 07 23 32 15 28 X07/14/84 17 04 41 25 37 08 X07/21/84 44 34 21 17 24 36 X07/28/84 12 04 21 43 42 23 X08/04/84 13 01 27 41 07 44 X08/11/84 32 05 19 40 33 18 X08/18/84 14 29 37 18 41 10 X08/25/84 41 31 23 02 38 28 X09/01/84 26 43 30 03 10 02 X09/08/84 12 15 43 18 22 38 X09/15/84 07 13 44 16 20 01 X09/22/84 04 25 20 03 34 43 X09/29/84 09 39 12 20 18 08 X10/06/84 32 30 11 36 03 07 X10/13/84 26 01 41 25 38 05 X10/20/84 43 42 15 35 23 28 X10/27/84 11 38 28 29 24 34 X11/03/84 29 03 05 32 17 24 X11/10/84 01 40 15 10 33 09 X11/17/84 44 35 34 31 26 01 X11/24/84 23 27 39 07 14 03 X12/01/84 36 13 10 20 40 44 X12/08/84 22 09 17 23 37 04 X12/15/84 40 01 31 35 13 10 X12/22/84 19 03 32 26 23 24 X12/29/84 33 04 13 06 14 20 X01/05/85 44 35 43 36 23 02 X01/12/85 21 32 42 02 29 20 X01/19/85 30 20 34 10 31 16 X01/26/85 27 03 09 14 39 21 X02/02/85 03 10 19 27 05 29 X02/09/85 28 06 05 41 13 42 X02/16/85 16 05 35 15 03 09 X02/23/85 06 30 14 19 25 08 X03/02/85 04 38 17 41 12 08 X03/09/85 32 02 10 18 30 20 X03/16/85 29 07 23 11 41 14 X03/23/85 16 27 37 36 42 39 X03/30/85 43 19 13 33 42 22 X04/06/85 02 08 24 16 04 40 X04/13/85 29 11 39 22 21 01 X04/20/85 44 21 20 39 14 36 X04/27/85 39 34 05 15 19 18 X05/04/85 42 17 35 25 14 22 X05/11/85 12 02 11 19 44 39 X05/18/85 24 18 06 27 08 22 X05/25/85 05 40 24 03 25 36 X06/01/85 04 34 39 09 25 40 X06/08/85 43 09 05 17 36 16 X06/15/85 35 34 33 43 22 19 X06/22/85 14 19 32 38 17 34 X06/29/85 27 12 36 13 19 29 X07/06/85 38 39 30 10 29 20 X07/13/85 31 37 16 38 32 07 X07/20/85 01 02 11 10 12 36 X07/27/85 43 15 31 20 10 25 X08/03/85 43 33 31 20 18 35 X08/10/85 24 20 30 13 44 25 X08/17/85 36 11 10 39 09 27 X08/31/85 34 15 17 36 19 22 X09/07/85 26 32 25 40 09 39 X09/14/85 33 28 32 07 36 37 X09/21/85 29 27 17 36 30 05 X09/28/85 40 23 22 33 43 07 X10/05/85 15 26 20 17 25 12 X10/12/85 19 05 41 24 03 12 X10/19/85 24 04 22 30 20 32 X10/26/85 08 12 33 37 38 30 X11/02/85 37 32 07 42 20 39 X11/09/85 41 37 14 29 16 04 X11/16/85 12 02 23 04 16 10 X11/23/85 24 22 14 08 11 17 X11/30/85 30 34 33 12 24 02 X12/07/85 41 21 07 35 20 36 X12/14/85 23 17 02 30 18 43 X12/21/85 09 39 22 30 35 15 X12/28/85 33 03 41 01 08 06 X01/04/86 23 25 04 31 26 15 X01/11/86 12 13 29 09 44 33 X01/15/86 28 38 07 37 22 17 X01/18/86 43 02 35 05 21 18 X01/22/86 11 41 02 05 40 14 X01/25/86 31 06 36 44 05 34 X01/29/86 43 34 25 14 32 30 X02/01/86 36 07 23 24 31 35 X02/05/86 30 08 34 28 03 05 X02/08/86 29 41 21 28 37 24 X02/12/86 03 18 23 41 26 01 X02/15/86 21 26 16 02 12 32 X02/19/86 44 32 09 24 01 41 X02/22/86 30 10 43 12 14 17 X02/26/86 29 18 03 35 16 09 X03/01/86 08 23 26 02 41 22 X03/05/86 43 33 38 36 40 30 X03/08/86 36 44 12 04 32 21 X03/12/86 02 10 14 01 31 17 X03/15/86 38 39 42 28 24 13 X03/19/86 02 20 39 14 24 11 X03/22/86 19 32 37 41 09 39 X03/26/86 10 03 04 35 05 39 X03/29/86 35 39 37 05 03 42 X04/02/86 40 44 14 19 35 24 X04/05/86 22 18 11 26 02 04 X04/09/86 27 19 22 43 42 31 X04/12/86 21 16 24 40 11 08 X04/16/86 18 09 02 26 05 41 X04/19/86 26 07 22 44 18 20 X04/23/86 35 10 15 31 43 34 X04/26/86 19 14 17 30 15 05 X04/30/86 41 28 14 01 31 26 X05/03/86 33 30 41 27 43 28 X05/07/86 18 06 12 42 26 10 X05/10/86 33 20 08 26 16 17 X05/14/86 05 20 41 24 29 04 X05/17/86 06 03 02 16 35 23 X05/21/86 04 14 24 25 21 06 X05/24/86 37 18 33 20 01 06 X05/28/86 27 21 32 29 18 42 X05/31/86 06 21 32 17 19 35 X06/04/86 26 41 33 40 19 38 X06/07/86 06 29 34 33 41 03 X06/11/86 20 13 30 31 44 18 X06/14/86 14 10 32 35 01 42 X06/18/86 14 30 05 41 26 21 X06/21/86 04 33 25 14 29 38 X06/25/86 09 43 34 12 14 37 X06/28/86 04 13 15 23 25 28 X07/02/86 34 42 37 06 18 30 X07/05/86 15 06 12 40 27 44 X07/09/86 27 40 36 33 32 13 X07/12/86 41 11 32 33 30 27 X07/16/86 15 13 03 23 04 21 X07/23/86 41 29 07 04 15 30 X07/26/86 12 14 30 41 42 05 X07/30/86 26 18 31 39 36 09 X08/02/86 25 44 41 09 19 12 X08/06/86 42 39 12 15 28 25 X08/09/86 38 23 39 02 06 29 X08/13/86 09 15 17 23 26 27 X08/16/86 02 22 29 37 38 44 X08/20/86 07 16 18 19 35 44 X08/23/86 02 21 32 33 35 44 X08/27/86 03 08 15 31 34 39 X08/30/86 02 16 21 29 30 35 X09/03/86 09 14 18 26 29 30 X09/06/86 16 25 30 34 41 44 X09/10/86 07 10 14 15 17 19 X09/13/86 04 05 09 25 38 40 X09/17/86 09 14 22 25 28 34 X09/20/86 03 11 13 17 40 42 X09/24/86 02 06 12 15 39 43 X09/27/86 02 16 23 26 31 39 X10/01/86 03 08 22 28 36 42 X10/04/86 02 12 26 29 38 42 X10/08/86 05 12 19 21 23 39 X10/11/86 13 17 20 22 26 29 X10/15/86 13 15 22 29 39 43 X10/18/86 05 07 10 14 15 17 X10/22/86 09 18 26 37 38 39 X10/25/86 01 07 09 33 38 39 X10/29/86 10 15 16 34 38 44 X11/01/86 01 03 22 27 30 41 X11/05/86 10 11 31 32 39 41 X11/08/86 02 06 08 16 28 39 X11/12/86 01 06 10 20 26 38 X11/15/86 05 18 19 20 37 38 X11/19/86 03 08 31 34 41 42 X11/22/86 15 21 23 29 35 42 X11/26/86 03 12 21 25 32 43 X11/29/86 01 04 08 13 28 30 X12/03/86 05 08 09 12 25 29 X12/06/86 05 07 14 20 21 26 X12/10/86 10 11 30 32 34 38 X12/13/86 01 04 12 14 19 40 X12/17/86 19 26 29 32 35 39 X12/20/86 01 02 09 15 32 39 X12/24/86 12 17 20 23 24 40 X12/27/86 06 07 08 28 40 44 X12/31/86 25 26 29 35 38 40 X01/03/87 03 05 06 10 17 21 X01/07/87 03 15 18 26 30 36 X01/10/87 08 16 19 24 27 39 X01/14/87 11 15 21 31 37 40 X01/17/87 04 10 20 25 35 41 X01/21/87 06 11 14 23 32 38 X01/24/87 08 09 17 18 32 38 X01/28/87 03 10 12 13 40 41 X01/31/87 02 13 15 16 28 44 X02/04/87 13 30 33 36 37 39 X02/07/87 11 24 25 39 40 43 X02/11/87 02 06 17 28 32 37 X02/14/87 09 25 26 32 33 35 X02/18/87 19 22 28 30 40 44 X02/21/87 03 08 15 16 18 27 X02/25/87 05 14 17 22 35 36 X02/28/87 01 05 14 29 30 36 X03/04/87 10 13 16 33 37 38 X03/07/87 04 09 25 40 41 43 X03/11/87 01 10 16 17 34 44 X03/14/87 18 26 28 33 38 41 X03/18/87 05 11 13 29 34 35 X03/21/87 03 07 14 15 22 44 X03/25/87 02 13 14 36 39 40 X03/28/87 13 22 27 28 32 33 X04/01/87 14 15 17 22 32 39 X04/04/87 01 02 04 19 24 31 X04/08/87 07 11 23 25 26 33 X04/11/87 22 26 30 32 34 42 !EOR! echo extracting ill_lotto6.doc sed 's/^X//' > ill_lotto6.doc << '!EOR!' X X X X XThis is the result of an amusing study in number theory. The product is a set Xof numbers for the Illinois Lottery. They are chosen so as to yield forty-four Xgames of six numbers each which are guaranteed to be unique. The numbers were Xrepresented as forty-four rows of six columns each. They were generated Xusing a pseudo-random number generator then sorted so that each number in the Xrange one to forty-four appears at most once in each column and also at most Xonce in each row. This set of games will maximize the chances of winning to Xthe statistical limit. X XIf this page has not been copied, this set of games is guranteed to be unique! !EOR! echo extracting ill_lotto7.doc sed 's/^X//' > ill_lotto7.doc << '!EOR!' X X X X X XThis is the continuation of an amusing study in number theory. The product is Xa set of numbers for the Illinois Lottery Lotto-7 game. The numbers are chosen Xso as to yield thirty-nine games of seven numbers each which are guaranteed to Xbe unique. The numbers were represented as thirty-nine rows of seven columns Xeach. They were generated using a pseudo-random number generator then sorted Xso that each number in the range one to thirty-nine appears at most once in Xeach column and also at most once in each row. This set of games will maximize Xthe chances of winning to the statistical limit. X XIf this page has not been copied, this set of games is guranteed to be unique. XThis means that the theoretical chances of winning are further extended by Xa number of people playing games from several of these pages on the same day. X X !EOR! echo extracting ill_lottodat.doc sed 's/^X//' > ill_lottodat.doc << '!EOR!' X X X X X X Stewart Dickson X April 23, 1987 X X X X X Attached is a refinement of the casual study of six-of-forty-four Xlottery games begun a year ago. The previous study attempted to maximize Xnumber coverage in a set of forty-four games assuming a uniform random Xdistribution of drawn numbers. To date, the previous study has succeeded Xquite well at proving just how closely theory has characterized the drawings -- Xand just how astronomical the theoretical chances of winning really are! X X The present study alters its view by recognizing that lottery Xdrawings approach a uniform distribution only as the number of drawings Xapproaches infinity. To date there have been only a few hundred drawings. XThus, the approach is to assume that until an infinite number of drawings Xhave been made, the histogram of drawn numbers will exhibit spectral Xoddities. X X Spectral oddities are numbers which have come up too often or have Xnot come up often enough to satisfy the theoretical uniform distribution. XThe numbers which have not come up often enough are the ones to play X(contrary to popular belief) because they are the ones which have more Xoccurrences due them in the future to satisfy statistics. X X The future drawings can be viewed as the histogram which, added to Xthe histogram of the drawings to date, yields the uniform random distribution. XA set of games can then be generated from the inverted, compliment histogram Xwhich will appropriately "aim" for the numbers whose time is due. X X The games generated from this program are still only a tiny sub-sampling Xof all possible drawings (approximately 17324272922341483000000000000000000 Xcombinations). However, odds of winning are theoretically maximized! XMoreover, the more people who play unique sets of unique games, such as appear Xin the attached analysis, the greater the chances of someone winning! X X X !EOR! echo extracting lotto.README sed 's/^X//' > lotto.README << '!EOR!' X X X XThe accompanying 'makefile' contains UNIX instructions for building and Xexecuting the Lottery Analysis program by Stewart Dickson. Databases Xexist for the State of Illinois and California State Lotteries. When they Xbecome outdated, updates may generally be obtained by sending a self-addressed, Xstamped envelope to: X X California State Lottery X 600 North 10 Street X Sacramento, CA 95814 X X OR: X X Public Information Office X Illinois State Lottery X P.O. Box 19080 X Springfield, IL 62794-9080 X (217)524-5155 X XHave fun and good luck! X X-Stewart Dickson Xcelia!tpg!dickson@tis.llnl.gov.ARPA X X X !EOR! echo extracting lotto.c sed 's/^X//' > lotto.c << '!EOR!' X/* file: lotto.c X X description: C source code for the program which generates lottery games X in a nums_game/range lottery system. The program maximizes X the statistical chances of winning by generating a complete X coverage of numbers assuming a uniform random distribution X of drawings. X X author: Stewart Dickson X*/ X X#define DONE 0 X#define NOTYET 1 X#include X Xmain(argc,argv) Xchar argc,**argv; X{ Xlong float drand48(); Xvoid srand48(); Xlong time(); Xint nums_game=6,range=44,nogames,loopcnt=0; Xint number[7][100]; Xchar uniq[101]; Xint uniqflg,argindx=1; Xint game,no,cmpno,indx; X Xif(argc<2) { X fprintf(stderr, X "usage: lotto [-n #'s_per_game] [-r range] number_games\n"); X exit(); X } X Xwhile(argindxrange) { X fprintf(stderr,"sorry, too many games - max. range\n"); X exit(); X } Xfprintf(stdout, X "calculating for %d games\n of %d numbers each, 1-%d\n\n", X nogames,nums_game,range); X X X/* initialize random number generator to pseudo-random value */ Xsrand48(time((long *)0)); X X/* fill matrix with random numbers */ Xfor(game=0;game500) { X fprintf(stdout,"sort quitting at 500\n"); X break; X } X /* make each 'no' column contain at most one of each number in the X range 1-range */ X for(no=0;no lotto.h << '!EOR!' X/* file: lotto.h X X description: Data structure for 6/44 number lottery data. X X author: Stewart Dickson X*/ X X#define NOGAMES 1000 X Xstruct lotto { X struct games { X int mon; X int day; X int yr; X int number[7]; X } game[NOGAMES]; X }; X !EOR! echo extracting lottodata.c sed 's/^X//' > lottodata.c << '!EOR!' X/* file: lottodata.c X X description: C program to analyze numbers for a n/m number lottery from X a history of games. n is the number of numbers per game, m is the X range of drawn numbers. X X author: Stewart Dickson X*/ X#define YES 1 X#define NO 0 X X#define RANGE 50 X X#define HELP 100 X#define CHECK 1 X#define CMPLMN 2 X#define ECHO 3 X#define GEN 4 X#define GRAPH 5 X#define HIST 6 X#define LIST 7 X#define PRINT 8 X#define RANK 9 X#define READ 10 X#define SET 11 X#define VERBOSE 12 X X#define GREY 16 X X#include X#include X#include X#ifdef IRIS X#include X#endif X#include "lotto.h" X Xint verbflg=NO,nonums = 6,range = 49,nogames=NOGAMES; XFILE *outfile; Xchar legend[] = " Frequency of Drawing "; X Xmain(argc,argv) Xchar argc,**argv; X{ XFILE *datafile; Xstruct tm *nowtime,*localtime(); Xstruct lotto *lottodata=NULL, *rd_lotto(); Xstruct ranks { X int numb; X int freq; X } rank[RANGE]; Xint hist[RANGE],argindx=1,game,datum,Number,maxfreq,minfreq,normfreq,stat; Xint index,thisval,lastval,thisindx,onogames,gameno,dataX,dataY,cmpnum; Xint mon,day,yr,value,linepos,charpos,badnum,dupnum,cnt; Xchar filename[128],line[128],cmd[128],clabel[128]; Xchar *zerfil(),*cterm, *getenv(), *string; Xlong secs,time(); Xvoid srand48(); Xfloat drand48(); Xoutfile=stdout; X X/* parse command line; format: lottodata [-v] [filename] */ Xwhile(argindx1 && argv[argc-1][0]!='-') { /* argv[argc-1] must be a file name */ X strcpy(filename,argv[argc-1]); X /* attempt to open file */ X if((datafile=fopen(filename,"r"))==NULL) { /* cannot open file */ X fprintf(stderr,"lottodata: cannot open '%s'\n",filename); X } X else { X /* attempt to read file */ X lottodata=rd_lotto(datafile,lottodata,nonums); X fclose(datafile); X } X } X X/* initialize random number generator to random value */ Xsecs=time((long *)0); Xsrand48(time((long *)0)); X/* generate ASCII current date */ Xnowtime=localtime(&secs); X/* read environment for $TERM variable */ Xif((cterm=getenv("TERM"))==NULL) { /* $TERM undefined */ X /* assume we are on a dumb terminal */ X if((cterm=(char *)malloc(128))==NULL) { X fprintf(stderr,"cannot allocate $TERM\n"); X exit(); X } X strcpy(cterm,"du"); X } Xfprintf(outfile,"TERM = %s\n",cterm); X X/* enter interactive command loop */ Xfprintf(stdout,"lotto>> "); Xwhile((stat=fgetc(stdin))!=EOF) { X ungetc(stat,stdin); X if((stat=fscanf(stdin,"%[^\n]",line))==EOF) { /* read command line */ X break; X } X switch(parse(line)) { /* find an int command number for this cmd */ X case HELP: { /* HELP */ X fprintf(outfile, X "lottodata commands:\n"); X fprintf(outfile, X "\t^D - exit\n"); X fprintf(outfile, X "\tcheck - check database consistency\n"); X fprintf(outfile, X "\tcmd > file - send output of cmd to file\n"); X fprintf(outfile, X "\tcmd >> file - append output of cmd to file\n"); X fprintf(outfile, X "\tcompliment - generate the compliment of the\n"); X fprintf(outfile, X "\t\tcurrent histogram (i.e., the histogram\n"); X fprintf(outfile, X "\t\twhich, when added to the current\n"); X fprintf(outfile, X "\t\thistogram, yields a uniform distribution)\n"); X fprintf(outfile, X "\techo string - echo string to output)\n"); X fprintf(outfile, X "\tgenerate nogames - generate games from the current histogram\n"); X fprintf(outfile, X "\tgraph - graph current histogram data\n"); X fprintf(outfile, X "\thist - compute histogram of all data\n"); X fprintf(outfile, X "\tlist - list database configuration\n"); X fprintf(outfile, X "\tprint - print games table\n"); X fprintf(outfile, X "\trank - rank and print histogram data\n"); X fprintf(outfile, X "\tread file - read lotto data file\n"); X fprintf(outfile, X "\tset nonums/range - set nums/game and range of nums\n"); X fprintf(outfile, X "\tverbose - toggle verbose flag\n"); X break; X } X case CHECK: { /* check command */ X /* format: ch[eck] */ X if(lottodata==NULL) { X fprintf(stderr, X "ERROR - no data has been read\n"); X break; X } X badnum=0; X dupnum=0; X /* for all games in database */ X for(game=0;gamegame[game].number[Number] < 1 || X lottodata->game[game].number[Number] > range) { X mon=lottodata->game[game].mon; X day=lottodata->game[game].day; X yr=lottodata->game[game].yr; X fprintf(stderr, X "game %d, %s/%s/%s - illegal number: %2d\n", X game, X zerfil(mon), X zerfil(day), X zerfil(yr), X lottodata->game[game].number[Number]); X fprintf(stderr,"legal range %d -> %d\n",1, range); X badnum++; X } X /* check for multiples of the X same number in a game */ X for(cmpnum=0;cmpnumgame[game].number[cmpnum] == X lottodata->game[game].number[Number]) { X mon=lottodata->game[game].mon; X day=lottodata->game[game].day; X yr=lottodata->game[game].yr; X fprintf(stderr, X "game %d, %s/%s/%s - duplicate number: %d=%d\n", X game, X zerfil(mon), X zerfil(day), X zerfil(yr), X lottodata->game[game].number[Number], X lottodata->game[game].number[Number]); X dupnum++; X } X } X } X } X fprintf(outfile,"%d numbers out of range, %d duplicate numbers\n", X badnum,dupnum); X break; X } X case CMPLMN: { /* compliment command */ X if(lottodata==NULL) { X fprintf(stderr, X "ERROR - no data has been read\n"); X break; X } X if(maxfreq==0) { X fprintf(stderr, X "ERROR - no histogram has been calculated\n"); X break; X } X /* format: co[mpliment] */ X /* build a histogram which is twice maxfreq minus X the current frequency value */ X normfreq=2.0*nonums*nogames/range; X /* make allowances for roundoff */ X if((float)2.0*nonums*nogames/range - normfreq > 0.8) { X normfreq++; X } X /* for each entry in histogram */ X for(datum=1;datum<=range;datum++) { X hist[datum]=normfreq-hist[datum]; X } X fprintf(outfile,"Calculated the compliment of the current"); X fprintf(outfile," histogram\n"); X break; X } X case ECHO: { /* echo string to output */ X /* strip off string from command line */ X cnt = 0; X while(line[cnt++] != ' '); X while(line[cnt] != '>' && line[cnt] != '\0') { X fprintf(outfile,"%c",line[cnt++]); X } X fprintf(outfile,"\n"); X break; X } X case GEN: { /* generate games from current histogram */ X /* format: gen[erate] no_games */ X onogames=nogames; X if(sscanf(line,"%s %d",cmd,&nogames) < 2) { X fprintf(stderr,"usage: gen[erate] nogames\n"); X break; X } X if(lottodata==NULL) { X fprintf(stderr, X "ERROR - no data has been read\n"); X break; X } X if(maxfreq==0) { X fprintf(stderr, X "ERROR - no histogram has been calculated\n"); X break; X } X /* set games table to zeroes and current date */ X /* for all games in database */ X for(game=0;gamegame[game].number[Number]=0; X } X lottodata->game[game].mon=nowtime->tm_mon+1; X lottodata->game[game].day=nowtime->tm_mday; X lottodata->game[game].yr=nowtime->tm_year; X } X /* generate new games from histogram */ X fprintf(outfile,"generating %d new games from histogram\n",nogames); X /* for each number in histogram 1 - RANGE */ X for(datum=1;datum<=range;datum++) { X /* plug frequency of instances of this X number normalized by requested number of X games into games table */ X normfreq=((float)nogames/onogames)*hist[datum]; X /* make allowance for roundoff */ X if(((float)nogames/onogames)*hist[datum] - normfreq > 0.55) { X normfreq++; X } X for(index=0;indexnogames || gameno<0) { X fprintf(stderr,"ERROR - game %d out of range\n",gameno); X goto rndsel; X } X /* for each number in this game */ X for(Number=0;Number<=nonums;Number++) { X if(Number==nonums) { X /* this game is full - try another */ X if(++cnt > nogames * nogames) { X break; X } X else { X goto rndsel; X } X } X /* if this position is unassigned */ X if(lottodata->game[gameno].number[Number]==0) { X /* put the number here */ X lottodata->game[gameno].number[Number]=datum; X if(verbflg == YES) { X fprintf(stderr, X "game %d, number %d = %d\n", X gameno, Number, datum); X } X /* done with this game - break */ X break; X } X /* if this game already contains this number */ X if(lottodata->game[gameno].number[Number]==datum) { X /* select another game */ X if(++cnt > nogames * nogames) { X break; X } X else { X goto rndsel; X } X } X /* else - next number position */ X } X } X } X break; X } X case GRAPH: { /* graph command */ X /* format: gr[aph] */ X if(lottodata==NULL) { X fprintf(stderr, X "ERROR - no data has been read\n"); X break; X } X if(maxfreq==0) { X fprintf(stderr, X "ERROR - no histogram has been calculated\n"); X break; X } X if(strcmp(cterm,"wsiris")==0 && outfile==stdout) { X /* we are on an IRIS in graphical mode */ X/* if we are compiling this for the SGI IRIS workstation */ X#ifdef IRIS X gbegin(); X cursoff(); X mapcolor(GREY,64,64,64); X color(GREY); X clear(); X color(WHITE); X /* draw axes */ X move2i(100,700); X draw2i(100,100); X draw2i(730,100); X /* label axes */ X for(dataY=700;dataY>=100;dataY-=60) { X color(WHITE); X sprintf(clabel,"%3d",maxfreq*(dataY-100)/600); X cmov2i(60,dataY); X charstr(clabel); X color(BLACK); X move2i(100,dataY); X draw2i(730,dataY); X } X for(dataX=100;dataX<=730;dataX+=(630/range)) { X color(WHITE); X sprintf(clabel,"%d",(dataX-100)/(630/range)); X if(((dataX-100)/(630/range))%2==0) { X cmov2i(dataX,80); X } X else { X cmov2i(dataX,55); X } X charstr(clabel); X color(BLACK); X move2i(dataX,700); X draw2i(dataX,100); X } X color(BLUE); X move2i(100,100); X /* for each entry in histogram */ X for(datum=1;datum<=range;datum++) { X dataX=datum*630/range+100; X dataY=hist[datum]*600/maxfreq+100; X /* plot point */ X draw2i(dataX,dataY); X } X color(BLACK); X cmov2i(500,25); X charstr("Hit Return to Continue "); X while((stat=getc(stdin))!='\n'); X gexit(); X#endif X } X else { /* this graph is to be printed on a terminal */ X fprintf(outfile,"\n"); X for(linepos=24;linepos>=0;linepos--) { X if(linepos%6==0) { X fprintf(outfile, X " %c %2d ",legend[24-linepos],maxfreq*linepos/24); X } X else { X fprintf(outfile," %c ",legend[24-linepos]); X } X fprintf(outfile,"|"); X for(charpos=1;charpos<=range;charpos++) { X if(hist[charpos]*24/maxfreq==linepos) { X fprintf(outfile,"*"); X } X else { X fprintf(outfile," "); X } X } X fprintf(outfile,"\n"); X } X fprintf(outfile," "); X for(charpos=0;charpos<=range;charpos++) { X fprintf(outfile,"_"); X } X fprintf(outfile,"\n"); X X fprintf(outfile," "); X for(charpos=2;charpos<=range;charpos+=3) { X fprintf(outfile,"%3d",charpos); X } X fprintf(outfile,"\n\n"); X fprintf(outfile," Range of Drawn Numbers\n\n"); X } X break; X } X case HIST: { /* generate histogram of current games table */ X /* format: hi[st] */ X if(lottodata==NULL) { X fprintf(stderr, X "ERROR - no data has been read\n"); X break; X } X /* clear histogram database */ X for(datum=0;datum<=range;datum++) { X hist[datum]=0; X } X /* for all games in database */ X for(game=0;gamegame[game].number[Number]; X hist[index]=hist[index]+1; X } X } X /* find minimum and maximum frequencies */ X maxfreq=0; X minfreq=999999; X for(index=1;index<=range;index++) { X if(hist[index]>maxfreq) { X maxfreq=hist[index]; X } X else if(hist[index]game[game].number[Number]<1 || X lottodata->game[game].number[Number]>range) { X badnum++; X goto pr_next; X } X } X mon=lottodata->game[game].mon; X day=lottodata->game[game].day; X yr=lottodata->game[game].yr; X fprintf(outfile,"%s/%s/%s", X zerfil(mon), X zerfil(day), X zerfil(yr)); X for(Number=0;Numbergame[game].number[Number]; X fprintf(outfile," %s", X zerfil(value)); X } X fprintf(outfile,"\n"); X if(game>0 && game%24==0 && outfile==stdout) { X fprintf(outfile,"- more -"); X while((stat=getc(stdin))!=' '); X } Xpr_next: ; X } X fprintf(outfile, X "*** %d games containing illegal numbers were omitted\n", X badnum); X break; X } X case RANK: { /* print ranked ordering of histogram */ X if(lottodata==NULL) { X fprintf(stderr, X "ERROR - no data has been read\n"); X break; X } X if(maxfreq==0) { X fprintf(stderr, X "ERROR - no histogram has been calculated\n"); X break; X } X for(index=1;index<=range;index++) { X rank[index].numb=index; X rank[index].freq=hist[index]; X } X fprintf(outfile,"\nRanked Frequencies of Current Games Table:\n\n"); X for(index=1;index<=range;index++) { X for(datum=index+1;datum<=range;datum++) { X if(rank[datum].freq0 && index%24==0 && outfile==stdout) { X fprintf(outfile,"- more -"); X while((stat=getc(stdin))!=' '); X } X } X break; X } X case READ: { /* (open and) read lotto data file */ X /* format: re[ad] filename */ X if(sscanf(line,"%s %s",cmd,filename) < 2) { X fprintf(stderr,"usage: re[ad] filename\n"); X break; X } X /* attempt to open file */ X if((datafile=fopen(filename,"r"))==NULL) { X /* cannot open file */ X fprintf(stderr, X "cannot open '%s'\n",filename); X } X else { X /* attempt to read file */ X lottodata=rd_lotto(datafile,lottodata,nonums); X fclose(datafile); X } X break; X } X case SET: { /* set nonums and range */ X /* format: s[et] nonums/range */ X if(sscanf(line,"%s %d/%d",cmd,&nonums,&range) < 3) { X fprintf(stderr, X "usage: set nonums/range\n"); X } X fprintf(outfile, X "Using %d games of %d numbers per game, range 1-%d\n", X nogames, nonums, range); X break; X } X case VERBOSE: { /* toggle verbose flag */ X /* format: ve[rbose] */ X if(verbflg == YES) { X verbflg = NO; X fprintf(stderr, X "verbose OFF\n"); X } X else { X verbflg = YES; X fprintf(stderr, X "verbose ON\n"); X } X break; X } X default: { /* command not found */ X break; X } X } X /* close output file (if opened) */ X if(outfile!=stdout) { X fclose(outfile); X /* return output to stdout */ X outfile=stdout; X } X strcpy(line,"\0"); X /* clear rest of line */ X while((stat=fgetc(stdin))!='\n'); X /* output prompt */ X fprintf(outfile,"lotto>> "); X } X} X X X Xint parse(command) Xchar *command; X{ Xchar cmd[128],filename[128]; Xint retval=NULL; X Xretval=NULL; X Xif(strncmp(command,"?",1)==0) { /* HELP */ X retval=HELP; X } X Xif(strncmp(command,"ch",2)==0) { /* CHECK */ X retval=CHECK; X } X Xif(strncmp(command,"co",2)==0) { /* CoMPLiMeNt */ X retval=CMPLMN; X } X Xif(strncmp(command,"echo",4)==0) { /* ECHO */ X retval=ECHO; X } X Xif(strncmp(command,"ge",2)==0) { /* GENerate */ X retval=GEN; X } X Xif(strncmp(command,"gr",2)==0) { /* GRAPH */ X retval=GRAPH; X } X Xif(strncmp(command,"hi",2)==0) { /* HIST */ X retval=HIST; X } X Xif(strncmp(command,"li",2)==0) { /* LIST */ X retval=LIST; X } X Xif(strncmp(command,"pr",2)==0) { /* PRINT */ X retval=PRINT; X } X Xif(strncmp(command,"ra",2)==0) { /* RANK */ X retval=RANK; X } X Xif(strncmp(command,"re",2)==0) { /* READ */ X retval=READ; X } X Xif(strncmp(command,"se",2)==0) { /* SET */ X retval=SET; X } X Xif(strncmp(command,"ve",2)==0) { /* VERBOSE */ X retval=VERBOSE; X } X Xif(sscanf(command,"%[^>]>>%s",cmd,filename)==2) { /* append to file */ X /* format: command [options] >file */ X if((outfile=fopen(filename,"a"))==NULL) { /* cannot open file */ X fprintf(stderr,"cannot open %s\n",filename); X outfile=stdout; X } X } Xelse if(sscanf(command,"%[^>]>%s",cmd,filename)==2) { /* create file */ X /* format: command [options] >>file */ X if((outfile=fopen(filename,"w"))==NULL) { /* cannot open file */ X fprintf(stderr,"cannot open %s\n",filename); X outfile=stdout; X } X } X Xreturn(retval); X} X X X Xchar *zerfil(digival) Xint digival; X{ Xchar *retval=NULL; X Xif(retval==NULL) { X retval=(char *)malloc(8); X } X Xif(digival<10) { X sprintf(retval,"0%1d",digival); X } Xelse { X sprintf(retval,"%2d",digival); X } X Xreturn(retval); X} !EOR! echo extracting makefile sed 's/^X//' > makefile << '!EOR!' X# file: makefile X X# description: compilation and execution instructions for lottery analysis X# games. X X# author: Stewart Dickson X XBIN = /usr/local/tools X X# Build for Sun XCFLAGS = -DSUN XLDFLAGS = -lm X X# Build for SGI IRIS X#CFLAGS = -DIRIS X#LDFLAGS = -lm -Zg X Xlotto: lotto.c X cc lotto.c -o $(BIN)/lotto $(LDFLAGS) X Xlottodata: lottodata.o rd_lotto.o X cc lottodata.o rd_lotto.o -o $(BIN)/lottodata $(LDFLAGS) X Xlottodata.o: lottodata.c lotto.h X cc $(CFLAGS) -c lottodata.c X Xrd_lotto.o: rd_lotto.c lotto.h X cc -c $(CFLAGS) rd_lotto.c X X# the following generate sets of games using either of two methods X Xcalottodata: cal_lotto.in X lottodata 7/49 6/49 < cal_lotto.in X cat cal_lottodat.doc game.out | lpr X Xcalotto: cal_lotto7.doc X cat cal_lotto7.doc > game7.out X lotto -n 6 -r 49 49 |pr -t -2 -w80 -l66 >> game7.out X pr game7.out | lpr X Xillottodata: ill_lotto6.in X lottodata 6/44 6/44 < ill_lotto6.in X cat ill_lottodat.doc game.out | lpr X Xillotto: ill_lotto7.doc X cat ill_lotto7.doc > game7.out X lotto -n 7 -r 39 39 |pr -t -2 -w80 -l66 >> game7.out X pr game7.out | lpr !EOR! echo extracting rd_lotto.c sed 's/^X//' > rd_lotto.c << '!EOR!' X/* file: rd_lotto.c X X description: C module for reading an ASCII formatted file containing game X data for n/m number lotteries. n is the number of numbers X played per game, m is the range of numbers in drawings. X X author: Stewart Dickson X*/ X#include X#include "lotto.h" X Xstruct lotto *rd_lotto(datafile,datastruc,no_numbs) XFILE *datafile; Xstruct lotto *datastruc; Xint no_numbs; X{ Xextern FILE *outfile; Xextern int nogames; Xint game,stat,mon,day,yr,one,two,three,four,five,six,seven,lineno=0; Xunsigned datasize; X Xif(datafile==NULL) { X fprintf(stderr,"rd_lotto: ERROR - NULL file pointer received\n"); X exit(-1); X } X X X/* print out opening message */ Xfprintf(outfile," *************************************\n"); Xfprintf(outfile," * *\n"); Xfprintf(outfile," * %d/49 lottery analysis program *\n",no_numbs); Xfprintf(outfile," * *\n"); Xfprintf(outfile," * By Stewart Dickson *\n"); Xfprintf(outfile," * *\n"); Xfprintf(outfile," *************************************\n"); X Xif(datastruc==NULL) { X fprintf(stderr,"rd_lotto: NULL data struct received -- allocating\n"); X datasize=sizeof(struct lotto); X if((datastruc=(struct lotto *)malloc(datasize))==NULL) { X fprintf(stderr, X "rd_lotto: cannot allocate data struct size %d\n", X datasize); X exit(); X } X } X Xwhile((stat=fscanf(datafile, "%2d/%2d/%2d", &mon,&day,&yr)) != EOF) { X switch(no_numbs) { X case 6: { X stat += fscanf(datafile, " %2d %2d %2d %2d %2d %2d", X &one,&two,&three,&four,&five,&six); X if(stat < 9) { X fprintf(stderr,"rd_lotto: data format error line %d --",lineno); X fprintf(stderr, X " %2d/%2d/%2d %2d %2d %2d %2d %2d %2d\n",mon,day,yr, X one,two,three,four,five,six); X } X break; X } X case 7: { X stat += fscanf(datafile, " %2d %2d %2d %2d %2d %2d %2d", X &one,&two,&three,&four,&five,&six,&seven); X if(stat < 10) { X fprintf(stderr,"rd_lotto: data format error line %d --",lineno); X fprintf(stderr, X " %2d/%2d/%2d %2d %2d %2d %2d %2d %2d %2d\n",mon,day,yr, X one,two,three,four,five,six,seven); X } X break; X } X } X datastruc->game[lineno].mon=mon; X datastruc->game[lineno].day=day; X datastruc->game[lineno].yr=yr; X datastruc->game[lineno].number[0]=one; X datastruc->game[lineno].number[1]=two; X datastruc->game[lineno].number[2]=three; X datastruc->game[lineno].number[3]=four; X datastruc->game[lineno].number[4]=five; X datastruc->game[lineno].number[5]=six; X datastruc->game[lineno].number[6]=seven; X if(++lineno>=nogames) { /* allocate more games */ X fprintf(stderr,"rd_lotto: too many games %d\n",nogames); X exit(-1); X } X } Xnogames=lineno; X Xfprintf(outfile,"Data is based on %d drawings from",nogames); Xfprintf(outfile," %d/%d/%d to %d/%d/%d\n", X datastruc->game[0].mon, X datastruc->game[0].day, X datastruc->game[0].yr, X datastruc->game[nogames-1].mon, X datastruc->game[nogames-1].day, X datastruc->game[nogames-1].yr); X Xreturn(datastruc); X} !EOR! .