Introduction
Pi is
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089...
Let's treat each digit as an instruction as to how to get to the next digit.
- The first digit is 3.
- Counting three digits after the first digit, we arrive at 1.
- One digit after this 1 is a 5.
- Five digits after that is 3.
- Three digits later is 9.
The digits included in this sequence are in bold: 3.1415926535897932384626433...
If a digit is 0, the next digit is 10 later.
Challenge
Given a positive integer n
less than 1000, find out how many of the first n
digits of pi, including the initial 3, are in the sequence.
Furthermore, your code's characters must have a "pi-based frequency". Choose any character; your program must use exactly three of that character. Choose another character, use exactly one of it. Choose another character, use it four times. You may continue for as long as you wish, but each character chosen must be different.
For example, the following snippet complies with the frequency rules (but produces the wrong output):
print "r\"rriiiittttnttttppppp"
# Uses 3 quotation marks, 1 space, 4 r's, 1 \, 5 i's, 9 t's, 2 n's, and 6 p's.
For the purposes of "pi-based frequency", treat the digit 0 as 10.
You may write a function or a full program. You may not use any built-in constants, trigonometry functions, or complex number functions to find pi.
Shortest code in characters wins. The tiebreaker is the most votes.
Examples
Input Output
-------------
1 1
2 1
3 1
4 2
5 3
28 8
77 17
123 28
328 73
625 122
999 189