Skip to main content
3 of 4
added 64 characters in body
emanresu A
  • 44.2k
  • 5
  • 100
  • 240

Vyxal, 95 91 bytes

@i|¥‛--oṘ:\irß›,;:£L‹(¥2wi:\-$r[@i;Q|Dh$t=[¥2ȯ‹|:«ƛẆ°«r[t«½∇«:1ǓĿ¥2ȯ+|t«½∇«:1ǔĿ¥2ȯ+‹]]£])@i

Try it Online!

The messiest mess I've ever made. Even I don't really understand it...

This goes through the first two characters of the string repeatedly, 'bubbling' -s to the end and eventually replacing double -s with nothing, then adding in ones if necessary.

Borrowed a trick from @ovs by checking if the result is a substring of -.

emanresu A
  • 44.2k
  • 5
  • 100
  • 240