add day 2 online solution

This commit is contained in:
yosh 2022-12-02 13:45:19 -05:00
parent 3c74beb814
commit c600e6198c
2 changed files with 14 additions and 0 deletions

12
02_ONLINE_01.awk Normal file
View File

@ -0,0 +1,12 @@
# 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
}

View File

@ -2,6 +2,8 @@ my advent of code 2022 solutions
mainly going to be using shell + posix-defined utilities, probably
this repo will also include online solutions that I think are neat, indicated by "ONLINE" and with credit in the file
## Days
1. awk (uses features exclusive to GNU's implementation, gawk)
2. shell (completely POSIX-conforming implementation)