Cody

# Problem 44853. Mean number of letters per word (Hard)

Solution 2960743

Submitted on 17 Sep 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   Pass
filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext,'eval'))) assert(isempty(strfind(filetext,'echo'))) assert(isempty(strfind(filetext,'switch')))

2   Fail
[a,g] = your_fcn_name(''); assert(isempty(a)) assert(isempty(g))

Unrecognized function or variable 'str'. Error in your_fcn_name (line 2) regexp(str,'[^\w]+','split'); Error in Test2 (line 1) [a,g] = your_fcn_name('');

3   Fail
[a,g] = your_fcn_name(' '); assert(isempty(a)) assert(isempty(g))

Unrecognized function or variable 'str'. Error in your_fcn_name (line 2) regexp(str,'[^\w]+','split'); Error in Test3 (line 1) [a,g] = your_fcn_name(' ');

4   Fail
[a,g] = your_fcn_name(' ,& '); assert(isempty(a)) assert(isempty(g))

Unrecognized function or variable 'str'. Error in your_fcn_name (line 2) regexp(str,'[^\w]+','split'); Error in Test4 (line 1) [a,g] = your_fcn_name(' ,& ');

5   Fail
[a,g] = your_fcn_name([]); assert(isempty(a)) assert(isempty(g))

Unrecognized function or variable 'str'. Error in your_fcn_name (line 2) regexp(str,'[^\w]+','split'); Error in Test5 (line 1) [a,g] = your_fcn_name([]);

6   Fail
[a,g] = your_fcn_name('23'); assert(isequal(a,0.000)) assert(isequal(g,0.000))

Unrecognized function or variable 'str'. Error in your_fcn_name (line 2) regexp(str,'[^\w]+','split'); Error in Test6 (line 1) [a,g] = your_fcn_name('23');

7   Fail
[a,g] = your_fcn_name(' The quick, brown fox jumps over the lazy dog.'); assert(isequal(a,3.889)) assert(isequal(g,3.792))

Unrecognized function or variable 'str'. Error in your_fcn_name (line 2) regexp(str,'[^\w]+','split'); Error in Test7 (line 1) [a,g] = your_fcn_name(' The quick, brown fox jumps over the lazy dog.');

8   Fail
[a,g] = your_fcn_name('...another 1 bites the dust...'); assert(isequal(a,3.800)) assert(isequal(g,0.000))

Unrecognized function or variable 'str'. Error in your_fcn_name (line 2) regexp(str,'[^\w]+','split'); Error in Test8 (line 1) [a,g] = your_fcn_name('...another 1 bites the dust...');

9   Fail
[a,g] = your_fcn_name('Is ''antidisestablishmentarianism'' the longest (nonscientific) word in the English language ?'); assert(isequal(a,7.700)) assert(isequal(g,5.386))

Unrecognized function or variable 'str'. Error in your_fcn_name (line 2) regexp(str,'[^\w]+','split'); Error in Test9 (line 1) [a,g] = your_fcn_name('Is ''antidisestablishmentarianism'' the longest (nonscientific) word in the English language ?');

10   Fail
[a,g] = your_fcn_name('I ate pudding :-)'); assert(isequal(a,3.667)) assert(isequal(g,2.759))

Unrecognized function or variable 'str'. Error in your_fcn_name (line 2) regexp(str,'[^\w]+','split'); Error in Test10 (line 1) [a,g] = your_fcn_name('I ate pudding :-)');

11   Fail
[a,g] = your_fcn_name('I hate pudding!'); assert(isequal(a,4.000)) assert(isequal(g,3.037))

Unrecognized function or variable 'str'. Error in your_fcn_name (line 2) regexp(str,'[^\w]+','split'); Error in Test11 (line 1) [a,g] = your_fcn_name('I hate pudding!');

### Community Treasure Hunt

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

Start Hunting!