generated from public/aoc_template
day14 - sub 1s
This commit is contained in:
parent
9aecc95f30
commit
d1ccb8222c
17
day14.py
17
day14.py
@ -48,26 +48,17 @@ class Day(AOCDay):
|
|||||||
|
|
||||||
def part2(self) -> Any:
|
def part2(self) -> Any:
|
||||||
robots = self.parse_input()
|
robots = self.parse_input()
|
||||||
|
num_robots = len(robots)
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
while True:
|
while True:
|
||||||
count += 1
|
count += 1
|
||||||
_, new_robots = self.move_robots(robots, steps=1)
|
_, robots = self.move_robots(robots, steps=1)
|
||||||
g = Grid()
|
|
||||||
for robot in new_robots:
|
|
||||||
g.set(Coordinate(robot[0][0], robot[0][1]))
|
|
||||||
|
|
||||||
found = False
|
# We assume, there is only one case where no robots overlap
|
||||||
for c in g.getActiveCells():
|
if len(set(x[0] for x in robots)) == num_robots:
|
||||||
if len(set(g.getRegion(c))) > 50:
|
|
||||||
found = True
|
|
||||||
break
|
break
|
||||||
|
|
||||||
if found:
|
|
||||||
break
|
|
||||||
|
|
||||||
robots = new_robots
|
|
||||||
|
|
||||||
return count
|
return count
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user