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 Piotr.Helminiak
def checkio(a, b, c):
import math
list=[a,b,c]
list.sort()
a=list[0]
b=list[1]
c=list[2]
if (a+b)<=c:
return [0,0,0]
cos1=(b*b+c*c-a*a)/(2*b*c)
cos2=(a*a+c*c-b*b)/(2*a*c)
cos3=(a*a+b*b-c*c)/(2*a*b)
kat1=round(math.acos(cos1)*180/math.pi)
kat2=round(math.acos(cos2)*180/math.pi)
kat3=round(math.acos(cos3)*180/math.pi)
angles=[kat1,kat2,kat3]
angles.sort()
return angles
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio(4, 4, 4) == [60, 60, 60], "All sides are equal"
assert checkio(3, 4, 5) == [37, 53, 90], "Egyptian triangle"
assert checkio(2, 2, 5) == [0, 0, 0], "It's can not be a triangle"
Nov. 4, 2016