Question: Python programming language required On a chessboard of 8 x 8 squares, a rook is positioned on a certain square and needs to move to

Python programming language requiredPython programming language required On a chessboard of 8 x 8 squares,a rook is positioned on a certain square and needs to move

On a chessboard of 8 x 8 squares, a rook is positioned on a certain square and needs to move to a certain position without crossing any occupied square. Determine the minimum number of moves necessary for the rook to reach its destination position. Standard input will contain a description of the chessboard in the form of 8 lines, each containing 8 symbols. Each symbol represents one chessboard square: ! - a free square 'x' - an occupied square 'V' - the starting position of the rook 'c' - the ending position of the rook The program should write a single integer to standard output - the minimum number of moves the rook must make to reach the destination square. If the rook cannot reach its destination, write the number -1. Sample input: ...XX... ..VX.... . . .XC... ...X.... . . .XX... ....X.X. Output: 4 Sample input #2: Output: 1 Sample input #3: .XC Output: 3 Sample input #4: V....... .XXXX... ...... X.C.... .X. Output: 3 Sample input #5: V....... X. Output: 2 Hints: you can use a breadth-first search to find the shortest This is a state space search problem. path between two states in a state space

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!