Skip to content

Instantly share code, notes, and snippets.

@cristaloleg
Created October 14, 2016 15:01
Show Gist options
  • Save cristaloleg/1e8f6f4f38fdce5a6894caf40694f7a1 to your computer and use it in GitHub Desktop.
Save cristaloleg/1e8f6f4f38fdce5a6894caf40694f7a1 to your computer and use it in GitHub Desktop.
bombom
# lel
def divs(n):
res = [1]
for i in range(2, 39):
if n % i == 0:
res.append(i)
return res
def isset(n, i):
return (n & (1 << i)) > 0
def uncheck(n, i):
return ~((~n) | 1 << i)
def check(n, i):
return n | 1 << i
def search(B, N):
S = sum(B)
if S == 703:
print(B)
return
dd = divs(S)
for d in dd:
if d < 38 and not isset(N, d):
N = check(N, d)
copy = B[:]
copy.append(d)
search(copy, N)
N = uncheck(N, d)
base = [37, 1]
N = 0
for k in base:
N = check(N, k)
search(base, N)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment