Something went wrong. Try again.
Code for the Advent of Code event
aoc advent-of-code
Something went wrong. Try again.
355 B · 14 lines
Ruby
at rust
123456789101112131415#!/usr/bin/env ruby# frozen_string_literal: true
SIZE = 25NUMS = ARGF.readlines.map(&:to_i).freeze
part1 = NUMS[SIZE..].find.with_index { |n, i| ri = i + SIZE NUMS[ri - SIZE...ri].combination(2).none? { _1 + _2 == n }}.tap { puts _1 }
puts (2..).lazy.map { |s| NUMS.each_cons(s).find { _1.sum == part1 }}.find { _1 }.then { _1.min + _1.max }