Skip to content

Commit

Permalink
Year 2021 Day 1
Browse files Browse the repository at this point in the history
  • Loading branch information
tudorpavel committed Oct 28, 2024
1 parent adf56c5 commit aca1f4d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions 2021/day01.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
measurements = STDIN.read.split("\n").map(&:to_i)

def solve(measurements, size)
measurements.each_cons(size).map(&:sum).each_cons(2).count { |a, b| a < b }
end
puts solve(measurements, 1)
puts solve(measurements, 3)
10 changes: 10 additions & 0 deletions 2021/examples/day01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
199
200
208
210
200
207
240
269
260
263

0 comments on commit aca1f4d

Please sign in to comment.