Cody

Solution 1949199

Submitted on 26 Sep 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   Pass
x = [0 5; 10 3; 20 15; 16 19; 25 25]; y_correct = [0 10;15 20;25 25]; assert(isequal(joinRanges(x),y_correct))

x = 0 5 3 10 15 20 16 19 25 25 b = [] p = 1×6 logical array 0 0 0 1 1 1 b = 0 10 p = 1×8 logical array 0 0 0 0 0 0 0 0 b = 0 10 15 20 p = 1×6 logical array 0 1 1 1 1 0 b = 0 10 15 20 15 20 p = 1×4 logical array 0 0 0 0 b = 0 10 15 20 15 20 25 25 y = 0 10 15 20 25 25

2   Fail
x = [-10 -5; 0 -8; -1 5]; y_correct = [-10 5]; assert(isequal(joinRanges(x),y_correct))

x = -10 -5 -8 0 -1 5 b = [] p = 1×6 logical array 0 0 1 1 1 1 b = -10 0 p = 1×9 logical array 0 0 0 0 0 0 0 1 1 b = -10 0 -8 5 y = -10 0 -8 5

Assertion failed.

3   Fail
x = [-50 0; 0 50; 100 50; -50 -100]; y_correct = [-100 100]; assert(isequal(joinRanges(x),y_correct))

x = -50 0 0 50 50 100 -100 -50 b = [] p = 1×51 logical array Columns 1 through 45 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 46 through 51 0 0 0 0 0 1 b = -50 50 p = 1×51 logical array Columns 1 through 45 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 46 through 51 0 0 0 0 0 1 b = -50 50 0 100 p = 1×51 logical array Columns 1 through 45 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 46 through 51 0 0 0 0 0 0 b = -50 50 0 100 -100 -50 y = -100 -50 -50 50 0 100

Assertion failed.

4   Fail
x = [99 51; -49 -1; -51 -99; 1 49]; y_correct = [-99 -51;-49 -1;1 49;51 99]; assert(isequal(joinRanges(x),y_correct))

x = 51 99 -49 -1 -99 -51 1 49 b = [] p = 1×49 logical array Columns 1 through 45 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 46 through 49 0 0 0 0 b = -49 -1 p = 1×49 logical array Columns 1 through 45 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 46 through 49 0 0 0 0 b = -49 -1 -99 -51 p = 1×49 logical array Columns 1 through 45 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 46 through 49 0 0 0 0 b = -49 -1 -99 -51 1 49 y = -99 -51 -49 -1 1 49

Assertion failed.

5   Fail
x = [-inf inf]; y_correct = x; assert(isequal(joinRanges(x),y_correct))

x = -Inf Inf b = [] y = []

Assertion failed.

6   Fail
x = [0 -42; -inf -10; inf 42]; y_correct = [-Inf 0;42 Inf]; assert(isequal(joinRanges(x),y_correct))

x = -42 0 -Inf -10 42 Inf b = []

Maximum variable size allowed by the program is exceeded. Error in joinRanges (line 5) p = ismember([x(i-1,1):x(i-1,2)],[x(i,1):x(i,2)]) Error in Test6 (line 3) assert(isequal(joinRanges(x),y_correct))

7   Fail
x = [36.154 63.178; 12.007 -5.156; -0.519 17.651]; y_correct = [-5.156 17.651;36.154 63.178]; assert(isequal(joinRanges(x),y_correct))

x = 36.1540 63.1780 -5.1560 12.0070 -0.5190 17.6510 b = [] p = 1×28 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = -5.1560 12.0070 p = 1×18 logical array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = -5.1560 12.0070 -0.5190 17.6510 y = -5.1560 12.0070 -0.5190 17.6510

Assertion failed.

8   Pass
assert(isempty(strfind(evalc('type joinRanges'), 'regexp')));