1
$\begingroup$

I understand Gray codes have one bit change between them and how to convert between binary and gray. But given a bit length of n, I want to generate a series of Gray codes (all possible) that have one bit change and have maximum k ones.
Example: Given n = 3 and k = 2
000 001 011 010 110 100 101

$\endgroup$
7
  • $\begingroup$ Interesting problem! This algorithm doesn't do what you need, but might be a pointer to something: it will generate all sequences with $k$ bits equal to 1. $\endgroup$
    – Peter K.
    Sep 4, 2015 at 16:34
  • 1
    $\begingroup$ I actually found a number of ways to do that here $\endgroup$
    – PSK
    Sep 4, 2015 at 17:20
  • $\begingroup$ Nice! If you find a nice technique, you might want to put it in an answer here. Or we can delete this question if you're happy otherwise. Your call. $\endgroup$
    – Peter K.
    Sep 4, 2015 at 17:27
  • $\begingroup$ No I mean I found a number ways to do what you suggested in your link but not much on the problem asked. $\endgroup$
    – PSK
    Sep 4, 2015 at 17:35
  • $\begingroup$ Ah, OK. My bad. $\endgroup$
    – Peter K.
    Sep 4, 2015 at 18:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.