I stumbled upon a problem that I’m looking for an smart solution to. It’s basically a combinatorics question.
I have five objects of which I need to select two, I can select the same one twice and it does not matter in which order I select them. This gives me ( 5 + 2 – 1 choose 2) = 15 possible combinations. I now want to reduce each combination (ie (1,1) or (2, 5)) to a number between 1 and 15. Any suggestions?
Quasi lexicographic ordering. Assign each selection its position in the lexicographic ordering, with the second component not smaller than the first.