Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rows, colons = list(map(int, input().split(", ")))
- matrix_list = [list(map(int, input().split(", "))) for _ in range(rows)]
- max_sum = {"max number": float('-inf'), "row": 0, "col": 0}
- def check_valid_index(row, col):
- return row + 1 < rows and col + 1 < colons
- def sum_square(row, col):
- if check_valid_index(row, col):
- sum_total = matrix_list[row][col] + matrix_list[row][col + 1] + matrix_list[row + 1][col] + matrix_list[row + 1][col + 1]
- if max_sum["max number"] < sum_total:
- max_sum["max number"] = sum_total
- max_sum["row"] = row
- max_sum["col"] = col
- for row in range(rows - 1):
- for col in range(colons - 1):
- sum_square(row, col)
- for row in range(max_sum["row"], max_sum["row"] + 2):
- print(" ".join(map(str, matrix_list[row][max_sum["col"]: max_sum["col"] + 2])))
- print(max_sum['max number'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement