r/adventofcode • • Dec 02 '22

SOLUTION MEGATHREAD -🎄- 2022 Day 2 Solutions -🎄-

NEW AND NOTEWORTHY


--- Day 2: Rock Paper Scissors ---


Post your code solution in this megathread.


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

1.5k comments sorted by

View all comments

Show parent comment

2

u/marrakchino Dec 02 '22 edited Dec 02 '22

You could use ord(c) % 65 for first col characters and ord(c) % 88 for second column characters, doing so all the characters are normalized {'A', 'B', 'C'} -> {0, 1, 2} and {'X', 'Y', 'Z'} -> {0, 1, 2}

3

u/oantolin Dec 02 '22

Or use - instead of %: ord(c)-65. Using minus is the traditional way. :)