DEV Community

Cover image for Advent of Code 2024 - Day 15: Warehouse Woes
Grant Riordan
Grant Riordan

Posted on

Advent of Code 2024 - Day 15: Warehouse Woes

Day 15: Warehouse Woes

This puzzle wasn't too difficult, I found myself just making a lot of functions and a lot of if statements and loops tbh.

It got to the point today where I was a bit tired out of 2D grid navigating, hence the lateness in posting this (i had to have a day off).

You can find my solution here as always.

Again, nothing too major to discuss today. The main concepts were:

a) navigate the grid looping over the instructions to determine which direction to move in.

b) keep track of where the boxes were, and checking to see if our next move was a wall or a box, if was a box check we can move the box or not.

Part 2:

a) apply the same logic, just with different parameters of being able to move two boxes at the same time as per puzzle instructions.

Key functions:

Find Boxes: The find_boxes function identifies pairs of box halves ([ and ]), representing the left and right sides of boxes, and maps their relationships for use in box-pushing logic.

Move Robot in Second Warehouse
The move_robot_in_second_warehouse function extends robot logic to handle modified grids. It uses a more complex strategy for pushing boxes ([]) and ensuring sufficient space is available. It tracks box relationships and moves them collectively when needed.

Part 1 uses the basic grid and robot logic to compute a result based on the positions of boxes (O). Whereas, Part 2 processes a modified grid, applying advanced movement rules, and computes a similar result for boxes ([])

Not much more too it really, just a 2D grid navigation with a load of conditions and movements. On the plus side, I feel my Python knowledge is improving more so around syntax, and useful library functions.

As always feel free to reach out to me on Twitter

Top comments (0)