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))
words =
11×1 string array
"and"
"but"
"cody"
"don't"
"i"
"like"
"love"
"matlab"
"on"
"problems"
"trivial"
idx =
5
7
8
1
3
2
5
4
6
11
8
10
9
3
count =
1
1
2
1
2
1
1
2
1
1
1
|
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))
words =
16×1 string array
"and"
"are"
"but"
"cody"
"don't"
"i"
"like"
"love"
"many"
"matlab"
"on"
"problems"
"there"
"too"
"trivial"
"unfortunately"
idx =
6
8
10
1
4
3
6
5
7
15
10
12
11
4
16
13
2
14
9
15
12
11
4
count =
1
1
1
3
1
2
1
1
1
2
2
2
1
1
2
1
|
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))
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"
idx =
41
20
10
10
20
1
23
7
19
37
17
44
21
25
23
42
10
43
6
36
31
32
39
23
9
18
31
35
2
29
40
33
15
39
18
13
8
38
12
5
14
31
11
26
3
30
27
34
22
1
30
27
1
34
16
4
28
24
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
|
399 Solvers
Back to basics 25 - Valid variable names
253 Solvers
624 Solvers
Calculate the Number of Sign Changes in a Row Vector (No Element Is Zero)
120 Solvers
341 Solvers