Problem: Minimum Moves to Capture The Queen

There is a 1-indexed `8 x 8` chessboard containing `3` pieces.

You are given `6` integers `a`, `b`, `c`, `d`, `e`, and `f` where:

* `(a, b)` denotes the position of the white rook.
* `(c, d)` denotes the position of the white bishop.
* `(e, f)` denotes the position of the black queen.

Given that you can only move the white pieces, return the minimum number of
moves required to capture the black queen.

Note that:

* Rooks can move any number of squares either vertically or horizontally, but cannot jump over other pieces.
* Bishops can move any number of squares diagonally, but cannot jump over other pieces.
* A rook or a bishop can capture the queen if it is located in a square that they can move to.
* The queen does not move.


Python solution:
import math
import itertools
import bisect
import collections
import string
import heapq
import functools
import sortedcontainers
from typing import List, Dict, Tuple, Iterator

class Solution:
  def minMovesToCaptureTheQueen(self, a: int, b: int, c: int, d: int, e: int, f: int) -> int:
    if a == e:
      if c == a and (b < d < f or b > d > f):
        return 2
      else:
        return 1
    if b == f:
      if d == f and (a < c < e or a > c > e):
        return 2
      else:
        return 1
    if c + d == e + f:
      if a + b == c + d and (c < a < e or c > a > e):
        return 2
      else:
        return 1
    if c - d == e - f:
      if a - b == c - d and (c < a < e or c > a > e):
        return 2
      else:
        return 1
    return 2


Java solution:
class Solution {
  public int minMovesToCaptureTheQueen(int a, int b, int c, int d, int e, int f) {
    // The rook is in the same row as the queen.
    if (a == e)
      // The bishop blocks the rook or not.
      return (c == a && (b < d && d < f || b > d && d > f)) ? 2 : 1;
    // The rook is in the same column as the queen.
    if (b == f)
      // The bishop blocks the rook or not.
      return (d == f && (a < c && c < e || a > c && c > e)) ? 2 : 1;
    // The bishop is in the same up-diagonal as the queen.
    if (c + d == e + f)
      // The rook blocks the bishop or not.
      return (a + b == c + d && (c < a && a < e || c > a && a > e)) ? 2 : 1;
    // The bishop is in the same down-diagonal as the queen.
    if (c - d == e - f)
      // The rook blocks the bishop or not.
      return (a - b == c - d && (c < a && a < e || c > a && a > e)) ? 2 : 1;
    // The rook can always get the green in two steps.
    return 2;
  }
}


C++ solution:
class Solution {
 public:
  int minMovesToCaptureTheQueen(int a, int b, int c, int d, int e, int f) {
    // The rook is in the same row as the queen.
    if (a == e)
      // The bishop blocks the rook or not.
      return (c == a && (b < d && d < f || b > d && d > f)) ? 2 : 1;
    // The rook is in the same column as the queen.
    if (b == f)
      // The bishop blocks the rook or not.
      return (d == f && (a < c && c < e || a > c && c > e)) ? 2 : 1;
    // The bishop is in the same up-diagonal as the queen.
    if (c + d == e + f)
      // The rook blocks the bishop or not.
      return (a + b == c + d && (c < a && a < e || c > a && a > e)) ? 2 : 1;
    // The bishop is in the same down-diagonal as the queen.
    if (c - d == e - f)
      // The rook blocks the bishop or not.
      return (a - b == c - d && (c < a && a < e || c > a && a > e)) ? 2 : 1;
    // The rook can always get the green in two steps.
    return 2;
  }
};