Triangle Validator - Problem
Given three positive integers representing the lengths of three sides, determine if they can form a valid triangle. If they can form a valid triangle, classify it as:
- Equilateral - All three sides are equal
- Isosceles - Exactly two sides are equal
- Scalene - All three sides are different
For three sides to form a valid triangle, they must satisfy the triangle inequality theorem: the sum of any two sides must be greater than the third side.
Input: Three positive integers a, b, and c representing side lengths.
Output: Return "Invalid" if they cannot form a triangle, otherwise return the triangle type as a string.
Input & Output
Example 1 — Valid Scalene Triangle
$
Input:
a = 5, b = 12, c = 13
›
Output:
Scalene
💡 Note:
Triangle inequality: 5+12=17>13 ✓, 5+13=18>12 ✓, 12+13=25>5 ✓. All sides different, so it's Scalene.
Example 2 — Valid Isosceles Triangle
$
Input:
a = 5, b = 5, c = 8
›
Output:
Isosceles
💡 Note:
Triangle inequality: 5+5=10>8 ✓, 5+8=13>5 ✓, 5+8=13>5 ✓. Two sides equal (a=b=5), so it's Isosceles.
Example 3 — Invalid Triangle
$
Input:
a = 1, b = 2, c = 5
›
Output:
Invalid
💡 Note:
Triangle inequality fails: 1+2=3 is not greater than 5. Cannot form a valid triangle.
Constraints
- 1 ≤ a, b, c ≤ 1000
- All inputs are positive integers
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code