Log in to get your input and submit your answers.
Day 11: Seating System
After daisy-chaining your joltage adapters, you finally make it into 42's main amphitheater for the Bocal's mandatory keynote.
Students trickle in one by one to find a seat. But being exhausted coders, everyone adheres to strict seating etiquette to avoid sitting too close to others.
The layout of the auditorium (your puzzle input) is represented as a character grid:
.: floor / walkway (no seat here)L: empty seat#: occupied seat
Part 1
All students apply the following rules simultaneously in rounds:
- If a seat is empty (
L) and there are no occupied seats adjacent to it (in the 8 directions: up, down, left, right, and 4 diagonals), the seat becomes occupied (#). - If a seat is occupied (
#) and four or more seats adjacent to it are also occupied, the seat becomes empty (L). - Otherwise, the seat's state does not change.
Floor tiles (.) never change.
Example
Consider this small auditorium layout initially:
L.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
L.LLLLL.LLIn the first round, since all seats are empty, they all become occupied (#). In subsequent rounds, seats with too many occupied neighbors empty out. Eventually, the seating arrangement stabilizes.
In this example, once the layout stops changing, 37 seats end up occupied.
Simulate the seating process on your own input grid. Once people stop moving around, how many seats end up occupied?