Check and legal moves (Chess)

A move is legal only if it does not leave your own king attacked. MOVES now lists only legal moves. CHECK prints <side is in check or <side is not in check for the side to move; COUNT prints <side has <n legal moves.

Input: As before, plus CHECK and COUNT.

Output: As before.

Difficulty: Hard. Write your answer in the browser editor, run the examples, then submit it against hidden tests. Python and JavaScript are free; other languages are part of licode Club.

Hint

  • Make the move on a copy of the board, then ask: is my king attacked?

More Chess practice