r/adventofcode • • Dec 07 '22

SOLUTION MEGATHREAD -πŸŽ„- 2022 Day 7 Solutions -πŸŽ„-


AoC Community Fun 2022: πŸŒΏπŸ’ MisTILtoe Elf-ucation πŸ§‘β€πŸ«

Submissions are OPEN! Teach us, senpai!

-❄️- Submissions Megathread -❄️-


--- Day 7: No Space Left On Device ---


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:14:47, megathread unlocked!

89 Upvotes

1.3k comments sorted by

View all comments

2

u/l_dang Dec 07 '22 edited Dec 08 '22

SIMPLE PYTHON

I tried to write the simplest possible code using the absolutely nothing a beginner wouldn't know, or any library at all. So:

My humongous parser that build the whole tree as a python dictionary: paste

With this dict, both task are trivial single line solution: paste

2

u/daggerdragon Dec 08 '22 edited Dec 08 '22

Post removed due to naughty language. Keep the megathreads SFW.

  1. Next time, use the four-spaces Markdown syntax for a code block so your code is easier to read on old.reddit and mobile apps.
  2. Your code is too long to be posted here directly, so instead of wasting your time fixing the formatting, read our article on oversized code which contains two possible solutions.
  3. Put your code in an external link, then edit your post and link that here instead.

If you edit your post to take out the naughty language and fix all the issues listed above, I'll re-approve the post.

Edit: I have taken the coal out of your stocking.

1

u/l_dang Dec 08 '22

I've edited per guideline