Search PI for missing sequence digits

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
I don't know any sites, but you can just download the first few gigabytes of pi and search for the sequence yourself.
I have little programming knowledge so was hoping someone would give me some pointers please
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

Or, if you're on Linux you could just grep '333?222?111' pi.txt.
Last edited on
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.
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
Thanks - great help
is there anywhere I can run this online without having to download visual?
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.

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!
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
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



You need a file pi.txt in the program directory that contains one billion digits of pi or more.
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
You simply need to place it in the program's directory.
Can someone please give me a detailed explanation on how/where to create a directory and insert the digits of pi?
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.