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 Kamil0320
import math
def f(x,y,z):
return math.floor(math.degrees(math.acos((x**2-y**2-z**2)/(-2*y*z)))+0.5)
#zaokrąglenie do najbliższej liczby całkowitej od arccos wyrażonego w stopniach
def checkio(a, b, c):
list=[]
list.append(a)
list.append(b)
list.append(c)
list.sort()
if list[0]+list[1]<=list[2]:
return [0,0,0]
else:
alfa=f(a,b,c)
beta=f(b,c,a)
gamma=f(c,a,b)
res=[alfa,beta,gamma]
res.sort()
return res
#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. 28, 2016