Paul Stanford · Permutive · London Scala User Group
seed 94IKWPES, if you want to play it yourself
Joker
+4 Mult
Greedy Joker
Played cards with Diamond suit give +3 Mult when scored
Crazy Joker
+12 Mult if played hand contains a Straight
Runner
Gains +15 Chips if played hand contains a Straight
All of these jokers just help increase the score
This Joker fundamentally changes the rules!
Playing with the Shortcut Joker I felt like I was getting loads of straights easily! But can this be quantified?
But first, a simpler question
You just do it, and it works: 73,870,336 of 752,538,150 hands, 9.82%
Paul Stanford · Permutive · London Scala User Group
5 cards
First we can work out how many straights exist if we ignore suits
To do this we need only consider the rank sets of a hand
I define a "rank set" as the set of distinct ranks in a hand
5 cards
For each card we have 4 choices of suit, and there are 5 cards
\(4^5 = 1{,}024\)
This is just a handful of examples with the first rank set, A to 5. Well, a few handfuls I guess!
5 cards
All 1,024 ways to choose suits for one rank set
5 cards
How many hands of 6 cards contain a straight?
10,240 5-card straights multiplied by 47 choices of sixth card = 481,280
But brute force says 367,616. So what did I do wrong?
If I have a run of 6 cards there's always going to be 2 ways to get to it!
More subtly if I have a hand with a straight and a duplicate rank there's also going to be two ways to get to it!
There are two different types of double counting which correspond to different "templates" for the hand; the difference is the number of distinct ranks in each hand
Each template can be thought of as a multiset
six distinct ranks
\(\{1, 1, 1, 1, 1, 1\}\)
five distinct ranks, one pair
\(\{2, 1, 1, 1, 1\}\)
A set is an unordered collection of objects where each object can appear at most once
A multiset is like a set but each
element can appear multiple times; each element has a
multiplicity. In Scala terms it is
a bit like a Map[A, Int],
from each element to its multiplicity
We can denote a multiset more compactly by using exponents to count how many times each element appears: \(\{2, 1, 1, 1, 1\} = \{2, 1^4\}\) and \(\{1, 1, 1, 1, 1, 1\} = \{1^6\}\)
Each multiset corresponds to a template for our hand; there are many possible ways to fill in this template by choosing different suits and choosing which ranks get paired up (or later tripled up)
I call these templates degeneracy classes because different templates have different repeated (or degenerate) ranks
\(\{2, 1^4\}\)
We only care about the number of rank sets that contain a straight. As with the 5 card case we only have 5 distinct ranks here so we have \(S = 10\).
Write it \(S(r)\), with \(r\) the number of distinct ranks: \(S(5) = 10\)
\(\{2, 1^4\}\)
A placement says which rank plays which role (i.e. which rank gets to be a pair, which gets to be a triple, etc). We can let \(P(d)\) denote the total placements for a degeneracy class \(d\).
Which rank gets the pair? 5 choices: \(P = 5\)
Or: the distinct orderings of \(\{2, 1, 1, 1, 1\}\) along the five ranks. 2 1 1 1 1, 1 2 1 1 1, … five of them
the pair
Which 2 of the 4 suits does the pair get? 6 ways
Written \(\binom{4}{2}\), "4 choose 2": the number of ways to choose 2 things from 4
Each single picks 1 suit of 4: \(\binom{4}{1} = 4\) ways
\(Su = \binom{4}{2}\binom{4}{1}^4 = 6 \times 256 = 1{,}536\)
\(S(5) \times P \times Su = 10 \times 5 \times 1{,}536 = 76{,}800\)
| ♠ | ♥ | ♣ | ♦ |
|---|---|---|---|
| ✓ | ✓ | ✗ | ✗ |
| ✓ | ✗ | ✓ | ✗ |
| ✓ | ✗ | ✗ | ✓ |
| ✗ | ✓ | ✓ | ✗ |
| ✗ | ✓ | ✗ | ✓ |
| ✗ | ✗ | ✓ | ✓ |
\(\binom{4}{2}\) is the number of distinct orderings of {✓, ✓, ✗, ✗} along the four suits
Four different things line up in \(4! = 4 \times 3 \times 2 \times 1 = 24\) ways
Swapping the two ✓s, or the two ✗s, changes nothing: divide by \(2!\) twice
\(\binom{4}{2} = \dfrac{4!}{2!\,2!} = \dfrac{24}{4} = 6\)
In general \(\binom{n}{k} = \dfrac{n!}{k!\,(n-k)!}\)
\((x+y)^4 = x^4 + 4x^3y + 6x^2y^2 + 4xy^3 + y^4\): the 6 is the orderings of \(x\,x\,y\,y\)
And \(\binom{52}{8} = 752{,}538{,}150\): every 8-card hand.
\(\{1^6\}\), no duplicates
Either a run of six ranks: 9 of them
Or a 5-card straight plus a rank that doesn't "touch" it: 62
\(S(6) = 9 + 62 = 71\)
\(P = 1\), \(Su = \binom{4}{1}^6\)
\(71 \times 4{,}096 = 290{,}816\)
A 5-card straight, plus a sixth rank that doesn't "touch" it
8 straights sit in the middle: \(13 - 5 - 2 = 6\) free ranks each
2 straights end on an Ace: \(13 - 5 - 1 = 7\) free ranks each
\(8 \times 6 + 2 \times 7 = 62\)
| class | multiset | \(r\) | \(S(r)\) | \(P(d)\) | \(Su(d)\) | product |
|---|---|---|---|---|---|---|
| no duplicates | \(\{1^6\}\) | 6 | 71 | \(\binom{6}{6} = 1\) | \(\binom{4}{1}^{6} = 4{,}096\) | 290,816 |
| one pair | \(\{2^{1}, 1^4\}\) | 5 | 10 | \(\binom{5}{1} = 5\) | \(\binom{4}{2}\binom{4}{1}^{4} = 1{,}536\) | 76,800 |
| sum | 367,616 |
Every hand is now built exactly once, the degeneracy classes can't ever overlap
Everything else, the suits and the placements, is just counting how many different hands share that rank set
That's why \(S(r)\) needs nothing but \(r\)
And there are only \(2^{13} = 8{,}192\) possible rank sets since each rank either appears or it doesn't. This is far fewer than the total number of hands
$$\text{hands with a straight} = \sum_{d} S(r)\, P(d)\, Su(d)$$
We can derive a formula
I was unable to derive a formula so used Scala
\(\{\textcolor{#fcecb0}{\mathbf{3}}, \textcolor{#ffd6da}{\mathbf{2}}, \textcolor{#ffffff}{\mathbf{1}}^3\}\)
the triple the pair
\(P(d)\) is the number of distinct orderings of \(\{\textcolor{#fcecb0}{\mathbf{3}}, \textcolor{#ffd6da}{\mathbf{2}}, \textcolor{#ffffff}{\mathbf{1}}, \textcolor{#ffffff}{\mathbf{1}}, \textcolor{#ffffff}{\mathbf{1}}\}\) along the ranks 3 to 7
\(P(d) = \dfrac{5!}{\textcolor{#fcecb0}{\mathbf{1!}}\,\textcolor{#ffd6da}{\mathbf{1!}}\,\textcolor{#ffffff}{\mathbf{3!}}} = \dfrac{120}{6} = 20\)
Another way to think about this would be to consider which rank gets to be a triple (5 choices) and then which rank gets to be a pair (4 choices.) But we shall see that the "orderings" approach is more generalisable
\(\{\textcolor{#fcecb0}{\mathbf{3}}, \textcolor{#ffd6da}{\mathbf{2}}^2, \textcolor{#ffffff}{\mathbf{1}}^2\}\)
the triple the pairs
9 cards: a triple, two pairs and two singles, on the ranks 3 to 7
\(P(d)\) is the number of distinct orderings of \(\{\textcolor{#fcecb0}{\mathbf{3}}, \textcolor{#ffd6da}{\mathbf{2}}, \textcolor{#ffd6da}{\mathbf{2}}, \textcolor{#ffffff}{\mathbf{1}}, \textcolor{#ffffff}{\mathbf{1}}\}\)
\(P(d) = \dfrac{5!}{\textcolor{#fcecb0}{\mathbf{1!}}\,\textcolor{#ffd6da}{\mathbf{2!}}\,\textcolor{#ffffff}{\mathbf{2!}}} = \dfrac{120}{4} = 30\)
5 choices for the triple, then \(\binom{4}{2} = 6\) for the two pairs: \(5 \times 6 = 30\)
| 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|
| \(\textcolor{#fcecb0}{\mathbf{3}}\) | \(\textcolor{#ffd6da}{\mathbf{2}}\) | \(\textcolor{#ffffff}{\mathbf{1_A}}\) | \(\textcolor{#ffffff}{\mathbf{1_B}}\) | \(\textcolor{#ffffff}{\mathbf{1_C}}\) |
| \(\textcolor{#fcecb0}{\mathbf{3}}\) | \(\textcolor{#ffd6da}{\mathbf{2}}\) | \(\textcolor{#ffffff}{\mathbf{1_A}}\) | \(\textcolor{#ffffff}{\mathbf{1_C}}\) | \(\textcolor{#ffffff}{\mathbf{1_B}}\) |
| \(\textcolor{#fcecb0}{\mathbf{3}}\) | \(\textcolor{#ffd6da}{\mathbf{2}}\) | \(\textcolor{#ffffff}{\mathbf{1_B}}\) | \(\textcolor{#ffffff}{\mathbf{1_A}}\) | \(\textcolor{#ffffff}{\mathbf{1_C}}\) |
| \(\textcolor{#fcecb0}{\mathbf{3}}\) | \(\textcolor{#ffd6da}{\mathbf{2}}\) | \(\textcolor{#ffffff}{\mathbf{1_B}}\) | \(\textcolor{#ffffff}{\mathbf{1_C}}\) | \(\textcolor{#ffffff}{\mathbf{1_A}}\) |
| \(\textcolor{#fcecb0}{\mathbf{3}}\) | \(\textcolor{#ffd6da}{\mathbf{2}}\) | \(\textcolor{#ffffff}{\mathbf{1_C}}\) | \(\textcolor{#ffffff}{\mathbf{1_A}}\) | \(\textcolor{#ffffff}{\mathbf{1_B}}\) |
| \(\textcolor{#fcecb0}{\mathbf{3}}\) | \(\textcolor{#ffd6da}{\mathbf{2}}\) | \(\textcolor{#ffffff}{\mathbf{1_C}}\) | \(\textcolor{#ffffff}{\mathbf{1_B}}\) | \(\textcolor{#ffffff}{\mathbf{1_A}}\) |
ranks across the top, card counts below:
six line-ups,
one placement
Label the singles A, B and C: \(\{\textcolor{#fcecb0}{\mathbf{3}}, \textcolor{#ffd6da}{\mathbf{2}}, \textcolor{#ffffff}{\mathbf{1_A}}, \textcolor{#ffffff}{\mathbf{1_B}}, \textcolor{#ffffff}{\mathbf{1_C}}\}\) lines up in \(5! = 120\) ways
Shuffling the labels changes nothing: every placement shows up \(3! = 6\) times
\(P = \dfrac{5!}{\textcolor{#fcecb0}{\mathbf{1!}}\,\textcolor{#ffd6da}{\mathbf{1!}}\,\textcolor{#ffffff}{\mathbf{3!}}} = \dfrac{120}{6} = 20\)
That is a multinomial coefficient, \(\binom{5}{\textcolor{#fcecb0}{\mathbf{1}},\,\textcolor{#ffd6da}{\mathbf{1}},\,\textcolor{#ffffff}{\mathbf{3}}}\): the distinct orderings of a multiset
\((\textcolor{#fcecb0}{\boldsymbol{x}}+\textcolor{#ffd6da}{\boldsymbol{y}}+\textcolor{#ffffff}{\boldsymbol{z}})^5\): the coefficient of \(\textcolor{#fcecb0}{\boldsymbol{x}}\,\textcolor{#ffd6da}{\boldsymbol{y}}\,\textcolor{#ffffff}{\boldsymbol{z}}^3\) is \(\binom{5}{\textcolor{#fcecb0}{\mathbf{1}},\,\textcolor{#ffd6da}{\mathbf{1}},\,\textcolor{#ffffff}{\mathbf{3}}} = 20\), the orderings of \(\textcolor{#fcecb0}{\boldsymbol{x}}\,\textcolor{#ffd6da}{\boldsymbol{y}}\,\textcolor{#ffffff}{\boldsymbol{z}}\,\textcolor{#ffffff}{\boldsymbol{z}}\,\textcolor{#ffffff}{\boldsymbol{z}}\)
A binomial is just the two-bucket case: \(\binom{n}{k} = \binom{n}{k,\,n-k}\)
\(\{\textcolor{#fcecb0}{\mathbf{3}}, \textcolor{#ffd6da}{\mathbf{2}}, \textcolor{#ffd6da}{\mathbf{2}}, \textcolor{#ffffff}{\mathbf{1}}, \textcolor{#ffffff}{\mathbf{1}}\}\): a triple, two pairs and two singles
Label the pairs A and B, and the singles A and B: \(\{\textcolor{#fcecb0}{\mathbf{3}}, \textcolor{#ffd6da}{\mathbf{2_A}}, \textcolor{#ffd6da}{\mathbf{2_B}}, \textcolor{#ffffff}{\mathbf{1_A}}, \textcolor{#ffffff}{\mathbf{1_B}}\}\) lines up in \(5! = 120\) ways
Swapping the two pairs changes nothing: divide by \(\textcolor{#ffd6da}{\mathbf{2!}}\)
Swapping the two singles changes nothing either: divide by \(\textcolor{#ffffff}{\mathbf{2!}}\) again
\(P = \dfrac{5!}{\textcolor{#fcecb0}{\mathbf{1!}}\,\textcolor{#ffd6da}{\mathbf{2!}}\,\textcolor{#ffffff}{\mathbf{2!}}} = \dfrac{120}{4} = 30 = \binom{5}{\textcolor{#fcecb0}{\mathbf{1}},\,\textcolor{#ffd6da}{\mathbf{2}},\,\textcolor{#ffffff}{\mathbf{2}}}\)
\((\textcolor{#fcecb0}{\boldsymbol{x}}+\textcolor{#ffd6da}{\boldsymbol{y}}+\textcolor{#ffffff}{\boldsymbol{z}})^5\): the coefficient of \(\textcolor{#fcecb0}{\boldsymbol{x}}\,\textcolor{#ffd6da}{\boldsymbol{y}}^2\,\textcolor{#ffffff}{\boldsymbol{z}}^2\) is 30, the orderings of \(\textcolor{#fcecb0}{\boldsymbol{x}}\,\textcolor{#ffd6da}{\boldsymbol{y}}\,\textcolor{#ffd6da}{\boldsymbol{y}}\,\textcolor{#ffffff}{\boldsymbol{z}}\,\textcolor{#ffffff}{\boldsymbol{z}}\)
$$\binom{n}{k_{1}, k_{2}, \ldots, k_{m}} = \frac{n!}{k_{1}! k_{2}! \cdots k_{m}!}$$
The number of distinct orderings of a multiset of \(n\) elements, where \(k_i\) is the multiplicity of the \(i\)th element
so \(n = k_1 + k_2 + \cdots + k_m\)
\(\{3^1, 2^1, 1^3\}\)
Under each rank, every way to assign the suits
| card count | multiplicity | suit factor |
|---|---|---|
| 3 | 1 | \(\binom{4}{3} = 4\) |
| 2 | 1 | \(\binom{4}{2} = 6\) |
| 1 | 3 | \(\binom{4}{1}^{3} = 64\) |
\(Su(d) = \binom{4}{3}\binom{4}{2}\binom{4}{1}^3\)
\(= 4 \times 6 \times 64 = 1{,}536\)
\(\{3, 2, 1^3\}\): card counts \(a_1, a_2, a_3 = 3, 2, 1\); multiplicities \(m(3) = 1,\ m(2) = 1,\ m(1) = 3\); \(t = 3\); \(r = 5\)
$$\{ a_{1}^{m(a_{1})} , a_{2}^{m(a_{2})} , \ldots , a_{t}^{m(a_{t})} \}$$
$$Su(\{a_1^{m(a_1)}, \ldots, a_t^{m(a_t)}\}) = \prod_{i=1}^{t} \binom{4}{a_i}^{m(a_i)}$$
$$\begin{aligned} P(\{a_1^{m(a_1)},a_2^{m(a_2)} \ldots, a_t^{m(a_t)}\}) &= \binom{r}{m(a_1),m(a_2), \ldots, m(a_t)} \\ &= \frac{r!}{m(a_1)!m(a_2)!\cdots m(a_t)!} \end{aligned}$$
| class | multiset | \(r\) | \(S(r)\) | \(P(d)\) | \(Su(d)\) |
|---|---|---|---|---|---|
| no duplicates | \(\{1^{8}\}\) | 8 | ? | \(\binom{8}{8} = 1\) | \(\binom{4}{1}^{8} = 65{,}536\) |
| one pair | \(\{2^{1}, 1^{6}\}\) | 7 | ? | \(\binom{7}{1,6} = 7\) | \(\binom{4}{2}\binom{4}{1}^{6} = 24{,}576\) |
| two pairs | \(\{2^{2}, 1^{4}\}\) | 6 | 71 | \(\binom{6}{2,4} = 15\) | \(\binom{4}{2}^{2}\binom{4}{1}^{4} = 9{,}216\) |
| three of a kind | \(\{3^{1}, 1^{5}\}\) | 6 | 71 | \(\binom{6}{1,5} = 6\) | \(\binom{4}{3}\binom{4}{1}^{5} = 4{,}096\) |
| three pairs | \(\{2^{3}, 1^{2}\}\) | 5 | 10 | \(\binom{5}{3,2} = 10\) | \(\binom{4}{2}^{3}\binom{4}{1}^{2} = 3{,}456\) |
| full house | \(\{3^{1}, 2^{1}, 1^{3}\}\) | 5 | 10 | \(\binom{5}{1,1,3} = 20\) | \(\binom{4}{3}\binom{4}{2}\binom{4}{1}^{3} = 1{,}536\) |
| four of a kind | \(\{4^{1}, 1^{4}\}\) | 5 | 10 | \(\binom{5}{1,4} = 5\) | \(\binom{4}{4}\binom{4}{1}^{4} = 256\) |
We have a "nice" formula for two columns but not for \(S\) sadly.
$$\text{hands with a straight} = \sum_{d} S(r)\, P(d)\, Su(d)$$
An integer partition of 8 writes 8 as a sum of positive whole numbers, order ignored
| class | partition of 8 | multiset | \(r\) |
|---|---|---|---|
| no duplicates | \(1{+}1{+}1{+}1{+}1{+}1{+}1{+}1\) | \(\{1^{8}\}\) | 8 |
| one pair | \(2{+}1{+}1{+}1{+}1{+}1{+}1\) | \(\{2^{1}, 1^{6}\}\) | 7 |
| two pairs | \(2{+}2{+}1{+}1{+}1{+}1\) | \(\{2^{2}, 1^{4}\}\) | 6 |
| three of a kind | \(3{+}1{+}1{+}1{+}1{+}1\) | \(\{3^{1}, 1^{5}\}\) | 6 |
| three pairs | \(2{+}2{+}2{+}1{+}1\) | \(\{2^{3}, 1^{2}\}\) | 5 |
| full house | \(3{+}2{+}1{+}1{+}1\) | \(\{3^{1}, 2^{1}, 1^{3}\}\) | 5 |
| four of a kind | \(4{+}1{+}1{+}1{+}1\) | \(\{4^{1}, 1^{4}\}\) | 5 |
There are actually 22 partitions of 8 but only 7 of them are relevant to us.
Parts of at most 4, because there are 4 suits. At least 5 parts, because a straight needs 5 ranks
\(\{2^2, 1^4\}\) is
Map(2 -> 2, 1 -> 4): card
count to multiplicity
:| is iron: a refined
Int the compiler knows is in
range
Each branch picks the next part, never bigger than the one before;
maxPart = 4 rules out 5 and 6
● at least 5 parts, kept ● dropped by the filter
The two survivors are the two six-card templates: \(\{1^6\}\) and \(\{2, 1^4\}\)
List(2, 2, 1, 1, 1, 1) becomes
Map(2 -> 2, 1 -> 4)
groupMapReduce: group equal
parts, map each to 1, add up the 1s
This is what my Show instance
(cats' type class for printing) spits out
$$\begin{aligned} P(\{a_1^{m(a_1)},a_2^{m(a_2)} \ldots, a_t^{m(a_t)}\}) &= \binom{r}{m(a_1),m(a_2), \ldots, m(a_t)} \\ &= \frac{r!}{m(a_1)!m(a_2)!\cdots m(a_t)!} \end{aligned}$$
d.values are the multiplicities
\(m(a_i)\), and they add up to \(r\)
$$Su(\{a_1^{m(a_1)}, \ldots, a_t^{m(a_t)}\}) = \prod_{i=1}^{t} \binom{4}{a_i}^{m(a_i)}$$
Base case: the ten straights (allFiveRankStraights, next slide). Step: add any rank the set doesn't have; still a
straight. Repeat.
Ten starting ranks, Ace to Ten. The
% 13 wraps King round to Ace,
so Ten gives T J Q K A. Nothing starts above Ten, so nothing wraps
any further: no Q K A 2 3.
the added
rank
built
twice, but deduped because I'm using
Set
Every straight, plus every rank it doesn't have: \(10 \times 8 = 80\) rank sets
Each of the 9 runs of six is built twice, so the
Set keeps \(80 - 9 = 71 =
S(6)\)
10 and 71 match what we counted by hand. Not in the OEIS (the On-Line Encyclopedia of Integer Sequences), sadly.
| class | multiset | \(r\) | \(S(r)\) | \(P(d)\) | \(Su(d)\) | product |
|---|---|---|---|---|---|---|
| no duplicates | \(\{1^{8}\}\) | 8 | 371 | \(\binom{8}{8} = 1\) | \(\binom{4}{1}^{8} = 65{,}536\) | 24,313,856 |
| one pair | \(\{2^{1}, 1^{6}\}\) | 7 | 217 | \(\binom{7}{1,6} = 7\) | \(\binom{4}{2}\binom{4}{1}^{6} = 24{,}576\) | 37,330,944 |
| two pairs | \(\{2^{2}, 1^{4}\}\) | 6 | 71 | \(\binom{6}{2,4} = 15\) | \(\binom{4}{2}^{2}\binom{4}{1}^{4} = 9{,}216\) | 9,815,040 |
| three of a kind | \(\{3^{1}, 1^{5}\}\) | 6 | 71 | \(\binom{6}{1,5} = 6\) | \(\binom{4}{3}\binom{4}{1}^{5} = 4{,}096\) | 1,744,896 |
| three pairs | \(\{2^{3}, 1^{2}\}\) | 5 | 10 | \(\binom{5}{3,2} = 10\) | \(\binom{4}{2}^{3}\binom{4}{1}^{2} = 3{,}456\) | 345,600 |
| full house | \(\{3^{1}, 2^{1}, 1^{3}\}\) | 5 | 10 | \(\binom{5}{1,1,3} = 20\) | \(\binom{4}{3}\binom{4}{2}\binom{4}{1}^{3} = 1{,}536\) | 307,200 |
| four of a kind | \(\{4^{1}, 1^{4}\}\) | 5 | 10 | \(\binom{5}{1,4} = 5\) | \(\binom{4}{4}\binom{4}{1}^{4} = 256\) | 12,800 |
| total: 9.82% | 73,870,336 | |||||
| Hand size | Total hands | With a straight | Probability |
|---|---|---|---|
| 5 | 2,598,960 | 10,240 | 0.39% |
| 6 | 20,358,520 | 367,616 | 1.81% |
| 7 | 133,784,560 | 6,454,272 | 4.82% |
| 8 | 752,538,150 | 73,870,336 | 9.82% |
| 9 | 3,679,075,400 | 619,588,736 | 16.84% |
| 10 | 15,820,024,220 | 4,051,217,344 | 25.61% |
| 11 | 60,403,728,840 | 21,461,806,976 | 35.53% |
| 12 | 206,379,406,870 | 94,674,009,184 | 45.87% |
| 13 | 635,013,559,600 | 355,161,047,872 | 55.93% |
$$\sum_{d} \textcolor{#f4c430}{S_g(r)}\, P(d)\, Su(d)$$
Only \(S\) knows what a straight is, so only \(S\) changes: \(S(r)\) becomes \(S_g(r)\), with \(g\) the biggest gap allowed
Normal straights correspond to \(S_0\). The Shortcut Joker corresponds to \(S_1\). \(P(d)\) and \(Su(d)\) remain the same
The recursion for \(S\) still works, so only its base case changes
Only the base case changes:
allFiveRankStraights(maxGap)
builds a tree of straights from every starting rank
Start with the Ace low straight
And then generate the rest by increasing all ranks by one
From an Ace the next rank can be a 2 or a 3! Each time we select the next rank there are actually 2 choices
\(2^4 = 16\) Ace-low gappy straights
The same tree from every start
● a gappy straight ● past the Ace, pruned
128 gappy straights, instead of 10
Fewer than the \(16 \times 10 = 160\) the tree suggests: trees that start high get pruned at the Ace
Add 1 to everything each round, kicking out anything past the high Ace, until nothing is left
Then flatten, and map the ordinals back to ranks: 128 gappy straights
| class | multiset | \(r\) | \(S_1(r)\) | \(P(d)\) | \(Su(d)\) | product |
|---|---|---|---|---|---|---|
| no duplicates | \(\{1^{8}\}\) | 8 | 1,156 | \(\binom{8}{8} = 1\) | \(\binom{4}{1}^{8} = 65{,}536\) | 75,759,616 |
| one pair | \(\{2^{1}, 1^{6}\}\) | 7 | 1,096 | \(\binom{7}{1,6} = 7\) | \(\binom{4}{2}\binom{4}{1}^{6} = 24{,}576\) | 188,547,072 |
| two pairs | \(\{2^{2}, 1^{4}\}\) | 6 | 576 | \(\binom{6}{2,4} = 15\) | \(\binom{4}{2}^{2}\binom{4}{1}^{4} = 9{,}216\) | 79,626,240 |
| three of a kind | \(\{3^{1}, 1^{5}\}\) | 6 | 576 | \(\binom{6}{1,5} = 6\) | \(\binom{4}{3}\binom{4}{1}^{5} = 4{,}096\) | 14,155,776 |
| three pairs | \(\{2^{3}, 1^{2}\}\) | 5 | 128 | \(\binom{5}{3,2} = 10\) | \(\binom{4}{2}^{3}\binom{4}{1}^{2} = 3{,}456\) | 4,423,680 |
| full house | \(\{3^{1}, 2^{1}, 1^{3}\}\) | 5 | 128 | \(\binom{5}{1,1,3} = 20\) | \(\binom{4}{3}\binom{4}{2}\binom{4}{1}^{3} = 1{,}536\) | 3,932,160 |
| four of a kind | \(\{4^{1}, 1^{4}\}\) | 5 | 128 | \(\binom{5}{1,4} = 5\) | \(\binom{4}{4}\binom{4}{1}^{4} = 256\) | 163,840 |
| total | 366,608,384 | |||||
| \(r\) | \(S_0(r)\) | \(S_1(r)\) |
|---|---|---|
| 5 | 10 | 128 |
| 6 | 71 | 576 |
| 7 | 217 | 1,096 |
| 8 | 371 | 1,156 |
| 9 | 384 | 709 |
| 10 | 234 | 286 |
| 11 | 77 | 78 |
| 12 | 13 | 13 |
| 13 | 1 | 1 |
The recursive step is the same, it's just that with gappy straights we have more to begin with!
$$\frac{366{,}608{,}384}{752{,}538{,}150} = 48.72\%$$
Without the joker it was about 10%, so having this joker makes getting a straight 5 times easier!!!
| Hand size | Gap 0 | Gap 1 | Gap 2 | Gap 3 | Gap 4 |
|---|---|---|---|---|---|
| 5 | 0.39% | 5.04% | 18.56% | 33.69% | 43.26% |
| 6 | 1.81% | 16.42% | 41.95% | 62.84% | 74.68% |
| 7 | 4.82% | 31.99% | 62.07% | 80.36% | 89.56% |
| 8 | 9.82% | 48.72% | 76.83% | 89.87% | 95.71% |
| 9 | 16.84% | 63.94% | 86.66% | 94.89% | 98.20% |
| 10 | 25.61% | 76.17% | 92.73% | 97.50% | 99.23% |
| 11 | 35.53% | 85.07% | 96.23% | 98.82% | 99.68% |
| 12 | 45.87% | 91.06% | 98.13% | 99.46% | 99.87% |
| 13 | 55.93% | 94.86% | 99.11% | 99.76% | 99.95% |
Gap 0 is a normal straight. Gap 1 is the Shortcut Joker. Gaps 2 to 4 need a joker that doesn't exist yet
$$\sum_{d} \textcolor{#f4c430}{S_g(r)}\, P(d)\, Su(d)$$
Four Fingers
Which parts of \(\sum_{d} S(r)\, P(d)\, Su(d)\) change?
What are the odds of a straight in 8 cards? And with the Shortcut Joker as well?
The blog post: stanosphere.github.io/blog/counting-balatro-straights