Advent of Code: Day 14 Solution

This year, I’m posting my solutions to the puzzles in the Advent of Code.

I’m changing the format of these posts: from now on, I will post the code directly, along with a link to the solution on Github.

And now, on with the solution:

Day 14, part 1

Simplified problem:

Given a specific input, add an increasing number (the index) to the end and calculate the MD5 hash. If the result meets the following criteria, we consider it a key:

  • It contains three of the same character in a row, like 777. Only consider the first such triplet in a hash.
  • One of the next 1000 hashes in the stream contains that same character five times in a row, like 77777.

What is the value of index when you have found the 64th key?

Day 14, Part 2

Instead of checking the MD5 hash of your input, the input is hashed 2016 times. For example, the MD5 of abc is 900150983cd24fb0d6963f7d28e17f72. Calcuate the MD5 hash of that hash, and repeat until the input has been hashed 2016 times. Then determine whether this hash is a key.

What is the value of index when you have found the 64th key?



You can find the full solution on Github

Leave a Reply

Your email address will not be published. Required fields are marked *