Cody

Problem 44322. Make one vector from two others

Solution 1742518

Submitted on 4 Mar 2019 by Martin C.
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   Pass
m1 = 1;m2=1;y_correct = 1; assert(isequal(combine_two_vectors(m1,m2),y_correct))

y = [] y = 1

2   Pass
m1=[1 2 3];m2=[1 2 3];y_correct=[1 2 2 3 3 3]; assert(isequal(combine_two_vectors(m1,m2),y_correct))

y = [] y = 1 y = 1 2 y = 1 2 2 y = 1 2 2 3 y = 1 2 2 3 3 y = 1 2 2 3 3 3

3   Pass
m1=[4 0 9 3];m2=[0 2 4 6];y_correct=[0 0 9 9 9 9 3 3 3 3 3 3]; assert(isequal(combine_two_vectors(m1,m2),y_correct))

y = [] y = 0 y = 0 0 y = 0 0 9 y = 0 0 9 9 y = 0 0 9 9 9 y = 0 0 9 9 9 9 y = 0 0 9 9 9 9 3 y = 0 0 9 9 9 9 3 3 y = 0 0 9 9 9 9 3 3 3 y = 0 0 9 9 9 9 3 3 3 3 y = 0 0 9 9 9 9 3 3 3 3 3 y = 0 0 9 9 9 9 3 3 3 3 3 3

4   Pass
v1=ceil(13*rand)+2; v2=ceil(6*rand)+2; m1=repmat(v1,1,v2) m2=randperm(v2); assert(isequal(combine_two_vectors(m1,m2),repmat(v1,1,sum(m2))))

m1 = 5 5 5 5 5 5 y = [] y = 5 y = 5 5 y = 5 5 5 y = 5 5 5 5 y = 5 5 5 5 5 y = 5 5 5 5 5 5 y = 5 5 5 5 5 5 5 y = 5 5 5 5 5 5 5 5 y = 5 5 5 5 5 5 5 5 5 y = 5 5 5 5 5 5 5 5 5 5 y = 5 5 5 5 5 5 5 5 5 5 5 y = 5 5 5 5 5 5 5 5 5 5 5 5 y = 5 5 5 5 5 5 5 5 5 5 5 5 5 y = 5 5 5 5 5 5 5 5 5 5 5 5 5 5 y = 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 y = 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 y = 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 y = 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 y = 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 y = 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 y = 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5

5   Pass
M1=[1 -3 5 7]; M2=[2 4 0 6]; y_correct=[1 1 -3 -3 -3 -3 7 7 7 7 7 7]; assert(isequal(combine_two_vectors(M1,M2),y_correct))

y = [] y = 1 y = 1 1 y = 1 1 -3 y = 1 1 -3 -3 y = 1 1 -3 -3 -3 y = 1 1 -3 -3 -3 -3 y = 1 1 -3 -3 -3 -3 7 y = 1 1 -3 -3 -3 -3 7 7 y = 1 1 -3 -3 -3 -3 7 7 7 y = 1 1 -3 -3 -3 -3 7 7 7 7 y = 1 1 -3 -3 -3 -3 7 7 7 7 7 y = 1 1 -3 -3 -3 -3 7 7 7 7 7 7

6   Pass
m1=[-1 1 -1 1 -1 1]; m2=[6 1 5 2 3 4]; y_correct=[-1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 1 1 1 1]; assert(isequal(combine_two_vectors(m1,m2),y_correct))

y = [] y = -1 y = -1 -1 y = -1 -1 -1 y = -1 -1 -1 -1 y = -1 -1 -1 -1 -1 y = -1 -1 -1 -1 -1 -1 y = -1 -1 -1 -1 -1 -1 1 y = -1 -1 -1 -1 -1 -1 1 -1 y = -1 -1 -1 -1 -1 -1 1 -1 -1 y = -1 -1 -1 -1 -1 -1 1 -1 -1 -1 y = -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 y = -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 y = -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 y = -1 -1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 1 y = -1 -1 -1 -1 -1 -1 1 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