generated from public/aoc_template
Day 3 - get rid of unnecessary if
This commit is contained in:
parent
55ba58a315
commit
cf12d0bd93
7
day03.py
7
day03.py
@ -22,9 +22,9 @@ class Day(AOCDay):
|
|||||||
def parse_input(self) -> Grid:
|
def parse_input(self) -> Grid:
|
||||||
grid = Grid()
|
grid = Grid()
|
||||||
num_found = 0
|
num_found = 0
|
||||||
for y, l in enumerate(self.getInput()):
|
|
||||||
number_digits = set()
|
number_digits = set()
|
||||||
number = 0
|
number = 0
|
||||||
|
for y, l in enumerate(self.getInput()):
|
||||||
for x, c in enumerate(l):
|
for x, c in enumerate(l):
|
||||||
if c.isdigit():
|
if c.isdigit():
|
||||||
number_digits.add((x, y))
|
number_digits.add((x, y))
|
||||||
@ -40,11 +40,6 @@ class Day(AOCDay):
|
|||||||
if c != ".":
|
if c != ".":
|
||||||
grid.set(Coordinate(x, y), c)
|
grid.set(Coordinate(x, y), c)
|
||||||
|
|
||||||
if number_digits:
|
|
||||||
for nc in number_digits:
|
|
||||||
grid.set(Coordinate(*nc), (num_found, number))
|
|
||||||
num_found += 1
|
|
||||||
|
|
||||||
return grid
|
return grid
|
||||||
|
|
||||||
def part1(self) -> Any:
|
def part1(self) -> Any:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user