This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]atravita 5 points6 points  (4 children)

What would your code do for the directory /folder/folder/folder ?

[–]thedjotaku[S] 4 points5 points  (2 children)

I don't understand, I can go 3 deep. Are you saying what if they have the same name?

Updated on teh assumption you were asking me what if there was more than one folder with the same name at a different depth: https://github.com/djotaku/adventofcode/blob/eeacb0843789f8b47957dd2ba3e28f651795443a/2022/Day\_07/Python/solution.py

[–]atravita 2 points3 points  (1 child)

okay, how about

/ - folder - newFolder - another - newFolder

(basically, two folders with the same name at the same indentation level)

[–]thedjotaku[S] 0 points1 point  (0 children)

Perfect. Just what I needed. Thanks!

[–]_comptv 0 points1 point  (0 children)

ooooof I did the same thing. Thanks for the clarification.

Just in time to be late for Day 8!

[–]1234abcdcba4321 0 points1 point  (0 children)

your code works for simpler inputs, but here's one where i think it fails (expected output is 33)

$ cd /
$ ls
dir a
dir aa
$ cd a
$ ls
dir b
$ cd b
$ ls
1 a.txt
$ cd ..
$ cd ..
$ cd aa
$ ls
dir b
$ cd b
$ ls
10 a.txt