Given a list of lists, the task is to find whether a sublist satisfies the triangle inequality.
The triangle inequality states that for any triangle, the sum of the lengths of any two sides must be greater than or equal to the length of the remaining side. In other words, a triangle is valid if sum of its two sides is greater than the third side. If three sides are a, b and c, then three conditions should be met.
a + b > c a + c > b b + c > a
Method #1 : Using List comprehension
[(4, 5, 6)]
Method #2 : Using Iteration
[4, 5, 6]
- Python | Checking if starting digits are similar in list
- Python | Program to count number of lists in a list of lists
- Python | Merge List with common elements in a List of Lists
- Python | Sorting list of lists with similar list elements
- Python | Maximum sum of elements of list in a list of lists
- Python | Ways to sum list of lists and return sum list
- Python | Check if a list exists in given list of lists
- Python | Convert List of lists to list of Strings
- Python | Convert list into list of lists
- Python | Split list into lists by particular value
- Python - Sum of different length Lists of list
- Python | Merge two list of lists according to first element
- Python | Split nested list into two lists
- Python | Remove given element from list of lists
- Python | Get positive elements from given list of lists
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.