blob: 63c1219f3c47b699a3b02ca1b432e841108eee33 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
# Day One: The Tyranny of the Rocket Equation
import os, strutils
let input: string = paramStr(1)
var sum, fuelsum: int = 0
for mass in lines(input):
var fuel = parseInt(mass) div 3 - 2
sum += fuel
fuelsum += fuel
while fuel > 0:
fuel = fuel div 3 - 2
fuelsum += max(0, fuel)
echo sum
echo fuelsum
|