I have a few lists that contain additive inverse pairs (adding both pairs give you zero), and for each list I am trying to remove those pairs.
Below are a few examples, where I am trying to go from this:
lst1 = [326, -326, 336, -336, 336]
lst2 = [-35, 35, 838, -838, 440]
lst3 = [544, -544, 544]
lst4 = [-25, 25, 32, -32, -32, 56, 79]
To this:
lst1 = [336]
lst2 = [440]
lst3 = [544]
lst4 = [-32, 56, 79]
You can see that in each list, the additive inverse pairs are removed, leaving the values that have no additive inverse, or the 1 extra non-mirrored value.
I wish I could share what I have tried, but I have been at it for a few days and any logic I come up with falls apart with the example in lst4.
I seem to have found a solution that yields exactly what I need, however it is written in R which I have no experience in, so I cannot understand the logic.
Any ideas on how I can overcome this?