Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def is_inside(r, c, size_):
- if 0 <= r < size_ and 0 <= c < size_:
- return True
- return False
- size = 7
- player_1, player_2 = input().split(', ')
- field = [input().split() for r in range(size)]
- player_1_points, player_2_points = 501, 501
- turn = 0
- current_player = ''
- while player_1_points > 0 and player_2_points > 0:
- turn += 1
- current_player = player_1 if turn % 2 != 0 else player_2
- hit_row, hit_col = eval(input())
- current_score = 0
- if not is_inside(hit_row, hit_col, size):
- continue
- elif field[hit_row][hit_col] == "B":
- break
- elif field[hit_row][hit_col] == "D":
- current_score = 2 * (int(field[hit_row][0]) + int(field[hit_row][size - 1]) +
- int(field[0][hit_col]) + int(field[size - 1][hit_col]))
- elif field[hit_row][hit_col] == "T":
- current_score = 3 * (int(field[hit_row][0]) + int(field[hit_row][size - 1]) +
- int(field[0][hit_col]) + int(field[size - 1][hit_col]))
- elif field[hit_row][hit_col].isdigit():
- current_score = int(field[hit_row][hit_col])
- player_1_points -= current_score if current_player == player_1 else 0
- player_2_points -= current_score if current_player == player_2 else 0
- print(f"{current_player} won the game with {turn//2 + turn % 2} throws!")
Advertisement
Add Comment
Please, Sign In to add comment