Validate chess moves from the starting position
I was asked this
No reports yet. Sign in to say where you were asked it.
Start from the standard chess position with White to move. You receive a list of attempted moves such as e2e4 (from-square, to-square). For each one, decide whether it is legal and, if it is, apply it and pass the turn; an illegal move changes nothing.
Implement normal movement for every piece: sliding pieces can't jump, knights can, pawns move one square (two from their starting rank through an empty square) and capture diagonally. A move may not capture a king or leave your own king in check. Castling, en passant and promotion are out of scope. At the end, print the board.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
