Skip to main content
deleted 1 character in body
Source Link
G. Sliepen
  • 1.3k
  • 9
  • 17

C (gcc), 165 164 140 138 137 136135 bytes

#define W(b,c);for(;X b;putchar(c)) x,y,X;f(s,w)char*s;{x=y=0 W(=*s=*s++,33){X=97X-*s++W=97 W(%w<x,8276)x--W(%w>x,7682)x++W(/w<y,6885)y--W(/w>y,8568)y++;}} 

Try it online!Try it online!

1 25 27 28 byte shaved off thanks to ceilingcat! Ungolfed:

int x, y, X, Y; f(char *s, int w) { x = 0; // Starting position is (0, 0) y = 0; while (*s) { // For each character X = (*s - 'a') % w; // Get its x coordinate Y = (*s - 'a') / w; // Get its y coordinate s++; while (X > x) putchar('R'), x++; // Print R for each step we need to move right while (X < x) putchar('L'), x--; // ...et cetera... while (Y > y) putchar('D'), y++; while (Y < y) putchar('U'), y--; putchar('!'); // We are there, print ! } } 

C (gcc), 165 164 140 138 137 136 bytes

#define W(b,c);for(;X b;putchar(c)) x,y,X;f(s,w)char*s;{x=y=0 W(=*s,33){X=97-*s++W(%w<x,82)x--W(%w>x,76)x++W(/w<y,68)y--W(/w>y,85)y++;}} 

Try it online!

1 25 27 28 byte shaved off thanks to ceilingcat! Ungolfed:

int x, y, X, Y; f(char *s, int w) { x = 0; // Starting position is (0, 0) y = 0; while (*s) { // For each character X = (*s - 'a') % w; // Get its x coordinate Y = (*s - 'a') / w; // Get its y coordinate s++; while (X > x) putchar('R'), x++; // Print R for each step we need to move right while (X < x) putchar('L'), x--; // ...et cetera... while (Y > y) putchar('D'), y++; while (Y < y) putchar('U'), y--; putchar('!'); // We are there, print ! } } 

C (gcc), 165 164 140 138 137 135 bytes

#define W(b,c);for(;X b;putchar(c)) x,y,X;f(s,w)char*s;{x=y=0 W(=*s++,33){X-=97 W(%w<x,76)x--W(%w>x,82)x++W(/w<y,85)y--W(/w>y,68)y++;}} 

Try it online!

1 25 27 28 byte shaved off thanks to ceilingcat! Ungolfed:

int x, y, X, Y; f(char *s, int w) { x = 0; // Starting position is (0, 0) y = 0; while (*s) { // For each character X = (*s - 'a') % w; // Get its x coordinate Y = (*s - 'a') / w; // Get its y coordinate s++; while (X > x) putchar('R'), x++; // Print R for each step we need to move right while (X < x) putchar('L'), x--; // ...et cetera... while (Y > y) putchar('D'), y++; while (Y < y) putchar('U'), y--; putchar('!'); // We are there, print ! } } 
added 18 characters in body
Source Link
G. Sliepen
  • 1.3k
  • 9
  • 17

C (gcc), 165 164 140 138138 137 136 bytes

#define W(b,c);for(;b;putchar;X b;putchar(c)) x,y,X;f(s,w)char*s;{x=y=0 W(*s=*s,33){X=*s++X=97-97 W*s++W(X%w>x%w<x,82)x++W(X%w<x,76)x--W(X/w>y%w>x,6876)y++Wx++W(X/w<y,8568)y--;W(/w>y,85)y++;}} 

Try it online!Try it online!

1 25 2727 28 byte shaved off thanks to ceilingcat! Ungolfed:

int x, y, X, Y; f(char *s, int w) { x = 0; // Starting position is (0, 0) y = 0; while (*s) { // For each character X = (*s - 'a') % w; // Get its x coordinate Y = (*s - 'a') / w; // Get its y coordinate s++; while (X > x) putchar('R'), x++; // Print R for each step we need to move right while (X < x) putchar('L'), x--; // ...et cetera... while (Y > y) putchar('D'), y++; while (Y < y) putchar('U'), y--; putchar('!'); // We are there, print ! } } 

C (gcc), 165 164 140 138 bytes

#define W(b,c);for(;b;putchar(c)) x,y,X;f(s,w)char*s;{x=y=0 W(*s,33){X=*s++-97 W(X%w>x,82)x++W(X%w<x,76)x--W(X/w>y,68)y++W(X/w<y,85)y--;}} 

Try it online!

1 25 27 byte shaved off thanks to ceilingcat! Ungolfed:

int x, y, X, Y; f(char *s, int w) { x = 0; // Starting position is (0, 0) y = 0; while (*s) { // For each character X = (*s - 'a') % w; // Get its x coordinate Y = (*s - 'a') / w; // Get its y coordinate s++; while (X > x) putchar('R'), x++; // Print R for each step we need to move right while (X < x) putchar('L'), x--; // ...et cetera... while (Y > y) putchar('D'), y++; while (Y < y) putchar('U'), y--; putchar('!'); // We are there, print ! } } 

C (gcc), 165 164 140 138 137 136 bytes

#define W(b,c);for(;X b;putchar(c)) x,y,X;f(s,w)char*s;{x=y=0 W(=*s,33){X=97-*s++W(%w<x,82)x--W(%w>x,76)x++W(/w<y,68)y--W(/w>y,85)y++;}} 

Try it online!

1 25 27 28 byte shaved off thanks to ceilingcat! Ungolfed:

int x, y, X, Y; f(char *s, int w) { x = 0; // Starting position is (0, 0) y = 0; while (*s) { // For each character X = (*s - 'a') % w; // Get its x coordinate Y = (*s - 'a') / w; // Get its y coordinate s++; while (X > x) putchar('R'), x++; // Print R for each step we need to move right while (X < x) putchar('L'), x--; // ...et cetera... while (Y > y) putchar('D'), y++; while (Y < y) putchar('U'), y--; putchar('!'); // We are there, print ! } } 
added 19 characters in body
Source Link
G. Sliepen
  • 1.3k
  • 9
  • 17

C (gcc), 165 164 140140 138 bytes

#define W(b,c)for;for(;b;putchar(c)) x,y,X;f(s,w)char*s;{x=y=0;Wx=y=0 W(*s,33){X=*s++-97;W97 W(X%w>x,82)x++;Wx++W(X%w<x,76)x--;WW(X/w>y,68)y++;Wy++W(X/w<y,85)y--;}} 

Try it online!Try it online!

1 2525 27 byte shaved off thanks to ceilingcat! Ungolfed:

int x, y, X, Y; f(char *s, int w) { x = 0; // Starting position is (0, 0) y = 0; while (*s) { // For each character X = (*s - 'a') % w; // Get its x coordinate Y = (*s - 'a') / w; // Get its y coordinate s++; while (X > x) putchar('R'), x++; // Print R for each step we need to move right while (X < x) putchar('L'), x--; // ...et cetera... while (Y > y) putchar('D'), y++; while (Y < y) putchar('U'), y--; putchar('!'); // We are there, print ! } } 

C (gcc), 165 164 140 bytes

#define W(b,c)for(;b;putchar(c)) x,y,X;f(s,w)char*s;{x=y=0;W(*s,33){X=*s++-97;W(X%w>x,82)x++;W(X%w<x,76)x--;W(X/w>y,68)y++;W(X/w<y,85)y--;}} 

Try it online!

1 25 byte shaved off thanks to ceilingcat! Ungolfed:

int x, y, X, Y; f(char *s, int w) { x = 0; // Starting position is (0, 0) y = 0; while (*s) { // For each character X = (*s - 'a') % w; // Get its x coordinate Y = (*s - 'a') / w; // Get its y coordinate s++; while (X > x) putchar('R'), x++; // Print R for each step we need to move right while (X < x) putchar('L'), x--; // ...et cetera... while (Y > y) putchar('D'), y++; while (Y < y) putchar('U'), y--; putchar('!'); // We are there, print ! } } 

C (gcc), 165 164 140 138 bytes

#define W(b,c);for(;b;putchar(c)) x,y,X;f(s,w)char*s;{x=y=0 W(*s,33){X=*s++-97 W(X%w>x,82)x++W(X%w<x,76)x--W(X/w>y,68)y++W(X/w<y,85)y--;}} 

Try it online!

1 25 27 byte shaved off thanks to ceilingcat! Ungolfed:

int x, y, X, Y; f(char *s, int w) { x = 0; // Starting position is (0, 0) y = 0; while (*s) { // For each character X = (*s - 'a') % w; // Get its x coordinate Y = (*s - 'a') / w; // Get its y coordinate s++; while (X > x) putchar('R'), x++; // Print R for each step we need to move right while (X < x) putchar('L'), x--; // ...et cetera... while (Y > y) putchar('D'), y++; while (Y < y) putchar('U'), y--; putchar('!'); // We are there, print ! } } 
deleted 16 characters in body
Source Link
G. Sliepen
  • 1.3k
  • 9
  • 17
Loading
added 46 characters in body
Source Link
G. Sliepen
  • 1.3k
  • 9
  • 17
Loading
Source Link
G. Sliepen
  • 1.3k
  • 9
  • 17
Loading