-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathREADME.html
255 lines (234 loc) · 7.98 KB
/
README.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, user-scalable=yes"
/>
<title>README</title>
<style type="text/css">
code {
white-space: pre-wrap;
}
span.smallcaps {
font-variant: small-caps;
}
span.underline {
text-decoration: underline;
}
div.column {
display: inline-block;
vertical-align: top;
width: 50%;
}
</style>
</head>
<body>
<h1 id="project-euler">Project Euler</h1>
<p>
Problems are taken from https://projecteuler.net/, the Project Euler.
<a href="https://projecteuler.net/copyright"
>Problems are licensed under CC BY-NC-SA 4.0</a
>.
</p>
<p>
Project Euler is a series of challenging mathematical/computer programming
problems that require more than just mathematical insights to solve.
Project Euler is ideal for mathematicians who are learning to code.
</p>
<p>
The solutions will be checked by our
<a href="https://travis-ci.com/github/TheAlgorithms/Python/pull_requests"
>automated testing on Travis CI</a
>
with the help of
<a
href="https://github.com/TheAlgorithms/Python/blob/master/scripts/validate_solutions.py"
>this script</a
>. The efficiency of your code is also checked. You can view the top 10
slowest solutions on Travis CI logs (under
<code>slowest 10 durations</code>) and open a pull request to improve
those solutions.
</p>
<h2 id="solution-guidelines">Solution Guidelines</h2>
<p>
Welcome to
<a href="https://github.com/TheAlgorithms/Python">TheAlgorithms/Python</a
>! Before reading the solution guidelines, make sure you read the whole
<a
href="https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md"
>Contributing Guidelines</a
>
as it won’t be repeated in here. If you have any doubt on the guidelines,
please feel free to
<a href="https://github.com/TheAlgorithms/Python/issues/new"
>state it clearly in an issue</a
>
or ask the community in
<a href="https://gitter.im/TheAlgorithms">Gitter</a>. You can use the
<a
href="https://github.com/TheAlgorithms/Python/blob/master/project_euler/README.md#solution-template"
>template</a
>
we have provided below as your starting point but be sure to read the
<a
href="https://github.com/TheAlgorithms/Python/blob/master/project_euler/README.md#coding-style"
>Coding Style</a
>
part first.
</p>
<h3 id="coding-style">Coding Style</h3>
<ul>
<li>
<p>
Please maintain consistency in project directory and solution file
names. Keep the following points in mind:
</p>
<ul>
<li>
Create a new directory only for the problems which do not exist yet.
</li>
<li>
If you create a new directory, please create an empty
<code>__init__.py</code> file inside it as well.
</li>
<li>
Please name the project <strong>directory</strong> as
<code>problem_<problem_number></code> where
<code>problem_number</code> should be filled with 0s so as to occupy
3 digits. Example: <code>problem_001</code>,
<code>problem_002</code>, <code>problem_067</code>,
<code>problem_145</code>, and so on.
</li>
</ul>
</li>
<li>
<p>
Please provide a link to the problem and other references, if used, in
the <strong>module-level docstring</strong>.
</p>
</li>
<li>
<p>
All imports should come <strong><em>after</em></strong> the
module-level docstring.
</p>
</li>
<li>
<p>
You can have as many helper functions as you want but there should be
one main function called <code>solution</code> which should satisfy
the conditions as stated below:
</p>
<ul>
<li>
It should contain positional argument(s) whose default value is the
question input. Example: Please take a look at
<a href="https://projecteuler.net/problem=1">Problem 1</a> where the
question is to
<em>Find the sum of all the multiples of 3 or 5 below 1000.</em> In
this case the main solution function will be
<code>solution(limit: int = 1000)</code>.
</li>
<li>
When the <code>solution</code> function is called without any
arguments like so: <code>solution()</code>, it should return the
answer to the problem.
</li>
</ul>
</li>
<li>
<p>
Every function, which includes all the helper functions, if any, and
the main solution function, should have <code>doctest</code> in the
function docstring along with a brief statement mentioning what the
function is about.
</p>
<ul>
<li>
<p>
There should not be a <code>doctest</code> for testing the answer
as that is done by our Travis CI build using this
<a
href="https://github.com/TheAlgorithms/Python/blob/master/project_euler/validate_solutions.py"
>script</a
>. Keeping in mind the above example of
<a href="https://projecteuler.net/problem=1">Problem 1</a>:
</p>
<p>
def solution(limit: int = 1000): """ A brief statement mentioning
what the function is about.
</p>
<pre><code>You can have a detailed explanation about the solution method in the
module-level docstring.
>>> solution(1)
...
>>> solution(16)
...
>>> solution(100)
...
"""</code></pre>
</li>
</ul>
</li>
</ul>
<h3 id="solution-template">Solution Template</h3>
<p>
You can use the below template as your starting point but please read the
<a
href="https://github.com/TheAlgorithms/Python/blob/master/project_euler/README.md#coding-style"
>Coding Style</a
>
first to understand how the template works.
</p>
<p>
Please change the name of the helper functions accordingly, change the
parameter names with a descriptive one, replace the content within
<code>[square brackets]</code> (including the brackets) with the
appropriate content.
</p>
<pre><code>"""
Project Euler Problem [problem number]: [link to the original problem]
... [Entire problem statement] ...
... [Solution explanation - Optional] ...
References [Optional]:
- [Wikipedia link to the topic]
- [Stackoverflow link]
...
"""
import module1
import module2
...
def helper1(arg1: [type hint], arg2: [type hint], ...) -> [Return type hint]:
"""
A brief statement explaining what the function is about.
... A more elaborate description ... [Optional]
...
[Doctest]
...
"""
...
# calculations
...
return
# You can have multiple helper functions but the solution function should be
# after all the helper functions ...
def solution(arg1: [type hint], arg2: [type hint], ...) -> [Return type hint]:
"""
A brief statement mentioning what the function is about.
You can have a detailed explanation about the solution in the
module-level docstring.
...
[Doctest as mentioned above]
...
"""
...
# calculations
...
return answer
if __name__ == "__main__":
print(f"{solution() = }")</code></pre>
</body>
</html>