*Question 1 / 1*
Given an integer *N*, there are *2^N* binary codewords of length N. All of
them are taken and sorted to create a sequence: Sort by the number of 1-bits
in the codeword bit-string. If there is a tie, break tie so that the smaller
number comes first in the output sequence

*Testcases format:*
You would be given 2 integers *N* (<=10) and *K* (1 <= K <= 2^N)
Output the codeword with index K into this sequence
The input is from stdin and output to stdout

*Sample Testcases:*
*Input #00:*
3 5
*Output #00:*
011
*Explanation:*
For N = 3, the sequence consists of {000,001,010,100,011,101,110,
111}. The 5th indexed number would be 011

*Input #01:*
7 127
*Output #01:*
1111110

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@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