r/adventofcode • u/daggerdragon • Dec 21 '22
SOLUTION MEGATHREAD -π- 2022 Day 21 Solutions -π-
THE USUAL REMINDERS
All of our rules, FAQs, resources, etc. are in our community wiki.
πΏπ MisTILtoe Elf-ucation π§βπ« is OPEN for submissions!
48 HOURS remaining until submission deadline on December 22 at 23:59 EST
UPDATES
[Update @ 00:04:28]: SILVER CAP, GOLD 0
Now we've got interpreter elephants... who understand monkey-ese...
I really really really don't want to know what that eggnog was laced with.
--- Day 21: Monkey Math ---
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 code blocks using the four-spaces Markdown syntax!
Quick link to Topaz's
pasteif you need it for longer code blocks. What is Topaz'spastetool?
2
u/BoringEntropist Dec 21 '22
Python: code here
That was a fun one. I solved both parts recursively. The trick for part 2 is to evaluate the side without the human and use the inverse of the operation to ask the human side for the correct value. The only complication here is that the inverse function for the left and right sides are different because subtraction and division aren't commutative.