aboutsummaryrefslogtreecommitdiff
path: root/2020/04/puzzle-1.awk
blob: 4c0c47460ae5d33e7273681bf70854cdda4e6dfb (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
24
25
26
27
28
29
30
#!/usr/bin/env -S awk -f

length == 0 {
	valid = 1
	for (i in fields) {
		if (fields[i] == "")
			valid = 0
	}

	if (valid)
		count++

	fields["byr"] = ""
	fields["iyr"] = ""
	fields["eyr"] = ""
	fields["hgt"] = ""
	fields["hcl"] = ""
	fields["ecl"] = ""
	fields["pid"] = ""
}

{
	for (i = 1; i <= NF; i++) {
		split($i, data, ":")
		fields[data[1]] = data[2]
	}
}

# Why do I need to subtract one? This code is so old I can't remember
END { print count - 1 }