Cody

Solution 1883369

Submitted on 24 Jul 2019
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)))

bx = 1 9 3 13 2 10 4 14 7 11 5 15 8 12 6 16

Assertion failed.

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

bx = 1 9 3 13 2 10 4 14 7 11 5 15 8 12 6 16

Assertion failed.

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

bx = 1 9 3 13 2 10 4 14 7 11 5 15 8 12 6 16

Assertion failed.