This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
This file contains hidden or 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/input02.txt") as inputFile: | |
| input = inputFile.read().splitlines() | |
| reports = [] | |
| for line in input: | |
| report = list(map(lambda x: int(x), line.split(' '))) | |
| reports.append(report) | |
| def report_is_safe(report): | |
| safe = True |
This file contains hidden or 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/input01.txt") as inputFile: | |
| input = inputFile.read().splitlines() | |
| left = [] | |
| right = [] | |
| for line in input: | |
| m = re.findall(r'(\d+)', line) | |
| left.append(int(m[0])) |