aboutsummaryrefslogtreecommitdiff
path: root/2017/02/puzzle-1.awk
blob: 4456c99d69a3992e6d6f80022d49d777983aa0d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/env -S awk -f

{
	min = max = $1
	for (i = 2; i <= NF; i++) {
		if ($i > max)
			max = $i
		else if ($i < min)
			min = $i
	}
	acc += max - min
}

END { print acc }