Cody

# Problem 42984. Vector addition

Solution 3611040

Submitted on 10 Nov 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   Pass

2   Pass
v1 = [1 4]; v2 = [3 8 6 1]; v3_correct = [3 8 7 5]; assert(isequal(vadd(v1,v2),v3_correct)) assert(isequal(vadd(v2,v1),v3_correct))

v3 = Python long with properties: denominator: [1×1 py.long] imag: [1×1 py.long] numerator: [1×1 py.long] real: [1×1 py.long] 3875 v3 = 3 8 7 5 v3 = Python long with properties: denominator: [1×1 py.long] imag: [1×1 py.long] numerator: [1×1 py.long] real: [1×1 py.long] 3875 v3 = 3 8 7 5

3   Pass
v1 = [9 9]; v2 = [9 9]; v3_correct = [1 9 8]; assert(isequal(vadd(v1,v2),v3_correct)) assert(isequal(vadd(v2,v1),v3_correct))

v3 = Python long with properties: denominator: [1×1 py.long] imag: [1×1 py.long] numerator: [1×1 py.long] real: [1×1 py.long] 198 v3 = 1 9 8 v3 = Python long with properties: denominator: [1×1 py.long] imag: [1×1 py.long] numerator: [1×1 py.long] real: [1×1 py.long] 198 v3 = 1 9 8

4   Fail
v1 = [9 4 2 3 5 6 7 3 3 5 5 4 6 3 2 4 2 5 7 7 8 5 4 3 4 7 8 7]; v2 = [3 5 7 3 4 5 2 5 4 8 7 6 4 3 7 8 9 5 4 0 3 2 7 9 0 3 2 8 9]; v3_correct = [4 5 1 5 8 0 9 2 8 2 3 1 9 0 1 1 3 7 9 8 1 1 3 3 3 8 0 7 6]; assert(isequal(vadd(v1,v2),v3_correct)) assert(isequal(vadd(v2,v1),v3_correct))

v3 = Python long with properties: denominator: [1×1 py.long] imag: [1×1 py.long] numerator: [1×1 py.long] real: [1×1 py.long] 45158092823190114316639535104 v3 = 4 5 1 5 8 0 9 2 8 2 3 1 9 0 1 1 4 3 1 6 6 3 9 5 3 5 1 0 4

Assertion failed.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!