Solution for Day 10

This commit is contained in:
2020-12-10 09:22:27 +01:00
parent 89090cb0f4
commit 83f4f0b6c6
3 changed files with 133 additions and 0 deletions

12
day_10/second.rb Normal file
View File

@ -0,0 +1,12 @@
# frozen_string_literal: true
input = File.readlines('./input').map(&:to_i).sort
input << input.max + 3
$c = { 0 => 1 }
input.each do |e|
$c[e] = $c.values_at(e - 1, e - 2, e - 3).compact.sum
end
puts $c[input.last]