What is a possible mapping for two given sets? Suppose I a set of integers $n=\{0,1,2,...,80\}$ and $m=\{0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,2,2,2,2,2,2,2,2,2,...\text{repeats from start}...\}$
where $|n|=|m|=81.$ What is a function that describes the mapping $n$ to $m$? I was able to get one if $m$ were to be $\{0,1,2,3,4,5,0,1,2,....,7,8,9,10,11,12,13,14,15,...\text{repeats from start}...\}$ using a couple of floor functions and mods but that is not what I am looking for.
 A: This is what you are looking for
$$f(k)=\begin{cases}
 2, & \left(\left\lfloor \frac{\left\lfloor \frac{k}{3}\right\rfloor }{3}\right\rfloor
   -2\right) \bmod 3=0 \\
 1, & \left(\left\lfloor \frac{k}{3}\right\rfloor -\left\lfloor \frac{\left\lfloor
   \frac{k}{3}\right\rfloor }{9}\right\rfloor \right) \bmod 2 \neq 0\\
 0, & \text{otherwise.}
\end{cases}$$
A: "What is a function that maps n to m?"  Um,.... what you just said was a  function that maps $n$ to $m$.  Functions don't need algebraic formulas or rules.  Any mapping IS a function. 
But if you want description:
Let $k  = 27a + 9b + 3c +d$ be the unique expression of $k$ as base three numbers.  That is $a,b,c,d \in \{0,1,2\}$.
$f(k) =\begin{cases}2&\text{if }b = 2\\1&\text{if }b\ne 2\text{ and }b+c\text{ is odd}\\0&b\ne 2\text{ and }b+c\text{ is even}\end{cases}$.
.....
I guess another way putting it is
$f(x) = 2$ if $[\frac{[\frac{[\frac x3]}3]}3]\equiv 2\pmod 3$
Otherwise $f(x) =1$ if $ [\frac x3]$ is odd.
Otherwise $f(x) = 0$.
where $[]$ is the greatest integer function.
