#275 · Lists · Intermediate · 60 XP · about 10 min
Pascal's triangle starts with a single 1 at the top. Each row below starts and ends with 1, and every other number is the sum of the two numbers diagonally above it:
1 row 0 1 1 row 1 1 2 1 row 2 1 3 3 1 row 3 1 4 6 4 1 row 4
Write pascal_row(n) that returns row n as a list of integers. Rows are numbered from 0, so row n has n + 1 numbers.
pascal_row(0) # returns [1] pascal_row(4) # returns [1, 4, 6, 4, 1] pascal_row(6) # returns [1, 6, 15, 20, 15, 6, 1]
0 <= n <= 500First solves only, ranked by stars and then time.