Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I wanted to post my initial attempt as the first answer but the website blocked me for around 8 hrs, and I've only been able to reply now. I've split the code into the more important snippets. </p> <p>This is my attempt so far :</p> <p>I think I should perform the following mods to the code below : </p> <pre><code> 1) Use dicts so that I have 0:000,1:001,... to improve the indexing. 2) Take the comparison string, adapt it to a list of all possible options then compare this to the full binary list e.g. 010 becomes 110,000,011 and this is then is compared to the full binary list. </code></pre> <p>My attempt to create a list of binary numbers is as follows (not using dicts yet)</p> <pre><code>def BinaryNumberList(N=4): Bins=[] for Num in range(2**N): Bin='' for Pow in sorted(range(N),reverse=True): Bin=Bin+str(Num/(2**Pow)) Num=Num-Num/(2**Pow)*2**Pow Bins.append(Bin) return Bins </code></pre> <p>Then run a for loop for comparing each string to the rest (currently not the best one)</p> <pre><code>def GreySets(Bins): for Bin1 in Bins : for Bin2 in Bins : stringXOR(Bin1,Bin2) </code></pre> <p>The string XOR I got from some one elses code on the interwebs and it returns a TrueFalseTrue (I need it to retrun the number of bits that don't match)</p> <pre><code>def stringXOR(a, b): # Error Checking msg = "Strings do not have same length: %d, %d!" assert len(a) == len(b), msg % (len(a), len(b)) cnt = len(a) - 1 # Code result = '' while cnt + 1: result = `(a[cnt] != b[cnt])` + result cnt = cnt - 1 return result </code></pre>
 

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