Created
October 14, 2016 15:01
-
-
Save cristaloleg/1e8f6f4f38fdce5a6894caf40694f7a1 to your computer and use it in GitHub Desktop.
bombom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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