Pages

Wednesday 25 October 2017

A Tryst With Chess- Coding challenge Solved with Backtracking Algorithm | Developed by PY.

Today I m posting solution developed by me for this coding challenge. Got Crazy with the Backtracking Algorithm.

PROBLEM STATEMENT: 

You are given a 10X10 chessboard with a knight on coordinate (I,J). You have to find the number of blocks on the chessboard that the knight can be at in exactly N moves.

NOTE:

The knight can move from its position in the diagram to all the coordinates marked by X
in the following diagram in one move. For the 10X10 chessboard (1,1) is the top-left corner,(1,10) is the top-right corner and (10,10) is the bottom-right corner.




INPUT :

Input will consist of three space separated integers I
,J,N

N is less than 10.

OUTPUT:

Print a single integer denoting the number of blocks on the chessboard that the knight can be at in exactly N
moves.


Sample Input: 3 3 1
Sample Output: 8