PDA

View Full Version : Lottery


Little_C
11-13-2003, 07:11 PM
Contest:
Write a program(any language) that:
1. Gets input from the user, four numbers from 1 to 500,000.
2. Creates random numbers (the winning numbers) and sees how many lottery tickets that person would buy to win the lottery.
3. There is no #3

Any extras can be thrown in, too.

Here's my entry, in good ol' MetaL:


'Lottery
cls:x=0
randomize timer
print "Pick four number between 1 and 500000"
input Zeus
input Ares
input Apollo
input Mars
a=random(500000)
b=random(500000)
c=random(500000)
d=random(500000)
cls
DO UNTIL Zeus=a and Ares=b and Apollo=c and Mars=d
keymap scan
locate 1,1
print "Purchased ";:? x;:? " lottery tickets"
x=x+1
if keymap key("q") or keymap key("Q") then goto outofloop
LOOP:cls
outofloop:
print "You have won the jackpot! ";:? "Too bad it took ";:?x;:? " Times!"


Output can be included, if you want (i'll have mine up in a little while).
Any complaints (Tygur, I know i'll be hearing from you, lol, j/k) can be posted below.

DNAunion2000
11-13-2003, 09:12 PM
/*DNAunion*/ I don't think anyone's going to win that lottery!

If the person guessing the numbers has no idea what they are, and the numbers are selected truly randomly, then the probability of getting all 4 correct in a single shot is 0.000002^4, or about 1 chance in 1.6 x 10^23. That is, 1 chance in 160,000,000,000,000,000,000,000. Even if a person entered a set of 4 numbers every second, of every minute, or every hour, of every day, of every year, since birth, he'd expire a long time before entering enough sets to have a reasonable chance of success.

MJPhill
11-13-2003, 10:01 PM
Agreed, it would probably be more appropriate to create a game that told you if you had to guess higher or lower.

Little_C
11-14-2003, 06:35 PM
Originally posted by DNAunion2000
/*DNAunion*/ I don't think anyone's going to win that lottery!

If the person guessing the numbers has no idea what they are, and the numbers are selected truly randomly, then the probability of getting all 4 correct in a single shot is 0.000002^4, or about 1 chance in 1.6 x 10^23. That is, 1 chance in 160,000,000,000,000,000,000,000. Even if a person entered a set of 4 numbers every second, of every minute, or every hour, of every day, of every year, since birth, he'd expire a long time before entering enough sets to have a reasonable chance of success.

Update
Due to recent knowledge (see above) I've decieded to amke the contest more... possible
I'll reduce it to one number, and.... between one and 100,000. It will tell higher or lower.
It was a joke I thought up at school; I showed some friends how it worked, poking fun at the lotteries' chances of being won.