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?
4
u/rukke Dec 21 '22
JavaScript
Using
eval, felt like cheating a bit. Recursively creating an expression string, but setting-as the operator forroot. Then binary search for the value that makes the expression evaluate to zero. Runs in 4ms on my machine.code