My girlfriend have one of those numerous strange habbits girls have.
When we buy bus tickets, she counts ticket numbers to find out if one of us got a "lucky" one.
Ticket number are all 6 digits, e.g. "ABC DEF".
If A + B + C = D + E + F, the ticket is considered "lucky".
There, I got this thought, how many "lucky" tickets could be there?
I've tried to make a simple script to perform exhaustive search, but it hanged my browser.
So I changed it a bit (introduced search "granularity") to pick and test few numbers at random, and extrapolate results back onto all possible combinations:
<SCRiPT>
s = ""; htN = 0; N = 0; g = 250
for(i = 1000000; i < 2000000; i += Math.round(g * Math.random()), N++)
if(parseInt(i.toString().substr(1,1)) +
parseInt(i.toString().substr(2,1)) +
parseInt(i.toString().substr(3,1)) ==
parseInt(i.toString().substr(4,1)) +
parseInt(i.toString().substr(5,1)) +
parseInt(i.toString().substr(6,1)) ) { htN++; s += "<BR>" +
i.toString().substr(1,1) +
i.toString().substr(2,1) +
i.toString().substr(3,1) +
i.toString().substr(4,1) +
i.toString().substr(5,1) +
i.toString().substr(6,1); }
document.write(s + "<BR>" + htN + " (" + (htN*1000000/N) + ") out of " + N + " (1000000)");
</SCRiPT>
The output of this script was:
g = 500
225 (56207.84411691232) out of 4003 (1000000)
232 (57582.5266815587) out of 4029 (1000000)
215 (54033.67680321689) out of 3979 (1000000)
225 (56334.501752628945) out of 3994 (1000000)
g = 250
439 (54663.18017681484) out of 8031 (1000000)
414 (52518.07687428644) out of 7883 (1000000)
437 (54899.497487437184) out of 7960 (1000000)
469 (58964.04324867991) out of 7954 (1000000)
so resulting probability estimation 5.5% seems to be pretty stable.
This is where I left it. Now, I want you to present exact mathematical estimation (proove, formula and the number). A non-brute-force script to produce all combinations would be nice, but not necessary (considering that I am totally out of points ;).
My brute force script says that of the 1 million possible numbers, 55252 are 'lucky.'
There are 1000 possible 3-digit numbers. The sum of 3 digits range from 0 to 27. A few moments in Excel gives us the following distribution:
0 Count 1
1 Count 3
2 Count 6
3 Count 10
4 Count 15
5 Count 21
6 Count 28
7 Count 36
8 Count 45
9 Count 55
10 Count 63
11 Count 69
12 Count 73
13 Count 75
14 Count 75
15 Count 73
16 Count 69
17 Count 63
18 Count 55
19 Count 45
20 Count 36
21 Count 28
22 Count 21
23 Count 15
24 Count 10
25 Count 6
26 Count 3
27 Count 1
The odds of getting a lucky '0' are (1/1000)². The odds of getting a lucky '1' are (3/1000)². Sum these odds together, and we get 5.5252%, which is what the brute force method suggested.
>> snoyes_jw Sorry for the crossed posts. Long live Excel.
0
This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.
snoyes_jw you said "5.5252%" that yields 55,252 combinations, and d-glitch you said "5.525 percent" that yields 55,250 combinations ???
also, numbers - "A few moments in Excel gives us the following distribution" and "They are not evenly distributed. Here is a brute force solution with Excel" do not explain how did you get these numbers.
And you said: resulting probability estimation 5.5% which means 55,500 combinations????
My method and solution are identical to those of snoyes_jw.
I rounded my answer to four significant figures.
He gave you all five, which is certainly proper in this case.
0
Question has a verified solution.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.
There are 1000 possible 3-digit numbers. The sum of 3 digits range from 0 to 27. A few moments in Excel gives us the following distribution:
0 Count 1
1 Count 3
2 Count 6
3 Count 10
4 Count 15
5 Count 21
6 Count 28
7 Count 36
8 Count 45
9 Count 55
10 Count 63
11 Count 69
12 Count 73
13 Count 75
14 Count 75
15 Count 73
16 Count 69
17 Count 63
18 Count 55
19 Count 45
20 Count 36
21 Count 28
22 Count 21
23 Count 15
24 Count 10
25 Count 6
26 Count 3
27 Count 1
The odds of getting a lucky '0' are (1/1000)². The odds of getting a lucky '1' are (3/1000)². Sum these odds together, and we get 5.5252%, which is what the brute force method suggested.