Created
September 24, 2012 22:28
-
-
Save zfogg/3778844 to your computer and use it in GitHub Desktop.
The answer to 'The Birthday Problem'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
randomBirthdays = (n) -> | |
r = {} | |
for i in [1..n] | |
r[Math.floor Math.random() * 364 + 1] = true | |
k for k,v of r | |
do -> | |
n = 23; sum = 0 | |
for i in [0..Math.pow 10, 4] | |
if n != (randomBirthdays n).length | |
sum++ | |
console.log sum/i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment