There are 7 distinct solutions to the alphametic
YES*NO=MAYBE
Please provide the one maximizing the sum of SOME & MANY
The seven solutions are:
YES NO MAYBE SOME MANY sum
[705, 38, 26790] 5820 2637 8457
[705, 28, 19740] 5810 1927 7737
[605, 82, 49610] 5240 4986 10226
[384, 27, 10368] 4718 1023 5741
[705, 62, 43710] 5240 4367 9607
[706, 35, 24710] 6520 2437 8957
[567, 38, 21546] 7826 2135 9961
So the solution that maximizes SOME + MANY is
YES NO MAYBE
[605, 82, 49610]
-------------
solutions = []
from itertools import permutations
for perm in permutations([0,1,2,3,4,5,6,7,8,9]):
Y = perm[0]
if Y == 0:
continue
E = perm[1]
S = perm[2]
N = perm[3]
if N == 0:
continue
O = perm[4]
M = perm[5]
if M == 0:
continue
A = perm[6]
Y = perm[7]
if Y == 0:
continue
B = perm[8]
YES = 100*Y+10*E+S
NO = 10*N+O
MAYBE = 10000*M+1000*A+100*Y+10*B+E
if YES*NO == MAYBE:
ans = [YES, NO, MAYBE]
if ans in solutions:
continue
solutions.append(ans)
SOME = 1000*S+100*O+10*M+E
MANY = 1000*M+100*A+10*N+Y
print(ans, SOME, MANY, SOME + MANY)
|
Posted by Larry
on 2025-01-22 09:56:26 |