Fresh out of college, you're throwing a huge party to celebrate with friends and family. Over 70 people have shown up, including your mildly eccentric Uncle Ted.
In one of his usual antics, he bets you £100 that at least two people in the room share the same birthday. That sounds ridiculous — there are many more possible birthdays than there are guests, so you confidently accept.
To your astonishment, after collecting the birthdays of just 32 guests, you've already found two guests that share the same birthday. Accepting your loss, you hand Uncle Ted his £100, but something feels off.
The next day, curiosity gets the better of you. A quick web search leads you to the birthday paradox, which reveals that with just 23 people, the probability of a shared birthday exceeds 50%.
Ah. So that's why Uncle Ted was so confident.
Determined to turn the tables, you start looking up other paradoxes; next time, you'll be the one making the bets.
The birthday paradox is a veridical paradox: even though it feels wrong, it is actually true.
Your task is to estimate the birthday paradox's probabilities.
To do this, you need to:
A birthdate includes the full date of birth (year, month, and day), whereas a birthday refers only to the month and day, which repeat each year. Two birthdates with the same month and day correspond to the same birthday.
The birthday paradox assumes that:
Your implementation must follow these assumptions.
The function random_birthdates() should produce dates with the following properties:
y is non-leap and so that 1600 <= y < 2129.Both the year and birthday distributions are checked by a chi-squared test, at the level of p < 0.0001.
This means that if the dates are being generated according to the instructions, there's less than a 0.01% chance of it producing a distribution of values that fails the test.
Sign up to Exercism to learn and master x86-64 Assembly with 22 concepts130 exercises, and real human mentoring, all for free.