Jimmy needs your help!

Python 2, 70 67 bytes

lambda s:S('/',' ',S("\S.{5}","----- ",s+' '*5))
import re;S=re.sub

Try it online!

-3 bytes thanks to Kevin Cruijssen & Neil

Not the prettiest, not sure how to better handle those leftover slashes...

Unfortunately, we can't replace both ends of each platform with spaces using a single re.sub call, because in the case of 2 platforms being one space apart, the gap between them can't be matched more than once. A lookahead/lookbehind assertion won't help, because anything matched within those assertions doesn't get replaced.

Using a single re.sub reference:

Python 3.8 (pre-release), 78 bytes

lambda s:[s:=re.sub(".[^/ -].{5}"," ----- ",s+"  ",1)for c in s][-1]
import re

Try it online!

JavaScript (ES6),  56 55  54 bytes

s=>[...s+1e4].map(c=>(s--?s:s=c>{}&&5)?'-':' ').join``

Try it online!

Or 47 bytes if returning an array of characters is acceptable.

Python 3, 158 164 160 bytes

for i,c in enumerate(a):
  if c in"/o":
   r+=(a[i+5<len(a)and i+5or len(a)-1]=="o"and" "or"")+"----- "
  else:r+=" "

Try it online!

This is my first code golf answer, and I'm happy it's on a Jimmy question!


  • a=input();r="": Take in input and initialize a new string r.

  • for i,c in enumerate(a):: Enumerate over the input.

  • try:r[i] ... except:: See if r[i] exists - if not, process the except block.

  • if c in"/o":: Check if the current character is in Jimmy's first two body parts.

  • r+=(a[i+5<len(a)and i+5or len(a)-1]=="o"and" "or"")+"----- ": If so, add a new segment. Add a space before our new segment if another Jimmy head is present in five characters.

  • else:r+=" ": Otherwise, just add a space.

  • print(r): Print our final result.