diff --git a/day14.py b/day14.py index 246a173..1751d70 100644 --- a/day14.py +++ b/day14.py @@ -48,26 +48,17 @@ class Day(AOCDay): def part2(self) -> Any: robots = self.parse_input() + num_robots = len(robots) count = 0 while True: count += 1 - _, new_robots = self.move_robots(robots, steps=1) - g = Grid() - for robot in new_robots: - g.set(Coordinate(robot[0][0], robot[0][1])) + _, robots = self.move_robots(robots, steps=1) - found = False - for c in g.getActiveCells(): - if len(set(g.getRegion(c))) > 50: - found = True - break - - if found: + # We assume, there is only one case where no robots overlap + if len(set(x[0] for x in robots)) == num_robots: break - robots = new_robots - return count