Code formatting
Signed-off-by: AKU <tom@tdpain.net>
This commit is contained in:
parent
14b4e1fe1a
commit
6a47ee7439
1 changed files with 16 additions and 6 deletions
|
@ -4,6 +4,7 @@ from aocpy import BaseChallenge
|
|||
Point = Tuple[int, int]
|
||||
Cave = Dict[Point, int]
|
||||
|
||||
|
||||
def parse(instr: str) -> Cave:
|
||||
# I would be lying if I said I didn't copy this from day 9
|
||||
o = {}
|
||||
|
@ -12,11 +13,12 @@ def parse(instr: str) -> Cave:
|
|||
o[(x, y)] = int(digit)
|
||||
return o
|
||||
|
||||
|
||||
def print_cave(cave: Cave):
|
||||
max_x = max(x for x, y in cave)
|
||||
max_y = max(y for x, y in cave)
|
||||
for y in range(max_y+1):
|
||||
for x in range(max_x+1):
|
||||
for y in range(max_y + 1):
|
||||
for x in range(max_x + 1):
|
||||
print(cave[(x, y)], end="")
|
||||
print(flush=True)
|
||||
print()
|
||||
|
@ -24,7 +26,16 @@ def print_cave(cave: Cave):
|
|||
|
||||
def get_adjacent_points(point: Point) -> List[Point]:
|
||||
x, y = point
|
||||
return [(x, y - 1), (x - 1, y), (x + 1, y), (x, y + 1), (x-1, y-1), (x+1, y+1), (x-1, y+1), (x+1, y-1)]
|
||||
return [
|
||||
(x, y - 1),
|
||||
(x - 1, y),
|
||||
(x + 1, y),
|
||||
(x, y + 1),
|
||||
(x - 1, y - 1),
|
||||
(x + 1, y + 1),
|
||||
(x - 1, y + 1),
|
||||
(x + 1, y - 1),
|
||||
]
|
||||
|
||||
|
||||
def iterate(cave: Cave) -> Tuple[Cave, int, bool]:
|
||||
|
@ -66,7 +77,6 @@ def iterate(cave: Cave) -> Tuple[Cave, int, bool]:
|
|||
|
||||
|
||||
class Challenge(BaseChallenge):
|
||||
|
||||
@staticmethod
|
||||
def one(instr: str) -> int:
|
||||
cave = parse(instr)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue