Triangle Judgement

2pts
Uber

Problem Statement

Uber relies on geometric algorithms for mapping and routing. A fundamental check is determining if three line segments can form a triangle. According to the triangle inequality theorem, for any three sides, the sum of any two sides must be strictly greater than the third side.

Write an SQL query to report for every three line segments whether they can form a triangle.

Rules:

  • Create a new column triangle that contains "Yes" if the segments form a triangle and "No" otherwise.
  • Return all original columns (x, y, z) plus the new triangle column.
  • Results must be sorted by x, y, and z in ascending order.
Tests your understanding of
Basic SQL, Conditional Logic, CASE Statement and Math

Input Tables

triangle
x(INTEGER)y(INTEGER)z(INTEGER)
131530
101010

Expected Output

x(INTEGER)y(INTEGER)z(INTEGER)triangle(VARCHAR)
101010Yes
131530No

Tags

EasyBasic SQLConditional LogicCASE StatementMath
5-10 min
70%

Hints