Introduction
In base 10, the Champernowne constant is defined by concatenating representations of successive integers. In base 10: 0.1234567891011121314151617...
and so on.
You can see that the first appearence of 15
starts at the 20th
decimal:
Position
0000000001111111111222222222233333333334444444444555555555566666666
1234567890123456789012345678901234567890123456789012345678901234567
^
0.1234567891011121314151617181920212223242526272829303132333435363738...
^^
15 = position 20
The first appearence of 45
starts at the 4th
decimal:
Position
0000000001111111111222222222233333333334444444444555555555566666666
1234567890123456789012345678901234567890123456789012345678901234567
^
0.1234567891011121314151617181920212223242526272829303132333435363738...
^^
45 = position 4
So, the task is easy. Given a non-negative integer, output the position of the integer in the Champernowne constant.
Rules
- You may provide a function or a program
- This is code-golf, so the submission with the least amount of bytes wins!
Test cases
Input: 20
Output: 30
Input: 333
Output: 56
Input: 0
Output: 11 (note that the 0 before the decimal point is ignored)
Input: 2930
Output: 48
0 <= x <= 99
, but it should theoretically work for integers higher than99
. \$\endgroup\$