Skip to content

Instantly share code, notes, and snippets.

@washingweb
Created May 22, 2022 04:56
Show Gist options
  • Save washingweb/827928a24c2a4e550d7fa61b409c7151 to your computer and use it in GitHub Desktop.
Save washingweb/827928a24c2a4e550d7fa61b409c7151 to your computer and use it in GitHub Desktop.
A quiz
from itertools import product
def factor(n):
"""I don't know the english name"""
for i in range(1, n+1):
if n % i == 0:
yield i
search_space = product(factor(48), factor(100), factor(92), factor(128))
for x, y, z, m in search_space:
if x*(y+z+m) == 48 and \
y*(x+z+m) == 100 and \
z*(x+y+m) == 92 and \
m*(x+y+z) == 128:
print(x, y, z, m)
break
print("Solution not found")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment