mralex18

kploykov1697

Jun 22nd, 2021
728
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def fano(a, b):
  2.     if len(a) > len(b):
  3.         return a[:len(b)] == b
  4.     return b[:len(a)] == a
  5.  
  6. def fano_list(a):
  7.     for i in range(len(a) - 1):
  8.         for j in range(i + 1, len(a)):
  9.             if fano(a[i], a[j]):
  10.                 #print(a[i], a[j])
  11.                 return False
  12.     return True
  13.  
  14. s = ['111', '0100', '1100', '0010', '0001', '0011', '0110', '1001', '1010']
  15. minn = ''
  16. for i in range(0, 2 ** 5):
  17.     for zeros in range(10):
  18.         n = bin(i)[2:] + '0' * zeros
  19.         s.append(n)
  20.         #print(n, s)
  21.         if fano_list(s):
  22.             if len(n) < len(minn) or minn == '':
  23.                 minn = n
  24.             elif len(n) == len(minn) and int(minn, 2) > int(n, 2):
  25.                 minn = n
  26.         s.pop(-1)
  27. print(minn)          
RAW Paste Data