Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for The Angles of a Triangle by mdroz
import math
def checkio(a, b, c):
tab = []
if a + b <= c or b + c <= a or c + a <= b:
tab.append(0)
tab.append(0)
tab.append(0)
return tab
else:
p = (a+b+c)*0.5
P = math.sqrt(p*(p-a)*(p-b)*(p-c))
sin_a = P/(0.5*b*c)
sin_b = P/(0.5*a*c)
sin_c = P/(0.5*a*b)
a = round(math.degrees(math.asin(sin_a)))
tab.append(a)
b = round(math.degrees(math.asin(sin_b)))
tab.append(b)
c = 180 - (a+b)
tab.append(c)
tab.sort()
return tab
#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(11,20,30) == [11,20,30], "Egyptian triangle"
# assert checkio(2, 2, 5) == [0, 0, 0], "It's can not be a triangle"
Oct. 30, 2017