You are viewing a single comment's thread. Return to all comments →
Python
def calculate_triangle_area(x1, y1, x2, y2, x3, y3): area = 0.5 * abs(x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) return area ret = 0 for _ in range(int(input())): x1, y1, x2, y2, x3, y3 = map(int, input().split()) area = calculate_triangle_area(x1, y1, x2, y2, x3, y3) area1 = calculate_triangle_area(0, 0, x2, y2, x3, y3) area2 = calculate_triangle_area(x1, y1, 0, 0, x3, y3) area3 = calculate_triangle_area(x1, y1, x2, y2, 0, 0) if area == area1 + area2 + area3: ret += 1 print(ret)
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #102: Triangle containment
You are viewing a single comment's thread. Return to all comments →
Python