Unique magic triplets
Ruby, 46 51 58 bytes
->l{l.permutation(3).select{|a,b,c|a+b==c}.map(&:sort)|[]}
Try it online!
Ok, not so straightforward, but now seems to work.
05AB1E, 11 10 9 10 bytes
{æ3ùêʒxsOå
+1 byte as bugfix for test cases like [1,0,-1] → [[-1,0,1]] (-1+1=0)
and [-1,-2,-3] → [[-3,-2,-1]] (-1+-2=-3)
.
Try it online or verify all test cases.
Explanation:
{ # Sort the (implicit) input-list from lowest to highest value
æ # Take the powerset of this sorted list
3ù # Only keep inner lists of length 3
ê # (Sort and) uniquify this entire list of triplets
ʒ # Filter this list of (individually sorted) triplets by:
x # Double each value in the triplet (without popping the triplet itself)
s # Swap to get the original triplet
O # Take the sum of this triplet
å # And check whether this value is in the doubled list
# (after which the filtered list is output implicitly as result)
The last four bytes could alternatively be œÆ0å
(given by @Grimy): Try it online or verify all test cases.
œ # Get all possible permutations of the triplet
Æ # Reduce each by subtracting: [a,b,c] → a-b-c
0å # And check if there are any 0s among the reduced permutations
Jelly, 10 bytes
Ṣœc3ḤiSƊƇQ
Try it online!
Ṣ Sort the input,
œc3 find all length-3 subsequences,
Ƈ filter to only the sets for which
S the sum of all three elements
i is an element of
Ḥ Ɗ the set with all elements doubled,
Q and uniquify.