Skip to main content
11 of 18
Now even shorter

C 367

Edits:

  • Thanks to @algorithmshark for lots of help making the original shorter
  • Thanks to @ceilingcat for some very nice pieces of golfing - now even shorter

Here is the code:

#import<bits/stdc++.h>
#define P o[i])
#define N(x)P;else if(n<x)(P==92?
#define O (o[++i]):(P==47?n++:
char p[99],*q=p,r[99],*s=r;int i,t;main(int n,char**m){for(std::string o=m[1];i<=o.size();++i){if(!N(3)putchar O putchar(N(4)*q++=O(*q++=N(5)*s++=O(*s++=P;if(n>4){for(;~(t=o.find(p,i+1));)o=o.substr(0,t)+r+o.substr(t+strlen(p));bzero(q=p,99);bzero(s=r,99);n=2;}}}

Try it online!