Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://judge.softuni.org/Contests/Practice/Index/4226#1
- def directions(position, direction, rows, matrix):
- row, col = position
- matrix[row][col] = "-"
- moves = {
- 'up': (-1, 0),
- 'down': (1, 0),
- 'left': (0, -1),
- 'right': (0, 1)
- }
- d_row, d_col = moves[direction]
- row += d_row
- col += d_col
- if 0 <= row < rows and 0 <= col < rows:
- return row, col, matrix
- return None
- def main():
- rows = int(input())
- game_board = []
- gambler = "G"
- amount = 0
- position = (-1, -1)
- neshto = {
- 'W': 100,
- 'P': -200,
- 'J': 100000
- }
- for row_ in range(rows):
- line = list(input())
- if gambler in line:
- amount += 100
- position = (row_, line.index(gambler))
- game_board.append(line)
- target = input()
- while target != "end":
- result = directions(position, target, rows, game_board)
- if result is None:
- print("Game over! You lost everything!")
- return
- else:
- new_row, new_col, game_board = result
- new_position = (new_row, new_col)
- step = game_board[new_row][new_col]
- if step in neshto:
- amount += neshto[step]
- if amount <= 0:
- print("Game over! You lost everything!")
- return
- if step == "J":
- game_board[new_row][new_col] = gambler
- print("You win the Jackpot!")
- break
- game_board[new_row][new_col] = gambler
- position = new_position
- target = input()
- print(f"End of the game. Total amount: {amount}$")
- for pr in game_board:
- print("".join(pr))
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement