A Bezier curve of degree degree, like the cubic curves behind CSS cubic-bezier() timing functions, weights its control points with binomial coefficients: the numbers in row degree of Pascal's triangle. Each number in the triangle is the sum of the two numbers above it, and every row starts and ends with 1.
Write bezierWeights(degree) that returns row degree of Pascal's triangle as an array. Row 0 is [1].
Input: degree = 3 Output: [1,3,3,1]
The cubic weights: row 2 is [1, 2, 1], and each inner number of row 3 adds two neighbors from it.
Input: degree = 0 Output: [1]
Row 0 is a single 1.
0 <= degree <= 33Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #566 Bezier Weight Row. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.