Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: 8 queens problem meets obfuscated C programming

Author: Tony Werten

Date: 04:49:20 04/10/03

Go up one level in this thread


On April 10, 2003 at 07:44:49, Uri Blass wrote:

>On April 10, 2003 at 07:11:43, Albert Bertilsson wrote:
>
>>On April 10, 2003 at 06:35:07, Uri Blass wrote:
>>
>>>On April 09, 2003 at 23:56:54, Russell Reagan wrote:
>>>
>>>>So...who wants to explain how this works? I don't know how it works, but it
>>>>finds all of the solutions to the 8 queens problem.
>>>>
>>>>#include <stdio.h>
>>>>int v,i,j,k,l,s,a[99];
>>>>void main(void){
>>>>for(s=8;*a-s;v=a[j*=v]-a[i],k=i<s,j+=(v=j<s&#38;&#38;(!k&#38;&#38;!!printf(2+"\n\n%c"-(!l<<!j),"
>>>>#Q"[l^v?(l^j)&1:2])&&++l||a[i]<s&#38;&#38;v&#38;&#38;v-i+j&#38;&#38;v+i-j))&#38;&#38;!(l%=s),v||(i==j?a[i+=k]=0:++a[i])>=s*k&&++a[--i]);
>>>> printf("\n\n");
>>>>}
>>>
>>>I do not understand this code because my C knowledge is not enough.
>>>
>>>What is *a-s
>>>
>>>I understand that j*=v is j=j*v butI do not understand the meaning when * is at
>>>the beginning of the command.
>>>
>>>I never used it.
>>>
>>>Uri
>>The *a means "content of a". a is here regarded as a pointer to an integer, thus
>>it can be interpreted as the number at the adress that a points to.
>>
>>*a is the same as a[0], guess this later is more commonly used.
>>
>>/Regards Albert
>
>I understand now.
>
>I have pointers but I do not use them in that way.
>I also do not have numbers as conditions
>
>I think that it is a bad writing and it is better to write
>(a[0]-s)!=0) because it is more clear and I assume that there is no difference
>in speed because the compiler translate it to the same code.
>
>
>I guess that the code starts
>
>s=8
>a[0]-s!=0 so we continue to do the loop

I think it just a difficult way of saying a[0]!=8 since I don't think s is
changing.

Tony

>v=A[j*v]-A[i]=0-0=0
>j=j*v=0
>
>k=i<s
>Again I do not use it without ()
>Does it mean k=(i<s)(I see no meaning for (k=i)<s
>
>I think the way to try to understand it is simply to follow all the varaibles
>manually in the first steps but I am not going to do it now.
>
>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.