Chapter 252
How Many Pennies Should You Pinch?
The Riddler for January 24, 2020. The Express counts the most players a Hall-of-Fame ballot can possibly admit; the Classic is a two-pile coin game, “Pinching Pennies,” that turns out to be a famous piece of game theory in disguise.
Riddler Express
There are players on the Baseball Hall of Fame ballot and voters. Each voter may select up to players (no player more than once), and a player is inducted only if named on at least of the ballots. What is the maximum number of players that can be inducted?
The Riddler, FiveThirtyEight, January 24, 2020(original post)
Solution
Count the votes two ways. Each of the voters names at most players, so at most votes are cast in total. Each inducted player needs at least of of them. If players are inducted they soak up at least votes, and forces
Thirteen is achievable. Label the players through and split the voters into four blocs of , each bloc casting a full votes: Now appears in all four blocs ( votes), and each of the other twelve appears in exactly three ( votes), so all clear the bar. The answer is Notice the count depends only on the ballot cap and the threshold: , independent of the number of candidates or voters.
The computation
Tally the four-bloc construction to confirm players reach votes, and confirm is impossible against the -vote ceiling.
blocs = ["ABCDEFGHIJ", "DEFGHIJKLM", "ABCGHIJKLM", "ABCDEFJKLM"]
from collections import Counter
votes = Counter(p for b in blocs for p in b) # each bloc = 100 voters
inducted = [p for p, c in votes.items() if 100*c >= 300]
print(len(inducted), 4000 // 300) # 13 13
print(14 * 300 > 4000) # True: 14 impossible
The construction inducts players, matching the ceiling , while would need votes.
Riddler Classic
The game “Pinching Pennies” starts with between and pennies, which your opponent divides into two piles any way they like. You then alternate turns, you first: on a turn a player removes any positive number of pennies from one pile, or the same positive number from both piles. The player who takes the last penny wins. If both play optimally, which starting totals (between and ) guarantee that you can win?
The Riddler, FiveThirtyEight, January 24, 2020(original post)
Solution
Call a two-pile position cold if the player about to move from it loses under best play, and hot otherwise. The recursion is the usual one: a position is cold exactly when every legal move leads to a hot position. The empty position is cold (the mover has no penny to take, so the previous player took the last one and won). Building up from there, the cold positions are the celebrated pairs of Wythoff’s game, whose coordinates track the golden ratio. From any other (hot) position the mover can always reach a cold one and hand the loss to the opponent.
Now read the puzzle’s roles carefully. Your opponent chooses how to split the total, and then you move first. A clever opponent will hand you a cold split if the total admits one, since the mover from a cold position loses. So you are guaranteed to win precisely when no split of the total is a cold position. The totals of the cold pairs above are and within to the only ones hit are , and . For every other total no split is cold, so you win. The guaranteed-win totals are On , and the opponent wins by dealing you , or .
The computation
Label every position cold or hot by the recursion (a position is cold iff all its moves lead to hot positions), then for each total to test whether the opponent can choose a cold split; you win exactly when none exists.
M = 31
cold = [[False]*(M+1) for _ in range(M+1)]
for x in range(M+1):
for y in range(M+1):
moves = [(x-k, y) for k in range(1, x+1)]
moves += [(x, y-k) for k in range(1, y+1)]
moves += [(x-k, y-k) for k in range(1, min(x, y)+1)]
cold[x][y] = all(not cold[a][b] for a, b in moves) if moves else True
win = [n for n in range(20, 31)
if not any(cold[a][n-a] for a in range(n+1) if a <= M and n-a <= M)]
print(win) # [20, 22, 23, 25, 26, 27, 28, 30]
The totals with no cold split, hence guaranteed wins for you, are exactly the boxed eight.