Cody

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

Solution 2108687

Submitted on 28 Jan 2020 by Avishay Hertz
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))

x = 1 s = 'This is BETTER than C++' x = 0 s = 'This is BETTER than C++' s = 'This is BETTER than C++' s = 'This is BETTER than C++' x = 1 s = 'This Is BETTER than C++' x = 0 s = 'This Is BETTER than C++' x = 1 s = 'This Is BETTER than C++' x = 0 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++' x = 1 s = 'This Is Better Than C++' x = 0 s = 'This Is Better Than C++' s = 'This Is Better Than C++' s = 'This Is Better Than C++' x = 1 s = 'This Is Better Than C++' x = 0 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))

x = 1 s = 'HEy, tHis iS vErY wroNg!' x = 0 s = 'Hey, tHis iS vErY wroNg!' s = 'Hey, tHis iS vErY wroNg!' s = 'Hey, tHis iS vErY wroNg!' x = 1 s = 'Hey, THis iS vErY wroNg!' x = 0 s = 'Hey, This iS vErY wroNg!' s = 'Hey, This iS vErY wroNg!' s = 'Hey, This iS vErY wroNg!' x = 1 s = 'Hey, This IS vErY wroNg!' x = 0 s = 'Hey, This Is vErY wroNg!' x = 1 s = 'Hey, This Is VErY wroNg!' x = 0 s = 'Hey, This Is VerY wroNg!' s = 'Hey, This Is VerY wroNg!' s = 'Hey, This Is Very wroNg!' x = 1 s = 'Hey, This Is Very WroNg!' x = 0 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))

x = 1 s = 'THIS sENTENCE wILL bE iNVERTED' x = 0 s = 'ThIS sENTENCE wILL bE iNVERTED' s = 'ThiS sENTENCE wILL bE iNVERTED' s = 'This sENTENCE wILL bE iNVERTED' x = 1 s = 'This SENTENCE wILL bE iNVERTED' x = 0 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' s = 'This SentencE wILL bE iNVERTED' s = 'This Sentence wILL bE iNVERTED' x = 1 s = 'This Sentence WILL bE iNVERTED' x = 0 s = 'This Sentence WiLL bE iNVERTED' s = 'This Sentence WilL bE iNVERTED' s = 'This Sentence Will bE iNVERTED' x = 1 s = 'This Sentence Will BE iNVERTED' x = 0 s = 'This Sentence Will Be iNVERTED' x = 1 s = 'This Sentence Will Be INVERTED' x = 0 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' 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))

x = 1 s = 'This Sentence Will Not Be Changed' x = 0 s = 'This Sentence Will Not Be Changed' s = 'This Sentence Will Not Be Changed' s = 'This Sentence Will Not Be Changed' x = 1 s = 'This Sentence Will Not Be Changed' x = 0 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' s = 'This Sentence Will Not Be Changed' x = 1 s = 'This Sentence Will Not Be Changed' x = 0 s = 'This Sentence Will Not Be Changed' s = 'This Sentence Will Not Be Changed' s = 'This Sentence Will Not Be Changed' x = 1 s = 'This Sentence Will Not Be Changed' x = 0 s = 'This Sentence Will Not Be Changed' s = 'This Sentence Will Not Be Changed' x = 1 s = 'This Sentence Will Not Be Changed' x = 0 s = 'This Sentence Will Not Be Changed' x = 1 s = 'This Sentence Will Not Be Changed' x = 0 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))

x = 1 s = 'HELLO THERE' x = 0 s = 'HeLLO THERE' s = 'HelLO THERE' s = 'HellO THERE' s = 'Hello THERE' x = 1 s = 'Hello THERE' x = 0 s = 'Hello ThERE' s = 'Hello TheRE' s = 'Hello TherE' s = 'Hello There' corrected = 'Hello There'

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

x = 1 s = 'AlTeRnAtInG cApS' x = 0 s = 'AlTeRnAtInG cApS' s = 'AlteRnAtInG cApS' s = 'AlteRnAtInG cApS' s = 'AlternAtInG cApS' s = 'AlternAtInG cApS' s = 'AlternatInG cApS' s = 'AlternatInG cApS' s = 'AlternatinG cApS' s = 'AlternatinG cApS' s = 'Alternating cApS' x = 1 s = 'Alternating CApS' x = 0 s = 'Alternating CapS' s = 'Alternating CapS' s = 'Alternating Caps' corrected = '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!