combination, filter_map - Day 11 - Advent of Code
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: https://adventofcode.com/
My Solutions: https://gist.github.com/cjavdev/d15a2a4ffed6c840c2fb28a093e9f927/
Playlist https://www.youtube.com/playlist?list=PLS6F722u-R6KYlGyUv65EFpGKl2Esmurr
#adventofcode #ruby