Chapter 53
Can You Cross Like A Boss?
Six three-digit numbers fill the rows of a CrossProduct table, one digit per cell. The product of each row’s three digits is given on the right (), and the products down the hundreds, tens and ones columns are , and . Find all six numbers.
Solution
Each row product factors into three single digits in only a handful of ways, and the three column products decide which factorization each row must take. Searching across the rows and pruning the moment a running column product overshoots its target leaves exactly one consistent table: Reading down the columns confirms it: the hundreds digits multiply to , the tens to , and the ones to .
The computation
For each row list the digit triples whose product matches; then search across rows for the one combination whose hundreds, tens and ones digits hit the three column totals.
rows = [210, 144, 54, 135, 4, 49]
cols = (6615, 15552, 420)
opts = [[(h, t, o) for h in range(1, 10) for t in range(1, 10)
for o in range(1, 10) if h*t*o == p] for p in rows]
sols = []
def search(i, prod, acc):
if any(prod[c] > cols[c] for c in range(3)): return
if i == len(rows):
if prod == list(cols): sols.append(acc)
return
for h, t, o in opts[i]:
search(i + 1, [prod[0]*h, prod[1]*t, prod[2]*o], acc + [f"{h}{t}{o}"])
search(0, [1, 1, 1], [])
print(len(sols), sols[0]) # 1, ['765','982','392','593','141','717']