MCPcopy Create free account
hub / github.com/geekcomputers/Python / check_winner

Function check_winner

Tic-Tac-Toe Games/tic-tac-toe1.py:28–39  ·  view source on GitHub ↗

Return True if `player` has won.

(board: Board, player: str)

Source from the content-addressed store, hash-verified

26
27
28def check_winner(board: Board, player: str) -> bool:
29 """Return True if `player` has won."""
30 for i in range(3):
31 if all(board[i][j] == player for j in range(3)) or all(
32 board[j][i] == player for j in range(3)
33 ):
34 return True
35 if all(board[i][i] == player for i in range(3)) or all(
36 board[i][2 - i] == player for i in range(3)
37 ):
38 return True
39 return False
40
41
42def is_full(board: Board) -> bool:

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected