diff options
Diffstat (limited to '2020/04/puzzle-1.awk')
-rwxr-xr-x | 2020/04/puzzle-1.awk | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/2020/04/puzzle-1.awk b/2020/04/puzzle-1.awk new file mode 100755 index 0000000..4c0c474 --- /dev/null +++ b/2020/04/puzzle-1.awk @@ -0,0 +1,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 } |