Chapter 246
Can You Break The Riddler Bank?
Riddler Express
In a grid maze, the number in each box tells you how many spaces up, down, left, or right you must move (no diagonals). Starting at the yellow in the bottom-left corner, can you reach the asterisk?
The Riddler, FiveThirtyEight, October 18, 2019(original post)
Status
Solving the maze needs the published grid: the specific number printed in every box, which is given only as an image with no machine-readable transcription. Without those numbers the moves cannot be reconstructed. The puzzle has a definite answer (the asterisk is reachable, in as few as eight moves, found by working backwards from the goal or by a breadth-first search over the grid), but it is an image-specified path-finding puzzle.
The Express is therefore deferred from the worked-solution standard, in the same category as the column’s other image-only grid and maze puzzles. Were the grid transcribed, it would be a short breadth-first search.
Riddler Classic
Riddler Nation has two coins: the Dio ($) and the Phantus ($). The bank converts a dollar amount only if it can be written as a whole number of Dios and Phanti. What is the largest dollar amount that cannot be converted, i.e. the largest whole number not expressible as with ? Extra credit: if a third coin worth $ is added, what is the largest non-convertible amount then?
The Riddler, FiveThirtyEight, October 18, 2019(original post)
Solution
This is the Frobenius coin problem. For two coin values that share no common factor, , every large enough amount is payable, and the largest that is not has a classic closed form, Here that gives The reason: group amounts by their remainder modulo . Each remainder class first becomes payable at some multiple of (since , the multiples of cycle through all remainders). The last remainder to unlock does so at the th multiple, ; the largest unpayable amount in that class is , and every amount above it is payable.
For the extra credit, adding a $ coin has no two-coin closed form, but the largest non-representable amount is a quick search: The third coin fills in many previously unreachable amounts, dropping the threshold sharply.
The computation
Encode representability directly with a coin-reachability table (a number is reachable if subtracting some coin leaves a reachable number), then take the largest unreachable amount and confirm everything above it is reachable.
def reachable(n, coins):
dp = [False] * (n + 1); dp[0] = True
for i in range(1, n + 1):
dp[i] = any(i >= c and dp[i - c] for c in coins)
return dp
dp = reachable(11000, [19, 538])
g = max(i for i in range(11001) if not dp[i])
print("Frobenius(19, 538) =", g, "| all above representable:", all(dp[g + 1:]))
dp3 = reachable(3000, [19, 101, 538])
g3 = max(i for i in range(3001) if not dp3[i])
print("Frobenius(19, 101, 538) =", g3, "| all above:", all(dp3[g3 + 1:]))
# Frobenius(19, 538) = 9665 | all above representable: True
# Frobenius(19, 101, 538) = 1799 | all above: True
The search confirms for the two coins and once the $ coin is added.