[Community puzzle] Advanced Tree


#46

100%

You were right! I forgot to remove dot in hidden file name and sorting was wrong..

Thanks a lot!


#47

I have modified the Multiple Flags Test to highlight when the sorting logic is incorrect. Hopefully this will prevent confusion in the future. Thanks for your help in identifying this issue.

  • danBhentschel

#48

I do not understand the difference between test case 3 and test case 13. Why should the output be an error, instead of the following?

Directory3
|-- File5
`-- .File8
0 directories, 2 files

Should I assume that, for input line 1 "string S - a path to execute tree in", S always refers to "./" plus S if S does not begin with "./"?

Not sure if the answer to the above has anything to do with the puzzle statement: "You're only given valid paths, which are only starting with one "current directory" (./) and without "parent directory" (../)"? But I have no idea what "without parent directory" means >.< Sorry if my question sounds stupid.

Thank you.


#49

Yes.

I agree, this is a bit ambiguous, especially if you don't have a priori knowledge of how Unix-like filesystems work.

  • danBhentschel

#50

OK, thanks for your reply!


#51

Any hindsight on Validator 12? I pass every IDE TC and every submit TC except this one.


#52

Nevermind I found my issue, I wasn’t treating correctly the depth when the start directory was different than ‘.’ :slight_smile:


#53

Feel free to suggest a new test/validator pair to help others debug that!


#54

Any case where the starting directory is not ‘.’ and there’s a depth flag set will do, this TC is not covered in the IDE if I’m not mistaken :slight_smile:


#55

No, seriously, I solved this way too long to be in any kind of mood nearing reading the statement fully. Especially that one, from my memory of it.

You’re still in it, you’re at your best! Write two similar test cases, put the slightly harder one here and PM me the slightly easier one, and everybody benefits!


#56

So I made 2 TC like you asked. Turns out by doing them I found another bug in my code that wasn’t showed through any of the TC (IDE or submit).
Here’s a complex test:
Input =>

./Directory4/Directory5/Directory6
-a,-L 4
15
./Directory1/File1
./Directory1/File2
./Directory2/File3
./Directory1/File4
./Directory2/DirectoryA/File5
./File6
./.File7
./Directory2/DirectoryA/.File8
./Directory2/DirectoryA/DirectoryIII/File9
./Directory2/DirectoryA/DirectoryIII/.File10
./.Directory3/File11
./.Directory3/File13
./.Directory3/.File12
./.Directory3/DirectoryA/DirectoryI/DirectoryII/File14
./.Directory3/DirectoryA/DirectoryI/DirectoryII/File15
./Directory4/Directory5/Directory6/Directory8/Fileb
./Directory4/Directory5/Directory6/Directory8/Filec
./Directory4/Directory5/Directory6/Directory9/Directory10/Directory11/Directory12/Filee
./Directory4/Directory5/Directory6/Directory9/Directory10/Directory11/Filef
./Directory4/Directory5/Directory6/Directory7/File18
./Directory4/Directory5/Directory6/Directory7/.File17
./Directory4/Directory5/Directory6/Directory7/.File16
./Directory4/Directory5/Directory6/Directory7/File19

Output =>

./Directory4/Directory5/Directory6
|-- Directory7
|   |-- .File16
|   |-- .File17
|   |-- File18
|   `-- File19
|-- Directory8
|   |-- Fileb
|   `-- Filec
`-- Directory9
    `-- Directory10
        `-- Directory11
            |-- Directory12
            `-- Filef
            
6 directories, 7 files

I pmed you the other one.


#57

Merged.

The interface wouldn’t let me do without deciding for a difficulty level, so I put Medium for lack of a better inspiration. Feedback and counterproposals welcome.


#58

The problem I see with this puzzle, it’s more ASCII art and edge case tweaking to match an arbitrary display format than anything algorithmic. It can be very time-consuming to discover all the little discrepancies between some detail interpretations and what is actually expected. Especially in a string-unfriendly language like C++.

On the positive side:

  • Tests are very comprehensive and seem to cover pretty much all angles. I had no trouble at all with the validators.
  • Explanations are pretty good, though some points could be made clearer IMO.

My suggestions:

  • State more clearly that directory and file count shall still be printed in case of error

  • Remove this wrong and confusing explanation about name sorting. What is expected is a basic case-insensitive sort, not a weird prioritization of lowercase vs uppercase.:slight_smile:

  • The first input line is not “the path in which ‘tree’ will work” but the actual parameter passed to ‘tree’ on the command line. That’s why it can have a leading “./” or not depending on the scenarios. I had a standardized path printing routine up and running before some test showed me I had written it in vain.

  • A more meaningful example could be useful (showing things like depth limit, hidden files or directory filtering, a case of name sorting, etc.) to plan ahead instead of writing useless code that will be revealed by successive tests.


#59

God this one was a bunch of hassle
Simple but terrible to code