Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Chess programming puzzle

Author: Scott Gasch

Date: 14:14:59 02/22/05

Go up one level in this thread


On February 22, 2005 at 16:29:40, Alessandro Scotti wrote:

>On February 22, 2005 at 15:37:44, Scott Gasch wrote:
>
>>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
>
>It can get worse though... :-)
>
>#include <stdio.h>
>
>int main( void )
>{
>    for( int nn=0; nn<4096; nn++ )
>        if( (nn & (nn >> 6)) == 0 ) {
>            for( int empty=0, sq=0; sq < 64 || printf( empty ? "%d w - - 0 1\n"
>: " w - - %d 1\n", empty ) == 0; sq++ ) {
>                if( (sq % 8) == 0 || sq == (nn & 0x3F) || sq == (nn >> 6) ) {
>                    printf( empty ? "%d%s%s" : "%*s%s", empty, "", sq && (sq %
>8) == 0 ? "/" : "" );
>                    empty = -printf( "%s", sq == (nn & 0x3F) ? "n" : sq == (nn
>>> 6) ? "N" : "" );
>                }
>                empty++;
>            }
>        }
>
>    return 0;
>}

[ scott@wannabe:~/tmp ] % gcc34 good.c -std=c99 -O -S ; wc -l good.s
     122 good.s
[ scott@wannabe:~/tmp ] % g++34 good.c -O -S ; wc -l good.s
     183 good.s

I thought you were the winner until I realized that gcc and g++ are spitting out
different asm.  I like the solution though :)

Scott



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.