Cody

# Problem 43635. Return the amount of palindromes (words) in the string.

Solution 2154903

Submitted on 9 Mar 2020 by Asif Newaz
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
s='eye story pop dictionary noon enjoy software moon' assert(isequal(Palindromes(s),3))

s = 'eye story pop dictionary noon enjoy software moon' c = 1×8 cell array {'eye'} {'story'} {'pop'} {'dictionary'} {'noon'} {'enjoy'} {'software'} {'moon'} d = 1×8 cell array {'eye'} {'yrots'} {'pop'} {'yranoitcid'} {'noon'} {'yojne'} {'erawtfos'} {'noom'}

2   Pass
s='keep running' assert(isequal(Palindromes(s),0))

s = 'keep running' c = 1×2 cell array {'keep'} {'running'} d = 1×2 cell array {'peek'} {'gninnur'}

3   Pass
s='the two men stood face to face' assert(isequal(Palindromes(s),0))

s = 'the two men stood face to face' c = 1×7 cell array {'the'} {'two'} {'men'} {'stood'} {'face'} {'to'} {'face'} d = 1×7 cell array {'eht'} {'owt'} {'nem'} {'doots'} {'ecaf'} {'ot'} {'ecaf'}

4   Pass
s='Did he do that?' assert(isequal(Palindromes(s),1))

s = 'Did he do that?' c = 1×4 cell array {'did'} {'he'} {'do'} {'that'} d = 1×4 cell array {'did'} {'eh'} {'od'} {'taht'}

5   Pass
s='The civic duty of Anna was to level the kayak attached to the racecar at noon, so said her mom.' assert(isequal(Palindromes(s),7))

s = 'The civic duty of Anna was to level the kayak attached to the racecar at noon, so said her mom.' c = 1×20 cell array Columns 1 through 15 {'the'} {'civic'} {'duty'} {'of'} {'anna'} {'was'} {'to'} {'level'} {'the'} {'kayak'} {'attached'} {'to'} {'the'} {'racecar'} {'at'} Columns 16 through 20 {'noon'} {'so'} {'said'} {'her'} {'mom'} d = 1×20 cell array Columns 1 through 15 {'eht'} {'civic'} {'ytud'} {'fo'} {'anna'} {'saw'} {'ot'} {'level'} {'eht'} {'kayak'} {'dehcatta'} {'ot'} {'eht'} {'racecar'} {'ta'} Columns 16 through 20 {'noon'} {'os'} {'dias'} {'reh'} {'mom'}

6   Pass
s='Did she or did bob or did mom wow Anna at noon?' assert(isequal(Palindromes(s),8))

s = 'Did she or did bob or did mom wow Anna at noon?' c = 1×12 cell array {'did'} {'she'} {'or'} {'did'} {'bob'} {'or'} {'did'} {'mom'} {'wow'} {'anna'} {'at'} {'noon'} d = 1×12 cell array {'did'} {'ehs'} {'ro'} {'did'} {'bob'} {'ro'} {'did'} {'mom'} {'wow'} {'anna'} {'ta'} {'noon'}

7   Pass
s='The rotor rotated on the level table.' assert(isequal(Palindromes(s),2))

s = 'The rotor rotated on the level table.' c = 1×7 cell array {'the'} {'rotor'} {'rotated'} {'on'} {'the'} {'level'} {'table'} d = 1×7 cell array {'eht'} {'rotor'} {'detator'} {'no'} {'eht'} {'level'} {'elbat'}