class Point:
def __init__(self,x,y):
self.x = x
self.y = y
def checkCollinearity(P1,P2,P3):
if P1.x*(P2.y-P3.y) - P1.y*(P2.x-P3.x) + P2.x*P3.y - P2.y*P3.x == 0:
return True
else:
return False
def main():
Points = []
for i in range(3):
print("Point#%d"%(i+1))
x = float(input("abs="))
y = float(input("ord="))
P = Point(x,y)
Points.append(P)
#method 1 with Slope
if Points[0].x == Points[1].x or Points[0].x == Points[2].x:
if Points[0].x == Points[2].x:
print("Collinear.")
else:
print("No Collinear.")
else:
if((Points[1].y - Points[0].y)/(Points[1].x - Points[0].x) == (Points[2].y - Points[1].y)/(Points[2].x - Points[1].x)):
print("Collinear.")
else:
print("No Collinear.")
#method 2 with Sarrus
if(checkCollinearity(Points[0], Points[1], Points[2]) is True):
print("Collinear.")
else:
print("No Collinear.")
main()
Y2xhc3MgUG9pbnQ6CiAgICBkZWYgX19pbml0X18oc2VsZix4LHkpOgogICAgICAgIHNlbGYueCA9IHgKICAgICAgICBzZWxmLnkgPSB5CmRlZiBjaGVja0NvbGxpbmVhcml0eShQMSxQMixQMyk6CiAgICBpZiBQMS54KihQMi55LVAzLnkpIC0gUDEueSooUDIueC1QMy54KSArIFAyLngqUDMueSAtIFAyLnkqUDMueCA9PSAwOgogICAgICAgcmV0dXJuIFRydWUKICAgIGVsc2U6CiAgICAgICByZXR1cm4gRmFsc2UKZGVmIG1haW4oKToKICAgIFBvaW50cyA9IFtdCiAgICBmb3IgaSBpbiByYW5nZSgzKToKICAgICAgICBwcmludCgiUG9pbnQjJWQiJShpKzEpKQogICAgICAgIHggPSBmbG9hdChpbnB1dCgiYWJzPSIpKQogICAgICAgIHkgPSBmbG9hdChpbnB1dCgib3JkPSIpKQogICAgICAgIFAgPSBQb2ludCh4LHkpCiAgICAgICAgUG9pbnRzLmFwcGVuZChQKQogICAgI21ldGhvZCAxIHdpdGggU2xvcGUgICAgCiAgICBpZiBQb2ludHNbMF0ueCA9PSBQb2ludHNbMV0ueCBvciBQb2ludHNbMF0ueCA9PSBQb2ludHNbMl0ueDoKICAgICAgIGlmIFBvaW50c1swXS54ID09IFBvaW50c1syXS54OgogICAgICAgICAgIHByaW50KCJDb2xsaW5lYXIuIikKICAgICAgIGVsc2U6CiAgICAgICAgICAgcHJpbnQoIk5vIENvbGxpbmVhci4iKQogICAgZWxzZToKICAgICAgICBpZigoUG9pbnRzWzFdLnkgLSBQb2ludHNbMF0ueSkvKFBvaW50c1sxXS54IC0gUG9pbnRzWzBdLngpID09IChQb2ludHNbMl0ueSAtIFBvaW50c1sxXS55KS8oUG9pbnRzWzJdLnggLSBQb2ludHNbMV0ueCkpOgogICAgICAgICAgICBwcmludCgiQ29sbGluZWFyLiIpCiAgICAgICAgZWxzZToKICAgICAgICAgICAgcHJpbnQoIk5vIENvbGxpbmVhci4iKQogCiAgICAjbWV0aG9kIDIgd2l0aCBTYXJydXMKICAgIGlmKGNoZWNrQ29sbGluZWFyaXR5KFBvaW50c1swXSwgUG9pbnRzWzFdLCBQb2ludHNbMl0pIGlzIFRydWUpOgogICAgICAgICAgICBwcmludCgiQ29sbGluZWFyLiIpCiAgICBlbHNlOgogICAgICAgICAgICBwcmludCgiTm8gQ29sbGluZWFyLiIpCm1haW4oKQ==