Classify a Triangle by Its Sides
Given an array sides containing exactly three integer side lengths from 0 through 1000, classify the triangle by its sides. Return Invalid if a side is zero…
Given an array `sides` containing exactly three integer side lengths from 0 through 1000, classify the triangle by its sides. Return `Invalid` if a side is zero or any two sides sum to at most the third side. Otherwise return `Equilateral` when all sides are equal, `Isosceles` when exactly two sides are equal, or `Scalene` when all three differ. The order of the input sides does not change the classification, and the input must remain unchanged.
- `sides` contains exactly three integer values. - Each value is in `[0, 1000]`; booleans, nonintegers, negative values, and values above 1000 are invalid. - A zero side is a valid input that produces `Invalid`. - A triangle is valid only when `a + b > c`, `a + c > b`, and `b + c > a`. - Return exactly one case-sensitive string: `Invalid`, `Equilateral`, `Isosceles`, or `Scalene`. - Coding and visualization domains are the same fixed three-element domain.
Example 1: input sides = [4, 4, 4]; output Equilateral. All three sides are equal and the strict triangle inequalities hold.
Example 2: input sides = [3, 4, 4]; output Isosceles. The sides form a valid triangle, and exactly two sides are equal.
Example 3: input sides = [3, 4, 5]; output Scalene. The sides form a valid triangle and all three side lengths differ.
Category: Math & Numbers. Topic: math. Difficulty: Easy. Patterns: math.