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 Nuszwkartlo
def checkio(a, b, c):
list = [a, b, c]
list.sort()
if ((list[0]+list[1])<=list[2]):
return [0, 0, 0]
cosinusA = ((list[0]*list[0])-(list[1]*list[1])-(list[2]*list[2]))/(-2*list[1]*list[2])
cosinusB = ((list[1]*list[1])-(list[0]*list[0])-(list[2]*list[2]))/(-2*list[0]*list[2])
cosinusC = ((list[2]*list[2])-(list[0]*list[0])-(list[1]*list[1]))/(-2*list[0]*list[1])
from math import degrees, acos
return (round(degrees(acos(cosinusA)),0),round(degrees(acos(cosinusB)),0),round(degrees(acos(cosinusC)),0))
#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"
Jan. 20, 2016