Author: Steffan Westcott
Date: 10:32:33 02/22/05
Go up one level in this thread
On February 22, 2005 at 08:35:07, Andrew Wagner wrote: >There are 64 x 63 = 4032 ways to put a black knight and white knoght both on a >chess board. Write a program -- from scratch -- to generate FENs for each of >these positions. The FENs should look something like: Nn6/8/8/8/8/8/8/8 w - - 0 >1. Here is my answer written in Perl. I had fun with this :) Cheers, Steffan. $a = "N" . " " x 62; do { $b = "n" . $a; do { $_ = $b; s/.{8}(?=.)/$&\//g ; s/ +(?{$n=length $&})/$n/g ; print $_ . " w - - 0 1\n"; $b = (chop $b) . $b; } until ($b =~ /^n/); $a = (chop $a) . $a; } until ($a =~ /^N/);
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.