Need some help (basic turing user)
Author |
Message |
eomfe123
|
Posted: Sun Jun 20, 2010 12:38 pm Post subject: Need some help (basic turing user) |
|
|
I'm doing a simulation to see how long it would take to win the lottery. For example, a user picks 3 numbers and three random numbers are generated. I don't understand how to list all of the possible ways of them winning without it taking up a TON of space.
For example.. let's say the variables for the random numbers are :lottopick1,lottopick2,lottopick3
and they're pick are : userpick1,userpick2,userpick3
What would I need so that if all three of their picks matched up with the three lotto picks, in any order, it would count as them winning? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Monduman11
|
Posted: Sun Jun 20, 2010 1:44 pm Post subject: RE:Need some help (basic turing user) |
|
|
umm well use a randint for lottopic1, lottopic2m lottopick3, from the desired numbers so lets say ur doing 649 loto then do the randint(lottopic1, 1,49)
do that for all 3
and then to check if they match just do if lottopick1 = userpick1 or potopick1 = userpick2... u get the idea |
|
|
|
|
|
Cezna
|
Posted: Sun Jun 20, 2010 5:49 pm Post subject: RE:Need some help (basic turing user) |
|
|
Monduman is right on the dot.
You just need 6 variables, 3 randint lines, and 3 if statements.
You could even get away with :
[code="Turing]
if Rand.Int (0, 10) = userpick1 then
put "You got the first number right
end if
[/code]
Of course the 0 and 10 are just examples.
|
|
|
|
|
|
DtY
|
Posted: Sun Jun 20, 2010 6:14 pm Post subject: Re: RE:Need some help (basic turing user) |
|
|
Monduman11 @ Sun Jun 20, 2010 1:44 pm wrote: umm well use a randint for lottopic1, lottopic2m lottopick3, from the desired numbers so lets say ur doing 649 loto then do the randint(lottopic1, 1,49)
do that for all 3
and then to check if they match just do if lottopick1 = userpick1 or potopick1 = userpick2... u get the idea This is true, except that the same number will not be picked twice; if a 5 is picked on the first try, it will be guaranteed not to be picked on any of the next two draws, whereas this example does not guarantee that. |
|
|
|
|
|
Monduman11
|
Posted: Sun Jun 20, 2010 6:28 pm Post subject: Re: RE:Need some help (basic turing user) |
|
|
DtY @ Sun Jun 20, 2010 6:14 pm wrote: Monduman11 @ Sun Jun 20, 2010 1:44 pm wrote: umm well use a randint for lottopic1, lottopic2m lottopick3, from the desired numbers so lets say ur doing 649 loto then do the randint(lottopic1, 1,49)
do that for all 3
and then to check if they match just do if lottopick1 = userpick1 or potopick1 = userpick2... u get the idea This is true, except that the same number will not be picked twice; if a 5 is picked on the first try, it will be guaranteed not to be picked on any of the next two draws, whereas this example does not guarantee that.
this is just an example of couse he has to elaborate on it for it to work properly, plus i thought we arnt supposed to write the progam for others and let them figure it out for themselves thats why i didint write all the posibilities, instead i just gave him an example |
|
|
|
|
|
Cezna
|
Posted: Sun Jun 20, 2010 7:43 pm Post subject: Re: RE:Need some help (basic turing user) |
|
|
DtY @ Sun Jun 20, 2010 6:14 pm wrote: Monduman11 @ Sun Jun 20, 2010 1:44 pm wrote: umm well use a randint for lottopic1, lottopic2m lottopick3, from the desired numbers so lets say ur doing 649 loto then do the randint(lottopic1, 1,49)
do that for all 3
and then to check if they match just do if lottopick1 = userpick1 or potopick1 = userpick2... u get the idea This is true, except that the same number will not be picked twice; if a 5 is picked on the first try, it will be guaranteed not to be picked on any of the next two draws, whereas this example does not guarantee that.
Do you mean that the same number is not picked twice in the real lottery?
Aren't real lotteries normally a whole bunch of numbers? |
|
|
|
|
|
TheGuardian001
|
Posted: Sun Jun 20, 2010 7:52 pm Post subject: Re: RE:Need some help (basic turing user) |
|
|
Cezna @ Sun Jun 20, 2010 7:43 pm wrote: DtY @ Sun Jun 20, 2010 6:14 pm wrote: Monduman11 @ Sun Jun 20, 2010 1:44 pm wrote: umm well use a randint for lottopic1, lottopic2m lottopick3, from the desired numbers so lets say ur doing 649 loto then do the randint(lottopic1, 1,49)
do that for all 3
and then to check if they match just do if lottopick1 = userpick1 or potopick1 = userpick2... u get the idea This is true, except that the same number will not be picked twice; if a 5 is picked on the first try, it will be guaranteed not to be picked on any of the next two draws, whereas this example does not guarantee that.
Do you mean that the same number is not picked twice in the real lottery?
Aren't real lotteries normally a whole bunch of numbers?
Yes... Lotteries are a whole bunch of numbers. But there's generally only one of each. IE, you will never get "5 5 21 3 16" as a winner, because 5 cannot be chosen twice. It's like bingo. They don't let B5 be picked twice in a game. If it's already been chosen, then it won't ever come up again in that game. Likewise, you will never find a card with two B5's.
The only way to accomplish this is to continue to re-roll the number and compare it against the other picks until it is unique. |
|
|
|
|
|
Cezna
|
Posted: Sun Jun 20, 2010 7:59 pm Post subject: Re: RE:Need some help (basic turing user) |
|
|
TheGuardian001 @ Sun Jun 20, 2010 7:52 pm wrote: Cezna @ Sun Jun 20, 2010 7:43 pm wrote: DtY @ Sun Jun 20, 2010 6:14 pm wrote: Monduman11 @ Sun Jun 20, 2010 1:44 pm wrote: umm well use a randint for lottopic1, lottopic2m lottopick3, from the desired numbers so lets say ur doing 649 loto then do the randint(lottopic1, 1,49)
do that for all 3
and then to check if they match just do if lottopick1 = userpick1 or potopick1 = userpick2... u get the idea This is true, except that the same number will not be picked twice; if a 5 is picked on the first try, it will be guaranteed not to be picked on any of the next two draws, whereas this example does not guarantee that.
Do you mean that the same number is not picked twice in the real lottery?
Aren't real lotteries normally a whole bunch of numbers?
Yes... Lotteries are a whole bunch of numbers. But there's generally only one of each. IE, you will never get "5 5 21 3 16" as a winner, because 5 cannot be chosen twice. It's like bingo. They don't let B5 be picked twice in a game. If it's already been chosen, then it won't ever come up again in that game. Likewise, you will never find a card with two B5's.
The only way to accomplish this is to continue to re-roll the number and compare it against the other picks until it is unique.
Ohhhhhh, I thought we were just talking about say 12 random one digit numbers, and you match each number to win, but we are talking about multidigit numbers (that may not be a word, but it is the best way to get my idea across).
I understand now. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
|
|