Advent of Code 2019 - Lua
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

12 lines
279 B

result_p1 = 0
result_p2 = 0
for mass in io.lines(arg[1], "n") do
fuel = mass // 3 - 2
result_p1 = result_p1 + fuel
while fuel > 0 do
result_p2 = result_p2 + fuel
fuel = fuel // 3 - 2
end
end
print("Part 1:", result_p1)
print("Part 2:", result_p2)