Given an 8x8 grid of letters representing the current state of a game of chess, your program's task is to find a next move for white that results in checkmate (the answer will always be mate in one move).
Input
Input will be on STDIN - 8 lines of 8 characters each. The meanings of each character are as follows:
K/k - king
Q/q - queen
B/b - bishop
N/n - knight
R/r - rook
P/p - pawn
- - empty square
Upper case letters represent white pieces, and lower case represents black. The board will be oriented so that white is playing up from the bottom and black is playing down from the top.
Output
A move for white that results in checkmate, in algebraic notation. You do not need to notate when a piece has been taken, nor do you need to be concerned about disambiguating between two identical pieces which can make the same move.
Sample input
Example 1
Input:
------R-
--p-kp-p
-----n--
--PPK---
p----P-r
B-------
--------
--------
Output:
c6
Example 2
Input:
--b-r--r
ppq-kp-p
-np-pn-B
--------
---N----
--P----P
PP---PP-
R--QRBK-
Output:
Nf5
Example 3
Input:
---r-nr-
-pqb-p-k
pn--p-p-
R-------
--------
-P-B-N-P
-BP--PP-
---QR-K-
Output:
Rh5
You can assume that the solution will not involve castling or en-passant.
This is code-golf - shortest solution wins.
(Examples taken from mateinone.com - puzzles 81, 82 and 83 Website has been replaced with spam)