Wolfram Language

Core Language

Find a Sequence in the Digits of π

The new functions SequenceCases, SequencePosition, and SequenceCount offer new functionality to extract sequences using pattern matching.

Find the occurrence of the first release date of Mathematica in the digits of .

In[1]:=
Click for copyable input
EntityValue[ Entity["ProgrammingLanguage", "WolframLanguage"], "DateIntroduced"]
Out[1]=

Change this date to a format suited to the search.

In[2]:=
Click for copyable input
EntityValue[ Entity["ProgrammingLanguage", "WolframLanguage"], "DateIntroduced"]; date = Characters[DateString[%, {"Month", "Day", "YearShort"}]]
Out[2]=

Generate the first three million digits of .

In[3]:=
Click for copyable input
pi = Characters[ToString@N[Pi, 3000000]];

SequencePosition gives the positions at which the formatted date starts and ends.

In[4]:=
Click for copyable input
pos = SequencePosition[pi, date]
Out[4]=

It appears only once in the first three million digits of . This occurrence can be represented in a simple way using a Grid object.

show complete Wolfram Language input
In[5]:=
Click for copyable input
chars = Join[ Take[pi, 21], Characters["..."], Take[pi, First@pos - {14, 6}], Style[#, Orange] & /@ Take[pi, First@pos], Take[pi, First@pos + {6, 4}] ];
In[6]:=
Click for copyable input
Grid[Partition[chars, 8]]
Out[6]=

Try other dates and find your day here!

Related Examples

de es fr ja ko pt-br ru zh