Introduction
Describing the three main streams of present-day mathematical philosophy (formalism, Platonism and intuitionism) in a well-known book, The Emperor's New Mind, R. Penrose says:
...it will perhaps be helpful if I refer to just a few of the problems. An example often referred to by Brouwer concerns the decimal expansion of $\pi = 3.141592653589793...$
Does there exists a succession of twenty consecutive sevens somewhere in this expansion, i.e. $$\pi = 3.141592653589793...77777777777777777777...$$ or does there not ?
In ordinary mathematical terms, all that we can say, as of now, is that either there does or there does not—and we do not know which! This would seem to be a harmless enough statement. However, the intuitionists would actually deny that one can validly say "either there exists a succession of twenty consecutive sevens somewhere in the decimal expansion of $\pi$, or else there does not"—unless and until one has (in some constructive way acceptable to the intuitionists) either established that there is indeed such a succession, or else established that there is none! A direct calculation could suffice to show that a succession of twenty consecutive sevens actually does exist somewhere in the decimal expansion of $\pi$, but some sort of mathematical theorem would be needed to establish that there is no such succession. No computer has yet proceeded far enough in the computation of $\pi$ to determine that there is indeed such a succession. One's expectation on probabilistic grounds would be that such a succession does actually exist, but even if the computer were to produce digits consistently at the rate of, say, $10^{10}$ per second, it would be likely to take something of the order of between one hundred and one thousand years to find the sequence!
The actual problem
Since the above seems rather a bit beyond the scope of average computers I would like to find every sequence of length at least 10 of consecutive identical digits in the first $10^{9}$ digits of the decimal expansion of $\pi$. The solution would be better if it could be easily extensible to a multiple of $10^{9}$ digits, say the first $10^{10}$ digits of $\pi$.
We shouldn't restrict to the decimal digits of $\pi$, but preferable solutions should work with any finite numbers of digits any transcendental numbers, e.g. $e^\pi, {\sqrt 2}^{\sqrt 3}$, etc.
Techniques like parallelization, compilation, GPU support etc. are acceptable to achive any possibly efficient solutions.
A step by step method not fulfilling expectations
In case of $\pi$ we could e.g. try something like a "step by step" approach:
l2 = Split[ First @ RealDigits[Pi, 10, 10000000, -20000000]];
Position[ Length /@ l2, Max @ (Length /@ l2)]
l2[[#]] & /@ Flatten @ %
(* {{4193044}}
{{7, 7, 7, 7, 7, 7, 7, 7, 7}} *)
and
l4 = Split[ First @ RealDigits[Pi, 10, 10000000, -40000000]];
Position[ Length /@ l4, Max @ (Length /@ l4)]
l4[[#]] & /@ Flatten @ %
(* {{5113613}, {5996894}}
{{6, 6, 6, 6, 6, 6, 6, 6, 6}, {8, 8, 8, 8, 8, 8, 8, 8, 8}} *)
Here we found only succsessions of length 9
, so it is not exactly what I wanted but it helps to understand why this method suffers from time and memory problems, often yielding
No more memory available.
Mathematica kernel has shut down.
Try quitting other applications and then retry.
A "step by step" is too time-consuming because Mathematica needs to compute first decimal digits every time we want to proceed to the next step and the access time depends roughly linearly on number of steps, e.g. :
tunit = First[ Split[ First @ RealDigits[Pi, 10, 1000, -10000]]; // AbsoluteTiming];
timeT = 1/tunit Table[ First @ AbsoluteTiming[ Split[ First @ RealDigits[Pi, 10, 1000, -6000k]];],
{k, 60}];
ListLinePlot[timeT]
Maybe some Reap
and Sow
approach or whatever else?