Pick your spot in line

A movie theater manager announces a deal: the first person in line whose birthday matches someone who already bought a ticket wins a free ticket. You can choose any position. Which spot maximizes your chance of winning?

What do you think?
Which position in line gives you the best chance of winning the free ticket?

Watch a single trial unfold

Before doing any math, let's see what one round of this game actually looks like. People step up one at a time, reveal their birthday, and we check for a match:

Watch a trial unfold

Notice the tension. Early on, there are very few birthdays ahead — a match is unlikely. Later, there are many birthdays ahead, but by then someone else may have already matched first. Your ideal position is somewhere in between.

Running many trials

Now run hundreds of trials at once and see which position wins most often:

Birthday Line Simulator
Trials
0
Win rate
Theory P(n)
3.23%

If you've seen the birthday paradox, this problem is a close relative. But instead of asking "does any pair match?", it asks "does person nn match someone among the first n1n-1, given no earlier match occurred?"

Two competing forces

Why is there a sweet spot around position 20? Two forces compete as you move further back in line:

Two competing forces
P(no earlier match)P(your match)P(win) × 3011020304050Position n0%25%50%75%100%
P(no earlier match)
62.1%
P(your match)
5.21%
P(you win)
3.232%

The green product curve — your actual winning probability — rises then falls. The peak is where the "more birthdays to match" benefit exactly balances the "earlier collision risk."

Visualizing P(n) for every position

Here's P(n)P(n) plotted for every position from 1 to 50:

P(you win) by position
11020304050Position n0%1%2%3%n=20 (3.23%)
Optimal position: n = 20 with P = 3.232%

The curve rises as nn grows (more birthdays to match) then falls (too likely someone else already matched). The peak is at n=20n = 20.

Setting up the formula

Now let's make this precise. Suppose you choose to be the nn-th person in line. For you to win:

  1. No earlier match: The first n1n-1 people must all have different birthdays
  2. Your birthday matches: Your birthday must equal one of those n1n-1 distinct birthdays

These are independent (your birthday is chosen after theirs), so:

P(n)=365365364365365n+2365first n1 all different×n1365yours matches oneP(n) = \underbrace{\frac{365}{365} \cdot \frac{364}{365} \cdots \frac{365 - n + 2}{365}}_{\text{first } n-1 \text{ all different}} \times \underbrace{\frac{n-1}{365}}_{\text{yours matches one}}

The first factor is the probability that n1n-1 people all have distinct birthdays — exactly the complement of the birthday problem. The second factor is the chance your birthday is among those n1n-1 distinct ones.

Finding the peak: when does P(n) start declining?

When nn is small, adding one more person ahead of you helps because the extra birthday to match outweighs the slightly higher risk of an earlier collision. At some point, the collision risk overtakes. We need to find the transition.

We want the crossover point: the nn where P(n)>P(n1)P(n) > P(n-1) but P(n)>P(n+1)P(n) > P(n+1).

Finding the optimal position
P(n)=365!(365n+1)!365n1n1365P(n) = \frac{365!}{(365 - n + 1)! \cdot 365^{n-1}} \cdot \frac{n-1}{365}
The formula combining 'all different' and 'yours matches'.
Step 1 of 6

This ratio plot makes the crossover visible. When the ratio drops below 1, moving further back in line hurts:

Ratio P(n+1) / P(n)
1.0crossover at n=20510152025303540Position n

When the ratio drops below 1, moving further back hurts more than it helps.

Unimodal Sequence

A sequence a1,a2,a_1, a_2, \ldots is unimodal if it first increases then decreases (possibly with a flat plateau at the peak). P(n)P(n) for the birthday line problem is unimodal, which is why there's a single optimal position.

The answer

n=20\boxed{n = 20}

You should be the 20th person in line, giving you a winning probability of about 3.23%.

That probability seems low — only about 1 in 31. But it's the best you can do. Any other position gives you a strictly lower chance.

What do you think?
What is P(20) approximately?
decimal like 0.032

Connection to the birthday paradox

In the classic birthday problem, with 23 people the probability of some match exceeds 50%. Here, we're asking something stricter: not just "does a match exist?" but "is person nn specifically the first match?" The answer n=20n = 20 appears before the famous 23, which makes sense — we need the match to happen at our position, not just anywhere.

ProblemKey questionAnswer
Birthday paradoxP(any match in group of nn) ≥ 50%n=23n = 23
Birthday lineWhich nn maximizes P(person nn is first match)?n=20n = 20

Competition appearances

This problem appears in:

  • Quant finance interviews (Jane Street, Two Sigma): tests conditional probability reasoning
  • AMC/AIME preparation: unimodal optimization over discrete distributions
  • Putnam training sets: the ratio test technique for finding discrete maxima
  • Programming contests: efficient computation of birthday probability products
What is P(2), the probability of winning in position 2? (decimal like 0.003)
What is P(3)? (decimal like 0.005)
In a year with 100 days (instead of 365), what position would be optimal? (integer like 11)

Takeaway

The birthday line problem extends the famous birthday paradox by pinning down who gets the first match. The product of "no earlier collisions" times "your collision probability" creates a unimodal curve peaking at position 20. The ratio test — comparing P(n+1)/P(n)P(n+1)/P(n) to 1 — is a general technique for finding peaks in discrete probability sequences.