Skip to content

Instantly share code, notes, and snippets.

@psqq
Created March 29, 2021 13:02
Show Gist options
  • Save psqq/a35552d1eff767357d3734ad0b5ffe33 to your computer and use it in GitHub Desktop.
Save psqq/a35552d1eff767357d3734ad0b5ffe33 to your computer and use it in GitHub Desktop.
from itertools import *
ar = range(1, 10)
ae = range(1, 6)
ash = range(0, 10)
ai = range(0, 6)
as_ = range(1, 6)
al = range(0, 6)
an = range(0, 6)
all_variants = product(ar, ae, ash, ai, as_, al, an)
for r, e, sh, i, s, l, n in all_variants:
reshi = 1000 * r + 100 * e + 10 * sh + i
esli = 1000 * e + 100 * s + 10 * l + i
silen = 10000 * s + 1000 * i + 100 * l + 10 * e + n
if reshi + esli == silen and len(set([r, e, sh, i, s, l, n])) == 7:
print(f"{reshi} + {esli} = {silen}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment