transpose, reverse, roll! - Day 14 - Advent of Code 2023

In this video, you’ll see how to solve Day 14 for the Advent of Code 2023 Part 1 and Part 2. The puzzle involves manipulating a grid representing a panel with rocks on it. The goal is to tilt the panel north, south, east and west to get the round rocks to roll around.


In Part 1, we’ll write a "roll" method to move the round rocks on a single row all the way to the left by swapping spaces. Then we’ll use "transpose" to tilt the whole grid north and calculate the "weight" or load on the north beam.


In Part 2, the puzzle introduces a "spin cycle" which tilts the panel in four directions repeatedly. We’ll write methods for tilting each direction. Then detect cycles in the grid states using a dictionary and set to count unique patterns. By moduloing the number of cycles by the cycle length, we’re able to index into the grid states and get the weight after 1 billion cycles.


The video demonstrates Ruby array manipulation, recursion, cycles and modulo to solve the Advent of Code puzzle.


Advent of Code: https://adventofcode.com/
My Solutions: https://gist.github.com/cjavdev/d15a2a4ffed6c840c2fb28a093e9f927/
Playlist https://www.youtube.com/playlist?list=PLS6F722u-R6KYlGyUv65EFpGKl2Esmurr

#adventofcode #ruby