aboutsummaryrefslogtreecommitdiff
path: root/2016/03/puzzle-2.awk
blob: 6e2c2f75d9c14b291b0e2b03ccc044ea6f54820e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/awk -f

NR % 3 == 1 { split($0, x) }
NR % 3 == 2 { split($0, y) }
NR % 3 == 0 { split($0, z) }

(NR % 3 == 0) && (x[1] + y[1] > z[1]) &&
	(y[1] + z[1] > x[1]) && (z[1] + x[1] > y[1]) { c++ }
(NR % 3 == 0) && (x[2] + y[2] > z[2]) &&
	(y[2] + z[2] > x[2]) && (z[2] + x[2] > y[2]) { c++ }
(NR % 3 == 0) && (x[3] + y[3] > z[3]) &&
	(y[3] + z[3] > x[3]) && (z[3] + x[3] > y[3]) { c++ }

END { print c }