Advertisement
Nenogzar

02. Pawn Wars CEO

Jun 19th, 2024
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. matrix = []
  2. b_row, b_col, w_col, w_row = 0, 0, 0, 0
  3.  
  4. for row in range(8):
  5.     matrix.append(input().split())
  6.     if "w" in matrix[row]:
  7.         w_row, w_col = row, matrix[row].index("w")
  8.     elif "b" in matrix[row]:
  9.         b_row, b_col = row, matrix[row].index("b")
  10.  
  11. while True:
  12.  
  13.     if (w_row - 1, w_col - 1) == (b_row, b_col) or (w_row - 1, w_col + 1) == (b_row, b_col):
  14.         print(f"Game over! White win, capture on {chr(97 + b_col)}{abs(b_row - 8)}.")
  15.         break
  16.     w_row -= 1
  17.     if w_row == -1:
  18.         print(f"Game over! White pawn is promoted to a queen at {chr(97 + w_col)}8.")
  19.         break
  20.  
  21.     if (b_row + 1, b_col - 1) == (w_row, w_col) or (b_row + 1, b_col + 1) == (w_row, w_col):
  22.         print(f"Game over! Black win, capture on {chr(97 + w_col)}{abs(w_row - 8)}.")
  23.         break
  24.     b_row += 1
  25.     if b_row == 8:
  26.         print(f"Game over! Black pawn is promoted to a queen at {chr(97 + b_col)}1.")
  27.         break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement