Skip to content

Commit

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

puts module_masses.map { |mass| (mass / 3) - 2 }.sum
puts (
module_masses.map do |mass|
fuel = 0
while mass > 0
mass = (mass / 3) - 2
fuel += mass < 0 ? 0 : mass
end
fuel
end.sum
)
3 changes: 3 additions & 0 deletions 2019/examples/day01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
14
1969
100756

0 comments on commit 578ebe0

Please sign in to comment.