subject

Your program should read from an input file, which will contain one or more test cases. Each test case consists of one line containing two squares separated by one space. A square is a string consisting of a letter (a-h) representing the column and a digit (1-8) representing the row on the chessboard. Input. txte2 e4a1 b2b2 c3a1 h8a1 h7h8 a1b1 c3f6 f6Output SpecificationFor each test case, print one line saying To get from xx to yy takes ?? knight moves. in console. Sample OutputBelow is the correct output for the previous sample input:To get from e2 to e4 takes 2 knight moves. To get from a1 to b2 takes 4 knight moves. To get from b2 to c3 takes 2 knight moves. To get from a1 to h8 takes 6 knight moves. To get from a1 to h7 takes 5 knight moves. To get from h8 to a1 takes 6 knight moves. To get from b1 to c3 takes 1 knight moves. To get from f6 to f6 takes 0 knight moves. Hints1. According to the problem description, the grid is 8 by 8, therefore there are 64 squares. We can then model the chessboard as a graph with 64 vertices; and an edge between two vertices exists if and only if we can make a knight move from one vertex to another.2. When moving to the next position, a knight can have at most eight possible directions, as shown in the above figure for the black knight, without getting out of the chess board boundary.3. The problem becomes a graph traversal problem!4. DFS or BFS? Which one will work?

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 13:30
1. technician a says horsepower information can be used by consumers to compare the power of different automobile engines. technician b says that manufacturers will often list the horsepower output of their engines in the online service information. who is right?
Answers: 2
question
Computers and Technology, 23.06.2019 23:30
A. in packet tracer, only the server-pt device can act as a server. desktop or laptop pcs cannot act as a server. based on your studies so far, explain the client-server model.
Answers: 2
question
Computers and Technology, 24.06.2019 02:20
Peter is thinking of a number which isless than 50. the number has 9 factors.when he adds 4 to the number, itbecomes a multiple of 5. what is thenumber he is thinking of ?
Answers: 1
question
Computers and Technology, 24.06.2019 02:40
Has anyone seen my grandma shes been gone for 4 years already
Answers: 1
You know the right answer?
Your program should read from an input file, which will contain one or more test cases. Each test ca...
Questions
question
Mathematics, 14.09.2020 18:01
question
Mathematics, 14.09.2020 18:01
question
Social Studies, 14.09.2020 18:01
question
Mathematics, 14.09.2020 18:01
question
English, 14.09.2020 18:01
question
Mathematics, 14.09.2020 18:01
question
Mathematics, 14.09.2020 18:01
question
Health, 14.09.2020 18:01
question
Social Studies, 14.09.2020 18:01
question
Mathematics, 14.09.2020 18:01
question
Mathematics, 14.09.2020 18:01
question
Mathematics, 14.09.2020 18:01
question
Mathematics, 14.09.2020 18:01
question
Physics, 14.09.2020 18:01
question
English, 14.09.2020 18:01
question
Geography, 14.09.2020 18:01
question
Geography, 14.09.2020 18:01
question
Mathematics, 14.09.2020 18:01
question
Mathematics, 14.09.2020 18:01
question
Mathematics, 14.09.2020 18:01
Questions on the website: 13722360