From 74e0e76c6c386aded47339b7f3f07e48e54c81c0 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 18 Oct 2019 18:07:07 -0500 Subject: [PATCH 1/6] Create servindc.py --- Python/15.Lattice_paths/servindc.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Python/15.Lattice_paths/servindc.py diff --git a/Python/15.Lattice_paths/servindc.py b/Python/15.Lattice_paths/servindc.py new file mode 100644 index 0000000..829d408 --- /dev/null +++ b/Python/15.Lattice_paths/servindc.py @@ -0,0 +1,12 @@ +# Solution to Euler problem 15 +from math import factorial as f + +def Lattice_paths(n): + pascal_row = [] + for i in range(n+1): + pascal_row.append( f(n)//(f(n-i)*f(i)) ) + return sum([i**2 for i in pascal_row]) + +k = Lattice_paths(20) + +print(f"There are {k} routes through a 20×20 grid.") From 688ad8615a36a1a09b01b2794f8a848235d5ae60 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 18 Oct 2019 18:10:38 -0500 Subject: [PATCH 2/6] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bb01073..ba6938f 100644 --- a/README.md +++ b/README.md @@ -43,8 +43,8 @@ Happy Contributing! 😃 | 12 | [Highly divisible triangular number](https://projecteuler.net/problem=12) | | | | | | | :white_check_mark: | | | | | | | 13 | [Large sum](https://projecteuler.net/problem=13) | :white_check_mark: | | | :white_check_mark: | | | | | | | | | | 14 | [Longest Collatz sequence](https://projecteuler.net/problem=14) | | | | | | | | | | | | | -| 15 | [Lattice paths](https://projecteuler.net/problem=15) | | | | | | | | | | | | | -| 16 | [Power digit sum](https://projecteuler.net/problem=16) | | :white_check_mark:| | :white_check_mark: | | | | | | | | | +| 15 | [Lattice paths](https://projecteuler.net/problem=15) | | | | :white_check_mark: | | | | | | | | | +| 16 | [Power digit sum](https://projecteuler.net/problem=16) | | :white_check_mark: | | :white_check_mark: | | | | | | | | | | 17 | [Number letter counts](https://projecteuler.net/problem=17) | | | | | | | | | | | | | | 18 | [Maximum path sum I](https://projecteuler.net/problem=18) | | | | | | | | | | | | | | 19 | [Counting Sundays](https://projecteuler.net/problem=19) | | | | | | | | | | | | | From bd9aa6086278e16ea503cb9509e5cc900a224390 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 21 Oct 2019 10:58:11 -0500 Subject: [PATCH 3/6] Update servindc.py --- Python/15.Lattice_paths/servindc.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Python/15.Lattice_paths/servindc.py b/Python/15.Lattice_paths/servindc.py index 829d408..f139db6 100644 --- a/Python/15.Lattice_paths/servindc.py +++ b/Python/15.Lattice_paths/servindc.py @@ -2,6 +2,7 @@ from math import factorial as f def Lattice_paths(n): + n = int(n) pascal_row = [] for i in range(n+1): pascal_row.append( f(n)//(f(n-i)*f(i)) ) From c31f0baac2ccd14044c469d9953c678e0ef49c1b Mon Sep 17 00:00:00 2001 From: David Date: Fri, 25 Oct 2019 14:23:51 -0500 Subject: [PATCH 4/6] Delete servindc.py --- Python/15.Lattice_paths/servindc.py | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 Python/15.Lattice_paths/servindc.py diff --git a/Python/15.Lattice_paths/servindc.py b/Python/15.Lattice_paths/servindc.py deleted file mode 100644 index f139db6..0000000 --- a/Python/15.Lattice_paths/servindc.py +++ /dev/null @@ -1,13 +0,0 @@ -# Solution to Euler problem 15 -from math import factorial as f - -def Lattice_paths(n): - n = int(n) - pascal_row = [] - for i in range(n+1): - pascal_row.append( f(n)//(f(n-i)*f(i)) ) - return sum([i**2 for i in pascal_row]) - -k = Lattice_paths(20) - -print(f"There are {k} routes through a 20×20 grid.") From 95c3932e9a846ce61054f7dde529e44f939ce5a8 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 25 Oct 2019 15:33:12 -0500 Subject: [PATCH 5/6] Create servindc.R --- R/15.Lattice_paths/servindc.R | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 R/15.Lattice_paths/servindc.R diff --git a/R/15.Lattice_paths/servindc.R b/R/15.Lattice_paths/servindc.R new file mode 100644 index 0000000..31eaee5 --- /dev/null +++ b/R/15.Lattice_paths/servindc.R @@ -0,0 +1,10 @@ +# Solution to Euler problem 15 +Lattice_paths <- function(n){ + n <- as.integer(n) + p <- 0 + for (i in 0:n){ + p <- p + (factorial(n)/(factorial(n-i)*factorial(i)))^2 + } + print(p) +} +cat("Routes through a 20x20 grid: ", Lattice_paths(20)) From 9e030e46174338fd8a7d8ab1d1c2c9e635116380 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 25 Oct 2019 15:35:49 -0500 Subject: [PATCH 6/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eda89ff..7421688 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Happy Contributing! 😃 | 15 | [Lattice paths](https://projecteuler.net/problem=15) | | | | :white_check_mark: | | | | | | | | | | 16 | [Power digit sum](https://projecteuler.net/problem=16) | | :white_check_mark: | | :white_check_mark: | | | | | | | | | | 17 | [Number letter counts](https://projecteuler.net/problem=17) | | | | | | | | | | | | | -| 15 | [Lattice paths](https://projecteuler.net/problem=15) | | | | | | | | | | | | | +| 15 | [Lattice paths](https://projecteuler.net/problem=15) | | | | | | | | | | :white_check_mark: | | | | 16 | [Power digit sum](https://projecteuler.net/problem=16) | | :white_check_mark: | | :white_check_mark: | | | | | | | | | | 17 | [Number letter counts](https://projecteuler.net/problem=17) | | | | :white_check_mark: | | | | | | | | | | 18 | [Maximum path sum I](https://projecteuler.net/problem=18) | | | | | | | | | | | | |