Cody

# Problem 2055. Create numeric palindromes and their square roots

Solution 370613

Submitted on 16 Dec 2013 by Adam Wyatt
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
%% n=3; [p,r]=palinroot(n); y_correct=[1 0 0 0 0; 1 2 1 0 0; 1 2 3 2 1]; z_correct=[1 0 0; 1 1 0; 1 1 1]; assert(isequal(p,y_correct)) assert(isequal(r,z_correct))

r = 1 0 0 1 1 0 1 1 1

2   Pass
%% n=9; [p,r]=palinroot(n); rr=1; for s1=2:n rr(s1)=rr(s1-1)*10+1; end rr=num2str(rr','%.0f'); z_correct=tril(fliplr(rr)-'0'); pp=zeros(n,n*2-1); for s=1:n p1=1:s; p2=fliplr(p1); st=deal([p1,p2(2:end)]); pp(s,1:numel(st))=st; end y_correct=pp; assert(isequal(p,y_correct)) assert(isequal(r,z_correct))

r = 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1

3   Pass
%% n=5; [p,r]=palinroot(n); rr=1; for s1=2:n rr(s1)=rr(s1-1)*10+1; end rr=num2str(rr','%.0f'); z_correct=tril(fliplr(rr)-'0'); pp=zeros(n,n*2-1); for s=1:n p1=1:s; p2=fliplr(p1); st=deal([p1,p2(2:end)]); pp(s,1:numel(st))=st; end y_correct=pp; assert(isequal(p,y_correct)) assert(isequal(r,z_correct))

r = 1 0 0 0 0 1 1 0 0 0 1 1 1 0 0 1 1 1 1 0 1 1 1 1 1

4   Pass
%% n=7; [p,r]=palinroot(n); rr=1; for s1=2:n rr(s1)=rr(s1-1)*10+1; end rr=num2str(rr','%.0f'); z_correct=tril(fliplr(rr)-'0'); pp=zeros(n,n*2-1); for s=1:n p1=1:s; p2=fliplr(p1); st=deal([p1,p2(2:end)]); pp(s,1:numel(st))=st; end y_correct=pp; assert(isequal(p,y_correct)) assert(isequal(r,z_correct))

r = 1 0 0 0 0 0 0 1 1 0 0 0 0 0 1 1 1 0 0 0 0 1 1 1 1 0 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 0 1 1 1 1 1 1 1