Up for the count
def counting_series(n):
The Champernowne word 1234567891011121314151617181920212223... is an infinitely long string of digits made up of all positive integers written in ascending order without any separators between the individual numbers. This function should return the integer digit that lies in the position n of the Champernowne word, position count again starting from zero as usual.Of course, the automated tester will give your function values of n large enough that anybody trying to solve this problem by explicitly constructing the series as a string would run out of time and space long before receiving the answer. Instead, you should observe that the structure of this infinite sequence is quite straightforward, as it starts with 9 single-digit numbers, followed by 90 two-digit numbers, followed by 900 three-digit numbers, and so on. Such a predictably self-similar structure allows you to skip over prefixes of this series in exponentially widening leaps and bounds, until you reach the position n and find out the digit that is waiting for you there.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here