3 added 384 characters in body
source | link

C, 150148 150 151

p,x[2];main(){char c,d,l[99],*j="%d,%d,%c%s";scanf(j,x,x+1,&d,l);for(d=d%8%5;c=l[p++];d-=c%23)x[d&1]+=c%2*(1x[d&1]-=c%2*~-(d&2));printf(j,*x,x[1],"ENWS"[d&3],"");}

A tweak of @edc65's solution to use my ASCII value abuse approach, removing 14 bytes total.

Further abuse is achieved by mapping ENWS to 0,1,2,3 with d=d%8%5.Specifically:

  • d%8%5 maps the characters ENWS to 0,1,2,3 respectively
  • c%23 turns L into 7, M into 8 and R into 13. Because d (the direction variable) is always used mod 4, this effectively makes L add -1 mod 4, M add 0 mod 4, and R add 1 mod 4.
  • d&1 is 1 for NS and 0 for EW directions.
  • d&2 is 2 for WS and 0 for NE directions.
  • ~-(d&2) is 1 for WS and -1 for NE directions.
  • c%2 is 1 for M and 0 for LR.

C, 150 151

p,x[2];main(){char c,d,l[99],*j="%d,%d,%c%s";scanf(j,x,x+1,&d,l);for(d=d%8%5;c=l[p++];d-=c%23)x[d&1]+=c%2*(1-(d&2));printf(j,*x,x[1],"ENWS"[d&3],"");}

A tweak of @edc65's solution to use my ASCII value abuse approach, removing 14 bytes total.

Further abuse is achieved by mapping ENWS to 0,1,2,3 with d=d%8%5.

C, 148 150 151

p,x[2];main(){char c,d,l[99],*j="%d,%d,%c%s";scanf(j,x,x+1,&d,l);for(d=d%8%5;c=l[p++];d-=c%23)x[d&1]-=c%2*~-(d&2);printf(j,*x,x[1],"ENWS"[d&3],"");}

A tweak of @edc65's solution to use my ASCII value abuse approach.

Specifically:

  • d%8%5 maps the characters ENWS to 0,1,2,3 respectively
  • c%23 turns L into 7, M into 8 and R into 13. Because d (the direction variable) is always used mod 4, this effectively makes L add -1 mod 4, M add 0 mod 4, and R add 1 mod 4.
  • d&1 is 1 for NS and 0 for EW directions.
  • d&2 is 2 for WS and 0 for NE directions.
  • ~-(d&2) is 1 for WS and -1 for NE directions.
  • c%2 is 1 for M and 0 for LR.
2 remove one character
source | link

C, 151150 151

p,x[2];main(){char c,d,l[99],*j="%d,%d,%c%s";scanf(j,x,x+1,&d,l);for(d=d%8%5;c=l[p++];d-=c%4-1=c%23)x[d&1]+=c%2*(1-(d&2));printf(j,*x,x[1],"ENWS"[d&3],"");}

A tweak of @edc65's solution to use my ASCII value abuse approach, removing 1314 bytes total.

Further abuse is achieved by mapping ENWS to 0,1,2,3 with d=d%8%5.

C, 151

p,x[2];main(){char c,d,l[99],*j="%d,%d,%c%s";scanf(j,x,x+1,&d,l);for(d=d%8%5;c=l[p++];d-=c%4-1)x[d&1]+=c%2*(1-(d&2));printf(j,*x,x[1],"ENWS"[d&3],"");}

A tweak of @edc65's solution to use my ASCII value abuse approach, removing 13 bytes total.

Further abuse is achieved by mapping ENWS to 0,1,2,3 with d=d%8%5.

C, 150 151

p,x[2];main(){char c,d,l[99],*j="%d,%d,%c%s";scanf(j,x,x+1,&d,l);for(d=d%8%5;c=l[p++];d-=c%23)x[d&1]+=c%2*(1-(d&2));printf(j,*x,x[1],"ENWS"[d&3],"");}

A tweak of @edc65's solution to use my ASCII value abuse approach, removing 14 bytes total.

Further abuse is achieved by mapping ENWS to 0,1,2,3 with d=d%8%5.

1
source | link

C, 151

p,x[2];main(){char c,d,l[99],*j="%d,%d,%c%s";scanf(j,x,x+1,&d,l);for(d=d%8%5;c=l[p++];d-=c%4-1)x[d&1]+=c%2*(1-(d&2));printf(j,*x,x[1],"ENWS"[d&3],"");}

A tweak of @edc65's solution to use my ASCII value abuse approach, removing 13 bytes total.

Further abuse is achieved by mapping ENWS to 0,1,2,3 with d=d%8%5.