Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for The Angles of a Triangle by Bartlomiej_Szal
import math
def checkTriangleCondition(a,b,c):
list = [a,b,c]
list = sorted(list)
if list[2] >= list[0] + list[1]:
return False
else:
return True
def checkio(a, b, c):
if not checkTriangleCondition(a,b,c):
return [0,0,0]
sides = [a, b, c]
sides = sorted(sides)
cos = (sides[2]**2 - sides[0]**2 - sides[1]**2)/(-2 * sides[0] * sides[1])
angle1 = math.degrees(math.acos(cos))
cos2 = (sides[0]**2 - sides[2]**2 - sides[1]**2)/(-2 * sides[2] * sides[1])
angle2 = math.degrees(math.acos(cos2))
angle3 = 180 - round(angle1) - round(angle2)
angles = [round(angle1), round(angle2), round(angle3)]
return sorted(angles)
Oct. 12, 2016