here2share

# constrained_binaries.py

Apr 11th, 2022 (edited)
1,292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. # constrained_binaries.py
  2.  
  3. aaa = 3
  4. bbb = ['0001111000' * aaa] #
  5.  
  6. ttt = {}
  7.  
  8. print ('...')
  9. while bbb:
  10.     b = bbb.pop()
  11.     ttt[b] = []
  12.     zzz = []
  13.     # print (b)
  14.     while 1:
  15.         step = 0
  16.         for s in ('10','01'):
  17.             iii = 0
  18.             while s in b[iii:]:
  19.                 if b.count('1') < aaa*6.3:
  20.                     i = b[iii:].index(s)+1
  21.                     t = b[:iii]+b[iii:].replace(s,'11',1)
  22.                     if t not in zzz:
  23.                         step = 1
  24.                         zzz += [t]
  25.                         # zzz += [t[::-1]] # to avoid mirrors
  26.                         bbb += [t]
  27.                         ttt[b] += [t]
  28.                     iii += i
  29.                 else:
  30.                     break
  31.         if not step:
  32.             break
  33. print (len(ttt))
Add Comment
Please, Sign In to add comment