<- back

advent of code - day 11

2023-12-11

See the puzzle here.

See my full solution here.

Part 1

After day 10 I was afraid day 11 would be even harder and I would need to throw in the towel, but this one was a nice break.

For part 1, I did was seemed logical and literally adjusted the galaxy map to include the extra rows and columns and then computed the distance between each pair of galaxies.

I was tempted to over-think the shortest distance algorithm, but it was just a matter of computing the difference between the x and y of each galaxy and then adding them together.

Part 2

My solution for part 1 didn't easily extend to part 2 because if I literally created the map with the extra millions of rows and columns, I started hitting memory and compute limits for my program.

I realized that I don't have to actually create the map, I just needed to check how many empty rows and columns there were between each pair, and add the extra millions to the computed distance.