30
3
Challenge :
Pi is supposed to be infinite. That means every number is contained inside the decimal part of pi. Your task will be to take a positive integer on input and return the position of this number in pi digits on output.
For example, if the input is 59
, we'll return 4
Here is why : we will look for the number 59
in the digits of pi
3.14159265...
^^
The value starts at the 4th digit, so the output will be 4
.
Some other examples :
input : 1 output : 1
input : 65 output : 7
input : 93993 output : 42
input : 3 output : 9
Rules :
- You don't have to handle digits that doesn't exist within the first 200 digits
- Standard loopholes are, as always, forbidden.
- This is codegolf, so the fewer bytes wins.
41Numbers with the property you mention are known as normal numbers. An infinite decimal expansion, even if non-periodic, doesn't imply normality. 0.101001000100001... is a counterexample. – Dennis – 2018-04-03T14:21:45.887
38And, absolutely, Pi is not supposed to be infinite. It's decimal representation, however, have infinite digits. – rafa11111 – 2018-04-03T14:22:32.587
11@Dennis Normal is a much stronger condition (all-uniform vs all-exist) – user202729 – 2018-04-03T14:24:29.793
1Related – Luis Mendo – 2018-04-03T14:25:14.100
@user202729 Shows how much I know about number theory. :/ – Dennis – 2018-04-03T14:25:37.280
I was about to incorrectly type the same (numbers like that being normal) :-D – Luis Mendo – 2018-04-03T14:26:22.943
Can we take input as a string? – Dennis – 2018-04-03T14:38:37.770
@Dennis yes, there is no restiction for the input – The random guy – 2018-04-03T14:39:23.630
Related – caird coinheringaahing – 2018-04-03T14:51:08.330
6Are we allowed to output the 0-indexed
n
'th index? So the text cases would return0, 6, 41, 8
instead of1, 7, 42, 9
. – Kevin Cruijssen – 2018-04-03T15:37:07.4477@rafa11111 I agree. We should abandon integers and use numbers in base-PI. Then integers will have infinite digits, instead. – mbomb007 – 2018-04-03T16:09:52.363
2"You don't have to handle digits that doesn't exist within the first 200 digits" - do you mean input integers that don't? – Jonathan Allan – 2018-04-03T16:34:59.133
@mbomb007 that's a lovely idea but, unfortunately, somebody already thought on this... https://en.wikipedia.org/wiki/Non-integer_representation#Base_%CF%80
– rafa11111 – 2018-04-03T17:39:09.257@rafa11111 Yeah, I know. I've been looking at related information. – mbomb007 – 2018-04-03T17:55:16.117
1
@rafa11111 https://codegolf.stackexchange.com/q/76062/34718
– mbomb007 – 2018-04-03T18:16:25.407I say allow for negative numbers, with the understanding that negative means "signed" so it's the first occurrence of that number where it is immediately preceded by
1
. – Anthony – 2018-04-04T02:18:15.137From https://en.wikipedia.org/wiki/Normal_number: It is widely believed that the (computable) numbers √2, π, and e are normal, but a proof remains elusive. (emphasis mine) π only probably contains every possible sequence of digits.
– CJ Dennis – 2018-04-05T03:32:48.617