From 61c244e84dea782f17c2e7377c405e0ac4198cfc Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Sun, 4 Dec 2022 18:00:16 -0500 Subject: Solve day 3 part 1 --- 2022/day03.awk | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 2022/day03.awk diff --git a/2022/day03.awk b/2022/day03.awk new file mode 100644 index 0000000..6a4a153 --- /dev/null +++ b/2022/day03.awk @@ -0,0 +1,17 @@ +function common(a, b) { + split(a, as, ""); + for (i in as) { + if (index(b, as[i])) return as[i]; + } +} +function priority(x) { + return index("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", x); +} +{ + a = substr($1, 1, length($1)/2); + b = substr($1, length($1)/2 + 1); + sum += priority(common(a, b)); +} +END { + print sum; +} -- cgit 1.4.1 dontfiles
summary refs log tree commit diff
path: root/port/wcwidth (unfollow)
Commit message (Expand)Author
2020-06-11Alias sudo=doas if availableJune McEnroe
2020-06-11Add all VMs to ssh configJune McEnroe
2020-06-08Add additional permission for linking with LibreSSLJune McEnroe
2020-06-08Replace __DECONST with regular castsJune McEnroe
2020-06-08Replace __printflike with __attribute__((format(printf, ...)))June McEnroe
2020-06-08Replace __dead2 with __attribute__((noreturn))June McEnroe
2020-06-08Replace __FBSDID macros with commentsJune McEnroe
2020-06-08Remove reference to FreeBSD-specific libedit hackJune McEnroe
2020-06-08Prefix mandoc with exec in about-filterJune McEnroe
2020-06-07Remove mktemp options from mkbuiltins, mktokensJune McEnroe
2020-06-07Cast z_stream fields to size_tJune McEnroe
2020-06-07Call static_assert by _Static_assertJune McEnroe
2020-06-07Add OpenBSD to install.shJune McEnroe
2020-06-03Add The Song of AchillesJune McEnroe
2020-06-01Allow redirecting input in everJune McEnroe
2020-05-31Add %c conversion to c scriptJune McEnroe
2020-05-31Add c script to READMEJune McEnroe
2020-05-31Add c scriptJune McEnroe
2020-05-31Update mdoc source URLsJune McEnroe
2020-05-26Remove unfinished PSF fontsJune McEnroe