diff options
author | Thomas Voss <mail@thomasvoss.com> | 2022-12-01 13:37:51 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2022-12-01 13:37:51 +0100 |
commit | ab1a834e1dded68d7d722148000cce2503b56d57 (patch) | |
tree | dffe28998dd29579795f37f4f20d9a536678b5cc /2022 | |
parent | faba8123fea6f386a9f1654056c3693e5acd521f (diff) |
Slight refactor
Diffstat (limited to '2022')
-rwxr-xr-x | 2022/01/puzzle-1.awk | 4 | ||||
-rwxr-xr-x | 2022/01/puzzle-2.awk | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/2022/01/puzzle-1.awk b/2022/01/puzzle-1.awk index 406a663..564bb46 100755 --- a/2022/01/puzzle-1.awk +++ b/2022/01/puzzle-1.awk @@ -1,5 +1,5 @@ #!/usr/bin/awk -f -/[0-9]+/ { acc += $1; next } - { if (acc > max) max = acc; acc = 0 } +/[0-9]+/ { acc += $1 } +!/./ { if (acc > max) max = acc; acc = 0 } END { print max } diff --git a/2022/01/puzzle-2.awk b/2022/01/puzzle-2.awk index d8bbaaa..6186084 100755 --- a/2022/01/puzzle-2.awk +++ b/2022/01/puzzle-2.awk @@ -1,7 +1,7 @@ #!/usr/bin/awk -f -/[0-9]+/ { acc += $1; next } -{ +/[0-9]+/ { acc += $1 } +!/./ { if (acc > max[1]) { max[3] = max[2]; max[2] = max[1]; |