AoC 2020 D24: Lobby Layout
| Problem statement | Source code | Tags: Cellular automataGrid walking
← Previous Back to AoC Index Next →
Part 1
The hexagonal grid looks like this:
We can still label them by rows and columns, and now the neighbors are:
e:(r, c + 2)w:(r, c - 2)ne:(r - 1, c + 1)nw:(r - 1, c - 1)se:(r + 1, c + 1)sw:(r + 1, c - 1)
This encoding turns this problem back into a grid problem, where we can use a set of coordinates to track black tiles.
Part 2
Yet another cellular automaton. The only twist is that the grid is hexagonal instead of square, but that just requires tweaks to the neighbor calculation. Again, the template remains unchanged:
The neighbors are just the six directions defined above.