Boolean system (for C ++ / C # / java)

How can I programmatically enable this type of system:

A = !B B = !C D = !B E = !A E = !B 

so I can get by replacing A = C = D (3) and E = B (2) . I need only the number of two groups. If it is not possible to get 2 groups, an error message will be displayed.

+2
source share
2 answers

In case this is not closed as a hoax, from my answer in the previous question:

To solve equations of the form

X 1 = NOT X 3

X 5 = NOT X 2

etc.

Create a graph with nodes like X i and connect X i and X j if the equation is X i = NOT X j .

Now try a 2-color plot using the first width search.

+3
source

Consider a string of bits ABCDE . For each subset of this row, set all the variables in this subset to true and all variables that are not included in the subset to false . See which subset suits your conditions.

You can implement this by counting in binary format from 0 to 2^(num variables) - 1 . For each number, its binary representation gives you which variables are true and which are false . So you just need to get all the bits of the number and complete your checks.

-1
source

All Articles