Saturday, March 16, 2013

Tic Tac Toe AI Techniques

Tic Tac Toe AI Techniques

This is a basic tic tac toe game for windows. It is based on Artificial Intelligence technique called Min-Max procedure. It is developed in C++ using OpenGL glut library for graphics.
Below is the link showing the working of game:



Techgig programming problem - Find the slope

Find the slope

Problem Statement
Question here is that you are given range of number (A to B) and you have to tell the sum of slope of all the number between A and B.
Now we define the term slope of a number N. Slope of a number N is the number of digits (excluding the first and the last digit) which is either maxima or minima in that number.
Consider a number N. A digit in number N is called minima if it is smaller than both of its neighbour and a digit is called maximaif it is larger than both of its neighbour. 
In case of wrong ranges or unexpected ranges, please return output as -1
Input Specification:

Input 1 specifies the starting range of numbers. It will be of integer type
Input 2 specifies the ending range of numbers. It will be of integer type
Output Specification:

sum of slope value of all the number in the given range . Output will be of integer type
In case of wrong ranges or unexpected ranges, please return  output as -1

Examples:

Example 1 : Consider the range 1-100 in this range all the numbers are either one digit or 2 digit so the slope value of all the number is zero and hence the sum is zero. 

Similarly, consider the range 100-150 the sum of slope of all the number in this range is 19
Example 2 : Consider the number 54698 in range 54698-54800. In this number 4 is a minima because it is smaller than it both neighbor i.e. 5 and 6. similarly digit 9 is a maxima because it is grater than both of its neighbor i.e. 6 and 8. 

Slope of 54698 is 2 because it has 4 as minima and 9 as maxima and there is no other minima or maxima. 

Similarly we check next numbers in the range 54698-54800 and sum of slope of all the numbers will be the output.