17-2-anim

This commit is contained in:
2024-12-18 19:48:26 +01:00
parent 0af1538d7f
commit 904f7f7c27
8 changed files with 3740 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from copy import deepcopy
file = "./input.txt"
XY_DIMENSION = 70
@@ -29,10 +30,11 @@ def print_grid(f):
print()
def fill_grid(gri:list[list[str]], ma:list[list[int]], filler:str)->list[list[str]]:
result = deepcopy(gri)
for m in ma:
x , y = m[0],m[1]
gri[y][x] = filler
return gri
result[y][x] = filler
return result
def read_input(input_file:str, ) -> list[list[int]]:
out = []
@@ -58,7 +60,7 @@ def shortest_path(array, start, end):
for dx, dy in [(0, 1), (1, 0), (0, -1), (-1, 0)]:
nx, ny = x + dx, y + dy
if 0 <= nx < zeilen and 0 <= ny < spalten and array[nx][ny] == '.' and (nx, ny) not in visited:
queue.append(((nx, ny), pfad + [(nx, ny)]))
queue.append(((nx, ny), pfad + [(ny, nx)]))
visited.add((nx, ny))
return -1, [] # Kein Pfad gefunden