login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A060555 String together the first n numbers in an order which minimizes the result. 2

%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

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 24 11:21 EDT 2024. Contains 371936 sequences. (Running on oeis4.)