Skip to content

Instantly share code, notes, and snippets.

@zfogg
Created September 24, 2012 22:28
Show Gist options
  • Save zfogg/3778844 to your computer and use it in GitHub Desktop.
Save zfogg/3778844 to your computer and use it in GitHub Desktop.
The answer to 'The Birthday Problem'
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