Computing the index in a structured way

I want to map the various combinations to an unique index: For a given $n$ and $r$, we would have $\binom{n}{r}$ arrangement for values:$[0,\dots,n)$:

Ex: For n = 6, r = 3
[012,
013,
014,
015,
...,
345]
So, for any given arrangement [012] the index would 0 as its the very first element.
Similarly, the index for arrangement for [015] should be 3. Trying to come up a formula to determine the correct index for a given arrangement.

• – D.W. Feb 12 '16 at 18:22
• @D.W. Now the question has become unanswerable. Why not convert your comment to an answer? – Yuval Filmus Feb 12 '16 at 18:49
• @YuvalFilmus, I don't understand why the question has become unanswerable. I don't have time right now to write up a full answer, but anyone else who would like to is welcome to do so. – D.W. Feb 12 '16 at 23:41