solved day 1
parent
ea46dbb964
commit
3862cfb0b1
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,12 @@
|
|||
#!/bin/env ruby
|
||||
|
||||
depths = File.readlines('./input').map(&:to_i)
|
||||
|
||||
# Part 1
|
||||
changes = depths.each_cons(2).map { |first, second| second - first}
|
||||
pp changes.reject { |num| num.negative?}.count
|
||||
|
||||
# Part 2
|
||||
sums = depths.each_cons(3).map { |nums| nums.sum }
|
||||
changes = sums.each_cons(2).map { |first, second| second - first}
|
||||
pp changes.reject { |num| !num.positive?}.count
|
Loading…
Reference in New Issue