28 lines
735 B
Python
Executable File
28 lines
735 B
Python
Executable File
#!/usr/bin/env python3.11
|
|
|
|
from common import *
|
|
import shapely
|
|
|
|
|
|
def inside_points(labyrinth: Labyrinth) -> list[Point]:
|
|
labyrinth = labyrinth.clean()
|
|
path = labyrinth.get_path()
|
|
empty_points = labyrinth.get_empty_points()
|
|
logging.debug("let's shapely that")
|
|
shp_path = []
|
|
for point in path:
|
|
shp_path.append(shapely.Point(point.x, point.y))
|
|
polygon = shapely.Polygon(shp_path)
|
|
inside_points = []
|
|
for point in empty_points:
|
|
current = shapely.Point(point.x, point.y)
|
|
if shapely.contains(polygon, current):
|
|
inside_points.append(point)
|
|
|
|
return inside_points
|
|
|
|
|
|
if __name__ == "__main__":
|
|
labyrinth = parse("input.txt")
|
|
print(len(inside_points(labyrinth)))
|