Advertisement
Korotkodul

Gazprom_N2_they_sol

Mar 21st, 2023 (edited)
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. cells = list(map(int, input().split(', ')))
  2.  
  3. print('По слоям')
  4. counters = [0] * (len(cells) + 1)
  5. i = 0
  6. while i < len(cells):
  7.     if cells[i] % 23 != 0:
  8.         i += 1
  9.         continue
  10.     j = i + 1
  11.     while j < len(cells) and cells[j] % 23 == 0:
  12.         j += 1
  13.     lenght = j - i
  14.     print(f'От {i + 1} до {j} содержится {lenght} ячеек')
  15.     counters[lenght] += 1
  16.     i = j
  17.  
  18. print('По количеству')
  19. for l, c in enumerate(counters):
  20.     if c == 0:
  21.         continue
  22.     print(f'Подпоследовательностей длиной {l}: {c}')
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement