AoC2020/day10/solution1.rb

11 lines
274 B
Ruby
Raw Normal View History

2020-12-10 13:46:43 +00:00
#!/bin/env ruby
require 'pry'
numbers = File.read('./input').split("\n").map(&:to_i).sort
solution = numbers.map.with_index do |num, i|
next if i == 0
num - numbers[i-1]
end
#binding.pry
final = [solution.count(1)+1, solution.count(3)+1]
pp final, final.reduce(&:*)