# easter_bunny

Jan 25th, 2022
762
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. directions_moves = {'right': [], 'left': [], 'up': [], 'down': []}
2.
3. max_eggs = float('-inf')
4. max_direction = ''
5.
6. rows = int(input())
7. matrix = []
8. bunny_row, bunny_col = None, None
9.
10. for row in range(rows):
11.     current_line = input().split()
12.     matrix.append(current_line)
13.     for col in range(rows):
14.         if matrix[row][col] == "B":
15.             bunny_row, bunny_col = row, col
16.
17. for direction in ["right", "left", "up", "down"]:
18.     current_direction = direction
19.     current_eggs = 0
20.     if direction == 'up':
21.         for r in range(bunny_row - 1, -1, -1):
22.             if matrix[r][bunny_col] != 'X':
23.                 current_eggs += int(matrix[r][bunny_col])
24.                 directions_moves[current_direction].append((r, bunny_col))
25.             else:
26.                 break
27.     elif direction == "right":
28.         for c in range(bunny_col + 1, rows):
29.             if matrix[bunny_row][c] != 'X':
30.                 current_eggs += int(matrix[bunny_row][c])
31.                 directions_moves[current_direction].append((bunny_row, c))
32.             else:
33.                 break
34.     elif direction == "left":
35.         for c in range(bunny_col - 1, -1, -1):
36.             if matrix[bunny_row][c] != 'X':
37.                 current_eggs += int(matrix[bunny_row][c])
38.                 directions_moves[current_direction].append((bunny_row, c))
39.             else:
40.                 break
41.     elif direction == "down":
42.         for r in range(bunny_row + 1, rows):
43.             if matrix[r][bunny_col] != 'X':
44.                 current_eggs += int(matrix[r][bunny_col])
45.                 directions_moves[current_direction].append((r, bunny_col))
46.             else:
47.                 break
48.     if current_eggs > max_eggs and directions_moves[current_direction]:
49.         max_eggs = current_eggs
50.         max_direction = current_direction
51.
52. if max_direction:
53.     print(max_direction)
54.     for idx_r, idx_c in directions_moves[max_direction]:
55.         print(f"[{idx_r}, {idx_c}]")
56.
57. print(max_eggs)
58.
59.