day15: minimal code beautifications
This commit is contained in:
parent
8b31c6c531
commit
56c4e03322
18
day15.py
18
day15.py
@ -10,16 +10,16 @@ def getGrid(lines: List[str], multiply: bool = False) -> Grid:
|
|||||||
for y, l in enumerate(lines):
|
for y, l in enumerate(lines):
|
||||||
for x, v in enumerate(map(int, l)):
|
for x, v in enumerate(map(int, l)):
|
||||||
g.set(Coordinate(x, y), v)
|
g.set(Coordinate(x, y), v)
|
||||||
if multiply:
|
if not multiply:
|
||||||
for x2 in range(5):
|
continue
|
||||||
for y2 in range(5):
|
|
||||||
if x2 == 0 and y2 == 0:
|
|
||||||
continue
|
|
||||||
nv = v + x2 + y2
|
|
||||||
if nv > 9:
|
|
||||||
nv -= 9
|
|
||||||
|
|
||||||
g.set(Coordinate(size * x2 + x, size * y2 + y), nv)
|
for x2 in range(5):
|
||||||
|
for y2 in range(5):
|
||||||
|
if x2 == y2 == 0:
|
||||||
|
continue
|
||||||
|
nv = 1 + (v + x2 + y2 - 1) % 9
|
||||||
|
|
||||||
|
g.set(Coordinate(size * x2 + x, size * y2 + y), nv)
|
||||||
|
|
||||||
return g
|
return g
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user