2013-04-17 14:34:39 +08:00

27 lines
563 B
Python

def pl(p1, p2):
return p1[0] * p2[1] - p1[1] * p2[0]
def isit(lis):
if pl(lis[1], lis[0]) * pl(lis[2], lis[0]) > 0:
return False
if pl(lis[0], lis[1]) * pl(lis[2], lis[1]) > 0:
return False
if pl(lis[0], lis[2]) * pl(lis[1], lis[2]) > 0:
return False
return True
def breaknum(lis):
return [[int(lis[0]), int(lis[1])], [int(lis[2]), int(lis[3])], [int(lis[4]), int(lis[5])]]
ff = open('../triangles.txt', 'r')
points = ff.readlines()
ff.close()
count = 0
for i in points:
if isit(breaknum(i.split(','))):
count += 1
print count