Skip to content

Commit adfef73

Browse files
authored
Merge branch 'master' into master
2 parents 16d2b1e + 54aa73f commit adfef73

31 files changed

+639
-196
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
build:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v4
12+
- uses: actions/checkout@v5
1313
- uses: astral-sh/setup-uv@v6
1414
with:
1515
enable-cache: true

.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@v4
15+
- uses: actions/checkout@v5
1616
- uses: devcontainers/[email protected]
1717
with:
1818
push: never

.github/workflows/directory_writer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
directory_writer:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v4
9+
- uses: actions/checkout@v5
1010
with:
1111
fetch-depth: 0
1212
- uses: actions/setup-python@v5

.github/workflows/project_euler.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
project-euler:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v5
1818
- uses: astral-sh/setup-uv@v6
1919
- uses: actions/setup-python@v5
2020
with:
@@ -24,7 +24,7 @@ jobs:
2424
validate-solutions:
2525
runs-on: ubuntu-latest
2626
steps:
27-
- uses: actions/checkout@v4
27+
- uses: actions/checkout@v5
2828
- uses: astral-sh/setup-uv@v6
2929
- uses: actions/setup-python@v5
3030
with:

.github/workflows/ruff.yml

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

.github/workflows/sphinx.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
build_docs:
2626
runs-on: ubuntu-24.04-arm
2727
steps:
28-
- uses: actions/checkout@v4
28+
- uses: actions/checkout@v5
2929
- uses: astral-sh/setup-uv@v6
3030
- uses: actions/setup-python@v5
3131
with:
@@ -34,7 +34,7 @@ jobs:
3434
- run: uv sync --group=docs
3535
- uses: actions/configure-pages@v5
3636
- run: uv run sphinx-build -c docs . docs/_build/html
37-
- uses: actions/upload-pages-artifact@v3
37+
- uses: actions/upload-pages-artifact@v4
3838
with:
3939
path: docs/_build/html
4040

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repos:
1616
- id: auto-walrus
1717

1818
- repo: https://github.com/astral-sh/ruff-pre-commit
19-
rev: v0.12.8
19+
rev: v0.12.10
2020
hooks:
2121
- id: ruff-check
2222
- id: ruff-format
@@ -47,7 +47,7 @@ repos:
4747
- id: validate-pyproject
4848

4949
- repo: https://github.com/pre-commit/mirrors-mypy
50-
rev: v1.15.0
50+
rev: v1.17.1
5151
hooks:
5252
- id: mypy
5353
args:

DIRECTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* [Combination Sum](backtracking/combination_sum.py)
1313
* [Crossword Puzzle Solver](backtracking/crossword_puzzle_solver.py)
1414
* [Generate Parentheses](backtracking/generate_parentheses.py)
15+
* [Generate Parentheses Iterative](backtracking/generate_parentheses_iterative.py)
1516
* [Hamiltonian Cycle](backtracking/hamiltonian_cycle.py)
1617
* [Knight Tour](backtracking/knight_tour.py)
1718
* [Match Word Pattern](backtracking/match_word_pattern.py)
@@ -174,6 +175,7 @@
174175

175176
## Data Compression
176177
* [Burrows Wheeler](data_compression/burrows_wheeler.py)
178+
* [Coordinate Compression](data_compression/coordinate_compression.py)
177179
* [Huffman](data_compression/huffman.py)
178180
* [Lempel Ziv](data_compression/lempel_ziv.py)
179181
* [Lempel Ziv Decompress](data_compression/lempel_ziv_decompress.py)
@@ -956,6 +958,7 @@
956958
* [Sol1](project_euler/problem_009/sol1.py)
957959
* [Sol2](project_euler/problem_009/sol2.py)
958960
* [Sol3](project_euler/problem_009/sol3.py)
961+
* [Sol4](project_euler/problem_009/sol4.py)
959962
* Problem 010
960963
* [Sol1](project_euler/problem_010/sol1.py)
961964
* [Sol2](project_euler/problem_010/sol2.py)
@@ -1266,6 +1269,7 @@
12661269
* [Comb Sort](sorts/comb_sort.py)
12671270
* [Counting Sort](sorts/counting_sort.py)
12681271
* [Cycle Sort](sorts/cycle_sort.py)
1272+
* [Cyclic Sort](sorts/cyclic_sort.py)
12691273
* [Double Sort](sorts/double_sort.py)
12701274
* [Dutch National Flag Sort](sorts/dutch_national_flag_sort.py)
12711275
* [Exchange Sort](sorts/exchange_sort.py)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
<a href="https://github.com/pre-commit/pre-commit">
2828
<img src="https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=flat-square" height="20" alt="pre-commit">
2929
</a>
30-
<a href="https://github.com/psf/black">
31-
<img src="https://img.shields.io/static/v1?label=code%20style&message=black&color=black&style=flat-square" height="20" alt="code style: black">
30+
<a href="https://docs.astral.sh/ruff/formatter/">
31+
<img src="https://img.shields.io/static/v1?label=code%20style&message=ruff&color=black&style=flat-square" height="20" alt="code style: black">
3232
</a>
3333
<!-- Short description: -->
3434
<h3>All algorithms implemented in Python - for education</h3>

backtracking/combination_sum.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,18 @@ def combination_sum(candidates: list, target: int) -> list:
4747
>>> combination_sum([-8, 2.3, 0], 1)
4848
Traceback (most recent call last):
4949
...
50-
RecursionError: maximum recursion depth exceeded
50+
ValueError: All elements in candidates must be non-negative
51+
>>> combination_sum([], 1)
52+
Traceback (most recent call last):
53+
...
54+
ValueError: Candidates list should not be empty
5155
"""
56+
if not candidates:
57+
raise ValueError("Candidates list should not be empty")
58+
59+
if any(x < 0 for x in candidates):
60+
raise ValueError("All elements in candidates must be non-negative")
61+
5262
path = [] # type: list[int]
5363
answer = [] # type: list[int]
5464
backtrack(candidates, path, answer, target, 0)

0 commit comments

Comments
 (0)