ExplorationsPenney’s game: whatever pattern the first player bets on, the second can answer with a better one
The Coin Bet You Can Always Beat
Two players each bet on a pattern of three coin flips, such as HHT. The first player chooses, then the second. One fair coin is then flipped over and over, both players watching the same flips, and whoever’s pattern turns up first in the run wins. Whatever the first player bets, the second can reply so as to win at least 2 games in 3: the opposite of the first player’s middle call, then the first two calls. Against HHT the reply is THH, which wins 3 games in 4, although both take 8 flips to appear on average. There is no best pattern.
Interactive laboratory
First player bets
0 of 3 matched
Second player bets
0 of 3 matched
- The first player’s middle call is H, so the reply starts with its opposite, T.
- Then come the first player’s first two calls, H H.
- Together: T H H.
No flips yet. Press Flip to toss the shared coin once.
Over many games the second player’s THH wins 3/4 of them (75.0%) and the first player’s HHT wins the rest.
- a flip
- one toss of the single shared coin, in order
- a blue bar
- the flip is part of the end of the run that matches the start of the first player’s pattern
- a red bar
- the same for the second player’s pattern
- a thick ring
- the three flips that completed the winning pattern
Each circle is one flip of the single coin, in the order it came. Under a circle, a blue bar means the flip is part of how much of the first player’s pattern the run now ends with, and a red bar means the same for the second player’s pattern. The game stops at the first flip that completes either pattern, and that player wins.
The first player has bet on HHT and the second on THH, with no flips yet. Over many games the second player’s THH wins 3/4 of them (75.0%) and the first player’s HHT wins the rest. Press Flip to toss the shared coin once.
- Flips
- 0
- First, HHT
- 0 of 3
- Second, THH
- 0 of 3 (wins 3/4)
Try this
Set a first bet, work out the reply yourself using the rule (the opposite of the middle call, then the first two calls), and then compare it with the bet the page chooses.
What is going on
Each explanation begins with a worked example and follows the same operation through intuition, formal statements and proofs. Later sections distinguish what is established from questions that remain open, so you can follow the level of detail useful to you.
- HHT against itself (call it AA)the last 3 flips of HHT are the first 3 of HHT: 44A pattern always overlaps itself completely, which scores 4. Its last flip T is not its first H, and its last two flips HT are not its first two HH, so nothing else counts.
- HHT followed by THH (AB)the last 1 flip of HHT is the first 1 of THH: 11Both end and start with T, an overlap of one flip, which scores 1. The last two flips HT are not TH, and HHT is not THH, so nothing more counts.
- THH against itself (BB)the last 3 flips of THH are the first 3 of THH: 44Again only the complete overlap, because the last flip H is not the first T and the last two flips HH are not TH.
- THH followed by HHT (BA)the last 1 flip of THH is the first 1 of HHT: 1; the last 2 flips of THH are the first 2 of HHT: 23THH ends in H, and HHT starts with H, which scores 1. It ends in HH, and HHT starts with HH, which scores 2. The full patterns THH and HHT differ.
- the chance that THH turns up first(AA − AB) ÷ ((AA − AB) + (BB − BA)) = (4 − 1) ÷ ((4 − 1) + (4 − 3))3 ÷ 4 = 3/4The reply wins 3 games in 4, so the first player’s HHT wins 1 in 4. That is exactly the chance that the game opens with two heads, the only way HHT can come first.
What you are seeing
Two bets, one coin, and a race to the first match
This is a game for two players, and the first thing to be clear about is that nobody flips a coin of their own. Each player makes a bet on a pattern of three flips, such as HHT for heads, heads, tails. The first player chooses a pattern, and then the second player chooses a different one. After that, one fair coin is flipped over and over, and both players watch the same flips. The first time either pattern appears in the run, in exactly that order and on consecutive flips, that player wins.
The ribbon in the laboratory is the run of flips so far. A blue bar under a flip means it belongs to the end of the run that already matches the start of the first player’s pattern, and a red bar means the same for the second player’s pattern. A flip can carry both. When three flips in a row match one pattern, that game is over.
The surprise is about the second player. Whatever the first player bets, the second can reply with a pattern that wins at least 2 games in 3. The rule is to take the opposite of the first player’s middle call, and then the first player’s first two calls. Against HHT the middle call is H, its opposite is T, and the first two calls are H H, so the reply is T H H.
Why it starts to make sense
Equally likely, but not equally early
The tempting thought is that every pattern of three flips is as likely as every other. That is true of any three flips you choose to look at: HHT and THH each turn up there with chance one in eight. It does not follow that they are equally likely to turn up first, because a race is not a look at three chosen flips. It is a long run of flips in which the patterns can overlap and borrow from each other.
Watch what the ribbon does. After a flip of H, a player betting on HHT has made one step and a player betting on THH has made none. After a T, it is the other way round. A run of two heads that comes after a tail finishes THH on the spot, while the same two heads still need a tail after them to finish HHT. Nearly every pair of heads in a run has a tail in front of it, and that is the whole difference.
Now look at the table of replies. The average number of flips each pattern takes to turn up when it is alone is the same for HHT and THH, 8 flips. An average wait and a race are different questions. Two runners with the same average finish time can still have one of them win almost every time they race, if one tends to be steady and the other tends to be slow or fast by turns. Here the similar waiting times hide a lopsided race.
The key idea
The reply is already half built when the game begins
The reply THH is made from the first player’s HHT by sliding it along one place: the first two calls of HHT, H H, become the last two calls of the reply. That is the point. The first player needs those two flips in a row to get started, and the reply is only one flip, a tail in front of them, away from being complete.
Here is the argument for HHT and THH in one line. The first time two heads appear in a row, unless they are flips 1 and 2, the flip before them must be a tail, because otherwise two heads would have appeared one flip earlier. A tail followed by two heads is THH, so the reply has already won. The only way HHT can win is for the game to open with two heads, which has probability 1/4, and then HHT wins as soon as the first tail arrives. So the reply wins 3 games in 4.
The same idea explains the most lopsided case. A first bet of HHH can only win if the game opens HHH, so the reply THH wins 7 games in 8. Other first bets give the reply a smaller edge, down to 2 games in 3, and the table below lists them all. The rule picks the best possible reply in every case, and no first bet escapes.
Formal statement
The exact odds from overlaps
Write a pattern as a word of three flips. For two patterns and , count how far the end of is also the start of :
where the sum runs over every length from 1 to 3 for which the last flips of are the same as the first flips of . This number, one of John Conway’s leading numbers as Martin Gardner described them, depends only on the two patterns. For a first bet and a second bet the chance that turns up before is
The average number of flips before a single pattern first turns up is . For HHT this is , for HTH it is , and for HHH it is .
A pattern beats when this chance is more than one half. The game is not transitive: if beats and beats , it does not follow that beats . Four patterns form a ring: THH beats HHT with chance 3/4, HHT beats HTT with 2/3, HTT beats TTH with 3/4, and TTH beats THH with 2/3.
Proof
Why THH beats HHT, and what has been checked
The case of HHT against THH can be proved completely in a few lines. Suppose the game does not open with two heads. Then the first pair of consecutive heads, wherever it is, is preceded by a flip, and that flip is a tail, since a head there would have given an earlier pair. So the run already contains T followed by H H, which is THH, and the second player has won. Suppose instead the game opens with two heads. The run is then all heads until the first tail, and nothing can have completed THH before that tail arrives, so that tail completes HHT and the first player wins. The first player therefore wins exactly when the first two flips are heads, which has probability , and the second wins with probability . The tests also check this over every one of the 16,384 runs of 14 flips.
For all eight bets, the page uses the overlap formula above, and the tests recompute every pair a second way. That second way follows the coin flip by flip, remembering only the last two flips, with exact fractions, up to 160 flips. After that many flips the part of the game still undecided is smaller than one in a trillion, and the exact chance always lies between the part decided for the reply and that part plus the undecided part. This is an exhaustive check of 56 ordered pairs of three-flip patterns, and it is not a claim about patterns of other lengths.
The best reply to each first bet, with its exact chance of winning, is:
- HHH is answered by THH, which wins 7 games in 8.
- HHT is answered by THH, which wins 3 games in 4.
- HTH is answered by HHT, which wins 2 games in 3.
- HTT is answered by HHT, which wins 2 games in 3.
- THH is answered by TTH, which wins 2 games in 3.
- THT is answered by TTH, which wins 2 games in 3.
- TTH is answered by HTT, which wins 3 games in 4.
- TTT is answered by HTT, which wins 7 games in 8.
If the first player picked one of the eight patterns at random and the second always used the rule, the second would win 71 games in 96 on average, a little under 3 in 4. The weakest case for the reply is still 2 in 3.
Limits and further questions
What the odds say, and what a deck of cards would change
Everything on this page concerns patterns of exactly three flips on a fair coin. The method of overlaps is described for patterns of any length in Gardner’s column and in the paper by Guibas and Odlyzko, but this page does not use or check any longer pattern, so it claims nothing about them.
The odds are a statement about many games. In a single game a first bet of HHT wins a quarter of the time against THH, and a seeded tally of a thousand games is a record of one seed. It wanders about the exact chance and does not establish it. The exact value comes from the overlaps, and the tally only illustrates it.
The game can also be played with cards: deal a shuffled deck one card at a time, with red for heads and black for tails, and watch for each pattern. A reply chosen by the same rule should still do well, but the odds are not exactly the coin’s. Cards are dealt without replacement, so each card dealt changes the chance of the next, and a game can run out of cards before either pattern has turned up. This page computes no card odds and quotes none.
Read this next to Three Dice, Each Beaten by the Next. The two pages are the same idea in different materials. There, three dice each beat the next, so no die is best. Here, four patterns each beat the next, so no pattern is best. In both, beating is a statement about a pair, not a number carried by one thing, and so a ranking by beating does not have to exist.
What is actually established
Every statement on this page, with its status, its exact scope, and the date that status was last checked.
For each of the eight first bets, the reply given by the rule wins with exactly these chances: HHH 7/8, HHT 3/4, HTH 2/3, HTT 2/3, THH 2/3, THT 2/3, TTH 3/4 and TTT 7/8. No other pattern does better against any first bet, so the second player can always win at least 2 games in 3.
- Scope
- Patterns of exactly three flips, one fair coin, and a game that ends at the first flip that completes either pattern. All 56 ordered pairs of different bets were computed. It says nothing about patterns of other lengths, a biased coin, or a game played with cards.
- Why
- The chances are worked out with Conway’s leading numbers in integer arithmetic. The unit tests recompute every pair a second way, by following the coin flip by flip with exact fractions and keeping only the last two flips, and the two agree. That second calculation stops after 160 flips, so it brackets each chance between the part already decided and that part plus the part still undecided, which is below one in a trillion.
- Computation (exact)
- All 56 ordered pairs of different three-flip patterns, with exact fractions from integer arithmetic, each bracketed by an independent exact calculation over 160 flips. Algorithm penney-conway-v1.
- Status checked
- Sources
- Mathematical Games citation unresolved; Penney-Ante citation unresolved; String overlaps, pattern matching, and nontransitive games
THH beats HHT with probability exactly 3/4: HHT can come first only when the game opens with two heads, which has probability 1/4.
- Scope
- This pair of bets, one fair coin. The same argument shows THH beats HHH with probability 7/8, since HHH comes first only when the game opens with three heads.
- Why
- Suppose the game does not open HH. The first time two heads appear in a row, they are not flips 1 and 2, so the flip just before them exists. It cannot be a head, or two heads would have appeared a flip earlier. So it is a tail, and THH is already complete. If the game does open HH, every flip is a head until the first tail, and that tail completes HHT before THH could appear. The tests also confirm the claim over all 16,384 runs of 14 flips.
- Status checked
No pattern of three flips is best. Every pattern is beaten by another, and THH, HHT, HTT and TTH beat each other round a ring: THH beats HHT with probability 3/4, HHT beats HTT with 2/3, HTT beats TTH with 3/4, and TTH beats THH with 2/3.
- Scope
- Patterns of exactly three flips and one fair coin. The page makes no claim about longer patterns.
- Why
- For each of the eight patterns the table of all 56 ordered pairs contains a reply with probability above one half. The ring is read from four of those entries.
- Computation (exact)
- All 56 ordered pairs of different three-flip patterns, with exact fractions from integer arithmetic. Algorithm penney-conway-v1.
- Status checked
- Sources
- Mathematical Games citation unresolved
Played alone on a fair coin, a pattern takes on average 8 flips to turn up if it is HHT, HTT, THH or TTH, 10 flips if it is HTH or THT, and 14 flips if it is HHH or TTT. So HHT and THH have the same average wait, and yet THH beats HHT 3 games in 4.
- Scope
- Patterns of exactly three flips and one fair coin. An average wait is the mean over many solo runs and is not the same question as which of two patterns comes first.
- Why
- The kernel computes twice the pattern’s overlap with itself in integers. The tests compare each value with a flip-by-flip sum of the number of flips times the chance the pattern first turns up on that flip, taken over 4,000 flips in floating point, which agrees to eight decimal places.
- Computation (exact)
- All eight three-flip patterns, with the average wait from integer arithmetic checked against a floating-point sum over the first 4,000 flips. Algorithm penney-conway-v1.
- Status checked
- Sources
- Mathematical Games citation unresolved; String overlaps, pattern matching, and nontransitive games
Sources
Review notes show which bibliographic details Mathomaly has checked and which remain unresolved. Checking a publication record does not independently verify its proof.
- Walter Penney, Penney-Ante, Journal of Recreational Mathematics, October 1969, 1969.
Where the game was first published, as a short problem. Cited for the history of the game; every number on this page is recomputed here.
Citation details remain unresolved after review by Mathomaly.
Bibliographic review:
AI-assisted bibliographic audit. Evidence type: unresolved.
A reference list in a secondary encyclopaedia article gives the author, the journal, October 1969 and page 241. The journal issue was not inspected, and the exact title, volume and issue were not confirmed.
- Martin Gardner, Mathematical Games, Scientific American, October 1974, 1974.
The column that brought the game to a wide audience and described Conway’s algorithm for the exact odds. Cited for the history of the game and for the method; the page recomputes every value rather than quoting the column.
Citation details remain unresolved after review by Mathomaly.
Bibliographic review:
AI-assisted bibliographic audit. Evidence type: unresolved.
The month and year of the column are from secondary accounts of the game; its subtitle is not given because it could not be confirmed. A Crossref search found Gardner’s other 1974 Mathematical Games columns in volume 230 but did not return an October 1974 entry, so the column, its title and its page range remain unconfirmed.
- Leonidas J. Guibas, Andrew M. Odlyzko, String overlaps, pattern matching, and nontransitive games, Journal of Combinatorial Theory, Series A, volume 30, 1981. Link
A proof of the overlap formulas for the odds and average waits, for patterns of any length, and a study of which reply is best. Cited as the published proof behind the method this page applies to patterns of three flips.
Bibliographic record checked. This is not an independent verification of the proof.
Bibliographic review:
AI-assisted bibliographic audit. Evidence type: publisher record.
The Crossref registration record gives the title, the authors L. J. Guibas and A. M. Odlyzko, the Journal of Combinatorial Theory Series A, volume 30, pages 183 to 208, March 1981. The paper text was not inspected, so which results it proves, and in what generality, was not checked against it.
Related by mechanism
Connected by how they work, not by sharing a topic label.