Cody

Problem 2528. expand intervals

Solution 2796784

Submitted on 6 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
bounds = [1 5 7 9 24 32]; elements = [1 2 3 4 5 7 8 9 24 25 26 27 28 29 30 31 32]; assert(isequal(ExpandIntervals(bounds),elements))

Unrecognized function or variable 'elements'. Error in ExpandIntervals (line 7) elements = union(elements, temp); Error in Test1 (line 3) assert(isequal(ExpandIntervals(bounds),elements))

2   Fail
bounds = [9 9 11 11]; elements = [9 11]; assert(isequal(ExpandIntervals(bounds),elements))

Unrecognized function or variable 'elements'. Error in ExpandIntervals (line 7) elements = union(elements, temp); Error in Test2 (line 3) assert(isequal(ExpandIntervals(bounds),elements))

3   Fail
bounds = [100 200 300 400]; elements = [100:200 300:400]; assert(isequal(ExpandIntervals(bounds),elements))

Unrecognized function or variable 'elements'. Error in ExpandIntervals (line 7) elements = union(elements, temp); Error in Test3 (line 3) assert(isequal(ExpandIntervals(bounds),elements))

4   Fail
temp = [-10:10; -10:10]; bounds = temp(:)'; elements = -10:10; assert(isequal(ExpandIntervals(bounds),elements))

Unrecognized function or variable 'elements'. Error in ExpandIntervals (line 7) elements = union(elements, temp); Error in Test4 (line 4) assert(isequal(ExpandIntervals(bounds),elements))

5   Fail
bounds = [-10 10]; elements = -10:10; assert(isequal(ExpandIntervals(bounds),elements))

Unrecognized function or variable 'elements'. Error in ExpandIntervals (line 7) elements = union(elements, temp); Error in Test5 (line 3) assert(isequal(ExpandIntervals(bounds),elements))

Suggested Problems

More from this Author9

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!