Advertisement
nq1s788

12 найти исходную

Jan 20th, 2024
683
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. for x in range(50): #кол-во единиц в исходной
  2.     for y in range(50): #кол-во двоек в исх
  3.         for z in range(50): #кол-во троек
  4.             s = '0' + '1' * x + '2' * y + '3' * z
  5.             while ('01' in s) or ('02' in s) or ('03' in s):
  6.                 s = s.replace('01', '2302', 1)
  7.                 s = s.replace('02', '10', 1)
  8.                 s = s.replace('03', '201', 1)
  9.             if s.count('1') == 50 and s.count('2') == 12 and s.count('3') == 7:
  10.                 print('0' + '1' * x + '2' * y + '3' * z, x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement