Skip to content · ⁨דלג לתוכן⁩

Tic-tac-toe winner · ⁨מנצח משחק קרוס-או-ואן⁩

English

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".

עברית

מנצח בקטקטוא

לקבוע מי ניצח במשחק צ'כיה מהלוח.

ישנם שמונה קווים לבדיקה: שלוש שורות, שלושה עמודות ושני אלכסונים. board[r][c] הוא הריבוע בשורה r בעמודה c, ולכן עמודה היא board[0][c] + board[1][c] + board[2][c]. איסוף כל שמונת הקווים כמחרוזות של שלושה אותיות, ולאחר מכן חיפוש אחר "XXX" או "OOO".

Log in or create account · ⁨היכנס או צור חשבון⁩

IGCSE, A-Level & AP