What general tips do you have for golfing in ///? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to /// (e.g. "remove unnecessary whitespace" is not an answer). Tips for itflabtijtslwi and Lines are on-topic and valid here as well.

Please post one tip per answer.


Use // as a replacement

When you define a bunch of replacements, e.g.:


(65 bytes). You can use // as a replacement:


(61 bytes).


Incomplete /// blocks are not printed

Note that this line of code


prints only Overflow - the part from /ignore onwards is not included in the output, because /// only prints things in its third slash-part.

Try the incomplete block online!

It is however still considered by the replacer: if we were to inject a slash in there, things change:


Try that online!

Output here is Overflowdoit, because replacing x with / made it valid syntax.


When expanding on a basis and printing intermediate results, incorporate previous iterations in future ones

That sounded a bit convoluted. What I mean might better be described using an actual answer. This challenge requires this specific output:

Steve Ballmer still does not know.
Steve Ballmer still does not know what he did.
Steve Ballmer still does not know what he did wrong.
Steve Ballmer still does not know what he did wrong with mobile.

One naive solution might be:

/1/Steve Ballmer still does not know//2/ what he did//3/ wrong//4/ with mobile./1.

Notice how the pattern 1, 12,123 ... is repeated? Well, not when you do this:

/1/Steve Ballmer still does not know//2/1 what he did//3/2 wrong//4/3 with mobile/1.

Once again, thanks go to Martin Ender for pointing this out!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.