Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

White and Black Horse Lili was very glad when playing chess. She also very interested especially on knight piece. The, she decided to find some

White and Black Horse
Lili was very glad when playing chess. She also very interested especially on knight piece.
The, she decided to find some fact from the knight piece. Apparently, the “black” knight
and “white” knight are couple. Because Lili knows the truth, she will try to bring them
together. But because Lili is a beginner player in chess, she can only run each piece N
times.
Help Lili find out whether the two knights (the white and the black one) can meet together
or not.
You are encouraged to use recursive techniques to solve this problem.
Format Input
Input consists of 1 integer T indicating number of testcase and followed by 2T row after.
For each test case, the first line contains N , number of step limitation in this game. The
second line contains the coordinate (in chessboard) x1, y1, location of the “black” knight
and the coordinate (in chessboard) x2, y2, location of the “white” knight. Coordinates
will be expressed in letter and number form (e.g. A5, A2, C1).
Format Output
Output should be expressed in format “Case #X: Y ” - X is number of testcase (staring
from 1) and Y is the answer “YES” if those two knights can meet together and “NO” if
they can not meet together (without quotes).

Constraints
• 1 ≤ T, N ≤ 10
• A ≤ x1, x2 ≤ H
• 1 ≤ y1, y2 ≤ 8
Sample Input (standard input)
2
3
A1 H8
1
H1 A8
Sample Output (standard output)
Case #1: YES
Case #2: NO
Explanation
The possible way for them to meet each other is described on the figure above. Steps for
the “black” knight is colored yellow and for the “white” knight is colored red. Finally,
they meet together in a purple area.
Note
For this problem, there are many possibilities those knights can meet at various points.
So as long as they can meet together, the output will be “YES”, even though there is
only 1 valid point.

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

Entrepreneurship

Authors: Andrew Zacharakis, William D Bygrave

5th Edition

1119563097, 9781119563099

More Books

Students also viewed these Computer Network questions

Question

1. What does this mean for me?

Answered: 1 week ago