Author: Uri Blass
Date: 03:25:52 02/23/05
Go up one level in this thread
On February 23, 2005 at 02:18:16, Ross Boyd wrote:
>On February 22, 2005 at 17:24:44, Alessandro Scotti wrote:
>
>>On February 22, 2005 at 17:14:59, Scott Gasch wrote:
>>
>>>I thought you were the winner until I realized that gcc and g++ are spitting out
>>>different asm. I like the solution though :)
>>>
>>>Scott
>>
>>Drats! So much for the shower of praise and adulation then... :-)
>
>Ok,
>
>Are you ready....
>
>Seated? ....
>
>Shall we begin?... :-)
>
>Alessandro, your code is simply stupendous in its elegance and profundity. If
>Alan Turing were alive today he would weep with tears of joy at the elegance,
>the irrefutable logic, the precision, the mental acuity, the divine simplicity.
>
>Even God himself would wax envious and mutter "Drats! I couldn't have done it as
>good as that."
I think that god certainly could do a better code to teach me C by adding
comments
I had no idea what %*s%s" means and only after rewriting the code
I could understand that it probably means ignoring the first thing.
I am still unsure if *s means ignore first information that is supposed to be a
string in the general case
Here is a better code with my comments
#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 ? "/" : "" );
/*
if (empty)
{
printf("%d%s",empty,"");
if (sq&&((sq%8)==0))
printf("/");
else
printf("");
}
else
{
//*s in the equivalent code tell the program to ignore the first int and
not to think that it is a string
if (sq&&((sq%8)==0))
printf("/");
else
printf("");
}
*/
empty = -printf( "%s", sq == (nn & 0x3F) ? "n" : sq == (nn
>> 6) ? "N" : "" );
}
empty++;
}
}
return 0;
}
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.