Classify a triangle from three side lengths.
Problem
You are given the lengths of three sides. Determine what type of triangle they form.
Return:
equilateralif all three sides are equal,isoscelesif exactly two sides are equal,scaleneif all three sides are different.
If the three lengths cannot form a valid triangle, return invalid.
Notes
A valid triangle must satisfy:
- each side length is positive, and
- the sum of any two sides is greater than the third side.
Input Format
Three integers representing the side lengths of a triangle.
Output Format
Return one of the strings: equilateral, isosceles, scalene, or invalid.
Constraints
- Side lengths are integers.
- Side lengths may be in any order.
- Use the triangle inequality to determine validity.
Example 1
Input
a = 3, b = 3, c = 3
Output
equilateral
Explanation
All three sides are equal and the triangle inequality holds.
Example 2
Input
a = 4, b = 4, c = 6
Output
isosceles
Explanation
Exactly two sides are equal, and the three lengths can form a valid triangle.
Show 1 more example
Example 3
Input
a = 2, b = 3, c = 7
Output
invalid
Explanation
The sum of the two smaller sides is not greater than the largest side.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.