Tic-tac-toe winner · tic-tac-toe の勝者判定
Tic-tac-toe winner
Decide a game of noughts and crosses from the board.
There are eight lines to check: three rows, three columns and two diagonals. board[r][c] is the square in row r and column c, so a column is board[0][c] + board[1][c] + board[2][c]. Collect all eight lines as three-letter strings, then look for "XXX" or "OOO".
タックタックトゥーの勝者判定
ボードを見てオタOXゲームの勝者を決定します。
確認すべき8つのラインがあります:3つの行、3つの列、2つの対角線です。board[r][c] は行 r と列 c のマス目なので、列は board[0][c] + board[1][c] + board[2][c] です。8つのラインをすべて3文字の文字列として収集し、"XXX" または "OOO" を探します。
Write winner(board). board is a list of three strings, one per row, using X, O, and . for an empty square. Return "X" or "O" if that player has three in a row, column or diagonal, otherwise "". · winner(board)を記述する。boardは3つの文字列のリストであり、1行ずつX、O、.で空白を表している。そのプレイヤーが横、縦、斜めに3つ揃っている場合"X"または"O"を返し、否则""を返す。
Click Run to see the output here. · 実行ボタンをクリックして出力を確認してください。