Triangle Validity Checker

Easy ⏱ 8 min 73% acceptance ★★★★★ 4.9
Write a function is_valid_triangle(a, b, c) that returns True if three side lengths can form a valid triangle (the sum of any two sides must exceed the third side), and False otherwise.

Examples

Example 1
Input
is_valid_triangle(3, 4, 5)
Output
True
Explanation

3+4>5, 4+5>3, and 3+5>4.

Example 2
Input
is_valid_triangle(1, 2, 10)
Output
False
Explanation

1+2 is not greater than 10.

Constraints

  • a, b, c are positive numbers.

Topics

Conditional Statementsif/else

Companies

OracleIBM

Hints

Hint 1

You need to check the triangle inequality for all three pairings.

Hint 2

Combine the three checks with `and`.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.