From 6026898a558788e45c0f92a1372b383e67125d1e Mon Sep 17 00:00:00 2001 From: daviddoji Date: Thu, 22 Sep 2022 09:07:36 +0200 Subject: [PATCH] Adopted new convention from template --- src/Python/Problems001-050/Problem015.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Python/Problems001-050/Problem015.py b/src/Python/Problems001-050/Problem015.py index c8e2334..4e9cdf5 100644 --- a/src/Python/Problems001-050/Problem015.py +++ b/src/Python/Problems001-050/Problem015.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python """ Created on 7 Jan 2018 @@ -10,22 +10,23 @@ https://projecteuler.net/problem=15 """ from math import factorial + from utils import timeit @timeit("Problem 15") 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 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 - 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__": - - print(f"Result for Problem 15: {compute()}") \ No newline at end of file + print(f"Result for Problem 15 is {compute()}")