I am wondering if it is possible to take the binary strings of length $3$ (tuples) whose sums have weight $2$ (i.e they have $2$ non-zero entries)(binary case, meaning they have two $1$'s entries) $$u \in \text{tuples}$$ $$v \in \text{tuples}$$ $$u + v \in \text{tuples of weight } 2$$ and then recover which original strings ($u,v$) summed together to give a vector of weight $2$?
The following code takes all the possible binary strings of length $3$ (tuples) and then adds every string to every other string (filter). I do this in order to find the positions in which those strings differ (because they are binary strings, a 1 in position i means that both strings differed in the $i^{th}$ position).
I then use the If[]
function to see which resulting vectors from the filter have weight $2$.
However, what I would like to do would be to find a way to "reverse" this process and figure out which of the original tuples added together to give these vectors of weight 2 (two non-zero entries).
I'm not quite sure how to go about this. If anyone had any ideas, that would be great!
tuples=Tuples[{0,1},3]
filter=Flatten[Outer[Mod[Plus[##], 2] &, tuples, tuples, 1], 1]
distance2=If[Total[#] == 2, #, Nothing] & /@ filter
Select[filter, Total[#] == 2 &]
which gives the same resultdistance2
$\endgroup$