Problem 315. Valid Chess Moves
Using standard Algebraic notation ('' for a pawn), given previous move and a next move, output true if it is a valid move or false otherwise. Assume there are no other pieces on the chess board, that the piece can be either black or white (whichever generates a valid result) and the previous move was valid. Examples:
Moving a pawn one space:
('c5','c6') -> true
Moving a bishop non-diagonally:
('Bb7','Bd7') -> false
Solution Stats
Problem Comments
-
2 Comments
Jean-Marie Sainthillier
on 20 Jul 2012
Hard !
Rafael S.T. Vieira
on 11 Aug 2020
This is a good problem, but it needs more test cases. There is no test with the King for instance, and there should be a true and false state test for every piece.
Solution Comments
Show commentsProblem Recent Solvers75
Suggested Problems
-
Remove the small words from a list of words.
1526 Solvers
-
Back to basics 23 - Triangular matrix
1030 Solvers
-
Lychrel Number Test (Inspired by Project Euler Problem 55)
100 Solvers
-
Make a vector of prime numbers
798 Solvers
-
String Array Basics, Part 1: Convert Cell Array to String Array; No Missing Values
1721 Solvers
More from this Author39
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!