Chess endgame: White to Mate In One
Ruby, 589 512 510 499 493 characters
R=0..7
a=-&gt;b{o=[];R.map{|r|R.map{|c|v=Hash[?K,[6,7,8,11,13,16,17,18],?R,s=[157,161,163,167],?B,t=[156,158,166,168],?Q,s+t,?N,[1,3,5,9,15,19,21,23],?P,[32,181,183]][z=b[r][c]];v&amp;&amp;v.map{|s|k=2!=l=s/25+1;u=r;v=c;l.times{u+=s/5%5-2;v+=s%5-2;R===u&amp;&amp;R===v||break;t=b[u][v];j=t&lt;?.&amp;&amp;l&lt;8;(j||t=~/[a-z]/&amp;&amp;k)&amp;&amp;o&lt;&lt;=(h=b.map &amp;:swapcase;h[u][v]=h[r][c];h[r][c]=?-;[z+&quot;%c%d&quot;%[97+v,8-u],h.reverse]);j&amp;&amp;(k||r==6)||break}}}};o}
a[$&lt;.map{|l|l}].map{|m,b|a[b].any?{|f,x|a[x].all?{|g,y|y*&quot;&quot;=~/K/}}||$&gt;&lt;&lt;m[/[^P]+/]}

Input is given via stdin, e.g.:
&gt; ruby mateinone.rb
--------
--------
--------
-k------
b-------
-N-P----
--------
-----K-Q
^Z
Qb7

The output is not just one move that forces a mate in one but every move that does so.
Edit 1: The function e was used only once so I inlined it. Second, the encoding now is based on number 5 instead of 10. And refactoring the cloning of the board saved quite a few chars.
Edit 2: Still not as much improvement as I wanted. Changing the hash from {a=&gt;b,c=&gt;d} to Hash[a,b,c,d]. This costs 4 characters but saves one per key-value pair.
Edit 3: Only minor reductions: inlining M (4 characters), t==?- -&gt; t&lt;?. (2), removing Pawn in algebraic notation at the end (2), replaced puts (3). The program is now less than 500 characters.
Edit 4: It is interesting how much one can still find in such a program. Moved an invariant outside the loop and found another duplicate calculation.