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 [1m[37mthe first seat they can see[0m in each of those eight directions! 5 6Now, instead of considering just the eight immediately adjacent seats, consider the [1m[37mfirst 7seat[0m in each of those eight directions. For example, the empty seat below would see 8[1m[37meight[0m occupied seats: 9 10.......#. ...#..... .#....... ......... ..#L....# ....#.... ......... #........ ...#..... 11 12The leftmost empty seat below would only see [1m[37mone[0m empty seat, but cannot see any of the 13occupied ones: 14 15............. .L.L.#.#.#.#. ............. 16 17The empty seat below would see [1m[37mno[0m occupied seats: 18 19.##.##. #.#.#.# ##...## ...L... ##...## #.#.#.# .##.##. 20 21Also, people seem to be more tolerant than you expected: it now takes [1m[37mfive or more[0m 22visible occupied seats for an occupied seat to become empty (rather than [1m[37mfour or more[0m 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 [1m[37m26[0m occupied seats. 52 53Given the new visibility method and the rule change for occupied seats becoming empty, once 54equilibrium is reached, [1m[37mhow many seats end up occupied?[0m 55 56