Problem 199171 · medium · Phase 01 Prerequisites & Setup

Triangle Classifier

conditionals · boolean logic

Write classify_triangle(a, b, c) that takes three side lengths and returns:

  • "not a triangle" if the sides cannot form a triangle (any side is 0, or the two shorter sides do not add up to more than the longest one),
  • "equilateral" if all three sides are equal,
  • "isosceles" if exactly two sides are equal,
  • "scalene" if all sides are different.

Examples

Input:  a = 3, b = 4, c = 5
Output: "scalene"

Input:  a = 2, b = 2, c = 2
Output: "equilateral"

Input:  a = 1, b = 2, c = 3
Output: "not a triangle"

Constraints

  • 0 <= a, b, c <= 1000 (integers)

Goals

  • Reject impossible triangles with the triangle inequality
  • Combine equality tests with and/or
  • Order the checks so the most specific case wins
Starting Python…