#246 · Math · Beginner · 35 XP · about 6 min
You are given the lengths of three sticks as whole numbers. They make a triangle only when every length is positive and the two shorter sticks together are longer than the longest one. If they are exactly as long, the "triangle" lies flat, and that does not count.
Write triangle_type(a, b, c) that returns one of these strings:
'not a triangle' when the sticks cannot make a triangle (check this first)'equilateral' when all three sides are equal'isosceles' when exactly two sides are equal'scalene' when all three sides are differentThe sides can come in any order.
triangle_type(3, 3, 3) # returns 'equilateral' triangle_type(5, 8, 5) # returns 'isosceles' triangle_type(3, 4, 5) # returns 'scalene' triangle_type(1, 2, 3) # returns 'not a triangle'
1 + 2 is exactly 3, so the last one lies flat.
First solves only, ranked by stars and then time.