Birthday in Pi

Hi! , recently I have been curious about how to do exercises from MatLab to Julia and I started doing the birthday day in pi, in MatLab there is the function “SequencePosition” that helps in this type of problems. My question is if there is something similar in Julia
Code in MatLab:

SequencePosition[First[RealDigits[Pi, 10, 1000000]], {1, 1, 1, 7, 9, 9}]
# With 1000000 Decimals of pi and {1, 1, 1, 7, 9, 9} the birthday

How I started the problem in Julia

setprecision(BigFloat, 20000000) do
    a=BigFloat(pi)
end

But I don’t know how to move on

That looks like Mathematica, not Matlab? You could do this with a regex.

julia> function pi_str(n)
           setprecision(Int(ceil(log2(10) * n))) do
               string(BigFloat(pi))
           end
       end

julia> m = match(r"(111799)", pi_str(10^6))
RegexMatch("111799", 1="111799")

julia> m.offset
123957
3 Likes