| 30 | """ |
| 31 | |
| 32 | def sum_of_three(arr, target=0) : |
| 33 | result = list() |
| 34 | arr.sort() |
| 35 | |
| 36 | for i in range(len(arr)-2) : |
| 37 | left = i+1;right=len(arr)-1 |
| 38 | |
| 39 | while left < right : |
| 40 | current_sum = arr[i] + arr[left] + arr[right] |
| 41 | if current_sum == target : |
| 42 | result.append((arr[i], arr[left], arr[right])) |
| 43 | left+=1 |
| 44 | right-=1 |
| 45 | elif current_sum < target : |
| 46 | left += 1 |
| 47 | elif current_sum > target : |
| 48 | right -= 1 |
| 49 | else : |
| 50 | print("Dont with the loop") |
| 51 | return result |
| 52 | |
| 53 | if __name__ == '__main__' : |
| 54 | print(sum_of_three([3,5,-4,8,11,1,-1,6])) |