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 sawako.oono
from typing import List
import math
from itertools import permutations
def checkio(a: int, b: int, c: int) -> List[int]:
for x in (a,b,c):
if x>=sum((a,b,c))-x:
return [0, 0, 0]
degrees=[]
for d,e,f in ((a,b,c),(b,c,a),(c,a,b)):
degrees.append(round(math.degrees(math.acos((d**2+e**2-f**2)/(2*d*e)))))
degrees.sort()
return degrees
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
print("Example:")
print(checkio(4, 4, 4))
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"
print("Coding complete? Click 'Check' to earn cool rewards!")
June 11, 2021