Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- m = [[0,1,1,1,1,1,0],
- [0,1,0,0,1,0,0,0,1],
- [1,1,1,1,1,1,1,1,1],
- [0,1,0,0,0,1],
- [1,1,1,1,1],
- [1]
- ]
- kk = 2
- def f(n):
- global j, kk
- k = kk
- res = 0
- for i in range(len(n) - k + 1):
- if not sum(n[i:k]): res = j
- k += 1
- return res
- cinema = []
- for j in m:
- cinema += [f(j)]
- result = list(map(lambda x: len(x) if x != 0 else 0,cinema))
- if result.count(0) == len(result):
- print('таких мест нет')
- else:
- max_ = max(result)
- for i in range(len(result)):
- if result[i] < max_ and result[i]:
- max_ = result[i]
- print(kk,'находящихся рядом свободных места находятся в', result.index(max_) + 1, 'ряду. И у него наименьшая длина из всех вариантов')
Advertisement
Add Comment
Please, Sign In to add comment