I would like to serialize parallel information like 1,23,5,32,6,1,0,5,1,6 into one single integer ("index" from now on).
The array has always exactly ten evalues and the order of the values matters. The values of the array are integers that can reach from 0 to +inf and are completely independent from each other.
I thought through a few possible solutions, but I can’t come up with a solution where every possible array has exactly one possible index and where every possible index has exactly one possible array.
You can imagine the situation like ten ordered boxes in a row in which specific numbers of balls were put. Now there is an infinite number of these rows and each of the row has a different number of balls in the boxes. How can you give each of the rows one number (like a catalogue) and you exactly know how many balls are in which box?
I know that the index number is going to be ridiculously big with big array values, but I won’t use big array values anyway.
examples:
Index: array
0: (0,0,0,0...,0,0)
1: (0,0,0,0...,0,1)
There should be a simple mathematical solution to this, but I don’t see it.
You could just interleave the digits. Example with arrays of size 3 instead of 10:
insert leading zeros if necessary: