Cody

# Problem 75. Find the palindrome

Solution 455604

Submitted on 16 Jun 2014 by goc3
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)));

==== str_f = x ans = 1 ==== str_f = kx ans = [] ==== str_f = akx ans = [] ==== str_f = yakx ans = [] ==== str_f = ayakx ans = [] ==== str_f = kayakx ans = [] ==== str_f = ykayakx ans = [] ==== str_f = yykayakx ans = [] ==== str_f = k ans = 2 6 ==== str_f = ak ans = 5 ==== str_f = yak ans = 4 ==== str_f = ayak ans = 3 ==== str_f = kayak ans = 2 ==== str_f = ykayak ans = [] ==== str_f = yykayak ans = [] ==== str_f = a ans = 3 5 ==== str_f = ya ans = 4 ==== str_f = aya ans = 3 ==== str_f = kaya ans = 2 ==== str_f = ykaya ans = [] ==== str_f = yykaya ans = [] ==== str_f = y ans = 4 7 8 ==== str_f = ay ans = 3 ==== str_f = kay ans = 2 ==== str_f = ykay ans = [] ==== str_f = yykay ans = [] ==== str_f = a ans = 3 5 ==== str_f = ka ans = 2 ==== str_f = yka ans = [] ==== str_f = yyka ans = [] ==== str_f = k ans = 2 6 ==== str_f = yk ans = [] ==== str_f = yyk ans = [] ==== str_f = y ans = 4 7 8 ==== str_f = yy ans = 7 ==== str_f = y ans = 4 7 8

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

==== str_f = 3 ans = 1 11 17 19 26 27 29 45 48 66 ==== str_f = .3 ans = 10 16 18 25 28 44 47 65 ==== str_f = 1.3 ans = [] ==== str_f = 41.3 ans = [] ==== str_f = 141.3 ans = [] ==== str_f = 5141.3 ans = [] ==== str_f = 95141.3 ans = [] ==== str_f = 295141.3 ans = [] ==== str_f = 6295141.3 ans = [] ==== str_f = 56295141.3 ans = [] ==== str_f = 356295141.3 ans = [] ==== str_f = 5356295141.3 ans = [] ==== str_f = 85356295141.3 ans = [] ==== str_f = 985356295141.3 ans = [] ==== str_f = 7985356295141.3 ans = [] ==== str_f = 97985356295141.3 ans = [] ==== str_f = 397985356295141.3 ans = [] ==== str_f = 2397985356295141.3 ans = [] ==== str_f = 32397985356295141.3 ans = [] ==== str_f = 832397985356295141.3 ans = [] ==== str_f = 4832397985356295141.3 ans = [] ==== str_f = 64832397985356295141.3 ans = [] ==== str_f = 264832397985356295141.3 ans = [] ==== str_f = 6264832397985356295141.3 ans = [] ==== str_f = 46264832397985356295141.3 ans = [] ==== str_f = 346264832397985356295141.3 ans = [] ==== str_f = 3346264832397985356295141.3 ans = [] ==== str_f = 83346264832397985356295141.3 ans = [] ==== str_f = 383346264832397985356295141.3 ans = [] ==== str_f = 2383346264832397985356295141.3 ans = [] ==== str_f = 72383346264832397985356295141.3 ans = [] ==== str_f = 972383346264832397985356295141.3 ans = [] ==== str_f = 5972383346264832397985356295141.3 ans = [] ==== str_f = 05972383346264832397985356295141.3 ans = [] ==== str_f = 205972383346264832397985356295141.3 ans = [] ==== str_f = 8205972383346264832397985356295141.3 ans = [] ==== str_f = 88205972383346264832397985356295141.3 ans = [] ==== str_f = 488205972383346264832397985356295141.3 ans = [] ==== str_f = 1488205972383346264832397985356295141.3 ans = [] ==== str_f = 91488205972383346264832397985356295141.3 ans = [] ==== str_f = 791488205972383346264832397985356295141.3 ans = [] ==== str_f = 1791488205972383346264832397985356295141.3 ans = [] ==== str_f = 61791488205972383346264832397985356295141.3 ans = [] ==== str_f = 961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 3961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 93961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 3993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 73993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 1573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 01573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 501573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 8501573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 28501573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 028501573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 9028501573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 79028501573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 479028501573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 9479028501573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 49479028501573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 449479028501573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 5449479028501573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 95449479028501573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 295449479028501573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 3295449479028501573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 03295449479028501573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 703295449479028501573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 8703295449479028501573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 18703295449479028501573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 618703295449479028501573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 4618703295449479028501573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 04618703295449479028501573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 604618703295449479028501573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 2604618703295449479028501573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 82604618703295449479028501573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = 682604618703295449479028501573993961791488205972383346264832397985356295141.3 ans = [] ==== str_f = . ans = Columns 1 through 16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Columns 17 through 32 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Columns 33 through 48 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 Columns 49 through 64 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 Columns 65 through 77 65 66 67 68 69 70 71 72 73 74 75 76 77 ==== str_f = 1. ans = 3 5 39 42 51 70 ==== str_f = 41. ans = 4 38 ==== str_f = 141. ans = 3 ==== str_f = 5141. ans = [] ==== str_f = 95141. ans = [] ==== str_f = 295141. ans = [] ==== str_f = 6295141. ans = [] ==== str_f = 56295141. ans = [] ==== str_f = 356295141. ans = [] ==== str_f = 5356295141. ans = [] ==== str_f = 85356295141. ans = [] ==== str_f = 985356295141. ans = [] ==== str_f = 7985356295141. ans = [] ==== str_f = 97985356295141. ans = [] ==== str_f = 397985356295141. ans = [] ==== str_f = 2397985356295141. ans = [] ==== str_f = 32397985356295141. ans = [] ==== str_f = 832397985356295141. ans = [] ==== str_f = 4832397985356295141. ans = [] ==== str_f = 64832397985356295141. ans = [] ==== str_f = 264832397985356295141. ans = [] ==== str_f = 6264832397985356295141. ans = [] ==== str_f = 46264832397985356295141. ans = [] ==== str_f = 346264832397985356295141. ans = [] ==== str_f = 3346264832397985356295141. ans = [] ==== str_f = 83346264832397985356295141. ans = [] ==== str_f = 383346264832397985356295141. ans = [] ==== str_f = 2383346264832397985356295141. ans = [] ==== str_f = 72383346264832397985356295141. ans = [] ==== str_f = 972383346264832397985356295141. ans = [] ==== str_f = 5972383346264832397985356295141. ans = [] ==== str_f = 05972383346264832397985356295141. ans = [] ==== str_f = 205972383346264832397985356295141. ans = [] ==== str_f = 8205972383346264832397985356295141. ans = [] ==== str_f = 88205972383346264832397985356295141. ans = [] ==== str_f = 488205972383346264832397985356295141. ans = [] ==== str_f = 1488205972383346264832397985356295141. ans = [] ==== str_f = 91488205972383346264832397985356295141. ans = [] ==== str_f = 791488205972383346264832397985356295141. ans = [] ==== str_f = 1791488205972383346264832397985356295141. ans = [] ==== str_f = 61791488205972383346264832397985356295141. ans = [] ==== str_f = 961791488205972383346264832397985356295141. ans = [] ==== str_f = 3961791488205972383346264832397985356295141. ans = [] ==== str_f = 93961791488205972383346264832397985356295141. ans = [] ==== str_f = 993961791488205972383346264832397985356295141. ans = [] ==== str_f = 3993961791488205972383346264832397985356295141. ans = [] ==== str_f = 73993961791488205972383346264832397985356295141. ans = [] ==== str_f = 573993961791488205972383346264832397985356295141. ans = [] ==== str_f = 1573993961791488205972383346264832397985356295141. ans = [] ==== str_f = 01573993961791488205972383346264832397985356295141. ans = [] ==== str_f = 501573993961791488205972383346264832397985356295141. ans = [] ==== str_f = 8501573993961791488205972383346264832397985356295141. ans = [] ==== str_f = 28501573993961791488205972383346264832397985356295141. ans = [] ==== str_f = 028501573993961791488205972383346264832397985356295141. ans = [] ==== str_f = 9028501573993961791488205972383346264832397985356295141. ans = [] ==== str_f = 79028501573993961791488205972383346264832397985356295141. ans = [] ==== str_f = 479028501573993961791488205972383346264832397985356295141. ans = [] ==== str_f = 9479028501573993961791488205972383346264832397985356295141. ans = [] ==== str_f = 49479028501573993961791488205972383346264832397985356295141. ans = [] ==== str_f = 449479028501573993961791488205972383346264832397985356295141. ans = [] ==== str_f = 5449479028501573993961791488205972383346264832397985356295141. ans = [] ==== str_f = 95449479028501573993961791488205972383346264832397985356295141. ans = [] ==== str_f = 295449479028501573993961791488205972383346264832397985356295141. ans = [] ==== str_f = 3295449479028501573993961791488205972383346264832397985356295141. ans = [] ==== str_f = 03295449479028501573993961791488205972383346264832397985356295141. ans = [] ==== str_f = 7032954494790285015739939617914882059723833462648323979853562951...

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)));

==== str_f = t ans = 1 43 45 48 56 62 ==== str_f = rt ans = [] ==== str_f = urt ans = [] ==== str_f = lurt ans = [] ==== str_f = ylurt ans = [] ==== str_f = ylurt ans = [] ==== str_f = I ylurt ans = [] ==== str_f = I ylurt ans = [] ==== str_f = s I ylurt ans = [] ==== str_f = as I ylurt ans = [] ==== str_f = yas I ylurt ans = [] ==== str_f = :yas I ylurt ans = [] ==== str_f = :yas I ylurt ans = [] ==== str_f = a :yas I ylurt ans = [] ==== str_f = ba :yas I ylurt ans = [] ==== str_f = lba :yas I ylurt ans = [] ==== str_f = elba :yas I ylurt ans = [] ==== str_f = elba :yas I ylurt ans = [] ==== str_f = w elba :yas I ylurt ans = [] ==== str_f = aw elba :yas I ylurt ans = [] ==== str_f = saw elba :yas I ylurt ans = [] ==== str_f = saw elba :yas I ylurt ans = [] ==== str_f = I saw elba :yas I ylurt ans = [] ==== str_f = I saw elba :yas I ylurt ans = [] ==== str_f = e I saw elba :yas I ylurt ans = [] ==== str_f = re I saw elba :yas I ylurt ans = [] ==== str_f = ere I saw elba :yas I ylurt ans = [] ==== str_f = ere I saw elba :yas I ylurt ans = [] ==== str_f = I ere I saw elba :yas I ylurt ans = [] ==== str_f = I ere I saw elba :yas I ylurt ans = [] ==== str_f = s I ere I saw elba :yas I ylurt ans = [] ==== str_f = as I ere I saw elba :yas I ylurt ans = [] ==== str_f = was I ere I saw elba :yas I ylurt ans = [] ==== str_f = was I ere I saw elba :yas I ylurt ans = [] ==== str_f = e was I ere I saw elba :yas I ylurt ans = [] ==== str_f = le was I ere I saw elba :yas I ylurt ans = [] ==== str_f = ble was I ere I saw elba :yas I ylurt ans = [] ==== str_f = able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = b ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = ub ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = tub ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = tub ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = t tub ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = ht tub ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = aht tub ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = taht tub ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = taht tub ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = i taht tub ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = si taht tub ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = si taht tub ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = a si taht tub ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = na si taht tub ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = ona si taht tub ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = tona si taht tub ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = htona si taht tub ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = ehtona si taht tub ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = rehtona si taht tub ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = rehtona si taht tub ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = s rehtona si taht tub ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = ts rehtona si taht tub ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = ots rehtona si taht tub ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = rots rehtona si taht tub ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = yrots rehtona si taht tub ,able was I ere I saw elba :yas I ylurt ans = [] ==== str_f = r ans = 2 26 59 64 ==== str_f = ur ans = [] ==== str_f = lur ans = [] ==== str_f = ylur ans = [] ==== str_f = ylur ans = [] ==== str_f = I ylur ans = [] ==== str_f = I ylur ans = [] ==== str_f = s I ylur ans = [] ==== str_f = as I ylur ans = [] ==== str_f = yas I ylur ans = [] ==== str_f = :yas I ylur ans = [] ==== str_f = :yas I ylur ans = [] ==== str_f = a :yas I ylur ans = [] ==== str_f = ba :yas I ylur ans = [] ==== str_f = lba :yas I ylur ans = [] ==== str_f = elba :yas I ylur ans = [] ==== str_f = elba :yas I ylur ans = [] ==== str_f = w elba :yas I ylur ans = [] ==== str_f = aw elba :yas I ylur ans = [] ==== str_f = saw elba :yas I ylur ans = [] ==== str_f = saw elba :yas I ylur ans = [] ==== str_f = I saw elba :yas I ylur ans = [] ==== str_f = I saw elba :yas I ylur ans = [] ==== str_f = e I saw elba :yas I ylur ans = [] ==== str_f = re I saw elba :yas I ylur ans = [] ==== str_f = ere I saw elba :yas I ylur ans = [] ==== str_f = ere I saw elba :yas I ylur ans = [] ==== str_f = I ere I saw elba :yas I ylur ans = [] ==== str_f = I ere I saw elba :yas I ylur ans = [] ==== str_f = s I ere I saw elba :yas I ylur ans = [] ==== str_f = as I ere I saw elba :yas I ylur ans = [] ==== str_f = was I ere I saw elba :yas I ylur ans = [] ==== str_f = was I ere I saw elba :yas I ylur ans = [] ==== str_f = e was I ere I saw elba :yas I ylur ans = [] ==== str_f = le was I ere I saw elba :yas I ylur ans = [] ==== str_f = ble was I ere I saw elba :yas I ylur ans = [] ==== str_f = able was I ere I saw elba :yas I ylur ans = [] ==== str_f = ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = b ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = ub ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = tub ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = tub ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = t tub ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = ht tub ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = aht tub ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = taht tub ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = taht tub ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = i taht tub ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = si taht tub ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = si taht tub ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = a si taht tub ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = na si taht tub ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = ona si taht tub ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = tona si taht tub ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = htona si taht tub ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = ehtona si taht tub ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = rehtona si taht tub ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = rehtona si taht tub ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = s rehtona si taht tub ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = ts rehtona si taht tub ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = ots rehtona si taht tub ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = rots rehtona si taht tub ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = yrots rehtona si taht tub ,able was I ere I saw elba :yas I ylur ans = [] ==== str_f = u ans = 3 42 ==== str_f = lu ans = [] ==== str_f = ylu ans = [] ==== str_f = ylu ans = [] ==== str_f = I ylu ans = [] ==== str_f = I ylu ans = [] ==== str_f = s I ylu ans = [] ==== str_f = as I ylu ans = [] ==== str_f = yas I ylu ans = [] ==== str_f = :yas I ylu ans = [] ==== str_f = :yas I ylu ans = [] ==== str_f = a :yas I ylu ans = [] ==== str_f = ba :yas I ylu ans = [] ==== str_f = lba :yas I ylu ans = [] ==== str_f = elba :yas I ylu ans = [] ==== str_f = elba :yas I ylu ans = [] ==== str_f = w elba :yas I ylu ans = [] ==== str_f = aw elba :yas I ylu ans = [] ==== str_f = saw elba :yas I ylu ans = [] ==== str_f = saw elba :yas I ylu ans = [] ==== str_f = I saw elba :yas I ylu ans = [] ==== str_f = I saw elba :yas I ylu ans = [] ==== str_f = e I saw elba :yas I ylu ans = [] ==== str_f = re I saw elba :yas I ylu ans = [] ==== str_f = ere I saw elba :yas I ylu ans = [] ==== str_f = ere I saw elba :yas I ylu ans = [] ==== str_f = I ere I saw elba :yas I ylu ans = [] ==== str_f = I ere I saw elba :yas I ylu ans = [] ==== str_f = s I ere I saw elba :yas I ylu ans = [] ==== str_f = as I ere I saw elba :yas I ylu ans = [] ==== str_f = was I ere I saw elba :yas I ylu ans = [] ==== str_f = was I ere I saw elba :yas I ylu ans = [] ==== str_f = e was I ere I saw elba :yas I ylu ans = [] ==== str_f = le was I ere I saw elba :yas I ylu ans = [] ==== str_f = ble was I ere I saw elba :yas I ylu ans = [] ==== str_f = able was I ere I saw elba :yas I ylu ans = [] ==== str_f = ,able was I ere I saw elba :yas I ylu ans = [] ==== str_f = ,able was I ere I saw elba :yas I ylu ans = [] ==== str_f = b ,able was I ere I saw elba :yas I ylu ans = [] ==== str_f = ub ,able was I ere I saw elba :yas I ylu ans = [] ==== str_f = tub ,able was I ere I saw elba :yas I ylu ans = [] ==== str_f = tub ,able was I ere I saw elba :yas I ylu ans = [] ==== str_f = t tub ,able was I er...

### Community Treasure Hunt

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

Start Hunting!