LOADING: An error occurred. Update Chrome, try Firefox, or visit this post for more details.

⚠️Reddit changed how removals work, which breaks Reveddit's website. Install the extension to track removed content:Add to chromeAdd to firefoxWhat changed?
✖︎
about reveddit
⚙F.A.Q.add-ons
r/
status
copy sharelink
[+] show filters
91
SOLUTION MEGATHREAD-🎄- 2022 Day 7 Solutions -🎄-(self.adventofcode)
submitted 3 years, 1 month ago* (edited 15 minutes after) by daggerdragon to /r/adventofcode (134.8k)
1259 commentsredditother-discussionssubreddit-indexmessage modsop-focus
  • All of our rules, FAQs, resources, etc. are in our community wiki.
  • A reque...

... view full text

since 3 years, 1 month ago
4 of 4

Tip Reveddit Real-Time can notify you when your content is removed.

your account history
(check your username's removed content. why?)
Tip Check if your account has any removed comments.
view my removed comments
you are viewing a single comment's thread.
view all comments
[–][deleted]14 points3 years, 1 month ago* (edited 10 hours, 5 minutes after)

Google Sheets

Wasted too much on time on this because I assumed there weren't different directories with the same name. But eventually managed to get a one formula solution for both parts.

=sortn(lambda(f,query(if({1,-1}*f>{1e5,4e7-1-sum(--regexextract(A1,substitute
(regexreplace(A1,"(\d+)","($1)"),"$","\$")))},,f),"select sum(Col1), min(Col2)"))
(lambda(l,byrow(--regexextract(l,regexreplace(l,"(\d+)","($1)")),lambda(r,sum(r))))
(lambda(e,g,byrow(regexreplace(regexreplace(g,"dir (\w+)","dir "&e&"/$1"),"/+","/"),
lambda(r,reduce(r&char(10),e,lambda(a,c,ifna(regexreplace(regexreplace(a,
regexextract(a,"(?ms)dir "&c&"\n"),filter(g,e=regexextract(a,
"(?ms)dir ("&c&")\n"))&char(10)),"dir (\w+)","dir "&c&"/$1"),a))))))
(query(unique(scan(,flatten(regexextract(A1&char(10)&"$",substitute(
regexreplace(A1&char(10)&"$","(?ms)cd ([^/]+?)(\n\$)","cd ($1)$2"),"$","\$"))),
lambda(a,c,if(c<>"..",a&"/"&c,regexextract(a,"(.*)/"))))),"where Col1 is not null"),
flatten(regexextract(A1&char(10)&"$",substitute(regexreplace(A1&char(10)&"$",
"(?ms)(cd \w+\n\$ ls\n)(.*?)(\n\$)","$1($2)$3"),"$","\$")))))))

This formula will spill one cell to the right with the result of part2 and it assumes that the whole input is in cell A1.

permalinkhide replies (1)as-of
[–]mootwind2 points3 years, 1 month ago

That is actually an insane solve, good job! I also solved it through google sheets, but ended up with almost 400 columns. Also made the mistake of assuming each dir name was unique.

permalinkparentcontexthide replies (1)author-focusas-ofpreserve
[–][deleted]1 point3 years, 1 month ago* (edited 4 hours, 15 minutes after)

Thanks! I edited my post with a single formula that solves both parts. :)

The new LAMBDA and helper functions are very useful, I totally recommend getting familiar with them. (especially REDUCE, arguably the most powerful function in Sheets)

permalinkparentcontexthide replies (1)as-of
[–]mootwind1 point3 years, 1 month ago

Thanks for the tip, I will look into those! For now, I'm stuck with regular ol' cell manipulation formulas, although I dabble quite a lot with array formulas ^^

permalinkparentcontextauthor-focusas-ofpreserve
r/revedditremoved.substack.com
🚨 NEWS 🚨
✖︎

Important: Reddit Changed How Removals Work

A recent Reddit update makes mod-removed content disappear from profile pages, which breaks Reveddit's website.

Install the browser extension to receive removal alerts.

Add to chromeAdd to firefox

What changed?

r/revedditremoved.substack.com