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

8

u/xelf Dec 02 '22

very similar:

with open(filename) as f: data = f.read().replace(' ','').splitlines()
p1 = ['','BX','CY','AZ','AX','BY','CZ','CX','AY','BZ']
p2 = ['','BX','CX','AX','AY','BY','CY','CZ','AZ','BZ']
print(f'part1: {sum(map(p1.index,data))} part2: {sum(map(p2.index,data))}')

4

u/4HbQ Dec 02 '22

Nice! Happy to see you’re back again and still writing clever code.

I learned quite a few nice (and niche) tricks from you last year.

3

u/xelf Dec 02 '22

That's what I love about aoc, seeing all the different approaches! I still need to learn more numpy, your solutions last year were absolutely amazing.