Skip to main content
added test snippet
Source Link
ETHproductions
  • 50.1k
  • 6
  • 94
  • 240

JavaScript (ES6), 52 46 bytes

f=([[c,...s],...a])=>s+a?c+f(s+s?[...a,s]:a):c

Takes input as an array of strings and outputs as a single string.

Test snippet

f=([[c,...s],...a])=>s+a?c+f(s+s?[...a,s]:a):c

g=a=>console.log("Input:",JSON.stringify(a),"Output:",JSON.stringify(f(a)))

g(["SIMPLE"])
g(["POLLS","EPEES"])
g(["LYES","APRONS"])
g(["ABCDE","a c","123 567"])
g(["\"\\n$?*",",(.)\" "]) // Backslash and quote are escaped, but in/output are correct

JavaScript (ES6), 52 46 bytes

f=([[c,...s],...a])=>s+a?c+f(s+s?[...a,s]:a):c

Takes input as an array of strings and outputs as a single string.

JavaScript (ES6), 52 46 bytes

f=([[c,...s],...a])=>s+a?c+f(s+s?[...a,s]:a):c

Takes input as an array of strings and outputs as a single string.

Test snippet

f=([[c,...s],...a])=>s+a?c+f(s+s?[...a,s]:a):c

g=a=>console.log("Input:",JSON.stringify(a),"Output:",JSON.stringify(f(a)))

g(["SIMPLE"])
g(["POLLS","EPEES"])
g(["LYES","APRONS"])
g(["ABCDE","a c","123 567"])
g(["\"\\n$?*",",(.)\" "]) // Backslash and quote are escaped, but in/output are correct

golfed 6 bytes
Source Link
ETHproductions
  • 50.1k
  • 6
  • 94
  • 240

JavaScript (ES6), 5252 46 bytes

f=([[c,...s],...a])=>s+a?c+f(a.concat(s+s?[s][...a,s]:[])a):c

Takes input as an array of strings and outputs as a single string.

JavaScript (ES6), 52 bytes

f=([[c,...s],...a])=>s+a?c+f(a.concat(s+s?[s]:[])):c

Takes input as an array of strings and outputs as a single string.

JavaScript (ES6), 52 46 bytes

f=([[c,...s],...a])=>s+a?c+f(s+s?[...a,s]:a):c

Takes input as an array of strings and outputs as a single string.

Source Link
ETHproductions
  • 50.1k
  • 6
  • 94
  • 240

JavaScript (ES6), 52 bytes

f=([[c,...s],...a])=>s+a?c+f(a.concat(s+s?[s]:[])):c

Takes input as an array of strings and outputs as a single string.