aoc-2020-zig

Advent of Code 2020 Solutions in Zig
git clone https://git.sinitax.com/sinitax/aoc-2020-zig
Log | Files | Refs | README | sfeed.txt

part2 (1243B)


      1--- Part Two ---
      2
      3The tile floor in the lobby is meant to be a living art exhibit. Every day, the tiles are all
      4flipped according to the following rules:
      5
      6
      7 - Any black tile with zero or more than 2 black tiles
      8immediately adjacent to it is flipped to white.
      9 - Any white tile with exactly 2 black tiles immediately adjacent to it is
     10flipped to black.
     11
     12
     13Here, tiles immediately adjacent means the six tiles directly touching the tile in
     14question.
     15
     16The rules are applied simultaneously to every tile; put another way, it is first
     17determined which tiles need to be flipped, then they are all flipped at the same time.
     18
     19In the above example, the number of black tiles that are facing up after the given number of days
     20has passed is as follows:
     21
     22Day 1: 15
     23Day 2: 12
     24Day 3: 25
     25Day 4: 14
     26Day 5: 23
     27Day 6: 28
     28Day 7: 41
     29Day 8: 37
     30Day 9: 49
     31Day 10: 37
     32
     33Day 20: 132
     34Day 30: 259
     35Day 40: 406
     36Day 50: 566
     37Day 60: 788
     38Day 70: 1106
     39Day 80: 1373
     40Day 90: 1844
     41Day 100: 2208
     42
     43After executing this process a total of 100 times, there would be 2208 black tiles
     44facing up.
     45
     46How many tiles will be black after 100 days?
     47
     48