diff --git a/d01/run.awk b/d01/run.awk new file mode 100644 index 0000000..21ebb4e --- /dev/null +++ b/d01/run.awk @@ -0,0 +1,16 @@ +{ + l[NR] = $1 + r[NR] = $2 + C[$2]++ +} + +END { + asort(l) + asort(r) + for (i = 1; i <= NR; i++) { + d = l[i] - r[i] + D1 += (d < 0) ? -d : d + D2 += l[i] * C[l[i]] + } + print D1, D2 +}