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

{
	split($1, pos, "-")
	split($3, str, "")
	char = substr($2, 1, 1)

	# Count the frequency of char
	freq = 0
	if (str[pos[1]] == char)
		freq++
	if (str[pos[2]] == char)
		freq++

	if (freq == 1)
		count++
}

END { print count }