import numpy as np
arr = np.array([
[1, 9, 2, 8, 6, 1],
[8, 1, 11, 7, 6, 4],
[10, 12, 1, 9, 12, 14],
[8, 10, 3, 5, 17, 8],
[6, 4, 10, 13, 16, 19],
])
max_val = (0, ((0, 0,), (0, 0)))
class GTFO(Exception):
pass
def check(arr):
for row in arr:
for val in row:
if val % 2 == 0:
return False
return True
for i in range(len(arr)):
for j in range(len(arr[0])):
try:
for k in range(i, len(arr)):
for l in range(j, len(arr[0])):
arr_slice = arr[i:k + 1, j:l + 1]
if check(arr_slice):
if len(arr_slice)*len(arr_slice[0]) > max_val[0]:
max_val = (len(arr_slice)*len(arr_slice[0]), ((i, j), (k, l)))
else:
if l == j:
raise GTFO
else:
break
except GTFO:
pass
print(max_val)
print(arr[max_val[1][0][0]:max_val[1][1][0]+1, max_val[1][0][1]:max_val[1][1][1]+1])
Однозначно стоит найти что написать и написать)