Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utcsrgv.UUCP Path: utzoo!utcsrgv!dave From: dave@utcsrgv.UUCP (Dave Sherman) Newsgroups: net.sources Subject: Lotto 6/49 number allocation program for office pools Message-ID: <3083@utcsrgv.UUCP> Date: Tue, 10-Jan-84 14:14:35 EST Article-I.D.: utcsrgv.3083 Posted: Tue Jan 10 14:14:35 1984 Date-Received: Tue, 10-Jan-84 14:53:07 EST Distribution: can Organization: The Law Society of Upper Canada, Toronto Lines: 225 The staff in the office here are playing Loto 6/49 this week (seems like everyone is), and they drafted me to have the computer sort the numbers. Everyone who is playing put in $1 and selected 6 numbers, but if there's a winner they don't want anyone to be able to say "those are my numbers". So the problem was to put ALL the numbers selected into a pot, and to generate 6-number tickets from that pot. Here's my half-hour hack for anyone who's interested. (The getline() and yes() routines are from another package, which is why they look more complex than they might have to be.) Change /dev/console to whatever file you want to use to save the tickets generated. Dave Sherman Toronto ======================================================================== /* * lotto - let people put their chosen lottery numbers into a * pot and generate tickets * * Dave Sherman * The Law Society of Upper Canada * Toronto * utcsrgv!lsuc!dave (also utcsrgv!dave at U of Toronto) */ #include int *a; int array[180] = { 0 }; long now; FILE *printer; int ticket[6]; int totalnums; char buffer[256]; main() { register i, j; register sets; int try; printf("Hello.\n\n"); printf("This is your friendly computer speaking.\n"); printf("Today I'm going to help you win the lottery.\n"); if(yes("\n\nDo you want to let me help you win Loto 6/49? ") == 0) { printf("Spoilsport!\n"); exit(1); } printer = fopen("/dev/console", "w"); if(printer == NULL) { printf("Sorry, I can't get the printer open.\n"); } fprintf(printer, "\n COMPUTER-SORTED LOTTERY NUMBERS\n\n"); printf("\n"); sleep(1); start: printf("\nOK, let's start.\n\nHow many sets of six numbers do you have?\n"); getline(buffer); sets = atoi(buffer); if(yes("You have %d sets of numbers, then, is that right? ", sets) == 0) { printf("Oh. I must have misunderstood you.\n\n\n"); goto start; } totalnums = sets * 6; next: printf("\nNow you have to tell me what the numbers are.\n\n"); sleep(1); for(i=0; i