MCPcopy Create free account
hub / github.com/AxlLind/AdventOfCode / get_target

Function get_target

2018/src/15.py:21–26  ·  view source on GitHub ↗
(m: list[list[tuple[str,int]]], r: int, c: int, enemy: str)

Source from the content-addressed store, hash-verified

19 return None
20
21def get_target(m: list[list[tuple[str,int]]], r: int, c: int, enemy: str) -> tuple[int,int] | None:
22 minhp, rt, ct = 1000, None, None
23 for rr,cc in [(r-1,c),(r,c-1),(r,c+1),(r+1,c)]:
24 if m[rr][cc][0] == enemy and m[rr][cc][1] < minhp:
25 minhp,rt,ct = m[rr][cc][1],rr,cc
26 return (rt,ct) if rt and ct else None
27
28def step(m: list[list[tuple[str,int]]], dmg: dict[str,int]):
29 moved = set()

Callers 1

stepFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected