Advent of Code: Day 22 Solution

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

Click the link to view the puzzle and code, along with a link to the solution on Github.

And now, on with the solution:

Day 22, part 1

Simplified Problem:

Given a list of nodes (your puzzle input), how many pairs follow these rules:

  • Node A is not empty (its Used is not zero).
  • Nodes A and B are not the same node.
  • The data on node A (its Used) would fit on node B (its Avail).

Day 22, Part 2

How many steps does it take to move from Node 0,0 to the node with the highest x value, y=0? The data in the nodes must be swapped at each step.


I was able to solve for Part 1, however I became stuck on Part 2.

For Part 2, I used a solution found on the Day 22 2016 solution thread on Reddit:


You can find the full solution on Github

Leave a Reply

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