I hereby claim:
- I am spielkind on github.
- I am spielkind (https://keybase.io/spielkind) on keybase.
- I have a public key whose fingerprint is F83D DFE9 8059 35BF E12D B96A 4672 D4DB C014 5952
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
#!/bin/python | |
with open('day1.txt') as f: | |
measurements= [int(x) for x in f] | |
def compare(n): | |
return sum(1 for i in range(len(n)) if n[i]>n[i-1]) | |
print("Part One: ",compare(measurements)) | |
#!/bin/python | |
class Submarine(): | |
def __init__(self): | |
self.position={'horizontal': 0, 'depth': 0} | |
self.aim=0 | |
def forward(self,amount): | |
self.position['horizontal']+=amount | |
self.position['depth']+=amount*self.aim | |
def up(self,amount): |
#!/bin/python | |
with open('day3.txt') as f: | |
bitslist = [list(map(int, line.strip())) for line in f] | |
def column(bitslist, location): | |
return [bits[location] for bits in bitslist] | |
def bitcount(bitslist, location): | |
zero_count = column(bitslist, location).count(0) |
#!/bin/python | |
with open('day4.txt') as f: | |
numbers = list(map(int, f.readline().strip().split(','))) | |
player = -1 | |
bingocards = [] | |
matches = [] | |
for line in f: | |
if line.strip() == '': | |
player += 1 |
#!/bin/python | |
lines = [] | |
with open('day5.txt') as f: | |
for line in f: | |
lines.append([list(map(int, c.strip().split(','))) for c in [p for p in line.strip().split('->')]]) | |
def init_diagram(values): | |
max_x = max(c[0] for l in values for c in l)+1 | |
max_y = max(c[1] for l in values for c in l)+1 |
#!/bin/python | |
fish = [0] * 9 | |
with open('day6.txt') as f: | |
for timer in map(int, next(f).strip().split(',')): | |
fish[timer] += 1 | |
for days in range(256): | |
nextdayfish = [0] * 9 |
#!/bin/python | |
with open('day7.txt') as f: | |
crabs = list(map(int, next(f).strip().split(','))) | |
pl, ph = min(crabs), max(crabs)+1 | |
fn1 = list(range(ph)) | |
fn2 = {num: num*(num+1)//2 for num in range(ph)} | |
def opt(fn): |
#!/bin/python | |
entries = [] | |
with open('day8.txt') as f: | |
for line in f: | |
entry = [] | |
for part in line.strip().split('|'): | |
entry.append([sorted(list(segments)) for segments in part.strip().split()]) | |
entries.append(entry) |
#!/bin/python | |
with open('day9.txt') as f: | |
heightmap = [list(map(int, line.strip())) for line in f] | |
def get_neighbours(p): | |
neighbours = [] | |
(x, y) = p[0], p[1] | |
if x != 0: neighbours.append((x-1, y)) | |
if x != len(heightmap[y])-1: neighbours.append((x+1, y)) |