Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Law of Cosines solution in Creative category for The Angles of a Triangle by Renelvon
from math import acos, pi
'Find angle using law of cosines'
angle = lambda tr: acos((tr[0]**2 + tr[1]**2 - tr[2]**2) / (2*tr[0]*tr[1]))
def checkio(a, b, c, res=[0, 0, 0]):
lengths = [a,b,c,a,b,a+b-c,a+c-b,b+c-a]
if all(map(lambda x: x > 0, lengths)):
res = sorted(round(180 / pi * angle(lengths[i:i+3])) for i in range(3))
return res
#These "asserts" using only for self-checking and not necessary for auto-testing
May 19, 2014