///, 6634204313747905 > 958
From
string/.~~~~~/0
to
string/0 /.~
This relies on the program not being required to terminate. I started from a core-range of 958 much like the other solutions, from
string//
to
string//~~~~~~~~
However, in this case, //
is not a comment. In /// everything that's not a slash is just printed (hence this always prints string
before doing anything else). A slash then starts a substitution pattern of the form /pattern/replacement/
. If only one or two /
are found, then the program simply terminates. However, the above range obviously also includes strings with three or more slashes. The trick here is that the pattern to be searched for is empty, and substitutions are performed iteratively until the pattern cannot be found any more. Since the empty string can always be found, this substitution never terminates, and hence the program never gets around to print anything after the initial string
.
But since this doesn't rely on //
being a comment, we can actually go a bit further! E.g. the previous and next string around this range, respectively, are:
string/.~~~~~~~~
string/0
These still don't contain a full substitution instruction so they also only print string
and then terminate. Let's see how far we can go! I'll focus on the upper end of the range (the lower end works analogously). What if we get another /
? The first time this happens is
string/0 /
But that's still not a valid replacement pattern, so all is well. It looks like we need three slashes to break the magic. The first time we get three slashes is at
string/0 //
What now? Well, the pattern to be searched for is 0
(and a bunch of spaces), to be replaced with an empty string. That pattern is never found, so the substitution completes immediately. But luckily, there is nothing to print afterwards in the source code, so the result is still only string
. Neat. :)
So we need a valid substitution instruction and more source code afterwards to not print string
:
string/0 //
And this is indeed the first code that doesn't work to spec, as it prints string
followed by a space. So the last code that works is
string/0 /.~
We can apply the same argument to the beginning of the range, the last failing code being
string/.~~~~~//~
such that the first code that works is
string/.~~~~~/0