Skip to content
Programmingoneonone
Programmingoneonone
  • Engineering Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
    • 100+ C++ Programs
  • Solutions
    • HackerRank
      • Algorithms Solutions
      • C solutions
      • C++ solutions
      • Java solutions
      • Python solutions
    • Leetcode Solutions
    • HackerEarth Solutions
  • Work with US
Programmingoneonone
Programmingoneonone

HackerEarth A chessboard problem solution

YASH PAL, 31 July 202415 February 2026
In this HackerEarth A chessboard problem solution In this version of chess, only two kings pieces are placed on the chessboard. Initially, the coordinates of the first king piece are generated (X1, Y1), it is placed on the chessboard at the generated position. Now, the coordinates of the second king piece are generated (X2, Y2), it is placed on the chessboard at the generated position.
 
These pieces can be moved in a sequential manner, that is, one by one, starting from the first piece. Both the kings want to win if they can not, at least draw.
 
 
HackerEarth A chessboard problem solution

 

 

HackerEarth A chessboard problem solution.

#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define endl "n"
#define test ll txtc; cin>>txtc; while(txtc--)
typedef long long int ll;
typedef long double ld;
int main() {
FIO;
test
{
ll x1,y1; cin>>x1>>y1;
ll x2,y2; cin>>x2>>y2;
if(x1==x2 && y1==y2){
cout<<"SECOND";
}
else if(abs(x1-x2)<=1 && abs(y1-y2)<=1){
cout<<"FIRST";
}
else{
cout<<"DRAW";
}
cout<<endl;
}
return 0;
}
 

Second solution

t = int(input())
while t > 0:
t -= 1
[x1, y1] = map(int, input().split())
[x2, y2] = map(int, input().split())
print("SECOND" if abs(x1 - x2) <= 0 and abs(y1 - y2) <= 0 else "FIRST" if abs(x1 - x2) <= 1 and abs(
 
coding problems solutions HackerEarth HackerEarth

Post navigation

Previous post
Next post

Leave a Reply

Your email address will not be published. Required fields are marked *

Programmingoneonone

We at Programmingoneonone, also known as Programming101 is a learning hub of programming and other related stuff. We provide free learning tutorials/articles related to programming and other technical stuff to people who are eager to learn about it.

Pages

  • About US
  • Contact US
  • Privacy Policy

Practice

  • Java
  • C++
  • C

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes