Skip to content

Commit 932f2fc

Browse files
Merge branch 'TheAlgorithms:master' into codex/find-and-fix-a-bug
2 parents a291f1b + c3d4b9e commit 932f2fc

782 files changed

Lines changed: 20687 additions & 5214 deletions

File tree

Some content is hidden

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

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# https://github.com/microsoft/vscode-dev-containers/blob/main/containers/python-3/README.md
2-
ARG VARIANT=3.12-bookworm
2+
ARG VARIANT=3.13-bookworm
33
FROM mcr.microsoft.com/vscode/devcontainers/python:${VARIANT}
44
COPY requirements.txt /tmp/pip-tmp/
55
RUN python3 -m pip install --upgrade pip \

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// Update 'VARIANT' to pick a Python version: 3, 3.11, 3.10, 3.9, 3.8
88
// Append -bullseye or -buster to pin to an OS version.
99
// Use -bullseye variants on local on arm64/Apple Silicon.
10-
"VARIANT": "3.12-bookworm",
10+
"VARIANT": "3.13-bookworm",
1111
}
1212
},
1313

.github/CODEOWNERS

Lines changed: 6 additions & 8 deletions
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,15 +19,15 @@
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

3432
# /digital_image_processing/
3533

@@ -67,7 +65,7 @@
6765

6866
# /neural_network/
6967

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

7270
# /project_euler/
7371

@@ -81,7 +79,7 @@
8179

8280
# /sorts/
8381

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

8684
# /traversals/
8785

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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:

.github/workflows/build.yml

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,28 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v4
13-
- uses: actions/setup-python@v4
13+
- uses: astral-sh/setup-uv@v6
1414
with:
15-
python-version: 3.12
16-
allow-prereleases: true
17-
- uses: actions/cache@v3
15+
enable-cache: true
16+
cache-dependency-glob: uv.lock
17+
- uses: actions/setup-python@v5
1818
with:
19-
path: ~/.cache/pip
20-
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
21-
- name: Install dependencies
22-
run: |
23-
python -m pip install --upgrade pip setuptools six wheel
24-
python -m pip install pytest-cov -r requirements.txt
19+
python-version: 3.13
20+
allow-prereleases: true
21+
- run: uv sync --group=test
2522
- name: Run tests
2623
# TODO: #8818 Re-enable quantum tests
27-
run: pytest
28-
--ignore=quantum/q_fourier_transform.py
29-
--ignore=project_euler/
30-
--ignore=scripts/validate_solutions.py
31-
--cov-report=term-missing:skip-covered
32-
--cov=. .
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+
--ignore=web_programming/fetch_anime_and_play.py
34+
--cov-report=term-missing:skip-covered
35+
--cov=. .
3336
- if: ${{ success() }}
3437
run: scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md

.github/workflows/directory_writer.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
name: directory_writer
44
on: [push]
55
jobs:
6-
build:
6+
directory_writer:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v4
1010
with:
1111
fetch-depth: 0
12-
- uses: actions/setup-python@v4
12+
- uses: actions/setup-python@v5
1313
with:
1414
python-version: 3.x
1515
- name: Write DIRECTORY.md
1616
run: |
1717
scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md
18-
git config --global user.name github-actions
19-
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 "$GITHUB_ACTOR@users.noreply.github.com"
2020
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
2121
- name: Update DIRECTORY.md
2222
run: |

.github/workflows/project_euler.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,21 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- uses: actions/checkout@v4
18-
- uses: actions/setup-python@v4
18+
- uses: astral-sh/setup-uv@v6
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 numpy 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:
2927
- uses: actions/checkout@v4
30-
- uses: actions/setup-python@v4
28+
- uses: astral-sh/setup-uv@v6
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 numpy 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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ jobs:
1111
ruff:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v4
15-
- run: pip install --user ruff
16-
- run: ruff --output-format=github .
14+
- uses: actions/checkout@v4
15+
- uses: astral-sh/setup-uv@v6
16+
- run: uvx ruff check --output-format=github .

.github/workflows/sphinx.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: sphinx
2+
3+
on:
4+
# Triggers the workflow on push or pull request events but only for the "master" branch
5+
push:
6+
branches: ["master"]
7+
pull_request:
8+
branches: ["master"]
9+
# Or manually from the Actions tab
10+
workflow_dispatch:
11+
12+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20+
concurrency:
21+
group: "pages"
22+
cancel-in-progress: false
23+
24+
jobs:
25+
build_docs:
26+
runs-on: ubuntu-24.04-arm
27+
steps:
28+
- uses: actions/checkout@v4
29+
- uses: astral-sh/setup-uv@v6
30+
- uses: actions/setup-python@v5
31+
with:
32+
python-version: 3.13
33+
allow-prereleases: true
34+
- run: uv sync --group=docs
35+
- uses: actions/configure-pages@v5
36+
- run: uv run sphinx-build -c docs . docs/_build/html
37+
- uses: actions/upload-pages-artifact@v3
38+
with:
39+
path: docs/_build/html
40+
41+
deploy_docs:
42+
environment:
43+
name: github-pages
44+
url: ${{ steps.deployment.outputs.page_url }}
45+
if: github.event_name != 'pull_request'
46+
needs: build_docs
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/deploy-pages@v4
50+
id: deployment

0 commit comments

Comments
 (0)