Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Inside job solution in Clear category for Searchlights by veky
def vertices(xtop, ytop, side, n):
from cmath import pi, sin, exp
a, top = pi / n, complex(xtop, ytop)
for k in range(n): yield top + side/2j * (1 - exp(2j*a*k)) / sin(a)
def searchlights(polygons, lights):
return sum(any(abs(z - complex(xc, yc)) < r for xc, yc, r in lights)
for P in polygons for z in vertices(*P) if z.real > 0 < z.imag)
Nov. 20, 2019