Solution (source code)

= Solution

There are four one-bit <Boolean functions>, fully specified by the ordered pair $(f(0),f(1))$:

* $(0,0)$: $f(x)=0$, constant.
* $(1,1)$: $f(x)=1$, constant.
* $(0,1)$: $f(x)=x$, balanced.
* $(1,0)$: $f(x)=1\oplus x$, balanced.

Writing $a=f(0)$ and $b=f(0)\oplus f(1)$ gives $f(x)=a\oplus bx$. Constant functions have $b=0$ and balanced functions have $b=1$.