advent-of-code/2019/01/day1.awk
2019-12-02 09:57:13 +01:00

20 lines
259 B
Awk

#!/usr/bin/awk -f
function calc_fuel(mass) {
return int(mass / 3) - 2;
}
{
c = calc_fuel($1);
p1 += c;
while (c > 0) {
p2 += c;
c = calc_fuel(c);
}
}
END {
printf("Part 1: %s\n", p1)
printf("Part 2: %s\n", p2)
}