-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1.rb
19 lines (13 loc) · 1.04 KB
/
1.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module_masses = [95249,126697,77237,80994,91186,53823,115101,130919,88127,141736,53882,67432,94292,73223,139947,66450,55710,128647,73874,57163,139502,140285,119987,125308,77561,74573,85364,92991,102935,71259,99622,118876,124482,148442,77664,90453,111933,110449,74172,148641,58574,135365,84703,81077,65290,136749,127256,94872,143534,81702,59493,72365,69497,149082,79552,78509,73759,147439,97535,118952,114301,104401,95080,100907,132914,136096,52451,70544,120717,107010,76840,51324,135258,73985,118067,86602,95127,51182,84838,60430,86347,140487,147777,85143,114215,100410,126504,69630,123656,108886,144192,123620,147217,146090,101966,80577,62193,143331,79947,93518]
@total_fuel = 0
def calculate_fuel(mass)
fuel_required = (mass / 3) - 2
puts "Fuel Required for mass: #{mass} = #{fuel_required}"
if (fuel_required > 0)
@total_fuel += fuel_required
puts "Total Fuel now: #{@total_fuel}"
calculate_fuel(fuel_required)
end
end
module_masses.each {|mm| calculate_fuel(mm) }
puts "Total Module Fuel Required: #{@total_fuel}"