Question

Chess horse walks - two cells vertically in any direction and
one cell horizontally, or vice versa. Two different cells of the
chessboard are given, determine whether the horse can get from the
first cage to the second one move.

Input format

The program receives four numbers from 1 to 8 each, setting
the column number and the number of the line first for the first
cell, then for the second cell.

Output format

The program should withdraw YES if the first cage by the
stroke of the horse can get into

the second or NO otherwise.

Answer #1

Since this question doesnt specify a programming language I am using c++.

This question asks if a horse can reach from one cell to another in one move.

#include<bits/stdc++.h>

using namespace std;

int main()

{

int x1,x2,y1,y2;

cin>>x1>>y1>>x2>>y2;

if(abs(x1-x2)==2&&(abs(y1-y2)==1))

cout<<"YES"<<endl;

else if(abs(x1-x2)==1&&abs(y1-y2)==2)

cout<<"YES"<<endl;

else

cout<<"NO"<<endl;

}

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 23 minutes ago

asked 34 minutes ago

asked 42 minutes ago

asked 45 minutes ago

asked 57 minutes ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 2 hours ago

asked 2 hours ago

asked 2 hours ago