Table of contents
1.
Introduction
2.
Problem statement
3.
Solution 
3.1.
Explanation 
4.
Frequently Asked Questions
4.1.
What is the logic behind the Tic-tac-toe game?
4.2.
Is Tic-tac-toe a solved game?
4.3.
Is it necessary to start the game first in a Tic-tac-toe game to win?
5.
Conclusion
Last Updated: Mar 27, 2024

Tic Tac Toe Puzzle

Author Shivam Verma
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?
Interview Puzzles

Introduction

Puzzles are good exercise for the brain. They help in enhancing the cognitive abilities of the brain helping with Problem Solving and related skills. There are numerous types of puzzles; each one having a logic inherent to itself which helps in cracking it. A good puzzle well is actually like a good mystery that we may have read about or watched on TV. It has the finest of hints which help in reaching its solution.

The following article discusses one such puzzle so let's get right to it.

Problem statement

The Tic-tac-toe game is being played between two players in which two players came through the given situation after six moves, as depicted in the below figure.

Illustration Image

Can you answer the following questions after analyzing the puzzle?

  1. Who will win the puzzle, O or X?
  2. Who marks the last move and at which position?

Assume that both the contestant are intelligent enough, and each of their moves will be the best possible move that can be taken in a particular situation.

Solution 

O will win the puzzle. X marks the last move and at 9th position.

Explanation 

The following problem leads us to a dilemma where we have two conditions, and they are represented by the figure as depicted below.

  1. If the next turn is of O, then O wins.
     
Illustration Image
  1. If the next turn is of X, then X wins.
     
Illustration Image

After concluding both the cases, the 7th move will be the deciding move. So our main aim is to gather information about who marks the last move and at which position.

Before analyzing the 7th(last move) move, we must have clarity on the sixth move of the game.

There are two possibilities for the sixth move, i.e., X in the 9th box and O in the 7th box.

Illustration Image

As we know that both the players are intelligent enough, the sixth mark can never be of O in square 7. Instead, he would have placed O in square 5 and won the game before the sixth move. This can be easily depicted by the figure shown above.

From the above discussion, it is clear that the X makes the sixth move at 9th position, and the next move is done by O at 5th position and will win the game.

Check out this problem - 8 Queens Problem

Frequently Asked Questions

What is the logic behind the Tic-tac-toe game?

The Tic-tac-toe is a popular game for two players, X and O, who take turns marking the empty spaces in a 3×3 grid. The participant who successfully places three of their marks in a vertical, horizontal, or diagonal row wins the game.

Is Tic-tac-toe a solved game?

Tic-tac-toe is a solved game; unless a player makes a dumb mistake, every game will end in a draw.

Is it necessary to start the game first in a Tic-tac-toe game to win?

No, it is just a myth both players have equal chances of winning the game.

Conclusion

In this article, we have extensively discussed the problem statement and solution regarding the Tic-tac-toe Puzzle considering both the players move optimally we moved on from cases to reach a deciding point and thus arrive at a proper solution. We have estimated the moves of each player for every turn as best as possible and the moves are all optimally decided and played. Thus we reach a conclusion in the end.

Recommended Readings:


Do check out The Interview guide for Product Based Companies as well as some of the Popular Interview Problems from Top companies like Amazon, Microsoft, Google, etc. on Coding Ninjas Studio.

Also check out some of the Guided Paths on topics such as Data Structure and Algorithms, Competitive Programming, Operating Systems, Computer Networks, DBMS, etc. as well as some Interview Bundles, and some Interview Experiences curated by top Industry Experts only on Coding Ninjas Studio.

Do upvote our blog to help other ninjas grow. Happy Coding!

Live masterclass