Skip to content

Instantly share code, notes, and snippets.

@igorvanloo
Created May 9, 2022 03:39
Show Gist options
  • Save igorvanloo/27a765a6f98d096b443dc104903b9b52 to your computer and use it in GitHub Desktop.
Save igorvanloo/27a765a6f98d096b443dc104903b9b52 to your computer and use it in GitHub Desktop.
Problem 166
def valid(n):
if n < 0 or n > 9:
return False
return True
def compute():
total = 0
for a in range(0, 10):
print(a)
for b in range(0, 10):
for c in range(0, 10):
for d in range(0, 10):
s = a + b + c + d
for e in range(0, 10):
for i in range(0, 10):
m = s - a - e - i
if valid(m):
for j in range(0, 10):
g = s - d - j - m
if valid(g):
for f in range(0, 10):
n = s - b - f - j
if valid(n):
for k in range(0, 10):
o = s - c - g - k
if valid(o):
h = s - e - f - g
if valid(h):
l = s - i - j - k
if valid(l):
p = s - a - f - k
if valid(p):
if m + n + o + p == s and d + h + l + p == s:
total += 1
return total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment