Cube Digit Pairs¶
There's only ${10 \choose 6} = 210$ distinct cubes, making this problem easy to brute force. We first make a generator for those cubes.
In [1]:
from itertools import combinations
def cubes():
yield from combinations(range(0, 10), 6)
We also write a simple function for handling the fact that we can flip 6s and 9s.
In [2]:
def extended_set(s):
s = set(s)
if 6 in s:
s.add(9)
elif 9 in s:
s.add(6)
return s
Another simple function tests if we can display all the square numbers with a given pair of cubes.
In [3]:
def all_squares_displayable(s, t):
es = extended_set(s)
et = extended_set(t)
square_digits = ((0, 1), (0, 4), (0, 9), (1, 6), (2, 5), (3, 6), (4, 9), (6, 4), (8, 1))
for (m, n) in square_digits:
if not ((m in es and n in et) or (n in es and m in et)):
return False
return True
Then we just check all the cube pairs.
In [4]:
arrangements = set()
for s, t in combinations(cubes(), 2):
if all_squares_displayable(s, t):
arrangements.add((s, t))
In [5]:
len(arrangements)
Out[5]:
1217
Copyright (C) 2025 filifa¶
This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license and the BSD Zero Clause license.