Cody

Problem 1845. Pascal's pyramid

Solution 1709936

Submitted on 18 Jan 2019 by HH
• Size: 9
• This is the leading solution.
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=1; p=1; assert(isequal(pascalp(n),p))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In pascalp (line 2) In ScoringEngineTestPoint1 (line 3) In solutionTest (line 3)]

2   Pass
n=3; p=[1 2 1;2 4 2;1 2 1]; assert(isequal(pascalp(n),p))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In pascalp (line 2) In ScoringEngineTestPoint2 (line 3) In solutionTest (line 5)]

3   Pass
n=5; p=[1 4 6 4 1;4 16 24 16 4;6 24 36 24 6;4 16 24 16 4;1 4 6 4 1]; assert(isequal(pascalp(n),p))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In pascalp (line 2) In ScoringEngineTestPoint3 (line 3) In solutionTest (line 7)]

4   Pass
n=8; p=[1 7 21 35 35 21 7 1;7 49 147 245 245 147 49 7;21 147 441 735 735 441 147 21;35 245 735 1225 1225 735 245 35;35 245 735 1225 1225 735 245 35;21 147 441 735 735 441 147 21;7 49 147 245 245 147 49 7;1 7 21 35 35 21 7 1]; assert(isequal(pascalp(n),p))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In pascalp (line 2) In ScoringEngineTestPoint4 (line 3) In solutionTest (line 9)]

Community Treasure Hunt

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

Start Hunting!