Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
complex locus solution in Clear category for Four To The Floor by ogoro
from math import e, pi
PRECISION = 1000
def is_covered(room, sensors):
width, height = room
for sensor in sensors:
sensor_x, sensor_y, sensor_radius = sensor
sensor_center = complex(sensor_y, sensor_x)
locus = (sensor_center + sensor_radius * e ** (2j * pi * segment_index / PRECISION)
for segment_index in range(PRECISION + 1))
locus_in_room = (point for point in locus
if height > point.real > 0
and width > point.imag > 0)
other_sensors = [other_sensor for other_sensor in sensors if sensor != other_sensor]
is_locus_covered = all(any(abs(point - complex(other_y, other_x)) <= other_radius
for other_x, other_y, other_radius in other_sensors)
for point in locus_in_room)
if not is_locus_covered:
return False
return True
April 7, 2021
Comments: