Cody

Solution 1690258

Submitted on 11 Dec 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
BW = [0 0 0 0; 1 1 1 1; 0 1 1 0]; out_correct = [2 3 3 2]; assert(isequal(findlastindim(BW,1),out_correct)) out_correct = [0; 4; 3]; assert(isequal(findlastindim(BW,2),out_correct))

c = 2 c = 3 c = 3 c = 2 out = 2 3 3 2 c = 4 c = 3 out = 0 4 3

Assertion failed.

2   Fail
BW = eye(10); out_correct = 1:10; assert(isequal(findlastindim(BW,1),out_correct)) assert(isequal(findlastindim(BW,2),out_correct'))

c = 1 c = 2 c = 3 c = 4 c = 5 c = 6 c = 7 c = 8 c = 9 c = 10 out = 1 2 3 4 5 6 7 8 9 10 c = 1 c = 2 c = 3 c = 4 c = 5 c = 6 c = 7 c = 8 c = 9 c = 10 out = 1 2 3 4 5 6 7 8 9 10

Assertion failed.

3   Pass
BW = rand(10)>0.5; assert(isequal(findlastindim(BW,3),BW)) assert(isequal(findlastindim(BW,4),BW))

out = 10×10 logical array 0 1 1 0 0 1 1 1 1 0 0 1 1 1 0 0 1 0 1 0 1 0 1 0 1 1 0 1 1 1 1 0 0 1 1 0 1 1 0 1 1 0 0 0 1 0 1 1 0 1 0 0 1 0 0 1 1 1 1 0 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 1 0 0 0 1 0 0 0 0 1 0 0 1 1 1 1 1 0 0 1 out = 10×10 logical array 0 1 1 0 0 1 1 1 1 0 0 1 1 1 0 0 1 0 1 0 1 0 1 0 1 1 0 1 1 1 1 0 0 1 1 0 1 1 0 1 1 0 0 0 1 0 1 1 0 1 0 0 1 0 0 1 1 1 1 0 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 1 0 0 0 1 0 0 0 0 1 0 0 1 1 1 1 1 0 0 1 out = 10×10 logical array 0 1 1 0 0 1 1 1 1 0 0 1 1 1 0 0 1 0 1 0 1 0 1 0 1 1 0 1 1 1 1 0 0 1 1 0 1 1 0 1 1 0 0 0 1 0 1 1 0 1 0 0 1 0 0 1 1 1 1 0 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 1 0 0 0 1 0 0 0 0 1 0 0 1 1 1 1 1 0 0 1 out = 10×10 logical array 0 1 1 0 0 1 1 1 1 0 0 1 1 1 0 0 1 0 1 0 1 0 1 0 1 1 0 1 1 1 1 0 0 1 1 0 1 1 0 1 1 0 0 0 1 0 1 1 0 1 0 0 1 0 0 1 1 1 1 0 1 1 1 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 1 0 0 0 1 0 0 0 0 1 0 0 1 1 1 1 1 0 0 1

4   Pass
BW = cat(3, eye(5), fliplr(eye(5))); out_correct = [1 0 0 0 2 0 1 0 2 0 0 0 2 0 0 0 2 0 1 0 2 0 0 0 1]; assert(isequal(findlastindim(BW,3),out_correct))

c = 1 c = 2 c = 1 c = 2 c = 2 c = 2 c = 1 c = 2 c = 1 out = 1 0 0 0 2 0 1 0 2 0 0 0 2 0 0 0 2 0 1 0 2 0 0 0 1