1
$\begingroup$

I have three positive integers, a, b, and c. I know that $a\oplus b\oplus c=0$, so I got that each pairwise xor has to be the other positive integer. $a\oplus b=c$, $b\oplus c=a$, and so on, but I can't find a, b, and c.

There are lots of solutions, (I'm pretty sure), I'm just trying to code a quick way to find all of the solutions

$\endgroup$

1 Answer 1

1
$\begingroup$

There are infinitely many solutions: choose $a=b\in\mathbb N, c=0$ and then $a\oplus b\oplus c=0$.

To find all solutions, choose an arbitrary $c\in\mathbb N$. We want to find all $a,b$ with $a\oplus b=c$. Its equivalent to $a=b\oplus c$, so for every $b\in\mathbb N$ we would choose $a=b\oplus c$ and $a,b,c$ would be a valid solution.

All of the solutions are of this form - and therefore thats how you can iterate through every possible solution to the question

$\endgroup$
1
  • 1
    $\begingroup$ As explained, the set of solutions is 2-dimensional in that 3-dimensional space--it's a big "infinitely many". $\endgroup$ Commented Nov 7, 2020 at 7:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.