Cody

Problem 2228. Time Expansion

Solution 2712807

Submitted on 19 Jul 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
n=4 x=[2 1 2 3 4 5 -3 4 -1 2 2 2] y_correct = [2 0 0 0 1 0 0 0 2 0 0 0 3 0 0 0 4 0 0 0 5 0 0 0 -3 0 0 0 4 0 0 0 -1 0 0 0 2 0 0 0 2 0 0 0 2]; assert(isequal(time_expansion(x,n),y_correct))

n = 4 x = 2 1 2 3 4 5 -3 4 -1 2 2 2

Error using horzcat Dimensions of arrays being concatenated are not consistent. Error in time_expansion (line 2) t = [x zeros(n,length(x))]; Error in Test1 (line 4) assert(isequal(time_expansion(x,n),y_correct))

2   Fail
n=1 x=[2 1 2 3 4 5 -3 4 -1 2 2 2] y_correct=x; assert(isequal(time_expansion(x,n),y_correct))

n = 1 x = 2 1 2 3 4 5 -3 4 -1 2 2 2

Assertion failed.

3   Fail
n=5 x=[2 1 2 3 4] y_correct=[2 0 0 0 0 1 0 0 0 0 2 0 0 0 0 3 0 0 0 0 4]; assert(isequal(time_expansion(x,n),y_correct))

n = 5 x = 2 1 2 3 4

Error using horzcat Dimensions of arrays being concatenated are not consistent. Error in time_expansion (line 2) t = [x zeros(n,length(x))]; Error in Test3 (line 4) assert(isequal(time_expansion(x,n),y_correct))

Suggested Problems

More from this Author21