[Community puzzle] Advanced Tree

Ahh now the test cases work, but now I crashes at Validator 14, which I cannot debug, cause I don’t know what this validator actually validates, since everything else works fine.

The Validator 14 is nothing edgy but the limit flag -L.
Your limit flag handling surely have problems

Well, except the number of files and filenames ofc, the big validator is testing the same ‘thing’ as the “Hidden Files with -a” test.

If you don’t pass the big validator… well it’s kinda weird, maybe check your sorting function but i don’t think the printing is the problem here then

So… What Excatly did I forget… I’m ignoring -L if there is no number. if the number is 0 or less I also do ignore it. What am I missing?

I have worked with several people who all had the same issue… matching directory names at the same depth in different branches of the hierarchy.

For example:

./A/B/X.txt
./C/B/Y.txt

There were previously no test cases that hit this situation, but some of the validators did. I have updated “Big Test 1” to test for this condition. You might want to retry your code with this modified test to see if this helps highlight the issue.

  • danBhentschel

Thanks for your help player_one :smiley:

I wish there will be notifications about posts you’re ‘following’ on the forum :confused:

You mean CG notifications? Or forum (discourse) notifications? The latter should work if you’re “watching” the topic. Let me know :wink:

Hello,
I don’t know UNIX and maybe some rules are implicit. All tests are OK but three validators are wrong and I don’t understqnd why.
With this example:
.
-a
18
./Directory1/File1
./directory4/File2
./Directory7/File3
./Directory1/File4
./Directory7/DirectoryA/File5
./File6
./.File7
./Directory7/DirectoryA/.File8
./Directory7/DirectoryA/DirectoryIII/File9
./Directory7/DirectoryA/DirectoryIII/.File10
./Directory7/DirectoryA/directoryIV/.File9
./Directory7/DirectoryA/0/File10
./.Repertoire/File11
./.Repertoire/File13
./DirecTory5/File3
./.Repertoire/.File12
./.Repertoire/RepertoireA/.DirectoryI/DirectoryII/File14
./.Repertoire/RepertoireA/.DirectoryI/DirectoryII/File15

I produce the next outputs (replacing space by .)

.
|-- directory4
|…-- File2 |-- Directory1 |...|-- File1 |...– File4
|-- Directory7
|…|-- DirectoryA
|…|…|-- 0
|…|…|…-- File10 |...|...|-- directoryIV |...|...|...– .File9
|…|…|-- DirectoryIII
|…|…|…|-- .File10
|…|…|…-- File9 |...|...|-- File5 |...|...– .File8
|…-- File3 |-- DirecTory5 |...– File3
|-- File6
|-- .File7
-- .Repertoire ....|-- File11 ....|-- .File12 ....|-- File13 ....– RepertoireA
-- .DirectoryI ............– DirectoryII
…|-- File14
…`-- File15

12 directories, 18 files

Where am I wrong? In the sort ?
Thnaks in advance
Eric

Yeah I meant CG notifications :wink:

Yup, I think you’re wrong in the sorting
Like it’s said in the statement, the tree needs to be sorted in alphabetical order with letters in lowercase having priority on uppercase.

What you misunderstood is it needs to be firstly sorted by alphabetical order, but when the letter in lowercase equals the letter in uppercase ‘lowered’, then the letter case in lowercase needs to be printed at first

Here is the output to your test (also replacing space by whitespaces):

.
|-- Directory1
|…|-- File1
|…-- File4 |-- directory4 |...– File2
|-- Directory7
|…|-- DirectoryA
|…|…|-- 0
|…|…|…-- File10 |...|...|-- DirectoryIII |...|...|...|-- .File10 |...|...|...– File9
|…|…|-- directoryIV
|…|…|…-- .File9 |...|...|-- File5 |...|...– .File8
|…-- File3 |-- DirecTory5 |...– File3
|-- File6
|-- .File7
-- .Repertoire ...|-- File11 ...|-- .File12 ...|-- File13 ....– RepertoireA
-- .DirectoryI ............– DirectoryII
…|-- File14
…`-- File15

12 directories, 18 files

I hope that helps :smiley:

Is the validator 11 the multiple flags test case ?
If so, there isn’t something special checked on it compared to the Multiple Flags Test

If you really pass the Multiple Flags Test, I don’t get why you can’t pass the Validator since it’s testing the same kind of flags

If you pass everything else, try to test the Multiple Flags Test with flags in a different order for exemple. If it doesn’t help, come back there and I will give you a testcase

Sorry, still no luck. Please take a look on my code or give test from validator (maybe changed or smth)…

if( flags.length() )
{
    if( flags.find("-a") != string::npos )
    {
        printAll = true;         
    }
    if( flags.find("-d") != string::npos )
    {
        printDirsOnly = true;         
    }        
    if( flags.find("-L") != string::npos )
    {
        // parse number after L parameter:         -L 2, -a
        int begin = 2 + flags.find( "-L" );   //     ^
        int end = flags.find( ",", begin ); //         ^
        
        if( end < 0 || end > begin)  // if no coma (-L is last flag) or there is a coma later than flag
        {
            limit = stoi( flags.substr( begin, end-begin ) );
        }
    }        
}

I notice that your end variable is only looking for a comma, but what if the -L flag is the last one given ?

Try this :

.
-d, -L 2
6
./Directory1/File1
./Directory1/File2
./Directory2/File3
./Directory1/File4
./Directory2/Directory3/File5
./File6

gives the following output :

.
|-- Directory1
`-- Directory2
    `-- Directory3

3 directories

Hi,

Variable end is then -1 as returned by find() and limit is also parsed correctly:

For your example:

Console output
Standard Output Stream:
.
-d, -L 2
6
./Directory1/File1
./Directory1/File2
./Directory2/File3
./Directory1/File4
./Directory2/Directory3/File5
./File6
.
|-- Directory1
– Directory2
– Directory3
3 directories
Success

Help! :slight_smile:

Hi,

any other idea? This test passed…

I really don’t get why you can’t pass this Validator…

You can send me your code in PM and I could take a look on it if you want :slight_smile:

Hi there, (I think) I sent you private message with code… Any ideas?

Oops sorry, I was busy these days :confused:
Gonna check out tomorrow, sorry for the wait :sweat:

You’re sorting hidden files / directories wrong. The instructions state:

The tree needs to be sorted … without considering the leading and first character ‘.’ (dot) from hidden files or directories names

Try this test case (a minor change to Multiple Flags Test)

.
-L 2,-a
8
./Directory1/File1
./Directory1/File2
./Directory2/File3
./Directory1/File4
./Directory2/Directory3/File5
./.File7
./File6
./Directory2/Directory3/.File8

It should output:

.
|-- Directory1
|   |-- File1
|   |-- File2
|   `-- File4
|-- Directory2
|   |-- Directory3
|   `-- File3
|-- File6
`-- .File7

3 directories, 6 files

Good luck.

  • danBhentschel