Cody

# Problem 676. Reindex a vector

Solution 2775715

Submitted on 4 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
N = [1 3 2 7]; IDX= [2 3 4 6]; y_correct = [0 1 3 2 0 7]; assert(isequal(reindex_a_vector(N,IDX),y_correct))

y = 0 0 0 0 0 0 y = 0 1 3 2 0 7

Undefined function 'iscolon' for input arguments of type 'double'. Error in reindex_a_vector (line 4) if iscolon(N)==1 Error in Test1 (line 4) assert(isequal(reindex_a_vector(N,IDX),y_correct))

2   Fail
N=[ -1 0 4 2]; IDX=[3 8 1 6]; y_correct = [4 0 -1 0 0 2 0 0]; assert(isequal(reindex_a_vector(N,IDX),y_correct))

y = 0 0 0 0 0 0 0 0 y = 4 0 -1 0 0 2 0 0

Undefined function 'iscolon' for input arguments of type 'double'. Error in reindex_a_vector (line 4) if iscolon(N)==1 Error in Test2 (line 4) assert(isequal(reindex_a_vector(N,IDX),y_correct))

3   Fail
N=[-1 0 4 2]'; IDX=[3 8 1 6]; y_correct = [4 0 -1 0 0 2 0 0]'; assert(isequal(reindex_a_vector(N,IDX),y_correct))

y = 0 0 0 0 0 0 0 0 y = 4 0 -1 0 0 2 0 0

Undefined function 'iscolon' for input arguments of type 'double'. Error in reindex_a_vector (line 4) if iscolon(N)==1 Error in Test3 (line 4) assert(isequal(reindex_a_vector(N,IDX),y_correct))

4   Fail
N=[1 2 3 4 5 6 7 8 9 10]; IDX=[3 4 5 6 7 8 9 10 11 13]; y_correct=[0 0 1 2 3 4 5 6 7 8 9 0 10]; assert(isequal(reindex_a_vector(N,IDX),y_correct))

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

Undefined function 'iscolon' for input arguments of type 'double'. Error in reindex_a_vector (line 4) if iscolon(N)==1 Error in Test4 (line 4) assert(isequal(reindex_a_vector(N,IDX),y_correct))