Cody

# Problem 43671. Words Count: A Cell Array Approach

Solution 2125091

Submitted on 11 Feb 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
txt = 'I love MATLAB and Cody, but I don''t like trivial matlab problems on cody.'; words = {'and';'but';'Cody';'don''t';'I';'like';'love';'MATLAB';'on';'problems';'trivial'}; count = [1; 1; 2; 1; 2; 1; 1; 2; 1; 1; 1]; [words1,count1] = wordscount(txt); assert(isequal(lower(words1),lower(words))&isequal(count,count1))

Unrecognized function or variable 'p'. Error in wordscount (line 2) txt=replace(txt,p,''); Error in Test1 (line 4) [words1,count1] = wordscount(txt);

2   Fail
txt = sprintf('I love MATLAB and Cody, but I don''t like trivial matlab problems on cody.\n\nUnfortunately, there are too many trivial problems on Cody.'); words = {'and';'are';'but';'cody';'don''t';'I';'like';'love';'many';'matlab';'on';'problems';'there';'too';'trivial';'unfortunately'}; count = [1; 1; 1; 3; 1; 2; 1; 1; 1; 2; 2; 2; 1; 1; 2; 1]; [words1,count1] = wordscount(txt); assert(isequal(lower(words1),lower(words))&isequal(count,count1))

Unrecognized function or variable 'p'. Error in wordscount (line 2) txt=replace(txt,p,''); Error in Test2 (line 4) [words1,count1] = wordscount(txt);

3   Fail
txt = ['What is Cody? ',newline,' Cody is a MATLAB Central game', newline ... 'that expands your knowledge of MATLAB.',newline,... 'With Cody, you can:',newline, ... 'Solve problems related to MATLAB code;',newline, ... 'Find problems, solutions, and players; ',newline, ... 'Use search directives to find content; ',newline, ... 'Challenge the community by contributing problems;',newline, ... ' Comment on any problem or solution;',newline,... 'Like a problem or a solution; ',newline, ... 'Earn badges;',newline,newline, ... 'Play now!']; words = {'a';'and';'any';'badges';'by';'can';'central';'challenge';'code';'cody';'comment';... 'community';'content';'contributing';'directives';'earn';'expands';'find';'game';... 'is';'knowledge';'like';'matlab';'now';'of';'on';'or';'play';'players';'problem';... 'problems';'related';'search';'solution';'solutions';'solve';'that';'the';'to';... 'use';'what';'with';'you';'your'}; count = [3;1;1;1;1;1;1;1;1;3;1;1;1;1;1;1;1;2;1;2;1;1;3;1;1;1;2;1;1;2;3;1;1;2;1;1;1;1;2;1;1;1;1;1]; [words1,count1] = wordscount(txt); assert(isequal(lower(words1),lower(words))&isequal(count,count1))

Unrecognized function or variable 'p'. Error in wordscount (line 2) txt=replace(txt,p,''); Error in Test3 (line 18) [words1,count1] = wordscount(txt);

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!