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)