summary refs log tree commit diff homepage
path: root/2022
diff options
context:
space:
mode:
Diffstat (limited to '2022')
-rw-r--r--2022/day02.awk17
1 files changed, 15 insertions, 2 deletions
diff --git a/2022/day02.awk b/2022/day02.awk
index 3e349c3..d01b15d 100644
--- a/2022/day02.awk
+++ b/2022/day02.awk
@@ -13,8 +13,21 @@ function score(a, b) {
 {
 	a = index("ABC", $1);
 	b = index("XYZ", $2);
-	total += score(a, b);
+	total1 += score(a, b);
+	if (b == 1) {
+		if (a == 1) b = 3;
+		if (a == 2) b = 1;
+		if (a == 3) b = 2;
+	} else if (b == 2) {
+		b = a;
+	} else if (b == 3) {
+		if (a == 1) b = 2;
+		if (a == 2) b = 3;
+		if (a == 3) b = 1;
+	}
+	total2 += score(a, b);
 }
 END {
-	print total;
+	print total1;
+	print total2;
 }