Something went wrong. Try again.
Code for the Advent of Code event
aoc advent-of-code
Something went wrong. Try again.
410 B · 13 lines
Ruby
at rust
1234567891011121314#!/usr/bin/env ruby# frozen_string_literal: true
times, distances = ARGF.readlines.map { _1.scan(/\d+/).map(&:to_i) }
puts times.zip(distances).reduce(1) { |total, (time, distance)| total * (0..time).find { (time - _1) * _1 > distance }.then { time - (2 * _1) + 1 }}
time = times.join.to_idistance = distances.join.to_i
puts (0..time).find { (time - _1) * _1 > distance }.then { time - (2 * _1) + 1 }