In this kata, you should calculate type of triangle with three given sides ``a``, ``b`` and ``c`` (given in any order).

If all angles are less than ``90°``, this triangle is ``acute`` and function should return ``1``.

If one angle is strictly ``90°``, this triangle is ``right`` and function should return ``2``.

If one angle more than ``90°``, this triangle is ``obtuse`` and function should return ``3``.

If three sides cannot form triangle, or one angle is ``180°`` (which turns triangle into segment) - function should return ``0``.

Input parameters are ``sides`` of given triangle. All input values are non-negative floating point or integer numbers (or both).




Acute


Right


Obtuse




### Examples:
```python
triangle_type(2, 4, 6) # return 0 (Not triangle)
triangle_type(8, 5, 7) # return 1 (Acute, angles are approx. 82°, 38° and 60°)
triangle_type(3, 4, 5) # return 2 (Right, angles are approx. 37°, 53° and exactly 90°)
triangle_type(7, 12, 8) # return 3 (Obtuse, angles are approx. 34°, 106° and 40°)
```

If you stuck, this can help you: http://en.wikipedia.org/wiki/Law_of_cosines. But you can solve this kata even without angle calculation.

There is very small chance of random test to fail due to round-off error, in such case resubmit your solution.

Source: codewars | Difficulty: EASY
Tags: Geometry

Mathematics

Starter code: def triangle_type(a, b, c):
	

Solutions:
def triangle_type(a, b, c):
	(x, y, z) = sorted([a, b, c])
	if z >= x + y:
		return 0
	if z * z == x * x + y * y:
		return 2
	return 1 if z * z < x * x + y * y else 3


def triangle_type(a, b, c):
	(a, b, c) = sorted((a, b, c))
	if a + b <= c:
		return 0
	t = a ** 2 + b ** 2 - c ** 2
	if t > 0:
		return 1
	if t == 0:
		return 2
	else:
		return 3


def triangle_type(a, b, c):
	(x, y, z) = sorted([a, b, c])
	diff = z * z - y * y - x * x
	if z >= x + y:
		return 0
	elif not diff:
		return 2
	return 1 if diff < 0 else 3


def triangle_type(a, b, c):
	(a, b, c) = sorted([a, b, c])
	if a + b - c <= 0:
		return 0
	(aa_bb, cc) = (a * a + b * b, c * c)
	if aa_bb > cc:
		return 1
	elif aa_bb == cc:
		return 2
	else:
		return 3


def is_triangle(a, b, c):
	return a + b > c

def is_at_least_right(a, b, c):
	return is_triangle(a, b, c) and a * a + b * b <= c * c

def is_obtuse(a, b, c):
	return is_triangle(a, b, c) and a * a + b * b < c * c

def triangle_type(a, b, c):
	(a, b, c) = sorted([a, b, c])
	return is_triangle(a, b, c) + is_at_least_right(a, b, c) + is_obtuse(a, b, c)


def triangle_type(*sides):
	(a, b, c) = sorted(sides)
	if a + b <= c:
		return 0
	(ab2, c2) = (a * a + b * b, c * c)
	return 1 if ab2 > c2 else 2 if ab2 == c2 else 3


def triangle_type(a, b, c):
	if max(a, b, c) >= sum([a, b, c]) / 2:
		return 0
	sq = [max(a, b, c) ** 2, sum([x ** 2 for x in [a, b, c]]) / 2]
	return 3 if sq[0] > sq[1] else 2 if sq[0] == sq[1] else 1


def triangle_type(a, b, c):
	h = max(a, b, c)
	return 0 if a + b + c <= 2 * h else 1 if 2 * h ** 2 < a ** 2 + b ** 2 + c ** 2 else 2 if 2 * h ** 2 == a ** 2 + b ** 2 + c ** 2 else 3