Solve this alphametic:
GO*FLY = KITES
where FLY is exactly divisible by GO.
GO * FLY = KITES
27 * 594 = 16038
and 594/27 = 22
--------
from itertools import permutations
for perm in permutations([0,1,2,3,4,5,6,7,8,9]):
G = perm[0]
if G == 0:
continue
O = perm[1]
F = perm[2]
if F == 0:
continue
L = perm[3]
Y = perm[4]
K = perm[5]
if K == 0:
continue
I = perm[6]
T = perm[7]
E = perm[8]
S = perm[9]
GO = 10*G+O
FLY = 100*F+10*L+Y
KITES = 10000*K+1000*I+100*T+10*E+S
if GO*FLY != KITES:
continue
if FLY % GO != 0:
continue
print(GO,FLY,KITES, FLY/GO)
|
Posted by Larry
on 2025-01-22 14:07:17 |