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

1

u/Emotional_Cicada_575 Dec 02 '22 edited Dec 05 '22

Python

o = [[(i+j)%3*3 for i in range(j, 3+j)] for j in range(2,5)]

def solve(inp): return sum(o[a-1][b-1] + b for a,b in inp)

def parse(lines):
    return [[1 if x in "AX" else 2 if x in "BY" else 3 for x in x.strip().split()] for x in lines]

print(solve(parse(open('data/data.txt').readlines())))

1

u/daggerdragon Dec 05 '22

Please edit your post to use the four-spaces Markdown syntax for a code block so your code is easier to read on old.reddit and mobile apps.