Posts

Showing posts from September 19, 2021

Knight - Possible Moves

Image
 Knight - Possible Moves PROBLEM STATEMENT : The program must accept the position of a Knight (Horse) in a chessboard denoted by the letter 'H'  and print the number of moves M it can make from that position. Assume no other pieces are on the chessboard which is denoted by the letter B . Note: In Chess, a knight can move two squares vertically and one square horizontally, or two squares horizontally and one square vertically (with both forming the shape of an L). Input Format: 8 lines and one line among them containing the letter H. Output Format: The first line contains M. Example Input/Output 1: Input: ( ) B B B B B B H B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B Output: 3 Explanation:  The positions where the Knight can move are indicated by ' * '. B B B B B B H B B B B B * B B B B B B B B * B * B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B As three moves are possib...