Exercise · Conditions · lesson 7 of 7
Exercise: triangle kind
Write a function func triangleKind(a, b, c int) string that tells the kind of a triangle from the lengths of its three sides. It returns "equilateral" if all sides are equal, "isosceles" if exactly two are equal, and "scalene" if all differ. If no triangle with such sides exists, the function returns "invalid".
triangleKind(3, 4, 5)→"scalene"triangleKind(5, 5, 8)→"isosceles"triangleKind(1, 2, 3)→"invalid"
Constraints: the sides are integers from −100 to 100 in any order. A triangle does not exist if some side is not greater than zero or not less than the sum of the other two.
Do not add extra imports unless the task says so explicitly.
Subscribe to take the course
The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.