Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# FindInPi
A Kotlin HTTP API to searching pi for specific strings of numbers. Includes a pure kotlin and C/JNI/kotlin impelemntation.
A Kotlin HTTP API for searching Pi for specific series of numbers. Includes both pure Kotlin and C/JNI/Kotlin impelemntations.

## Why?
Pi is probably the most famous irrational number. As an irrational number, when pi is represented as a decimal it is a never ending, never permanently repeating, seemingly random stream of numbers.
Pi is the world's most famous irrational number. As an irrational number, Pi is a never ending, never permanently repeating, seemingly random stream of numbers when represented as a decimal.

Pi has long been popular to calculate to many digits using computers, with the world record at the time of this writing being over 100 trillion digits.
Pi has long been a popular reference number by which to calculate numbers to many digits using computers, with the world record at the time of this writing being over 100 trillion digits.

A random number number this long contains many other smaller numbers, such as your social securty number, phone number, birthday, etc. These numbers occur by chance, but it can still be interesting to see exactly where in pi some of these numbers might occur.
A random number this long contains many smaller number series, such as your social securty number, phone number, birthday, etc. These numbers occur by chance, but it can still be interesting to see exactly where in Pi some of these numbers might occur.

Let's use phone numbers as an example. US phone numbers are 10 digits long, so there are 10<sup>10</sup> possible phone numbers. If we were to randomly generate 10<sup>10</sup> 10-digit numbers, the resulting set should contain nearly all possible values. Following this we can see that in any random string of digits, if we want to find any decimal number of length n, our string of digits must be 10<sup>n</sup> * n digits long. So in our example we'd need 10<sup>10</sup> * 10 digits of pi, or 100 billion digits.
Let's use phone numbers as an example. US phone numbers are 10 digits long, so there are 10<sup>10</sup> possible phone numbers. If we were to randomly generate 10<sup>10</sup> 10-digit numbers, the resulting set should contain nearly all possible values. For example, in any random string of digits, if we want to find any decimal number of length n, our string of digits must be 10<sup>n</sup> * n digits long. So in our example, we would need 10<sup>10</sup> * 10 digits of Pi, or 100 billion digits.

This program was written for pi day 2024, and it can be used to search large pi data files for any string of digits.
This program was written for Pi day 2024 and can be used to search large Pi data files for any string of digits.
## Building
### Prerequisites
- Java 11+
Expand All @@ -28,35 +28,37 @@ To build only the native library:

## Running
### Prerequisites
Before running, you'll need to provide a pi data file. The file should be a **SINGLE LINE** text file containg the
Before running, you'll need to provide a Pi data file. The file should be a **SINGLE LINE** text file containg the
digits of pi.

The [file](src/main/resources/Pi1M.txt) provided with this repository is only 1M digits long, which isn't very
NOTE: The [file](src/main/resources/Pi1M.txt) provided with this repository is only 1M digits long, which isn't very
interesting to search.

#### Getting a data file
You download some 1B+ digit calculations of pi from [here](https://stuff.mit.edu/afs/sipb/contrib/pi/),
or you can calculate your own pi data file with [y-cruncher](http://www.numberworld.org/y-cruncher/), or you

Set the location of the file as an environment variable:
To get Pi data, you can do the following:
- Download 1B+ digit calculations of Pi from [here](https://stuff.mit.edu/afs/sipb/contrib/pi/)
- Calculate your own Pi data file with [y-cruncher](http://www.numberworld.org/y-cruncher/)
- Perform the following steps:

1. Set the location of the file as an environment variable:
Copy link
Owner

@frazieje frazieje Apr 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the update to use an unordered list for the data file options, but this line about setting the location of the file starts the next section, which should be titled "Configuring the data file" or "using your data file" or something like that

```shell
$ export PI_DATA=[location of data file]
```

Run the program:
2. Run the program:
```shell
$ ./gradlew run
```
You can also set the location of the data file as a program argument:
Optional: Set the location of the data file as a program argument:
```shell
$ ./gradlew run -PpiData=[location of data file]
```

### Usage
To use the HTTP API once running:
After you run the program, use the HTTP API:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"After you run the program, use the HTTP to search for a number in Pi:"

Should we also mention that they need to update the searchText to whatever number they want to search for?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

```shell
$ curl --request POST \
--header 'Content-Type: application/json' \
--url 'http://localhost:8080/search' \
--data '{"searchText":"62643"}'
```
```