From 6a4cc23d95b9077fdeb4dc8cebc258da03ed4ffd Mon Sep 17 00:00:00 2001 From: Matthew Reishus Date: Mon, 27 Dec 2021 21:13:37 -0600 Subject: [PATCH] 2021: python: general cleanup --- 2021/python2021/aoc/day01.py | 4 +- 2021/python2021/aoc/day02.py | 4 -- 2021/python2021/aoc/day03.py | 4 -- 2021/python2021/aoc/day04.py | 6 +-- 2021/python2021/aoc/day13.py | 13 +++--- 2021/python2021/aoc/day14.py | 8 ++-- 2021/python2021/aoc/day15.py | 9 ++--- 2021/python2021/aoc/day16.py | 4 +- 2021/python2021/aoc/day17.py | 4 +- 2021/python2021/aoc/day19.py | 8 ++-- 2021/python2021/aoc/day21.py | 7 ++-- 2021/python2021/aoc/day23.py | 34 ++++++++-------- 2021/python2021/aoc/day23b.py | 62 +++++++++++++++++++---------- 2021/python2021/aoc/day24.py | 14 +++---- 2021/python2021/aoc/day25.py | 5 +-- 2021/python2021/python2021.py | 34 ++++++---------- 2021/python2021/tests/test_day17.py | 23 +++++++++++ 2021/python2021/tests/test_day19.py | 23 +++++++++++ 2021/python2021/tests/test_day20.py | 23 +++++++++++ 2021/python2021/tests/test_day21.py | 23 +++++++++++ 2021/python2021/tests/test_day22.py | 23 +++++++++++ 2021/python2021/tests/test_day25.py | 19 +++++++++ 22 files changed, 240 insertions(+), 114 deletions(-) create mode 100644 2021/python2021/tests/test_day17.py create mode 100644 2021/python2021/tests/test_day19.py create mode 100644 2021/python2021/tests/test_day20.py create mode 100644 2021/python2021/tests/test_day21.py create mode 100644 2021/python2021/tests/test_day22.py create mode 100644 2021/python2021/tests/test_day25.py diff --git a/2021/python2021/aoc/day01.py b/2021/python2021/aoc/day01.py index cfc6f22..ea9efe9 100644 --- a/2021/python2021/aoc/day01.py +++ b/2021/python2021/aoc/day01.py @@ -16,16 +16,14 @@ def increase_count(data: List[int], window: int) -> int: class Day01: - """ AoC 2021 Day 01 """ + """AoC 2021 Day 01""" @staticmethod def part1(filename: str) -> int: - """ Given a filename, solve 2021 day 01 part 1 """ data = parse(filename) return increase_count(data, 1) @staticmethod def part2(filename: str) -> int: - """ Given a filename, solve 2021 day 01 part 2 """ data = parse(filename) return increase_count(data, 3) diff --git a/2021/python2021/aoc/day02.py b/2021/python2021/aoc/day02.py index fed3690..0633e49 100644 --- a/2021/python2021/aoc/day02.py +++ b/2021/python2021/aoc/day02.py @@ -17,11 +17,8 @@ def parse_line(line): class Day02: - """ AoC 2021 Day 02 """ - @staticmethod def part1(filename: str) -> int: - """ Given a filename, solve 2021 day 02 part 1 """ data = parse(filename) loc = complex(0, 0) @@ -37,7 +34,6 @@ def part1(filename: str) -> int: @staticmethod def part2(filename: str) -> int: - """ Given a filename, solve 2021 day 02 part 2 """ data = parse(filename) loc = complex(0, 0) diff --git a/2021/python2021/aoc/day03.py b/2021/python2021/aoc/day03.py index c8e8f91..154eb72 100644 --- a/2021/python2021/aoc/day03.py +++ b/2021/python2021/aoc/day03.py @@ -34,11 +34,8 @@ def bit_criteria_selection(data: List[str], most_common=True) -> int: class Day03: - """AoC 2021 Day 03""" - @staticmethod def part1(filename: str) -> int: - """Given a filename, solve 2021 day 03 part 1""" data = parse(filename) common = "" @@ -60,7 +57,6 @@ def part1(filename: str) -> int: @staticmethod def part2(filename: str) -> int: - """Given a filename, solve 2021 day 03 part 2""" data = parse(filename) o2 = bit_criteria_selection(data, True) diff --git a/2021/python2021/aoc/day04.py b/2021/python2021/aoc/day04.py index 7eed882..3137c43 100644 --- a/2021/python2021/aoc/day04.py +++ b/2021/python2021/aoc/day04.py @@ -77,11 +77,11 @@ def is_winner(self): class Day04: - """ AoC 2021 Day 04 """ + """AoC 2021 Day 04""" @staticmethod def part1(filename: str) -> int: - """ Given a filename, solve 2021 day 04 part 1 """ + """Given a filename, solve 2021 day 04 part 1""" (first, boards_raw) = parse(filename) boards = [Board(board_raw) for board_raw in boards_raw] @@ -96,7 +96,7 @@ def part1(filename: str) -> int: @staticmethod def part2(filename: str) -> int: - """ Given a filename, solve 2021 day 04 part 2 """ + """Given a filename, solve 2021 day 04 part 2""" (first, boards_raw) = parse(filename) boards = [Board(board_raw) for board_raw in boards_raw] diff --git a/2021/python2021/aoc/day13.py b/2021/python2021/aoc/day13.py index f6911c0..f18c07f 100644 --- a/2021/python2021/aoc/day13.py +++ b/2021/python2021/aoc/day13.py @@ -1,7 +1,7 @@ #!/usr/bin/env python """ Advent Of Code 2021 Day 13 -https://adventofcode.com/2021/day/8 +https://adventofcode.com/2021/day/13 """ import re import numpy as np @@ -59,11 +59,11 @@ def fold(grid, var, amt): class Day13: - """ AoC 2021 Day 13 """ + """AoC 2021 Day 13""" @staticmethod def part1(filename: str) -> int: - """ Given a filename, solve 2021 day 13 part 1 """ + """Given a filename, solve 2021 day 13 part 1""" # (You guessed 722.) coords, instructs = parse(filename) @@ -72,7 +72,6 @@ def part1(filename: str) -> int: for x, y in coords: max_x = max(x, max_x) max_y = max(y, max_y) - print(f"{max_x} {max_y}") if max_x == 1305: max_x = 1310 if max_y == 893: @@ -81,8 +80,6 @@ def part1(filename: str) -> int: grid = np.zeros((max_y + 1, max_x + 1), dtype=int) for x, y in coords: grid[y][x] = 1 - # print("") - # print(grid) for var, amt in instructs: grid = fold(grid, var, amt) break @@ -90,7 +87,7 @@ def part1(filename: str) -> int: @staticmethod def part2(filename: str) -> int: - """ Given a filename, solve 2021 day 13 part 2 """ + """Given a filename, solve 2021 day 13 part 2""" coords, instructs = parse(filename) max_x = 0 @@ -98,7 +95,6 @@ def part2(filename: str) -> int: for x, y in coords: max_x = max(x, max_x) max_y = max(y, max_y) - print(f"{max_x} {max_y}") if max_x == 1305: max_x = 1310 if max_y == 893: @@ -109,5 +105,6 @@ def part2(filename: str) -> int: grid[y][x] = 1 for var, amt in instructs: grid = fold(grid, var, amt) + np.set_printoptions(linewidth=150) print(grid) return "Look at grid :)" diff --git a/2021/python2021/aoc/day14.py b/2021/python2021/aoc/day14.py index 205e742..f43db71 100644 --- a/2021/python2021/aoc/day14.py +++ b/2021/python2021/aoc/day14.py @@ -1,7 +1,7 @@ #!/usr/bin/env python """ Advent Of Code 2021 Day 14 -https://adventofcode.com/2021/day/8 +https://adventofcode.com/2021/day/14 """ from typing import Tuple, Dict from collections import defaultdict @@ -56,7 +56,7 @@ def expand(pairs, rules): class Day14: - """ AoC 2021 Day 14 """ + """AoC 2021 Day 14""" @staticmethod def partX(filename: str, steps: int) -> int: @@ -70,10 +70,10 @@ def partX(filename: str, steps: int) -> int: @staticmethod def part1(filename: str) -> int: - """ Given a filename, solve 2021 day 14 part 1 """ + """Given a filename, solve 2021 day 14 part 1""" return Day14.partX(filename, 10) @staticmethod def part2(filename: str) -> int: - """ Given a filename, solve 2021 day 14 part 2 """ + """Given a filename, solve 2021 day 14 part 2""" return Day14.partX(filename, 40) diff --git a/2021/python2021/aoc/day15.py b/2021/python2021/aoc/day15.py index fff5015..e9bcd92 100644 --- a/2021/python2021/aoc/day15.py +++ b/2021/python2021/aoc/day15.py @@ -1,9 +1,8 @@ #!/usr/bin/env python """ Advent Of Code 2021 Day 15 -https://adventofcode.com/2021/day/8 +https://adventofcode.com/2021/day/15 """ -import re from collections import defaultdict from queue import PriorityQueue @@ -97,11 +96,11 @@ def possible_edges2(loc, grid, xs, ys): class Day15: - """ AoC 2021 Day 15 """ + """AoC 2021 Day 15""" @staticmethod def part1(filename: str) -> int: - """ Given a filename, solve 2021 day 15 part 1 """ + """Given a filename, solve 2021 day 15 part 1""" grid, xs, ys = parse(filename) loc = (0, 0) @@ -135,7 +134,7 @@ def part1(filename: str) -> int: @staticmethod def part2(filename: str) -> int: - """ Given a filename, solve 2021 day 15 part 2 """ + """Given a filename, solve 2021 day 15 part 2""" grid, xs, ys = parse(filename) loc = (0, 0) diff --git a/2021/python2021/aoc/day16.py b/2021/python2021/aoc/day16.py index 39da9b3..a64715c 100644 --- a/2021/python2021/aoc/day16.py +++ b/2021/python2021/aoc/day16.py @@ -1,7 +1,7 @@ #!/usr/bin/env python """ Advent Of Code 2021 Day 16 -https://adventofcode.com/2021/day/8 +https://adventofcode.com/2021/day/16 """ from itertools import islice import math @@ -100,7 +100,7 @@ def p2(all_bits): class Day16: - """ AoC 2021 Day 16 """ + """AoC 2021 Day 16""" @staticmethod def part1(filename: str) -> int: diff --git a/2021/python2021/aoc/day17.py b/2021/python2021/aoc/day17.py index 5c41055..0b69238 100644 --- a/2021/python2021/aoc/day17.py +++ b/2021/python2021/aoc/day17.py @@ -1,7 +1,7 @@ #!/usr/bin/env python """ Advent Of Code 2021 Day 17 -https://adventofcode.com/2021/day/8 +https://adventofcode.com/2021/day/17 """ from typing import List import re @@ -57,7 +57,7 @@ def whatever(bound, xv, yv): class Day17: - """ AoC 2021 Day 17 """ + """AoC 2021 Day 17""" @staticmethod @lru_cache(maxsize=None) diff --git a/2021/python2021/aoc/day19.py b/2021/python2021/aoc/day19.py index 0478211..f6577c3 100644 --- a/2021/python2021/aoc/day19.py +++ b/2021/python2021/aoc/day19.py @@ -1,7 +1,7 @@ #!/usr/bin/env python """ Advent Of Code 2021 Day 19 -https://adventofcode.com/2021/day/8 +https://adventofcode.com/2021/day/19 """ from typing import List import re @@ -36,7 +36,7 @@ class Orientation: def all_orientations(): - """ Returns 48 orientations instead of 24 """ + """Returns 48 orientations instead of 24""" for swap in range(2): for roll in range(3): for fx in [False, True]: @@ -129,7 +129,7 @@ def match(scan1, scan2): class Day19: - """ AoC 2021 Day 19 """ + """AoC 2021 Day 19""" @staticmethod @lru_cache(maxsize=None) @@ -189,7 +189,7 @@ def part1(filename: str) -> int: @staticmethod def part2(filename: str) -> int: - """ Given a filename, solve 2021 day 19 part 2 """ + """Given a filename, solve 2021 day 19 part 2""" size, solved, scanners = Day19.partX(filename) max_dist = 0 for i in range(size): diff --git a/2021/python2021/aoc/day21.py b/2021/python2021/aoc/day21.py index 71f69bc..51cadc2 100644 --- a/2021/python2021/aoc/day21.py +++ b/2021/python2021/aoc/day21.py @@ -23,11 +23,11 @@ def wrap(num): class Day21: - """ AoC 2021 Day 21 """ + """AoC 2021 Day 21""" @staticmethod def part1(filename: str) -> int: - """ Given a filename, solve 2021 day 21 part 1 """ + """Given a filename, solve 2021 day 21 part 1""" data = [9, 3] d = Die() @@ -40,13 +40,12 @@ def part1(filename: str) -> int: if scores[i] >= 1000: break i = (i + 1) % 2 - print(scores) j = (i + 1) % 2 return scores[j] * d.rolls @staticmethod def part2(filename: str) -> int: - """ Given a filename, solve 2021 day 21 part 2 """ + """Given a filename, solve 2021 day 21 part 2""" roll1 = [3, 4, 5, 4, 5, 6, 5, 6, 7] roll2 = [x + 1 for x in roll1] roll3 = [x + 2 for x in roll1] diff --git a/2021/python2021/aoc/day23.py b/2021/python2021/aoc/day23.py index c6d6072..74b6cda 100644 --- a/2021/python2021/aoc/day23.py +++ b/2021/python2021/aoc/day23.py @@ -4,7 +4,6 @@ https://adventofcode.com/2021/day/23 """ from collections import namedtuple, defaultdict, deque -import math import itertools from heapq import heappush, heappop @@ -142,7 +141,8 @@ def solve(self): while not pq.empty(): (state, length) = pq.pop_task() if len(pq.pq) % 1000 == 0: - print(len(pq.pq)) + # print(len(pq.pq)) + pass # if len(pq.pq) > 40000: # i = 0 # for cost, counter, state in pq.pq: @@ -177,18 +177,18 @@ def solve(self): for k, v in dist_to.items(): if is_winner(k): # return v - print("Found winner:") - print(f"{v} {k}") - win_cost = v - actual_remaining_costs = {k: 0} - all_states = [k] - while k in edge_to: - all_states.append(k) - # print(edge_to[k]) - k = edge_to[k] - actual_remaining_costs[k] = -1 * (dist_to[k] - win_cost) - - self.animate(list(reversed(all_states)), actual_remaining_costs) + # print("Found winner:") + # print(f"{v} {k}") + # win_cost = v + # actual_remaining_costs = {k: 0} + # all_states = [k] + # while k in edge_to: + # all_states.append(k) + # # print(edge_to[k]) + # k = edge_to[k] + # actual_remaining_costs[k] = -1 * (dist_to[k] - win_cost) + + # self.animate(list(reversed(all_states)), actual_remaining_costs) return v return -1 @@ -454,17 +454,17 @@ def is_winner(state: State): class Day23: - """ AoC 2021 Day 23 """ + """AoC 2021 Day 23""" @staticmethod def part1(filename: str) -> int: - """ Given a filename, solve 2021 day 23 part 1 """ + """Given a filename, solve 2021 day 23 part 1""" m = Maze(filename) return m.solve() @staticmethod def part2(filename: str) -> int: - """ Given a filename, solve 2021 day 23 part 2 """ + """Given a filename, solve 2021 day 23 part 2""" return -1 diff --git a/2021/python2021/aoc/day23b.py b/2021/python2021/aoc/day23b.py index dcc5bf5..e5a6539 100644 --- a/2021/python2021/aoc/day23b.py +++ b/2021/python2021/aoc/day23b.py @@ -194,7 +194,7 @@ def solve(self): (state, length) = pq.pop_task() if len(pq.pq) % 1000 == 0: max_q_len = max(max_q_len, len(pq.pq)) - print(len(pq.pq)) + # print(len(pq.pq)) if False and len(pq.pq) > 8000: i = 0 for cost, counter, state in pq.pq: @@ -229,20 +229,20 @@ def solve(self): # print("==Done==") for k, v in dist_to.items(): if is_winner(k): - # return v - win_cost = v - actual_remaining_costs = {k: 0} - all_states = [k] - while k in edge_to: - all_states.append(k) - # print(edge_to[k]) - k = edge_to[k] - actual_remaining_costs[k] = -1 * (dist_to[k] - win_cost) - - self.animate(list(reversed(all_states)), actual_remaining_costs) - print(f"Max Q length: {max_q_len}") - print("Found winner:") - print(f"{v} {k}") + # # return v + # win_cost = v + # actual_remaining_costs = {k: 0} + # all_states = [k] + # while k in edge_to: + # all_states.append(k) + # # print(edge_to[k]) + # k = edge_to[k] + # actual_remaining_costs[k] = -1 * (dist_to[k] - win_cost) + + # self.animate(list(reversed(all_states)), actual_remaining_costs) + # # print(f"Max Q length: {max_q_len}") + # # print("Found winner:") + # # print(f"{v} {k}") return v return -1 @@ -517,25 +517,45 @@ def get_neighbors(loc): def is_winner(state: State): # return sorted(state.podlocs) == ideal As = sorted( - [state.podlocs[0], state.podlocs[1], state.podlocs[2], state.podlocs[3],] + [ + state.podlocs[0], + state.podlocs[1], + state.podlocs[2], + state.podlocs[3], + ] ) if As != [(3, 2), (3, 3), (3, 4), (3, 5)]: return False Bs = sorted( - [state.podlocs[4], state.podlocs[5], state.podlocs[6], state.podlocs[7],] + [ + state.podlocs[4], + state.podlocs[5], + state.podlocs[6], + state.podlocs[7], + ] ) if Bs != [(5, 2), (5, 3), (5, 4), (5, 5)]: return False Cs = sorted( - [state.podlocs[8], state.podlocs[9], state.podlocs[10], state.podlocs[11],] + [ + state.podlocs[8], + state.podlocs[9], + state.podlocs[10], + state.podlocs[11], + ] ) if Cs != [(7, 2), (7, 3), (7, 4), (7, 5)]: return False Ds = sorted( - [state.podlocs[12], state.podlocs[13], state.podlocs[14], state.podlocs[15],] + [ + state.podlocs[12], + state.podlocs[13], + state.podlocs[14], + state.podlocs[15], + ] ) if Ds != [(9, 2), (9, 3), (9, 4), (9, 5)]: return False @@ -543,11 +563,11 @@ def is_winner(state: State): class Day23b: - """ AoC 2021 Day 23 """ + """AoC 2021 Day 23""" @staticmethod def part2(filename: str) -> int: - """ Given a filename, solve 2021 day 23 part 1 """ + """Given a filename, solve 2021 day 23 part 1""" m = Maze(filename) return m.solve() diff --git a/2021/python2021/aoc/day24.py b/2021/python2021/aoc/day24.py index 02f7f04..5e124f3 100644 --- a/2021/python2021/aoc/day24.py +++ b/2021/python2021/aoc/day24.py @@ -3,8 +3,6 @@ Advent Of Code 2021 Day 24 https://adventofcode.com/2021/day/24 """ -from typing import List -import re import random PRINT_LOG = False @@ -84,11 +82,11 @@ def run(self): class Day24: - """ AoC 2021 Day 24 """ + """AoC 2021 Day 24""" @staticmethod def part1(filename: str) -> int: - """ Given a filename, solve 2021 day 24 part 1 """ + """Given a filename, solve 2021 day 24 part 1""" data = parse(filename) inputs = [] @@ -119,7 +117,7 @@ def check_model(inputs): PRINT_LOG = False print("") check_model(digits) - exit("check2") + return -1 # ---> [6, 7, 2, 7, 4, 1, 8, 1, 6, 2, 7, 7, 7, 5] <--- for i in range(50000): @@ -134,12 +132,12 @@ def check_model(inputs): @staticmethod def part2(filename: str) -> int: - """ Given a filename, solve 2021 day 24 part 2 """ + """Given a filename, solve 2021 day 24 part 2""" data = parse(filename) if len(data) < 20: print(data) return -1 -if __name__ == "__main__": - print(Day24.part1("../inputs/24/input.txt")) +# if __name__ == "__main__": +# print(Day24.part1("../inputs/24/input.txt")) diff --git a/2021/python2021/aoc/day25.py b/2021/python2021/aoc/day25.py index c67cb11..0d17b05 100644 --- a/2021/python2021/aoc/day25.py +++ b/2021/python2021/aoc/day25.py @@ -3,7 +3,6 @@ Advent Of Code 2021 Day 25 https://adventofcode.com/2021/day/25 """ -from typing import List from collections import defaultdict @@ -74,11 +73,11 @@ def step(grid, xsize, ysize): class Day25: - """ AoC 2021 Day 25 """ + """AoC 2021 Day 25""" @staticmethod def part1(filename: str) -> int: - """ Given a filename, solve 2021 day 25 part 1 """ + """Given a filename, solve 2021 day 25 part 1""" grid, xs, ys = parse(filename) i = 0 while True: diff --git a/2021/python2021/python2021.py b/2021/python2021/python2021.py index bf38198..2154da1 100755 --- a/2021/python2021/python2021.py +++ b/2021/python2021/python2021.py @@ -56,10 +56,12 @@ def alldays(): (Day20.part1, Day20.part2), (Day21.part1, Day21.part2), (Day22.part1, Day22.part2), - # (Day23.part1, Day23b.part2), # Bit of a mess that needs cleaning up, p1/p2 are diff files that I've been running with pypy - # Also need to bring p2 optimizations to p1, or find a way to generalize 4bots vs 2bots - # Day23b.part2 needs a special input input_b.txt, or it needs to modify input.txt to become input_b.txt + ( + Day23.part1, + Day23b.part2, + ), (Day24.part1, Day24.part2), + (Day25.part1, lambda x: 0), ] for (i, (p1, p2)) in enumerate(solvers, 1): path = f"../inputs/{i:02}/input.txt" @@ -70,6 +72,11 @@ def alldays(): p1_time = (p1_end - p1_start) * 1000 p2_start = timer() + + # Special case for p2 Day23 - input_b.txt instead of making the program modify the input + if i == 23: + path = f"../inputs/{i:02}/input_b.txt" + p2_answer = p2(path) p2_end = timer() p2_time = (p2_end - p2_start) * 1000 @@ -82,23 +89,6 @@ def alldays(): def latest(): """Scratchpad to work on.""" - # print("2021 Day 24 Part 1 (small):", end=" ") - # print(Day24.part1("../inputs/24/input_small.txt")) - # print("2021 Day 24 Part 2 (small):", end=" ") - # print(Day24.part2("../inputs/24/input_small.txt")) - - # print("2021 Day 24 Part 1b (small):", end=" ") - # print(Day24.part1b("../inputs/24/input_small3.txt")) - # print("2021 Day 24 Part 1b (small):", end=" ") - # print(Day24.part1b("../inputs/24/input.txt")) - - # print("2021 Day 24 Part 2 (small):", end=" ") - # print(Day24.part2("../inputs/24/input_small3.txt")) - # print("2021 Day 20 Part 1 (small2):", end=" ") - # print(Day24.part1("../inputs/24/input_small2.txt")) - # print("2021 Day 20 Part 2 (small2):", end=" ") - # print(Day24.part2("../inputs/24/input_small2.txt")) - print("2021 Day 25 Part 1 (small):", end=" ") print(Day25.part1("../inputs/25/input_small2.txt")) print("2021 Day 25 Part 1:", end=" ") @@ -106,5 +96,5 @@ def latest(): if __name__ == "__main__": - # alldays() - latest() + alldays() + # latest() diff --git a/2021/python2021/tests/test_day17.py b/2021/python2021/tests/test_day17.py new file mode 100644 index 0000000..315acdd --- /dev/null +++ b/2021/python2021/tests/test_day17.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +""" +Test Day17. +""" + +import unittest +from aoc.day17 import Day17 + + +class TestDay17(unittest.TestCase): + """Test Day17.""" + + def test_part1(self): + """Test part1""" + self.assertEqual(Day17.part1("../inputs/17/input.txt"), 30628) + + def test_part2(self): + """Test part2""" + self.assertEqual(Day17.part2("../inputs/17/input.txt"), 4433) + + +if __name__ == "__main__": + unittest.main() diff --git a/2021/python2021/tests/test_day19.py b/2021/python2021/tests/test_day19.py new file mode 100644 index 0000000..ec11c39 --- /dev/null +++ b/2021/python2021/tests/test_day19.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +""" +Test Day19. +""" + +import unittest +from aoc.day19 import Day19 + + +class TestDay19(unittest.TestCase): + """Test Day19.""" + + def test_part1(self): + """Test part1""" + self.assertEqual(Day19.part1("../inputs/19/input.txt"), 338) + + def test_part2(self): + """Test part2""" + self.assertEqual(Day19.part2("../inputs/19/input.txt"), 9862) + + +if __name__ == "__main__": + unittest.main() diff --git a/2021/python2021/tests/test_day20.py b/2021/python2021/tests/test_day20.py new file mode 100644 index 0000000..a4ee76f --- /dev/null +++ b/2021/python2021/tests/test_day20.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +""" +Test Day20. +""" + +import unittest +from aoc.day20 import Day20 + + +class TestDay20(unittest.TestCase): + """Test Day20.""" + + def test_part1(self): + """Test part1""" + self.assertEqual(Day20.part1("../inputs/20/input.txt"), 4873) + + def test_part2(self): + """Test part2""" + self.assertEqual(Day20.part2("../inputs/20/input.txt"), 16394) + + +if __name__ == "__main__": + unittest.main() diff --git a/2021/python2021/tests/test_day21.py b/2021/python2021/tests/test_day21.py new file mode 100644 index 0000000..f4f0f7b --- /dev/null +++ b/2021/python2021/tests/test_day21.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +""" +Test Day21. +""" + +import unittest +from aoc.day21 import Day21 + + +class TestDay21(unittest.TestCase): + """Test Day21.""" + + def test_part1(self): + """Test part1""" + self.assertEqual(Day21.part1("../inputs/21/input.txt"), 1073709) + + def test_part2(self): + """Test part2""" + self.assertEqual(Day21.part2("../inputs/21/input.txt"), 148747830493442) + + +if __name__ == "__main__": + unittest.main() diff --git a/2021/python2021/tests/test_day22.py b/2021/python2021/tests/test_day22.py new file mode 100644 index 0000000..4671144 --- /dev/null +++ b/2021/python2021/tests/test_day22.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +""" +Test Day22. +""" + +import unittest +from aoc.day22 import Day22 + + +class TestDay22(unittest.TestCase): + """Test Day22.""" + + def test_part1(self): + """Test part1""" + self.assertEqual(Day22.part1("../inputs/22/input.txt"), 582644) + + def test_part2(self): + """Test part2""" + self.assertEqual(Day22.part2("../inputs/22/input.txt"), 1263804707062415) + + +if __name__ == "__main__": + unittest.main() diff --git a/2021/python2021/tests/test_day25.py b/2021/python2021/tests/test_day25.py new file mode 100644 index 0000000..8bb25e1 --- /dev/null +++ b/2021/python2021/tests/test_day25.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 +""" +Test Day25. +""" + +import unittest +from aoc.day25 import Day25 + + +class TestDay25(unittest.TestCase): + """Test Day25.""" + + def test_part1(self): + """Test part1""" + self.assertEqual(Day25.part1("../inputs/25/input.txt"), 582) + + +if __name__ == "__main__": + unittest.main()