407221: GYM102697 192 Knight's Move
Description
You have an 8 by 8 chessboard with several knights on it. The chessboard has no other pieces on it. Given the positions of the knights, find all of the spaces that the knights can travel to in a single move.
Recall that in chess, a knight can move exactly 2 spaces in one direction, and exactly one space in a perpendicular direction. For example, a knight could move 2 spaces left and 1 space up, or 2 spaces up and 1 space left, but a knight could not move 2 spaces left on its own, or 1 space up and 1 space right, for example.
InputThe input consists of 8 lines, each consisting of 8 characters, representing the chessboard.
A single dot (".") represents an empty space on the chessboard, and an uppercase K ("K") represents the position of a knight.
OutputOutput 8 lines, in the same format as the input, except, replace each empty space that can be moved to by at least one knight in a single move with an asterisk ("*").
ExamplesInput........ ........ ........ ...K.... ........ .....K.. ........ ........Output
........ ..*.*... .*...*.. ...K*.*. .*.*.*.* ..*.*K.. ...*...* ....*.*.Input
........ ..K....K ........ ...K.... ........ .....K.. ........ ......KKOutput
*...**.. ..K.*..K **..**.. .*.K*.*. .*.*.*.* ..*.*K** ...***.* ....*.KKInput
........ ........ ........ ........ ........ ........ ........ .......KOutput
........ ........ ........ ........ ........ ......*. .....*.. .......K