views:

285

answers:

1

Hi,

I am searching for a function that get as an input a number x (assuming 15), number of bits d (4) and number of permutations m (2). The output of the function will be all the numbers that are m bit's permutations from the given number x at a d length bits.

For the given numbers, (x = 15, d = 4 and m = 2) we get 6=\binom{4}{2}different number's combination.

I would like to know if such kind of function already exist in C++ STD or boost or etc. that returns me those numbers...

P.S. if you know a function that returns all permutations' numbers till m.

regards

A: 

i looked again at the comment from @Gregory Pakosz and i found out it was not so bad direction to start with. I tried to implement the suggested code from Bit Twiddling Hacks in my program and after some bugs in my code it worked.

Thanks

Eagle