Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Boring solution in Clear category for Convex Hull by veky
def checkio(data):
import cmath
i0 = data.index(min(data))
data = [x*1j - y for x, y in data]
limit, orig, hull = (cmath.pi, float("inf")), data[i0], [i0]
while True:
maxkey = -cmath.pi, None
for ind, pt in enumerate(data):
rel = pt - orig
key = cmath.phase(rel), -abs(rel)
if maxkey < key <= limit and rel:
maxkey = key
i = ind
print(i)
if i == i0: return hull
hull.append(i)
limit, orig = (maxkey[0], float("inf")), data[i]
March 2, 2014
Comments: