Skip to main content

Data Structure & Algo

Connect Three

Difficulty: Easy

In this challenge, you'll build a classic Tic Tac Toe game for two players. Players take turns marking X or O on a 3x3 grid, and the game declares a winner when one player achieves three in a row. If the grid is full with no winner, the game ends in a draw.

Requirements

Grid Setup
  • Create a 3x3 grid for gameplay.
  • Players take turns marking the grid:
    • Player 1 → X
    • Player 2 → O
Win Detection
  • Detect three matching symbols in a row:
    • Horizontally
    • Vertically
    • Diagonally
  • Display the winner's name when a player wins.
  • If the grid is full and no player has won, display a draw message.

Done with this challenge? Give 4-Dots a try! 🎯