Cody

Problem 43033. Create a constant offset.

Solution 1209444

Submitted on 10 Jun 2017
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
a = 1; offset = 2 y_correct = 3; assert(isequal(constant_offset(a,offset),y_correct))

offset = 2 y = 3 y = 1

Assertion failed.

2   Fail
a = [-1 1]; offset = 2 y_correct = [1 3]; assert(isequal(constant_offset(a,offset),y_correct))

offset = 2 y = 3 y = 1 1

Undefined function or variable 'ans'. Error in constant_offset (line 5) y=sort([ans(1:end-1) a(end)+o]) Error in TestPoint2 (line 4) assert(isequal(constant_offset(a,offset),y_correct))

3   Fail
a = [-10:1:1]; offset = 10 y_correct = [0:11]; assert(isequal(constant_offset(a,offset),y_correct))

offset = 10 y = 3 y = 10 9 8 7 6 5 4 3 2 1 0 1

Undefined function or variable 'ans'. Error in constant_offset (line 5) y=sort([ans(1:end-1) a(end)+o]) Error in TestPoint3 (line 4) assert(isequal(constant_offset(a,offset),y_correct))