Cody

# Problem 44499. Capitilize the first letter of every word in a string

Solution 1922133

Submitted on 4 Sep 2019 by Nikolaos Nikolaou
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
sentence = 'this is BETTER than C++'; corrected = 'This Is Better Than C++'; assert(isequal(autoCase(sentence), corrected))

s = 'this is better than c++' t = 1×6 cell array {'t'} {'i'} {'b'} {'t'} {'c'} {'+'} t1 = 1 6 9 16 21 23 s = 'This is better than c++' s = 'This Is better than c++' s = 'This Is Better than c++' s = 'This Is Better Than c++' s = 'This Is Better Than C++' s = 'This Is Better Than C++' corrected = 'This Is Better Than C++'

2   Pass
sentence = 'hEy, tHis iS vErY wroNg!'; corrected = 'Hey, This Is Very Wrong!'; assert(isequal(autoCase(sentence), corrected))

s = 'hey, this is very wrong!' t = 1×6 cell array {'h'} {' '} {'t'} {'i'} {'v'} {'w'} t1 = 1 5 6 11 14 19 s = 'Hey, this is very wrong!' s = 'Hey, this is very wrong!' s = 'Hey, This is very wrong!' s = 'Hey, This Is very wrong!' s = 'Hey, This Is Very wrong!' s = 'Hey, This Is Very Wrong!' corrected = 'Hey, This Is Very Wrong!'

3   Pass
sentence = 'tHIS sENTENCE wILL bE iNVERTED'; corrected = 'This Sentence Will Be Inverted'; assert(isequal(autoCase(sentence), corrected))

s = 'this sentence will be inverted' t = 1×5 cell array {'t'} {'s'} {'w'} {'b'} {'i'} t1 = 1 6 15 20 23 s = 'This sentence will be inverted' s = 'This Sentence will be inverted' s = 'This Sentence Will be inverted' s = 'This Sentence Will Be inverted' s = 'This Sentence Will Be Inverted' corrected = 'This Sentence Will Be Inverted'

4   Pass
sentence = 'This Sentence Will Not Be Changed'; corrected = 'This Sentence Will Not Be Changed'; assert(isequal(autoCase(sentence), corrected))

s = 'this sentence will not be changed' t = 1×6 cell array {'t'} {'s'} {'w'} {'n'} {'b'} {'c'} t1 = 1 6 15 20 24 27 s = 'This sentence will not be changed' s = 'This Sentence will not be changed' s = 'This Sentence Will not be changed' s = 'This Sentence Will Not be changed' s = 'This Sentence Will Not Be changed' s = 'This Sentence Will Not Be Changed' corrected = 'This Sentence Will Not Be Changed'

5   Pass
sentence = 'HELLO THERE'; corrected = 'Hello There'; assert(isequal(autoCase(sentence), corrected))

s = 'hello there' t = 1×2 cell array {'h'} {'t'} t1 = 1 7 s = 'Hello there' s = 'Hello There' corrected = 'Hello There'

6   Pass
sentence = 'AlTeRnAtInG cApS'; corrected = 'Alternating Caps'; assert(isequal(autoCase(sentence), corrected))

s = 'alternating caps' t = 1×2 cell array {'a'} {'c'} t1 = 1 13 s = 'Alternating caps' s = 'Alternating Caps' corrected = 'Alternating Caps'