Skip to content

Commit 5859ae1

Browse files
authored
Merge branch 'master' into algo/transitiveClosure
2 parents 45c8bc0 + c0ad5bb commit 5859ae1

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

.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.13.0
19+
rev: v0.13.1
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.18.1
50+
rev: v1.18.2
5151
hooks:
5252
- id: mypy
5353
args:

data_structures/arrays/sudoku_solver.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@
1111
def cross(items_a, items_b):
1212
"""
1313
Cross product of elements in A and elements in B.
14+
15+
>>> cross('AB', '12')
16+
['A1', 'A2', 'B1', 'B2']
17+
>>> cross('ABC', '123')
18+
['A1', 'A2', 'A3', 'B1', 'B2', 'B3', 'C1', 'C2', 'C3']
19+
>>> cross('ABC', '1234')
20+
['A1', 'A2', 'A3', 'A4', 'B1', 'B2', 'B3', 'B4', 'C1', 'C2', 'C3', 'C4']
21+
>>> cross('', '12')
22+
[]
23+
>>> cross('A', '')
24+
[]
25+
>>> cross('', '')
26+
[]
1427
"""
1528
return [a + b for a in items_a for b in items_b]
1629

strings/edit_distance.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ def edit_distance(source: str, target: str) -> int:
1414
1515
>>> edit_distance("GATTIC", "GALTIC")
1616
1
17+
>>> edit_distance("NUM3", "HUM2")
18+
2
19+
>>> edit_distance("cap", "CAP")
20+
3
21+
>>> edit_distance("Cat", "")
22+
3
23+
>>> edit_distance("cat", "cat")
24+
0
25+
>>> edit_distance("", "123456789")
26+
9
27+
>>> edit_distance("Be@uty", "Beautyyyy!")
28+
5
29+
>>> edit_distance("lstring", "lsstring")
30+
1
1731
"""
1832
if len(source) == 0:
1933
return len(target)

0 commit comments

Comments
 (0)