Cody

Solution 173644

Submitted on 6 Dec 2012 by @bmtran
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
%% 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;
2   Pass
%% 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;
3   Pass
%% 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)));
4   Pass
%% 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)));
5   Pass
%% 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;