Skip to content

Commit 2d7e08e

Browse files
dhruvmanilapoyea
andauthored
Update README.md for Project Euler (#3256)
* Update README.md for Project Euler * Add link to solution template * Add newlines for better separation * Add __name__ == __main__ block in template * Apply suggestions from code review Co-authored-by: John Law <[email protected]> * Improve introduction part Co-authored-by: John Law <[email protected]>
1 parent 671ab1d commit 2d7e08e

File tree

1 file changed

+111
-4
lines changed

1 file changed

+111
-4
lines changed

Diff for: project_euler/README.md

+111-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,118 @@
1-
# ProjectEuler
1+
# Project Euler
22

33
Problems are taken from https://projecteuler.net/.
44

55
Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical
66
insights to solve. Project Euler is ideal for mathematicians who are learning to code.
77

8-
Here the efficiency of your code is also checked.
9-
I've tried to provide all the best possible solutions.
8+
The solutions will be checked by our [automated testing on Travis CI](https://travis-ci.com/github/TheAlgorithms/Python/pull_requests) with the help of [this script](https://github.com/TheAlgorithms/Python/blob/master/project_euler/validate_solutions.py). The efficiency of your code is also checked. You can view the top 10 slowest solutions on Travis CI logs and open a pull request to improve those solutions.
109

11-
For description of the problem statements, kindly visit https://projecteuler.net/show=all
10+
11+
## Solution Guidelines
12+
13+
Welcome to [TheAlgorithms/Python](https://github.com/TheAlgorithms/Python)! Before reading the solution guidelines, make sure you read the whole [Contributing Guidelines](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md) as it won't be repeated in here. If you have any doubt on the guidelines, please feel free to [state it clearly in an issue](https://github.com/TheAlgorithms/Python/issues/new) or ask the community in [Gitter](https://gitter.im/TheAlgorithms). You can use the [template](https://github.com/TheAlgorithms/Python/blob/master/project_euler/README.md#solution-template) we have provided below as your starting point but be sure to read the [Coding Style](https://github.com/TheAlgorithms/Python/blob/master/project_euler/README.md#coding-style) part first.
14+
15+
### Coding Style
16+
17+
* Please maintain consistency in project directory and solution file names. Keep the following points in mind:
18+
* Create a new directory only for the problems which do not exist yet.
19+
* If you create a new directory, please create an empty `__init__.py` file inside it as well.
20+
* Please name the project directory as `problem_<problem_number>` where `problem_number` should be filled with 0s so as to occupy 3 digits. Example: `problem_001`, `problem_002`, `problem_067`, `problem_145`, and so on.
21+
22+
* Please provide a link to the problem and other references, if used, in the module-level docstring.
23+
24+
* All imports should come ***after*** the module-level docstring.
25+
26+
* You can have as many helper functions as you want but there should be one main function called `solution` which should satisfy the conditions as stated below:
27+
* It should contain positional argument(s) whose default value is the question input. Example: Please take a look at [problem 1](https://projecteuler.net/problem=1) where the question is to *Find the sum of all the multiples of 3 or 5 below 1000.* In this case the main solution function will be `solution(limit: int = 1000)`.
28+
* When the `solution` function is called without any arguments like so: `solution()`, it should return the answer to the problem.
29+
30+
* Every function, which includes all the helper functions, if any, and the main solution function, should have `doctest` in the function docstring along with a brief statement mentioning what the function is about.
31+
* There should not be a `doctest` for testing the answer as that is done by our Travis CI build using this [script](https://github.com/TheAlgorithms/Python/blob/master/project_euler/validate_solutions.py). Keeping in mind the above example of [problem 1](https://projecteuler.net/problem=1):
32+
33+
```python
34+
def solution(limit: int = 1000):
35+
"""
36+
A brief statement mentioning what the function is about.
37+
38+
You can have a detailed explanation about the solution method in the
39+
module-level docstring.
40+
41+
>>> solution(1)
42+
...
43+
>>> solution(16)
44+
...
45+
>>> solution(100)
46+
...
47+
"""
48+
```
49+
50+
### Solution Template
51+
52+
You can use the below template as your starting point but please read the [Coding Style](https://github.com/TheAlgorithms/Python/blob/master/project_euler/README.md#coding-style) first to understand how the template works.
53+
54+
Please change the name of the helper functions accordingly, change the parameter names with a descriptive one, replace the content within `[square brackets]` (including the brackets) with the appropriate content.
55+
56+
```python
57+
"""
58+
Project Euler Problem [problem number]: [link to the original problem]
59+
60+
... [Entire problem statement] ...
61+
62+
... [Solution explanation - Optional] ...
63+
64+
References [Optional]:
65+
- [Wikipedia link to the topic]
66+
- [Stackoverflow link]
67+
...
68+
69+
"""
70+
import module1
71+
import module2
72+
...
73+
74+
def helper1(arg1: [type hint], arg2: [type hint], ...) -> [Return type hint]:
75+
"""
76+
A brief statement explaining what the function is about.
77+
78+
... A more elaborate description ... [Optional]
79+
80+
...
81+
[Doctest]
82+
...
83+
84+
"""
85+
...
86+
# calculations
87+
...
88+
89+
return
90+
91+
92+
# You can have multiple helper functions but the solution function should be
93+
# after all the helper functions ...
94+
95+
96+
def solution(arg1: [type hint], arg2: [type hint], ...) -> [Return type hint]:
97+
"""
98+
A brief statement mentioning what the function is about.
99+
100+
You can have a detailed explanation about the solution in the
101+
module-level docstring.
102+
103+
...
104+
[Doctest as mentioned above]
105+
...
106+
107+
"""
108+
109+
...
110+
# calculations
111+
...
112+
113+
return answer
114+
115+
116+
if __name__ == "__main__":
117+
print(f"{solution() = }")
118+
```

0 commit comments

Comments
 (0)