While reading through about the birthday problem on Wikipedia, I came across some of the variations described in formulating the problem, notably
Another generalization is to ask how many people are needed in order to have a better than 50% chance that two people have a birthday within one day of each other, or within two, three, etc., days of each other.
A related question is, as people enter a room one at a time, which one is most likely to be the first to have the same birthday as someone already in the room? That is, for what $n$ is $p(n) − p(n − 1)$ maximum? The answer is 20—if there's a prize for first match, the best position in line is 20th.
So a question would be, which position in the line of people entering the room has the highest probability of the person at that position having a birthday within 2, (or say $k$) days of somebody already in the room?
What about for the problem with 3 people? What positions would have the highest probability of winning the prize, if there is a prize for the first triplet that share the same birthday?
Say as people enter the room, \$100 is awarded to the first person (called A) who enters the room and shares a birthday with someone already in the room, and \$1000 is awarded to the first person (called B) who enters the room and shares the same birthday with two people already present (not necessarily A). Then which positions yield the best chances of winning the \$100 or the \$1000?
The maths for this is probably quite wrangled. I don't mind if somebody uses a simulation to answer my questions. Preferably code that is easily portable, like Python or Fortran, maybe C or Matlab.
This could keep on getting more complicated. How many people do we need in a room before the chances of three people having birthdays within a day of each other exceeds 50%? And again, if we have people troop into the room sequentially, which positions stand the best chance of being in that triplet?
When I learnt of this simple fact in first year maths I didn't think it had so many interesting shades!