Cody

Problem 42461. This is a palindrome and so am I

Solution 2810062

Submitted on 8 Aug 2020 by ChrisR
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 = 'a man a plan a canal panama'; assert(isequal(is_pal(s),true))

2   Pass
s = 'taco cat'; assert(isequal(is_pal(s),true))

3   Pass
s = 'a man a plan canal panama'; assert(isequal(is_pal(s),false))

4   Pass
s = char(randi(74,1,200)+'0'); assert(isequal(is_pal(s),false)); % most probably

5   Pass
s = char(randi(74,1,200)+'0'); s = [s fliplr(s)]; assert(isequal(is_pal(s),true));

6   Pass
s = fileread('is_pal.m'); s = regexprep(s,'%This code written by profile_id.*','') assert(isequal(is_pal(s),true));

s = 'function y = is_pal(s),s1 = regexprep(s,'\W',''); n = floor(length(s1)/2); y = strcmp(s1(1:n),s1(end:-1:end-n+1));%;))1+n-dne:1-:dne(1s,)n:1(1s(pmcrts = y ;)2/)1s(htgnel(roolf = n ;)'','W\',s(perpxeger = 1s,)s(lap_si = y noitcnuf '