Books · The Fiddler: Solutions
Chapter 11
Can You Number the Number Cubes?
You have four number cubes, and each of the faces can show any one digit from to . You form a number by picking three faces on three distinct cubes and lining them up, reading every value as three digits with leading zeros, so is . A may be turned upside down to serve as a , and vice versa, but no other digits are interchangeable. Choosing the faces wisely, what is the largest such that every whole number from to can be formed?
The Fiddler, Zach Wissner-Gross, April 10, 2026(original post)
Solution
Forming a number means matching its three digits to three distinct cubes, each carrying the required digit, so a number is reachable exactly when its digits have a system of distinct representatives among the cubes. Treat and as one symbol, leaving nine symbols in all; an optimal cube carries six distinct symbols.
The maximum is The face budget makes this sharp. The triples and each demand their digit on three cubes (six symbols three cubes faces); then , , each force a symbol onto two cubes ( faces). That is faces, exactly the four cubes. Reaching would need a third cube bearing a , with no free face for it. One design that attains is writing for the shared symbol.
The computation
Pose it as a constraint problem: each cube carries six of the nine symbols, and for every target the three digits must map to three distinct cubes that each carry the needed symbol. A CP-SAT solver finds a design for and proves none exists for .
from ortools.sat.python import cp_model
IDX = {0:0,1:1,2:2,3:3,4:4,5:5,6:6,9:6,7:7,8:8} # 6 and 9 share symbol 6
def reachable(M): # can one design form every 1..M?
m = cp_model.CpModel()
has = {(c,s): m.NewBoolVar("") for c in range(4) for s in range(9)}
for c in range(4):
m.Add(sum(has[c,s] for s in range(9)) == 6)
for k in range(1, M+1):
r = [IDX[k//100%10], IDX[k//10%10], IDX[k%10]]
a = {(p,c): m.NewBoolVar("") for p in range(3) for c in range(4)}
for p in range(3):
m.Add(sum(a[p,c] for c in range(4)) == 1)
for c in range(4): m.Add(a[p,c] <= has[c, r[p]])
for c in range(4): m.Add(sum(a[p,c] for p in range(3)) <= 1)
return cp_model.CpSolver().Solve(m) in (cp_model.OPTIMAL, cp_model.FEASIBLE)
print(reachable(776), reachable(777)) # True False -> max N = 776
Extra Credit
How many distinct ways are there to fill the four cubes so as to attain this greatest ? Cubes are unordered, the order of faces on a cube does not matter, and and count as the same digit.
Solution
Every optimal design is forced into the same shape: the symbols appear on exactly three cubes each and on exactly two, using all faces. Enumerating the four six-symbol cubes under that budget and keeping those that really do form all of to , the number of distinct designs is (The source’s extra-credit answer is behind its paywall; this count is my own, from the enumeration below.)
The computation
Enumerate every unordered choice of four six-symbol cubes (as bitmasks), keep those meeting the symbol budget, and accept a design only if every required digit-triple up to has a system of distinct representatives across the cubes.
import itertools as it
mult = {tuple(sorted(IDX[d] for d in (k//100%10, k//10%10, k%10)))
for k in range(1, 777)}
masks = [sum(1 << s for s in S) for S in it.combinations(range(9), 6)]
def sdr(d, r): # distinct cubes for the three digits r
def go(i, used):
if i == 3: return True
return any(not used >> c & 1 and d[c] >> r[i] & 1
and go(i+1, used | 1 << c) for c in range(4))
return go(0, 0)
count = 0
for combo in it.combinations_with_replacement(range(len(masks)), 4):
d = [masks[i] for i in combo]
if all(sum(x >> s & 1 for x in d) >= 3 for s in (1,2,3,4,5,6)) \
and all(sdr(d, r) for r in mult):
count += 1
print(count) # 855