diff options
| author | DrNuget <drnuget@outlook.com> | 2025-12-03 00:20:36 +0200 |
|---|---|---|
| committer | DrNuget <drnuget@outlook.com> | 2025-12-03 00:20:36 +0200 |
| commit | f39a368e0785bcd53edaa6e30a750f026999c709 (patch) | |
| tree | 6451e15ee133cff258dae7114d15c8e3f8b83b31 /day-2/main.awk | |
| parent | c45e5600d6b0db90d672fa5cab3c4ef87b9d4edf (diff) | |
| download | aoc-2025-master.tar.gz | |
Diffstat (limited to 'day-2/main.awk')
| -rwxr-xr-x | day-2/main.awk | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/day-2/main.awk b/day-2/main.awk index 5200e96..bfa6350 100755 --- a/day-2/main.awk +++ b/day-2/main.awk @@ -2,11 +2,20 @@ BEGIN { RS="," + pass=0 } { split($0, range, "-") for (i=range[1];i<=range[2];i++) { - print i + first=substr(i, 1, length(i)/2) + last=substr(i, length(i)/2+1) + if (first==last) { + pass=pass+i + } } } + +END { + print "password " pass +} |
