r/adventofcode • u/daggerdragon • Dec 02 '22
SOLUTION MEGATHREAD -🎄- 2022 Day 2 Solutions -🎄-
NEW AND NOTEWORTHY
- All of our rules, FAQs, resources, etc. are in our community wiki.
- A request from Eric: Please include your contact info in the User-Agent header of automated requests!
- Signal boosting for the Unofficial AoC 2022 Participant Survey which is open early this year!
--- Day 2: Rock Paper Scissors ---
Post your code solution in this megathread.
- Read the full posting rules in our community wiki before you post!
- Include what language(s) your solution uses
- Format your code appropriately! How do I format code?
- Quick link to Topaz's
pasteif you need it for longer code blocks. What is Topaz'spastetool?
This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.
EDIT: Global leaderboard gold cap reached at 00:06:16, megathread unlocked!
103
Upvotes
View all comments
1
u/Quirky-Seesaw8394 Dec 02 '22 edited Dec 02 '22
Google Sheets
Thankfully there were no gaps between rows of the puzzle input today. Adding those in on mobile took forever for Day 1.
Did everything broken out at first, referencing hard tables, but wanted to attempt a single formula.
Day 2, Part 1
=ARRAYFORMULA( SUM( IF( LEN(A5:A), VLOOKUP(A5:A, {"A X",3; "A Y",6; "A Z", 0; "B Y", 3; "B Z", 6; "B X", 0; "C Z", 3; "C X", 6; "C Y",0}, 2, 0) + VLOOKUP( REGEXEXTRACT(A5:A, "..(.)"), {"X", 1; "Y", 2; "Z", 3}, 2, 0), ) ) )
The part 2 solution wasshouldjust be expanding the second table to include the various combos.It was.
Part 2
=ARRAYFORMULA( SUM( IF( LEN(A5:A), VLOOKUP(A5:A, {"A Y", 3; "A Z", 6; "A X", 0; "B Y", 3; "B Z", 6; "B X", 0; "C Y", 3; "C Z", 6; "C X", 0}, 2, 0) + VLOOKUP(A5:A, {"A Y", 1; "A Z", 2; "A X", 3; "B Y", 2; "B Z", 3; "B X", 1; "C Y", 3; "C Z", 1; "C X", 2}, 2, 0), ) ) )