Skip to main content
added 96 characters in body
Source Link
Justin Mariner
  • 5k
  • 1
  • 13
  • 18

JavaScript (ES6), 87 7878 76 bytes

-9 bytes thanks to @RickHitchcock.
-2 bytes thanks to @Neil.

f=(s,i=10)=>s.trim()&&s+`
`+f(s.replace(/./g,c=>parseInt(c,36)-i>0>i?c:" "),i+1)

Takes input as a string and returns without anywith one trailing whitespacenewline.

Test Cases

f=(s,i=10)=>s.trim()&&s+`
`+f(s.replace(/./g,c=>parseInt(c,36)-i>0>i?c:" "),i+1)

;["hello", "Programming Puzzles & Code Golf!", "~|[abc<0>cba]|~", "abcdefg0123456789"]
.forEach(s=>console.log(f(s)));
.as-console-wrapper{max-height:100%!important}

JavaScript (ES6), 87 78 bytes

-9 bytes thanks to @RickHitchcock.

f=(s,i=10)=>s.trim()&&s+`
`+f(s.replace(/./g,c=>parseInt(c,36)-i>0?c:" "),i+1)

Takes input as a string and returns without any trailing whitespace.

Test Cases

f=(s,i=10)=>s.trim()&&s+`
`+f(s.replace(/./g,c=>parseInt(c,36)-i>0?c:" "),i+1)

;["hello", "Programming Puzzles & Code Golf!", "~|[abc<0>cba]|~", "abcdefg0123456789"]
.forEach(s=>console.log(f(s)));
.as-console-wrapper{max-height:100%!important}

JavaScript (ES6), 87 78 76 bytes

-9 bytes thanks to @RickHitchcock.
-2 bytes thanks to @Neil.

f=(s,i=10)=>s.trim()&&s+`
`+f(s.replace(/./g,c=>parseInt(c,36)>i?c:" "),i+1)

Takes input as a string and returns with one trailing newline.

Test Cases

f=(s,i=10)=>s.trim()&&s+`
`+f(s.replace(/./g,c=>parseInt(c,36)>i?c:" "),i+1)

;["hello", "Programming Puzzles & Code Golf!", "~|[abc<0>cba]|~", "abcdefg0123456789"]
.forEach(s=>console.log(f(s)));
.as-console-wrapper{max-height:100%!important}

added 105 characters in body
Source Link
Justin Mariner
  • 5k
  • 1
  • 13
  • 18

JavaScript (ES6), 8787 78 bytes

-9 bytes thanks to @RickHitchcock.

f=(s,i=1,o=si=10)=>i>25?o=>s.trim():f&&s+`
`+f(s,i+1,o+`
`+s.replace(/./g,c=>parseInt(c,36)-9>ii>0?c:" "),i+1)

Takes input as a string and returns without any trailing whitespace.

Test Cases

f=(s,i=1,o=si=10)=>i>25?o=>s.trim():f&&s+`
`+f(s,i+1,o+`
`+s.replace(/./g,c=>parseInt(c,36)-9>ii>0?c:" "),i+1)

;["hello", "Programming Puzzles & Code Golf!", "~|[abc<0>cba]|~", "abcdefg0123456789"]
.forEach(s=>console.log(f(s)));
.as-console-wrapper{max-height:100%!important}

JavaScript (ES6), 87 bytes

f=(s,i=1,o=s)=>i>25?o.trim():f(s,i+1,o+`
`+s.replace(/./g,c=>parseInt(c,36)-9>i?c:" "))

Takes input as a string and returns without any trailing whitespace.

Test Cases

f=(s,i=1,o=s)=>i>25?o.trim():f(s,i+1,o+`
`+s.replace(/./g,c=>parseInt(c,36)-9>i?c:" "))

;["hello", "Programming Puzzles & Code Golf!", "~|[abc<0>cba]|~", "abcdefg0123456789"]
.forEach(s=>console.log(f(s)));
.as-console-wrapper{max-height:100%!important}

JavaScript (ES6), 87 78 bytes

-9 bytes thanks to @RickHitchcock.

f=(s,i=10)=>s.trim()&&s+`
`+f(s.replace(/./g,c=>parseInt(c,36)-i>0?c:" "),i+1)

Takes input as a string and returns without any trailing whitespace.

Test Cases

f=(s,i=10)=>s.trim()&&s+`
`+f(s.replace(/./g,c=>parseInt(c,36)-i>0?c:" "),i+1)

;["hello", "Programming Puzzles & Code Golf!", "~|[abc<0>cba]|~", "abcdefg0123456789"]
.forEach(s=>console.log(f(s)));
.as-console-wrapper{max-height:100%!important}

Source Link
Justin Mariner
  • 5k
  • 1
  • 13
  • 18

JavaScript (ES6), 87 bytes

f=(s,i=1,o=s)=>i>25?o.trim():f(s,i+1,o+`
`+s.replace(/./g,c=>parseInt(c,36)-9>i?c:" "))

Takes input as a string and returns without any trailing whitespace.

Test Cases

f=(s,i=1,o=s)=>i>25?o.trim():f(s,i+1,o+`
`+s.replace(/./g,c=>parseInt(c,36)-9>i?c:" "))

;["hello", "Programming Puzzles & Code Golf!", "~|[abc<0>cba]|~", "abcdefg0123456789"]
.forEach(s=>console.log(f(s)));
.as-console-wrapper{max-height:100%!important}