From b010ad87b4a8a83f76dfbb8223f7b60b894c2159 Mon Sep 17 00:00:00 2001 From: kohzhixin Date: Mon, 28 Oct 2019 10:58:22 +0000 Subject: [PATCH 1/6] added problem 31 in py3 --- Python/31. Coin sums/kohzhixin.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Python/31. Coin sums/kohzhixin.py diff --git a/Python/31. Coin sums/kohzhixin.py b/Python/31. Coin sums/kohzhixin.py new file mode 100644 index 0000000..a0f6bc6 --- /dev/null +++ b/Python/31. Coin sums/kohzhixin.py @@ -0,0 +1,11 @@ +coins = [1, 2, 5, 10, 20, 50, 100, 200] + +def solution(amt): + ans = [0] * (amt + 1) + ans[0] = 1 + for i in range(len(coins)): + for j in range(coins[i], amt + 1): + ans[j] += ans[j - coins[i]] + return ans[-1] + +print(solution(200)) \ No newline at end of file From 7ead7fc1f61ea79259806ecda4178f53749a2917 Mon Sep 17 00:00:00 2001 From: kohzhixin Date: Mon, 28 Oct 2019 11:00:35 +0000 Subject: [PATCH 2/6] added problem 31 in py3 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 559d187..0d5eb2d 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Happy Contributing! 😃 | 28 | [Number spiral diagonals](https://projecteuler.net/problem=28) | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | | :white_check_mark: | | | | | | | 29 | [Distinct powers](https://projecteuler.net/problem=29) | | | | :white_check_mark: | | | | | | | | | | 30 | [Digit fifth powers](https://projecteuler.net/problem=30) | | | | :white_check_mark: | | | | | | | | | -| 31 | [Coin sums](https://projecteuler.net/problem=31) | | :white_check_mark: | | | | | | | | | | | +| 31 | [Coin sums](https://projecteuler.net/problem=31) | | :white_check_mark: | | | | :white_check_mark: | | | | | | | | 32 | [Pandigital products](https://projecteuler.net/problem=32) | | | | | | | | | | | | | | 33 | [Digit cancelling fractions](https://projecteuler.net/problem=33) | | | | | | | | | | | | | | 34 | [Digit factorials](https://projecteuler.net/problem=34) | | | | | | | | | | | | | From f87a95658b29ceb0fe2409bb5afa39ac8b0ea874 Mon Sep 17 00:00:00 2001 From: kohzhixin Date: Mon, 28 Oct 2019 11:02:59 +0000 Subject: [PATCH 3/6] added problem 31 in py3 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0d5eb2d..0e53ca1 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Happy Contributing! 😃 | 28 | [Number spiral diagonals](https://projecteuler.net/problem=28) | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | | :white_check_mark: | | | | | | | 29 | [Distinct powers](https://projecteuler.net/problem=29) | | | | :white_check_mark: | | | | | | | | | | 30 | [Digit fifth powers](https://projecteuler.net/problem=30) | | | | :white_check_mark: | | | | | | | | | -| 31 | [Coin sums](https://projecteuler.net/problem=31) | | :white_check_mark: | | | | :white_check_mark: | | | | | | | +| 31 | [Coin sums](https://projecteuler.net/problem=31) | | :white_check_mark: | | :white_check_mark: | | | | | | | | | | 32 | [Pandigital products](https://projecteuler.net/problem=32) | | | | | | | | | | | | | | 33 | [Digit cancelling fractions](https://projecteuler.net/problem=33) | | | | | | | | | | | | | | 34 | [Digit factorials](https://projecteuler.net/problem=34) | | | | | | | | | | | | | From c9dbd2b03c7c43937e9ed0126ecc3f4a97754ba4 Mon Sep 17 00:00:00 2001 From: kohzhixin Date: Mon, 28 Oct 2019 17:33:05 +0000 Subject: [PATCH 4/6] added problem 39 in py3 --- Python/39. Integer right triangles/kohzhixin.py | 16 ++++++++++++++++ README.md | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 Python/39. Integer right triangles/kohzhixin.py diff --git a/Python/39. Integer right triangles/kohzhixin.py b/Python/39. Integer right triangles/kohzhixin.py new file mode 100644 index 0000000..73f2e5c --- /dev/null +++ b/Python/39. Integer right triangles/kohzhixin.py @@ -0,0 +1,16 @@ +""" +Problem 39 +""" + +def solution(max_p): + max_num = 0 + for p in range(0, max_p, 2): + c = 0 + for a in range(2, int(p/3)): + if (p**2 - 2*p*a) % (2 * (p-a)) == 0: + c += 1 + if c > max_num: + max_num = c + return max_num + +print(solution(1000)) \ No newline at end of file diff --git a/README.md b/README.md index 0e53ca1..8bc8e49 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ Happy Contributing! 😃 | 36 | [Double-base palindromes](https://projecteuler.net/problem=36) | | | | | | | | | | | | | | 37 | [Truncatable primes](https://projecteuler.net/problem=37) | | | | | | | | | | | | | | 38 | [Pandigital multiples](https://projecteuler.net/problem=38) | | | | | | | | | | | | | -| 39 | [Integer right triangles](https://projecteuler.net/problem=39) | :white_check_mark: | :white_check_mark: | | | | | | | | | | | +| 39 | [Integer right triangles](https://projecteuler.net/problem=39) | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | | | | | | | | | 40 | [Champernowne's constant](https://projecteuler.net/problem=40) | | | | :white_check_mark: | | | | | | | | | | 41 | [Pandigital prime](https://projecteuler.net/problem=41) | | | | :white_check_mark: | | | | | | | | | | 42 | [Coded triangle numbers](https://projecteuler.net/problem=42) | | | | :white_check_mark: | | | | | | | | | From baf911c0f6e28014b265311bbefa3c80a1e2842b Mon Sep 17 00:00:00 2001 From: kohzhixin Date: Mon, 28 Oct 2019 21:14:18 +0000 Subject: [PATCH 5/6] added problem 43 in py3 --- .../43. Sub-string divisibility/kohzhixin.py | 24 +++++++++++++++++++ README.md | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 Python/43. Sub-string divisibility/kohzhixin.py diff --git a/Python/43. Sub-string divisibility/kohzhixin.py b/Python/43. Sub-string divisibility/kohzhixin.py new file mode 100644 index 0000000..96de1e4 --- /dev/null +++ b/Python/43. Sub-string divisibility/kohzhixin.py @@ -0,0 +1,24 @@ +""" +Problem 43 +""" + +from itertools import permutations + +div = [2, 3, 5, 7, 11, 13, 17] + +def solution(): + total = 0 + for i in list(permutations([j for j in range(10)])): + if check_num(i): + total += int("".join([str(n) for n in i])) + return total + +def check_num(i): + for j in range(len(div)): + num = i[j+1] * 100 + i[j+2] * 10 + i[j+3] + if num % div[j] != 0: + return False + return True + + +print(solution()) \ No newline at end of file diff --git a/README.md b/README.md index 8bc8e49..9ebcac9 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ Happy Contributing! 😃 | 40 | [Champernowne's constant](https://projecteuler.net/problem=40) | | | | :white_check_mark: | | | | | | | | | | 41 | [Pandigital prime](https://projecteuler.net/problem=41) | | | | :white_check_mark: | | | | | | | | | | 42 | [Coded triangle numbers](https://projecteuler.net/problem=42) | | | | :white_check_mark: | | | | | | | | | -| 43 | [Sub-string divisibility](https://projecteuler.net/problem=43) | | | | | | | | | | | | | +| 43 | [Sub-string divisibility](https://projecteuler.net/problem=43) | | | | :white_check_mark: | | | | | | | | | | 44 | [Pentagon numbers](https://projecteuler.net/problem=44) | | | | :white_check_mark: | | | | | | | | | | 45 | [Triangular, pentagonal, and hexagonal](https://projecteuler.net/problem=45) | | | | :white_check_mark: | | | | | | | | | | 46 | [Goldbach's other conjecture](https://projecteuler.net/problem=46) | | | | :white_check_mark: | | | | | | | | | From b1175be6f0d69913d28f5daac384718661e7a7a5 Mon Sep 17 00:00:00 2001 From: kohzhixin <1002914@mymail.sutd.edu.sg> Date: Mon, 28 Oct 2019 21:34:45 +0000 Subject: [PATCH 6/6] Revert "problem 43 done in py3" --- C#/1.Multiples_of_3_and_5/arya-prof.cs | 25 ------------------------- README.md | 2 +- 2 files changed, 1 insertion(+), 26 deletions(-) delete mode 100644 C#/1.Multiples_of_3_and_5/arya-prof.cs diff --git a/C#/1.Multiples_of_3_and_5/arya-prof.cs b/C#/1.Multiples_of_3_and_5/arya-prof.cs deleted file mode 100644 index e5b813c..0000000 --- a/C#/1.Multiples_of_3_and_5/arya-prof.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Euler 1 -using System; - -namespace _5_multiples -{ - public class MainClass - { - public static void Main() - { - int currentNumber = 1000; - int allSum = 0; - - currentNumber = currentNumber - 1; - while (currentNumber > 0) - { - if ( (currentNumber % 3 == 0) | (currentNumber % 5 == 0)) - { - allSum = allSum + currentNumber; - } - currentNumber = currentNumber - 1; - } - Console.WriteLine(allSum); - } - } -} diff --git a/README.md b/README.md index f8db000..9ebcac9 100644 --- a/README.md +++ b/README.md @@ -81,9 +81,9 @@ Happy Contributing! 😃 | 49 | [Prime permutations](https://projecteuler.net/problem=49) | | | | :white_check_mark: | | | | | | | | | | 50 | [Consecutive prime sum](https://projecteuler.net/problem=50) | | | | :white_check_mark: | | | :white_check_mark: | | :white_check_mark: | | | | - ## Thanks + - Thanks to you all who are doing their best in solving the problems, we appriciate your efforts. - We thank you all for the overwelming P.R that we have recieved, To mantain the quality and response of the P.R we have updated the [guidelines](#How-to-contribute).