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!)
A262323 Lexicographically earliest sequence of distinct terms such that the decimal representations of two consecutive terms overlap. 10
1, 10, 11, 12, 2, 20, 22, 21, 13, 3, 23, 30, 33, 31, 14, 4, 24, 32, 25, 5, 15, 41, 16, 6, 26, 42, 27, 7, 17, 51, 18, 8, 28, 52, 29, 9, 19, 61, 36, 43, 34, 40, 44, 45, 50, 35, 53, 37, 63, 38, 73, 39, 83, 48, 54, 46, 60, 56, 55, 57, 65, 58, 75, 47, 64, 49, 74 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
COMMENTS
Two terms are said to overlap:
- if the decimal representation of one term is contained in the decimal representation of the other term (for example, 12 and 2 overlap),
- or if, for some k>0, the first k decimal digits (without leading zero) of one term correspond to the k last decimal digits of the other term (for example, 1017 and 1101 overlap).
This sequence is a permutation of the positive integers, with inverse A262255.
The first overlap involving 1 digit occurs between a(1)=1 and a(2)=10.
The first overlap involving 2 digits occurs between a(108)=100 and a(109)=110.
The first overlap involving 3 digits occurs between a(1039)=1017 and a(1040)=1101.
The first overlap involving 4 digits occurs between a(10584)=10212 and a(10585)=11021.
LINKS
EXAMPLE
The first terms of the sequence are:
+----+---------+
| n | a(n) |
+----+---------+
| 1 | 1 |
| 2 | 10 |
| 3 | 11 |
| 4 | 12 |
| 5 | 2 |
| 6 | 20 |
| 7 | 22 |
| 8 | 21 |
| 9 | 13 |
| 10 | 3 |
| 11 | 23 |
| 12 | 30 |
| 13 | 33 |
| 14 | 31 |
| 15 | 14 |
| 16 | 4 |
| 17 | 24 |
| 18 | 32 |
| 19 | 25 |
| 20 | 5 |
+----+---------+
PROG
(Perl) See Links section.
(Haskell)
import Data.List (inits, tails, intersect, delete)
a262323 n = a262323_list !! (n-1)
a262323_list = 1 : f "1" (map show [2..]) where
f xs zss = g zss where
g (ys:yss) | null (intersect its $ tail $ inits ys) &&
null (intersect tis $ init $ tails ys) = g yss
| otherwise = (read ys :: Int) : f ys (delete ys zss)
its = init $ tails xs; tis = tail $ inits xs
-- Reinhard Zumkeller, Sep 21 2015
(Python)
def overlaps(a, b):
s, t = sorted([str(a), str(b)], key = lambda x: len(x))
if any(t.startswith(s[i:]) for i in range(len(s))): return True
return any(t.endswith(s[:i]) for i in range(1, len(s)+1))
def aupto(nn):
alst, aset = [1], {1}
for n in range(2, nn+1):
an = 1
while True:
while an in aset: an += 1
if overlaps(an, alst[-1]): alst.append(an); aset.add(an); break
an += 1
return alst
print(aupto(67)) # Michael S. Branicky, Jan 10 2021
CROSSREFS
Cf. A262367 (fixed points), A262411 (ternary version), A262460 (hexadecimal version).
Sequence in context: A184992 A162501 A286890 * A262412 A333722 A299981
KEYWORD
nonn,look,base,nice
AUTHOR
Paul Tek, Sep 19 2015
STATUS
approved

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 18 22:18 EDT 2024. Contains 371782 sequences. (Running on oeis4.)