11
\$\begingroup\$

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.

\$\endgroup\$
4
\$\begingroup\$

Use // as a replacement

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

/a/b//c/d//e/f//g/h//i/j//k/l//m/n//o/p//q/r//s/t//u/v//w/x//y/z/

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

/~/\/\///a/b~c/d~e/f~g/h~i/j~k/l~m/n~o/p~q/r~s/t~u/v~w/x~y/z/

(61 bytes).

\$\endgroup\$
4
\$\begingroup\$

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.
12.
123.
1234

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.
2.
3.
4.

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

\$\endgroup\$
3
\$\begingroup\$

Incomplete /// blocks are not printed

Note that this line of code

/Stack/Overflow//x/\//Stack/ignore/DoItyignore

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:

/Stack/Overflow//x/\//Stack/ignore/doitxignore

Try that online!

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

\$\endgroup\$

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.