Triangle and Its Three Sides
InterviewTime limit1sMemory limit128 MB
Read triples of positive integers until 0 0 0, and for each print Equilateral, Isosceles, Scalene, or Invalid based on equal sides and the triangle inequality.
- Level
Easy1 of 10
- Topics
- Implementation, Math, Sorting
- Solved
- No attempts yet
Problem
Given the lengths of the three sides of a triangle, classify it according to the following definitions.
- Equilateral: all three sides have the same length
- Isosceles: exactly two sides have the same length
- Scalene: all three sides have different lengths
However, if the three given lengths cannot form a triangle, output "Invalid". The lengths cannot form a triangle when the sum of the two shorter sides is not greater than the longest side (that is, less than or equal to it). For example, 6, 3, 2 is such a case, since the longest side 6 is greater than 3 + 2 = 5.
Given the three side lengths, print the result according to the definitions above.
Input
Each line contains three positive integers, each not exceeding 1,000, separated by spaces. The last line is 0 0 0; this line marks the end of the input and is not processed.
Output
For each input line, print the corresponding result (Equilateral, Isosceles, Scalene, or Invalid), one per line.