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 Angelika
import math
def checkio(a, b, c):
katy=[]
if a+b<=c or a+c<=b or b+c<=a:
for i in range(3):
katy.append(0)
else:
cosa=(b*b+c*c-a*a)/(2*b*c)
cosb=(a*a+c*c-b*b)/(2*a*c)
cosc=(b*b+a*a-c*c)/(2*b*a)
a=math.acos(cosa)
b=math.acos(cosb)
c=math.acos(cosc)
a=math.degrees(a)
b=math.degrees(b)
c=math.degrees(c)
a=a*10
b=b*10
c=c*10
a=int(a)
b=int(b)
c=int(c)
x=a%10
if x>=5:
a=a+10
x=b%10
if x>=5:
b=b+10
x=c%10
if x>=5:
c=c+10
a=a/10
b=b/10
c=c/10
a=int(a)
b=int(b)
c=int(c)
for i in range(3):
x=min(a,b,c)
katy.append(x)
if x==a:
a=1000000
elif x==b:
b=1000000
elif x==c:
c=1000000
return katy
#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. 31, 2016