Cody

# Problem 43670. Words Count: A String Array Approach

Solution 1213087

Submitted on 15 Jun 2017 by Timothy Greco
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   Pass
txt = 'I love MATLAB and Cody, but I don''t like trivial matlab problems on cody.'; words = string({'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))

txt = 'I love MATLAB and Cody but I don't like trivial matlab problems on cody' words = 11Ã—1 string array "and" "but" "Cody" "don't" "I" "like" "love" "MATLAB" "on" "problems" "trivial"

2   Pass
txt = sprintf('\n\nI 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 = string({'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))

txt = ' I love MATLAB and Cody but I don't like trivial matlab problems on cody Unfortunately there are too many trivial problems on Cody' words = 16Ã—1 string array "and" "are" "but" "Cody" "don't" "I" "like" "love" "many" "MATLAB" "on" "problems" "there" "too" "trivial" "Unfortunately"

3   Pass
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 = string({'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))

txt = 'What is Cody Cody is a MATLAB Central game that expands your knowledge of MATLAB With Cody you can Solve problems related to MATLAB code Find problems solutions and players Use search directives to find content Challenge the community by contributing problems Comment on any problem or solution Like a problem or a solution Earn badges Play now' words = 44Ã—1 string array "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"