Python: Determine which triples sum to zero
Zero-Sum Triples Finder
Write a Python program to determine which triples sum to zero from a given list of lists.
Input: [[1343532, -2920635, 332], [-27, 18, 9], [4, 0, -4], [2, 2, 2], [-20, 16, 4]] Output: [False, True, True, False, True] Input: [[1, 2, -3], [-4, 0, 4], [0, 1, -5], [1, 1, 1], [-2, 4, -1]] Output: [True, True, False, False, False]
Visual Presentation:

Sample Solution-1:
Python Code:
Sample Output:
Original list of lists: [[1343532, -2920635, 332], [-27, 18, 9], [4, 0, -4], [2, 2, 2], [-20, 16, 4]] Determine which triples sum to zero: [False, True, True, False, True] Original list of lists: [[1, 2, -3], [-4, 0, 4], [0, 1, -5], [1, 1, 1], [-2, 4, -1]] Determine which triples sum to zero: [True, True, False, False, False]
Flowchart:

Sample Solution-2:
Python Code:
Sample Output:
Original list of lists: [[1343532, -2920635, 332], [-27, 18, 9], [4, 0, -4], [2, 2, 2], [-20, 16, 4]] Determine which triples sum to zero: [False, True, True, False, True] Original list of lists: [[1, 2, -3], [-4, 0, 4], [0, 1, -5], [1, 1, 1], [-2, 4, -1]] Determine which triples sum to zero: [True, True, False, False, False]
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Python program to identify and return a list of booleans indicating which sublists sum to zero from a list of triple lists.
- Write a Python program to check each triple in a list of triples and return True if the elements sum to zero.
- Write a Python program to use list comprehension to verify zero-sum properties for each triple in a nested list.
- Write a Python program to iterate through a list of triple lists and determine for each whether their sum is zero.
Go to:
Previous: Sort the numbers by the sum of their digits.
Next: Find string s that, when case is flipped gives target where vowels are replaced by chars two later.
Python Code Editor :
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.