Cody

# Problem 37. Pascal's Triangle

Solution 2066035

Submitted on 21 Dec 2019 by Alistair James
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
n = 0; correct = [1]; assert(isequal(pascalTri(n),correct))

top = 1 bottom = 1 1 y = 1

2   Pass
n = 1; correct = [1 1]; assert(isequal(pascalTri(n),correct))

top = 1 bottom = 1 1 y = 1 1

3   Pass
n = 2; correct = [1 2 1]; assert(isequal(pascalTri(n),correct))

top = 1 bottom = 1 1 current = 1 1 k = 1 nextlength = 3 specialfigs = 1 bottom = 1 1 bottom = 1 2 lengthbottom = 2 bottom = 1 2 1 current = 1 2 1 y = 1 2 1

4   Pass
n = 3; correct = [1 3 3 1]; assert(isequal(pascalTri(n),correct))

top = 1 bottom = 1 1 current = 1 1 k = 2 nextlength = 3 specialfigs = 1 bottom = 1 1 bottom = 1 2 lengthbottom = 2 bottom = 1 2 1 current = 1 2 1 nextlength = 4 specialfigs = 2 bottom = 1 2 1 bottom = 1 3 1 bottom = 1 3 3 lengthbottom = 3 bottom = 1 3 3 1 current = 1 3 3 1 y = 1 3 3 1

5   Pass
n = 10; correct = [1 10 45 120 210 252 210 120 45 10 1]; assert(isequal(pascalTri(n),correct))

top = 1 bottom = 1 1 current = 1 1 k = 9 nextlength = 3 specialfigs = 1 bottom = 1 1 bottom = 1 2 lengthbottom = 2 bottom = 1 2 1 current = 1 2 1 nextlength = 4 specialfigs = 2 bottom = 1 2 1 bottom = 1 3 1 bottom = 1 3 3 lengthbottom = 3 bottom = 1 3 3 1 current = 1 3 3 1 nextlength = 5 specialfigs = 3 bottom = 1 3 3 1 bottom = 1 4 3 1 bottom = 1 4 6 1 bottom = 1 4 6 4 lengthbottom = 4 bottom = 1 4 6 4 1 current = 1 4 6 4 1 nextlength = 6 specialfigs = 4 bottom = 1 4 6 4 1 bottom = 1 5 6 4 1 bottom = 1 5 10 4 1 bottom = 1 5 10 10 1 bottom = 1 5 10 10 5 lengthbottom = 5 bottom = 1 5 10 10 5 1 current = 1 5 10 10 5 1 nextlength = 7 specialfigs = 5 bottom = 1 5 10 10 5 1 bottom = 1 6 10 10 5 1 bottom = 1 6 15 10 5 1 bottom = 1 6 15 20 5 1 bottom = 1 6 15 20 15 1 bottom = 1 6 15 20 15 6 lengthbottom = 6 bottom = 1 6 15 20 15 6 1 current = 1 6 15 20 15 6 1 nextlength = 8 specialfigs = 6 bottom = 1 6 15 20 15 6 1 bottom = 1 7 15 20 15 6 1 bottom = 1 7 21 20 15 6 1 bottom = 1 7 21 35 15 6 1 bottom = 1 7 21 35 35 6 1 bottom = 1 7 21 35 35 21 1 bottom = 1 7 21 35 35 21 7 lengthbottom = 7 bottom = 1 7 21 35 35 21 7 1 current = 1 7 21 35 35 21 7 1 nextlength = 9 specialfigs = 7 bottom = 1 7 21 35 35 21 7 1 bottom = 1 8 21 35 35 21 7 1 bottom = 1 8 28 35 35 21 7 1 bottom = 1 8 28 56 35 21 7 1 bottom = 1 8 28 56 70 21 7 1 bottom = 1 8 28 56 70 56 7 1 bottom = 1 8 28 56 70 56 28 1 bottom = 1 8 28 56 70 56 28 8 lengthbottom = 8 bottom = 1 8 28 56 70 56 28 8 1 current = 1 8 28 56 70 56 28 8 1 nextlength = 10 specialfigs = 8 bottom = 1 8 28 56 70 56 28 8 1 bottom = 1 9 28 56 70 56 28 8 1 bottom = 1 9 36 56 70 56 28 8 1 bottom = 1 9 36 84 70 56 28 8 1 bottom = 1 9 36 84 126 56 28 8 1 bottom = 1 9 36 84 126 126 28 8 1 bottom = 1 9 36 84 126 126 84 8 1 bottom = 1 9 36 84 126 126 84 36 1 bottom = 1 9 36 84 126 126 84 36 9 lengthbottom = 9 bottom = 1 9 36 84 126 126 84 36 9 1 current = 1 9 36 84 126 126 84 36 9 1 nextlength = 11 specialfigs = 9 bottom = 1 9 36 84 126 126 84 36 9 1 bottom = 1 10 36 84 126 126 84 36 9 1 bottom = 1 10 45 84 126 126 84 36 9 1 bottom = 1 10 45 120 126 126 84 36 9 1 bottom = 1 10 45 120 210 126 84 36 9 1 bottom = 1 10 45 120 210 252 84 36 9 1 bottom = 1 10 45 120 210 252 210 36 9 1 bottom = 1 10 45 120 210 252 210 120 9 1 bottom = 1 10 45 120 210 252 210 120 45 1 bottom = 1 10 45 120 210 252 210 120 45 10 lengthbottom = 10 bottom = 1 10 45 120 210 252 210 120 45 10 1 current = 1 10 45 120 210 252 210 120 45 10 1 y = 1 10 45 120 210 252 210 120 45 10 1