Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Chess programming puzzle

Author: Scott Gasch

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

Go up one level in this thread


On February 22, 2005 at 15:18:44, Alessandro Scotti wrote:

>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 );
>            }

Yours was hard to compile.. I had to add a main function and use -std=c99 to get
 the for loops to work.  Also had to use gcc instead of g++.

[ scott@wannabe:~/tmp ] % gcc34 -O -S -std=c99 wagner.c ; wc -l wagner.s
     118 wagner.s



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.