Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Chess programming puzzle

Author: Scott Gasch

Date: 12:29:28 02/22/05

Go up one level in this thread


On February 22, 2005 at 15:16:54, Dann Corbit wrote:

>On February 22, 2005 at 15:13:05, Dann Corbit wrote:
>
>>On February 22, 2005 at 15:06:32, Uri Blass wrote:
>>>On February 22, 2005 at 14:45:07, Dann Corbit wrote:
>>[snip]
>>>>Exactly the same, only completely different:
>>>>
>>>>#include<stdio.h>
>>>>char q0??(9??)=??<'0','1','2','3','4','5','6','7','8'??>;int main(void
>>>>)??<int q1,q2,q3,q4;for(q1=0;q1<64;q1++)??<for(q2=0;q2<64;q2++)??<if(
>>>>q1==q2)continue;for(q4=0,q3=0;q3<64;q3++)??<if(q3&#38;&#38;(q3&#38;7)==0)putchar(
>>>>'/');if(q3==q1||q3==q2)??<if(q4!=0)??<putchar(q0??(q4??));q4=0;??>
>>>>putchar(q3==q1?'N':'n');??>else??<q4++;if((q3&#38;7)==7)??<putchar(q0??(q4
>>>>??));q4=0;??>??>??>puts("\40\55\40\55\40\60\40\61");??>??>return 0;??>
>>>
>>>
>>>I find that it works but unfortunately I do not understand your code.
>>>I never use ?? in code that I write and I do not know what it means.
>>
>>It is Tim's algorithm, deliberately obfuscated.  I used trigraphs and some other
>>icky tricks to make the exact same thing hard to read.
>>
>>>Tim's code is the shortest code that I can understand.
>>
>>That's the intent.  It makes a simple algorithm into a C puzzle of another kind.
>>
>>So I turned a puzzle into another kind of puzzle.
>>
>>If you run it through your compiler's C preprocessor then you will see that it
>>looks almost exactly like Tim's code.
>
>This is the version that I used before I mangled it:
>
>#include <stdio.h>
>char            counts[9] = {'0', '1', '2', '3', '4', '5', '6', '7', '8'};
>int             main(void)
>{
>    int             i,
>                    j,
>                    k,
>                    cnt;
>    for (i = 0; i < 64; i++) {
>        for (j = 0; j < 64; j++) {
>            if (i == j)
>                continue;
>            for (cnt = 0, k = 0; k < 64; k++) {
>                if (k && (k & 7) == 0)
>                    putchar('/');
>                if (k == i || k == j) {
>                    if (cnt != 0) {
>                        putchar(counts[cnt]);
>                        cnt = 0;
>                    }
>                    putchar(k == i ? 'N' : 'n');
>                } else {
>                    cnt++;
>                    if ((k & 7) == 7) {
>                        putchar(counts[cnt]);
>                        cnt = 0;
>                    }
>                }
>            }
>            puts(" - - 0 1");
>        }
>    }
>    return 0;
>}

Not to be the jackass who runs around compiling people's solutions but I'm the
jackass who runs around compiling people's solutions:

[ scott@wannabe:~/tmp ] % g++34 -O -S zzz.c ; wc -l zzz.s
     238 zzz.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.