Skip to content

Instantly share code, notes, and snippets.

@echojc
Last active December 15, 2015 05:58
Show Gist options
  • Save echojc/5212393 to your computer and use it in GitHub Desktop.
Save echojc/5212393 to your computer and use it in GitHub Desktop.
Simple empirical test of birthday problem probabilities.
def bday = new Random().nextInt(365)
def uniq(n: Int) = (1 to n).map(_ => bday).distinct.size == n
def puniq(n: Int, c: Int = 1000000) = (1 to c).map(_ => uniq(n)).count(_ == true).toDouble / c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment