Note that there are some explanatory texts on larger screens.

plurals
  1. POGenerating all n-bit strings whose hamming distance is n/2
    primarykey
    data
    text
    <p>I'm playing with some variant of <a href="http://en.wikipedia.org/wiki/Hadamard_matrix" rel="nofollow">Hadamard matrices</a>. I want to generate <strong>all</strong> <i>n</i>-bit binary strings which satisfy these requirements:</p> <ol> <li>You can assume that <i>n</i> is a multiple of 4. </li> <li>The first string is 0<sup>n</sup>.<br />&rarr; a string of all 0s.</li> <li>The remaining strings are sorted in alphabetic order.<br />&rarr; 0 comes before 1.</li> <li>Every two distinct <i>n</i>-bit strings have <a href="http://en.wikipedia.org/wiki/Hamming_distance" rel="nofollow">Hamming distance</a> <i>n/2</i>.<br />&rarr; Two distinct <i>n</i>-bit strings agree in exactly <i>n/2</i> positions and disagree in exactly <i>n/2</i> positions.</li> <li>Due to the above condition, every string except for the first string must have the same number of 0s and 1s.<br/> &rarr; Every string other than the first string must have <i>n/2</i> ones and <i>n/2</i> zeros.</li> <li>(<em>Updated</em>) All the <i>n</i>-bit strings begin with <code>0</code>.</li> </ol> <p>For example, this is the list that I want for when <i>n=4</i>.</p> <blockquote> <p><code>0000</code><br /> <code>0011</code><br /> <code>0101</code><br /> <code>0110</code></p> </blockquote> <p>You can easily see that every two distinct rows have hamming distance <i>n/2 = 4/2 = 2</i> and the list satisfies all the other requirements as well.</p> <p>Note that I want to generate <strong>all</strong> such strings. My algorithm may just output three strings <code>0000</code>, <code>0011</code>, and <code>0101</code> before terminating. This list satisfies all the requirements above but it misses <code>0110</code>.</p> <ol> <li>What would be a good way to generate such sets? <br />A python pseudo-code is preferred but any high-level description will do.</li> <li>What is the <strong>maximum</strong> number of such strings for a given <i>n</i>?<br />For example, when <i>n=4</i>, the max number of such strings happen to be 4. I'm wondering whether there can be any closed form solution for this upper bound.</li> </ol> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload