commit a13d83511102bf95c1f2fe307a917d1a87fdd3a0
parent f3fa62f6f9672706ac5f44c628fcdfd705df2842
Author: Eamon Caddigan <eamon.caddigan@gmail.com>
Date: Mon, 20 Dec 2021 13:18:34 -0500
Solution to day 20, part 2
Diffstat:
1 file changed, 24 insertions(+), 0 deletions(-)
diff --git a/day20_part2.py b/day20_part2.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+"""Advent of Code 2021, day 20 (part 2): Trench Map
+Iteratively apply an 'image enhancement algorithm' to a map of the trench
+floor, more times than in part 1"""
+
+# Very easy followup puzzle
+
+from day20_part1 import (EXAMPLE_INPUT,
+ parse_input,
+ enhance_image)
+from utils import get_puzzle_input
+
+def solve_puzzle(input_string: str) -> int:
+ """Return the numeric solution to the puzzle"""
+ return enhance_image(*((parse_input(input_string)) + (50,)))[0].sum()
+
+def main() -> None:
+ """Run when the file is called as a script"""
+ assert solve_puzzle(EXAMPLE_INPUT) == 3351
+ print("Total number of lit pixels:",
+ solve_puzzle(get_puzzle_input(20)))
+
+if __name__ == "__main__":
+ main()