Advent of Code 2018 - clj's Nim Solutions

Day 18: Settlers of The North Pole

Day 18 is cellular automaton day. The goal is to determine the resource value (| multiplied by #) after a certain number of iterations. For Part I the resource value after 10 iterations is the answer, which is easy. For Part II the resource value after 1000000000 iterations which would take quite a while to find unless we can find a short-cut. As you can see below, the cellular automaton reaches a state where the pattern periodically repeats itself. If we find the start and period of the repeating pattern we can easily calculate the resource value at any point in time without having to actually run the automaton.

Using the HTML5 canvas terminal from day 15 makes bringing the cellar automaton to the web trivial. Especially as terminal output was already a feature of the original implementation. I added colour and fixed the coordinate labels, but that is about it.

Other than that I just added the ability to randomly fill and run a map in addition to the puzzle and test inputs.

Cellular Automaton

0