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 | |
with open("./data/input14.txt") as inputFile: | |
input = inputFile.read().splitlines() | |
init = [] | |
for line in input: | |
m = re.findall(r'p=(-?\d+),(-?\d+) v=(-?\d+),(-?\d+)', line) | |
p = (int(m[0][0]), int(m[0][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 itertools import groupby | |
import re | |
with open("./data/input13.txt") as inputFile: | |
input = inputFile.read().splitlines() | |
groups = [list(sub) for is_empty, sub in groupby(input, key = lambda x: x == '') if not is_empty] | |
machines = [] | |
for group in groups: |
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 | |
from itertools import combinations | |
sys.setrecursionlimit(10**6) | |
with open("./data/input11.txt") as inputFile: | |
input = inputFile.read() | |
stones = [] | |
for num in input.split(' '): |
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 | |
from itertools import combinations | |
sys.setrecursionlimit(10**6) | |
with open("./data/input10.txt") as inputFile: | |
input = inputFile.read().splitlines() | |
trailheads = [] | |
grid = [] |
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
with open("./data/input09.txt") as inputFile: | |
input = inputFile.read() | |
fs = [] | |
total_free_blocks = 0 | |
i = 0 | |
while i < len(input): | |
file_id = i // 2 | |
file_size = int(input[i]) | |
free_blocks = 0 if i == len(input)-1 else int(input[i+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
import sys | |
from itertools import combinations | |
sys.setrecursionlimit(10**6) | |
with open("./data/input08.txt") as inputFile: | |
input = inputFile.read().splitlines() | |
antennas = {} | |
for r in range(len(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 | |
sys.setrecursionlimit(10**6) | |
with open("./data/input07.txt") as inputFile: | |
input = inputFile.read().splitlines() | |
equations = [] | |
for line in input: | |
tokens = line.split(': ') |
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
with open("./data/input05.txt") as inputFile: | |
input = inputFile.read().splitlines() | |
orders = set() | |
updates = [] | |
for line in input: | |
if '|' in line: | |
pages = line.split('|') | |
orders.add((int(pages[0]), int(pages[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
import re | |
with open("./data/input04.txt") as inputFile: | |
input = inputFile.read().splitlines() | |
upper_bound = len(input)-1 | |
def rev(ar): return ar[::-1] | |
# Part 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
import re | |
with open("./data/input03.txt") as inputFile: | |
input = inputFile.read() | |
def evaluate(expr): | |
m = re.findall(r'\d{1,3}', expr) | |
return int(m[0]) * int(m[1]) | |
# Part 1 |
NewerOlder