whitespace cleanup
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 10 Sep 2022 14:07:37 +0000 (15:07 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 10 Sep 2022 14:07:37 +0000 (15:07 +0100)
src/openpower/decoder/quine.py

index 72c308b211eda4565f845e982e731427fadbf408..4c9c209e87430d97f488ac86f38a5f3e24a8f0b5 100644 (file)
@@ -3,28 +3,28 @@
 
 def collapse(patterns):
     """Reduce patterns into compact dash notation"""
-    newPatterns = []  #reduced patterns
-    matched = []      #indexes with a string that was already matched
-    for x,p1 in enumerate(patterns):    #pattern1
-        if x in matched: continue       #skip if this pattern already matched
-        for y,p2 in enumerate(patterns[x+1:],1):
-            if x+y in matched: continue #skip if this pattern already matched
-            diffs=0     # number of differences found
-            for idx,bit in enumerate(zip(p1,p2)):
-                if bit[0] != bit [1]:     # count of bits that are different
+    newPatterns = []  # reduced patterns
+    matched = []      # indexes with a string that was already matched
+    for x, p1 in enumerate(patterns):    # pattern1
+        if x in matched: continue        # skip if this pattern already matched
+        for y, p2 in enumerate(patterns[x+1:], 1):
+            if x+y in matched: continue  # skip if this pattern already matched
+            diffs = 0                    # number of differences found
+            for idx, bit in enumerate(zip(p1, p2)):
+                if bit[0] != bit[1]:     # count of bits that are different
                     diffs += 1
-                    dbit  = idx
-                if diffs >1:break
+                    dbit = idx
+                if diffs > 1: break
             # if exactly 1 bit different between the two,
             # they can be compressed together
             if diffs == 1:
-                newPatterns.append(p1[:dbit]+'-'+p1[dbit+1:])
+                newPatterns.append('-'.join([p1[:dbit], p1[dbit+1:]]))
                 matched+=[x,x+y]
                 break
         # if the pattern wasn't matched, just append it as is.
         if x not in matched: newPatterns.append(p1)
 
-    # if reductions occured on this run, then call again
+    # if reductions occurred on this run, then call again
     # to check if more are possible.
     if matched:
         newPatterns = collapse(newPatterns)