Skip to content

Commit

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

def solve(elves, size)
elves.map(&:sum).max(size).sum
end
puts solve(elves, 1)
puts solve(elves, 3)
14 changes: 14 additions & 0 deletions 2022/examples/day01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
1000
2000
3000

4000

5000
6000

7000
8000
9000

10000

0 comments on commit fbee56d

Please sign in to comment.