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 part1(input_data): | |
output = input_data.split('\n') | |
fs = [] | |
cwd = "" | |
for line in output: | |
line = line.split() | |
if line[0] == '$': | |
# command |
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 partN(input_data, step): | |
for i, window in enumerate( | |
[input_data[i:i + step] for i in range(len(input_data) - step)]): | |
if len(set(window)) == step: | |
return i + step | |
if __name__ == '__main__': | |
with open('./input.txt') as f: |
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 partN(input_data, step): | |
for i, window in enumerate( | |
[input_data[i:i + step] for i in range(len(input_data) - step)]): | |
if len(set(window)) == step: | |
return i + step | |
if __name__ == '__main__': |
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 re | |
def partN(input_data, one_at_a_time): | |
step = 4 | |
instructions = [] | |
stack_data, instruction_data = input_data.split('\n\n') | |
cols = int(stack_data.strip().split()[-1]) # ugh? | |
stacks = [''] * cols | |
stacks_data_lines = list(reversed(stack_data.split('\n')[:-1])) |
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 part1(inp): | |
overlaps = 0 | |
for pair in inp: | |
bounds = [] | |
for elf in pair.split(','): | |
lower, upper = elf.split('-') | |
bounds.append(set(range(int(lower), int(upper) + 1))) | |
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 string import ascii_letters | |
from itertools import zip_longest | |
def chunk(things, num): | |
things = [iter(things)] * num | |
return zip_longest(fillvalue=None, *things) | |
def part1(inp): |
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 run(): | |
with open('./input.txt') as f: | |
data = f.read() | |
calorie_counts = {} | |
for elf, calories in enumerate(data.split('\n\n'), start=1): | |
calorie_counts[elf] = sum(map(int, calories.strip().split('\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
-- 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 |
NewerOlder