Cody

Problem 65. Word Counting and Indexing

Solution 2672027

Submitted on 9 Jul 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Fail
sl = {'one two three','two one four zero'}; wtc = {'four','one','three','two','zero'}; silc = {[2 4 3],[4 2 1 5]}; [wt,sil] = word_index(sl); assert(isequal(wt,wtc))

Error using split (line 99) Element 2 of the text contains 3 delimiters while the previous elements have 2. All elements must contain the same number of delimiters. Error in word_index (line 2) temp = split(str_list, " "); Error in Test1 (line 4) [wt,sil] = word_index(sl);

2   Fail
sl = {'one two three'}; wtc = {'one','three','two'}; silc = {[1 3 2]}; [wt,sil] = word_index(sl); assert(isequal(wt,wtc))

Matrix dimensions must agree. Error in word_index (line 8) while(temp{j-1} == temp{j}) Error in Test2 (line 4) [wt,sil] = word_index(sl);

3   Fail
sl = {'this little piggy went to market', ... 'and this little piggy stayed home', ... 'this little piggy had roast beef', ... 'and this one studied computer science at piggy university'}; wtc = { ... 'and','at','beef','computer','had','home', ... 'little','market','one','piggy','roast','science', ... 'stayed','studied','this','to','university','went'}; silc = { ... [15 7 10 18 16 8], ... [1 15 7 10 13 6], ... [15 7 10 5 11 3], ... [ 1 15 9 14 4 12 2 10 17]}; [wt,sil] = word_index(sl); assert(isequal(wt,wtc))

Error using split (line 99) Element 4 of the text contains 8 delimiters while the previous elements have 5. All elements must contain the same number of delimiters. Error in word_index (line 2) temp = split(str_list, " "); Error in Test3 (line 15) [wt,sil] = word_index(sl);