Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more solutions to Project Euler problems #2695

Closed
arpit-omprakash opened this issue Oct 3, 2020 · 30 comments
Closed

Add more solutions to Project Euler problems #2695

arpit-omprakash opened this issue Oct 3, 2020 · 30 comments

Comments

@arpit-omprakash
Copy link

arpit-omprakash commented Oct 3, 2020

Project Euler has about 700 problems, but the current repository hosts solutions for only about 60-70 problems.
I'm willing to work on the issue and also if someone wants to help they can join in.
We can create guidelines on how many minimum solutions a PR should have to prevent spammy PRs with just one or two easy solutions. (open to discussion)

@dhruvmanila
Copy link
Member

dhruvmanila commented Oct 3, 2020

UPDATE: Please read the Project Euler Solution Guidelines for Coding Style before opening a pull request.

UPDATE: Only submit solution to problems which doesn't exists in this repository.

As of now, we are only accepting PRs with one algorithm in it as it is easier to review one file at a time.
Feel free to open PR for whichever problem you have solved provided the answer is correct.

NOTE:

  • Please give us time to review as there are so many to go through. If possible submit one PR at a time and when that is merged provided it passes all the automatic tests, you can submit another PR. Also, please read the contributing guidelines before opening a PR.
  • Please don't mention Fixes: #2695 in your PR or any of your commit. Just put Reference: #2695 in your PR description.

One step at a time

FAQ:

Q: Where can I get the problems from?
https://projecteuler.net/

Q: When there is a program for which input is presented as a file, how should the input be coded?
Should it be hardcoded in the file or should it be reading from a file relative to the directory?
Refer: #2695 (comment)

Q: Hi, can we add solution to any problem?
For now, we are only accepting solutions for problems that do not exist in this repository.
Refer: #2695 (comment)

Q: I am good at mathematics and would like to contribute in this. kindly assign me this work.
Refer: #2695 (comment)

Q: Doesn't the Project Euler website specifically say not to post solutions to the problems publicly?
Refer: #2695 (comment)

@RGarg2002
Copy link

Where can I get the problems from?

@berry-thawson
Copy link

https://projecteuler.net/
Hope this helps

@RGarg2002
Copy link

Thanks it helped🙂

@hbarovertwo
Copy link

I would love to join and contribute. Project Euler was always fun to me back in college :)

@berry-thawson
Copy link

Hi,
When there is a program for which input is presented as a file, how should the input be coded?
Should it be hardcoded in the file or should it be reading from a file relative to the directory?

@dhruvmanila dhruvmanila added hacktoberfest hacktoberfest-accepted Accepted to be counted towards Hacktoberfest labels Oct 6, 2020
@dhruvmanila
Copy link
Member

dhruvmanila commented Oct 6, 2020

@berry-thawson Please refer to problem_54#L367-L369

import os  # with other imports
...

def solution():
    script_dir = os.path.abspath(os.path.dirname(__file__))
    <file_name_without_extension> = os.path.join(script_dir, "<file_name>")
    with open(<file_name_without_extension> , "r") as file_hand:
        # ... your code ...
  • Instead of <file_name> add the name of the file you want to import.
  • Instead of <file_name_without_extension> add the variable name which is descriptive. If possible choose the name as the file name but without the extension.
  • Then using with do whatever you want to do with the contents of the file.

I hope this clears your doubt. If you still have any problem, don't hesitate to ask.

@berry-thawson
Copy link

Thanks @dhruvmanila
This is helpful

@appsx13
Copy link

appsx13 commented Oct 7, 2020

Hi, can we add solution to any problem?

@peteryao7 peteryao7 mentioned this issue Oct 8, 2020
14 tasks
peteryao7 added a commit to peteryao7/Python that referenced this issue Oct 8, 2020
@peteryao7 peteryao7 mentioned this issue Oct 8, 2020
14 tasks
peteryao7 added a commit to peteryao7/Python that referenced this issue Oct 8, 2020
@peteryao7 peteryao7 mentioned this issue Oct 8, 2020
14 tasks
peteryao7 added a commit to peteryao7/Python that referenced this issue Oct 8, 2020
stokhos pushed a commit to stokhos/Python that referenced this issue Jan 3, 2021
* Added solution for Project Euler problem 38. Fixes: TheAlgorithms#2695

* Update docstring and 0-padding in directory name. Reference: TheAlgorithms#3256

* Renamed is_9_palindromic to is_9_pandigital.

* Changed just-in-case return value for solution() to None.

* Moved exmplanation to module-level docstring and deleted unnecessary import
stokhos pushed a commit to stokhos/Python that referenced this issue Jan 3, 2021
* Added solution for Project Euler problem 87. Fixes: TheAlgorithms#2695

* Update docstring and 0-padding in directory name. Reference: TheAlgorithms#3256
stokhos pushed a commit to stokhos/Python that referenced this issue Jan 3, 2021
* add solution to Project Euler problem 206

* Add solution to Project Euler problem 205

* updating DIRECTORY.md

* updating DIRECTORY.md

* Revert "Add solution to Project Euler problem 205"

This reverts commit 64e3d36.

* Revert "add solution to Project Euler problem 206"

This reverts commit 53568cf.

* add solution for project euler problem 207

* updating DIRECTORY.md

* add type hint for output of helper function

* Correct default parameter value in solution

* use descriptive variable names and remove problem solution from doctest Fixes: TheAlgorithms#2695

Co-authored-by: nico <esistegal-aber@gmx.de>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
stokhos pushed a commit to stokhos/Python that referenced this issue Jan 3, 2021
* Readd Project Euler 206 solution for issue TheAlgorithms#2695, dupe of pull request TheAlgorithms#3042

* Add PE 206 to directory

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
stokhos pushed a commit to stokhos/Python that referenced this issue Jan 3, 2021
Name: Prime square remainders

Let pn be the nth prime: 2, 3, 5, 7, 11, ..., and
let r be the remainder when (pn−1)^n + (pn+1)^n is divided by pn^2.

For example, when n = 3, p3 = 5, and 43 + 63 = 280 ≡ 5 mod 25.
The least value of n for which the remainder first exceeds 10^9 is 7037.

Find the least value of n for which the remainder first exceeds 10^10.

Reference: https://projecteuler.net/problem=123

reference: TheAlgorithms#2695

Co-authored-by: Ravi Kandasamy Sundaram <rkandasamysundaram@luxoft.com>
stokhos pushed a commit to stokhos/Python that referenced this issue Jan 3, 2021
* Add solution for Project Euler 70, Fixes: TheAlgorithms#2695

* Remove parameter from solution()

* Add tests for all functions, add fstring and positional arg for solution()

* Rename directory to 070

* Move up explanation to module code block

* Move solution() below helper functions, rename variables

* Remove whitespace from defining min_numerator

* Add whitespace

* Improve type hints with typing.List

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
peRFectBeliever pushed a commit to peRFectBeliever/Python that referenced this issue Apr 1, 2021
* Added solution for Project Euler problem 38. Fixes: TheAlgorithms#2695

* Update docstring and 0-padding in directory name. Reference: TheAlgorithms#3256

* Renamed is_9_palindromic to is_9_pandigital.

* Changed just-in-case return value for solution() to None.

* Moved exmplanation to module-level docstring and deleted unnecessary import
peRFectBeliever pushed a commit to peRFectBeliever/Python that referenced this issue Apr 1, 2021
* Added solution for Project Euler problem 87. Fixes: TheAlgorithms#2695

* Update docstring and 0-padding in directory name. Reference: TheAlgorithms#3256
peRFectBeliever pushed a commit to peRFectBeliever/Python that referenced this issue Apr 1, 2021
* add solution to Project Euler problem 206

* Add solution to Project Euler problem 205

* updating DIRECTORY.md

* updating DIRECTORY.md

* Revert "Add solution to Project Euler problem 205"

This reverts commit 64e3d36.

* Revert "add solution to Project Euler problem 206"

This reverts commit 53568cf.

* add solution for project euler problem 207

* updating DIRECTORY.md

* add type hint for output of helper function

* Correct default parameter value in solution

* use descriptive variable names and remove problem solution from doctest Fixes: TheAlgorithms#2695

Co-authored-by: nico <esistegal-aber@gmx.de>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
peRFectBeliever pushed a commit to peRFectBeliever/Python that referenced this issue Apr 1, 2021
* Readd Project Euler 206 solution for issue TheAlgorithms#2695, dupe of pull request TheAlgorithms#3042

* Add PE 206 to directory

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
peRFectBeliever pushed a commit to peRFectBeliever/Python that referenced this issue Apr 1, 2021
Name: Prime square remainders

Let pn be the nth prime: 2, 3, 5, 7, 11, ..., and
let r be the remainder when (pn−1)^n + (pn+1)^n is divided by pn^2.

For example, when n = 3, p3 = 5, and 43 + 63 = 280 ≡ 5 mod 25.
The least value of n for which the remainder first exceeds 10^9 is 7037.

Find the least value of n for which the remainder first exceeds 10^10.

Reference: https://projecteuler.net/problem=123

reference: TheAlgorithms#2695

Co-authored-by: Ravi Kandasamy Sundaram <rkandasamysundaram@luxoft.com>
peRFectBeliever pushed a commit to peRFectBeliever/Python that referenced this issue Apr 1, 2021
* Add solution for Project Euler 70, Fixes: TheAlgorithms#2695

* Remove parameter from solution()

* Add tests for all functions, add fstring and positional arg for solution()

* Rename directory to 070

* Move up explanation to module code block

* Move solution() below helper functions, rename variables

* Remove whitespace from defining min_numerator

* Add whitespace

* Improve type hints with typing.List

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
Panquesito7 pushed a commit to Panquesito7/Python that referenced this issue May 13, 2021
Panquesito7 pushed a commit to Panquesito7/Python that referenced this issue May 13, 2021
Name: Digit power sum

Problem Statement: The number 512 is interesting because it is equal to the sum of its digits raised to some power: 5 + 1 + 2 = 8, and 83 = 512. Another example of a number with this property is 614656 = 284.
We shall define an to be the nth term of this sequence and insist that a number must contain at least two digits to have a sum.
You are given that a2 = 512 and a10 = 614656.
Find a30

Reference: https://projecteuler.net/problem=119

reference: TheAlgorithms#2695

Co-authored-by: Ravi Kandasamy Sundaram <rkandasamysundaram@luxoft.com>
Panquesito7 pushed a commit to Panquesito7/Python that referenced this issue May 13, 2021
* Added solution for Project Euler problem 113. TheAlgorithms#2695

* Updated formatting and doctests. Reference: TheAlgorithms#3256
Panquesito7 pushed a commit to Panquesito7/Python that referenced this issue May 13, 2021
* Added solution for Project Euler problemm problem 173. TheAlgorithms#2695

* Added docstring

* Update formatting, doctest and annotations. Reference: TheAlgorithms#3256
Panquesito7 pushed a commit to Panquesito7/Python that referenced this issue May 13, 2021
* Added solution for Project Euler problem 74. Fixes: TheAlgorithms#2695

* Added doctest for solution() in project_euler/problem_74/sol1.py

* Update docstrings and 0-padding of directory name. Reference: TheAlgorithms#3256
Panquesito7 pushed a commit to Panquesito7/Python that referenced this issue May 13, 2021
* Added solution for Project Euler problem 91. Reference: TheAlgorithms#2695

* Added doctest for solution() in project_euler/problem_91/sol1.py

* Update docstring and 0-padding in directory name. Reference: TheAlgorithms#3256

* Update sol1.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
Panquesito7 pushed a commit to Panquesito7/Python that referenced this issue May 13, 2021
* Added solution for Project Euler problem 38. Fixes: TheAlgorithms#2695

* Update docstring and 0-padding in directory name. Reference: TheAlgorithms#3256

* Renamed is_9_palindromic to is_9_pandigital.

* Changed just-in-case return value for solution() to None.

* Moved exmplanation to module-level docstring and deleted unnecessary import
Panquesito7 pushed a commit to Panquesito7/Python that referenced this issue May 13, 2021
* Added solution for Project Euler problem 87. Fixes: TheAlgorithms#2695

* Update docstring and 0-padding in directory name. Reference: TheAlgorithms#3256
Panquesito7 pushed a commit to Panquesito7/Python that referenced this issue May 13, 2021
* add solution to Project Euler problem 206

* Add solution to Project Euler problem 205

* updating DIRECTORY.md

* updating DIRECTORY.md

* Revert "Add solution to Project Euler problem 205"

This reverts commit 64e3d36.

* Revert "add solution to Project Euler problem 206"

This reverts commit 53568cf.

* add solution for project euler problem 207

* updating DIRECTORY.md

* add type hint for output of helper function

* Correct default parameter value in solution

* use descriptive variable names and remove problem solution from doctest Fixes: TheAlgorithms#2695

Co-authored-by: nico <esistegal-aber@gmx.de>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Panquesito7 pushed a commit to Panquesito7/Python that referenced this issue May 13, 2021
* Readd Project Euler 206 solution for issue TheAlgorithms#2695, dupe of pull request TheAlgorithms#3042

* Add PE 206 to directory

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Panquesito7 pushed a commit to Panquesito7/Python that referenced this issue May 13, 2021
Name: Prime square remainders

Let pn be the nth prime: 2, 3, 5, 7, 11, ..., and
let r be the remainder when (pn−1)^n + (pn+1)^n is divided by pn^2.

For example, when n = 3, p3 = 5, and 43 + 63 = 280 ≡ 5 mod 25.
The least value of n for which the remainder first exceeds 10^9 is 7037.

Find the least value of n for which the remainder first exceeds 10^10.

Reference: https://projecteuler.net/problem=123

reference: TheAlgorithms#2695

Co-authored-by: Ravi Kandasamy Sundaram <rkandasamysundaram@luxoft.com>
Panquesito7 pushed a commit to Panquesito7/Python that referenced this issue May 13, 2021
* Add solution for Project Euler 70, Fixes: TheAlgorithms#2695

* Remove parameter from solution()

* Add tests for all functions, add fstring and positional arg for solution()

* Rename directory to 070

* Move up explanation to module code block

* Move solution() below helper functions, rename variables

* Remove whitespace from defining min_numerator

* Add whitespace

* Improve type hints with typing.List

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
shermanhui pushed a commit to shermanhui/Python that referenced this issue Oct 22, 2021
* Added solution for Project Euler problem 38. Fixes: TheAlgorithms#2695

* Update docstring and 0-padding in directory name. Reference: TheAlgorithms#3256

* Renamed is_9_palindromic to is_9_pandigital.

* Changed just-in-case return value for solution() to None.

* Moved exmplanation to module-level docstring and deleted unnecessary import
shermanhui pushed a commit to shermanhui/Python that referenced this issue Oct 22, 2021
* Added solution for Project Euler problem 87. Fixes: TheAlgorithms#2695

* Update docstring and 0-padding in directory name. Reference: TheAlgorithms#3256
shermanhui pushed a commit to shermanhui/Python that referenced this issue Oct 22, 2021
* add solution to Project Euler problem 206

* Add solution to Project Euler problem 205

* updating DIRECTORY.md

* updating DIRECTORY.md

* Revert "Add solution to Project Euler problem 205"

This reverts commit 64e3d36.

* Revert "add solution to Project Euler problem 206"

This reverts commit 53568cf.

* add solution for project euler problem 207

* updating DIRECTORY.md

* add type hint for output of helper function

* Correct default parameter value in solution

* use descriptive variable names and remove problem solution from doctest Fixes: TheAlgorithms#2695

Co-authored-by: nico <esistegal-aber@gmx.de>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
shermanhui pushed a commit to shermanhui/Python that referenced this issue Oct 22, 2021
* Readd Project Euler 206 solution for issue TheAlgorithms#2695, dupe of pull request TheAlgorithms#3042

* Add PE 206 to directory

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
shermanhui pushed a commit to shermanhui/Python that referenced this issue Oct 22, 2021
Name: Prime square remainders

Let pn be the nth prime: 2, 3, 5, 7, 11, ..., and
let r be the remainder when (pn−1)^n + (pn+1)^n is divided by pn^2.

For example, when n = 3, p3 = 5, and 43 + 63 = 280 ≡ 5 mod 25.
The least value of n for which the remainder first exceeds 10^9 is 7037.

Find the least value of n for which the remainder first exceeds 10^10.

Reference: https://projecteuler.net/problem=123

reference: TheAlgorithms#2695

Co-authored-by: Ravi Kandasamy Sundaram <rkandasamysundaram@luxoft.com>
shermanhui pushed a commit to shermanhui/Python that referenced this issue Oct 22, 2021
* Add solution for Project Euler 70, Fixes: TheAlgorithms#2695

* Remove parameter from solution()

* Add tests for all functions, add fstring and positional arg for solution()

* Rename directory to 070

* Move up explanation to module code block

* Move solution() below helper functions, rename variables

* Remove whitespace from defining min_numerator

* Add whitespace

* Improve type hints with typing.List

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.