Introduction
Introduction Statistics Contact Development Disclaimer Help
taoc2b: add aoc day 2 part B - aoc22 - advent of code 2022 solutions
git clone git://src.adamsgaard.dk/aoc22
Log
Files
Refs
README
---
commit 6759117bc4ae6e546eda4f5cca25727cbf23e411
parent 6255129568acf9777c55a4e9b2792c266b19f7dc
Author: Anders Damsgaard <[email protected]>
Date: Fri, 2 Dec 2022 16:13:46 +0000
aoc2b: add aoc day 2 part B
Diffstat:
A 2/aoc2b | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/2/aoc2b b/2/aoc2b
t@@ -0,0 +1,30 @@
+#!/bin/awk -f
+# usage: aoc2b <input
+BEGIN {
+ value["A"] = 1 # rock
+ value["B"] = 2 # paper
+ value["C"] = 3 # scissors
+}
+{
+ if ($2 == "Y") {
+ sym = $1
+ sum += 3
+ } else if ($2 == "Z") {
+ if ($1 == "A")
+ sym = "B"
+ else if ($1 == "B")
+ sym = "C"
+ else
+ sym = "A"
+ sum += 6
+ } else {
+ if ($1 == "A")
+ sym = "C"
+ else if ($1 == "B")
+ sym = "A"
+ else
+ sym = "B"
+ }
+ sum += value[sym]
+}
+END { print sum }
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.