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 | |
| LOWERLIMIT = 1 | |
| UPPERLIMIT = 10 ** 12 | |
| NUMDIGITS = 1 | |
| def recur(i): | |
| queue = [[int(j) for j in str(i)]] | |
| z = 0 | |
| while z < len(queue): | |
| for j in xrange(len(queue[z]) - 1): |
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
| PROMPT 1 | |
| TIMEOUT 60 | |
| DEFAULT linux | |
| SAY Now booting the kernel from SYSLINUX... | |
| LABEL linux | |
| KERNEL /isolinux/vmlinuz | |
| APPEND toram=squashfs.fs ro | |
| INITRD /isolinux/initrd.img |
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
| numbers = [1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 8, 9, 9, 10, 11, 12, 10, 5, 4, 2, 7, 8, 9, 4, 2, 7] | |
| i = 0 | |
| while i + 2 < len(numbers): | |
| if numbers[i] < numbers[i+1] and numbers[i+1] < numbers[i+2]: | |
| numbers.pop(i+1) | |
| else: | |
| if numbers[i] > numbers[i+1] and numbers[i+1] > numbers[i+2]: | |
| numbers.pop(i+1) | |
| else: |
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 | |
| import os | |
| import hashlib | |
| import argparse | |
| # http://pythoncentral.io/hashing-files-with-python/ | |
| def hashfile(afile, hasher, blocksize=65536): | |
| buf = afile.read(blocksize) |
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
| package main | |
| import "fmt" | |
| import "strconv" | |
| import "bytes" | |
| import "math" | |
| // Below from Google examples | |
| /* |
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 | |
| def recur(i): | |
| queue = [[int(j) for j in str(i)]] | |
| z = 0 | |
| while z < len(queue): | |
| for j in xrange(len(queue[z]) - 1): | |
| current = queue[z] | |
| if current[j] != 0: | |
| current = list(queue[z]) |
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 | |
| class Memoize: | |
| def __init__(self, f): | |
| self.f = f | |
| self.memo = {} | |
| def __call__(self, *args): | |
| if not args in self.memo: | |
| self.memo[args] = self.f(*args) | |
| return self.memo[args] |
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, combinations | |
| import multiprocessing | |
| def process(z): | |
| numbers = [i for i in str(z)] | |
| thestring = "".join([str(i) for i in numbers]) | |
| a = [str(i) for i in numbers] | |
| for b in permutations(thestring): | |
| for c in xrange(0, 2 ** len(numbers)): | |
| 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 copy import deepcopy as copy | |
| queue = [] | |
| for i in xrange(1, 10): | |
| for j in copy(queue): | |
| queue.append(j + [i]) | |
| queue.append([i]) | |
| for i in xrange(1, 10): | |
| for k in queue: | |
| current = " + ".join([str(j) + "**" + str(i) for j in k]) |
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
| queue = [([str(i)],["0"]) for i in xrange(1, 10)] | |
| answers = dict() | |
| while len(queue) > 0: | |
| current = queue.pop() | |
| total = eval("+".join([current[0][i] + "**" + current[1][i] for i in xrange(len(current[0]))])) | |
| if len(current[0]) == 10 and total < 10000: | |
| if total not in answers: | |
| answers[total] = [] |