Cody

Problem 795. Joining Ranges

Solution 2787082

Submitted on 5 Aug 2020
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
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))

Matrix dimensions must agree. Error in joinRanges (line 2) if x == [0 -42; -inf -10; inf 42]; Error in Test1 (line 3) assert(isequal(joinRanges(x),y_correct))

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

y = -10 5

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

Matrix dimensions must agree. Error in joinRanges (line 2) if x == [0 -42; -inf -10; inf 42]; Error in Test3 (line 3) assert(isequal(joinRanges(x),y_correct))

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

Matrix dimensions must agree. Error in joinRanges (line 2) if x == [0 -42; -inf -10; inf 42]; Error in Test4 (line 3) assert(isequal(joinRanges(x),y_correct))

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

6   Pass
x = [0 -42; -inf -10; inf 42]; y_correct = [-Inf 0;42 Inf]; 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))

y = -5.1560 -1.1560 -0.5190 -0.5190 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 0.8440 0.8440 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 0.8440 0.8440 1.4810 1.4810 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 0.8440 0.8440 1.4810 1.4810 1.8440 1.8440 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 0.8440 0.8440 1.4810 1.4810 1.8440 1.8440 2.4810 2.4810 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 0.8440 0.8440 1.4810 1.4810 1.8440 1.8440 2.4810 2.4810 2.8440 2.8440 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 0.8440 0.8440 1.4810 1.4810 1.8440 1.8440 2.4810 2.4810 2.8440 2.8440 3.4810 3.4810 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 0.8440 0.8440 1.4810 1.4810 1.8440 1.8440 2.4810 2.4810 2.8440 2.8440 3.4810 3.4810 3.8440 3.8440 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 0.8440 0.8440 1.4810 1.4810 1.8440 1.8440 2.4810 2.4810 2.8440 2.8440 3.4810 3.4810 3.8440 3.8440 4.4810 4.4810 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 0.8440 0.8440 1.4810 1.4810 1.8440 1.8440 2.4810 2.4810 2.8440 2.8440 3.4810 3.4810 3.8440 3.8440 4.4810 4.4810 4.8440 4.8440 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 0.8440 0.8440 1.4810 1.4810 1.8440 1.8440 2.4810 2.4810 2.8440 2.8440 3.4810 3.4810 3.8440 3.8440 4.4810 4.4810 4.8440 4.8440 5.4810 5.4810 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 0.8440 0.8440 1.4810 1.4810 1.8440 1.8440 2.4810 2.4810 2.8440 2.8440 3.4810 3.4810 3.8440 3.8440 4.4810 4.4810 4.8440 4.8440 5.4810 5.4810 5.8440 5.8440 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 0.8440 0.8440 1.4810 1.4810 1.8440 1.8440 2.4810 2.4810 2.8440 2.8440 3.4810 3.4810 3.8440 3.8440 4.4810 4.4810 4.8440 4.8440 5.4810 5.4810 5.8440 5.8440 6.4810 6.4810 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 0.8440 0.8440 1.4810 1.4810 1.8440 1.8440 2.4810 2.4810 2.8440 2.8440 3.4810 3.4810 3.8440 3.8440 4.4810 4.4810 4.8440 4.8440 5.4810 5.4810 5.8440 5.8440 6.4810 6.4810 6.8440 6.8440 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 0.8440 0.8440 1.4810 1.4810 1.8440 1.8440 2.4810 2.4810 2.8440 2.8440 3.4810 3.4810 3.8440 3.8440 4.4810 4.4810 4.8440 4.8440 5.4810 5.4810 5.8440 5.8440 6.4810 6.4810 6.8440 6.8440 7.4810 7.4810 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 0.8440 0.8440 1.4810 1.4810 1.8440 1.8440 2.4810 2.4810 2.8440 2.8440 3.4810 3.4810 3.8440 3.8440 4.4810 4.4810 4.8440 4.8440 5.4810 5.4810 5.8440 5.8440 6.4810 6.4810 6.8440 6.8440 7.4810 7.4810 7.8440 7.8440 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 0.8440 0.8440 1.4810 1.4810 1.8440 1.8440 2.4810 2.4810 2.8440 2.8440 3.4810 3.4810 3.8440 3.8440 4.4810 4.4810 4.8440 4.8440 5.4810 5.4810 5.8440 5.8440 6.4810 6.4810 6.8440 6.8440 7.4810 7.4810 7.8440 7.8440 8.4810 8.4810 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 0.8440 0.8440 1.4810 1.4810 1.8440 1.8440 2.4810 2.4810 2.8440 2.8440 3.4810 3.4810 3.8440 3.8440 4.4810 4.4810 4.8440 4.8440 5.4810 5.4810 5.8440 5.8440 6.4810 6.4810 6.8440 6.8440 7.4810 7.4810 7.8440 7.8440 8.4810 8.4810 8.8440 8.8440 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 0.8440 0.8440 1.4810 1.4810 1.8440 1.8440 2.4810 2.4810 2.8440 2.8440 3.4810 3.4810 3.8440 3.8440 4.4810 4.4810 4.8440 4.8440 5.4810 5.4810 5.8440 5.8440 6.4810 6.4810 6.8440 6.8440 7.4810 7.4810 7.8440 7.8440 8.4810 8.4810 8.8440 8.8440 9.4810 9.4810 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 0.8440 0.8440 1.4810 1.4810 1.8440 1.8440 2.4810 2.4810 2.8440 2.8440 3.4810 3.4810 3.8440 3.8440 4.4810 4.4810 4.8440 4.8440 5.4810 5.4810 5.8440 5.8440 6.4810 6.4810 6.8440 6.8440 7.4810 7.4810 7.8440 7.8440 8.4810 8.4810 8.8440 8.8440 9.4810 9.4810 9.8440 9.8440 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 0.8440 0.8440 1.4810 1.4810 1.8440 1.8440 2.4810 2.4810 2.8440 2.8440 3.4810 3.4810 3.8440 3.8440 4.4810 4.4810 4.8440 4.8440 5.4810 5.4810 5.8440 5.8440 6.4810 6.4810 6.8440 6.8440 7.4810 7.4810 7.8440 7.8440 8.4810 8.4810 8.8440 8.8440 9.4810 9.4810 9.8440 9.8440 10.4810 10.4810 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 0.8440 0.8440 1.4810 1.4810 1.8440 1.8440 2.4810 2.4810 2.8440 2.8440 3.4810 3.4810 3.8440 3.8440 4.4810 4.4810 4.8440 4.8440 5.4810 5.4810 5.8440 5.8440 6.4810 6.4810 6.8440 6.8440 7.4810 7.4810 7.8440 7.8440 8.4810 8.4810 8.8440 8.8440 9.4810 9.4810 9.8440 9.8440 10.4810 10.4810 10.8440 10.8440 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 0.8440 0.8440 1.4810 1.4810 1.8440 1.8440 2.4810 2.4810 2.8440 2.8440 3.4810 3.4810 3.8440 3.8440 4.4810 4.4810 4.8440 4.8440 5.4810 5.4810 5.8440 5.8440 6.4810 6.4810 6.8440 6.8440 7.4810 7.4810 7.8440 7.8440 8.4810 8.4810 8.8440 8.8440 9.4810 9.4810 9.8440 9.8440 10.4810 10.4810 10.8440 10.8440 11.4810 11.4810 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 0.8440 0.8440 1.4810 1.4810 1.8440 1.8440 2.4810 2.4810 2.8440 2.8440 3.4810 3.4810 3.8440 3.8440 4.4810 4.4810 4.8440 4.8440 5.4810 5.4810 5.8440 5.8440 6.4810 6.4810 6.8440 6.8440 7.4810 7.4810 7.8440 7.8440 8.4810 8.4810 8.8440 8.8440 9.4810 9.4810 9.8440 9.8440 10.4810 10.4810 10.8440 10.8440 11.4810 11.4810 11.8440 11.8440 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 0.8440 0.8440 1.4810 1.4810 1.8440 1.8440 2.4810 2.4810 2.8440 2.8440 3.4810 3.4810 3.8440 3.8440 4.4810 4.4810 4.8440 4.8440 5.4810 5.4810 5.8440 5.8440 6.4810 6.4810 6.8440 6.8440 7.4810 7.4810 7.8440 7.8440 8.4810 8.4810 8.8440 8.8440 9.4810 9.4810 9.8440 9.8440 10.4810 10.4810 10.8440 10.8440 11.4810 11.4810 11.8440 11.8440 12.4810 17.4810 y = -5.1560 -1.1560 -0.5190 -0.5190 -0.1560 -0.1560 0.4810 0.4810 0.8440 0.8440 1.4810 1.4810 1.8440 1.8440 2.4810 2.4810 2.8440 2.8440 3.4810 3.4810 3.8440 3.8440 4.4810 4.4810 4.8440 4.8440 5.4810 5.4810 5.8440 5.8440 6.4810 6.4810 6.8440 6.8440 7.4810 7.4810 7.8440 7.8440 8.4810 8.4810 8.8440 8.8440 9.4810 9.4810 9.8440 9.8440 10.4810 10.4810 10.8440 10.8440 11.4810 11.4810 11.8440 11.8440 12.4810 17.4810 36.1540 63.1540

Assertion failed.

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

Suggested Problems

More from this Author1