init
This commit is contained in:
commit
14a17e01a9
6 changed files with 55 additions and 0 deletions
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# Python-generated files
|
||||
__pycache__/
|
||||
*.py[oc]
|
||||
build/
|
||||
dist/
|
||||
wheels/
|
||||
*.egg-info
|
||||
|
||||
# Virtual environments
|
||||
.venv
|
||||
1
.python-version
Normal file
1
.python-version
Normal file
|
|
@ -0,0 +1 @@
|
|||
3.13
|
||||
0
README.md
Normal file
0
README.md
Normal file
29
main.py
Normal file
29
main.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
w = 3
|
||||
h = 3
|
||||
|
||||
def main():
|
||||
path = [(0,0)]
|
||||
|
||||
paths = find_paths(path, set())
|
||||
print(len(paths))
|
||||
print('\n'.join(str(path) for path in paths))
|
||||
|
||||
def find_paths(path: list[tuple[int, int]], paths: set[list[tuple[int, int]]]):
|
||||
x, y = path[-1]
|
||||
|
||||
if x == w - 1 and y == h - 1:
|
||||
paths.add(tuple(path))
|
||||
return paths
|
||||
|
||||
for mv in ((0, 1), (1, 1), (1, 0)):
|
||||
nx = x + mv[0]
|
||||
ny = y + mv[1]
|
||||
if nx < w and ny < h:
|
||||
path.append((nx, ny))
|
||||
paths = find_paths(path, paths)
|
||||
path.pop()
|
||||
|
||||
return paths
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
7
pyproject.toml
Normal file
7
pyproject.toml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[project]
|
||||
name = "abel-paths"
|
||||
version = "0.1.0"
|
||||
description = "Add your description here"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.13"
|
||||
dependencies = []
|
||||
8
uv.lock
generated
Normal file
8
uv.lock
generated
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
version = 1
|
||||
revision = 3
|
||||
requires-python = ">=3.13"
|
||||
|
||||
[[package]]
|
||||
name = "abel-paths"
|
||||
version = "0.1.0"
|
||||
source = { virtual = "." }
|
||||
Loading…
Add table
Add a link
Reference in a new issue