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
$\begingroup$
$\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$– PSKSep 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$– PSKSep 4, 2015 at 17:35
-
$\begingroup$ Ah, OK. My bad. $\endgroup$– Peter K. ♦Sep 4, 2015 at 18:33
|
Show 2 more comments