So for example, I have an array containing 52 shuffled integers between 0 and 52 – no repeated values.
How can I encode this array according to an algorithm such that it can be represented as less numbers, and then decode and again to reproduce the original values?
I was thinking I could create a big binary String and group grouping of 0’s or 1’s together as characters, and expand on that. Would that be the way to go? Thanks
There are 52! (that’s fifty two factorial) different arrays like you describe. By the way they are called permutations. A single number between 0 and 52! uniquely represents such a permutation. You need 226 bits to store such a number. Eight 32-bit integers would do just as well.
You can read about mapping numbers to permutations and back here.