Skip to content

Commit 790b418

Browse files
Merge branch 'master' into patch-1
2 parents 4f8b772 + 135c748 commit 790b418

Some content is hidden

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

52 files changed

+1531
-141
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,25 @@ jobs:
99
build:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v5
13-
- uses: astral-sh/setup-uv@v6
12+
- run: sudo apt-get update && sudo apt-get install -y libhdf5-dev
13+
- uses: actions/checkout@v6
14+
- uses: astral-sh/setup-uv@v7
1415
with:
1516
enable-cache: true
1617
cache-dependency-glob: uv.lock
1718
- uses: actions/setup-python@v6
1819
with:
19-
python-version: 3.x
20+
python-version: 3.14
2021
allow-prereleases: true
2122
- run: uv sync --group=test
2223
- name: Run tests
2324
# TODO: #8818 Re-enable quantum tests
24-
run: uv run pytest
25+
run: uv run --with=pytest-run-parallel pytest
26+
--iterations=8 --parallel-threads=auto
2527
--ignore=computer_vision/cnn_classification.py
2628
--ignore=docs/conf.py
2729
--ignore=dynamic_programming/k_means_clustering_tensorflow.py
30+
--ignore=machine_learning/local_weighted_learning/local_weighted_learning.py
2831
--ignore=machine_learning/lstm/lstm_prediction.py
2932
--ignore=neural_network/input_data.py
3033
--ignore=project_euler/

.github/workflows/devcontainer_ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
build:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v5
15+
- uses: actions/checkout@v6
1616
- uses: devcontainers/ci@v0.3
1717
with:
1818
push: never

.github/workflows/directory_writer.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ jobs:
66
directory_writer:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v5
9+
- uses: actions/checkout@v6
1010
with:
1111
fetch-depth: 0
1212
- uses: actions/setup-python@v6
1313
with:
14-
python-version: 3.x
14+
python-version: 3.14
15+
allow-prereleases: true
1516
- name: Write DIRECTORY.md
1617
run: |
1718
scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md

.github/workflows/project_euler.yml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,37 @@ jobs:
1414
project-euler:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v5
18-
- uses: astral-sh/setup-uv@v6
17+
- run:
18+
sudo apt-get update && sudo apt-get install -y libtiff5-dev libjpeg8-dev libopenjp2-7-dev
19+
zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk
20+
libharfbuzz-dev libfribidi-dev libxcb1-dev
21+
libxml2-dev libxslt-dev
22+
libhdf5-dev
23+
libopenblas-dev
24+
- uses: actions/checkout@v6
25+
- uses: astral-sh/setup-uv@v7
1926
- uses: actions/setup-python@v6
2027
with:
21-
python-version: 3.x
28+
python-version: 3.14
29+
allow-prereleases: true
2230
- run: uv sync --group=euler-validate --group=test
2331
- run: uv run pytest --doctest-modules --cov-report=term-missing:skip-covered --cov=project_euler/ project_euler/
2432
validate-solutions:
2533
runs-on: ubuntu-latest
2634
steps:
27-
- uses: actions/checkout@v5
28-
- uses: astral-sh/setup-uv@v6
35+
- run:
36+
sudo apt-get update && sudo apt-get install -y libtiff5-dev libjpeg8-dev libopenjp2-7-dev
37+
zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk
38+
libharfbuzz-dev libfribidi-dev libxcb1-dev
39+
libxml2-dev libxslt-dev
40+
libhdf5-dev
41+
libopenblas-dev
42+
- uses: actions/checkout@v6
43+
- uses: astral-sh/setup-uv@v7
2944
- uses: actions/setup-python@v6
3045
with:
31-
python-version: 3.x
46+
python-version: 3.14
47+
allow-prereleases: true
3248
- run: uv sync --group=euler-validate --group=test
3349
- run: uv run pytest scripts/validate_solutions.py
3450
env:

.github/workflows/ruff.yml

Lines changed: 2 additions & 2 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@v5
15-
- uses: astral-sh/setup-uv@v6
14+
- uses: actions/checkout@v6
15+
- uses: astral-sh/setup-uv@v7
1616
- run: uvx ruff check --output-format=github .

.github/workflows/sphinx.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,18 @@ jobs:
2525
build_docs:
2626
runs-on: ubuntu-24.04-arm
2727
steps:
28-
- uses: actions/checkout@v5
29-
- uses: astral-sh/setup-uv@v6
28+
- run:
29+
sudo apt-get update && sudo apt-get install -y libtiff5-dev libjpeg8-dev libopenjp2-7-dev
30+
zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk
31+
libharfbuzz-dev libfribidi-dev libxcb1-dev
32+
libxml2-dev libxslt-dev
33+
libhdf5-dev
34+
libopenblas-dev
35+
- uses: actions/checkout@v6
36+
- uses: astral-sh/setup-uv@v7
3037
- uses: actions/setup-python@v6
3138
with:
32-
python-version: 3.13
39+
python-version: 3.14
3340
allow-prereleases: true
3441
- run: uv sync --group=docs
3542
- uses: actions/configure-pages@v5

.pre-commit-config.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
ci:
2+
autoupdate_schedule: monthly
3+
14
repos:
25
- repo: https://github.com/pre-commit/pre-commit-hooks
36
rev: v6.0.0
@@ -11,12 +14,12 @@ repos:
1114
- id: requirements-txt-fixer
1215

1316
- repo: https://github.com/MarcoGorelli/auto-walrus
14-
rev: 0.3.4
17+
rev: 0.4.1
1518
hooks:
1619
- id: auto-walrus
1720

1821
- repo: https://github.com/astral-sh/ruff-pre-commit
19-
rev: v0.13.1
22+
rev: v0.14.14
2023
hooks:
2124
- id: ruff-check
2225
- id: ruff-format
@@ -29,7 +32,7 @@ repos:
2932
- tomli
3033

3134
- repo: https://github.com/tox-dev/pyproject-fmt
32-
rev: v2.6.0
35+
rev: v2.12.1
3336
hooks:
3437
- id: pyproject-fmt
3538

@@ -47,7 +50,7 @@ repos:
4750
- id: validate-pyproject
4851

4952
- repo: https://github.com/pre-commit/mirrors-mypy
50-
rev: v1.18.2
53+
rev: v1.19.1
5154
hooks:
5255
- id: mypy
5356
args:

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ We want your work to be readable by others; therefore, we encourage you to note
9999
ruff check
100100
```
101101

102-
- Original code submission require docstrings or comments to describe your work.
102+
- Original code submissions require docstrings or comments to describe your work.
103103

104104
- More on docstrings and comments:
105105

@@ -159,7 +159,7 @@ We want your work to be readable by others; therefore, we encourage you to note
159159
starting_value = int(input("Please enter a starting value: ").strip())
160160
```
161161

162-
The use of [Python type hints](https://docs.python.org/3/library/typing.html) is encouraged for function parameters and return values. Our automated testing will run [mypy](http://mypy-lang.org) so run that locally before making your submission.
162+
The use of [Python type hints](https://docs.python.org/3/library/typing.html) is encouraged for function parameters and return values. Our automated testing will run [mypy](https://mypy-lang.org) so run that locally before making your submission.
163163

164164
```python
165165
def sum_ab(a: int, b: int) -> int:

DIRECTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@
195195
* [Permutations](data_structures/arrays/permutations.py)
196196
* [Prefix Sum](data_structures/arrays/prefix_sum.py)
197197
* [Product Sum](data_structures/arrays/product_sum.py)
198+
* [Rotate Array](data_structures/arrays/rotate_array.py)
198199
* [Sparse Table](data_structures/arrays/sparse_table.py)
199200
* [Sudoku Solver](data_structures/arrays/sudoku_solver.py)
200201
* Binary Tree
@@ -397,6 +398,7 @@
397398
* [Minimum Squares To Represent A Number](dynamic_programming/minimum_squares_to_represent_a_number.py)
398399
* [Minimum Steps To One](dynamic_programming/minimum_steps_to_one.py)
399400
* [Minimum Tickets Cost](dynamic_programming/minimum_tickets_cost.py)
401+
* [Narcissistic Number](dynamic_programming/narcissistic_number.py)
400402
* [Optimal Binary Search Tree](dynamic_programming/optimal_binary_search_tree.py)
401403
* [Palindrome Partitioning](dynamic_programming/palindrome_partitioning.py)
402404
* [Range Sum Query](dynamic_programming/range_sum_query.py)
@@ -623,6 +625,7 @@
623625
* [Sequential Minimum Optimization](machine_learning/sequential_minimum_optimization.py)
624626
* [Similarity Search](machine_learning/similarity_search.py)
625627
* [Support Vector Machines](machine_learning/support_vector_machines.py)
628+
* [T Stochastic Neighbour Embedding](machine_learning/t_stochastic_neighbour_embedding.py)
626629
* [Word Frequency Functions](machine_learning/word_frequency_functions.py)
627630
* [Xgboost Classifier](machine_learning/xgboost_classifier.py)
628631
* [Xgboost Regressor](machine_learning/xgboost_regressor.py)
@@ -878,6 +881,7 @@
878881
* [Quine](other/quine.py)
879882
* [Scoring Algorithm](other/scoring_algorithm.py)
880883
* [Sdes](other/sdes.py)
884+
* [Sliding Window Maximum](other/sliding_window_maximum.py)
881885
* [Tower Of Hanoi](other/tower_of_hanoi.py)
882886
* [Word Search](other/word_search.py)
883887

backtracking/generate_parentheses_iterative.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
def generate_parentheses_iterative(length: int) -> list:
1+
def generate_parentheses_iterative(length: int) -> list[str]:
22
"""
33
Generate all valid combinations of parentheses (Iterative Approach).
44
55
The algorithm works as follows:
66
1. Initialize an empty list to store the combinations.
77
2. Initialize a stack to keep track of partial combinations.
8-
3. Start with empty string and push it onstack along with the counts of '(' and ')'.
8+
3. Start with empty string and push it on stack along with
9+
the counts of '(' and ')'.
910
4. While the stack is not empty:
1011
a. Pop a partial combination and its open and close counts from the stack.
1112
b. If the combination length is equal to 2*length, add it to the result.
@@ -34,8 +35,11 @@ def generate_parentheses_iterative(length: int) -> list:
3435
>>> generate_parentheses_iterative(0)
3536
['']
3637
"""
37-
result = []
38-
stack = []
38+
if length == 0:
39+
return [""]
40+
41+
result: list[str] = []
42+
stack: list[tuple[str, int, int]] = []
3943

4044
# Each element in stack is a tuple (current_combination, open_count, close_count)
4145
stack.append(("", 0, 0))
@@ -45,6 +49,7 @@ def generate_parentheses_iterative(length: int) -> list:
4549

4650
if len(current_combination) == 2 * length:
4751
result.append(current_combination)
52+
continue
4853

4954
if open_count < length:
5055
stack.append((current_combination + "(", open_count + 1, close_count))

0 commit comments

Comments
 (0)