BOY*GIRL=POETRY
To each one of the ten distinct letters a corresponding digit should be allocated, making the above equation true.
Please find the 1 to 1 matching.
BOY*GIRL=POETRY
265*1739=460835
---------------
count = 0
for v0 in range(1,10):
for v1 in range(0,10):
if v0==v1:
continue
for v2 in range(0,10):
if v0==v2 or v1==v2:
continue
for v3 in range(1,10):
if v0==v3 or v1==v3 or v2==v3:
continue
for v4 in range(0,10):
if v0==v4 or v1==v4 or v2==v4 or v3==v4:
continue
for v5 in range(0,10):
if v0==v5 or v1==v5 or v2==v5 or v3==v5 or v4==v5:
continue
for v6 in range(0,10):
if v0==v6 or v1==v6 or v2==v6 or v3==v6 or v4==v6 or v5==v6:
continue
for v7 in range(1,10):
if v0==v7 or v1==v7 or v2==v7 or v3==v7 or v4==v7 or v5==v7 or v6==v7:
continue
for v8 in range(0,10):
if v0==v8 or v1==v8 or v2==v8 or v3==v8 or v4==v8 or v5==v8 or v6==v8 or v7==v8:
continue
for v9 in range(0,10):
if v0==v9 or v1==v9 or v2==v9 or v3==v9 or v4==v9 or v5==v9 or v6==v9 or v7==v9 or v8==v9:
continue
BOY = 100*v0 + 10*v1 + v2
GIRL = 1000*v3 + 100*v4 + 10*v5 + v6
POETRY = 100000*v7 + 10000*v1 + 1000*v8 + 100*v9 + 10*v5 + v2
if BOY*GIRL == POETRY:
count +=1
print(int(BOY), int(GIRL), int(POETRY))
print('done', int(count))
|
Posted by Larry
on 2019-12-18 15:21:09 |