Cody

# Problem 1502. Perl 1: push

Solution 1983722

Submitted on 20 Oct 2019
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
x = [1 2 3 4 5]; y = [6 7 8]; [x, num] = push(x, y); y_correct = [1 2 3 4 5 6 7 8]; num_correct = 8; assert(isequal(x,y_correct) & isequal(num, num_correct));

Error using horzcat Dimensions of arrays being concatenated are not consistent. Error in push (line 2) y=[x(:) list(:)] Error in Test1 (line 3) [x, num] = push(x, y);

2   Fail
x = [1 2 3 4 5]; y = 6; [x, num] = push(x, y); y_correct = [1 2 3 4 5 6]; num_correct = 6; assert(isequal(x,y_correct) & isequal(num, num_correct));

Error using horzcat Dimensions of arrays being concatenated are not consistent. Error in push (line 2) y=[x(:) list(:)] Error in Test2 (line 3) [x, num] = push(x, y);

3   Fail
x = [1 2 3 4 5]'; y = [6 7 8]; [x, num] = push(x, y); y_correct = [1 2 3 4 5 6 7 8]'; num_correct = 8; assert(isequal(x,y_correct) & isequal(num, num_correct));

Error using horzcat Dimensions of arrays being concatenated are not consistent. Error in push (line 2) y=[x(:) list(:)] Error in Test3 (line 3) [x, num] = push(x, y);

4   Fail
x = []; y = [1 2 3]; [x, num] = push(x, y); y_correct = [1 2 3]; num_correct = 3; assert(isequal(x,y_correct) & isequal(num, num_correct));

y = 1 2 3 k = 3

Assertion failed.

5   Fail
x = [0.5 8.4 9.6]; y = [12.0 pi]; [x, num] = push(x, y); y_correct = [0.5 8.4 9.6 12.0 pi]; num_correct = 5; assert(isequal(x,y_correct) & isequal(num, num_correct));

Error using horzcat Dimensions of arrays being concatenated are not consistent. Error in push (line 2) y=[x(:) list(:)] Error in Test5 (line 3) [x, num] = push(x, y);