Skip to content
Vamshi Jandhyala

Books · The Riddler

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 (210,144,54,135,4,49210, 144, 54, 135, 4, 49), and the products down the hundreds, tens and ones columns are 6,6156{,}615, 15,55215{,}552 and 420420. 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: 765, 982, 392, 593, 141, 717.\boxed{765,\ 982,\ 392,\ 593,\ 141,\ 717.} Reading down the columns confirms it: the hundreds digits multiply to 793517=6,6157\cdot9\cdot3\cdot5\cdot1\cdot7 = 6{,}615, the tens to 689941=15,5526\cdot8\cdot9\cdot9\cdot4\cdot1 = 15{,}552, and the ones to 522317=4205\cdot2\cdot2\cdot3\cdot1\cdot7 = 420.

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']