Tic Tac Toe Validator

Medium Mini Projects & Algorithmic Challenges
Solve in Playground →

Problem Statement

Write a C++ program checking a 3×3 Tic Tac Toe grid for a winning condition (‘X’ or ‘O’).

Input Format

A 3x3 character matrix representing the board state.

Output Format

Print 'X Wins', 'O Wins', or 'Ongoing'.

Constraints

Grid elements are 'X', 'O', or '.'

Sample Input

X X X
. O .
. O .

Sample Output

X Wins

Explanation

Evaluates rows, columns, and diagonals for matching symbols.

Starter Code

#include <iostream>
#include <vector>

int main() {
    char grid[3][3];
    bool ok = true;
    for(int i=0; i<3; i++) {
        for(int j=0; j<3; j++) {
            if(!(std::cin >> grid[i][j])) ok = false;
        }
    }
    if(ok) {
        // Write your tic tac toe validator logic here
    }
    return 0;
}

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used