Skip to content

Instantly share code, notes, and snippets.

@theonlypwner
Created January 10, 2015 16:10
Show Gist options
  • Save theonlypwner/5e9db40cef529a908c30 to your computer and use it in GitHub Desktop.
Save theonlypwner/5e9db40cef529a908c30 to your computer and use it in GitHub Desktop.
4*MATH=HTAM
# N*[MATH]=[HTAM]
# MATH -> ABCD
# N(1000A+100B+10C+D)=1000D+100C+10B+A
# (1000N-1)A+10(10N-1)B=10(10-N)C+(1000-N)D
count = [0] * 9
for N in range(1, 10):
for A in range(10):
for B in range(10):
for C in range(10):
for D in range(10):
if (1000*N-1)*A + 10*(10*N-1)*B == 10*(10-N)*C + (1000-N)*D:
print("%d*%d%d%d%d=%d%d%d%d" % (N, A, B, C, D, D, C, B, A))
count[N-1] += 1
print(count)
print("done")
1*0000=0000
1*0110=0110
1*0220=0220
1*0330=0330
1*0440=0440
1*0550=0550
1*0660=0660
1*0770=0770
1*0880=0880
1*0990=0990
1*1001=1001
1*1111=1111
1*1221=1221
1*1331=1331
1*1441=1441
1*1551=1551
1*1661=1661
1*1771=1771
1*1881=1881
1*1991=1991
1*2002=2002
1*2112=2112
1*2222=2222
1*2332=2332
1*2442=2442
1*2552=2552
1*2662=2662
1*2772=2772
1*2882=2882
1*2992=2992
1*3003=3003
1*3113=3113
1*3223=3223
1*3333=3333
1*3443=3443
1*3553=3553
1*3663=3663
1*3773=3773
1*3883=3883
1*3993=3993
1*4004=4004
1*4114=4114
1*4224=4224
1*4334=4334
1*4444=4444
1*4554=4554
1*4664=4664
1*4774=4774
1*4884=4884
1*4994=4994
1*5005=5005
1*5115=5115
1*5225=5225
1*5335=5335
1*5445=5445
1*5555=5555
1*5665=5665
1*5775=5775
1*5885=5885
1*5995=5995
1*6006=6006
1*6116=6116
1*6226=6226
1*6336=6336
1*6446=6446
1*6556=6556
1*6666=6666
1*6776=6776
1*6886=6886
1*6996=6996
1*7007=7007
1*7117=7117
1*7227=7227
1*7337=7337
1*7447=7447
1*7557=7557
1*7667=7667
1*7777=7777
1*7887=7887
1*7997=7997
1*8008=8008
1*8118=8118
1*8228=8228
1*8338=8338
1*8448=8448
1*8558=8558
1*8668=8668
1*8778=8778
1*8888=8888
1*8998=8998
1*9009=9009
1*9119=9119
1*9229=9229
1*9339=9339
1*9449=9449
1*9559=9559
1*9669=9669
1*9779=9779
1*9889=9889
1*9999=9999
2*0000=0000
3*0000=0000
4*0000=0000
4*2178=8712
5*0000=0000
6*0000=0000
7*0000=0000
8*0000=0000
9*0000=0000
9*1089=9801
[100, 1, 1, 2, 1, 1, 1, 1, 2]
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment