Skip to content

Instantly share code, notes, and snippets.

@kosugi
Created February 5, 2020 09:26
Show Gist options
  • Select an option

  • Save kosugi/f20b31cb88fe301412dfd05b017f8df6 to your computer and use it in GitHub Desktop.

Select an option

Save kosugi/f20b31cb88fe301412dfd05b017f8df6 to your computer and use it in GitHub Desktop.
from itertools import permutations
f = lambda xs: g(xs[0], xs[1] * 10 + xs[2], xs[3], xs[4] * 10 + xs[5], xs[6], xs[7] * 10 + xs[8])
g = lambda a, b, c, d, e, f: a * d * f + b * c * f + b * d * e == b * d * f
h = lambda xs: tuple(sorted([(xs[0], xs[1] * xs[2]), (xs[3], xs[4] * xs[5]), (xs[6], xs[7] * xs[8])]))
print(set(map(h, filter(lambda xs: f(xs), permutations(range(1, 10))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment