don’t want to look at today’s :thread: and have it...
# advent-of-code
l
don’t want to look at today’s 🧵 and have it spoiled, so i’m just gonna ask those who have finished it something in this 🧵 :
am i barking up the wrong tree (no pun intended) by implementing my own tree? 😂
c
You don’t have to do so but a number of us have
I’ve implemented my own file system structure on the basis of I suspect this is going to come up again and I can re-use it
l
ok thanks @Charles Flynn - yeah, the more i worked with my tree implementation the closer it got to just a FS structure, so i’ll keep up with that and then figure out how to do the filtering and counting 🙂
j
That's the easy part my problem was parsing the tree
f
I didn't - just parsed most of it as strings. I suspect I will regret it when Day13 comes though... when we will have to add support for multiple
ls
in the same directory, add support for
rm
and
touch
, handle changing file sized and what not
great way to ask a question btw - discussing without spoiling @Luke Armitage!
j
@Fredrik Rødland thinking about intcode computer from previous years I also hope that this year Eric hasn't decided to make us gradually implement a filesystem including symlinks/hardlinks, cyclic references, permissions, etc. or doing other low-level OS-related stuff in some assembly language in the communication device the Elves so gladly gave us.
d
There is no problem making your own tree, I did as well. To filter it, you can use a breadth first or depth first search to traverse the tree
l
yeah, i'm (i think) doing depth-first, recursively iterating through directories and getting all the files that are less than the max size, however when i add them up i get the right answer for the example but the wrong answer (too high) for the proper input :(
d'oh. realised i'd set a file-level val to refer to the root of the tree, when i first started it was a string but ended up becoming a Directory, but then when it was running the proper input it still had the test FS in it 😅
thanks for your help everyone, looking through the other thread it looks like a lot of other people ran into similar issues (reusing the root node aside 😂 )
a
I did a quick and dirty tree structure with a DFS visitor pattern to grab the nodes that met the criteria. Looking at other solutions (and since it all fits into memory) just keeping a list of directory nodes simplified the problem.