Two-Move Knight
InterviewTime limit1sMemory limit1024 MB
Given a knight's starting square on a chess board, list every square the knight can reach in exactly two moves.
- Level
Easy2 of 10
- Topics
- Brute force, Implementation
- Solved
- No attempts yet
Statement
A knight moves in an L-shape: first two squares horizontally or vertically, then one square in the direction perpendicular to the first. The figure below marks every square the knight can reach in one move.

Write a program that finds every square where the knight can be after exactly two moves, starting from a given position on the board.
Input
The first line contains the knight's starting position in standard chess notation: a letter from 'a' to 'h' for the column and a digit from '1' to '8' for the row.
Output
Print each square where the knight can be after two moves, one per line, in the same format as the starting position in the input. The order of the lines does not matter.