aoc-2022/02_ONLINE_01.awk

13 lines
253 B
Awk

# from /u/haveo on reddit
# https://old.reddit.com/r/adventofcode/comments/zac2v2/2022_day_2_solutions/iynf98p/?context=3
{
a = index("AB", $1)
b = index("XYZ", $2)
x += (b-a+4) % 3 * 3 + b
y += 3 * b + (a+b) % 3 - 2
}
END {
print "1: "x" 2: "y
}