Cody

Solution 1943077

Submitted on 19 Sep 2019 by Augusto Mazzei
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
binary_array = [1 1 0 1]; expected_length = 2; expected_index = 1; [actual_length actual_index] = longest_run(binary_array); assert(isequal(expected_length, actual_length)); assert(isequal(expected_index, actual_index));

d = 1×3 logical array 0 0 0 idx = 1×0 empty double row vector d = 1×3 logical array 0 0 0 idx = 1×0 empty double row vector d = 1×3 logical array 1 0 0 idx = 1 L = 2

2   Pass
binary_array = [1 1 0 1 0 0 0 0 1 1 1]; expected_length = 4; expected_index = 5; [actual_length actual_index] = longest_run(binary_array); assert(isequal(expected_length, actual_length)); assert(isequal(expected_index, actual_index));

d = 1×10 logical array 0 0 0 0 0 0 0 0 0 0 idx = 1×0 empty double row vector d = 1×10 logical array 0 0 0 0 0 0 0 0 0 0 idx = 1×0 empty double row vector d = 1×10 logical array 0 0 0 0 0 0 0 0 0 0 idx = 1×0 empty double row vector d = 1×10 logical array 0 0 0 0 0 0 0 0 0 0 idx = 1×0 empty double row vector d = 1×10 logical array 0 0 0 0 0 0 0 0 0 0 idx = 1×0 empty double row vector d = 1×10 logical array 0 0 0 0 0 0 0 0 0 0 idx = 1×0 empty double row vector d = 1×10 logical array 0 0 0 0 0 0 0 0 0 0 idx = 1×0 empty double row vector d = 1×10 logical array 0 0 0 0 1 0 0 0 0 0 idx = 5 L = 4

3   Pass
binary_array = [1 0]; expected_length = 1; expected_index = 1; [actual_length actual_index] = longest_run(binary_array); assert(isequal(expected_length, actual_length)); assert(isequal(expected_index, actual_index));

L = 1

4   Pass
binary_array = [1]; expected_length = 1; expected_index = 1; [actual_length actual_index] = longest_run(binary_array); assert(isequal(expected_length, actual_length)); assert(isequal(expected_index, actual_index));

L = 1

5   Pass
binary_array = [1 1 1 1 1 1]; expected_length = 6; expected_index = 1; [actual_length actual_index] = longest_run(binary_array); assert(isequal(expected_length, actual_length)); assert(isequal(expected_index, actual_index));

d = 1×5 logical array 1 0 0 0 0 idx = 1 L = 6