Skip to content

Commit cc561e3

Browse files
committed
Merge branch 'master' of https://github.com/TheAlgorithms/Python
2 parents 75c7da7 + 03d3435 commit cc561e3

File tree

145 files changed

+8305
-1033
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+8305
-1033
lines changed

.github/stale.yml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Configuration for probot-stale - https://github.com/probot/stale
2+
3+
# Number of days of inactivity before an Issue or Pull Request becomes stale
4+
daysUntilStale: 30
5+
6+
# Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
7+
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
8+
daysUntilClose: 7
9+
10+
# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled)
11+
onlyLabels: []
12+
13+
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
14+
exemptLabels:
15+
- "Status: on hold"
16+
17+
# Set to true to ignore issues in a project (defaults to false)
18+
exemptProjects: false
19+
20+
# Set to true to ignore issues in a milestone (defaults to false)
21+
exemptMilestones: false
22+
23+
# Set to true to ignore issues with an assignee (defaults to false)
24+
exemptAssignees: false
25+
26+
# Label to use when marking as stale
27+
staleLabel: stale
28+
29+
# Limit the number of actions per hour, from 1-30. Default is 30
30+
limitPerRun: 5
31+
32+
# Comment to post when removing the stale label.
33+
# unmarkComment: >
34+
# Your comment here.
35+
36+
# Optionally, specify configuration settings that are specific to just 'issues' or 'pulls':
37+
pulls:
38+
# Comment to post when marking as stale. Set to `false` to disable
39+
markComment: >
40+
This pull request has been automatically marked as stale because it has not had
41+
recent activity. It will be closed if no further activity occurs. Thank you
42+
for your contributions.
43+
44+
# Comment to post when closing a stale Pull Request.
45+
closeComment: >
46+
Please reopen this pull request once you commit the changes requested
47+
or make improvements on the code. If this is not the case and you need
48+
some help, feel free to seek help from our [Gitter](https://gitter.im/TheAlgorithms)
49+
or ping one of the reviewers. Thank you for your contributions!
50+
51+
issues:
52+
# Comment to post when marking as stale. Set to `false` to disable
53+
markComment: >
54+
This issue has been automatically marked as stale because it has not had
55+
recent activity. It will be closed if no further activity occurs. Thank you
56+
for your contributions.
57+
58+
# Comment to post when closing a stale Issue.
59+
closeComment: >
60+
Please reopen this issue once you add more information and updates here.
61+
If this is not the case and you need some help, feel free to seek help
62+
from our [Gitter](https://gitter.im/TheAlgorithms) or ping one of the
63+
reviewers. Thank you for your contributions!

.github/workflows/auto_close_empty_issues.yml

-20
This file was deleted.

.github/workflows/build.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: "build"
2+
3+
on:
4+
pull_request:
5+
schedule:
6+
- cron: "0 0 * * *" # Run everyday
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-python@v2
14+
with:
15+
python-version: "3.9"
16+
- uses: actions/cache@v2
17+
with:
18+
path: ~/.cache/pip
19+
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip setuptools six wheel
23+
python -m pip install pytest-cov -r requirements.txt
24+
- name: Run tests
25+
run: pytest --doctest-modules --ignore=project_euler/ --ignore=scripts/ --cov-report=term-missing:skip-covered --cov=. .
26+
- if: ${{ success() }}
27+
run: scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md

.github/workflows/pre-commit.yml

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v2
10+
- uses: actions/cache@v2
11+
with:
12+
path: |
13+
~/.cache/pre-commit
14+
~/.cache/pip
15+
key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
1016
- uses: actions/setup-python@v2
1117
- name: Install pre-commit
1218
run: |

.github/workflows/project_euler.yml

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
on:
22
pull_request:
3-
# only check if a file is changed within the project_euler directory and related files
3+
# Run only if a file is changed within the project_euler directory and related files
44
paths:
5-
- 'project_euler/**'
6-
- '.github/workflows/project_euler.yml'
7-
- 'scripts/validate_solutions.py'
5+
- "project_euler/**"
6+
- ".github/workflows/project_euler.yml"
7+
- "scripts/validate_solutions.py"
8+
schedule:
9+
- cron: "0 0 * * *" # Run everyday
810

9-
name: 'Project Euler'
11+
name: "Project Euler"
1012

1113
jobs:
1214
project-euler:
@@ -24,8 +26,10 @@ jobs:
2426
steps:
2527
- uses: actions/checkout@v2
2628
- uses: actions/setup-python@v2
27-
- name: Install pytest
29+
- name: Install pytest and requests
2830
run: |
2931
python -m pip install --upgrade pip
30-
python -m pip install --upgrade pytest
32+
python -m pip install --upgrade pytest requests
3133
- run: pytest scripts/validate_solutions.py
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/stale.yml

-23
This file was deleted.

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ repos:
4242
hooks:
4343
- id: codespell
4444
args:
45-
- --ignore-words-list=ans,fo,followings,hist,iff,secant,som,tim
45+
- --ignore-words-list=ans,fo,followings,hist,iff,mater,secant,som,tim
4646
- --skip="./.*,./other/dictionary.txt,./other/words,./project_euler/problem_022/p022_names.txt"
4747
- --quiet-level=2
4848
exclude: |

.travis.yml

-17
This file was deleted.

CONTRIBUTING.md

+15-2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@ Algorithms should:
4949

5050
Algorithms in this repo should not be how-to examples for existing Python packages. Instead, they should perform internal calculations or manipulations to convert input values into different output values. Those calculations or manipulations can use data types, classes, or functions of existing Python packages but each algorithm in this repo should add unique value.
5151

52+
#### Pre-commit plugin
53+
Use [pre-commit](https://pre-commit.com/#installation) to automatically format your code to match our coding style:
54+
55+
```bash
56+
python3 -m pip install pre-commit # required only once
57+
pre-commit install
58+
```
59+
That's it! The plugin will run every time you commit any changes. If there are any errors found during the run, fix them and commit those changes. You can even run the plugin manually on all files:
60+
61+
```bash
62+
pre-commit run --all-files --show-diff-on-failure
63+
```
64+
5265
#### Coding Style
5366

5467
We want your work to be readable by others; therefore, we encourage you to note the following:
@@ -64,14 +77,14 @@ We want your work to be readable by others; therefore, we encourage you to note
6477
- Please consider running [__psf/black__](https://github.com/python/black) on your Python file(s) before submitting your pull request. This is not yet a requirement but it does make your code more readable and automatically aligns it with much of [PEP 8](https://www.python.org/dev/peps/pep-0008/). There are other code formatters (autopep8, yapf) but the __black__ formatter is now hosted by the Python Software Foundation. To use it,
6578

6679
```bash
67-
pip3 install black # only required the first time
80+
python3 -m pip install black # only required the first time
6881
black .
6982
```
7083

7184
- All submissions will need to pass the test __flake8 . --ignore=E203,W503 --max-line-length=88__ before they will be accepted so if possible, try this test locally on your Python file(s) before submitting your pull request.
7285

7386
```bash
74-
pip3 install flake8 # only required the first time
87+
python3 -m pip install flake8 # only required the first time
7588
flake8 . --ignore=E203,W503 --max-line-length=88 --show-source
7689
```
7790

0 commit comments

Comments
 (0)