Advertisement
Nenogzar

Untitled

Nov 15th, 2023
704
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.06 KB | None | 0 0
  1. matrix = []
  2.  
  3. for run in range(3):
  4.     list_app = list(map(int, input().split()))
  5.     matrix.append(list_app)
  6.  
  7. first_player = False
  8. second_player = False
  9.  
  10. # Check for rows and columns
  11. for i in range(3):
  12.     # Rows
  13.     if matrix[i][0] == matrix[i][1] == matrix[i][2] != 0:
  14.         if matrix[i][0] == 1:
  15.             first_player = True
  16.         elif matrix[i][0] == 2:
  17.             second_player = True
  18.  
  19.     # Columns
  20.     if matrix[0][i] == matrix[1][i] == matrix[2][i] != 0:
  21.         if matrix[0][i] == 1:
  22.             first_player = True
  23.         elif matrix[0][i] == 2:
  24.             second_player = True
  25.  
  26. # Check diagonals
  27. if matrix[0][0] == matrix[1][1] == matrix[2][2] != 0:
  28.     if matrix[0][0] == 1:
  29.         first_player = True
  30.     elif matrix[0][0] == 2:
  31.         second_player = True
  32.  
  33. if matrix[0][2] == matrix[1][1] == matrix[2][0] != 0:
  34.     if matrix[0][2] == 1:
  35.         first_player = True
  36.     elif matrix[0][2] == 2:
  37.         second_player = True
  38.  
  39. # Determine the winner or draw
  40. if first_player:
  41.     print("First player won")
  42. elif second_player:
  43.     print("Second player won")
  44. else:
  45.     print("Draw!")
  46.    
  47. ###########################################*-*FROM*CEO*-*###########################################
  48.  
  49. # field = []
  50. #
  51. # first_player_win = False
  52. # second_player_win = False
  53. # draw = False
  54. # #  drawing the game field in separate lists
  55. # for field_row in range(3):
  56. #     current_row = input().split()
  57. #     field.append(current_row)
  58. # #  checking each row to see if there is a winner in the row
  59. # for row in range(3):
  60. #     if field[row][0] == field[row][1] == field[row][2] != "0":
  61. #         if field[row][0] == field[row][1] == field[row][2] == "1":
  62. #             first_player_win = True
  63. #         elif field[row][0] == field[row][1] == field[row][2] == "2":
  64. #             second_player_win = True
  65. # #  checking each column to see if there is a winner in the column
  66. # for col in range(3):
  67. #     if field[0][col] == field[1][col] == field[2][col] != "0":
  68. #         if field[0][col] == field[1][col] == field[2][col] == "1":
  69. #             first_player_win = True
  70. #         elif field[0][col] == field[1][col] == field[2][col] == "2":
  71. #             second_player_win = True
  72. # #  checking left diagonal if there is a winner
  73. # if field[0][0] == field[1][1] == field[2][2] != "0":
  74. #     if field[0][0] == field[1][1] == field[2][2] == "1":
  75. #         first_player_win = True
  76. #     elif field[0][0] == field[0][1] == field[2][2] == "2":
  77. #         second_player_win = True
  78. # #  checking right diagonal if there is a winner
  79. # elif field[0][2] == field[1][1] == field[2][0] != "0":
  80. #     if field[0][2] == field[1][1] == field[2][0] == "1":
  81. #         first_player_win = True
  82. #     elif field[0][2] == field[1][1] == field[2][0] == "2":
  83. #         second_player_win = True
  84. # # if there is no winner found the game is a draw
  85. # if not first_player_win and not second_player_win:
  86. #     draw = True
  87. #
  88. # if first_player_win:
  89. #     print("First player won")
  90. # elif second_player_win:
  91. #     print("Second player won")
  92. # elif draw:
  93. #     print("Draw!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement