Cody

Solution 846822

Submitted on 8 Mar 2016 by Jan Orwat
  • Size: 127
  • 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
str = [1 1 0 0 0 0 0 0 1 1 1 1 1 0 0 1]; bx = beadBox(str); % Is bx the right size? assert(isequal(size(bx),sqrt(length(str))*[1 1])) % Does it use all the numbers? assert(isequal(unique(bx),find(bx))) % Is it snaky? [I,J]=arrayfun(@(f) find(bx==f),1:numel(bx)); assert(all(abs(diff(complex(I,J)))==1)) % Are all the 1's on the bottom? beads = str(bx); assert(all(find(beads')>nnz(beads)))

2   Pass
str = [1 1 0 0]; bx = beadBox(str); % Is bx the right size? assert(isequal(size(bx),sqrt(length(str))*[1 1])) % Does it use all the numbers? assert(isequal(unique(bx),find(bx))) % Is it snaky? [I,J]=arrayfun(@(f) find(bx==f),1:numel(bx)); assert(all(abs(diff(complex(I,J)))==1)) % Are all the 1's on the bottom? beads = str(bx); assert(all(find(beads')>nnz(beads)))

3   Pass
str = [0 1 1 0 0 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0]; bx = beadBox(str); % Is bx the right size? assert(isequal(size(bx),sqrt(length(str))*[1 1])) % Does it use all the numbers? assert(isequal(unique(bx),find(bx))) % Is it snaky? [I,J]=arrayfun(@(f) find(bx==f),1:numel(bx)); assert(all(abs(diff(complex(I,J)))==1)) % Are all the 1's on the bottom? beads = str(bx); assert(all(find(beads')>nnz(beads)))

Suggested Problems

More from this Author63