Skip to content

Instantly share code, notes, and snippets.

Avatar

Christian Jauvin cjauvin

View GitHub Profile
View meds.py
#!/usr/bin/env python
import datetime as dt
import json
import os
N_PER_BOX = 30
path = os.path.dirname(os.path.realpath(__file__))
View geocoding.py
def intersect(cur, sn1, sn2, sdr, inter_table):
sn1_field = STREETNAME_FIELD
if isinstance(sn1, int):
sn1_field = 'norte'
sn2_field = STREETNAME_FIELD
if isinstance(sn2, int):
sn2_field = 'norte'
q = """
View hanoi.org
{0,1,2,3} {} {}
{0,1,2} {} {}
{0,1} {} {}
{0,1,2,3} {} {} -> {1,2,3} {0} {}
{0} {} {} -> {} {0} {}
View day13.py
from collections import Counter, defaultdict
import numpy as np
N = 45
K = 1350
#K = 10
goal = (31, 39) # (7, 4)
#goal = (7, 4)
G = np.zeros((N, N)) # [y][x]
View day10.py
from collections import defaultdict
import re
bot_values = defaultdict(list) # bot i -> list of values
bins = {}
s = """value 5 goes to bot 2
bot 2 gives low to bot 1 and high to bot 0
value 3 goes to bot 1
View day9.py
import sys
import re
def decompress(s):
d = []
while True:
m = re.search('(\((\d+)x(\d+)\)).*', s)
if m:
n_chars, mult = map(int, m.groups()[1:])
View day8.py
import numpy as np
import re
def rect(a, b):
g[:b, :a] = 1
def rotate_row(a, b):
g[a, :] = np.append(g[a, -b:], g[a, :-b])
View day2.py
G = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
H = [[-1, -1, 1, -1, -1], [-1, 2, 3, 4, -1], [5, 6, 7, 8, 9], [-1, 'A', 'B', 'C', -1], [-1, -1, 'D', -1, -1]]
def bathroom_code(S):
p = [1, 1]
code = []
for line in s:
for x in line:
d = 1 if x in 'LR' else 0
if x in 'LU':
View advent_of_code_day1.py
# http://adventofcode.com/2016/day/1
import re
import numpy as np
def taxi_dist(S):
p = [0, 0]
i = 0
d = 1
View claire_et_guillaume.py
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-s', help='input string, dir arrows if none')
parser.add_argument('-n', type=int, default=10)
args = parser.parse_args()
You can’t perform that action at this time.