combination, filter_map - Day 11 - Advent of Code
Вставка
- Опубліковано 27 сер 2024
- Join me as we traverse the cosmos while solving Day 11 of Advent of Code 2023 - Cosmic Expansion - in Ruby!
In this coding galaxy quest, we'll:
Parse an image grid of galaxies and empty space
Expand the grid by inserting extra rows and columns
Find all galaxy locations and calculate distances
Generate combinations of galaxies to compare
Refactor distance to handle cosmic doubling
Scale empty spaces to multiply distances
The solution handles parsing the image input and initially expanding it. We then pivot to a calculation-based approach without materializing massive arrays. Some elegant Ruby built in methods like combination and inject help compare galaxy pairs.
Advent of Code: adventofcode.com/
My Solutions: gist.github.co...
Playlist • Advent of Code
#adventofcode #ruby