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
from jinja2 import BytecodeCache | |
class RedisTemplateBytecodeCache(BytecodeCache): | |
'''Implements a Jinja2 bytecode cache on top of a pyredis.StrictRedis | |
connection | |
See: http://jinja.pocoo.org/docs/2.10/api/#bytecode-cache | |
''' | |
def __init__(self, redis_cnx, template_cache_key_prefix=None, ttl=86400): |
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
-- table a: | |
create table a ( | |
uid text primary key, | |
title text not null | |
); | |
create table u ( | |
uid text primary key, |
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
from itertools import combinations | |
def get_input(): | |
with open('./input9.txt') as inp: | |
return inp.read().strip().split('\n') | |
def part1(): | |
inp = get_input() |
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
import sys | |
def get_input(): | |
with open('./input8.txt') as inp: | |
return inp.read().strip().split('\n') | |
def finishes(ops): | |
visited = set() | |
acc = 0 |
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
def calc(ticket): | |
seat_id = 0 | |
for i, instr in enumerate(ticket): | |
if instr in 'BR': | |
seat_id += 2**(9-i) | |
return seat_id | |
def part_1(data): | |
return max(calc(line) for line in data) |
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
import string | |
def get_input(): | |
with open('input4full.txt') as f: | |
passwords = f.read() | |
return passwords.strip() | |
def run(): | |
passports = [p.replace('\n', ' ').split(' ') for p in get_input().split('\n\n')] |
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
def get_input(): | |
with open('input3full.txt') as f: | |
passwords = f.readlines() | |
return map(str.strip, passwords) | |
def get_next(right, down, x, y, land_map): | |
x += right | |
y += down | |
line = land_map[y] |
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
from collections import Counter | |
def get_input(): | |
with open('2.txt') as f: | |
passwords = f.readlines() | |
return map(str.strip, passwords) | |
def get_password_specs(specs): |
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
from operator import mul | |
from functools import reduce | |
def get_input(): | |
with open('input3full.txt') as f: | |
passwords = f.readlines() | |
return map(str.strip, passwords) | |
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
from collections import Counter | |
def get_input(): | |
with open('2.txt') as f: | |
passwords = f.readlines() | |
return map(str.strip, passwords) | |
def get_password_specs(specs): |