# Project Euler
Problems are taken from https://projecteuler.net/, the Project Euler. [Problems are licensed under CC BY-NC-SA 4.0](https://projecteuler.net/copyright).
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.
The solutions will be checked by our [automated testing on GitHub Actions](https://github.com/TheAlgorithms/Python/actions) with the help of [this script](https://github.com/TheAlgorithms/Python/blob/master/scripts/validate_solutions.py). The efficiency of your code is also checked. You can view the top 10 slowest solutions on GitHub Actions logs (under `slowest 10 durations`) and open a pull request to improve those solutions.
## Solution Guidelines
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/community). 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.
### Coding Style
* Please maintain consistency in project directory and solution file names. Keep the following points in mind:
* Create a new directory only for the problems which do not exist yet.
* If you create a new directory, please create an empty `__init__.py` file inside it as well.
* 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.
* Please provide a link to the problem and other references, if used, in the **module-level docstring**.
* All imports should come ***after*** the module-level docstring.
* 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:
* 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)`.
* When the `solution` function is called without any arguments like so: `solution()`, it should return the answer to the problem.
* 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.
* There should not be a `doctest` for testing the answer as that is done by our GitHub Actions build using this [script](https://github.com/TheAlgorithms/Python/blob/master/scripts/validate_solutions.py). Keeping in mind the above example of [Problem 1](https://projecteuler.net/problem=1):
```python
def solution(limit: int = 1000):
"""
A brief statement mentioning what the function is about.
You can have a detailed explanation about the solution method in the
module-level docstring.
>>> solution(1)
...
>>> solution(16)
...
>>> solution(100)
...
"""
```
### Solution Template
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.
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.
```python
"""
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() = }")
```
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
包括问题001,问题002,问题003,问题004,问题005,问题006,问题007,问题008,问题009,问题010,问题011,问题012,问题013,问题014,问题015,问题016,问题017,问题018,问题019,问题020,问题021,问题022,问题023,问题024,问题025,问题026,问题027,问题028,问题029,问题030,问题031,问题032,问题033,问题034,问题035,问题036,问题037,问题038,问题039,问题040,问题041,问题042,问题043,问题044,问题045,问题046,问题047,问题048,问题049,问题050,问题051,问题052,问题053,问题054,问题055,问题056,问题057,问题058,问题059,问题062,问题063,问题064,问题065,问题067,问题068,问题069,问题070,问题071,问题072,问题073,问题074,问题075,问题076,问题077,问题078,问题079,问题080,问题081,问题082,问题085,问题086到问题800的解
资源推荐
资源详情
资源评论
收起资源包目录
project ruier 答案 详细解析 python 课程作业 (317个子文件)
README.md 5KB
sol1.py 13KB
test_poker_hand.py 7KB
sol1.py 6KB
sol1.py 6KB
sol1.py 5KB
sol1.py 5KB
sol1.py 5KB
sol2.py 5KB
sol1.py 4KB
sol1.py 4KB
sol1.py 4KB
sol1.py 4KB
sol1.py 4KB
sol1.py 4KB
sol1.py 4KB
sol3.py 3KB
sol1.py 3KB
sol1.py 3KB
sol1.py 3KB
sol1.py 3KB
sol1.py 3KB
sol2.py 3KB
sol1.py 3KB
sol1.py 3KB
sol1.py 3KB
sol1.py 3KB
sol1.py 3KB
sol1.py 3KB
sol1.py 3KB
sol1.py 3KB
sol1.py 3KB
sol1.py 3KB
sol2.py 3KB
sol1.py 3KB
sol1.py 3KB
sol1.py 3KB
sol1.py 3KB
sol1.py 3KB
sol2.py 3KB
sol1.py 3KB
sol1.py 3KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol4.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol2.py 2KB
sol2.py 2KB
sol1.py 2KB
sol3.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol3.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol2.py 2KB
sol1.py 2KB
sol32.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol3.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 2KB
sol1.py 1KB
sol2.py 1KB
sol2.py 1KB
sol1.py 1KB
sol1.py 1KB
sol1.py 1KB
sol1.py 1KB
共 317 条
- 1
- 2
- 3
- 4
资源评论
Nosetime
- 粉丝: 0
- 资源: 43
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功