Count all possible position that can be reached by Modified Knight
Given a chessboard of size 8 x 8 and the current position of Mirandote. All the rules of this chess game are the same but the knight is modified. We call the new knight “Mirandote”. The move of Mirandote is given by a blue color where its current position is denoted by red color in the following image :
The task is to find how many possible positions exist in Chessboard that can be reached by Mirandote in exactly S steps.
Input: row = 4, col = 4, steps = 1
All the 12 moves denoted by the following image by blue color :
Input: row = 4, col = 4, steps = 2
We can observe that all the possible positions with respect to the current position can be written in the form of rows and columns. This is illustrated by the following image:
We can call a function recursively for each possible position and count all the possible positions.
Below is the required implementation to find the positions:
Time complexity of the above algorithm is O(12S), where S is the number of steps.