Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Complex solution in Clear category for Count Squares by Phil15
import itertools as it
def count_squares(points: list[list[int]]) -> int:
points = frozenset(x + 1j * y for x, y in points)
return len({
frozenset((z0, z1, z2, z3))
for z0, z1 in it.combinations(points, 2)
for e in (-1j, 1j)
if (z2 := z0 + e * (z1 - z0)) in points
and (z3 := z1 - e * (z0 - z1)) in points
})
June 29, 2023
Comments: