each_cons, and layers 🎂 - Day 09 - Advent of Code 2023

Поділитися
Вставка
  • Опубліковано 11 жов 2024
  • Learn how to solve Day 9 of Advent of Code 2023 - Mirage Maintenance - in Ruby!
    In this episode, we'll cover:
    Parsing the input data into statistics
    Breaking down the statistics layer by layer to differences
    Building back up each layer to extrapolate the next value
    Collecting layers into an array of arrays
    Predicting future and past values by adding to array ends
    Refactoring with destructuring for conciseness
    The solution demonstrates some neat iteration techniques in Ruby:
    each_cons to yield consecutive pairs
    unshift to add to array front
    map, select, inject to transform arrays
    We walk through the thought process, test examples, and refine the logic until we have scripts that generate the right answers for both parts of this puzzle.
    If you're participating in Advent of Code or just want to level up your Ruby skills, join me for this festive programming challenge!
    Advent of Code: adventofcode.com/
    My Solutions: gist.github.co...
    Playlist • Advent of Code
    #adventofcode #ruby

КОМЕНТАРІ •