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 (2383B)


      1--- Part Two ---
      2
      3As soon as people start to arrive, you realize your mistake. People don't just care about adjacent
      4seats - they care about the first seat they can see in each of those eight directions!
      5
      6Now, instead of considering just the eight immediately adjacent seats, consider the first
      7seat in each of those eight directions. For example, the empty seat below would see
      8eight occupied seats:
      9
     10.......#. ...#..... .#....... ......... ..#L....# ....#.... ......... #........ ...#.....
     11
     12The leftmost empty seat below would only see one empty seat, but cannot see any of the
     13occupied ones:
     14
     15............. .L.L.#.#.#.#. .............
     16
     17The empty seat below would see no occupied seats:
     18
     19.##.##. #.#.#.# ##...## ...L... ##...## #.#.#.# .##.##.
     20
     21Also, people seem to be more tolerant than you expected: it now takes five or more
     22visible occupied seats for an occupied seat to become empty (rather than four or more
     23from the previous rules). The other rules still apply: empty seats that see no occupied seats become
     24occupied, seats matching no rule don't change, and floor never changes.
     25
     26Given the same starting layout as above, these new rules cause the seating area to shift around as
     27follows:
     28
     29L.LL.LL.LL LLLLLLL.LL L.L.L..L.. LLLL.LL.LL L.LL.LL.LL L.LLLLL.LL ..L.L..... LLLLLLLLLL L.LLLLLL.L
     30L.LLLLL.LL
     31
     32#.##.##.## #######.## #.#.#..#.. ####.##.## #.##.##.## #.#####.## ..#.#..... ########## #.######.#
     33#.#####.##
     34
     35#.LL.LL.L# #LLLLLL.LL L.L.L..L.. LLLL.LL.LL L.LL.LL.LL L.LLLLL.LL ..L.L..... LLLLLLLLL# #.LLLLLL.L
     36#.LLLLL.L#
     37
     38#.L#.##.L# #L#####.LL L.#.#..#.. ##L#.##.## #.##.#L.## #.#####.#L ..#.#..... LLL####LL# #.L#####.L
     39#.L####.L#
     40
     41#.L#.L#.L# #LLLLLL.LL L.L.L..#.. ##LL.LL.L# L.LL.LL.L# #.LLLLL.LL ..L.L..... LLLLLLLLL# #.LLLLL#.L
     42#.L#LL#.L#
     43
     44#.L#.L#.L# #LLLLLL.LL L.L.L..#.. ##L#.#L.L# L.L#.#L.L# #.L####.LL ..#.#..... LLL###LLL# #.LLLLL#.L
     45#.L#LL#.L#
     46
     47#.L#.L#.L# #LLLLLL.LL L.L.L..#.. ##L#.#L.L# L.L#.LL.L# #.LLLL#.LL ..#.L..... LLL###LLL# #.LLLLL#.L
     48#.L#LL#.L#
     49
     50Again, at this point, people stop shifting around and the seating area reaches equilibrium. Once
     51this occurs, you count 26 occupied seats.
     52
     53Given the new visibility method and the rule change for occupied seats becoming empty, once
     54equilibrium is reached, how many seats end up occupied?
     55
     56