On 17 November 2010 10:42, Dave <dave_and_da...@juno.com> wrote:
> @Siddharth: Try this ("nnwtsnoob" = "next number with the same number
> of one bits"):
>
> unsigned nnwtsnoob(unsigned x)
> {
>    return (x+(x&(-x)))|(((x^(x+(x&(-x))))>>2)/(x&(-x)));
> }
>
> For the explanation/justification, see
> http://groups.google.com/group/programming-puzzles/msg/3a05b3c8b4042d5b.
>

Thanks a lot Dave

> Dave
>
> On Nov 16, 12:18 pm, siddharth srivastava <akssps...@gmail.com> wrote:
>> Input a number and then find the next higher number
>> such that for both the number (inputted and the next higher
>> number)
>> in binary representation contains equal number os ones.
>> Example:
>> Input:3(0000000000000011)
>> Ouput:5(0000000000000101)
>>
>> --
>> Siddharth Srivastava
>>
>> When you have learned to snatch the error code from the trap frame, it
>> will be time for you to leave.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to 
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/algogeeks?hl=en.
>
>



-- 
Siddharth Srivastava

When you have learned to snatch the error code from the trap frame, it
will be time for you to leave.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to