Advertisement
Pastehsjsjs

Untitled

Jan 15th, 2023 (edited)
842
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. from itertools import permutations
  2.  
  3.  
  4. def f(s):
  5.     while '00' not in s:
  6.         s = s.replace('012', '30', 1)
  7.         if '011' in s:
  8.             s = s.replace('011', '20', 1).replace('022', '40', 1)
  9.         else:
  10.             s = s.replace('01', '10', 1).replace('02', '101', 1)
  11.     return s
  12.  
  13.  
  14. s = '0{}0'
  15. min_k = 10000
  16. for i in permutations('1' * 10 + '2' * 10, r=20):
  17.     out = f(s.format(''.join(i)))
  18.     if out.count('1') == 7 and out.count('2') == 5:
  19.         if out.count('3') < min_k:
  20.             min_k = out.count('3')
  21.             print(min_k)
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement