Suppose I have N
items and a binary number that represents inclusion of these items in a result:
N = 4
# items 1 and 3 will be included in the result
vector = 0b0101
# item 2 will be included in the result
vector = 0b0010
I'm also provided a list conflicts which indicates which items cannot be included in the result at the same time:
conflicts = [
0b0110, # any result that contains items 1 AND 2 is invalid
0b0111, # any result that contains AT LEAST 2 items from {1, 2, 3} is invalid
]
Given this list of conflicts, we can determine the validity of the earlier vector
s:
# invalid as it triggers conflict 1: [0, 1, 1, 1]
vector = 0b0101
# valid as it triggers no conflicts
vector = 0b0010
How can bit manipulation be used to determine validity of a vector or large list of vectors against a list of conflicts in this context?
The solution provided here already gets us most of the way there but I'm unsure how to adapt it to the integer use case (to avoid numpy arrays and numba entirely).