I am sorry for not being detailed, I will try to explain it to you @rocco_sprmnt21.
In this task, the array is:
a = [1, 0, 0, 1, 0, 1, 0, 1]
Then I need to XOR array a with each of the arrays below:
z = [0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 1; 0 0 0 0 0 0 1 0; 0 0 0 0 0 0 1 1;
0 0 0 0 0 1 0 0; 0 0 0 0 0 1 0 1; 0 0 0 0 0 1 1 0; 0 0 0 0 0 1 1 1;
0 0 0 0 1 0 0 0; 0 0 0 0 1 0 0 1; 0 0 0 0 1 0 1 0; 0 0 0 0 1 0 1 1;
0 0 0 0 1 1 0 0; 0 0 0 0 1 1 0 1; 0 0 0 0 1 1 1 0; 0 0 0 0 1 1 1 1;
0 0 0 1 0 0 0 0; 0 0 0 1 0 0 0 1; 0 0 0 1 0 0 1 0; 0 0 0 1 0 0 1 1;
0 0 0 1 0 1 0 0; 0 0 0 1 0 1 0 1; 0 0 0 1 0 1 1 0; 0 0 0 1 0 1 1 1;
0 0 0 1 1 0 0 0; 0 0 0 1 1 0 0 1; 0 0 0 1 1 0 1 0; 0 0 0 1 1 0 1 1;
0 0 0 1 1 1 0 0; 0 0 0 1 1 1 0 1; 0 0 0 1 1 1 1 0; 0 0 0 1 1 1 1 1;
0 0 1 0 0 0 0 0; 0 0 1 0 0 0 0 1; 0 0 1 0 0 0 1 0; 0 0 1 0 0 0 1 1;
0 0 1 0 0 1 0 0; 0 0 1 0 0 1 0 1; 0 0 1 0 0 1 1 0; 0 0 1 0 0 1 1 1;
0 0 1 0 1 0 0 0; 0 0 1 0 1 0 0 1; 0 0 1 0 1 0 1 0; 0 0 1 0 1 0 1 1;
0 0 1 0 1 1 0 0; 0 0 1 0 1 1 0 1; 0 0 1 0 1 1 1 0; 0 0 1 0 1 1 1 1;
0 0 1 1 0 0 0 0; 0 0 1 1 0 0 0 1; 0 0 1 1 0 0 1 0; 0 0 1 1 0 0 1 1;
0 0 1 1 0 1 0 0; 0 0 1 1 0 1 0 1; 0 0 1 1 0 1 1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1 0 1 1;
1 1 1 0 1 1 0 0; 1 1 1 0 1 1 0 1; 1 1 1 0 1 1 1 0; 1 1 1 0 1 1 1 1;
1 1 1 1 0 0 0 0; 1 1 1 1 0 0 0 1; 1 1 1 1 0 0 1 0; 1 1 1 1 0 0 1 1;
1 1 1 1 0 1 0 0; 1 1 1 1 0 1 0 1; 1 1 1 1 0 1 1 0; 1 1 1 1 0 1 1 1;
1 1 1 1 1 0 0 0; 1 1 1 1 1 0 0 1; 1 1 1 1 1 0 1 0; 1 1 1 1 1 0 1 1;
1 1 1 1 1 1 0 0; 1 1 1 1 1 1 0 1; 1 1 1 1 1 1 1 0; 1 1 1 1 1 1 1 1;
The XOR operation is using:
c = zeros(8)
for i in 1 : 2^8
for j in 1 : 8
c[j] = xor(a[j], z[i, j]
end
end
Using one of the solutions above, I will check the sum of array c
res = []
b = [1, 2, 3, 5]
sum_c = sum(Base.Fix1(getindex,a), b)
if sum_c == 0
res = c
end
And use the array that has sum = 0 as the result.
z = [1, 0, 0, 0, 0, 0, 0, 0]
c = [0, 0, 0, 1, 0, 1, 0, 1]
The operation is actually done in the while loop, and when sum_c = 0, the loop will stop and give the result.
(I hope you understand now because it is really hard to create array z)