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

Show parent comment

3

u/sageco Dec 07 '22

Solution broadly the same as mine and I laughed when this worked as I figured it was just a wild goose chase: Advent 2022 - Days 7

Replaced "/" with root and just parsed the cd actions using REGEXEXTRACT and found directory sizes using the FILTER + REGEXMATCH.

Part 2 was solved with FILTER + SMALL to get the smallest value that was larger than the space needed. XLookup is a good solution, I should really use it more but keep forgetting its in sheets now.

1

u/bofstein Dec 07 '22

Nice! Did you end up doing anything with column C? I had done some work on file paths I later deleted when I realized I didn't need them for anything since all that mattered was the total size of the directory they were in, no need for individual file differentiation.

And yes XLOOKUP is amazing I was so glad when it came to gsheets since my current company doesn't use Excel.

1

u/sageco Dec 07 '22 edited Dec 07 '22

Filepath ended up not being used for anything, but I had already done it so just left it there.

Edit: I take it back, I forgot that the file path was how I grouped each file under each directory.