Cody

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

Solution 2655785

Submitted on 5 Jul 2020 by Ramesh Kumar V
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))

str = 'this is better than c++' idx = 1 6 9 16 21 str = 'This Is Better Than C++' c = 'This Is Better Than C++'

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

str = 'hey, this is very wrong!' idx = 1 6 11 14 19 str = 'Hey, This Is Very Wrong!' c = 'Hey, This Is Very Wrong!'

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

str = 'this sentence will be inverted' idx = 1 6 15 20 23 str = 'This Sentence Will Be Inverted' c = '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))

str = 'this sentence will not be changed' idx = 1 6 15 20 24 27 str = 'This Sentence Will Not Be Changed' c = 'This Sentence Will Not Be Changed'

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

str = 'hello there' idx = 1 7 str = 'Hello There' c = 'Hello There'

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

str = 'alternating caps' idx = 1 13 str = 'Alternating Caps' c = 'Alternating Caps'

Suggested Problems

More from this Author25

Community Treasure Hunt

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

Start Hunting!