We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2e1892e commit 6a6e662Copy full SHA for 6a6e662
project_euler/problem_015/sol2.py
@@ -6,9 +6,6 @@
6
How many such routes are there through a 20x20 grid?
7
"""
8
9
-from numpy import integer, ones
10
-
11
12
def solution(n: int = 20) -> int:
13
14
Solve by explicitly counting the paths with dynamic programming.
@@ -21,13 +18,13 @@ def solution(n: int = 20) -> int:
21
18
2
22
19
23
20
24
- counts = ones((n + 1, n + 1), dtype=integer)
+ counts = [[1 for _ in range(n + 1)] for _ in range(n + 1)]
25
26
for i in range(1, n + 1):
27
for j in range(1, n + 1):
28
counts[i][j] = counts[i - 1][j] + counts[i][j - 1]
29
30
- return int(counts[n][n])
+ return counts[n][n]
31
32
33
if __name__ == "__main__":
0 commit comments