TL;DR

On with Advent of Code puzzle 11 from 2016: attack to part 2.

In previous post AoC 2016/11 - Part 1 solution we eventually got past part 1 of the puzzle with about 30 seconds of computation:

$ cat 11.input
The first floor contains a promethium generator and a promethium-compatible microchip.
The second floor contains a cobalt generator, a curium generator, a ruthenium generator, and a plutonium generator.
The third floor contains a cobalt-compatible microchip, a curium-compatible microchip, a ruthenium-compatible microchip, and a plutonium-compatible microchip.
The fourth floor contains nothing relevant.
poletti@polebian:2016 (posts-11 *)$ time perl 11.pl 11.input
33

real  0m31.129s
user  0m30.636s
sys	  0m0.292s

This is not an encouraging time, I know, but it’s actually not that bad in the light of having spent the least amount of programmer time. Well… not any programmer, but this programmer.

(I say this because other programmers surely spent much less time to get to a much faster solution!)

So… we have access to part 2 of the puzzle, which is exactly the same problem but with more stuff to move around:

Upon entering the isolated containment area, however, you notice some extra parts on the first floor that weren’t listed on the record outside:

  • An elerium generator.
  • An elerium-compatible microchip.
  • A dilithium generator.
  • A dilithium-compatible microchip.

Well… our code is theoretically equipped to tackle this, let’s just craft a different input file, right? Here it is:

The first floor contains a promethium generator and a promethium-compatible microchip.
The second floor contains a cobalt generator, a curium generator, a ruthenium generator, and a plutonium generator.
The third floor contains a cobalt-compatible microchip, a curium-compatible microchip, a ruthenium-compatible microchip, and a plutonium-compatible microchip.
The fourth floor contains nothing relevant.
The first floor contains a elerium generator and a elerium-compatible microchip.
The first floor contains a dilithium generator and a dilithium-compatible microchip.

Same as before, with two added lines at the end, containing the new stuff.

Everything is in place. We’re ready.

Let’s run it.

OK it takes more time, that was expected.

Is it still running after about 30 minutes?

Why is the PC so slowed down?

What? This is eating up a lot of memory?!?

OK, let’s stop it.

Back. To. The. Whiteboard.