返回所有和为0且不重复的三元组
import numpy as np
nums = [0, 0, 0, 0]
ans = []
for i in range(len(nums)):
for j in range(i+1, len(nums)):
for k in range(j+1, len(nums)):
if nums[i] + nums[j] + nums[k] == 0:
ans.append([nums[i], nums[j], nums[k]])
for i in range(len(ans)):
ans[i].sort()
ans = np.unique(ans, axis=0)
print(ans)