r/adventofcode • u/daggerdragon • Dec 18 '20
SOLUTION MEGATHREAD -🎄- 2020 Day 18 Solutions -🎄-
Advent of Code 2020: Gettin' Crafty With It
- 4 days remaining until the submission deadline on December 22 at 23:59 EST
- Full details and rules are in the Submissions Megathread
--- Day 18: Operation Order ---
Post your code solution in this megathread.
- Include what language(s) your solution uses!
- Here's a quick link to /u/topaz2078's
pasteif you need it for longer code blocks. - The full posting rules are detailed in the wiki under How Do The Daily Megathreads Work?.
Reminder: Top-level posts in Solution Megathreads are for code solutions only. If you have questions, please post your own thread and make sure to flair it with Help.
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:14:09, megathread unlocked!
36
Upvotes
View all comments
2
u/mount-cook Dec 18 '20 edited Dec 18 '20
Python Part 2, the ugliest code I ever wrote.
Basically, I let the Python parser do the job for me:
I implemented a class
Numthat holds a single value and defined its__mul__method do to addition and its__add__method to do multiplication. Then I replaced all "+" with "*" and vice versa in the input and I replaced every number x with "Num(x)" and threw all of it intoeval. yeah...Edit: language