Ctrl K

Triangle From Three Sticks

Easy
Three sticks lie on a table; their lengths are given in the array sticks. A child wants to build a triangle using each stick as one side. Decide what comes out: - "equilateral": all three sides are equal; - "isosceles": exactly two sides are equal; - "scalene": all sides have different lengths; - "none": no triangle can be built (two sides together are not longer than the third). Return one of these strings.
Example 1
sticks=[7, 7, 7] → 'equilateral'

All three sticks are equal, so the triangle is equilateral.

Example 2
sticks=[5, 9, 5] → 'isosceles'

5 + 5 = 10 > 9, so a triangle exists, and exactly two sides match: isosceles.

Example 3
sticks=[2, 3, 8] → 'none'

2 + 3 = 5 is not greater than 8: the short sticks cannot reach, so the answer is "none".

Constraints
  • len(sticks) == 3
  • 1 ≤ sticks[i] ≤ 100
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsThe Lost Ticket EasyBest Product of Three EasyTriangle From Sticks EasyHow a Rumor Spreads EasyWhere the Friends Should Meet Hard
loading Python…
Input
sticks=[7, 7, 7]
Expected
'equilateral'

Run checks the first 3 tests in your browser. Submit checks all 98 tests on the server, hidden ones included.