Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Chess programming puzzle

Author: Alessandro Scotti

Date: 12:18:44 02/22/05

Go up one level in this thread


On February 22, 2005 at 08:35:07, Andrew Wagner wrote:

Here's another try (12 lines, I don't think the '*' width specifier is ANSI but
should be recognizer without problems by most compilers).

    for( int bn=0; bn<64; bn++ )
        for( int wn=0; wn<64; wn++ )
            if( bn != wn ) {
                for( int empty=0, sq=0; sq < 64; sq++ ) {
                    if( (sq % 8) == 0 || sq == bn || sq == wn ) {
                        printf( empty ? "%d%s%s" : "%*s%s", empty, "", sq && (sq
% 8) == 0 ? "/" : "" );
                        empty = -printf( "%s", sq == bn ? "n" : sq == wn ? "N" :
"" );
                    }
                    empty ++;
                }
                printf( empty ? "%d - - 0 1\n" : " - - %d 1\n", empty );
            }



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.