Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #12 Nov 30 2022 10:04:07
%S 1,12,123,1234,12345,123456,1234567,12345678,123456789,10123456789,
%T 1011123456789,101111223456789,10111121323456789,1011112131423456789,
%U 101111213141523456789,10111121314151623456789
%N String together the first n numbers in an order which minimizes the result.
%o (Python)
%o from itertools import count, islice
%o def agen(): # generator of terms
%o slst = []
%o for n in count(1):
%o s, least, argleast = str(n), ":", None
%o for i in range(len(slst)+1):
%o t = "".join(slst[:i]) + s + "".join(slst[i:])
%o if t < least: least, argleast = t, i
%o slst.insert(argleast, s)
%o yield int("".join(slst))
%o print(list(islice(agen(), 16))) # _Michael S. Branicky_, Nov 29 2022
%Y Cf. A000422, A060554.
%K base,easy,nonn
%O 1,2
%A _Henry Bottomley_, Apr 02 2001
%E Incorrect comment removed by _Sean A. Irvine_, Nov 30 2022