Cody

Problem 75. Find the palindrome

Solution 2614795

Submitted on 26 Jun 2020 by 春樹 内糸
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
a = 'xkayakyy'; p = 'kayak'; assert(isequal(p,pal(a)));

b = 0×0 empty char array n = 8 left = 0 right = 2 left = 1 right = 3 left = 2 right = 4 left = 3 right = 5 sub = 'aya' b = 'aya' left = 2 right = 6 sub = 'kayak' b = 'kayak' left = 1 right = 7 left = 4 right = 6 left = 5 right = 7 left = 6 right = 8 left = 7 right = 9

2   Pass
a = '3.141592653589793238462643383279502884197169399375105820974944592307816406286'; p = '46264'; assert(isequal(p,pal(a)));

b = 0×0 empty char array n = 77 left = 0 right = 2 left = 1 right = 3 left = 2 right = 4 left = 3 right = 5 sub = '141' b = '141' left = 2 right = 6 left = 4 right = 6 left = 5 right = 7 left = 6 right = 8 left = 7 right = 9 left = 8 right = 10 left = 9 right = 11 left = 10 right = 12 sub = '535' left = 9 right = 13 left = 11 right = 13 left = 12 right = 14 left = 13 right = 15 left = 14 right = 16 sub = '979' left = 13 right = 17 left = 15 right = 17 left = 16 right = 18 left = 17 right = 19 sub = '323' left = 16 right = 20 left = 18 right = 20 left = 19 right = 21 left = 20 right = 22 left = 21 right = 23 left = 22 right = 24 sub = '626' left = 21 right = 25 sub = '46264' b = '46264' left = 20 right = 26 left = 23 right = 25 left = 24 right = 26 left = 25 right = 27 left = 26 right = 28 left = 27 right = 29 sub = '383' left = 26 right = 30 left = 28 right = 30 left = 29 right = 31 left = 30 right = 32 left = 31 right = 33 left = 32 right = 34 left = 33 right = 35 left = 34 right = 36 left = 35 right = 37 left = 36 right = 38 left = 37 right = 39 left = 38 right = 40 left = 39 right = 41 left = 40 right = 42 left = 41 right = 43 left = 42 right = 44 left = 43 right = 45 left = 44 right = 46 sub = '939' left = 43 right = 47 left = 45 right = 47 left = 46 right = 48 left = 47 right = 49 left = 48 right = 50 left = 49 right = 51 left = 50 right = 52 left = 51 right = 53 left = 52 right = 54 left = 53 right = 55 left = 54 right = 56 left = 55 right = 57 left = 56 right = 58 left = 57 right = 59 left = 58 right = 60 left = 59 right = 61 sub = '494' left = 58 right = 62 left = 60 right = 62 left = 61 right = 63 left = 62 right = 64 left = 63 right = 65 left = 64 right = 66 left = 65 right = 67 left = 66 right = 68 left = 67 right = 69 left = 68 right = 70 left = 69 right = 71 left = 70 right = 72 left = 71 right = 73 left = 72 right = 74 left = 73 right = 75 left = 74 right = 76 left = 75 right = 77 left = 76 right = 78

3   Pass
a = 'truly I say: able was I ere I saw elba, but that is another story'; p = 'able was I ere I saw elba'; assert(isequal(p,pal(a)));

b = 0×0 empty char array n = 65 left = 0 right = 2 left = 1 right = 3 left = 2 right = 4 left = 3 right = 5 left = 4 right = 6 left = 5 right = 7 left = 6 right = 8 sub = ' I ' b = ' I ' left = 5 right = 9 left = 7 right = 9 left = 8 right = 10 left = 9 right = 11 left = 10 right = 12 left = 11 right = 13 left = 12 right = 14 left = 13 right = 15 left = 14 right = 16 left = 15 right = 17 left = 16 right = 18 left = 17 right = 19 left = 18 right = 20 left = 19 right = 21 left = 20 right = 22 left = 21 right = 23 left = 22 right = 24 sub = ' I ' left = 21 right = 25 left = 23 right = 25 left = 24 right = 26 left = 25 right = 27 sub = 'ere' left = 24 right = 28 sub = ' ere ' b = ' ere ' left = 23 right = 29 sub = 'I ere I' b = 'I ere I' left = 22 right = 30 sub = ' I ere I ' b = ' I ere I ' left = 21 right = 31 sub = 's I ere I s' b = 's I ere I s' left = 20 right = 32 sub = 'as I ere I sa' b = 'as I ere I sa' left = 19 right = 33 sub = 'was I ere I saw' b = 'was I ere I saw' left = 18 right = 34 sub = ' was I ere I saw ' b = ' was I ere I saw ' left = 17 right = 35 sub = 'e was I ere I saw e' b = 'e was I ere I saw e' left = 16 right = 36 sub = 'le was I ere I saw el' b = 'le was I ere I saw el' left = 15 right = 37 sub = 'ble was I ere I saw elb' b = 'ble was I ere I saw elb' left = 14 right = 38 sub = 'able was I ere I saw elba' b = 'able was I ere I saw elba' left = 13 right = 39 left = 26 right = 28 left = 27 right = 29 left = 28 right = 30 sub = ' I ' left = 27 right = 31 left = 29 right = 31 left = 30 right = 32 left = 31 right = 33 left = 32 right = 34 left = 33 right = 35 left = 34 right = 36 left = 35 right = 37 left = 36 right = 38 left = 37 right = 39 left = 38 right = 40 left = 39 right = 41 left = 40 right = 42 left = 41 right = 43 left = 42 right = 44 left = 43 right = 45 sub = 't t' left = 42 right = 46 left = 44 right = 46 left = 45 right = 47 left = 46 right = 48 left = 47 right = 49 left = 48 right = 50 left = 49 right = 51 left = 50 right = 52 left = 51 right = 53 left = 52 right = 54 left = 53 right = 55 left = 54 right = 56 left = 55 right = 57 left = 56 right = 58 left = 57 right = 59 left = 58 right = 60 left = 59 right = 61 left = 60 right = 62 left = 61 right = 63 left = 62 right = 64 left = 63 right = 65 left = 64 right = 66

Suggested Problems

More from this Author95

Community Treasure Hunt

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

Start Hunting!