# Classifying a problem involving matching bit arrays

First explaining the "reverse" use as a background:

1. There is an array A which contains N boolean values
2. There is an array B which contains N boolean values
3. I start iterating over array A and for every iteration I increment its current position by 1.
4. When corresponding bits at currentLocationA and currentLocationB in both arrays are true then the output become true.
5. Only when the current value in arrayA is true do I increment current position of arrayB.

The code for the "easy" direction is as following:

    var output = [];
var outputLength = 10;
var array1 = [false, false, true, true];
var array2 = [false, true, true];

var idx1 = -1,
idx2 = 0;

for (var i = 0; i < outputLength; i++) {
idx1 = (idx1 + 1) % array1.length;
output.push(array1[idx1] && array2[idx2]);
if (array1[idx1] == true) { idx2 = (idx2 + 1) % array2.length };
}

return output;


Will output:
Result: false, false, false, true, false, false, true, false, false, false

This is the simple direction.

The problem I am looking to classify (and resolve):

How do I classify the opposite use case: Given the output/result array - how can I get the input values required in array A and B? Input will be filled result array and a given size SizeA and SizeB for arrayA and arrayB.

Note: If the output array is longer than the input then the inputs wrap around

• Are you interested in deciding whether a solution exists, or in finding a solution under the promise that it exists? Sep 9 '18 at 6:41
• First objective is just to classify the problem domain. For implementation obviously whether a solution exists will be dependent on A and B being sufficiently big
– LK__
Sep 9 '18 at 6:46
• Did t answer you question... for implementation first step is to find whether a solution exists at all meaning whether given sizes of A and B are valid
– LK__
Sep 9 '18 at 6:53
• Perhaps you should clarify this in your question. You have to explain clearly what problem you’re interested in solving. We can’t second guess you. Sep 9 '18 at 7:00
• I thought title + “How do I classify the opposite use case” would emphasise that problem classification is the topic?
– LK__
Sep 9 '18 at 7:03