Output of program:
549 * 537 = 294813 and gain = 8349
done 1
Some of the letters changed just for my convenience:
winaregm -> BCDAFEGH
BCD * BAF = EDCGHA
gain -> GACD
----- program follows -----
count = 0
for A in range(0,10):
for B in range(1,10):
if A==B:
continue
for C in range(0,10):
if A==C or B==C:
continue
for D in range(0,10):
if A==D or B==D or C==D:
continue
for E in range(1,10):
if A==E or B==E or C==E or D==E:
continue
for F in range(0,10):
if A==F or B==F or C==F or D==F or E==F:
continue
for G in range(0,10):
if A==G or B==G or C==G or D==G or E==G or F==G:
continue
for H in range(0,10):
if A==H or B==H or C==H or D==H or E==H or F==H or G==H:
continue
win = 10**2*B + 10**1*C + 10**0*D
war = 10**2*B + 10**1*A + 10**0*F
enigma = 10**5*E + 10**4*D + 10**3*C + 10**2*G + 10**1*H + 10**0*A
if win * war == enigma:
count += 1
gain = 10**3*G + 10**2*A + 10**1*C + 10**0*D
print (win,'*',war,'=',enigma,' and gain =',gain)
print('done', count)
|
Posted by Larry
on 2020-07-09 11:39:05 |