Cody

Solution 931223

Submitted on 3 Aug 2016 by SirSteve26
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));

varlength = 2 run_length = 2 start_index = 1 varlength = 1 varlength = 1

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

varlength = 2 run_length = 2 start_index = 1 varlength = 1 varlength = 1 varlength = 1 varlength = 2 varlength = 3 run_length = 3 start_index = 5 varlength = 4 run_length = 4 start_index = 5 varlength = 1 varlength = 2 varlength = 3

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

varlength = 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));

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

varlength = 2 run_length = 2 start_index = 1 varlength = 3 run_length = 3 start_index = 1 varlength = 4 run_length = 4 start_index = 1 varlength = 5 run_length = 5 start_index = 1 varlength = 6 run_length = 6 start_index = 1

Suggested Problems