lcm, rotate!, and modulo - Day 08 - Advent of Code 2023
Автор: CJ Avilla (cjav_dev)
Загружено: 2023-12-08
Просмотров: 252
Learn how to solve day 8 of Advent of Code 2023 - The Haunted Wasteland - in this Ruby tutorial.
We'll cover:
Parsing the input data into directions and a graph representation
Navigating the graph by rotating through direction turns
Finding paths in the graph from starting to ending nodes
Handling Part 2 where paths start from multiple nodes
Using the modulo operator and lcm method to align ending points
Refactoring to allow re-use for both parts with a block
This solution demonstrates some elegant Ruby data structures and methods like rotate, lcm, and inject to concisely traverse a directed graph. The code walkthrough explains the initial thought process and a failed solution attempt before arriving at the final answer.
Advent of Code: https://adventofcode.com/
My Solutions: https://gist.github.com/cjavdev/d15a2...
Playlist • Advent of Code
#adventofcode #ruby
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: