TITLE: Function that sends $1,2,3,4$ to $0,1,1,0$ respectively
QUESTION [5 upvotes]: I already got tired trying to think of a function $f:\{1,2,3,4\}\rightarrow \{0,1,1,0\}$ in other words:
$$f(1)=0\\f(2)=1\\f(3)=1\\f(4)=0$$
Don't suggest division in integers; it will not pass for me. Are there ways to implement it with modulo, absolute value, and so on, without conditions?

REPLY [5 votes]: Since you tagged "binary" in your question, you might also want to recall that Karnaugh map is a standard way to map inputs to outputs with just complement, AND and OR gates. (Or "~", "$\&$" and "|" bit-wise operators in C)
For example, you can define $a,b,c$ to be bits at position 2,1,0 here to use the map.
If you draw out the map, this is what it looks like: 
$$\begin{array}{c|c|c|c|c|c|}
& &bc &bc &bc &bc\\ \hline 
& & 00 & 01 & 11 & 10\\ \hline
a& 0 & \text{X} & 0 & 1 & 1 \\ \hline
a& 1 & 0 & \text{X} & \text{X} & \text{X} \\ \hline
\end{array}$$
Explanation: X denotes values that cannot occur (normally called "Don't care" I think). We want to focus on representing the "1"s, which is represented by the entries $\bar abc$ and $\bar a b\bar c$. (Notice that you only get "1" for one of the variables, they cannot occur together.)
They can be combined: $\bar a bc + \bar a b \bar c=\bar a b (c+\bar c)=\bar a b$.
Getting rid of the $\bar a$ is possible when you noticed that its alternative row has no entries. (i.e. the 2 entries below are "X"s)  
Using this idea you can construct any function for any bigger variable.
It is probably not going to be the most efficient implementation, but you can get the solution fast. From there, you may do some reduction using logical operations and the final result should be decent.