aboutsummaryrefslogtreecommitdiff
path: root/2020/06/puzzle-2.awk
blob: 98224ac62c2c5ea871353742c482f493fa5ba981 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env -S awk -f

BEGIN {
	RS = ""
	FS = "\n"
}

{
	for (i = 1; i <= NF; i++) {
		len = split($i, answers, "")
		for (j = 1; j <= len; j++)
			count[answers[j]]++
	}

	for (i in count) {
		if (count[i] == NF)
			sum++
	}

	delete count
}

END { print sum }