Skip to content

Commit 881b778

Browse files
committed
chore: chore
1 parent 0aa965d commit 881b778

5 files changed

Lines changed: 211 additions & 93 deletions

File tree

bash.exe.stackdump

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Stack trace:
2+
Frame Function Args
3+
000FFFFA640 00180064365 (00180287B62, 00180266FBE, 00000000000, 000FFFFAB20)
4+
000FFFFAB70 001800499D2 (00000000000, 00000000000, 00000000000, 00180287C18)
5+
000FFFFBB80 00180049A11 (00180287C76, 000FFFFBAE8, 00000000000, 00000000020)
6+
000FFFFBBB0 001800CC245 (00000000000, 00000000000, 00000000000, 00000000000)
7+
000FFFFBC10 001800CC40E (000FFFFBC50, 00000000000, 00000000000, 00000000000)
8+
000FFFFBCD0 001800CDBAD (000FFFFBC50, 00000000000, 00000000000, 00000000000)
9+
End of stack trace

public/posts/penneys-game.txt

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Penney's Game: The Coin-Flip Bet Where Going Second Always Wins
2+
3+
*A short tour of a non-transitive coin game where the smart move is to let your opponent choose first.*
4+
5+
---
6+
7+
## TL;DR
8+
9+
Penney's Game is a two-player coin game. Each player picks a length-three sequence of heads and tails, like `HHT`. You then flip a fair coin over and over until one of the two chosen sequences shows up as three flips in a row — that player wins. The catch is that the game is **non-transitive**, just like rock-paper-scissors: whatever the first player picks, the second player can always pick something that beats it, sometimes by a mile. The whole trick is to never pick first.
10+
11+
---
12+
13+
## The rules
14+
15+
1. Player 1 announces a sequence of three, say `HHH`.
16+
2. Player 2, having heard it, announces their own, say `THH`.
17+
3. Flip a fair coin, tracking the running stream, until one player's pattern appears as three consecutive flips.
18+
4. That player wins.
19+
20+
It *feels* perfectly symmetric. It is not.
21+
22+
---
23+
24+
## Why going second wins
25+
26+
Take `HHH` vs `THH`. For `HHH` to win, the very first three flips must all be heads — probability `1/8`. If they aren't, then a tails has appeared somewhere before the run of heads finished, and the instant that tails is followed by two heads, `THH` has already won. So out of the gate, `THH` wins **7 times out of 8**.
27+
28+
The same logic, more gently, gives `THH` the edge over `HHT` at `3/4`. Your sequence is essentially lying in wait to swallow the opponent's.
29+
30+
---
31+
32+
## The second player's recipe
33+
34+
There's a one-line rule for the optimal response. Given Player 1's sequence `ABC`, Player 2 picks:
35+
36+
> the **opposite of the middle letter**, then the **first two letters** → `(not B) A B`.
37+
38+
So `HTH` → middle is `T`, flip to `H`, prepend to `HT` → Player 2 plays `HHT`.
39+
40+
The full table of best responses and the odds they give the second player:
41+
42+
| Player 1 | Player 2 | Odds for P2 |
43+
|----------|----------|-------------|
44+
| `HHH` | `THH` | 7 : 1 |
45+
| `HHT` | `THH` | 3 : 1 |
46+
| `HTH` | `HHT` | 2 : 1 |
47+
| `HTT` | `HHT` | 2 : 1 |
48+
| `THH` | `TTH` | 2 : 1 |
49+
| `THT` | `TTH` | 2 : 1 |
50+
| `TTH` | `HTT` | 3 : 1 |
51+
| `TTT` | `HTT` | 7 : 1 |
52+
53+
Every row is a winning bet for the player who moved second.
54+
55+
---
56+
57+
## The surprising part
58+
59+
There is **no best sequence**. Notice the loop: `HHT` beats `HTH`, `HTH` beats `HTT`... and `THH` beats `HHT`, which would beat something that beats `THH`. Pick any sequence and another one beats it — exactly the rock-paper-scissors structure, except here the imbalance can be a brutal 7-to-1 rather than a fair third.
60+
61+
Our intuition assumes that "more likely to win than X" is a transitive ranking. Penney's Game is the cleanest possible demonstration that it doesn't have to be. So the next time someone offers to let you pick your three coin flips first, decline — and make them go first instead.

public/posts/posts.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
[
2+
{
3+
"slug": "penneys-game",
4+
"title": "Penney's Game: The Coin-Flip Bet Where Going Second Always Wins",
5+
"date": "2026-06-24",
6+
"updated": "2026-06-24",
7+
"description": "A short explainer on Penney's Game, the non-transitive coin-flip game where the second player can always pick a three-flip sequence that beats the first player's — sometimes 7 to 1. Includes the optimal-response rule and the full odds table.",
8+
"tags": [
9+
"probability",
10+
"math",
11+
"games",
12+
"statistics",
13+
"non-transitive",
14+
"fun"
15+
],
16+
"category": "dev",
17+
"filename": "penneys-game.txt",
18+
"authors": [
19+
"fezcode"
20+
]
21+
},
222
{
323
"slug": "the-20-mile-march",
424
"title": "The 20 Mile March: Consistency Beats Heroics",

public/rss.xml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,24 @@
99
<link>https://fezcode.com</link>
1010
</image>
1111
<generator>RSS for Node</generator>
12-
<lastBuildDate>Fri, 19 Jun 2026 20:09:46 GMT</lastBuildDate>
12+
<lastBuildDate>Sun, 28 Jun 2026 21:25:17 GMT</lastBuildDate>
1313
<atom:link href="https://fezcode.com/rss.xml" rel="self" type="application/rss+xml"/>
14-
<pubDate>Fri, 19 Jun 2026 20:09:46 GMT</pubDate>
14+
<pubDate>Sun, 28 Jun 2026 21:25:17 GMT</pubDate>
1515
<copyright><![CDATA[2026 Ahmed Samil Bulbul]]></copyright>
1616
<language><![CDATA[en]]></language>
1717
<managingEditor><![CDATA[samil.bulbul@gmail.com (Ahmed Samil Bulbul)]]></managingEditor>
1818
<webMaster><![CDATA[samil.bulbul@gmail.com (Ahmed Samil Bulbul)]]></webMaster>
1919
<ttl>60</ttl>
20+
<item>
21+
<title><![CDATA[Penney's Game: The Coin-Flip Bet Where Going Second Always Wins]]></title>
22+
<description><![CDATA[[object Object]]]></description>
23+
<link>https://fezcode.com/blog/penneys-game</link>
24+
<guid isPermaLink="false">https://fezcode.com/blog/penneys-game</guid>
25+
<dc:creator><![CDATA[Ahmed Samil Bulbul]]></dc:creator>
26+
<pubDate>Wed, 24 Jun 2026 00:00:00 GMT</pubDate>
27+
<content:encoded><![CDATA[<h1>Penney&#39;s Game: The Coin-Flip Bet Where Going Second Always Wins</h1>
28+
<p><a href="https://fezcode.com/blog/penneys-game">Read more...</a></p>]]></content:encoded>
29+
</item>
2030
<item>
2131
<title><![CDATA[The 20 Mile March: Consistency Beats Heroics]]></title>
2232
<description><![CDATA[[object Object]]]></description>

0 commit comments

Comments
 (0)