Cody

Problem 31. Remove all the words that end with "ain"

Solution 1540633

Submitted on 26 May 2018 by Nicholas Radziul
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
s1 = 'The rain in Spain falls mainly on the plain'; s2 = 'The in falls mainly on the '; assert(strcmp(remAin(s1),s2));

s1 = 9×1 cell array {'The' } {'rain' } {'in' } {'Spain' } {'falls' } {'mainly'} {'on' } {'the' } {'plain' } s2 = [] s2 = [] a = 'The' a = 'The' s2 = 1×1 cell array {' The'} s2 = 1×1 cell array {' The'} a = 'rain' a = 'rain' s2 = 1×1 cell array {' The '} s2 = 1×1 cell array {' The '} a = 'in' a = 'in' s2 = 1×1 cell array {' The in'} s2 = 1×1 cell array {' The in'} a = 'Spain' a = 'Spain' s2 = 1×1 cell array {' The in '} s2 = 1×1 cell array {' The in '} a = 'falls' a = 'falls' s2 = 1×1 cell array {' The in falls'} s2 = 1×1 cell array {' The in falls'} a = 'mainly' a = 'mainly' s2 = 1×1 cell array {' The in falls mainly'} s2 = 1×1 cell array {' The in falls mainly'} a = 'on' a = 'on' s2 = 1×1 cell array {' The in falls mainly on'} s2 = 1×1 cell array {' The in falls mainly on'} a = 'the' a = 'the' s2 = 1×1 cell array {' The in falls mainly on the'} s2 = 1×1 cell array {' The in falls mainly on the'} a = 'plain' a = 'plain' s2 = 1×1 cell array {' The in falls mainly on the '} s2 = ' The in falls mainly on the ' s2 = 'The in falls mainly on the ' s2 = "The in falls mainly on the "

2   Pass
s1 = 'The pain from my migraine makes me complain'; s2 = 'The from my migraine makes me '; assert(strcmp(remAin(s1),s2));

s1 = 8×1 cell array {'The' } {'pain' } {'from' } {'my' } {'migraine'} {'makes' } {'me' } {'complain'} s2 = [] s2 = [] a = 'The' a = 'The' s2 = 1×1 cell array {' The'} s2 = 1×1 cell array {' The'} a = 'pain' a = 'pain' s2 = 1×1 cell array {' The '} s2 = 1×1 cell array {' The '} a = 'from' a = 'from' s2 = 1×1 cell array {' The from'} s2 = 1×1 cell array {' The from'} a = 'my' a = 'my' s2 = 1×1 cell array {' The from my'} s2 = 1×1 cell array {' The from my'} a = 'migraine' a = 'migraine' s2 = 1×1 cell array {' The from my migraine'} s2 = 1×1 cell array {' The from my migraine'} a = 'makes' a = 'makes' s2 = 1×1 cell array {' The from my migraine makes'} s2 = 1×1 cell array {' The from my migraine makes'} a = 'me' a = 'me' s2 = 1×1 cell array {' The from my migraine makes me'} s2 = 1×1 cell array {' The from my migraine makes me'} a = 'complain' a = 'complain' s2 = 1×1 cell array {' The from my migraine makes me '} s2 = ' The from my migraine makes me ' s2 = 'The from my migraine makes me ' s2 = "The from my migraine makes me "

3   Pass
s1 = 'I had to explain that "ain" is not a word'; s2 = 'I had to that "" is not a word'; assert(strcmp(remAin(s1),s2));

s1 = 10×1 cell array {'I' } {'had' } {'to' } {'explain'} {'that' } {'"ain"' } {'is' } {'not' } {'a' } {'word' } s2 = [] s2 = [] a = 'I' a = 'I' s2 = 1×1 cell array {' I'} s2 = 1×1 cell array {' I'} a = 'had' a = 'had' s2 = 1×1 cell array {' I had'} s2 = 1×1 cell array {' I had'} a = 'to' a = 'to' s2 = 1×1 cell array {' I had to'} s2 = 1×1 cell array {' I had to'} a = 'explain' a = 'explain' s2 = 1×1 cell array {' I had to '} s2 = 1×1 cell array {' I had to '} a = 'that' a = 'that' s2 = 1×1 cell array {' I had to that'} s2 = 1×1 cell array {' I had to that'} a = '"ain"' a = '"ain"' s2 = 1×1 cell array {' I had to that ""'} s2 = 1×1 cell array {' I had to that ""'} a = 'is' a = 'is' s2 = 1×1 cell array {' I had to that "" is'} s2 = 1×1 cell array {' I had to that "" is'} a = 'not' a = 'not' s2 = 1×1 cell array {' I had to that "" is not'} s2 = 1×1 cell array {' I had to that "" is not'} a = 'a' a = 'a' s2 = 1×1 cell array {' I had to that "" is not a'} s2 = 1×1 cell array {' I had to that "" is not a'} a = 'word' a = 'word' s2 = 1×1 cell array {' I had to that "" is not a word'} s2 = ' I had to that "" is not a word' s2 = 'I had to that "" is not a word' s2 = "I had to that "" is not a word"

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!