Solution for Day 10
This commit is contained in:
12
day_10/second.rb
Normal file
12
day_10/second.rb
Normal 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]
|
Reference in New Issue
Block a user