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.


4 Answers 4


Use // as a replacement

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


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


(61 bytes).


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!


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.


Use a character at the end of code to handle edge cases

When you have a piece of /// code that handles all but one case, then you can use a character at the edge of the code to handle the edge case.

Example: Unary add two numbers together unless the second number is 7, in which case just output the first number.

Code that handles all but the "second number is 7" case:

/+//<INPUT 1>+<INPUT 2>

By adding a * to the end of the code, we can handle the edge case by replacing +0000000* with nothing (it is necessary to include the + to makes sure the number is not greater than 7). Make sure to include code at the end before the input to clean it up.

/+0000000*///+///*//<INPUT 1>+<INPUT 2>*

Try it online!

For a "real-world" example, I used this trick on some of the "Jimmy" problems:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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