-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd82206
commit 20f7bf8
Showing
3 changed files
with
40 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,14 @@ | ||
# Pascal's Triangle | ||
# Pascal's Triangle | ||
|
||
Given an index k, return the kth row of the Pascal's triangle. | ||
Pascal's triangle: To generate A[C] in row R, sum up A'[C] and A'[C-1] from previous row R - 1. | ||
|
||
```text | ||
Example: | ||
Input : k = 3 | ||
Return : [1,3,3,1] | ||
``` | ||
|
||
Note: k is 0 based. k = 0, corresponds to the row [1]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import unittest | ||
from . import pascals_triangle, pascal_nth_row | ||
|
||
|
||
class PascalsTriangleTestCase(unittest.TestCase): | ||
def test_1(self): | ||
"""k=3 should return [1, 3, 3, 1]""" | ||
k = 3 | ||
expected = [1, 3, 3, 1] | ||
actual = pascal_nth_row(k) | ||
self.assertEqual(expected, actual) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |