From Unequal Chance to a Coin Game Dance: Variants of Penney's Game
Isha Agarwal, Matvey Borodin, Aidan Duncan, Kaylee Ji, Tanya Khovanova, Shane Lee, Boyan Litchev, Anshul Rastogi, Garima Rastogi, Andrew Zhao
FFrom Unequal Chance to a Coin Game Dance: Variantsof Penney’s Game
Isha Agarwal Matvey Borodin Aidan Duncan Kaylee JiShane Lee Boyan Litchev Anshul Rastogi Garima RastogiAndrew ZhaoPRIMES STEPTanya KhovanovaMITJune 24, 2020
Abstract
We introduce and analyze several variations of Penney’s game aimed to find a moreequitable game.
Alice and Bob, two firm and fair friends with spare change and spare time, have a fair cointo flip. Alice selects a string of flip outcomes (heads or tails) of length n , after which Bobchooses his very own string of flip outcomes, also of length n . They then begin by tossingthe coin. Whoever’s string appears first in the sequence of heads and tails that they flip isthe victor.This game that Alice and Bob have ventured out to play is known as “Penney’s game”or “paradoxical pennies.” We denote flip outcomes with H for heads and T for tails.Suppose Alice and Bob play the game for n = 3, where Alice selects the string HHH andBob selects the string THH. They then toss the coin several times and yield the followingsequence of flips: H H T T H T H H . We see that Bob’s selected string, emphasized in the sequence of flip outcomes above, appearsbefore Alice’s chosen string HHH does. As a result, he is the winner of this round.As Alice and Bob soon discover, Penney’s game is in fact far more intriguing than theyever anticipated. This is due to how deceptively counterintuitive the nature of the game1 a r X i v : . [ m a t h . HO ] J un ruly is. The dazzlingly daring duo decide to play several rounds with these same strings.They find that Bob accumulates a rather high amount of wins in comparison to Alice.Suspecting something, they decide to peer at Penney’s game a little closer. Alice correctlycommences with the claim that each string of length 3 comprised of Hs and Ts has thesame probability of × × = to appear in three consecutive tosses. Alice and Bobthen incorrectly assume that the game must be fair as a result. However, this assumptioncontradicts what was occurring — even with a fair coin, Bob was triumphant in the greatmajority of rounds.Befuddled, Alice and Bob approach us for aid as they lament about their predicament,a hopeful gleam scintillating in their eyes. We propose to them that perhaps they shouldapproach their fairness assumption by considering which one of HH or HT is expected toshow up in fewer flips.Concurring with a nod, Alice correctly starts, “In both cases, we need to wait for thefirst H. After that, an unfavorable flip for the former string, HH, means restarting entirely.However, while an unfavorable flip for the latter string, HT, means it fails to progress, itdoesn’t need to restart!”“So, the latter string, HT, has a shorter expected wait time!” Bob chimes in a conclusion.“This certainly shows that our initial assumption that the game was fair is not substantiated.Something is indubitably afoot! Perhaps it has to do with expected wait times.”“Aye,” Alice amiably agrees. “Is there a way to find the exact expected wait time interms of flips?”We tell them that, as a matter of fact, there is. We cover this further along in the paper,in Section 5. For the time being, we provide them with the following data for reference: theexpected wait time for HT is 4, while the wait time for HH is 6. For the string of length 3,the expected wait time for HHH and TTT is 16 flips, the expected wait time for HTH andTHT is 14 flips, and the expected wait time for the four remaining strings — HHT, HTT,THH, and TTH — is 8 flips.Now illuminated by this enrapturing revelation, the two companions present to us asecond erroneous argument: “If a string has a shorter wait time,” Bob incorrectly states,“it must bear a greater probability of winning since it is more likely to appear first. If twostrings have the same wait time, then the probabilities of winning are the same.”However, we inform them that this argument is incorrect as well. We explain to them,“Suppose that you, Alice, select the string HHH and you, Bob, choose HHT as your string.As we previously mentioned, Alice’s string has a much longer expected wait time of 16 flipswhile Bob’s has a shorter expected wait time of 8 flips.”“Right,” Alice and Bob eagerly nod along.“Let’s look at how these strings would play out in the actual game. Both of you wait fortwo Hs in a row since that segment of your selected strings is the same. After two Hs in arow appear, however, each of you wins with probability .”“I see,” Alice replies. “So, as you have elucidated, despite our selection here havingdrastically different wait times, our probabilities of winning are, in fact, equal.”“Correct,” we reply. “Yet another example where the string with a longer expected wait2ime has an advantage is where you, Alice, select the string THTH, which has an expectedwait time of 20 flips, and play against Bob’s choice of HTHH, which has an expected waittime of 18 flips. This case lies in your favor as your probability of winning is , althoughyour string has the higher expected wait time.”The formula for winning probabilities in Penney’s game is well-known. We present it inSection 5. Table 1 displays the probability of Bob winning in the game with strings of length3. Alice’s possible choices fill the top row and Bob’s possible choices are in the left column.We only show Bob’s winning probabilities for Alice’s potential strings that begin with H, aswe can calculate the rest by symmetry.HHH HHT HTH HTTHHH * 1/2 2/5 2/5HHT 1/2 * 2/3 2/3HTH 3/5 1/3 * 1/2HTT 3/5 1/3 1/2 *THH 7/8 3/4 1/2 1/2THT 7/12 3/8 1/2 1/2TTH 7/10 1/2 5/8 1/4TTT 1/2 3/10 5/12 1/8Table 1: Bob’s probability of winning.Table 2 below displays the best choice for Bob given Alice’s string and the odds of Bobwinning for that choice. Once again, we only need to consider Alice’s strings which startwith H. Alice’s string Bob’s best choice Bob’s oddsHHH THH 7 to 1HHT THH 3 to 1HTH HHT 2 to 1HTT HHT 2 to 1Table 2: Bob’s best choice and odds.Figure 1 shows Bob’s best choice. The arrow points from Alice’s string to Bob’s bestchoice.Interestingly, there is an algorithm Bob can employ to choose his string once providedAlice’s string such that he has the optimal probability of winning in Penney’s game. Namely,given Alice’s string of Hs and Ts, Bob takes the second letter from Alice’s string, reverses it(turns it to H if it’s T and vice versa), and adds the first n − The Head-Start Penney’s game. Head-start
We give Alice an edge by giving hera head-start of one flip. We discuss this coin game in detail in Section 2. Bob’s expectedwait time increases by 1 and Alice’s chances of winning are improved. However, Bobhas the advantage and, given her string, is capable of selecting his own such that hisprobability of winning is better than a half. Interestingly, given Alice’s string, Bob’soptimal string in this game is the same as Bob’s optimal string in Penney’s game.2.
The Post-a-Bobalyptic Penney’s game.
We discuss this game extensively in Sec-tion 3. In this variant of Penney’s game, Alice is allowed an additional toss at theend if Bob’s string appears before hers does. If her string appears with this extra toss,it is counted as a tie. Otherwise, Bob wins. For every choice Alice may make, herworst-case odds are better than in Penney’s game. Additionally, if Alice picks a goodstring, this game is fair for n = 3.3. The Second-Occurrence Penney’s game.
We explore and discuss this coin gamein Section 4. Here, the first player whose string occurs twice wins. This game doesimprove the odds in favor of Alice, but with a few exceptions.4.
The Two-Coin game.
In this game, which we analyze in Section 6, Alice and Bobflip separate coins. Whoever sees their string appear first in their own series of flips4ins. The Two-Coin game differs from other games in that the winning probabilitiesonly depend on expected wait time as the two strings cannot interact with one another.This game is fair for both players.5.
The No-Flippancy game.
We discuss this game in detail in Section 7. This game,being deterministic, is rather distinct from the others here, as it does not involve acoin. Alice and Bob decide on their turn what the result of a coin flip is according tosimple rules. Alice has the first turn, and they alternate turns afterwards. The natureof this variant is such that the outcome of each game is always either a win, a loss,or an infinite game. Unfortunately, it is not enough for her to have a fair chance inthis game. Interestingly, for n = 3, Bob can follow the algorithm to obtain an optimalstring in Penney’s game to pick a victorious string in the No-Flippancy game. As thisgame has numerous highly intriguing properties, we have written an in-depth paperabout it [1].6. The Blended game.
This game is a friendly mixture of the No-Flippancy andPenney’s game. We cover it in Section 8. When Alice’s and Bob’s wanted outcomescoincide, that is the outcome they receive, similar to the No-Flippancy Game. Ifnot, they flip a coin. Once again, whoever’s string appears first is triumphant. Oneinteresting feature of this game is that it also has a non-transitive cycle, which is oflength 6.It is worth noting that, in Penney’s game, the odds of a string S winning against astring S are independent of which player selects which string. This is due to the symmetrypresent in the game with respect to Alice and Bob.However, this property is not true in three of the game variants listed above: the Head-Start Penney’s game, the Post-a-Bobalyptic Penney’s game, and the No-Flippancy game.Nevertheless, the remaining three games — the Second-Occurrence game, Two-Coins game,and Blended game — retain this characteristic.Interestingly, the Second-Occurrence game has a non-transitive cycle of strings congruentto that of Penney’s game in Figure 1. The Blended game has a non-transitive cycle of lengthsix, which furthermore surprised us.We cover some general theory in Section 5. Specifically, we discuss a way to measurehow self-overlapping a string is, and we use this knowledge to explain the formula for theodds for Penney’s game. Additionally, we mention the probability that a string appears forthe first time in a given number of flips.Below are conventions we utilize throughout the paper. • We assume that Alice’s and Bob’s string are different, as most games would end in atie otherwise. • Unless otherwise noted, we assume that Alice’s string starts with H, as the results forstrings starting with T can be extended by symmetry.5
Alice and Bob choose strings of the same lengths. We denote this common length as n . • In all the tables with winning probabilities, unless otherwise noted, the top row showsAlice’s choices, the left column shows Bob’s choices, and we show Bob’s probabilitiesof winning.Alice and Bob commence their journey with the simplest variation of Penney’s game: theHead-Start Penney’s game.
Alice and Bob, deeply unsatisfied by the unfairness inherent to Penney’s Game, mutuallyconcur to even the odds somewhat. Bob graciously agrees to play the Head-Start Penney’sgame instead. In this variation of Penney’s game, the first toss counts only towards Alice’sstring. Just as with Penney’s game, the two players cannot tie.Before they play, the two companions wish to investigate how much, precisely, the gameleverages the odds in Alice’s favor.“Is there a method by which we may derive how much my probability of winning hasimproved in comparison to the standard Penney’s game?” Alice inquires.“The first toss aids you winning only if you’re victorious by immediately receiving yourstring in the initial n tosses. Otherwise, the first toss doesn’t affect the game,” Bob realizes.Excitedly, Alice adds, “I see! If I fail to win immediately, the game will proceed asPenney’s game would. The probability of a win occurring for me right off the bat is n .”With this new knowledge, they denote the probability of Alice winning in Penney’sgame, given her and Bob’s strings, as p . They now know that if Alice does not receive a winimmediately, which is the case with probability 1 − n , the game proceeds as Penney’s gamewould. So, Alice’s total winning chance with the same strings selected must be n +(1 − n ) p .This can be rewritten as p + (1 − p ) n .Therefore, Bob’s probability is 1 − n − (1 − n ) p = (1 − p )(1 − n ). His chance fora wonderful win in Penney’s game is 1 − p , so we can safely infer that his probability ofvictory in the Head-Start Penney’s game is directly proportional to his probability of victoryin Penney’s game.“The Head-Start Penny’s game indeed provides me with better odds than Penney’s gamedoes. Notably, the larger p is and the smaller n is, the greater the increase in my probabilityof winning in this game is compared to Penney’s game!” Alice gleefully remarks.“That, in turn, leads to a perhaps even more interesting statement,” Bob comments.“Given your string, my optimal string in Penney’s game must also be the optimal string forme in this game, since the probabilities are directly proportional! Quite fascinating.”“Precisely,” we interject in agreement. “Suppose, for example, n = 3. Then, Alice, yourchance of winning is p , and Bob’s chance of winning is − p )8 from what we established6ogether.”And thus, using the winning probabilities for Penney’s game for n = 3 from Table 1,we attain Table 3 below, which delineates Bob’s probabilities of winning in the Head-StartPenney game. HHH HHT HTH HTTHHH * 7/16 7/20 7/20HHT 7/16 * 7/12 7/12HTH 21/40 7/24 * 7/16HTT 21/40 7/24 7/16 *THH 49/64 21/32 7/16 7/16THT 49/96 21/64 7/16 7/16TTH 49/80 7/16 35/64 7/32TTT 7/16 21/80 35/96 7/64Table 3: Bob’s probabilities of winning.Table 4 shows Bob’s optimal string choice and odds of winning given Alice’s string. AsAlice mentioned previously, the optimal string for Bob is the same here as it is in Penney’sgame. This signifies that Figure 1 represents this game as well. Nevertheless, the odds in theHead-Start Penney’s game are certainly more favorable for Alice in comparison to Penney’sgame. Despite this, Bob still has an advantage because he can always pick a string withfavorable odds. Alice’s string Bob’s Best choice Bob’s oddsHHH THH 49 to 15HHT THH 21 to 11HTH HHT 7 to 5HTT HHT 7 to 5Table 4: Bob’s best choice and odds.As Bob is delayed by a toss, the expected wait time for his string increases by 1 flip. Inthis game, as in Penney’s game, the string bearing a longer wait time may still have a highersuccess rate. In Penney’s game, this only occurs for strings where n ≥
4. In the Head-StartPenney’s game, this can occur for n = 3 as well. All such cases for strings of length 3 aredisplayed in Table 5, where “Winner” denotes the player with the advantage.The last line in Table 5 particularly piques interest due to the incredibly disparate ex-pected wait times contradicting the true winner. This phenomenon continues and magnifiesfor greater string lengths. If Alice selects a string comprised uniformly of Hs and Bob choosesa string congruent to Alice’s except for the last term, Alice has the greater probability of7inner Alice Bob Wait TimeAlice HTH THH (10, 9)Bob HHT THH (8, 9)Alice HTH HTT (10, 9)Bob HTT HHT (8, 9)Alice HHH HHT (14, 9)Table 5: Winning versus wait time.winning despite her string’s expected wait time being almost twice as large as Bob’s string’sexpected wait time.Alice and Bob fail to reach their goal with the Head-Start Penney’s game, yet are gratifiedby the knowledge that allowing Alice an extra flip at the beginning did indeed help Alice.“What if Alice is provided with an extra flip at the end of Penney’s game instead?” theywonder pensively. This game is distinguished from Penney’s game by the fact that, if she loses, Alice receivesan extra toss at the very end. If this toss allows her string to appear, then it the outcome isa tie.“Well,” Bob begins, “if I attain my string first in the sequence of tosses, then you getan extra flip. However, that additional flip can only be of use if the last n − n − probability that you will receive your string’s last character and we tie. However, ifI select some other string, my probability of victory must be equivalent to that in Penney’sgame.”As Alice and Bob wish to model their probabilities in this novel game mathematically, weprovide them with a basis. Suppose, for some set of strings chosen by Alice and Bob, Alicecomes out the winner with the probability p ( A ) in Penney’s game and with the probability p (cid:48) ( A ) in the Post-a-Bobalyptic Penney’s game. Correspondingly, suppose Bob is triumphantagainst Alice in Penney’s game with the probability p ( B ) and in the Post-a-BobalypticPenney’s game with probability p (cid:48) ( B ). We furthermore denote by p (cid:48) ( T ) the probability thatAlice and Bob obtain a tie in the Post-a-Bobalyptic Penney’s game. We therefore have8 ( A ) + p ( B ) = 1 and p (cid:48) ( A ) + p (cid:48) ( B ) + p (cid:48) ( T ) = 1.Alice and Bob conclude that if the first n − n − p (cid:48) ( T ) = 0 p (cid:48) ( A ) = p ( A ) p (cid:48) ( B ) = p ( B ) . Otherwise, p (cid:48) ( T ) = p ( B )2 p (cid:48) ( A ) = p ( A ) p (cid:48) ( B ) = p ( B )2 . This illustrates that, given Alice’s string, if Bob chooses his string by performing thebest-odds algorithm, then his odds of winning in the Post-a-Bobalyptic Penney’s game are p ( B )2 p ( A ) . As described, this is half his odds in Penney’s game. Therefore, another string mightbe a better choice for Bob in the Post-a-Bobalyptic Penney’s game. In any case, his oddsare not reduced by more than twice.Table 6 displays probabilities of different game outcomes for strings of length 3. The firstterm represents the probability of Bob winning, the second one is the probability of Alicewinning, and the last one is the probability of a tie.HHH HHT HTH HTTHHH * 1/4, 1/2, 1/4 2/5, 3/5, 0 2/5, 3/5, 0HHT 1/2, 1/2, 0 * 1/3, 1/3, 1/3 1/3, 1/3, 1/3HTH 3/5, 2/5, 0 1/3, 2/3, 0 * 1/2, 1/2, 0HTT 3/5, 2/5, 0 1/3, 2/3, 0 1/2, 1/2, 0 *THH 7/16, 1/8, 7/16 3/8, 1/4, 3/8 1/2, 1/2, 0 1/2, 1/2, 0THT 7/12, 5/12, 0 3/8, 5/8, 0 1/4, 1/2, 1/4 1/4, 1/2, 1/4TTH 7/10, 3/10, 0 1/2, 1/2, 0 5/8, 3/8, 0 1/4, 3/4, 0TTT 1/2, 1/2, 0 3/10, 7/10, 0 5/12, 7/12, 0 1/8, 7/8, 0Table 6: Probabilities of different outcomes for the Post-a-Bobalyptic Penney’s game.Table 7 shows the odds of Bob winning.As seen in the table, this game is now a fair game for n = 3. If Alice picks HTT for herstring, at best, Bob can only tie with Alice. However, for any other string, Bob would stillhave an advantage.Table 8 shows the best choice for Bob and the odds of Bob’s winning.Alice Bob OddsHHH THH 7 to 2HHT THH 3 to 2HTH TTH 5 to 3HTT HHT, HTH, THH 1 to 1Table 8: Bob’s best choice and odds.9HH HHT HTH HTTHHH * 1 to 2 2 to 3 2 to 3HHT 1 to 1 * 1 to 1 1 to 1HTH 3 to 2 1 to 2 * 1 to 1HTT 3 to 2 1 to 2 1 to 1 *THH 7 to 2 3 to 2 1 to 1 1 to 1THT 7 to 5 3 to 5 1 to 2 1 to 2TTH 7 to 3 1 to 1 5 to 3 1 to 3TTT 1 to 1 3 to 7 5 to 7 1 to 7Table 7: Bob’s odds of victory in the Post-a-Bobalyptic Penney’s game.Figure 2 shows Bob’s best choice. The arrow points from Alice’s string to Bob’s bestchoice. Figure 2: Bob’s best choice.As is displayed in the preceding data tables, the optimal string choice for Bob in Penney’sgame remains the optimal choice in the Post-a-Bobalyptic Penney’s game for n = 3. However,in this game, it may share the mantle of ‘optimal string’ with other strings.We observed that in Penney’s game, a string with a greater expected wait time may havean advantage. This is true in the Post-a-Bobalyptic Penney’s game as well. We must have n ≥ n = 4.Winner Alice Bob Wait TimeAlice HTTH TTHH (18,16)Alice HTHT THTT (20,18)Alice HTHH THHH (18,16)Bob HHTT HTHH (16,18)Alice HTHH HHTT (18,16)Table 9: Pairs of strings for n = 4 where the string with the longer wait time has higherwinning probabilities. 10he penultimate line garners considerable interest. The Post-a-Bobalyptic game providesa greater advantage to Alice than Penney’s game does in certain cases. However, Bob maywin despite having a string with a longer expected wait time.As such, Alice and Bob continue their quest for a firmly fair game. Alice and Bob have seen that adding a flip in Alice’s favor has not quite completely workedout as intended. While there was certainly a slight improvement in her odds, the gamesthus far have failed to be fair. Instead, Alice suggests a new game — the
Second-OccurrencePenney’s game . Here, a player is declared the victor once their string appears the secondtime in the sequence of coin flips.As an example, suppose Alice’s string is HHH and Bob’s string is HHT. The game outputHHTHHHH is a win for Alice, as HHH appears twice whereas Bob’s string only appears once.As with Penney’s game, there are no ties possible in the Second-Occurrence Penney’sgame. Additionally, if Alice and Bob choose complementary strings, then, by symmetry,they both win with an equal probability.We define a self-overlapping string as follows: one can fit two occurrences of a string oflength n into less than 2 n tosses. These strings might have better odds in this game than inthe original Penney’s game. For example, HHH is an unfavorable string selection for Alice inPenney’s game. However, in the Second-Occurrence Penney’s game, Alice has a 1/2 chanceof attaining the second occurrence of this string immediately after the first occurrence if thegame output is HHHH, which improves her chances.We used a computer to calculate the probabilities of different outcomes for n = 3. Theresults are presented in Table 10. As before, the numbers below are Bob’s winning proba-bilities. HHH HHT HTH HTTHHH * 1/2 56/125 56/125HHT 1/2 * 16/27 16/27HTH 69/125 11/27 * 1/2HTT 69/125 11/27 1/2 *THH 11/16 3/4 1/2 1/2THT 59/108 7/16 1/2 1/2TTH 151/250 1/2 9/16 1/4TTT 1/2 99/250 49/108 5/16Table 10: Bob’s winning probabilities in the Second-Occurrence Penney’s gameTable 11 displays Bob’s optimal string choice for different string selections made by Aliceand the corresponding odds. The best choice for Bob for n = 3 is the same as in Penney’s11ame and is represented in Figure 1.Alice’s string Bob’s best choice Bob’s oddsHHH THH 11 to 5HHT THH 3 to 1HTH HHT 16 to 11HTT HHT 16 to 11Table 11: Bob’s best choice and odds.We now look at this table and discuss our observations.1. If Alice and Bob select complementary strings, the probability of either winning is 1/2,as expected.2. We assumed that the Second-Occurrence Penney’s game is fairer for Alice than theoriginal Penney’s game is. The probabilities are not altered between Penney’s gameand this game in cases where both players have a winning probability of 1/2. Thisresult is not surprising. The probability 1/2 is achieved for pairs of complementarystrings and pairs of strings that differ only in the last character.3. For the string pair HHT and THH (and, similarly, the complementary pair TTHand HTT), the probabilities did not change between this game and Penney’s game.The probability theory is rather tricky here. We can show not only for the Second-Occurrence Penney’s game but for any k th-Occurrence Penney’s game as well that theprobability for this pair of strings fails to change. Indeed, if we have a long string oftosses, HHT and THH must alternate. THH always appears between two occurrencesof HHT and, likewise, one HHT always occurs between two occurrences of THH. There-fore, whoever obtains the first occurrence of their string wins the any k th-OccurrencePenney’s game.4. For the remaining pairs of strings, the probabilities are closer to 1/2 than in Penney’sgame. Penney’s game has been extensively studied. The theory presented in this section is availablein many places, including [2, 3, 4, 5, 6, 7, 8, 9, 10]. The theory is built not only for stringsof coin tosses with two outcomes but for words in any alphabet. We do not discuss generalformulas, but rather assume that the size of our alphabet is 2.12 .1 Autocorrelation polynomial and Conway’s Leading Number
The autocorrelation vector of a word w = w . . . w n , where w i is the i -th character in the word,is c = ( c , . . . , c n − ), with c i being 1 if the prefix of length n − i equals the suffix of length n − i ,and with c i being 0 otherwise. That is, value c i indicates whether w i +1 . . . w n = w . . . w n − i .For example, the autocorrelation vector of HHH is (1 , ,
1) since all the prefixes are equalto all the suffixes. The autocorrelation vector of THH is (1 , ,
0) since no proper prefix isequal to a proper suffix. Finally, the autocorrelation vector of HHTTHH is (1 , , , , , c is always equal to 1 since the prefix and the suffix of length n are both equalto the word w . Similarly, c n − is 1 if and only if the first and the last letters are the same.If c = 1, then all letters in the word are the same. It follows that if c = 1, then for any i we have c i = 1.If c is the only value that is 1, we call the word w a non-self-overlapping word .The autocorrelation polynomial of w is defined as c w ( z ) = c z + · · · + c n − z n − . It is apolynomial of degree at most n − z + z and the autocorrelationpolynomial of THH is 1. Finally, the autocorrelation polynomial of HHTTHH is 1 + z + z .The Conway Leading Number is the integer value of the correlation vector viewed as astring of zeros and ones and evaluated in binary. Thus, the Conway Leading Number forHHH is 7, the Conway Leading Number for THH is 4, and the Conway Leading Number forHHTTHH is 35. We denote the Conway leading number of a word w as C w .We can express the Conway Leading Number through the autocorrelation polynomial: C w = 2 n − c w (cid:18) (cid:19) . Suppose we have a string A of length n . We call a string S that ends with A an A-first-timer if the last n characters of S is the only occurrence of A in S . We denote the number of A -first-timers of length i as a i ( A ) for i ≥
0. We call the sequence a ( A ), a ( A ), . . . and soon an A -first timer sequence .Let p i ( A ) denote the probability that we first see the string A after the i -th toss of acoin. The probabilities p i ( A ) and integers a i ( A ) are connected: p i ( A ) = a i ( A )2 i . For example, we know that a i ( HT ) = i −
1. Thus, p i ( HT ) = i − i .The generating function for the w -first-timer sequence, where word w has length k , isknown [7]: G ( z ) = z k z k + (1 − z ) c w ( z ) .
13f we plug in z = , we get 1, which is the probability that the string ever occurs.This generating function allows us to derive the formula for the expected wait time. The expected wait time of string A can be calculated as ∞ (cid:88) ip i = ∞ (cid:88) ia i ( A ) 12 i . Given that G ( z ) above is the generating function for the sequence a i ( A ), the generatingfunction for the sequence ia i ( A ) is zG (cid:48) , which equals z ( kz k − ( z k + (1 − z ) c ( z )) − z k ( kz k − − c ( z ) + (1 − z ) c (cid:48) ( z )))( z k + (1 − z ) c ( z )) . Minor manipulation produces kz k ((1 − z ) c ( z )) + 2 z k +1 c ( z ) − z k +1 (1 − z ) c (cid:48) ( z )))( z k + (1 − z ) c ( z )) . When we plug in z = , we get 2( ) k +1 c ( z )( ) k = 2 k c ( z ) . We can see that the expected wait time for a string is its Conway leading number times2, which is a well-known fact.Here are examples of the wait time for strings of length 3: HHH — 14; HTH — 10; HHTand HTT — 8.We can see some patterns: If all letters are the same, then the wait time for a stringof length n is 2 n +1 −
2. This is the longest wait time for strings of length n . Strings thatare reverses of each other have the same wait time as they have the same autocorrelationpolynomial. The shortest wait time is 2 n , which is provided by non-self-overlapping strings.We see that the wait time for some strings is almost twice the wait time for others. Table 12 shows the examples of the first-timer sequences for strings of length up to 3 andsome especially interesting examples for strings of length 4.We group strings with the same autocorrelation polynomial, that is, strings with thesame Conway Leading Number (CLN), into one line.14tring CLN SequenceH,T 1 1,1,1,1,1,1,1,1,1HH, TT 11 0,1,1,2,3,5,8,13,21HT, TH 10 0,1,2,3,4,5,6,7,8HHH, TTT 111 0,0,1,1,2,4,7,13,24HHT, HTT, THH, TTH 100 0,0,1,2,4,7,12,20,33HTH, THT 101 0,0,1,2,3,5,9,16,28HHHH, TTTT 1111 0,0,0,1,1,2,4,8,15HHHT,HHT,HTTT,TTTH,TTHH,THHH 1000 0,0,0,1,2,4,8,15,28Table 12: First-timer sequences for some strings of length up to 4.CLN OEIS Name Recurrence1 A000012 Only 1s a n = a n −
11 A000045 Fibonacci Numbers a n = a n − + a n −
10 A001477 Whole numbers a n = 2 a n − − a n −
111 A000073 Tribonacci Numbers a n = a n − + a n − + a n −
100 A000071 Fibonacci Numbers − a n = 2 a n − a n −
101 A005314 (No short description) a n = a n − + a n − + a n − a n = a n − + a n − + a n − + a n − a n = 2 a n − − a n − Table 13: First-timer sequences for small strings in the OEIS.Table 13 shows, given a Conway Leading Number, the sequence number in the OEIS andits linear recurrence. The sequence in the OEIS is often shifted. We also provide the nameof the sequence if it is short.
Example HHT.
Consider the string HHT of length 3. The corresponding first-timersequence is: 0 , , , , , , , . . . , with the recurrence a i = 2 a i − − a i − for i > a i ( HHT ) = F i +1 −
1, where F i isthe i -th Fibonacci number. This is also sequence of partial sums of the Fibonacci sequenceshifted one place to the right. One of the descriptions of this sequence in the OEIS says thatthis sequence is the number of 001-avoiding binary words of length i −
3. This is exactlyour sequence. Indeed, removing HHT from the end of HHT-first-timers makes a bijectionbetween our strings and strings avoiding HHT. The latter is the same as the number ofbinary strings avoiding 001. The generating function for the HHT-first-timer sequence is x (1 − x − x )(1 − x ) . trings with one letter. Consider strings that consist of the same letter. In ourtable, they correspond to the following sequences: Only 1s, Fibonacci numbers, Tribonaccinumbers, and Tetranacci numbers. They form a clear pattern. For strings of length n , eachnext term of the sequence is the sum of n previous terms. The sequence of only 1s belongsto this pattern. One might call it the “mononacci” numbers. Non-self-overlapping strings.
Consider non-self-overlapping strings, that is, stringswith Conway Leading Numbers that are powers of two. In our table, they correspond to thefollowing sequences: • Only 1s • Whole numbers • Fibonacci numbers − • Partial sums of Tribonacci numbersAt first glance, there is no clear pattern. Then, one might remember the following famousidentity for the Fibonacci numbers: n (cid:88) i =0 F i = F n +2 − . That is, the Fibonacci sequence is the sequence of partial sums of the Fibonacci numbersshifted by two terms. Now we can see a pattern. The sequence of whole numbers is alsothe sequence of partial sums of the sequence of all ones (our mononacci sequence). For anon-self-overlapping string of length n , the sequence is the partial sums of the n − To give the formula for winning probabilities, we need to extend the notion of ConwayLeading Numbers. Conway Leading Numbers quantify the overlaps of a word with itself.However, we can also quantify the overlap of a word with another word. We only definethe correlation of two words of the same length n , but it also can be defined for words ofdifferent lengths.The correlation vector of two words w and w is c w ,w = ( c , . . . , c n − ), with c i being 1if the prefix of length n − i of w equals the suffix of length n − i of w , and with c i being 0otherwise.The correlation vector defines the correlation polynomial, the same way as it is definedby one word. It also defines the Conway Leading Number for two words, which we denoteas C w ,w . 16f A is Alice’s string and B is Bob’s string, then the formula for Bob’s odds in Penney’sgame is: C A,A − C A,B C B,B − C B,A . Example HHT and THT.
For i = 0, we see that HHT is different from THT, so c = 0.For i = 1, we see that HT is different from TH, meaning that c = 0. For i = 2 we see thatT is the same as T, so c = 1. Therefore, c HHT,T HT = (0 , ,
1) and C HHT,T HT = 001 = 1.Similarly, we get that C HHT,HHT = 4, C T HT,T HT = 5, and C T HT,HHT = 0. This means thatBob’s comparative odds are − − = and his probability of winning is .Based on this formula, the strategy for Bob to pick the best string when Alice’s string isgiven is the following [4]. Bob takes the second character in Alice’s string and flips it. Then,he appends to it Alice’s prefix of size n −
1. For example, if Alice’s string is HHT, Bob flipsthe second character H and uses T as his first character. Then he appends HH. Thus Bob’sbest choice is THH.We are now ready to describe a new game that might be considered a fair game.
Alice and Bob, quite dismayed by their repeated failure to attain a truly fair game, decidethat a single coin will not cut it; they unveil their second and last coin, furiously brainstorm-ing to come up with a game necessitating the involvement of two coins.At last, their conjoined brainpower culminates to the simplistic yet elegant Two-Coingame. The two players toss their coins side-by-side, thus simultaneously developing separatesequences of flip outcomes as opposed to the singular sequence in Penney’s game. The firstperson to attain their string through the sequence of flips that they generate is the winner.In this game, a tie is possible when both players simultaneously get their string while flippingtheir own coins.However, their effort has resulted in a profound revelation: this game may, for once, trulybe fair. We show that the winning probabilities for Alice and Bob are solely dependent onthe expected wait time rather than the interaction between the strings.
Proposition 1.
The probabilities of a win/loss/tie depend only on the expected wait timesof Alice’s and Bob’s strings.Proof.
Alice’s string is A and Bob’s string is B . Suppose that p i (correspondingly q i ) are theprobabilities that Alice (correspondingly Bob) sees her (his) string for the first time at the i -th toss. These probabilities allow us to calculate the winning, losing, and tying probabilitiesfor Alice.Alice wins with probability ∞ (cid:88) i =1 p i (1 − i (cid:88) k =1 q i ) . ∞ (cid:88) i =1 q i (1 − i (cid:88) k =1 p i ) . There is a tie with probability ∞ (cid:88) i =1 p i q i . As the sequences p i and q i depend only on the autocorrelation of A and B respectively, itfollows that the winning probabilities depend only on the autocorrelation of each sequence.In other words, they only depend on the Conway Leading Numbers, which are half theexpected wait time.Note that these probabilities sum up to 1. That is, ∞ (cid:88) i =1 p i = ∞ (cid:88) i =1 q i = 1 . It follows that the probability of a win, loss, or a tie sum up to 1, or, equivalently, theprobability of an infinite game is 0.
Example.
Suppose Alice and Bob choose HT. As we showed before: p i ( HT ) = i − i .Thus, the probability of a tie is ∞ (cid:88) i =1 ( i − i = ∞ (cid:88) i =0 · i i . The generating function of the squares sequence is x (1+ x )(1 − x ) . Plugging in x = and dividingby 4, we get . That is, if both Alice and Bob choose HT or TH, then a tie occurs withprobability and each of them wins with probability .We wrote a program to calculate probabilities for strings of length 3 that are now inTable 14. The top row represents Alice’s string’s Conway Leading Number. The first columnshows Conway’s Leading Number for Bob’s string. The numbers in each cell, from left toright, represent the probability of Bob winning, Alice winning, and a tie.In Table 15 we approximated the values from Table 14 to make it easier to compare.Figure 3 shows Bob’s best choice. The arrow points from Alice’s Conway Leading Numberto Bob’s best choice. Figure 3: Bob’s best choice.The results are less surprising for this game compared to Penney’s game. The stringswith shorter expected wait time give better winning odds. Thus, both Alice and Bob should1811 101 100111 435913, 435913, 43913 32898691, 16432897, 4738691 2332773057 , , , , , , , , , , , , , , Alice and Bob play their Two-Coin game from dusk to dawn, reveling in their discovery of afair game. However, during an intermission in their game, Alice and Bob leave to completesome rudimentary chores. Bob hastily sweeps the two coins into his pocket before he departsso as to not forget them, blissfully unaware of the perfectly coin-sized hole at the bottom.By the time Bob returns, the coins are nowhere to be found. Upon knowing this, Aliceberates Bob about how his inattentiveness bungled the perfectly fair game.Hoping to avoid Alice’s scornful glare, Bob devises a coin game where they shall neverneed to flip a single coin — thus designated the No-Flippancy game.In this game, Alice chooses her string. Then Bob chooses his string of the same length.No one flips a coin. The outcome of the coin flip is decided deterministically. On their turn,each player looks at the current sequence of tosses and calculates the largest suffix, of length i , which matches the prefix of their string. Their choice is the character in position i + 1 intheir string. 19e study the games where the length of Alice’s and Bob’s strings is 3.Table 16 shows how the game proceeds. The top row shows Alice’s choice and the leftcolumn shows Bob’s choice.HHH HHT HTH HTTHHH HHH HHT HHTH HHTHTHT...HHT HHH HHT HHT HHTHTH HTH HTH HTH HTTHTT HTHTHT... HTHTHT... HTH HTTTHH HTHH HTHH HTH HTTTHT HTHT HTHT HTH HTTTTH HTHTHT... HTHTHT... HTH HTTTTT HTHTHT... HTHTHT... HTH HTTTable 16: The output of the game.Table 17 describes who wins and the number of turns in the game.HHH HHT HTH HTTHHH Tie, 3 Alice,3 Alice, 4 Tie, infiniteHHT Alice, 3 Tie, 3 Bob, 3 Bob, 3HTH Bob, 3 Bob, 3 Tie, 3 Alice, 3HTT Tie, infinite Tie, infinite Alice, 3 Tie, 3THH Bob, 4 Bob, 4 Alice, 3 Alice, 3THT Bob, 4 Bob, 4 Alice, 3 Alice, 3TTH Tie, infinite Tie, infinite Alice, 3 Alice, 3TTT Tie, infinite Tie, infinite Alice, 3 Alice, 3Table 17: The output of the game.We see that, in this game, if Alice chooses her string first, Bob can always choose hisstring so that he wins. Here is an amusing fact: given Alice’s string, Bob can use the optimalstrategy in Penney’s game to pick his winning string.It is surprising that, given that Alice starts first, she still loses. This game has manyintriguing properties, which we discuss in a separate paper [1].Now, as Alice loses, we need to help her again. We decided to add probabilities to thisgame. 20 The Blended game
This game is a variation of the No-Flippancy game, where we added chances back. Aliceand Bob choose strings of the same length. As in the No-Flippancy game, they each wantto increase their prefix in the output by 1. If they want the same outcome of a coin toss,they get it. If they want different outcomes, they flip a coin.As usual, we study when Alice and Bob have strings of length 3.If Alice’s first two characters are the same as Bob’s, then the probability of each of themwinning is 1/2. Indeed, they want the same first two characters, after which they flip a coinending a game. If they have complementary strings, by symmetry, the probability of eachof them winning is 1/2.We used a computer to calculate the results for other cases. Table 18 shows Bob’s winningprobabilities. 3 HHH HHT HTH HTTHHH * 1/2 1/4 2/5HHT 1/2 * 1/2 2/3HTH 3/4 1/2 * 1/2HTT 3/5 1/3 1/2 *THH 7/8 3/4 1/4 1/2THT 7/12 3/8 1/2 3/4TTH 7/10 1/2 5/8 1/4TTT 1/2 3/10 5/12 1/8Table 18: Bob’s winning probabilities.We see that a lot of entries in this table are the same as in Penney’s game. However,some differ. Suppose Alice picks HHH and Bob picks HTH. The first toss is H as both wantH. After that Alice wins only if the next flip is H, followed by another flip that is H.Bob’s best choice and odds are in Table 19.Alice’s string Bob’s best choice oddsHHH THH 7 to 1HHT THH 3 to 1HTH TTH 5 to 3HTT THT 3 to 1Table 19: Bob’s best choice and odds.Figure 4 shows Bob’s best choice. The arrow points from Alice’s string to Bob’s bestchoice. 21igure 4: Bob’s best choice.The above graphic demonstrates something rather beautiful about this game: it has anon-transitive cycle of length 6. As in Penney’s game, Bob always has better odds.After playing these numerous coin games, Alice and Bob have had enough. They decideto give their exorbitantly lustrous coin, which, like all the others, is worth 10 ,
000 USD, tocharity, and their discoveries to the world of coin-tastic mathematical research.
This project was done as part of MIT PRIMES STEP, a program that allows students ingrades 6 through 9 to try research in mathematics. Tanya Khovanova is the mentor of thisproject. We are grateful to PRIMES STEP for this opportunity.
References [1] Isha Agarwal, Matvey Borodin, Aidan Duncan, Kaylee Ji, Tanya Khovanova, Shane Lee,Boyan Litchev, Anshul Rastogi, Garima Rastogi, and Andrew Zhao, The No-FlippancyGame, math.CO arXiv:2006.09588 (2020).[2] Elwyn R. Berlekamp, John H. Conway and Richard K. Guy,
Winning Ways for yourMathematical Plays , 2nd Edition, Volume 4, AK Peters (2004), p. 885.[3] Stanley Collings, Coin Sequence Probabilities and Paradoxes, Bulletin of the Instituteof Mathematics and its Applications, 18, (1982), pp. 227–232.[4] Daniel Felix, Optimal Penney Ante Strategy via Correlation Polynomial Identities.
Electr. J. Comb.
Scientific American , 231(4), (1974), 120–125.226] Martin Gardner,
Time Travel and Other Mathematical Bewilderments , W. H. Freeman,(1988).[7] L.J. Guibas and A.M. Odlyzko, String Overlaps, Pattern Matching, and NontransitiveGames,
J. Combin. Theory Ser. A , Volume 30, Issue 2, (1981), pp. 183–208.[8] Steve Humble and Yutaka Nishiyama, Humble-Nishiyama Randomness Game — A NewVariation on Penney’s Coin Game,