Cody

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

Solution 1995107

Submitted on 29 Oct 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
s='eye story pop dictionary noon enjoy software moon' assert(isequal(Palindromes(s),3))

s = 'eye story pop dictionary noon enjoy software moon' s = 'eye story pop dictionary noon enjoy software moon' l = 1×8 cell array {'eye'} {'story'} {'pop'} {'dictionary'} {'noon'} {'enjoy'} {'software'} {'moon'} amount = 0 amount = 1 amount = 2 amount = 3

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

s = 'keep running' s = 'keep running' l = 1×2 cell array {'keep'} {'running'} amount = 0

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

s = 'the two men stood face to face' s = 'the two men stood face to face' l = 1×7 cell array {'the'} {'two'} {'men'} {'stood'} {'face'} {'to'} {'face'} amount = 0

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

s = 'Did he do that?' s = 'did he do that?' l = 1×4 cell array {'did'} {'he'} {'do'} {'that'} amount = 0 amount = 1

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.' s = 'the civic duty of anna was to level the kayak attached to the racecar at noon, so said her mom.' l = 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'} amount = 0 amount = 1 amount = 2 amount = 3 amount = 4 amount = 5 amount = 6 amount = 7

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?' s = 'did she or did bob or did mom wow anna at noon?' l = 1×12 cell array {'did'} {'she'} {'or'} {'did'} {'bob'} {'or'} {'did'} {'mom'} {'wow'} {'anna'} {'at'} {'noon'} amount = 0 amount = 1 amount = 2 amount = 3 amount = 4 amount = 5 amount = 6 amount = 7 amount = 8

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

s = 'The rotor rotated on the level table.' s = 'the rotor rotated on the level table.' l = 1×7 cell array {'the'} {'rotor'} {'rotated'} {'on'} {'the'} {'level'} {'table'} amount = 0 amount = 1 amount = 2