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 stanwys
def checkio(a, b, c):
import math
if(a==b & b==c):
return[60,60,60]
elif(a+b<=c or b+c<=a)or(a+c<=b):
return[0,0,0]
else:
ca=(b**2+c**2-a**2)/(2*b*c)
cb=(a**2+c**2-b**2)/(2*a*c)
cc=(b**2+a**2-c**2)/(2*b*a)
xa=math.acos(ca)
xb=math.acos(cb)
xc=math.acos(cc)
ya=math.degrees(xa)
yb=math.degrees(xb)
yc=math.degrees(xc)
ya=round(ya,0)
yb=round(yb,0)
yc=round(yc,0)
lis=[ya,yb,yc]
lis.sort()
return lis
#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"
Oct. 23, 2016