Chapter 73
Can You Systematically Solve A Friday Crossword?
Riddler Express
You are on points and must reach exactly (going over loses) with four bean-bag tosses. Each toss you choose: aggressive ( in the hole for , on the board for , miss), conservative (, , ), or a deliberate waste ( for sure). Playing optimally, what is your probability of finishing on exactly ?
Solution
You need exactly more points and must never exceed them. Work backwards over the throws, tracking how many points you still have in hand. Let be your best chance of finishing on when you have points and tosses left. Any score above is an instant loss (), and with no tosses left you succeed only if . Otherwise you pick the best of the three throws (aggressive, conservative, waste, top to bottom), The waste option matters: once you reach you simply waste the rest and lock in the win. Evaluating gives The optimal play opens aggressively while there is room for a , then turns conservative or wastes throws to protect a reachable exact total.
The computation
Recurse over (tosses left, points), taking the best throw at each state and treating any overshoot as a loss.
from fractions import Fraction as F
from functools import lru_cache
A = (F(4,10), F(3,10), F(3,10)); C = (F(1,10), F(8,10), F(1,10))
@lru_cache(None)
def P(k, x):
if x > 3: return F(0)
if k == 0: return F(1) if x == 3 else F(0)
throw = lambda h, b, m: h*P(k-1, x+3) + b*P(k-1, x+1) + m*P(k-1, x)
return max(throw(*A), throw(*C), P(k-1, x))
print(P(4, 0), float(P(4, 0))) # 2137/2500, 0.8548