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 ndj_ys
from typing import List
import math
from decimal import *
def checkio(a: int, b: int, c: int) -> List[int]:
try:
A = int(Decimal(math.degrees(math.acos((b*b + c*c - a*a) / (2*b*c)))).quantize(Decimal('0'),rounding=ROUND_HALF_UP))
B = int(Decimal(math.degrees(math.acos((a*a + c*c - b*b) / (2*a*c)))).quantize(Decimal('0'),rounding=ROUND_HALF_UP))
C = int(Decimal(math.degrees(math.acos((a*a + b*b - c*c) / (2*a*b)))).quantize(Decimal('0'),rounding=ROUND_HALF_UP))
if A+B >= 180 or A+C >= 180 or B+C >= 180:
return [0,0,0]
return sorted([A,B,C])
except ValueError:
return [0,0,0]
Aug. 30, 2018