(a || b) && (!a || !b)
The left side is true when at least 1 of a and b is true. The right side is true when at least 1 of a and b is false. The expression is true when either a or b is true but not both.
This is known as exclusive or (xor). With 2 boolean values, the operation is equivalent to:
a != b