aboutsummaryrefslogblamecommitdiff
path: root/2024/01/puzzle-1.awk
blob: 851ecce02638d87dfc36bdfeac6db8af3b11737a (plain) (tree)
1
2
3
4
5
6
7
8
9





                             
                   







                                       
#!/usr/bin/awk -f

function abs(n) {
	return n < 0 ? -n : n
}

{
	xs[NR] = $1
	ys[NR] = $2
}

END {
	asort(xs)
	asort(ys)
	for (i in xs)
		d += abs(xs[i] - ys[i])
	print d
}