Cody

# Problem 42708. Placing Beads Neatly in a Box

Solution 1549339

Submitted on 5 Jun 2018
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
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)))

Error in solution Line: 27 Column: 1 Illegal use of reserved keyword "end".

2   Fail
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)))

Error in solution Line: 27 Column: 1 Illegal use of reserved keyword "end".

3   Fail
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)))

Error in solution Line: 27 Column: 1 Illegal use of reserved keyword "end".