Create a function that takes a chess position (black pieces to move next) and returns the status of the black king.
P, Knight N, Bishop B, Rook R, Queen Q, King K. Black pieces are represented with lowercase letters.(x, y) being x, the horizontal position of the escape square, and y the vertical position of the escape square. The escape positions must be sorted by x and then y, always from the lowest value to the highest value.0 <= x < 8 and 0 <= y < 8. The white queen starts at (7, 3).chess([
[" ", " ", " ", " ", " ", "r", " ", " "],
[" ", " ", " ", " ", " ", " ", " ", "q"],
[" ", " ", " ", " ", " ", " ", "N", " "],
["k", " ", " ", " ", " ", " ", " ", " "],
[" ", "P", " ", "P", " ", " ", " ", " "],
[" ", " ", "P", " ", " ", "Q", " ", " "],
["B", " ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", "R", " ", " ", "K", " "],
])
➞ "The black king is checked. Possible escape positions: [(2, 0), (2, 1), (3, 1), (4, 0)]"
chess([
[" ", " ", " ", " ", " ", "r", " ", " "],
[" ", " ", " ", " ", " ", " ", "k", "q"],
[" ", " ", " ", " ", " ", " ", "N", " "],
[" ", " ", " ", " ", " ", " ", " ", " "],
[" ", "P", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", "Q", " ", " "],
["B", " ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", "R", " ", " ", "K", " "],
])
➞ "The black king is safe."
chess([
[" ", " ", " ", " ", " ", "r", " ", " "],
[" ", " ", " ", " ", " ", " ", " ", "q"],
[" ", " ", " ", " ", " ", " ", "N", " "],
[" ", " ", " ", " ", " ", " ", " ", " "],
[" ", "P", " ", "k", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", "Q", " ", " "],
["B", " ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", "R", " ", " ", "K", " "],
])
➞ "The black king is checkmated."
chess([
[" ", " ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", "k", " "],
[" ", " ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", "B", "p", " ", " "],
[" ", " ", " ", "q", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", " ", " "],
["p", " ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", "K", "R", " "],
])
➞ "The black king is double-checked. Possible escape positions: [(0, 5), (1, 5), (1, 7), (2, 7)]"
N/A