Skip to content
Vamshi Jandhyala

Books · The Fiddler: Solutions

Chapter 94

Can You Win at Non-Traditional Blackjack?

A deck has exactly ten cards, numbered 11 through 1010 (the 11 is always worth one). You shuffle and draw one card at a time, keeping a running total, and stop as soon as the total is at least 2121. If it is exactly 2121 you win; if it overshoots, you bust. What is your probability of winning?

The Fiddler, Zach Wissner-Gross, May 24, 2024(original post)

Solution

Work forward through the draws. From a running total s<21s<21 with a set RR of cards still in the deck, the next card cc is equally likely to be any of RR: if s+c=21s+c=21 you win, if s+c>21s+c>21 you bust, and otherwise you carry on from s+cs+c with that card removed. So the win probability obeys W(s,R)=1RcR{1s+c=21,0s+c>21,W(s+c,R{c})s+c<21.W(s,R)=\frac{1}{|R|}\sum_{c\in R} \begin{cases}1 & s+c=21,\\[2pt] 0 & s+c>21,\\[2pt] W(s+c,\,R\setminus\{c\}) & s+c<21.\end{cases} Unwinding this from the empty table over the full deck, W(0,{1,,10})W(0,\{1,\dots,10\}), gives 740=17.5%.\boxed{\tfrac{7}{40}}=17.5\%. Landing exactly on 2121 is delicate: most paths either skid past it or stop just short.

The computation

The recurrence is exact, so evaluating it is the computation: memoise WW on the running total and the remaining cards, summing the three cases over the actual draws in rational arithmetic.

from fractions import Fraction as F
from functools import lru_cache
@lru_cache(maxsize=None)
def W(s, R):                                       # R: frozenset of remaining cards
    n = len(R); total = F(0)
    for c in R:
        t = s + c
        if t == 21:   total += F(1, n)
        elif t < 21:  total += F(1, n) * W(t, R - frozenset([c]))
        # t > 21: bust, contributes 0
    return total
print(W(0, frozenset(range(1, 11))))               # 7/40

Extra Credit

Now play it safe: the moment any remaining card could possibly bust you, you stop the round and reshuffle for a fresh one. On average, how many rounds until you finally win?

Solution

Under the cautious rule you draw only while every remaining card keeps you at 2121 or below, that is while s+max(R)21s+\max(R)\le21; the instant a bust becomes possible you stop and start a fresh round. A round is won if it reaches exactly 2121 before that safety margin runs out. The per-round win probability, computed by the same forward recurrence with the new stopping rule, is 13630\tfrac{13}{630}. Rounds are independent, so the number until a win is geometric, with mean 113/630= 63013 48.5.\frac{1}{13/630}= \boxed{\ \frac{630}{13}\ }\approx48.5 . Caution rarely pays: refusing ever to risk a bust means you almost always stop short of 2121, and it takes about fifty fresh deals to finally land it.

The computation

The same recursion, now stopping the round as soon as any remaining card could bust, gives the per-round win probability and hence the expected number of rounds.

@lru_cache(maxsize=None)
def safe(s, R):                                    # P(round won) playing risk-averse
    if s == 21: return F(1)
    if not R or s + max(R) > 21: return F(0)        # any bust possible -> stop the round
    n = len(R)
    return sum(F(1, n) * safe(s + c, R - frozenset([c])) for c in R)
p = safe(0, frozenset(range(1, 11)))
print(p, 1 / p)                                    # 13/630   630/13