Cody

Solution 87130

Submitted on 9 May 2012
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   Fail
%% h = [1 1 0 0; 0 0 1 0; 0 0 0 1]; v = [0 0 1 0 1; 1 0 0 1 1]; lh_correct = [1 1 0 0; 0 0 1 0; 0 0 0 1]; lv_correct = [0 0 1 0 1; 2 0 0 1 1]; [lh,lv] = bordercon(h,v); assert(all(size(lh)==size(lh_correct))); assert(all(size(lv)==size(lv_correct))); l = [lh(:);lv(:)]; l_correct = [lh_correct(:);lv_correct(:)]; [ul,ui,uj] = unique(l); assert(all(ul(ul~=0)'==1:max(ul))); for i = ui' assert(all(l_correct(l==l(i))==l_correct(i))); assert(all(l_correct(l~=l(i))~=l_correct(i))); end;
Error: Assertion failed.
2   Fail
%% h = [0 0 1 0]; v = [0 1 0; 0 0 1]; lh_correct = h; lv_correct = v; [lh,lv] = bordercon(h,v); assert(all(size(lh)==size(lh_correct))); assert(all(size(lv)==size(lv_correct))); l = [lh(:);lv(:)]; l_correct = [lh_correct(:);lv_correct(:)]; [ul,ui,uj] = unique(l); assert(all(ul(ul~=0)'==1:max(ul))); for i = ui' assert(all(l_correct(l==l(i))==l_correct(i))); assert(all(l_correct(l~=l(i))~=l_correct(i))); end;
Error: Attempted to access v(:,4); index out of bounds because size(v)=[2,3].
3   Fail
%% h = zeros(4,5); v = zeros(5,4); lh_correct = h; lv_correct = v; [lh,lv] = bordercon(h,v); assert(all(all(lh==lh_correct))); assert(all(all(lv==lv_correct)));
Error: Attempted to access v(:,5); index out of bounds because size(v)=[5,4].
4   Fail
%% h = ones(6,5); v = ones(5,6); lh_correct = h; lv_correct = v; [lh,lv] = bordercon(h,v); assert(all(all(lh==lh_correct))); assert(all(all(lv==lv_correct)));
Error: Matrix dimensions must agree.
5   Fail
%% h = [1 0 0 1; 0 0 0 0; 0 0 1 1; 0 0 0 0; 1 0 0 1]; v = [1 0 0 0 1; 0 1 0 0 0; 0 1 0 0 0; 1 0 0 0 1]; lh_correct = [1 0 0 5; 0 0 0 0; 0 0 4 4; 0 0 0 0; 2 0 0 6]; lv_correct = [1 0 0 0 5; 0 3 0 0 0; 0 3 0 0 0; 2 0 0 0 6]; [lh,lv] = bordercon(h,v); assert(all(size(lh)==size(lh_correct))); assert(all(size(lv)==size(lv_correct))); l = [lh(:);lv(:)]; l_correct = [lh_correct(:);lv_correct(:)]; [ul,ui,uj] = unique(l); assert(all(ul(ul~=0)'==1:max(ul))); for i = ui' assert(all(l_correct(l==l(i))==l_correct(i))); assert(all(l_correct(l~=l(i))~=l_correct(i))); end;
Error: Assertion failed.