I can't understand the problem in my solution described below
We can create a tree and then find the pattern as follows:
As can be seen above, there are only 8 possible numbers (not necessarily distinct) shown below: {0, x, x&k, x|k, (∼x)&k, x&(∼k), x^k, k} (where ∼n represents bitwise negation of n; and all operators have their usual meanings)
So we can create a transition table for each of these numbers for each of the possiblities of AND, OR, XOR. Using this logic I arrived at this solution
But the program is giving incorrect answer. Can someone point out the flaw in logic and/or implementation, please.