You will write the triangle inequality as code, find the limits for a third side, and list the whole numbers that fit.
The idea. Three lengths make a triangle when the longest is less than the sum of the other two. If two sides are and , the third side must satisfy .
Your tasks.
can_form, return True when the three lengths make a triangle.third_side_limits, return the pair (low, high) with low = |a - b| and high = a + b.whole_numbers, return the list of whole numbers that the third side can be.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…