Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Algorithm 1 : Movement of Knights The relative positions of two knight pieces on a chess board are given to you. The position of each

Algorithm 1: Movement of Knights
The relative positions of two knight pieces on a chess board are given to you. The position of each
knight is given as a list of 2 values, the and coordinates. A knight can make 1 of 8 possible
moves on any given turn. Each of these moves involves moving in an "L" shape. This means they
can either move 2 squares horizontally and 1 square vertically, or they can move 1 square
horizontally and 2 squares vertically. For example, if a knight is currently at position [0,0], then
it can move to any of these 8 locations on its next move:
[
]
[-2,1],[-1,2],[1,2],[2,1],[2,-1],[1,-2],[-1,-2],[-2,-1]
A knight is able to capture the other knight when it moves onto the square currently occupied by
the second knight. For each knight, a turn allows only a move. For example, if both knights moved
towards each other once, and then knightA captures knightB on its next move, two turns would
have been used (even though knightB never made its second move).
Design an algorithm that returns the minimum number of turns required before one of the knights
is able to capture the other knight, assuming they are working together to achieve this goal. The
number should be rounded off to the whole number.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions

Question

What is the purpose of the staffing practice called Two-in-aBox?

Answered: 1 week ago

Question

What would you do?

Answered: 1 week ago