Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- size = 7
- player_1, player_2 = input().split(', ')
- total_points_player1, total_points_player2 = 501, 501
- total_count = 0
- winner = ''
- matrix = []
- for _ in range(size):
- matrix.append(input().split())
- while total_points_player1 > 0 and total_points_player2 > 0:
- total_count += 1
- current_points = 0
- if total_count % 2 == 0:
- current_player = player_2
- else:
- current_player = player_1
- coordinates = input().split(', ')
- current_row, current_col = int(coordinates[0][1]), int(coordinates[1][0])
- if current_row < 0 or current_col < 0 or current_row >= size or current_col >= size:
- continue
- if matrix[current_row][current_col] == 'B':
- winner = current_player
- if current_player == player_1:
- total_points_player1 = 0
- else:
- total_points_player2 = 0
- break
- elif matrix[current_row][current_col].isdigit():
- current_points = int(matrix[current_row][current_col])
- elif matrix[current_row][current_col] == 'D':
- current_points = (int(matrix[current_row][0]) + int(matrix[current_row][size - 1]) + int(matrix[0][current_col])
- + int(matrix[size - 1][current_col])) * 2
- elif matrix[current_row][current_col] == 'T':
- current_points = (int(matrix[current_row][0]) + int(matrix[current_row][size - 1]) + int(matrix[0][current_col])
- + int(matrix[size - 1][current_col])) * 3
- if current_player == player_1:
- total_points_player1 -= current_points
- else:
- total_points_player2 -= current_points
- if total_points_player1 > 0:
- winner = player_2
- total_count //= 2
- else:
- winner = player_1
- total_count = total_count % 2 + total_count // 2
- print(f"{winner} won the game with {total_count} throws!")
Advertisement
Add Comment
Please, Sign In to add comment