I'm working on a data warehousing project and need to assign a unique value to a permutation and store that value as dimension in the data warehouse. Currently, I'm relying upon a rather large lookup table to determine the unique value and I'm curious if it would be possible to achieve the same result via a function or algorithm.
Here is a small scale example of what I'm trying to accomplish.
Assume you have three values: 1, 2 and 3. Assuming order does not matter there are $3 \times 3 \times 3$ possible permutation. If you were develop a lookup table with all the possibilities it might look something like the following:
- 111
- 112
- 113
- ... ...
- 333
Now if I code the sequences 112 and 333 I would assign the values of 2 and 27, respectively. The look-up table approach works fine when you have three possible values in three possible position, but as the values and positions increase the look-up approach quickly loses its appeal.
My question is it possible to right a function (psuedo code or otherwise) that given a combination it yields the permutation's or unique value). Alternatively, is there a hash function that would have desirable properties.