Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = int(input())
- is_restored = False
- MINIMUM_REQUIRED_NECTAR = 30
- mat = []
- bee = []
- energy = 15
- nectar = 0
- for row in range(n):
- mat.append(list(input()))
- for col in range(n):
- if mat[row][col] == "B":
- mat[row][col] = "-"
- bee = [row, col]
- directions = {
- "up": (-1, 0),
- "down": (1, 0),
- "right": (0, 1),
- "left": (0, -1)
- }
- while True:
- command = input()
- row_move = (bee[0] + directions[command][0]) % n
- col_move = (bee[1] + directions[command][1]) % n
- bee = [row_move, col_move]
- energy -= 1
- if mat[row_move][col_move].isdigit():
- nectar += int(mat[row_move][col_move])
- mat[row_move][col_move] = "-"
- elif mat[row_move][col_move] == "H":
- if nectar >= MINIMUM_REQUIRED_NECTAR:
- print(f"Great job, Beesy! The hive is full. Energy left: {energy}")
- else:
- print("Beesy did not manage to collect enough nectar.")
- break
- if energy <= 0 and nectar < MINIMUM_REQUIRED_NECTAR:
- print("This is the end! Beesy ran out of energy.")
- break
- if energy <= 0 and nectar >= MINIMUM_REQUIRED_NECTAR:
- if not is_restored:
- diff = nectar - MINIMUM_REQUIRED_NECTAR
- energy = diff
- nectar = MINIMUM_REQUIRED_NECTAR
- is_restored = True
- if energy <= 0:
- print("This is the end! Beesy ran out of energy.")
- break
- mat[bee[0]][bee[1]] = "B"
- [print(''.join(row)) for row in mat]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement