Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from itertools import permutations
- def f(s):
- while '00' not in s:
- s = s.replace('012', '30', 1)
- if '011' in s:
- s = s.replace('011', '20', 1).replace('022', '40', 1)
- else:
- s = s.replace('01', '10', 1).replace('02', '101', 1)
- return s
- s = '0{}0'
- min_k = 10000
- for i in permutations('1' * 10 + '2' * 10, r=20):
- out = f(s.format(''.join(i)))
- if out.count('1') == 7 and out.count('2') == 5:
- if out.count('3') < min_k:
- min_k = out.count('3')
- print(min_k)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement