[Community puzzle] Advanced Tree



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

Thanks a lot!


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


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?

|-- 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.



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

  • danBhentschel


OK, thanks for your reply!


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


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


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


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:


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!


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 =>

-a,-L 4

Output =>

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

I pmed you the other one.



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.


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.


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


I am failing to pass just the LePoulpeVolant Validator, even I can pass the one posted in this page. Any idea what could I be missing? Thanks!


According to statement:

The tree needs to be sorted in ascending alphabetical order , letters in lowercase having priority on uppercases…

In reality, sorting must be case insensitive, as IDE TEST 09 shows, where .much goes after Love but before We.