Created
March 9, 2016 23:34
-
-
Save Radcliffe/43bbb0efc3ca6c3db535 to your computer and use it in GitHub Desktop.
Cryptarithm: HALF + FIFTH + TENTH + TENTH + TENTH = WHOLE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
for a,e,f,h,i,l,t,n,o,w in itertools.permutations(range(10)): | |
if h > 0 and t > 0 and f > 0 and w > 0: | |
half = 1000*h + 100*a + 10*l + f | |
fifth = 10100*f + i*1000 + t*10 + h | |
tenth = 10010*t + 1000*e + n*100 + h | |
whole = w*10000 + h*1000 + o*100 + l*10 + e | |
if half + fifth + 3*tenth == whole: | |
print "%s + %s + %s + %s + %s = %s" % ( | |
half, fifth, tenth, tenth, tenth, whole) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment