From 723a00b12f7da7d41de7cf5176f1e19b4f5d19ec Mon Sep 17 00:00:00 2001 From: jbayati Date: Mon, 17 Nov 2025 09:31:28 -0500 Subject: [PATCH] checkpoint 2:I scanned the board to find if there were three of the same symbols in a row, column, or diagonal. --- ttt/game.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ttt/game.py b/ttt/game.py index 2f0e302..68983af 100644 --- a/ttt/game.py +++ b/ttt/game.py @@ -58,4 +58,15 @@ class TTTGame: def check_winner(self, state, symbol): "Checks whether the player with `symbol` has won the game." + b = state["board"] + for r in range(3): + if b[3*r] == symbol and b[3*r+1] == symbol and b[3*r+2] == symbol: + return True + for c in range(3): + if b[c] == symbol and b[c+3] == symbol and b[c+6] == symbol: + return True + if b[0] == symbol and b[4] == symbol and b[8] == symbol: + return True + if b[2] == symbol and b[4] == symbol and b[6] == symbol: + return True return False