- Code: Select all
(X-4)*(X-4)+(Y-3.5)*(Y-3.5))
to:
- Code: Select all
X*X-8*X+16+Y*Y-7*Y+12.25
will take out 3 characters.
Moderator: Andres Valverde
(X-4)*(X-4)+(Y-3.5)*(Y-3.5))
X*X-8*X+16+Y*Y-7*Y+12.25
Kerwin wrote:I just realized that you would be able to save another 10 characters by doing a #define on "if" the way you do with "while" and "for". "I" would be a good replacement. You just need to rename the current "I" to something like "P". I could also be done for "return", but you would only be saving 1 character.
#define F(P,S,N) for(P=S;P<N;P++)
#define W(A) while(A)
#define I if(
#define R return
int V=112,M=136,P=8e3,C=799,X,Y,Q,N,
d[]={-16,-15,-17,0,1,16,0,1,16,15,17,0,14,18,31,33,0,
1,1,3,-1,3,5,9,
7,-1,11,6,8,3,6},
b[128]={6,3,5,7,4,5,3,6};
char n[]=".?pnkbrq?P?NKBRQ";
D(k,q,l,e,x,n)
int k,q,l,e,x,n;
{
int i=0,j,t,p,u,r,y,m=n>1|q>e?q:e,v,h,z;
N++;
do{
u=b[i];
I u&k)
{r=p=u&7;
j=d[p+23];
W(r=p>2&r<0?-r:-d[++j])
{y=i;
do
{y+=r;I y&M)break;
t=b[y];I t&k|p<3&!(r&7)-!t)break;
v=99*d[t&7|16];
I v<0)m=P;
I m>=l)R m;
I h=n-(y!=x))
{I p<6)v+=b[i+8]-b[y+8];
I p==4)v+=9*(e>C?!((x^y)&68):-3);
b[i]=0;b[y]=u;
I p<3)
{v-=9*((i-2&M||b[i-2]!=u)+(i+2&M||b[i+2]!=u)-1);
I y+r+1&128){b[y]|=7;v+=C;}
}
v=-D(24-k,-l,-m,z=-e-v,y,h);
v-=v>P/3;
I x==9){I v+P&&i==X&y==Y){Q=z;R l;}v=m;}
b[i]=u;b[y]=t;
I v>m){m=v;I x&8){X=i;Y=y;}}
}
t+=p<5;I p<3&&6*k+(y&V)==128)t--;
}W(!t);
}
}
}W(i=i+9&~M);
R m+P?m:-D(24-k,-P,P,0,x,1)/2;
}
main()
{
int k=8,*p,c[9],d;
F(X,0,8)
{b[X+V]=(b[X]+=16)-8;b[X+16]=18;b[X+96]=9;
F(Y,0,8)b[16*Y+X+8]=X*X-8*X+Y*Y-7*Y;
}
W(1)
{F(N,0,121)putchar(N&8&&(N+=7)?10:n[b[N]&15]);
p=c;W((*p++=getchar())>10);
I *c-10){X=*c-16*c[1]+C;Y=c[2]-16*c[3]+C;}else
{d=6;N=0;W(N<1e6)D(k,-P,P,Q,8,d++);}
I D(k,-P,P,Q,9,2)==P)k^=24;
}
}
#define F(P,S,N) for(P=S;P<N;P++)
#define W while(
#define I if(
#define R return
int V=112,M=136,P=8e3,C=799,X,Y,Q,N,
d[]={-16,-15,-17,0,1,16,0,1,16,15,17,0,14,18,31,33,0,
1,1,3,-1,3,5,9,
7,-1,11,6,8,3,6},
b[128]={6,3,5,7,4,5,3,6};
char n[]=".?pnkbrq?P?NKBRQ";
D(k,q,l,e,x,n)
int k,q,l,e,x,n;
{
int i=0,j,t,p,u,r,y,m=n>1|q>e?q:e,v,h,z;
N++;
do{
u=b[i];
I u&k)
{r=p=u&7;
j=d[p+23];
W r=p>2&r<0?-r:-d[++j])
{y=i;
do
{y+=r;I y&M)break;
t=b[y];I t&k|p<3&!(r&7)-!t)break;
v=99*d[t&7|16];
I v<0)m=P;
I m>=l)R m;
I h=n-(y!=x))
{I p<6)v+=b[i+8]-b[y+8];
I p==4)v+=9*(e>C?!((x^y)&68):-3);
b[i]=0;b[y]=u;
I p<3)
{v-=9*((i-2&M||b[i-2]!=u)+(i+2&M||b[i+2]!=u)-1);
I y+r+1&128){b[y]|=7;v+=C;}
}
v=-D(24-k,-l,-m,z=-e-v,y,h);
v-=v>P/3;
I x==9){I v+P&&i==X&y==Y){Q=z;R l;}v=m;}
b[i]=u;b[y]=t;
I v>m){m=v;I x&8){X=i;Y=y;}}
}
t+=p<5;I p<3&&6*k+(y&V)==128)t--;
}W !t);
}
}
}W i=i+9&~M);
R m+P?m:-D(24-k,-P,P,0,x,1)/2;
}
main()
{
int k=8,*p,c[9],d;
F(X,0,8)
{b[X+V]=(b[X]+=16)-8;b[X+16]=18;b[X+96]=9;
F(Y,0,8)b[16*Y+X+8]=X*X-8*X+Y*Y-7*Y;
}
W 1)
{F(N,0,121)putchar(N&8&&(N+=7)?10:n[b[N]&15]);
p=c;W (*p++=getchar())>10);
I *c-10){X=*c-16*c[1]+C;Y=c[2]-16*c[3]+C;}else
{d=6;N=0;W N<1e6)D(k,-P,P,Q,8,d++);}
I D(k,-P,P,Q,9,2)==P)k^=24;
}
}
int V=112,M=136,P=8e3,C=799,X,Y,Q,N,
V=112,M=136,P=8e3,C=799,X,Y,Q,N,
D(k,q,l,e,x,n)
int k,q,l,e,x,n;
D(k,q,l,e,x,n)
char n[]=".?pnkbrq?P?NKBRQ";
char *n=".?pnkbrq?P?NKBRQ";
main()
{
int k=8,*p,c[9],d;
V=112,M=136,P=8e3,C=799,X,Y,Q,N,
d[]={-16,-15,-17,0,1,16,0,1,16,15,17,0,14,18,31,33,0,
1,1,3,-1,3,5,9,
7,-1,11,6,8,3,6},
k=8,*p,c[9],e;
^
...
main()
...
{e=6;N=0;W N<1e6)D(k,-P,P,Q,8,e++);}
^ ^
main()
{
int k=8,*p,c[9],d;
main(d)
{
int k=8,*p,c[9];
#define F(P,S,N) for(P=S;P<N;P++)
#define W while(
#define I if(
#define R return
V=112,M=136,P=8e3,C=799,X,Y,Q,N,s=16,
b[128]={6,3,5,7,4,5,3,6};
char *n=".?pnkbrq?P?NKBRQ",
*d="$%#45D45DCE4BFSU4557379=;3?:<7:";
D(k,q,l,e,x,n)
{
int i=0,j,t,p,u,r,y,m=n>1|q>e?q:e,v,h,z;
N++;
do{
u=b[i];
I u&k)
{r=p=u&7;
j=d[p+23]-52;
W r=p>2&r<0?-r:-d[++j]+52)
{y=i;
do
{y+=r;I y&M)break;
t=b[y];I t&k|p<3&!(r&7)-!t)break;
v=99*(d[t&7|s]-52);
I v<0)m=P;
I m>=l)R m;
I h=n-(y!=x))
{I p<6)v+=b[i+8]-b[y+8];
I p==4)v+=9*(e>C?!((x^y)&68):-3);
b[i]=0;b[y]=u;
I p<3)
{v-=9*((i-2&M||b[i-2]!=u)+(i+2&M||b[i+2]!=u)-1);
I y+r+1&128){b[y]|=7;v+=C;}
}
v=-D(24-k,-l,-m,z=-e-v,y,h);
v-=v>P/3;
I x==9){I v+P&&i==X&y==Y){Q=z;R l;}v=m;}
b[i]=u;b[y]=t;
I v>m){m=v;I x&8){X=i;Y=y;}}
}
t+=p<5;I p<3&&6*k+(y&V)==128)t--;
}W !t);
}
}
}W i=i+9&~M);
R m+P?m:-D(24-k,-P,P,0,x,1)/2;
}
k=8,*p,c[9];
main(e)
{
F(X,0,8)
{b[X+V]=(b[X]+=s)-8;b[X+s]=18;b[X+96]=9;
F(Y,0,8)b[s*Y+X+8]=X*X-8*X+Y*Y-7*Y;
}
W 1)
{F(N,0,121)putchar(N&8&&(N+=7)?10:n[b[N]&15]);
p=c;W (*p++=getchar())>10);
I *c-10){X=*c-s*c[1]+C;Y=c[2]-s*c[3]+C;}else
{e=6;N=0;W N<1e6)D(k,-P,P,Q,8,e++);}
I D(k,-P,P,Q,9,2)==P)k^=24;
}
}
#define F(P,S,N) for(P=S;P<N;P++)
^
#define F(P,S,N)for(P=S;P<N;P++)
Kerwin wrote:Since every character counts in umax, changing:
- Code: Select all
(X-4)*(X-4)+(Y-3.5)*(Y-3.5))
to:
- Code: Select all
X*X-8*X+16+Y*Y-7*Y+12.25
will take out 3 characters.
Return to Programming and Technical Discussions
Users browsing this forum: No registered users and 28 guests