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 Haradd
import math
def checkio(a, b, c):
bok=[a,b,c]
bok.sort()
if bok[0]+bok[1]<=bok[2]:
return [0, 0, 0]
#/*** ang2 = round(math.acos((edges[0] ** 2 + edges[2] ** 2 - edges[1] ** 2) / float(2 * edges[0] * edges[2]))/pi*180) ***
alfa=round(math.degrees(math.acos((-bok[1]**2+bok[2]**2+bok[0]**2)/float(2*bok[2]*bok[0]))))
beta=round(math.degrees(math.acos((-bok[0]**2+bok[2]**2+bok[1]**2)/float(2*bok[2]*bok[1]))))
gamma=180-alfa-beta
result=[alfa,beta,gamma]
result.sort()
return result
#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. 7, 2016