#K61142. Knight Moves
Knight Moves
Knight Moves
Given a knight's position on a standard 8×8 chessboard, determine the number of valid moves the knight can make. The position is provided in standard algebraic notation (e.g., d4).
The knight moves in an L-shape: two squares in one direction and one square perpendicular. The set of possible moves in coordinate offsets is: $$\{ (2,1),\,(2,-1),\,(-2,1),\,(-2,-1),\,(1,2),\,(1,-2),\,(-1,2),\,(-1,-2) \}$$. Only moves that keep the knight within the board boundaries (columns a to h and rows 1 to 8) are considered valid.
inputFormat
The input consists of a single line containing a chessboard position in algebraic notation (e.g., d4).
outputFormat
Output a single integer representing the number of valid moves the knight can make from the given position.## sample
d4
8