This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.
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)))
|
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!