day 1 cannot mawk but it can gawk

This commit is contained in:
setop 2024-12-01 15:27:43 +01:00
parent 7cae50b408
commit cf7806ca01
1 changed files with 16 additions and 0 deletions

16
d01/run.awk Normal file
View File

@ -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
}