New Method for any similar question


#1

int Solution::solve(int A, int B) {
int sum=A+B;
int diff=(A-B);
int count=0;
for(int i=1;i<=8;i++)
for(int j=1;j<=8;j++)
{
if(((i-j)==diff)||((i+j)==sum))
count++;

}
return count-1;
}