solved day 1

master
s00ner 7 months ago
parent ea46dbb964
commit 3862cfb0b1
  1. 2000
      day01/input
  2. 12
      day01/solution.rb

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…
Cancel
Save