You can easily program this out, with the following algorithm:
Step 1: Split a given integer of n digits in 2 digit-sequences by viewing the first $ 0 \leq i \leq n-1$ as the first sequence(can be an empty sequence) and the next $n-i$ digits to be the second sequence. In this way we have n different splits.
Step 2: Verify which splits are 'good' splits. Good splits are splits such that, there is a integer ending with sequence 1 and a integer starting with sequence 2. In the 2012 case, we have 4 possible (different) splits:
- () , (2012)
- (2), (012)
- (20), (12)
- (201), (2)
In this case all but the second are good splits, because there is not integer which starts with the digits 012.
Step 3: After filtering, look at the ones who are good splits and calculate when they appear. And the answer to the question is the minimum of all these values.
Calculating the appearance is done like this:
Given a split (ab)(cdefg), calculate the minimal integer $d$ such that d starts with (cdefg) and ends with (ab+1). If $a \neq g$ then it is the integer $cdefgab+1$ for example. Then the digit where this integer occurs is $9*1+90*2+900*3+900*4+9000*5+90000*6+(cdefgab+1-10^6)*7+1-2$ in our case. The first 6 terms are there because our integer is bigger than 10*6, so all those integers come before him. Then there are $cdefgab+1-10^6$ integers before him with 7 digits. So this integer would start at the next place (+1 part) but since we want $abcdefg$, we can substract 2 places because this new integer starts 2 places earlier.
and this: http://oeis.org/A220376
– picakhu Jul 18 '13 at 17:43