solved part 1
parent
21e651af44
commit
1cd2b62ba0
|
@ -0,0 +1,18 @@
|
|||
#!/bin/env ruby
|
||||
|
||||
def valid_nums (nums)
|
||||
nums.map { |num| nums
|
||||
.map { |sub| sub + num if sub != num }}.flatten.uniq.compact
|
||||
end
|
||||
|
||||
numbers = File.readlines('./input').to_ary.map(&:strip!).map(&:to_i)
|
||||
preamble = 25
|
||||
|
||||
|
||||
numbers.each.with_index do |number, i|
|
||||
next if i < preamble
|
||||
if !valid_nums(numbers[(i-preamble)..(i-1)]).include?(number)
|
||||
puts number
|
||||
break
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue