Last Updated: June 7, 2026
Not every set of three lengths closes into a triangle. If one side is too long, the other two cannot reach far enough to meet at a corner. Picture two sticks hinged at the base of the longest stick: to form a triangle they together have to span more than that base. If they sum to exactly the base, they lie flat along it and the triangle collapses into a line. If they sum to less, they cannot touch at all.
This is the triangle inequality, and it has to hold for all three choices of which side is the "base". Each pair of sides must sum to strictly more than the third.
> rather than >=.Turn the inequality into three conditions, one for each choice of the "third" side:
a + b > ca + c > bb + c > aIf all three hold, the lengths form a triangle. If any fails, they do not. Joining them with AND captures that.
With all sides positive, the only way to fail is for the largest side to be too long, so the two conditions with smaller "third" sides are easy to satisfy. Checking all three stays correct without first finding which side is largest.
a + b is strictly greater than c.a + c is strictly greater than b.b + c is strictly greater than a.true only if all three checks pass.Input:
The sides are 1, 1, and 2. The first check, 1 + 1 > 2, asks whether 2 > 2, which is false. The two short sides sum to exactly the long side, so they lie flat along it instead of meeting at a point. One failed condition is enough to reject the whole set, so the answer is false.