Find the minimum possible positive integer base corresponding to which this alphametic has at least one solution:
STRONG
+STRONG
---------
PROBLEM
There are 11 unique characters, so start with base 11, which in fact does have a single solution.
Note that there are no repeat digits in STRONG, and P=1,
STRONG must be large enough to cause a carry when doubled.
STRONG PROBLEM
base 11 83576A 1570429
decimal 1339909 2679818
----------
import math
base = 11
largest = base2base('1000000',base,10)
smallest = math.ceil(largest / 2)
for n in range(smallest,largest):
STRONG = base2base(n,10,base)
if '1' in STRONG:
continue
if len(set(STRONG)) != len(STRONG):
continue
PROBLEM = base2base(n*2,10,base)
if '1' in PROBLEM[1:]:
continue
if PROBLEM[1] != STRONG[2]:
continue
if PROBLEM[2] != STRONG[3]:
continue
STRONGBLEM = STRONG + PROBLEM[3]+PROBLEM[4]+PROBLEM[5]+PROBLEM[6]
if len(set(STRONGBLEM)) != 10:
continue
print('base', base, STRONG, PROBLEM)
print('decimal', base2base(STRONG,base,10), base2base(PROBLEM,base,10))
|
Posted by Larry
on 2024-04-24 10:48:44 |