Skip to content

Commit 6a6e662

Browse files
Update sol2.py
1 parent 2e1892e commit 6a6e662

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

project_euler/problem_015/sol2.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
How many such routes are there through a 20x20 grid?
77
"""
88

9-
from numpy import integer, ones
10-
11-
129
def solution(n: int = 20) -> int:
1310
"""
1411
Solve by explicitly counting the paths with dynamic programming.
@@ -21,13 +18,13 @@ def solution(n: int = 20) -> int:
2118
2
2219
"""
2320

24-
counts = ones((n + 1, n + 1), dtype=integer)
21+
counts = [[1 for _ in range(n + 1)] for _ in range(n + 1)]
2522

2623
for i in range(1, n + 1):
2724
for j in range(1, n + 1):
2825
counts[i][j] = counts[i - 1][j] + counts[i][j - 1]
2926

30-
return int(counts[n][n])
27+
return counts[n][n]
3128

3229

3330
if __name__ == "__main__":

0 commit comments

Comments
 (0)