Adopted new convention from template

This commit is contained in:
David Doblas Jiménez 2022-09-22 09:07:36 +02:00
parent 4a89c7613c
commit 6026898a55

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python
""" """
Created on 7 Jan 2018 Created on 7 Jan 2018
@ -10,22 +10,23 @@ https://projecteuler.net/problem=15
""" """
from math import factorial from math import factorial
from utils import timeit from utils import timeit
@timeit("Problem 15") @timeit("Problem 15")
def compute(): def compute():
""" """
Starting in the top left corner of a 2×2 grid, and only being able to Starting in the top left corner of a 2x2 grid, and only being able to
move to the right and down, there are exactly 6 routes to the bottom move to the right and down, there are exactly 6 routes to the bottom
right corner. right corner.
How many such routes are there through a 20×20 grid? How many such routes are there through a 20x20 grid?
""" """
n = 20 n = 20
return int(factorial(2*n) / (factorial(n) * factorial(2*n - n))) return int(factorial(2 * n) / (factorial(n) * factorial(2 * n - n)))
if __name__ == "__main__": if __name__ == "__main__":
print(f"Result for Problem 15 is {compute()}")
print(f"Result for Problem 15: {compute()}")