Skip to main content
3 of 3
added test snippet
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

ETHproductions
  • 50.1k
  • 6
  • 94
  • 240