Solution for Day 09
This commit is contained in:
13
day_09/first.rb
Normal file
13
day_09/first.rb
Normal file
@ -0,0 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
input = File.readlines('./input').map(&:to_i)
|
||||
preamble = 25
|
||||
|
||||
input.each_with_index do |_line, i|
|
||||
next if i < preamble
|
||||
|
||||
unless input[i - preamble, preamble].combination(2).find { |a, b| a + b == input[i] }
|
||||
puts input[i]
|
||||
return
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user