Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Suppose I have a family of vectors of the form x=(x0,x1,x2,x3,x4,x5) where x0,x3 can taker either 0 or 1 value and all the other variables can take values 0,1,2,3,4,5,6,7. Then I m ordering them in lexigraphic order say like 000000<000001<000002<...<000010<000020<....

We have in total 16384= elements. I want to list thme in a list in this order so that when given say the number m I can recover the entries x0,..,x5 of the mth element in my list. So I need like function from these vectors to {0,1,...,16383}. I want this for a programming task actually.

share|improve this question

1 Answer 1

Just do it, write that program!

Anyway, it is the same as writing the given natural number $<16384$ into (max 14 digits) binary form, then rearraging its digits as $$\overbrace{d_1}\underbrace{d_2d_3d_4}\overbrace{d_5d_6d_7}\underbrace{d_8}\overbrace{d_9d_{10}d_{11}}\underbrace{d_{12}d_{13}d_{14}},$$ and the lexicographical order coincides with the traditional order of numbers.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.