Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 276720

Submitted on 9 Jul 2013 by James

Correct

56Size
Leading solution size is 44.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
APk= [59 101 271 509 577 1291 1699 1877 2357 2999 3307
311 353 523 761 829 1543 1951 2129 2609 3251 3559
389 431 601 839 907 1621 2029 2207 2687 3329 3637
521 563 733 971 1039 1753 2161 2339 2819 3461 3769
599 641 811 1049 1117 1831 2239 2417 2897 3539 3847
911 953 1123 1361 1429 2143 2551 2729 3209 3851 4159
1109 1151 1321 1559 1627 2341 2749 2927 3407 4049 4357
1481 1523 1693 1931 1999 2713 3121 3299 3779 4421 4729
2099 2141 2311 2549 2617 3331 3739 3917 4397 5039 5347
2591 2633 2803 3041 3109 3823 4231 4409 4889 5531 5839
3371 3413 3583 3821 3889 4603 5011 5189 5669 6311 6619];
p = Pandiagonal_11(APk);
assert(all(unique(p(:))==unique(APk(:))))
rcs=sum([p p']);
assert(all(rcs==trace(APk)))
pd=p;
pad=p;
for i=2:11
 pd(i,:)=circshift(p(i,:),[0 -i+1]);
 pad(i,:)=circshift(p(i,:),[0 i-1]);
end
rd=sum([pd pad]);
assert(all(rd==trace(APk)))