Cody

# Problem 42461. This is a palindrome and so am I

Solution 2181843

Submitted on 30 Mar 2020
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))

s = 'amanaplanacanalpanama' s1 = 'amanaplanacanalpanama' y = logical 1

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

s = 'tacocat' s1 = 'tacocat' y = logical 1

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

s = 'amanaplancanalpanama' s1 = 'amanaplanacnalpanama' y = logical 0

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

s = '7m6I:pdUWV2n9eHjNB>1U1il`OKpwh93q_^K=Y?iDA\^P28;6v7Yr1PhLOD;K@PEFy`;Mf9VyX>r?T<l<pd17km5LCZbwvU_na5TFruj`@I`ZTRuGRbc[XVin_FL1O\B7lAhIG?oLGWOCt6bxT6PgVP;3io>MiXiZ\uAQdg5^CW6EaAUkbU?8Zs77Se2EVngFWvUplBB' s1 = 'BBlpUvWFgnVE2eS77sZ8?UbkUAaE6WC^5gdQAu\ZiXiM>oi3;PVgP6Txb6tCOWGLo?GIhAl7B\O1LF_niVX[cbRGuRTZ`I@`jurFT5an_UvwbZCL5mk71dp<l<T?r>XyV9fM;`yFEP@K;DOLhP1rY7v6;82P^\ADi?Y=K^_q39hwpKO`li1U1>BNjHe9n2VWUdp:I6m7' y = logical 0

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

s = '7dY7u=u9KeZI5J^[]?>I]jdoP^XYo`zR^sfL>ilpy3WMTtMWOrVZ5T_9N6:vxDglZ;_pu82lFkWf1cVEZLZl538Bz_rEBI^OK;hrfIk[rijY]USrC7pt<_CJ=s?e\ts=]c7n;jqlN_qDic3fk`sy_3EDHk3YAzxSkQpOLJ5T;=eHE7A\qG]f6ONO^6^`Hn;1D53GQ@R33R@QG35D1;nH`^6^ONO6f]Gq\A7EHe=;T5JLOpQkSxzAY3kHDE3_ys`kf3ciDq_Nlqj;n7c]=st\e?s=JC_<tp7CrSU]Yjir[kIfrh;KO^IBEr_zB835lZLZEVc1fWkFl28up_;ZlgDxv:6N9_T5ZVrOWMtTMW3ypli>Lfs^Rz`oYX^Podj]I>?][^J5IZeK9u=u7Yd7' s1 = '7dY7u=u9KeZI5J^[]?>I]jdoP^XYo`zR^sfL>ilpy3WMTtMWOrVZ5T_9N6:vxDglZ;_pu82lFkWf1cVEZLZl538Bz_rEBI^OK;hrfIk[rijY]USrC7pt<_CJ=s?e\ts=]c7n;jqlN_qDic3fk`sy_3EDHk3YAzxSkQpOLJ5T;=eHE7A\qG]f6ONO^6^`Hn;1D53GQ@R33R@QG35D1;nH`^6^ONO6f]Gq\A7EHe=;T5JLOpQkSxzAY3kHDE3_ys`kf3ciDq_Nlqj;n7c]=st\e?s=JC_<tp7CrSU]Yjir[kIfrh;KO^IBEr_zB835lZLZEVc1fWkFl28up_;ZlgDxv:6N9_T5ZVrOWMtTMW3ypli>Lfs^Rz`oYX^Podj]I>?][^J5IZeK9u=u7Yd7' y = logical 1

6   Fail
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) % )s(lap_si = y noitcnuf s(s==' ')=[] s1=flip(s) y=isequal(s,s1) ' s = 'functiony=is_pal(s) %)s(lap_si=ynoitcnuf s(s=='')=[] s1=flip(s) y=isequal(s,s1) ' s1 = ' )1s,s(lauqesi=y )s(pilf=1s ][=)''==s(s functiony=is_pal(s)% )s(lap_si=ynoitcnuf' y = logical 0

Assertion failed.