Tuesday, September 4, 2012
Lotto Number Picker
There is something to be said for a well written plan. It's easy to follow through. OTOH, there is more than one way to skin a cat, and there's more than one way to code a program.
This Petit Computer program was done while docked at King Sooper, waiting to be unloaded. It's very easy to do, and it is proof that computer programming can be convenient, fun, and with potential of great reward!
Look at the algorithm and see if you can follow the code! Feel free to modify to suit!
'LOTTO NUMBER PICKER
'1. TITLE AND INITIALIZATIONS
'2. FILL BALL ARRAY 1 TO MAXNUM
'3. RANDOMIZE BALL ARRAY
'4. FOR I=1 TO NUMBER OF BALLS
'4.1 IF BALL NUMBER < 10, ADD LEADING ZERO
'4.2 APPEND TO TICKET ARRAY STRING
'5. REPEAT STEPS 3-4 UNTIL NUMBER OF TICKETS
'6. FOR I=1 TO NUMBER OF TICKETS
'6.1 PRINT TICKET$ ARRAY. ONE PER LINE
'7. PRESS ANY KEY TO CONTINUE. BACK TO TOP
?"(C) 2012 Harry M. Hardjono"
NB=6:'NUMBER OF BALLS
NT=20:'NUMBER OF TICKETS
REM THEN A MIRACLE OCCURS...
FOR I=0 TO NB*NT-1:C$=CHR$(RND(MN)+101)
IF !(I%NB) THEN LOCATE 0,I/NB+3:S$="":COLOR I/NB/3%2+4
IF 0>INSTR(S$,C$) THEN ?RIGHT$(STR$(ASC(C$)),2);" ";:S$=S$+C$ ELSE I=I-1
FOR I=0 TO 1:I=TCHST OR BUTTON(0):NEXT