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

C 634 632 629 625 588 chars

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

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

calccrypto
  • 171
  • 1
  • 4