Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #3073 > unrolled thread

Re: Seaching in Pi a sequence. Looking for a faster method

Started byPhil J Taylor <xptaylor@gmail.com>
First post2011-06-11 07:59 +0000
Last post2011-06-11 07:59 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Seaching in Pi a sequence. Looking for a faster method Phil J Taylor <xptaylor@gmail.com> - 2011-06-11 07:59 +0000

#3073 — Re: Seaching in Pi a sequence. Looking for a faster method

FromPhil J Taylor <xptaylor@gmail.com>
Date2011-06-11 07:59 +0000
SubjectRe: Seaching in Pi a sequence. Looking for a faster method
Message-ID<isv78c$7n$1@smc.vnet.net>
This works well for me ... it's about 3x faster than piesimo on my machine
and I can search for any sequence.
The final argument c is the number of matches that you are interested in
seeing.

piStringSearch[n_, s_, c_] :=
 Module[{a}, a = ToString[N[Pi, n]];
  StringPosition[a, ToString[s], c] /. {start_, end_} :> start - 2]

piStringSearch[10^7, 9999999, 100]

{1722776, 3389380, 4313727, 5466169}

On Fri, Jun 10, 2011 at 6:38 AM, Guillermo Sanchez <
guillermo.sanchez@hotmail.com> wrote:

> Dear Group
>
> I have developed this function
>
> piesimo[n_, m_, r_] := Module[{a}, a = Split[RealDigits[Pi - 3, 10, n]
> [[1]]]; Part[Accumulate[Length /@ a], Flatten[Position[a, Table[m,
> {r}]]] - 1] + 1]
>
> n is the digits of Pi, after 3, where to search a sequence of m digit
> r times consecutives.
> For instance:
>
> piesimo[10^7, 9, 7]
>
> Gives that the sequence 9999999 happens in positions:
>
> {1722776, 3389380, 4313727, 5466169}
>
> I know that in this group I will find  faster methods. Any idea?
>
> Guillermo
>
>

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web