Everyone in a room has a birthday on one of days equally likely days: 365 on Earth, and the puzzle also visits a planet with a 30-day year and one with a 10-day year. Write chance_shared(people, days): the chance, from 0 to 1, that at least two of the people in the room share a birthday.
A room of 23 people on Earth, each birthday dropping onto its day. The obvious guess, 23 out of 365, says 6%; 100 rooms like it say otherwise, and adding up a chance per pair runs past 100%. The goal is the exact chance those rooms point to. Your chance_shared() works it out for any room and any calendar.
chance_shared(people, days)| people | how many people are in the room | e.g. 1 |
| days | how many equally likely birthdays there are (365 on Earth) | e.g. 365 |
| returns | the chance, from 0 to 1, that at least two of them share a birthday | |