Merge both parts of day 1
This commit is contained in:
parent
b68651c4f8
commit
8da3860779
|
@ -1,8 +1,18 @@
|
|||
#!/usr/bin/awk -f
|
||||
|
||||
function calc_fuel(mass) {
|
||||
return int(mass / 3) - 2;
|
||||
}
|
||||
|
||||
{
|
||||
s += int($1 / 3) - 2;
|
||||
c = calc_fuel($1);
|
||||
p1 += c;
|
||||
while (c > 0) {
|
||||
p2 += c;
|
||||
c = calc_fuel(c);
|
||||
}
|
||||
}
|
||||
END {
|
||||
print s;
|
||||
printf("Part 1: %s\n", p1)
|
||||
printf("Part 2: %s\n", p2)
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
#!/usr/bin/awk -f
|
||||
|
||||
function calc_fuel(mass) {
|
||||
return int(mass / 3) - 2;
|
||||
}
|
||||
|
||||
{
|
||||
c = calc_fuel($1);
|
||||
while (c > 0) {
|
||||
s += c;
|
||||
c = calc_fuel(c);
|
||||
}
|
||||
}
|
||||
END {
|
||||
print s;
|
||||
}
|
Loading…
Reference in New Issue
Block a user