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 Rafal__Kotas
import math
def checkio(a, b, c):
l=[]
A=0.0
B=0.0
C=0.0
if( a+b<=c or a+c<=b or a+b<=c):
return ([0, 0, 0])
else:
if(math.degrees( math.acos ( ((a*a+b*b-c*c) / (2*a*b)) ) )-math.floor( math.degrees( math.acos ( ((a*a+b*b-c*c) / (2*a*b)) ) ) )>0.5):
A=math.ceil( math.degrees( math.acos ( ((a*a+b*b-c*c) / (2*a*b)) ) ) )
else:
A=math.floor( math.degrees( math.acos ( ((a*a+b*b-c*c) / (2*a*b)) ) ) )
if( math.degrees( math.acos ( ((b*b+c*c-a*a) / (2*b*c)) ) ) - math.floor( math.degrees( math.acos ( ((b*b+c*c-a*a) / (2*b*c)) ) ) )>0.5):
B=math.ceil( math.degrees( math.acos ( ((b*b+c*c-a*a) / (2*b*c)) ) ) )
else:
B=math.floor( math.degrees( math.acos ( ((b*b+c*c-a*a) / (2*b*c)) ) ) )
if(math.degrees( math.acos ( ((a*a+c*c-b*b) / (2*a*c)) ) )- math.floor(math.degrees( math.acos ( ((a*a+c*c-b*b) / (2*a*c)) ) ) )>0.5 ):
C=math.ceil( math.degrees( math.acos ( ((a*a+c*c-b*b) / (2*a*c)) ) ) )
else:
C=math.floor(math.degrees( math.acos ( ((a*a+c*c-b*b) / (2*a*c)) ) ) )
print (A)
print (B)
print (C)
l.append(A)
l.append(B)
l.append(C)
for i in range (3):
for j in range(2):
if(l[j]>l[j+1]):
l[j], l[j+1] = l[j+1], l[j]
return (l)
#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. 3, 2016