aoc-2018-python

Advent of Code 2018 Solutions in Python
git clone https://git.sinitax.com/sinitax/aoc-2018-python
Log | Files | Refs | README | sfeed.txt

part1 (3751B)


      1--- Day 18: Settlers of The North Pole ---
      2
      3On the outskirts of the North Pole base construction project, many Elves are collecting lumber.
      4
      5The lumber collection area is 50 acres by 50 acres; each acre can be either open ground (.),
      6trees (|), or a lumberyard (#). You take a scan of the area (your puzzle input).
      7
      8Strange magic is at work here: each minute, the landscape looks entirely different. In exactly
      9one minute, an open acre can fill with trees, a wooded acre can be converted to a lumberyard, or a
     10lumberyard can be cleared to open ground (the lumber having been sent to other projects).
     11
     12The change to each acre is based entirely on the contents of that acre as well as the number of
     13open, wooded, or lumberyard acres adjacent to it at the start of each minute. Here, "adjacent" means
     14any of the eight acres surrounding that acre. (Acres on the edges of the lumber collection area
     15might have fewer than eight adjacent acres; the missing acres aren't counted.)
     16
     17In particular:
     18
     19
     20 - An open acre will become filled with trees if three or more adjacent acres contained trees.
     21Otherwise, nothing happens.
     22
     23 - An acre filled with trees will become a lumberyard if three or more adjacent acres were
     24lumberyards. Otherwise, nothing happens.
     25
     26 - An acre containing a lumberyard will remain a lumberyard if it was adjacent to at least one other
     27lumberyard and at least one acre containing trees. Otherwise, it becomes open.
     28
     29
     30These changes happen across all acres simultaneously, each of them using the state of all acres at
     31the beginning of the minute and changing to their new form by the end of that same minute. Changes
     32that happen during the minute don't affect each other.
     33
     34For example, suppose the lumber collection area is instead only 10 by 10 acres with this initial
     35configuration:
     36
     37Initial state:
     38.#.#...|#.
     39.....#|##|
     40.|..|...#.
     41..|#.....#
     42#.#|||#|#|
     43...#.||...
     44.|....|...
     45||...#|.#|
     46|.||||..|.
     47...#.|..|.
     48
     49After 1 minute:
     50.......##.
     51......|###
     52.|..|...#.
     53..|#||...#
     54..##||.|#|
     55...#||||..
     56||...|||..
     57|||||.||.|
     58||||||||||
     59....||..|.
     60
     61After 2 minutes:
     62.......#..
     63......|#..
     64.|.|||....
     65..##|||..#
     66..###|||#|
     67...#|||||.
     68|||||||||.
     69||||||||||
     70||||||||||
     71.|||||||||
     72
     73After 3 minutes:
     74.......#..
     75....|||#..
     76.|.||||...
     77..###|||.#
     78...##|||#|
     79.||##|||||
     80||||||||||
     81||||||||||
     82||||||||||
     83||||||||||
     84
     85After 4 minutes:
     86.....|.#..
     87...||||#..
     88.|.#||||..
     89..###||||#
     90...###||#|
     91|||##|||||
     92||||||||||
     93||||||||||
     94||||||||||
     95||||||||||
     96
     97After 5 minutes:
     98....|||#..
     99...||||#..
    100.|.##||||.
    101..####|||#
    102.|.###||#|
    103|||###||||
    104||||||||||
    105||||||||||
    106||||||||||
    107||||||||||
    108
    109After 6 minutes:
    110...||||#..
    111...||||#..
    112.|.###|||.
    113..#.##|||#
    114|||#.##|#|
    115|||###||||
    116||||#|||||
    117||||||||||
    118||||||||||
    119||||||||||
    120
    121After 7 minutes:
    122...||||#..
    123..||#|##..
    124.|.####||.
    125||#..##||#
    126||##.##|#|
    127|||####|||
    128|||###||||
    129||||||||||
    130||||||||||
    131||||||||||
    132
    133After 8 minutes:
    134..||||##..
    135..|#####..
    136|||#####|.
    137||#...##|#
    138||##..###|
    139||##.###||
    140|||####|||
    141||||#|||||
    142||||||||||
    143||||||||||
    144
    145After 9 minutes:
    146..||###...
    147.||#####..
    148||##...##.
    149||#....###
    150|##....##|
    151||##..###|
    152||######||
    153|||###||||
    154||||||||||
    155||||||||||
    156
    157After 10 minutes:
    158.||##.....
    159||###.....
    160||##......
    161|##.....##
    162|##.....##
    163|##....##|
    164||##.####|
    165||#####|||
    166||||#|||||
    167||||||||||
    168
    169After 10 minutes, there are 37 wooded acres and 31 lumberyards.  Multiplying the number of wooded
    170acres by the number of lumberyards gives the total resource value after ten minutes: 37 * 31 =
    1711147.
    172
    173What will the total resource value of the lumber collection area be after 10 minutes?
    174
    175