aboutsummaryrefslogtreecommitdiff
path: root/2024/05/puzzle-1.awk
blob: bd9ed688fad799779da776db0bac92e57fa7b4b5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/awk -f

BEGIN { FS = "[|,]" }

/\|/ { rules[$1][$2] = 1 }
/,/ {
	delete seen
	for (i = 1; i <= NF; i++) {
		for (j in seen) {
			if (j in rules[$i])
				next
		}
		seen[$i] = 1
	}
	mid += $(i / 2)
}

END { print mid }