Advertisement
exDotaPro

?!

Jul 12th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.39 KB | None | 0 0
  1. def shift_step(my_list, shift=0):
  2.     length = len(my_list)
  3.     for idx, elem in enumerate(my_list[:]):
  4.         my_list[(idx + shift) % length] = elem
  5.     return my_list
  6.  
  7.  
  8. data = list(map(int, input().split()))
  9. rows, cols = data[0], data[1]
  10.  
  11. game = []
  12. for _ in range(rows):
  13.     current_row = input()
  14.     row = []
  15.     for char in current_row:
  16.         row.append(char)
  17.     game.append(row)
  18.  
  19. steps = int(input())
  20. for step in range(steps):
  21.     info = input().split()
  22.     arr, pos = int(info[0]), int(info[1])
  23.     game[arr] = shift_step(game[arr], pos)
  24.  
  25. jumps = 0
  26. player_idx = 0
  27.  
  28. for r in range(len(game), 0, -1):
  29.     player, step = 'S', '-'
  30.     for e in game[r - 1]:
  31.         if e == player:
  32.             player_idx = game[r - 1].index(player)
  33.         if e == step:
  34.             step_idx = game[r - 1].index(step)
  35.             if game[step_idx] == game[player_idx]:
  36.                 if game[r][player_idx] == player and game[r - 1][player_idx] == step:
  37.                     if r == rows - 1:
  38.                         game[r][step_idx] = '0'
  39.                     else:
  40.                         game[r][step_idx] = e
  41.                     game[r - 1].remove(e)
  42.                     game[r - 1].insert(step_idx, player)
  43.                     jumps += 1
  44.  
  45. if jumps == rows - 1:
  46.     print('Win')
  47. else:
  48.     print('Lose')
  49. print(f'Total Jumps: {jumps}')
  50. for games in game:
  51.     print(''.join(games))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement