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
import sys | |
import os | |
from os.path import join | |
from mock import Mock, patch | |
from twisted.internet import defer | |
src_path = os.path.realpath(join(os.path.dirname(__file__), "../src/")) | |
current_path = os.path.realpath(os.path.dirname(__file__)) | |
sys.path.insert(0, current_path) | |
sys.path.insert(0, src_path) |
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
[ 0.637461] Write protecting the kernel text: 4232k | |
[ 0.637500] Write protecting the kernel read-only data: 1272k | |
[ 0.647427] random: systemd-tmpfile urandom read with 0 bits of entropy available | |
[ 0.650489] systemd-udevd[47]: starting version 212 | |
[ 0.653627] i8042: PNP: PS/2 Controller [PNP0303:PS2K] at 0x60,0x64 irq 1 | |
[ 0.653634] i8042: PNP: PS/2 appears to have AUX port disabled, if this is incorrect please boot with i8042.nopnp | |
[ 0.654699] i8042: Warning: Keylock active | |
[ 0.654847] serio: i8042 KBD port at 0x60,0x64 irq 1 | |
[ 0.660105] input: AT Translated Set 2 keyboard as /devices/platform/i8042/serio0/input/input0 | |
[ 0.679289] sdhci: Secure Digital Host Controller Interface driver |
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
# BaseTestClient is flask.testing.FlaskClient | |
class TestClient(BaseTestClient): | |
""" | |
Test Client. | |
""" | |
def __exit__(self, exc_type, exc_value, tb): | |
self.preserve_context = False | |
top = _request_ctx_stack.top |
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
def check(A, B, C, index): | |
totals = [0 for _ in xrange(index)] | |
for i in xrange(index - 1, -1, -1): | |
totals[i] += B[i] | |
if C[i] != -1: | |
totals[C[i]] += totals[i] | |
return all([totals[i] <= A[i] for i in xrange(index)]) |
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
import System.Environment | |
fib_gen = 0 : 1 : [a + b | (a, b) <- zip fib_gen (tail fib_gen)] | |
main = do | |
args <- getArgs | |
let first_arg = if null args then "1" else head args | |
let fa = read first_arg :: Int | |
print $ last $ take fa fib_gen |
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
checkers = [ | |
lambda nums: False, | |
lambda nums: True, | |
lambda nums: nums[-1] % 2 == 0, | |
lambda nums: sum(nums) % 3 == 0, | |
lambda nums: (10 * nums[-2] + nums[-1]) % 4 == 0, | |
lambda nums: nums[-1] in [0, 5], | |
lambda nums: sum(nums) % 3 == 0 and nums[-1] % 2 == 0, | |
lambda nums: sum([10 ** i * nums[-(i + 1)] for i in xrange(len(nums))]) % 7 == 0, | |
lambda nums: sum([10 ** i * nums[-(i + 1)] for i in xrange(3)]) % 8 == 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
""" Computing the number of permutations on n points | |
no fix points in 3 ways. """ | |
from functools import wraps | |
from math import factorial, e, floor | |
from sys import argv | |
CACHE = {} | |
def cache(f): | |
@wraps(f) |
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 collections import defaultdict | |
from sys import argv | |
def to_dict(word): | |
ret = defaultdict(int) | |
for letter in word: | |
ret[letter] += 1 | |
return ret |
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
""" The problem is an extremely easy linear programming problem. | |
The only issue is that there is no simplex solver in the | |
standard library and scipy is not available on codeforces. | |
""" | |
from scipy.optimize import linprog | |
n, p, q = map(int, raw_input().strip().split()) | |
A = [[], []] | |
b = [-p, -q] | |
c = [1 for _ in xrange(n)] |
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
import re | |
PUT_PATTERN = re.compile(r'PUT (?P<what>[0-9]+) INSIDE (?P<to>[0-9]+)') | |
LOOSE_PATTERN = re.compile(r'SET (?P<which>[0-9]+) LOOSE') | |
SWAP_PATTERN = re.compile(r'SWAP (?P<one>[0-9]+) WITH (?P<other>[0-9]+)') | |
class Bag(object): | |
def __init__(self, n, parent=None): | |
self.n = n |