Cody

# Problem 2055. Create numeric palindromes and their square roots

Solution 452380

Submitted on 8 Jun 2014 by Jan Orwat
• Size: 32
• This is the leading solution.
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))

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

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

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

### Community Treasure Hunt

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

Start Hunting!