Inputting the numbers of the white and black king cells on the chessboard in turn, followed by the natural number N and the sequence N consisting of the numbers of the chessboard cells.It is required to print YES if the white king can eat the black one without passing through one of the specified n cells, assuming that the black king is stationary and NO, otherwise. Use the queue to solve the problem.
(*) - Take the first point in the queue, remove it from the queue and mark it as visited
- if it is the end point write "yes" and return
- queue up all its adjacent nodes that aren't yet visited
- if the queue isn't empty repeat from (*)
(**) - If you got this far you will never see the end point, so write "no"
It’s a trick question because the rules of chess are such that the kings can’t be eaten by each other, or even any other pice for that matter. Kings are the only pieces that can’t be taken. And in the special case of only two kings on the board it is a stalemate and no amount of manouvering can change it.