Tic-tac-toe winner · فائز لعبة X O
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".
فائز لعبة X O
تحديد الفائز في لعبة X O من اللوحة.
هناك ثمانية خطوط للتحقق منها: ثلاثة صفوف وثلاثة أعمدة واثنان قطريين. board[r][c] هو المربع في الصف r والعمود c، لذا العمود هو board[0][c] + board[1][c] + board[2][c]. اجمع جميع الخطوط الثمانية كسلاسل ثلاثية الأحرف، ثم ابحث عن "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 هي قائمة من ثلاث سلاسل نصية، واحدة لكل صف، تستخدم X، O، و. للمربع الفارغ. ارجع "X" أو "O" إذا كان ذلك اللاعب قد جمع ثلاثة في صف أو عمود أو قطر، وإلا ارجع "".
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.