whitesandsbeach
asked on
Chance of Guessing Seven Digit Codes?
Hi:
I having an event for kids where they "find" seven digit codes (generated randomly with a password generator) and put them into a database I built to see if they are winners. There will be about 1,500 codes and several hundred winners. A person helping me thinks the kids will sit at the computer and try codes until they guess the winning ones. What are the chances of that?
Thanks,
WSB
I having an event for kids where they "find" seven digit codes (generated randomly with a password generator) and put them into a database I built to see if they are winners. There will be about 1,500 codes and several hundred winners. A person helping me thinks the kids will sit at the computer and try codes until they guess the winning ones. What are the chances of that?
Thanks,
WSB
It depends on how smart the kids are. My guess is pretty high (like almost a certainty). You can easily gererate all possible conbinatins of 7 digits. (are you just using numbers or do you allow letters too?) It may however take a while to input these combinations into your program. You might limit the allowed number of guesses to a small number per hour, day , or week.
ASKER
Thanks for answering.
The kids will not be allowed any guesses. They will only be allowed to enter the codes they find during the event. There is only one computer available for checking codes and the kids will only be allowed to check codes during designated times for a total 3.5 hours per week and they'll be under staff supervision. The other worker thinks they'll try to enter codes they've made up when no one is looking. The codes are all numbers.
The kids will not be allowed any guesses. They will only be allowed to enter the codes they find during the event. There is only one computer available for checking codes and the kids will only be allowed to check codes during designated times for a total 3.5 hours per week and they'll be under staff supervision. The other worker thinks they'll try to enter codes they've made up when no one is looking. The codes are all numbers.
the possiblity of a random code being one of the 1500 winnwers is
1.5x10^3/10^7 = 1.5x10^(-4)
which is
0.00015 or 1 in 6666.67
ie really remote. By typing in a 100 hundred numbers they still only have a 1 in 6.67 chance of getting a winner
1.5x10^3/10^7 = 1.5x10^(-4)
which is
0.00015 or 1 in 6666.67
ie really remote. By typing in a 100 hundred numbers they still only have a 1 in 6.67 chance of getting a winner
Sorry my last staement is not correct
The chances of guessing a correct number is .00015 ()
So the chances of not guessing a correct number is 1 - 0 .00015 = 0.99985 (ie 1 to 6666.67)
So for instance the chances of not guessing a correct number 100 times in a row is (0.99985)^100 = 0.9851 (1000 to 1015 )
ie 1000 times out of 1015 attempts at trying 100 sets of numbers you do not get 1 right in
In short the chances of the kids guessing a number are remote
The chances of guessing a correct number is .00015 ()
So the chances of not guessing a correct number is 1 - 0 .00015 = 0.99985 (ie 1 to 6666.67)
So for instance the chances of not guessing a correct number 100 times in a row is (0.99985)^100 = 0.9851 (1000 to 1015 )
ie 1000 times out of 1015 attempts at trying 100 sets of numbers you do not get 1 right in
In short the chances of the kids guessing a number are remote
ASKER
Thanks! That's what I wanted, the odds, like 1 in whatever.
However, there will be a total of 1,500 codes distributed. Only 200 will be winners. Only the 200 winning codes will be in the database. Anything entered other than winning codes (those that are distributed or those made up) will show a screen that says you lost.
Would it be possible to do the odds for me on that?
I increased the points.
Thanks again,
WSB
However, there will be a total of 1,500 codes distributed. Only 200 will be winners. Only the 200 winning codes will be in the database. Anything entered other than winning codes (those that are distributed or those made up) will show a screen that says you lost.
Would it be possible to do the odds for me on that?
I increased the points.
Thanks again,
WSB
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I can write a webpage to check the numbers and one to generate the tickets if that is what you need? It will not take me long.
Here are a couple of web pages. If you can copy and paste these 2 scripts into notepad, save as .htm files and then open in a browser(just click on their icon) you are up and running. The first will generate the numbers for you and the second is a page to test for a winner. Any problems let me know
This generates the numbers, I have used a big font so you can cut them out
<script>
spacer='<font color="#FFFFFF">....</font >'
seed=1234 //choosing a different value gives a different set of values
a=new Array()
for (i=0;i<1500;i++){
seed=(27751*seed+1051)%104 729
num=Math.floor(10000000*se ed/104729)
while ((num+'').length <7) num='0'+num
document.write('<big><big> '+num+spac er+'</big> </big>')
if ((i+1)%8 ==0) document.write('<p>')
}
</script>
__________________________ __________ __________ __
This one will test the numbers for a winners (example winners from the above are 9942900 5525117 7627973 3983232 8796990 )
<script>
// Generate winners (the 1st 200 of the 1500)
numArray=new Array()
seed=1234 //this number must be the same as that in the program that generated them
for (i=0;i<200;i++){
seed=(27751*seed+1051)%104 729
num=Math.floor(10000000*se ed/104729)
while ((num+'').length <7) num='0'+num
numArray[i]=num
}
//This function tests
function test(num){
for (i=0;i<200;i++){
if (num==numArray[i]) alert("CONGRATULATIONS your number "+num+" is a winner!!!")
return
}
alert( "Sorry our number "+num+" is not a winner")
}
</script>
<body>
<p align="center"><u><font face="Arial" color="#FF0000"><strong><b ig><big><b ig><big>We lcome
to the winning ticket tester</big></big></big></ big></stro ng></font> </u></p>
<p align="center"><font color="#000080"><big>Type in your 7 digit number and click the
button</big></font></p>
<p align="center"> </p>
<p align="center"> </p>
<form>
<div align="center"><center><p>
<input size="7" style="font-size:16pt" name="num">
<input type="button" onclick="test(num.value)" value="Test Number" style="font-size:12pt" )
</form> </p>
</center></div>
</form>
</body>
This generates the numbers, I have used a big font so you can cut them out
<script>
spacer='<font color="#FFFFFF">....</font
seed=1234 //choosing a different value gives a different set of values
a=new Array()
for (i=0;i<1500;i++){
seed=(27751*seed+1051)%104
num=Math.floor(10000000*se
while ((num+'').length <7) num='0'+num
document.write('<big><big>
if ((i+1)%8 ==0) document.write('<p>')
}
</script>
__________________________
This one will test the numbers for a winners (example winners from the above are 9942900 5525117 7627973 3983232 8796990 )
<script>
// Generate winners (the 1st 200 of the 1500)
numArray=new Array()
seed=1234 //this number must be the same as that in the program that generated them
for (i=0;i<200;i++){
seed=(27751*seed+1051)%104
num=Math.floor(10000000*se
while ((num+'').length <7) num='0'+num
numArray[i]=num
}
//This function tests
function test(num){
for (i=0;i<200;i++){
if (num==numArray[i]) alert("CONGRATULATIONS your number "+num+" is a winner!!!")
return
}
alert( "Sorry our number "+num+" is not a winner")
}
</script>
<body>
<p align="center"><u><font face="Arial" color="#FF0000"><strong><b
to the winning ticket tester</big></big></big></
<p align="center"><font color="#000080"><big>Type in your 7 digit number and click the
button</big></font></p>
<p align="center"> </p>
<p align="center"> </p>
<form>
<div align="center"><center><p>
<input size="7" style="font-size:16pt" name="num">
<input type="button" onclick="test(num.value)" value="Test Number" style="font-size:12pt" )
</form> </p>
</center></div>
</form>
</body>
opps sorry there is a mistake in the second script it should be
<script>
// Generate winners (the 1st 200 of the 1500)
numArray=new Array()
seed=1234 //this number must be the same as that in the program that generated them
for (i=0;i<200;i++){
seed=(27751*seed+1051)%104 729
num=Math.floor(10000000*se ed/104729)
while ((num+'').length <7) num='0'+num
numArray[i]=num
}
//This function tests
function test(num){
for (i=0;i<200;i++){
if (num==numArray[i]){
alert("CONGRATULATIONS your number "+num+" is a winner!!!")
return
}
}
alert( "Sorry our number "+num+" is not a winner")
}
</script>
<body>
<p align="center"><u><font face="Arial" color="#FF0000"><strong><b ig><big><b ig><big>We lcome
to the winning ticket tester</big></big></big></ big></stro ng></font> </u></p>
<p align="center"><font color="#000080"><big>Type in your 7 digit number and click the
button</big></font></p>
<p align="center"> </p>
<p align="center"> </p>
<form>
<div align="center"><center><p>
<input size="7" style="font-size:16pt" name="num">
<input type="button" onclick="test(num.value)" value="Test Number" style="font-size:12pt" )
</form> </p>
</center></div>
</form>
</body>
<script>
// Generate winners (the 1st 200 of the 1500)
numArray=new Array()
seed=1234 //this number must be the same as that in the program that generated them
for (i=0;i<200;i++){
seed=(27751*seed+1051)%104
num=Math.floor(10000000*se
while ((num+'').length <7) num='0'+num
numArray[i]=num
}
//This function tests
function test(num){
for (i=0;i<200;i++){
if (num==numArray[i]){
alert("CONGRATULATIONS your number "+num+" is a winner!!!")
return
}
}
alert( "Sorry our number "+num+" is not a winner")
}
</script>
<body>
<p align="center"><u><font face="Arial" color="#FF0000"><strong><b
to the winning ticket tester</big></big></big></
<p align="center"><font color="#000080"><big>Type in your 7 digit number and click the
button</big></font></p>
<p align="center"> </p>
<p align="center"> </p>
<form>
<div align="center"><center><p>
<input size="7" style="font-size:16pt" name="num">
<input type="button" onclick="test(num.value)" value="Test Number" style="font-size:12pt" )
</form> </p>
</center></div>
</form>
</body>
> A person helping me thinks the kids will sit at the computer and try codes until they guess the winning ones. What are the chances of that?
Gwyn did well.
but about kids sitting next to the computer and checking successive numbers, the probability changes up to number of N = number of different 7-digit numbers the kids tried :
note : 10M = 10,000,000
Prob(N numbers failed) = (1-200/10M)*(1-200/(10M-1) )*...*(1-2 00/(10M-N) )
50% = about 34,600 different numbers should be checked, to reach 50% probability =>
even if the kids will check 34,600, they will have 50% of finding NOTHING, and 50% of finding at least on number (it would be probably just 1, since the probability to have 2 or more, exponentially decreased)
Gwyn did well.
but about kids sitting next to the computer and checking successive numbers, the probability changes up to number of N = number of different 7-digit numbers the kids tried :
note : 10M = 10,000,000
Prob(N numbers failed) = (1-200/10M)*(1-200/(10M-1)
50% = about 34,600 different numbers should be checked, to reach 50% probability =>
even if the kids will check 34,600, they will have 50% of finding NOTHING, and 50% of finding at least on number (it would be probably just 1, since the probability to have 2 or more, exponentially decreased)
I'd worry more about them hacking into the database to find the valid codes ...
:-)
BTW 200/10^7 is not 1 in 200000 but 1 in 50000 chance of any one guess being correct. If this is high enough to worry you, just make the codes longer. Each extra digit makes it 10 times harder to guess.
:-)
BTW 200/10^7 is not 1 in 200000 but 1 in 50000 chance of any one guess being correct. If this is high enough to worry you, just make the codes longer. Each extra digit makes it 10 times harder to guess.
>> I'd worry more about them hacking into the database to find the valid codes ...
My thoughts exactly heh :
select winning_number from number_table
lol
My thoughts exactly heh :
select winning_number from number_table
lol