Skip to content

Commit dc8b0b1

Browse files
Merge branch 'TheAlgorithms:master' into master
2 parents 8acb1a8 + 13e4d3e commit dc8b0b1

File tree

1,160 files changed

+52134
-12913
lines changed

Some content is hidden

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

1,160 files changed

+52134
-12913
lines changed

.coveragerc

-4
This file was deleted.

.devcontainer/Dockerfile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# https://github.com/microsoft/vscode-dev-containers/blob/main/containers/python-3/README.md
2+
ARG VARIANT=3.13-bookworm
3+
FROM mcr.microsoft.com/vscode/devcontainers/python:${VARIANT}
4+
COPY requirements.txt /tmp/pip-tmp/
5+
RUN python3 -m pip install --upgrade pip \
6+
&& python3 -m pip install --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
7+
&& pipx install pre-commit ruff \
8+
&& pre-commit install

.devcontainer/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://code.visualstudio.com/docs/devcontainers/tutorial

.devcontainer/devcontainer.json

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "Python 3",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"context": "..",
6+
"args": {
7+
// Update 'VARIANT' to pick a Python version: 3, 3.11, 3.10, 3.9, 3.8
8+
// Append -bullseye or -buster to pin to an OS version.
9+
// Use -bullseye variants on local on arm64/Apple Silicon.
10+
"VARIANT": "3.13-bookworm",
11+
}
12+
},
13+
14+
// Configure tool-specific properties.
15+
"customizations": {
16+
// Configure properties specific to VS Code.
17+
"vscode": {
18+
// Set *default* container specific settings.json values on container create.
19+
"settings": {
20+
"python.defaultInterpreterPath": "/usr/local/bin/python",
21+
"python.linting.enabled": true,
22+
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
23+
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy"
24+
},
25+
26+
// Add the IDs of extensions you want installed when the container is created.
27+
"extensions": [
28+
"ms-python.python",
29+
"ms-python.vscode-pylance"
30+
]
31+
}
32+
},
33+
34+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
35+
// "forwardPorts": [],
36+
37+
// Use 'postCreateCommand' to run commands after the container is created.
38+
// "postCreateCommand": "pip3 install --user -r requirements.txt",
39+
40+
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
41+
"remoteUser": "vscode"
42+
}

.github/CODEOWNERS

+11-13
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77

88
# Order is important. The last matching pattern has the most precedence.
99

10-
/.* @cclauss @dhruvmanila
11-
12-
# /arithmetic_analysis/
10+
/.* @cclauss
1311

1412
# /backtracking/
1513

@@ -21,21 +19,21 @@
2119

2220
# /cellular_automata/
2321

24-
# /ciphers/ @cclauss # TODO: Uncomment this line after Hacktoberfest
22+
# /ciphers/
2523

2624
# /compression/
2725

2826
# /computer_vision/
2927

30-
# /conversions/ @cclauss # TODO: Uncomment this line after Hacktoberfest
28+
# /conversions/
3129

32-
# /data_structures/ @cclauss # TODO: Uncomment this line after Hacktoberfest
30+
# /data_structures/
3331

34-
/digital_image_processing/ @mateuszz0000
32+
# /digital_image_processing/
3533

3634
# /divide_and_conquer/
3735

38-
/dynamic_programming/ @Kush1101
36+
# /dynamic_programming/
3937

4038
# /file_transfer/
4139

@@ -59,17 +57,17 @@
5957

6058
# /machine_learning/
6159

62-
/maths/ @Kush1101
60+
# /maths/
6361

6462
# /matrix/
6563

6664
# /networking_flow/
6765

6866
# /neural_network/
6967

70-
# /other/ @cclauss # TODO: Uncomment this line after Hacktoberfest
68+
# /other/
7169

72-
/project_euler/ @dhruvmanila @Kush1101
70+
# /project_euler/
7371

7472
# /quantum/
7573

@@ -79,9 +77,9 @@
7977

8078
# /searches/
8179

82-
/sorts/ @mateuszz0000
80+
# /sorts/
8381

84-
# /strings/ @cclauss # TODO: Uncomment this line after Hacktoberfest
82+
# /strings/
8583

8684
# /traversals/
8785

.github/ISSUE_TEMPLATE/feature_request.yml

+2-9
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,14 @@ body:
66
attributes:
77
value: >
88
Before requesting please search [existing issues](https://github.com/TheAlgorithms/Python/labels/enhancement).
9+
Do not create issues to implement new algorithms as these will be closed.
910
Usage questions such as "How do I...?" belong on the
1011
[Discord](https://discord.gg/c7MnfGFGa6) and will be closed.
1112
1213
- type: textarea
1314
attributes:
1415
label: "Feature description"
1516
description: >
16-
This could be new algorithms, data structures or improving any existing
17-
implementations.
17+
This could include new topics or improving any existing implementations.
1818
validations:
1919
required: true
20-
21-
- type: checkboxes
22-
attributes:
23-
label: Would you like to work on this feature?
24-
options:
25-
- label: Yes, I want to work on this feature!
26-
required: false

.github/ISSUE_TEMPLATE/other.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Other
2+
description: Use this for any other issues. PLEASE do not create blank issues
3+
labels: ["awaiting triage"]
4+
body:
5+
- type: textarea
6+
id: issuedescription
7+
attributes:
8+
label: What would you like to share?
9+
description: Provide a clear and concise explanation of your issue.
10+
validations:
11+
required: true
12+
13+
- type: textarea
14+
id: extrainfo
15+
attributes:
16+
label: Additional information
17+
description: Is there anything else we should know about this issue?
18+
validations:
19+
required: false

.github/dependabot.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Keep GitHub Actions up to date with Dependabot...
2+
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
3+
version: 2
4+
updates:
5+
- package-ecosystem: "github-actions"
6+
directory: "/"
7+
schedule:
8+
interval: "daily"

.github/pull_request_template.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* [ ] Add an algorithm?
66
* [ ] Fix a bug or typo in an existing algorithm?
7+
* [ ] Add or change doctests? -- Note: Please avoid changing both code and tests in a single pull request.
78
* [ ] Documentation change?
89

910
### Checklist:
@@ -16,5 +17,5 @@
1617
* [ ] All functions and variable names follow Python naming conventions.
1718
* [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html).
1819
* [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing.
19-
* [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
20-
* [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.
20+
* [ ] All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
21+
* [ ] If this pull request resolves one or more open issues then the description above includes the issue number(s) with a [closing keyword](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue): "Fixes #ISSUE-NUMBER".

.github/stale.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pulls:
4545
closeComment: >
4646
Please reopen this pull request once you commit the changes requested
4747
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)
48+
some help, feel free to seek help from our [Gitter](https://gitter.im/TheAlgorithms/community)
4949
or ping one of the reviewers. Thank you for your contributions!
5050
5151
issues:
@@ -59,5 +59,5 @@ issues:
5959
closeComment: >
6060
Please reopen this issue once you add more information and updates here.
6161
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
62+
from our [Gitter](https://gitter.im/TheAlgorithms/community) or ping one of the
6363
reviewers. Thank you for your contributions!

.github/workflows/build.yml

+20-11
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,28 @@ jobs:
99
build:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v3
13-
- uses: actions/setup-python@v4
12+
- uses: actions/checkout@v4
13+
- uses: astral-sh/setup-uv@v5
1414
with:
15-
python-version: 3.x
16-
- uses: actions/cache@v3
15+
enable-cache: true
16+
cache-dependency-glob: uv.lock
17+
- uses: actions/setup-python@v5
1718
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
19+
python-version: 3.13
20+
allow-prereleases: true
21+
- run: uv sync --group=test
2422
- name: Run tests
25-
run: pytest --doctest-modules --ignore=project_euler/ --ignore=scripts/validate_solutions.py --cov-report=term-missing:skip-covered --cov=. .
23+
# TODO: #8818 Re-enable quantum tests
24+
run: uv run pytest
25+
--ignore=computer_vision/cnn_classification.py
26+
--ignore=docs/conf.py
27+
--ignore=dynamic_programming/k_means_clustering_tensorflow.py
28+
--ignore=machine_learning/lstm/lstm_prediction.py
29+
--ignore=neural_network/input_data.py
30+
--ignore=project_euler/
31+
--ignore=quantum/q_fourier_transform.py
32+
--ignore=scripts/validate_solutions.py
33+
--cov-report=term-missing:skip-covered
34+
--cov=. .
2635
- if: ${{ success() }}
2736
run: scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md

.github/workflows/directory_writer.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ jobs:
66
build:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v1 # v1, NOT v2 or v3
10-
- uses: actions/setup-python@v4
9+
- uses: actions/checkout@v4
10+
with:
11+
fetch-depth: 0
12+
- uses: actions/setup-python@v5
1113
with:
1214
python-version: 3.x
1315
- name: Write DIRECTORY.md
1416
run: |
1517
scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md
16-
git config --global user.name github-actions
17-
git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com'
18+
git config --global user.name "$GITHUB_ACTOR"
19+
git config --global user.email "$[email protected]"
1820
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
1921
- name: Update DIRECTORY.md
2022
run: |

.github/workflows/pre-commit.yml

-28
This file was deleted.

.github/workflows/project_euler.yml

+10-14
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,22 @@ jobs:
1414
project-euler:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v3
18-
- uses: actions/setup-python@v4
17+
- uses: actions/checkout@v4
18+
- uses: astral-sh/setup-uv@v5
19+
- uses: actions/setup-python@v5
1920
with:
2021
python-version: 3.x
21-
- name: Install pytest and pytest-cov
22-
run: |
23-
python -m pip install --upgrade pip
24-
python -m pip install --upgrade pytest pytest-cov
25-
- run: pytest --doctest-modules --cov-report=term-missing:skip-covered --cov=project_euler/ project_euler/
22+
- run: uv sync --group=euler-validate --group=test
23+
- run: uv run pytest --doctest-modules --cov-report=term-missing:skip-covered --cov=project_euler/ project_euler/
2624
validate-solutions:
2725
runs-on: ubuntu-latest
2826
steps:
29-
- uses: actions/checkout@v3
30-
- uses: actions/setup-python@v4
27+
- uses: actions/checkout@v4
28+
- uses: astral-sh/setup-uv@v5
29+
- uses: actions/setup-python@v5
3130
with:
3231
python-version: 3.x
33-
- name: Install pytest and requests
34-
run: |
35-
python -m pip install --upgrade pip
36-
python -m pip install --upgrade pytest requests
37-
- run: pytest scripts/validate_solutions.py
32+
- run: uv sync --group=euler-validate --group=test
33+
- run: uv run pytest scripts/validate_solutions.py
3834
env:
3935
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/ruff.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# https://beta.ruff.rs
2+
name: ruff
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
jobs:
11+
ruff:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: astral-sh/setup-uv@v5
16+
- run: uvx ruff check --output-format=github .

0 commit comments

Comments
 (0)