F
filia&sofia
Let's take a 32-bit "unsigned int" integer i, i: [0, 2^32).
Let's order a sequence of integers 0,1,2,...,2^32-1 as follows:
1) first into groups of k-bits, k: [0,32]
2) elements in each group into increasing order
3) putting all 2^32 integers to a single sequence starting from group
where k=0 and then k=1,2,3,...,32
For example: 2-bit integers. i: [0,3]
1) groups
- k=2. 1 ints. 11
- k=1. 2 ints. 10 and 01
- k=0. 1 ints. 00
2) {00}, {01, 10}, {11}
3) 00,01,10,11
It's easy to see that, for example, i=0b10 is the 3rd integer in this
case. But what if we have 32-bit integer. What is the "position" of it
when we have a integer sequence that follows the description? So, in a
way, this problem is about finding the "position" of a combination.
Any ideas, links, etc? Thanks.
Let's order a sequence of integers 0,1,2,...,2^32-1 as follows:
1) first into groups of k-bits, k: [0,32]
2) elements in each group into increasing order
3) putting all 2^32 integers to a single sequence starting from group
where k=0 and then k=1,2,3,...,32
For example: 2-bit integers. i: [0,3]
1) groups
- k=2. 1 ints. 11
- k=1. 2 ints. 10 and 01
- k=0. 1 ints. 00
2) {00}, {01, 10}, {11}
3) 00,01,10,11
It's easy to see that, for example, i=0b10 is the 3rd integer in this
case. But what if we have 32-bit integer. What is the "position" of it
when we have a integer sequence that follows the description? So, in a
way, this problem is about finding the "position" of a combination.
Any ideas, links, etc? Thanks.