Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Chess programming puzzle

Author: Uri Blass

Date: 13:39:21 02/22/05

Go up one level in this thread


On February 22, 2005 at 15:33:31, Scott Gasch wrote:

>On February 22, 2005 at 13:32:33, Steffan Westcott wrote:
>
>>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 is nice.  I thought as soon as I read the parent "this would be cool to do
>in Perl" but I don't have the perl skills to make something.  You have my vote
>for coolest solution.
>
>Scott

I know nothing about perl so for me the solution is simply irrelevant.
relevant solutions are only solutions that I am able to understand.

Tim Foden's solution is for me the best solution.

Uri



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.