Wednesday, December 30, 2009


This tutorial is just an introduction to make one to think about solving the problem, rather than scratching head for program code directly. My further posts will directly deal with ‘c’ codes.

It is obvious that everyone faces problems in their stages of programming. Each and every puzzle or problems, given are compared by the level of hardness, which actually makes their life miserable.

It is not the programming language that one should go after, but it is the logic that they should strive for.

But then, acquiring the logic from the hidden worlds of brain is not so easy.
So let’s try to make programming life simpler by this short tutorial.

TIC TAC TOE - 'C' code and Algorithm - Part 2

If you missed the earlier part, please go through following link

Let’s just recollect what we have been through...

(1) We took position as input from user.
(2) Validated the position to be in the range of 1 and 9.
(3) Made sure that the given position is not repeated.
(4) Calculated position for two dimensional array.
(5) And then stored respective value considering the active player.

Now comes the actual part, checking whether particular move of the player made him win or game to draw.

TIC TAC TOE - 'C' code and Algorithm - Part 1


I’m back with a game this time. Well, this might be a huge tutorial, but after this most of the newbie problems will perish. So let’s get started.

Introduction to game:

In a game of Tic Tac Toe, two players take turns making an available cell in a 3X3 grid with their respective tokens (either X or O). When one player has placed three tokens in a horizontal, vertical or diagonal row on the grid, the game is over and that player has won. A draw (No winner) occurs when all the cells on the grid have been filled with tokens and neither player has achieved a win.


Let’s just note down steps to be covered.
(1) Take input position from player.
(2) Check whether respective player wins with that position.
(3) If not, continue start again from 1st step.
It’s so simple to analyse these things, but there is lot more to do to achieve these steps.