Search PI for missing sequence digits

Aug 24, 2012 at 7:28pm
Hi

I know there are plenty of places out there where a person can track down digit sequences within a sequence, BUT what I am looking to do and cannot seem to track down is track down sequences with some known and some unknown digits. eg.

In the sequence what are the unknown digits in the number sequence 111?222?333 - the list will obviously be quite extensive depending on the number lengths given. Any help will be hugely appreciated.
Last edited on Aug 30, 2012 at 9:39pm
Aug 24, 2012 at 7:37pm
I don't know any sites, but you can just download the first few gigabytes of pi and search for the sequence yourself.
Aug 24, 2012 at 8:10pm
I have little programming knowledge so was hoping someone would give me some pointers please
Aug 24, 2012 at 9:40pm
0x3A28213A, 0x6339392C, 0x7363682E... okay, just kidding.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

bool match(const char* buf,const std::string& matchStr)
{
  for (size_t i=0;i<matchStr.size();i++)
  {
    if (matchStr[i]!='?' && buf[i]!=matchStr[i])return false;
  }
  return true;
}

int main()
{
  ifstream in("pi.txt",ios::binary);

  string matchStr;
  cout << "Enter a search string: " << flush;
  getline(cin,matchStr);

  const int bufSize=10000;
  const int chunkSize=bufSize-matchStr.length();
  const int noChunks=1e9/chunkSize;
  for (int x=0;x<noChunks;x++)
  {
    char buf[bufSize];
    in.read(buf,bufSize);
    in.seekg(-int(matchStr.size()),ios_base::cur);
    for (int i=0;i<chunkSize;i++)
    {
      if (match(buf+i,matchStr))
      {
        cout << "Found sequence " << string(buf+i,matchStr.length()) << " at position " << x*chunkSize+i << endl;
      }
    }
  }

  cout << "Searched " << in.tellg() << " digits of pi" << endl;
}


Enter a search string: 333?222?111
Found sequence 33372226111 at position 712885093
Searched 999998790 digits of pi in 2.436 seconds

Aug 24, 2012 at 10:27pm
Or, if you're on Linux you could just grep '333?222?111' pi.txt.
Last edited on Aug 24, 2012 at 10:27pm
Aug 24, 2012 at 10:32pm
OK now please for the programming idiot in the room, where in windows do I copy paste that to get it to work? and how do I get it to work, I am below novice level.
Aug 24, 2012 at 10:35pm
1) Download Visual Studio Express : http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express
2) Create an empty project
3) Add a main.cpp file
4) Paste
5) Press the green play button
Aug 24, 2012 at 10:45pm
Thanks - great help
Aug 25, 2012 at 9:22am
is there anywhere I can run this online without having to download visual?
Aug 25, 2012 at 9:37am
There are online compilers ( for example : http://codepad.org/ )
But I'm not sure which one allows you to upload an input file ( pi.txt ) as well.
Aug 25, 2012 at 12:34pm

In PI what are the unknown digits in the number sequence 111?222?333

Hmmm...

As PI is an infinite, irrational number I would think that all numbers will fill the ?s at some point, as long as you seek far enough.

So I am pretty sure that your answer is ? = {0, 1, ..., 9}

Of course, the offset at which each one occurs still need to be found!
Aug 25, 2012 at 12:56pm
PS Just checked out "The Pi-Search Page"
http://www.angio.net/pi/piquery.html

Apparently the chance of finding a given 11 digit pattern in first 100 million digits is just under 10%.

I found my Birthday with a 2 digit year at offset 327948, but not by Birthday with a 4 digit year.

Andy

1
2
3
4
5
6
7
8
9
10
11
Chances of Finding Your Number in Pi

Why can/can't I find my number in Pi? If we view Pi as a big, random string of numbers (which is close enough for our purposes), then we can figure out the odds of finding any string in the first 100 million digits of Pi:
Number Length 	Chance of Finding
1-5	100%
6	Nearly 100%
7	99.995%
8	63%
9	9.5%
10	0.995%%
11	0.09995% 


327,948
Aug 27, 2012 at 8:30pm
OK

Thanks for the help so far, I downloaded the visualstudio then:
1.File> add new project
2. Add > New item > C++ File(.cpp)
3. Pasted your code and pressed green arrow -
results - window pops up saying "this project is out of date"
would you like yo build it? > yes

black window pops up saying "enter a search string"> I enterec a few numbers and nothing happened?

this message appeared

'TRY2.exe': Loaded 'C:\Users\Michael\Documents\Visual Studio 2010\Projects\TRY2\Debug\TRY2.exe', Symbols loaded.
'TRY2.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'TRY2.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'TRY2.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'TRY2.exe': Loaded 'C:\Windows\SysWOW64\msvcp100d.dll', Cannot find or open the PDB file
'TRY2.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Cannot find or open the PDB file

Anyone know what I am doing wrong?

I am also looking for not only the first instance that the searched digits appear, but also the instances they might occur later in pi.

Any help or advice appreciated

Thanks



Aug 27, 2012 at 10:15pm
You need a file pi.txt in the program directory that contains one billion digits of pi or more.
Aug 28, 2012 at 10:25am
Ok so i download a pi calculator and saved digits of pi as a txt. document, and now how do I link it to that file? or place it in the program directory? once again thanks

Athar you are a star

Last edited on Aug 28, 2012 at 9:11pm
Aug 29, 2012 at 4:01pm
You simply need to place it in the program's directory.
Aug 29, 2012 at 9:01pm
Can someone please give me a detailed explanation on how/where to create a directory and insert the digits of pi?
Aug 29, 2012 at 9:02pm
There's nothing to create. You find the .exe file somewhere in the project's directory after you compiled the program. That's where you place pi.txt.
Topic archived. No new replies allowed.