diff options
author | Thomas Voss <thomasvoss@live.com> | 2021-10-29 23:02:39 +0200 |
---|---|---|
committer | Thomas Voss <thomasvoss@live.com> | 2021-10-29 23:02:39 +0200 |
commit | e7c9108b95e39d7ea5a29ae06d619c4727f11027 (patch) | |
tree | 237261eef3afd0720be77dbcbb9599fa66a24b67 /2020/04/puzzle-1.awk |
Initial commit
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 } |