Problem 3 - Number string
Define S as an infinite string formed by concatenating all the natural numbers in increasing order, i.e., S = "123456789101112131415161718192021...99100101..."
Write an R function named num_str, which takes an argument of a sequence of digits named s and returns the first location in S where s appears. Save your function in a file named num-str.R. Example runs are given below.
> num_str("12")
[1] 1
> num_str("21")
[1] 15
Hint: Optimize your code, as some of the test cases may be challenging. Also, modular design can help avoid bugs.