Library · The Fiddler: Solutions · Chapter 146
Can You Bet Solely on Your Team’s Record?
Your home team, the Fiddle-delphia Eagles, has two games left in the season. Thanks to time travel you know they will win one and lose the other, but not in which order. You have $100, and before each game you may bet any amount you hold (fractions of a penny allowed) that the Eagles will win: bet and you gain if they win and lose if they lose. With the best strategy, how much money can you guarantee to have after both games, whichever order the results come in?
The Fiddler, Zach Wissner-Gross, August 25, 2023(original post)
The official solution appeared in the post of September 8, 2023 and gives $133.33 for the main puzzle and $827.47 for the Extra Credit. Both agree with the answers below.
Solution
Everything is decided by the first bet. Once the first game is played, the second result is no longer a mystery: it must be the opposite of the first.
Suppose you bet dollars on the first game. If the Eagles win it, you hold , and you know they will lose the next game, so you bet nothing and keep . If they lose it, you hold , and you know they will win the next game, so you bet everything and double it to .
You do not get to choose which of these happens, so what you can guarantee is the smaller of the two amounts. The first grows with and the second shrinks, so the smaller one is largest where they meet.
Setting gives , so dollars, and both outcomes then leave you with No other first bet does as well: a smaller one leaves less than this if the Eagles win first, and a larger one leaves less if they lose first.
The computation
The check plays the game as a contest against an opponent who picks the order of results to hurt you. With wins and losses still to come, you choose a bet, the opponent chooses whichever possible result leaves you worse off, and play continues. Write for the largest multiple of your money you can guarantee from there. Then , and otherwise is the best, over bet fractions , of the worse of and , where a result that can no longer happen is left out.
The program does not solve for the best by algebra. It searches for it: the worse of a rising and a falling line has a single peak, so a ternary search, which repeatedly discards the third of the interval that cannot hold the peak, homes in on it. Here runs from to , since you may only back the Eagles.
from functools import lru_cache
INF = float("inf")
def worst(x, win, lose):
"""Money left (as a multiple) in the worse of the two
possible results after betting fraction x on the Eagles.
A result that cannot happen is ignored (counted as INF)."""
a = (1 + x) * win if win < INF else INF
b = (1 - x) * lose if lose < INF else INF
return min(a, b)
@lru_cache(None)
def f(w, l, both_ways):
"""Largest guaranteed multiple of your money with w wins
and l losses still to come, in an unknown order."""
if w == 0 and l == 0:
return 1.0
win = f(w - 1, l, both_ways) if w else INF
lose = f(w, l - 1, both_ways) if l else INF
lo, hi = (-1.0 if both_ways else 0.0), 1.0
for _ in range(200): # ternary search: the worse
m1 = lo + (hi - lo) / 3 # of a rising and a falling
m2 = hi - (hi - lo) / 3 # line is unimodal in x
if worst(m1, win, lose) < worst(m2, win, lose):
lo = m1
else:
hi = m2
return worst((lo + hi) / 2, win, lose)
print(f"main: ${100 * f(1, 1, False):.2f}")
It prints
main: $133.33
Extra Credit
Now games remain, and you know the Eagles will win exactly of them, but not which. You may also bet on either team in each game (bet on either side and you win or lose ). With the best strategy, how much can you guarantee to have after the games?
Solution
Being allowed to back either side changes the character of the problem. A bet of on the Eagles is now just a bet with a sign: positive backs the Eagles, negative backs their opponents. The key fact is that every bet is fair in a bookkeeping sense. Whatever you hold before a game, call it , the two amounts you could hold after it are and , and these always add up to .
An upper limit. Imagine, just for counting, that the Eagles could produce any of the win and loss sequences, and follow your strategy along each one. After the first game the two branches hold amounts adding to . After the second, the four branches add to , because each pair of children adds to twice its parent. After all games, the final amounts over all sequences add up to You can never hold a negative amount, so the sequences that really can happen, those with exactly wins, share at most this total between them. There are of them. If you were guaranteed dollars on each, they would add up to at least , so
A strategy that reaches it. The bound is reached exactly when two things hold: every impossible sequence leaves you with nothing, and every possible sequence leaves you with the same amount. That suggests the strategy. At any moment, let be the number of games still to play and the number of ways the remaining results could still go (for instance, with wins and losses to come, ). Arrange to hold At the start, and , so , which is what you have. After the next game, the counts of possible continuations in the two branches add up to , and drops by one, so the two target amounts add up to Two targets adding to are exactly what one bet produces: back whichever side has the larger target, for the difference between that target and . When one result has become impossible its target is , and the bet is everything on the other side. At the end and , so you hold dollars whichever of the sequences occurred. So The same argument gives times your stake for wins and losses in any order. With one win and one loss that is , more than the of the main puzzle, because there you could not back the opponent in the first game.
The computation
The contest from The computation above, now letting the bet fraction run from to so that either side may be backed:
print(f"extra credit: ${100 * f(8, 4, True):.2f}")
It prints
extra credit: $827.47