Skip to main content
4 of 9
added 7 characters in body
calccrypto
  • 171
  • 1
  • 4

C 634 632 629 625 chars

#define F for(;i<4;i++)
#define B ;break;
N[8][2]={{-2,1},{-1,2},{1,2},{2,1},{-2,-1},{-2,-1},{1,-2},{2,-1}},S[4][2]={{1,0},{0,1},{-1,0},{0,-1}},D[4][2]={{-1,1},{-1,-1},{1,1},{1,-1}};
C(P,c,r){if((0<=c)&(c<8)&(0<r)&(r<9)){printf("%c%c%d ",P,c+'a',r);return 1;}return 0;}
M(int P,int x,int y,int m[2]){int c=m[0]+x,r=m[1]+y;if(C(P,c,r)) M(P,c,r,m);}
main(int argc,char*argv[]){
char*p=argv[1];
int x=p[1]-97,y=p[2]-48,i=0;
switch(*p){
case 75:F C(75,S[i][1]+x,S[i][0]+y),C(75,D[i][1]+x,D[i][0]+y)B
case 81:F M(81,x,y,D[i]),M(81,x,y,S[i])B
case 78:for(;i<8;i++)C(78,N[i][1]+x,N[i][0]+y)B
case 66:F M(66,x,y,D[i])B
case 82:F M(82,x,y,S[i])B}
}

Any suggestions on how to improve this? This is my first time submitting an answer.

calccrypto
  • 171
  • 1
  • 4