Skip to content

Instantly share code, notes, and snippets.

@chokkoyamada
Created February 5, 2020 02:17
Show Gist options
  • Save chokkoyamada/b86238b426b880f2860877fe75de43f4 to your computer and use it in GitHub Desktop.
Save chokkoyamada/b86238b426b880f2860877fe75de43f4 to your computer and use it in GitHub Desktop.
import itertools
n = (1, 2, 3, 4, 5, 6, 7, 8, 9)
for x in itertools.permutations(n):
bunbo1 = x[1] * 10 + x[2]
bunbo2 = x[4] * 10 + x[5]
bunbo3 = x[7] * 10 + x[8]
bunshi1 = x[0] * bunbo2 * bunbo3
bunshi2 = x[3] * bunbo1 * bunbo3
bunshi3 = x[6] * bunbo1 * bunbo2
if (bunbo1 * bunbo2 * bunbo3) == (bunshi1 + bunshi2 + bunshi3):
print(x)
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment