Guest User

Untitled

a guest
Jul 26th, 2022
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. m = [[0,1,1,1,1,1,0],
  2.      [0,1,0,0,1,0,0,0,1],
  3.      [1,1,1,1,1,1,1,1,1],
  4.      [0,1,0,0,0,1],
  5.      [1,1,1,1,1],
  6.      [1]
  7.      ]
  8. kk = 2
  9. def f(n):
  10.     global j, kk    
  11.     k = kk
  12.     res = 0    
  13.     for i in range(len(n) - k + 1):
  14.         if not sum(n[i:k]): res = j
  15.         k += 1
  16.     return res
  17.  
  18. cinema = []
  19. for j in m:
  20.     cinema += [f(j)]
  21. result = list(map(lambda x: len(x) if x != 0 else 0,cinema))
  22. if result.count(0) == len(result):
  23.     print('таких мест нет')
  24. else:
  25.     max_ = max(result)
  26.     for i in range(len(result)):
  27.         if result[i] < max_ and result[i]:
  28.             max_ = result[i]
  29.     print(kk,'находящихся рядом свободных места находятся в', result.index(max_) + 1, 'ряду. И у него наименьшая длина из всех вариантов')  
Advertisement
Add Comment
Please, Sign In to add comment