OFFSET
1,2
COMMENTS
Original name: "A self-describing sequence: The a(n) say the positions of the digits 1 inside the sequence when it is read as a string of digits."
For each n, the digit in position a(n) is equal to 1. At each step, choose the minimum integer not yet present in the sequence and not leading to a contradiction.
This sequence had been mentioned by Wasserman in 2008, cf. A098645, a variant of this sequence with additional restriction a(n+1) > a(n). - M. F. Hasler, Oct 08 2013
LINKS
EXAMPLE
The sequence starts with 1: the first digit is equal to 1. In the second position we cannot write 2 because the second digit would not be 1 but 2. Then we write 3. The third digit must be 1 and the minimum number starting with 1 is 10. And so on.
PROG
(Sage) #Returns the first n terms of this sequence for digit d
def dig_loc(d, n):
L, S = [], ""
while len(L)<n:
ext, new, lenS = 0, 0, len(S)
while new==0:
ext += 1
while d==0 and (lenS+ext+1 in L): ext += 1
d_s = [i for i in range(ext) if (lenS+i+1 in L)]
need = ext - len(d_s)
for i in range(10^(need-1)*(0 not in d_s), 10^(need)):
a = [str(0)]*(need - len(str(i))) + list(str(i))
for j in d_s: a.insert(j, d)
new = sum([int(a[ext-1-j])*10^j for j in range(ext)])
if ( new not in L ) and ( new>lenS or S[new-1]==str(d) ) and ( (new-lenS-1 not in range(ext)) or a[new-lenS-1]==str(d) ) and ( d!=0 or lenS+ext+1!=new ):
L.append(new)
S += str(new)
break
else: new = 0
return L
dig_loc(1, 58) # Danny Rorabaugh, Nov 27 2015
CROSSREFS
KEYWORD
nonn,base,nice
AUTHOR
Paolo P. Lava, Mar 26 2012
EXTENSIONS
Edited by M. F. Hasler, Oct 10 2013
STATUS
approved