This file contains hidden or 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
| from itertools import permutations | |
| for digits in xrange(1, 10): | |
| thestring = "".join([str(i) for i in range(1, digits + 1)]) | |
| for a in permutations(thestring): | |
| for b in permutations(thestring): | |
| answer = " + ".join([a[i] + "**" + b[i] for i in xrange(digits)]) | |
| if thestring == "".join(sorted(str(eval(answer)))): | |
| print "[" + str(eval(answer)) + " = " + answer + "]" |
This file contains hidden or 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
| from gmpy import is_prime | |
| START = 16661 | |
| BADDIGITS = "23457890" | |
| while True: | |
| print START | |
| i = 1 | |
| while not is_prime(int(str(i)[::-1] + str(START) + str(i))) or sum([str(i).count(j) for j in BADDIGITS]) > 0: | |
| i += 1 | |
| START = int(str(i)[::-1] + str(START) + str(i)) |
This file contains hidden or 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
| #!/bin/env python | |
| i = 1 | |
| while i <= 10000000: | |
| j = 1 | |
| answers = dict() | |
| while j * j <= i: | |
| if i % j == 0: | |
| rep = "".join(sorted(([k for k in str(j)]) + ([k for k in str(i/j)]))) | |
| if rep not in answers: |
This file contains hidden or 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
| i = 1 | |
| while i <= 1000000: | |
| j = 1 | |
| answers = dict() | |
| while j * j <= i: | |
| if i % j == 0: | |
| rep = "".join(sorted(([k for k in str(j)]) + ([k for k in str(i/j)]))) | |
| if rep not in answers: | |
| answers[rep] = [] | |
| answers[rep].append(str(j) + " * " + str(i/j)) |
This file contains hidden or 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
| i = 2 | |
| def recur(i, j, k): | |
| if len(k) > 0 and k[1] == "+": | |
| k = k[3:] | |
| if len(k) > 0: | |
| current = str(eval(k)) | |
| if len(current) == 10: | |
| if "1" in current: | |
| if "2" in current: |
This file contains hidden or 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
| from itertools import permutations | |
| seen = dict() | |
| seenline = set() | |
| i = 0 | |
| while True: | |
| current = sorted(set([int("".join(j)) for j in list(permutations(str(i)))])) | |
| if current[-1] not in seen: |
This file contains hidden or 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
| from itertools import permutations | |
| for ii in xrange(2, 10): | |
| for i in permutations("1234567890", ii): | |
| for k in xrange(1, len(i)): | |
| if i[:k][0] != '0': | |
| if i[k:][0] != '0': | |
| left = int("".join(i[:k])) | |
| right = int("".join(i[k:])) | |
| if right != 0: |
This file contains hidden or 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
| from copy import deepcopy as copy | |
| import heapq | |
| UPPERLIMIT = 1000000 | |
| fib = [1,1] | |
| while fib[-1] < UPPERLIMIT: | |
| fib.append(fib[-1] + fib[-2]) | |
| fib.pop(0) | |
| fib.pop() |
This file contains hidden or 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
| from copy import deepcopy as copy | |
| target = 2016 | |
| fib = [1,1] | |
| while fib[-1] < target: | |
| fib.append(fib[-1] + fib[-2]) | |
| fib.pop() | |
| fib = tuple(fib) | |
| fibs = set() |
This file contains hidden or 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
| from copy import deepcopy as copy | |
| from itertools import permutations | |
| def recur(levels, skills, skilltree): | |
| if len(skills) == 0: | |
| yield levels | |
| else: | |
| current = skills.pop(0) | |
| good = True | |
| for i in xrange(len(skilltree[current])): |