This solution was done in Perl. Run perl day12.pl
to get the answers.
This was a super fun problem to solve, especially part 2. I had to do a bit of playing around with the numbers to figure out a neat way to quickly get the answer. Perl was a fine language to solve it, although it has its quirks.