This commit is contained in:
DUEFON 2022-12-13 01:02:18 +01:00
parent 202b162b63
commit 9ebbf520fe
1 changed files with 17 additions and 3 deletions

View File

@ -24,12 +24,9 @@ def visits(y, x):
return [(y+u-1, x+v-1) for (u, v) in [(2, 1), (0, 1), (1, 2), (1, 0)]
if y+u-1 >= 0 and y+u-1 < h and x+v-1 >= 0 and x+v-1 < w
and goto[u][v][y,x]]
#ic(a)
done = False
for i in range(h*w): # still enough
if done: break # gah
ic(tovisit)
ic(s)
lenv = len(tovisit)
for j in range(lenv):
here = tovisit.popleft()
@ -40,3 +37,20 @@ for i in range(h*w): # still enough
if s[here[0],here[1]] > i:
s[here[0],here[1]] = i
tovisit.extend(visits(*here))
s.fill(h*w)
goto = [[p[u:h+u,v:w+v] - a >= -1 for v in range(3)] for u in range(3)]
tovisit = deque([E])
done = False
for i in range(h*w):
if done: break
lenv = len(tovisit)
for j in range(lenv):
here = tovisit.popleft()
if a[here[0],here[1]] == ord('a'):
print(i)
done = True
break
if s[here[0],here[1]] > i:
s[here[0],here[1]] = i
tovisit.extend(visits(*here))