Skip to main content
4 of 6
deleted 6 characters in body
Steadybox
  • 16.5k
  • 5
  • 41
  • 84

C, 62 bytes

f(char*s){for(;*s;)*++s-32&&*s||(s[-1]^=s[-2]^=s[-1]^=s[-2]);}

Try it online!

Recursive version (62 bytes):

f(char*s){*++s-32&&*s||(s[-1]^=s[-2]^=s[-1]^=s[-2]);*s&&f(s);}

Try it online!

Steadybox
  • 16.5k
  • 5
  • 41
  • 84