[Community puzzle] Advanced Tree


#22

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.


#24

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


#25

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


#26

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?


#27

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

#28

Thanks for your help player_one :smiley:

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


#29

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


#30

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


#31

Yeah I meant CG notifications :wink:


#32

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:


#34

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


#36

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


#37

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 ) );
        }
    }        
}

#38

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

#39

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:


#40

Hi,

any other idea? This test passed..


#41

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:


#43

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


#44

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


#45

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