Solve this duodecimal(base 12) alphametic
J*FROULA = RETIRE*S
where REST is the maximum.
J*FROULA = RETIRE*S
B*1A4596 = A307A3*2
results dictionary, sorted by decimal value of REST:
REST J FROULA RETIRE S
1003 [['3', '20415A', '067806', 'B'],
['3', '20451A', '067906', 'B']]
1004 [['3', '20579A', '068106', 'B']]
1247 [['5', '106A34', '08B908', '7']]
2422 [['6', '213780', '14A514', '9']]
3904 [['B', '025A69', '234823', '1']]
4047 [['B', '026A58', '243724', '1']]
4197 [['B', '028647', '259A25', '1']]
7653 [['B', '04A827', '459645', '1']]
9838 [['7', '2561B0', '58A458', '3']]
12140 [['2', 'A71546', '708B70', '3']]
12143 [['2', 'A75846', '70B970', '3']]
16447 [['5', '39A1B0', '967496', '2']]
17736 [['B', '1A4596', 'A307A3', '2']]
Maximum value for REST is decimal 17736 = base 12 'A320'
['B', '1A4596', 'A307A3', '2'] in base 12
[11, 463938, 2551659, 2] in base 10
11*463938 = 5103318
2*2551659 = 5103318
---------
answers = {}
from itertools import permutations
for perm in permutations(digits12):
S = perm[0]
if S == 0:
continue
A = perm[1]
E = perm[2]
U = perm[3]
I = perm[4]
O = perm[5]
R = perm[6]
if R == 0:
continue
L = perm[7]
F = perm[8]
if F == 0:
continue
T = perm[9]
J = perm[10]
if J == 0:
continue
j = base2base(J, 12, 10)
froula = base2base(F+R+O+U+L+A, 12, 10)
retire = base2base(R+E+T+I+R+E, 12, 10)
s = base2base(S, 12, 10)
rest = base2base(R+E+S+T, 12, 10)
if j*froula == retire*s:
print(J , F+R+O+U+L+A , R+E+T+I+R+E , S)
if rest not in answers:
answers[rest] = [[J , F+R+O+U+L+A , R+E+T+I+R+E , S]]
else:
answers[rest].append([J , F+R+O+U+L+A , R+E+T+I+R+E , S])
rest_dec_values = sorted(answers.keys())
for r in rest_dec_values:
print(r, answers[r])
|
Posted by Larry
on 2025-01-08 16:37:40 |