Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
9-liner: combine all pairs solution in Clear category for Wild Dogs by przemyslaw.daniel
def wild_dogs(coords):
from itertools import combinations
result = []
for (x0, y0), (x1, y1) in combinations(coords, 2):
A, B, C = y0-y1, x1-x0, y0*(x0-x1)-x0*(y0-y1)
distance = abs(C)/(A**2+B**2)**0.5
result += [(distance, (1, B/A, C/A) if A else (A/B, 1, C/B))]
distance, *_ = max(result, key=lambda x: (result.count(x), -x[0]))
return round(distance, 2)
Sept. 11, 2018
Comments: