Percent delimiters %w, zip - Day 06 - Advent of Code 2023

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

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

  • @phanta5m
    @phanta5m Год назад

    the => result is new to me, so we can assign to variable at the end of block ? cool

    • @cjav_dev
      @cjav_dev  Год назад

      Oh yes! Checkout the earlier episode called rightward assignment where we talk a lot about that new Ruby feature

  • @piotrtalarczyk8987
    @piotrtalarczyk8987 Год назад

    Finally i manged to complete day 5 - it was hard. Today's puzzles are tricky. I had to back to my school time when I was 15-19 yo - more then 20 years ago to re-learn how to do quadratic equations.
    class ToyBoat
    def initialize time_given, record
    @time_given = time_given
    @record = record
    end
    def get_winning_range
    delta = @time_given ** 2 - 4 * (@record+1)
    time1 = (@time_given - Math.sqrt(delta))/2
    time1 = time1.ceil
    time2 = (@time_given + Math.sqrt(delta))/2
    time2 = time2.floor
    (time1..time2)
    end
    end
    time, record = $stdin.read.split("
    ").map(&:split)
    p time = time[1..-1].join.to_i
    p record = record[1..-1].join.to_i
    race = ToyBoat.new(time,record)
    p race
    p gwr = race.get_winning_range
    p nums_of_ways = gwr.size

    • @cjav_dev
      @cjav_dev  Год назад +1

      Nice job! Way to stay with it.

  • @piotrtalarczyk8987
    @piotrtalarczyk8987 Год назад

    BTW: What is that vim/neovim plugin that shows warnings while typing?

    • @cjav_dev
      @cjav_dev  Год назад +2

      I'm using ale - github.com/dense-analysis/ale