I have an integer n, and a 6-tuple: (a,b,c,d,e,f). Each element of the tuple has a range:
a : 0 to 4
b : 0 to 4
c : 0 to 3
d : 0 to 4
e : 0 to 2
f : 0 to 4
n can be computed as follows: n = 5a + 5b + 4c + 5d + 3e + 5f. The coefficients on the tuple elements are just the size their respective ranges.
We assign a mapping from \mathbb{Z} to \mathbb{Z}^6 as follows:
0 -> (0,0,0,0,0,0)
1 -> (0,0,0,0,0,1)
...
6 -> (0,0,0,0,1,0)
7 -> (0,0,0,0,1,1)
Is there a decently efficient way to take that integer n and find the corresponding tuple (a,b,c,d,e,f)?
In order to make the map $$f(x) = \sum_{i=1}^N a_i x_i$$ a bijection ($f(x)=n$ and $x = (a,b,c,d,e,f)$ in your OP) where $x_i$ can take the values $0$ to $M_i-1$ can be consructed by chosing $a_1 = 1$ and $$a_{i+1} = a_i M_i$$ Here you'd get $$f(a,b,c,d,e,f) = a + 5b + 25c + 100d + 400e + 1200f$$ The inverse is given by $$(f^{-1}(n))_i = (n \mathop{\rm div} a_i) \bmod M_i$$ Where $\mathop{\rm div}$ is integer division and $\bmod$ is remainder (i.e. $n = n \mathop{\rm div} N + n \bmod N$ for all $n,N$)