aboutsummaryrefslogtreecommitdiff
path: root/day-2/main.awk
diff options
context:
space:
mode:
authorDrNuget <drnuget@outlook.com>2025-12-03 00:20:36 +0200
committerDrNuget <drnuget@outlook.com>2025-12-03 00:20:36 +0200
commitf39a368e0785bcd53edaa6e30a750f026999c709 (patch)
tree6451e15ee133cff258dae7114d15c8e3f8b83b31 /day-2/main.awk
parentc45e5600d6b0db90d672fa5cab3c4ef87b9d4edf (diff)
downloadaoc-2025-f39a368e0785bcd53edaa6e30a750f026999c709.tar.gz
day2 done, took more thinking than i like to admitHEADmaster
Diffstat (limited to 'day-2/main.awk')
-rwxr-xr-xday-2/main.awk11
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
+}