[2019][ruby][1.2]

sorbet
Alpha Chen 5 years ago
parent 039d772758
commit b15f5ee2a1

@ -0,0 +1,7 @@
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem "minitest"

@ -0,0 +1,13 @@
GEM
remote: https://rubygems.org/
specs:
minitest (5.13.0)
PLATFORMS
ruby
DEPENDENCIES
minitest
BUNDLED WITH
2.0.2

@ -0,0 +1,15 @@
# puts ARGF.read.lines.map(&:to_i).map {|mass|
# (mass / 3.0).floor - 2
# }.sum
fuel = ->(mass) {
total = 0
loop do
mass = (mass / 3.0).floor - 2
break if mass <= 0
total += mass
end
total
}
puts ARGF.read.lines.map(&:to_i).map(&fuel).sum
Loading…
Cancel
Save