The Lehmer code can be used for this. This looks like a pretty decent guide on how to do that: http://www.2ality.com/2013/03/permutations.html
Printing a unique order of 4 items from a unique input between 0-23 [duplicate]
Frage
There are 4 items
-I1
-I2
-I3
-I4
The possible order of these items is 4! = 24. In order to save space, I need to use only 5 bits to represent each of the unique 24 permutations.
What is the most efficient way to reverse engineer a specific priority order in the list if we just have a number as input ? In general, how do we do this for n items ? Is there any algorithm in place ?
Lösung
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow