Cody

Problem 82. Remove the small words from a list of words.

Solution 2615011

Submitted on 26 Jun 2020 by 春樹 内糸
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
inStr = 'ours is not to reason why'; outStr_correct = 'ours not reason why'; assert(isequal(remove_small_words(inStr),outStr_correct))

ws = 1×6 cell array {'ours'} {'is'} {'not'} {'to'} {'reason'} {'why'} wl = 4 2 3 2 6 3 outStr = 'ours not reason why'

2   Pass
inStr = 'To be or not to be That is the question'; outStr_correct = 'not That the question'; assert(isequal(remove_small_words(inStr),outStr_correct))

ws = 1×10 cell array {'To'} {'be'} {'or'} {'not'} {'to'} {'be'} {'That'} {'is'} {'the'} {'question'} wl = 2 2 2 3 2 2 4 2 3 8 outStr = 'not That the question'

3   Pass
inStr = ' He is a dirty so and so'; outStr_correct = 'dirty and'; assert(isequal(remove_small_words(inStr),outStr_correct))

ws = 1×8 cell array {0×0 char} {'He'} {'is'} {'a'} {'dirty'} {'so'} {'and'} {'so'} wl = 0 2 2 1 5 2 3 2 outStr = 'dirty and'

4   Pass
inStr = 'oh me oh my'; outStr_correct = ''; assert(isequal(remove_small_words(inStr),outStr_correct))

ws = 1×4 cell array {'oh'} {'me'} {'oh'} {'my'} wl = 2 2 2 2 outStr = 0×0 empty char array

Suggested Problems

More from this Author95

Community Treasure Hunt

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

Start Hunting!