diff options
| author | noahpy <noschl@proton.me> | 2025-05-15 17:12:01 +0200 |
|---|---|---|
| committer | noahpy <noschl@proton.me> | 2025-05-15 17:12:01 +0200 |
| commit | 683cef97216326ddad044d19a5cdea3bf18e0574 (patch) | |
| tree | cf8068006c46cd7f01b4462b9f5aeb0f5df9fdc8 | |
| download | pi_digit_positions-683cef97216326ddad044d19a5cdea3bf18e0574.tar.gz pi_digit_positions-683cef97216326ddad044d19a5cdea3bf18e0574.zip | |
init
| -rw-r--r-- | README.md | 3 | ||||
| -rw-r--r-- | calc_position.py | 31 |
2 files changed, 34 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..88d35b2 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ + +Calculates page, line and position of a given decimal point of Pi for the [One Million Digits of Pi](https://isbnsearch.org/isbn/9798631094345) book. +Fun paired with [The Pi-Search Page](https://www.angio.net/pi/). diff --git a/calc_position.py b/calc_position.py new file mode 100644 index 0000000..e2c19d0 --- /dev/null +++ b/calc_position.py @@ -0,0 +1,31 @@ + + +i = int(input("Enter position: ")) + +num_rows = 46 +num_cols = 52 + +first_line = 36 +first_page = 40 * 52 + +if i <= first_line: + print("Page 3, Line 1, Position " + str(i)) + exit(0) + +i -= first_line + +if i <= first_page: + line = i // num_cols + 2 + col = i % num_cols + print("Page 3, Line " + str(line) + ", Position " + str(col)) + exit(0) + +i -= first_page + +page = i // (num_rows * num_cols) + 2 +i -= (page - 2) * num_rows * num_cols + +line = i // num_cols +col = i % num_cols + +print("Page " + str(page + 2) + ", Line " + str(line) + ", Position " + str(col)) |