Tweeted twitter.com/StackCodeGolf/status/718222265788272645
4 added 101 characters in body
source | link
  • Input can be a multiline string or an array of strings.
  • Each line of the input will be padded with spaces to form a rectangular grid.
  • Characters in the string snake can only connect to adjacent characters above, below, left or right of them (just like in the game Snake). They cannot go diagonal.
  • The snake characters will never be adjacent to another part of the snake, only the connected characters.
  • The first character of the string is the end character with the shortest Manhattan distance from the top-left corner of the input grid (i.e. the minimum number of moves it would take for a snake to go directly from the end character to the top-left corner). Both ends will never have the same distance.
  • The string can contain any ASCII character between code points 33 and 126 inclusive (no spaces or newlines).
  • The string will be between 2 and 100 characters long.
  • Shortest code in bytes wins.
  • Input can be a multiline string or an array of strings.
  • Each line of the input will be padded with spaces to form a rectangular grid.
  • Characters in the string snake can only connect to adjacent characters above, below, left or right of them (just like in the game Snake). They cannot go diagonal.
  • The first character of the string is the end character with the shortest Manhattan distance from the top-left corner of the input grid (i.e. the minimum number of moves it would take for a snake to go directly from the end character to the top-left corner). Both ends will never have the same distance.
  • The string can contain any ASCII character between code points 33 and 126 inclusive (no spaces or newlines).
  • The string will be between 2 and 100 characters long.
  • Shortest code in bytes wins.
  • Input can be a multiline string or an array of strings.
  • Each line of the input will be padded with spaces to form a rectangular grid.
  • Characters in the snake can only connect to adjacent characters above, below, left or right of them (just like in the game Snake). They cannot go diagonal.
  • The snake characters will never be adjacent to another part of the snake, only the connected characters.
  • The first character of the string is the end character with the shortest Manhattan distance from the top-left corner of the input grid (i.e. the minimum number of moves it would take for a snake to go directly from the end character to the top-left corner). Both ends will never have the same distance.
  • The string can contain any ASCII character between code points 33 and 126 inclusive (no spaces or newlines).
  • The string will be between 2 and 100 characters long.
  • Shortest code in bytes wins.
3 added 5 characters in body
source | link

A regular string looks like this:

Hello,IAmAStringSnake!

And a string snake looks something like this:

Hel         
  l      rin
  o,IAmASt g
           S
       !ekan

Your Task

String snakes are dangerous, so you must make a program that takes a string snake as input and outputs it as a regular string.

Specifications

  • Input can be a multiline string or an array of strings.
  • Each line of the input will be padded with spaces to form a rectangular grid.
  • Characters in the string snake can only connect to adjacent characters above, below, left or right of them (just like in the game Snake). They cannot go diagonal.
  • The first character of the string is the end character with the shortest Manhattan distance from the top-left corner of the input grid (thei.e. the minimum number of moves it would take for a snake to go directly from the end character to the top-left corner). Both ends will never have the same distance.
  • The string can contain any ASCII character between code points 33 and 126 inclusive (no spaces or newlines).
  • The string will be between 2 and 100 characters long.
  • Shortest code in bytes wins.

Test Cases

(Input grid, followed by the output string)

Hel         
  l      rin
  o,IAmASt g
           S
       !ekan

Hello,IAmAStringSnake!

----------

Python

Python

----------

P  ngPu  Code 
r  i  z  d  G 
o  m  z  n  o 
gram  lesA  lf

ProgrammingPuzzlesAndCodeGolf

----------

   ~ zyx tsr XWVUTSR
   }|{ wvu q Y     Q
!          p Z `ab P
"#$ 6789:; o [ _ c O
  % 5    < n \]^ d N
('& 432  = m     e M
)     1  > lkjihgf L
*+,-./0  ?         K
         @ABCDEFGHIJ

!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

----------

  tSyrep    
  r    p    
  in Sli    
   g    Sile
   Snakes  n
Ser      ylt
a eh   ilS  
fe w   t    
   emo h    
     Sre    

SlipperyStringSnakesSilentlySlitherSomewhereSafe

A regular string looks like this:

Hello,IAmAStringSnake!

And a string snake looks something like this:

Hel         
  l      rin
  o,IAmASt g
           S
       !ekan

Your Task

String snakes are dangerous, so you must make a program that takes a string snake as input and outputs it as a regular string.

Specifications

  • Input can be a multiline string or an array of strings.
  • Each line of the input will be padded with spaces to form a rectangular grid.
  • Characters in the string snake can only connect to adjacent characters above, below, left or right of them (just like in the game Snake). They cannot go diagonal.
  • The first character of the string is the end character with the shortest Manhattan distance from the top-left corner of the input grid (the minimum number of moves it would take for a snake to go directly from the end character to the top-left corner). Both ends will never have the same distance.
  • The string can contain any ASCII character between code points 33 and 126 inclusive (no spaces or newlines).
  • The string will be between 2 and 100 characters long.
  • Shortest code in bytes wins.

Test Cases

(Input grid, followed by the output string)

Hel         
  l      rin
  o,IAmASt g
           S
       !ekan

Hello,IAmAStringSnake!

----------

Python

Python

----------

P  ngPu  Code 
r  i  z  d  G 
o  m  z  n  o 
gram  lesA  lf

ProgrammingPuzzlesAndCodeGolf

----------

   ~ zyx tsr XWVUTSR
   }|{ wvu q Y     Q
!          p Z `ab P
"#$ 6789:; o [ _ c O
  % 5    < n \]^ d N
('& 432  = m     e M
)     1  > lkjihgf L
*+,-./0  ?         K
         @ABCDEFGHIJ

!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

----------

  tSyrep    
  r    p    
  in Sli    
   g    Sile
   Snakes  n
Ser      ylt
a eh   ilS  
fe w   t    
   emo h    
     Sre    

SlipperyStringSnakesSilentlySlitherSomewhereSafe

A regular string looks like this:

Hello,IAmAStringSnake!

And a string snake looks something like this:

Hel         
  l      rin
  o,IAmASt g
           S
       !ekan

Your Task

String snakes are dangerous, so you must make a program that takes a string snake as input and outputs it as a regular string.

Specifications

  • Input can be a multiline string or an array of strings.
  • Each line of the input will be padded with spaces to form a rectangular grid.
  • Characters in the string snake can only connect to adjacent characters above, below, left or right of them (just like in the game Snake). They cannot go diagonal.
  • The first character of the string is the end character with the shortest Manhattan distance from the top-left corner of the input grid (i.e. the minimum number of moves it would take for a snake to go directly from the end character to the top-left corner). Both ends will never have the same distance.
  • The string can contain any ASCII character between code points 33 and 126 inclusive (no spaces or newlines).
  • The string will be between 2 and 100 characters long.
  • Shortest code in bytes wins.

Test Cases

(Input grid, followed by the output string)

Hel         
  l      rin
  o,IAmASt g
           S
       !ekan

Hello,IAmAStringSnake!

----------

Python

Python

----------

P  ngPu  Code 
r  i  z  d  G 
o  m  z  n  o 
gram  lesA  lf

ProgrammingPuzzlesAndCodeGolf

----------

   ~ zyx tsr XWVUTSR
   }|{ wvu q Y     Q
!          p Z `ab P
"#$ 6789:; o [ _ c O
  % 5    < n \]^ d N
('& 432  = m     e M
)     1  > lkjihgf L
*+,-./0  ?         K
         @ABCDEFGHIJ

!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

----------

  tSyrep    
  r    p    
  in Sli    
   g    Sile
   Snakes  n
Ser      ylt
a eh   ilS  
fe w   t    
   emo h    
     Sre    

SlipperyStringSnakesSilentlySlitherSomewhereSafe
2 edited title
| link

Desnakify De-Snakify a String

1
source | link