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
def part1(input_data):
output = input_data.split('\n')
fs = []
cwd = ""
for line in output:
line = line.split()
if line[0] == '$':
# command
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:
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__':
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]))
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)))
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):
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
-- table a:
create table a (
uid text primary key,
title text not null
);
create table u (
uid text primary key,
from itertools import combinations
def get_input():
with open('./input9.txt') as inp:
return inp.read().strip().split('\n')
def part1():
inp = get_input()
import sys
def get_input():
with open('./input8.txt') as inp:
return inp.read().strip().split('\n')
def finishes(ops):
visited = set()
acc = 0