advent_of_code_2021

My attempts to work through the 2021 Advent of Code problems.
git clone https://git.eamoncaddigan.net/advent_of_code_2021.git
Log | Files | Refs | README | LICENSE

day20_part2.py (782B)


      1 #!/usr/bin/env python
      2 """Advent of Code 2021, day 20 (part 2): Trench Map
      3 Iteratively apply an 'image enhancement algorithm' to a map of the trench
      4 floor, more times than in part 1"""
      5 
      6 # Very easy followup puzzle
      7 
      8 from day20_part1 import (EXAMPLE_INPUT,
      9                          parse_input,
     10                          enhance_image)
     11 from utils import get_puzzle_input
     12 
     13 def solve_puzzle(input_string: str) -> int:
     14     """Return the numeric solution to the puzzle"""
     15     return enhance_image(*((parse_input(input_string)) + (50,)))[0].sum()
     16 
     17 def main() -> None:
     18     """Run when the file is called as a script"""
     19     assert solve_puzzle(EXAMPLE_INPUT) == 3351
     20     print("Total number of lit pixels:",
     21           solve_puzzle(get_puzzle_input(20)))
     22 
     23 if __name__ == "__main__":
     24     main()