Skip to content

Instantly share code, notes, and snippets.

View rtt's full-sized avatar
🚍
' DROP TABLE user_statuses; --

Rich Taylor rtt

🚍
' DROP TABLE user_statuses; --
View GitHub Profile
View aoc-2022-day7.py
def part1(input_data):
output = input_data.split('\n')
fs = []
cwd = ""
for line in output:
line = line.split()
if line[0] == '$':
# command
View aoc-2022-day6.py
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:
View aoc-2022-day6.py
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__':
View aoc-2022-day5.py
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]))
View aoc-2022-day4.py
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)))
View aoc-2022-day3.py
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):
View aoc-2022-day1.py
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')))
@rtt
rtt / abu.sql
Last active February 4, 2021 09:20
foo bar baz
View abu.sql
-- table a:
create table a (
uid text primary key,
title text not null
);
create table u (
uid text primary key,
View aoc-2020-python-day9.py
from itertools import combinations
def get_input():
with open('./input9.txt') as inp:
return inp.read().strip().split('\n')
def part1():
inp = get_input()
View aoc-2020-python-day8-part2.py
import sys
def get_input():
with open('./input8.txt') as inp:
return inp.read().strip().split('\n')
def finishes(ops):
visited = set()
acc = 0