OFFSET
1,2
COMMENTS
Naive string search simply tries the pattern (n here) at each position of the text (1234... here) in turn until a match is found (i.e., without taking account of any special properties of the pattern or text).
LINKS
Sean A. Irvine, Table of n, a(n) for n = 1..1000
EXAMPLE
In the following examples x:y means compare pattern character x with text character y.
a(1)=1 because 1:1 (success).
a(2)=2 because 2:1 (fail), then 2:2 (success).
a(10)=12 because 1:1 (match), 0:2 (fail), then 1:2 (fail), ..., 1:9 (fail), then 1:1 (match), 1:0 (success).
a(12)=2 because 1:1 (match) and 2:2 (success).
PROG
(Python)
from itertools import count
def champ(): yield from (d for i in count(1) for d in str(i))
def a(n):
target, matches, match_idx, cstr, c = str(n), 0, 0, "", 0
for d in champ():
cstr, c = cstr + d, c + 1
if target[matches] == cstr[match_idx]:
matches, match_idx = matches + 1, match_idx + 1
else:
matches, match_idx = 0, match_idx - matches + 1
if matches == len(target): return c
print([a(n) for n in range(1, 68)]) # Michael S. Branicky, Jan 30 2026
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Sean A. Irvine, Jan 29 2026
STATUS
approved
