Page 1 of 1

Lottery question

Posted: Sat Dec 03, 2005 7:40 pm
by How would you do a lotto?
How would you write a program that randomly generates a lottery pick automatically based on the following restrictions:
1. Each pick consists of 6 lottery numbers.
2. Lottery numbers must be between 1 through 50
3. All six lottery numbers must be unique within any pick.

Posted: Sat Dec 03, 2005 8:11 pm
by Z!re
I would listen to my teacher, then read the textbook..

Ya.. that's what I'd do..

Posted: Sat Dec 03, 2005 8:54 pm
by Deleter
Z!re wrote:I would listen to my teacher, then read the textbook..

Ya.. that's what I'd do..
I would go straight to reading the textbook, personally...but in general thats good advice. :)

Posted: Sun Dec 04, 2005 4:28 pm
by {Nathan}
^^ I would quit the class...

Re: Lottery question

Posted: Sun Dec 04, 2005 4:54 pm
by Seb McClouth
How would you do a lotto? wrote:How would you write a program that randomly generates a lottery pick automatically based on the following restrictions:
1. Each pick consists of 6 lottery numbers.
2. Lottery numbers must be between 1 through 50
3. All six lottery numbers must be unique within any pick.
I would try to write something... listen to my teacher... listen to my teacher... and listen to my teacher... if it still sucks... I'd post it here... ask ppl to check it out...

Oh and do ask my teacher about it...

Posted: Tue Dec 06, 2005 3:32 pm
by PQBC says 'Hi!'
Z!re:
1. Is he a user that comes often?
2. Where did you get that avatar and why?

Here you go dude!

Posted: Tue Dec 06, 2005 4:15 pm
by QBGV

Code: Select all

CLS
RANDOMIZE TIMER
num=0
numa=0
numb=0
numc=0
numd=0
nume=0
do
num=int(rnd*50+1)
loop until num<>numa and num<>b and num<>numc and num<>numd and num<>nume
''now do this 6 times and replace num with numa, then numb, then numc, etc, and change the num<>whatever to numa<>whatever, numb<>whatever,etc, and make sure
''not do do numa<>numa, numb<>numb, etc

Posted: Tue Dec 06, 2005 10:38 pm
by Z!re
PQBC says 'Hi!' wrote:Z!re:
1. Is he a user that comes often?
2. Where did you get that avatar and why?
1. No
2. A warcraft III: the frozen throne custom minimap

Lottery question

Posted: Wed Dec 07, 2005 11:27 pm
by Atrapado
thank you?
welcome

Code: Select all

RANDOMIZE TIMER
DIM thelist(50) AS INTEGER
DIM picks(6) AS INTEGER

FOR aaa = 1 TO 6
repeat: bbb = INT(RND * 50) + 1
IF thelist(bbb) = 1 THEN GOTO repeat
thelist(bbb) = 1
NEXT aaa

ccc = 0
FOR aaa = 1 TO 50
IF thelist(aaa) = 1 THEN
ccc = ccc + 1: picks(ccc) = aaa
END IF
NEXT aaa

FOR aaa = 1 TO 6
PRINT picks(aaa);
NEXT aaa
PRINT

system