summary refs log tree commit diff homepage
diff options
context:
space:
mode:
-rw-r--r--2022/day03.awk17
1 files changed, 17 insertions, 0 deletions
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;
+}
09-07 13:19:32 -0400'>2019-09-07Add A Memory Called EmpireJune McEnroe 2019-09-05Handle lack of Content-TypeJune McEnroe 2019-09-05Use CURLINFO_CONTENT_TYPEJune McEnroe 2019-09-05Decode entities in titlesJune McEnroe 2019-09-05Print title as soon as it's availableJune McEnroe 2019-09-05Use CURL_PREFIX to set flagsJune McEnroe 2019-09-05Add titleJune McEnroe 2019-09-04Add Avorter n'est pas tuerJune McEnroe 2019-08-29Unset executable on shell scriptsJune McEnroe 2019-08-29Add long-missing setopt to bin.7June McEnroe 2019-08-29Add editJune McEnroe