6 kyu

Simple Fun #214: Pascal Matrix

83 of 123myjinxin2015

Description:

Task

Create an n × x rectangular matrix resembling Pascal's Triangle. To make it more triangle-like, put 0 between each pair of numbers in one row.

Input/Output

  • [input] integer n

    An odd number, the number of elements in the last row.

    3 ≤ n ≤ 65

  • [output] 2D integer array

    Pascal's Triangle.

Example

pascalMatrix(3) =

 [[0,1,0], 
  [1,0,1]]

pascalMatrix(5) =

[[0,0,1,0,0], 
 [0,1,0,1,0], 
 [1,0,2,0,1]]

pascalMatrix(9) =

[[0,0,0,0,1,0,0,0,0],
 [0,0,0,1,0,1,0,0,0],
 [0,0,1,0,2,0,1,0,0],
 [0,1,0,3,0,3,0,1,0],
 [1,0,4,0,6,0,4,0,1]]
Puzzles
Mathematics
Algorithms
Matrix

Stats:

CreatedApr 26, 2017
PublishedApr 26, 2017
Warriors Trained253
Total Skips16
Total Code Submissions299
Total Times Completed123
JavaScript Completions83
Python Completions47
Total Stars4
% of votes with a positive feedback rating92% of 54
Total "Very Satisfied" Votes47
Total "Somewhat Satisfied" Votes5
Total "Not Satisfied" Votes2
Total Rank Assessments5
Average Assessed Rank
5 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • kazk Avatar
  • docgunthrop Avatar
  • dfhwze Avatar
  • saudiGuy Avatar
Ad