Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Ugly one solution in Clear category for Three Points Circle by michal_bien
from math import sqrt
def checkio(data):
data=data.replace('(','').replace(')','').split(',')
x = [int(data[i]) for i in range(0,6,2)]
y = [int(data[i]) for i in range(1,6,2)]
xsl = x[1]**2*y[2]+y[1]**2*y[2]-x[0]*x[0]*y[2]+x[0]*x[0]*y[1]-y[0]*y[0]*y[2]+y[0]*y[0]*y[1]+y[0]*x[2]**2+y[0]*y[2]**2-y[0]*x[1]**2-y[0]*y[1]**2-y[1]*x[2]**2-y[1]*y[2]**2
xsm = y[0]*x[2]-y[0]*x[1]-y[1]*x[2]-y[2]*x[0]+y[2]*x[1]+y[1]*x[0]
xs= xsl/xsm/2
ysl = ((-x[0]*x[2]**2)-(x[0]*y[2]**2)+(x[0]*x[1]**2)+(x[0]*y[1]**2)+(x[1]*x[2]**2)+(x[1]*y[2]**2)-(x[1]**2*x[2])-(y[1]**2*x[2])+(x[0]**2*x[2])-(x[0]**2*x[1])+(y[0]**2*x[2])-(y[0]**2*x[1]))
ysm = ((y[0]*x[2])-(y[0]*x[1])-(y[1]*x[2])-(y[2]*x[0])+(y[2]*x[1])+(y[1]*x[0]))
ys = ysl/ysm/2
r = round(sqrt((x[0]-xs)**2+(y[0]-ys)**2)*100)/100
xs = round(xs*100)/100
ys = round(ys*100)/100
if (xs*100)%100==0:
xs=int(xs)
if (ys*100)%100==0:
ys=int(ys)
if (r*100)%100==0:
r=int(r)
res = '(x'+str(-xs)+')^2+(y'+str(-ys)+')^2='+str(r)+'^2'
return res
Oct. 14, 2016