Pattern matching with Ranges - Day 02 - Advent of Code 2023

Поделиться
HTML-код
  • Опубликовано: 8 сен 2024

Комментарии • 2

  • @piotrtalarczyk8987
    @piotrtalarczyk8987 9 месяцев назад +1

    In 1st puzzle I used:
    start_cubes = {red: 12, green: 13, blue: 14}
    start_cubes.default = 0
    def possible_play? start_cubes, taken_cubes
    taken_cubes.each{|color,number|
    return false if start_cubes[color] < number
    }
    true
    end
    ...
    I set default of hash because I was thinking: is it possible that in some games (or in 2nd puzzle) they will try to pick up a cube of some other color.

    • @cjav_dev
      @cjav_dev  9 месяцев назад +1

      Nice move with default