Library · The Fiddler: Solutions · Chapter 66
Can You Hack Bowling?
In ten-pin bowling, a strike (all ten on the first ball) scores plus your next two balls; a spare (all ten in two balls) scores plus your next ball; an open frame scores the pins it knocks down. What is the minimum total number of pins you must knock down to reach a score of at least ?
The Fiddler, Zach Wissner-Gross, July 11, 2025(original post)
Solution
Strikes are the efficient move: each knocks ten pins but, through bonuses, can be worth up to thirty. Four strikes followed by a single frame of and already reaches exactly : knocking down pins. Since a strike yields the most score per pin, no game does better.
The computation
Search the efficient family of games, some leading strikes plus one ordinary frame, scoring each with the bowling rules and keeping the fewest pins that still reach . The minimum is , from four strikes and a .
def score(r):
s = i = 0
for _ in range(10):
if i >= len(r): break
if r[i] == 10: s += 10 + r[i+1] + r[i+2]; i += 1
else:
s += (10 + r[i+2]) if r[i] + r[i+1] == 10 else r[i] + r[i+1]; i += 2
return s
best, arg = 10**9, None
for k in range(0, 11): # k leading strikes
for a in range(11):
for b in range(11 - a): # one ordinary frame (a, b)
if score([10]*k + [a, b] + [0]*30) >= 100 and 10*k + a + b < best:
best, arg = 10*k + a + b, (k, a, b)
print(best, arg) # 44 (4, 2, 2)
Extra Credit
You and your opponent each play a game in which you knock down the same total number of pins, yet your scores differ as much as they possibly can. What is the greatest possible difference between the two scores?
Solution
The idea is to split every score into the pins themselves and the bonus on top. Each ball’s pins count once in the frame where they fall. A strike or spare in frames to then counts the next one or two balls a second time, and that repeat is the bonus. The tenth frame is different: its extra balls exist only to complete that frame, so they count once and earn no bonus of their own. Hence where the bonus comes from frames to alone.
An upper bound. A frame’s bonus is at most : a strike repeats the next two balls, worth at most each, and a spare repeats one ball. With nine frames able to earn a bonus, the bonus is at most . So for any pin total , the higher score is at most and the lower is at least . The difference can never exceed .
The bound is reached. Both bowlers knock down pins.
You bowl nine strikes, then strike, strike and in the tenth frame: pins. Frames to each score (each strike is followed by two more balls of ), and the tenth scores , so the total is .
Your opponent bowls then in each of frames to ( pins, no bonus), then three strikes in the tenth ( pins, counted once). That is pins and a score of exactly .
The difference is , the largest the bound allows: The tenth frame is what makes this work. Because its strikes earn nothing extra, the opponent can absorb pins there without a single bonus point, which lifts the bonus-free pin total from to . That leaves room for the other bowler to collect all nine maximal bonuses. Any total from to pins works equally well.
The computation
The check does not use the pins-plus-bonus split. It scores games ball by ball from the rules, bowling all ten frames over every legal combination of balls, and for each pin total it records the lowest and highest score possible. A full listing of games is far too large, but the only thing a frame passes on to later frames is how many extra times the next two balls will count. So the search carries, for each such pair of weights, a table of pin totals with their lowest and highest scores, and it extends that table one frame at a time.
def frame_options(last):
"""Every legal way to bowl one frame, as a list of balls."""
if not last:
yield [10] # strike
for a in range(10):
for b in range(11 - a):
yield [a, b] # spare or open frame
else: # the tenth frame
for a in range(10):
for b in range(10 - a):
yield [a, b] # open: two balls
for c in range(11):
yield [a, 10 - a, c] # spare: one bonus ball
for b in range(11):
for c in range(11 if b == 10 else 11 - b):
yield [10, b, c] # strike: two bonus balls
# state: extra weight carried by the next ball and the ball after it
# value: {pins: (lowest score, highest score)}
states = {(0, 0): {0: (0, 0)}}
for frame in range(10):
last = frame == 9
new = {}
for (w1, w2), table in states.items():
for balls in frame_options(last):
weights = [1 + w1, 1 + w2, 1][:len(balls)]
pts = sum(w*x for w, x in zip(weights, balls))
if last: nxt = (0, 0)
elif balls == [10]: nxt = (w2 + 1, 1) # strike: next two balls count again
elif sum(balls) == 10: nxt = (1, 0) # spare: next ball counts again
else: nxt = (0, 0)
pins = sum(balls)
slot = new.setdefault(nxt, {})
for p, (lo, hi) in table.items():
old = slot.get(p + pins, (10**9, -1))
slot[p + pins] = (min(old[0], lo + pts), max(old[1], hi + pts))
states = new
games = states[(0, 0)]
gap = max(hi - lo for lo, hi in games.values())
print("largest difference:", gap)
print("pin totals achieving it:", [p for p, (lo, hi) in games.items() if hi - lo == gap])
print("fewest pins for a score of 100:", min(p for p, (lo, hi) in games.items() if hi >= 100))
It prints
largest difference: 180
pin totals achieving it: [110, 111, 112, 113, 114, 115, 116, 117, 118, 119]
fewest pins for a score of 100: 44
The last line rechecks the main puzzle by the same exhaustive search.