Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
block=[0 0 0 0;0 1 1 0;0 1 1 0;0 0 0 0];
Zoo=repmat(block,3,1);
ZooPre=Zoo_prior(Zoo);
mc=conv2(single(ZooPre),[1 1 1;1 0 1;1 1 1],'same');
ZooChk=~(mc<2 | mc>3) & ((ZooPre & mc==2) | (ZooPre & mc==3) | (~ZooPre & mc==3));
assert(all(all(ZooChk==Zoo)))
% figure(1);imagesc(ZooPre)
% figure(2);imagesc(Zoo)
|
2 | Pass |
caterer1=[0 0 0 0 0 0 0 0 0 0;0 0 0 1 0 0 0 0 0 0;0 1 0 0 0 1 1 1 1 0;0 1 0 0 0 1 0 0 0 0;0 1 0 0 0 0 0 0 0 0;0 0 0 0 1 0 0 0 0 0;0 0 1 1 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0];
caterer2=[0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 1 1 0 0;
0 0 1 0 1 1 1 1 0 0;
1 1 1 0 0 1 0 1 0 0;
0 0 0 0 0 0 0 0 0 0;
0 0 1 1 0 0 0 0 0 0;
0 0 0 1 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0];
caterer3=[0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 1 0 0;
0 0 1 1 1 0 0 0 1 0;
0 1 1 1 1 1 0 1 0 0;
0 0 0 1 0 0 0 0 0 0;
0 0 1 1 0 0 0 0 0 0;
0 0 1 1 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0];
Zoo=[caterer1 zeros(8,1) caterer2 zeros(8,1) caterer3] ;
ZooPre=Zoo_prior(Zoo);
mc=conv2(single(ZooPre),[1 1 1;1 0 1;1 1 1],'same');
ZooChk=~(mc<2 | mc>3) & ((ZooPre & mc==2) | (ZooPre & mc==3) | (~ZooPre & mc==3));
assert(all(all(ZooChk==Zoo)))
% figure(1);imagesc(ZooPre)
% figure(2);imagesc(Zoo)
|
3 | Pass |
caterer1=[0 0 0 0 0 0 0 0 0 0;0 0 0 1 0 0 0 0 0 0;0 1 0 0 0 1 1 1 1 0;0 1 0 0 0 1 0 0 0 0;0 1 0 0 0 0 0 0 0 0;0 0 0 0 1 0 0 0 0 0;0 0 1 1 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0]; % 8x10
Loaf=[0 0 0 0 0 0;0 0 1 1 0 0;0 1 0 0 1 0;0 0 1 0 1 0;0 0 0 1 0 0;0 0 0 0 0 0]; % 6x6
blinker=[0 0 0 0 0;0 0 0 0 0;0 1 1 1 0;0 0 0 0 0;0 0 0 0 0]; % 5x5
Zoo=[[Loaf;Loaf'] zeros(12,1) [caterer1;zeros(4,10)] [blinker;blinker';zeros(2,5)] ] ;
ZooPre=Zoo_prior(Zoo);
mc=conv2(single(ZooPre),[1 1 1;1 0 1;1 1 1],'same');
ZooChk=~(mc<2 | mc>3) & ((ZooPre & mc==2) | (ZooPre & mc==3) | (~ZooPre & mc==3));
assert(all(all(ZooChk==Zoo)))
% figure(1);imagesc(ZooPre)
% figure(2);imagesc(Zoo)
|
Sum all integers from 1 to 2^n
8412 Solvers
Given a 4x4 matrix, swap the two middle columns
515 Solvers
Make a vector of prime numbers
194 Solvers
420 Solvers
Is this triangle right-angled?
2874 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!