diff options
| author | DrNuget <drnuget@outlook.com> | 2025-12-01 18:26:44 +0200 |
|---|---|---|
| committer | DrNuget <drnuget@outlook.com> | 2025-12-01 18:26:44 +0200 |
| commit | 32831536ddb69f7a7acad1d40e24c06274752ba3 (patch) | |
| tree | 0f529878661b7dc4099fa427cbf4884f46077237 | |
| parent | d03a627b386f82f2378f819be7fa69843e198b1a (diff) | |
| download | aoc-2025-32831536ddb69f7a7acad1d40e24c06274752ba3.tar.gz | |
day1 logic should work, doesn't git right answer
| -rwxr-xr-x | day-1/main.awk | 33 | ||||
| -rw-r--r-- | day-1/test-input.txt | 2 |
2 files changed, 35 insertions, 0 deletions
diff --git a/day-1/main.awk b/day-1/main.awk new file mode 100755 index 0000000..0d2f1a1 --- /dev/null +++ b/day-1/main.awk @@ -0,0 +1,33 @@ +#!/bin/awk -f + +BEGIN { + dial=95 + pass=0 +} + +/^L/ { + #printf $0 " " dial + sub(/L/, "", $0) + dial = dial - $0 + if (dial<0) { + dial = dial + 100 + } + if (dial==0) { + pass=pass+1 + } + print dial +} + +/^R/ { + #printf $0 " " dial + sub(/R/, "", $0) + dial = (dial + $0) % 100 + if (dial==0) { + pass=pass+1 + } + print dial +} + +END { + print "password: " pass +} diff --git a/day-1/test-input.txt b/day-1/test-input.txt new file mode 100644 index 0000000..bb58b10 --- /dev/null +++ b/day-1/test-input.txt @@ -0,0 +1,2 @@ +R10 +L5 |
