C++ one Liner with logic

int Solution::solve(int A, int B) {
    return min(A, B) + min(9 - A, 9 - B) + min(9 - A, B) + min(A, 9 - B) - 4;

Think about the four rectangles formed by the bishop, just calculate the length of the diagonals of these. The length of the diagonal of a rectangle of W cells wide and L cells long would be min(L, W). Now subtract 4 from the answer as we have counted the bishop itself 4 times.