Cody

# Problem 2009. Insert certain elements into a vector.

Solution 362246

Submitted on 30 Nov 2013 by Andrei Bobrov
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
%% v = 1:5; u = [2 4]; w = [0 -1]; y = insert_some(v,w,u); y_correct = [1 0 2 3 -1 4 5]; assert(isequal(y,y_correct)) filetext = fileread('insert_some.m'); assert(isempty(strfind(filetext, 'regexp')),'regexp* command is forbidden'); assert(isempty(strfind(filetext, 'eval')),'eval* command is forbidden'); assert(isempty(strfind(filetext, 'inline')),'inline command is forbidden');

2   Pass
%% v = 1:100; u = 1:100; w = 1:100; y = insert_some(v,w,u); y_correct = reshape(repmat(1:100,2,1),1,[]); assert(isequal(y,y_correct))

3   Pass
%% v = 0:99; u = 11:10:101; w = repmat(nan,1,10); y = insert_some(v,w,u); y_correct = reshape([reshape(v,10,[]);repmat(nan,1,10)],1,[]); assert(isequaln(y,y_correct))

4   Pass
%% v = repmat(1:2,1,100); w = repmat(3,1,100); u = 3:2:201; y = insert_some(v,w,u); y_correct = repmat(1:3,1,100); assert(isequaln(y,y_correct))