# Penney's game

Penney's game, named after its inventor Walter Penney, is a binary (head/tail) sequence generating game between two players. At the start of the game, the two players agree on the length of the sequences to be generated. This length is usually taken to be three, but can be any larger number. Player A then selects a sequence of heads and tails of the required length, and shows this sequence to player B. Player B then selects another sequence of heads and tails of the same length. Subsequently, a fair coin is tossed until either player A's or player B's sequence appears as a consecutive subsequence of the coin toss outcomes. The player whose sequence appears first wins.

Provided sequences of at least length three are used, the second player (B) has an edge over the starting player (A). This is because the game is nontransitive such that for any given sequence of length three or longer one can find another sequence that has higher probability of occurring first.

## Analysis of the three-bit game

For the three-bit sequence game, the second player can optimise his odds by choosing sequences according to:

1st player's choice 2nd player's choice Odds in favour of 2nd player
HHH THH 7 to 1
HHT THH 3 to 1
HTH HHT 2 to 1
HTT HHT 2 to 1
THH TTH 2 to 1
THT TTH 2 to 1
TTH HTT 3 to 1
TTT HTT 7 to 1

An easy way to remember the sequence for using as a bar trick is for the second player to start with the opposite of the middle choice of the first player, then follow it with the first player's first two choices.

So for the first player's choice of 1-2-3
the second player must choose (not-2)-1-2

where (not-2) is the opposite of the second choice of the first player.[1]

An intuitive explanation for this result, is that in any case that the sequence is not immediately the first player's choice, the chances for the first player getting their sequence-beginning, the opening two choices, are usually the chance that the second player will be getting their full sequence. So the second player will most likely "finish before" the first player.[1]

## Strategy for more than three bits

The optimal strategy for the first player (for any length of the sequence no less than 4) was found by J.A. Csirik (See References). It is to choose HTTTT.....TTTHH ($k-3$ T's) in which case the second player's maximal odds of winning is $(2^{k-1}+1):(2^{k-2}+1)$.

## Variation with playing cards

One suggested variation on Penney’s Game uses a pack of ordinary playing cards. The Humble-Nishiyama Randomness Game follows the same format using Red and Black cards, instead of Heads and Tails.[2][3] The game is played as follows. At the start of a game each player decides on their three colour sequence for the whole game. The cards are then turned over one at a time and placed in a line, until one of the chosen triples appears. The winning player takes the upturned cards, having won that "trick". The game continues with the rest of the unused cards, with players collecting tricks as their triples come up, until all the cards in the pack have been used. The winner of the game is the player that has won the most tricks. An average game will consist of around 7 “tricks”. As this card-based version is essentially multiple repetitions of the original coin game, the second player's advantage is greatly amplified, as the follow probability table shows:

Below are the probabilities of the outcomes for each strategy.

1st player's choice 2nd player's choice Probability 1st player wins Probability 2nd player wins Probability of a draw
BBB RBB 0.11% 99.49% 0.40%
BBR RBB 2.62% 93.54% 3.84%
BRB BBR 11.61% 80.11% 8.28%
BRR BBR 5.18% 88.29% 6.53%
RBB RRB 5.18% 88.29% 6.53%
RBR RRB 11.61% 80.11% 8.28%
RRB BRR 2.62% 93.54% 3.84%
RRR BRR 0.11% 99.49% 0.40%

If the game is ended after the first trick, there is a negligible chance of a draw. The odds of the second player winning in such a game appear in the table below.

1st player's choice 2nd player's choice Odds in favour of 2nd player
BBB RBB 7.50 to 1
BBR RBB 3.08 to 1
BRB BBR 1.99 to 1
BRR BBR 2.04 to 1
RBB RRB 2.04 to 1
RBR RRB 1.99 to 1
RRB BRR 3.08 to 1
RRR BRR 7.50 to 1