# Inverse Champernowne Substrings

The Champernowne Constant is the irrational number 0.1234567891011... extending ad infinum.

We've done a question about it before. But this question is about its reciprocal, known as the Inverse Champernowne Constant. This is approximately 8.10000007.

Given a string of between one and three digits (every 3-digit string appears within the first 10,000 decimal places) inclusive, give the number of decimal places in the decimal portion of the Inverse Champernowne Constant that precede the first appearance of that string.

Builtins that perform this directly or generate approximations of either of these constants are forbidden, but builtins for arbitrary precision arithmetic are still permissible.

This is code golf, so the shortest program, in bytes, wins.

Test cases:

1 0
2 52
3 13
4 29
5 36
6 7
7 8
8 27
9 23
10 0
100 0
998 187
999 67
01 321
001 689
010 418

• Could you post a file the first 10,000 inverse Champernowne constant digits? – orlp Feb 10 '16 at 1:59
• @orlp gist.github.com/SuperJedi224/9c9adad78d872e4d568f to 10,000 decimal places (your program should only look at the part to the right of the decimal point) – SuperJedi224 Feb 10 '16 at 3:29
• Can result be 1-based? – Luis Mendo Feb 10 '16 at 10:21
• @LuisMendo The specs currently dictate 0-based – SuperJedi224 Feb 10 '16 at 11:10

# MATL, 37 bytes

Thanks to @AndrasDeak for his help with Octsympy's vpa function!

'1/'1e4:"@V]N$h1e4H$Y$t32>)I0h)jXf1)q  EDIT (June 11, 2016): due to changes in the language, replace 0 by J in the code. The link below includes that modification Try it online! It takes a while in the online compiler (less than 1 minute). '1/' % literal string 1e4: % array [1,2,...,1e4] " % for each number in that array @V % push number and convert to string ] % end loop N$h         % concatenate all strings
1e4H$Y$     % compute 1/123456789101112... as a string with 1e4 significant digits
t32>)       % remove unwanted spaces and newlines in the output string
I0h)        % remove the first two characters ('8.')
j           % input string
Xf          % find indices of occurrences of input string within computed string
1)          % take first index
q           % subtract 1


## Ruby, 69 67 bytes

->x{"#{1/BigDecimal.new(?.+[*1..9999]*'')}".index(x)-3}


Score: 55 source code bytes + 12 for the -rbigdecimal flag.

Pretty straightforward. Only weird part is that the to_s implicitly called by the #{} construction on BigDecimal returns

0.81000000670 [...] 3036E1


so it's necessary to subtract 3 to get the correct index.

# Python 2, 69 bytes

lambda s:str(10**30000/int("".join(map(str,range(3000))))).index(s)-1

• This won't work for an input of "8". – negative seven Jun 9 '19 at 16:29