%I #15 Jan 03 2023 01:27:14
%S 1,3,0,1,0,2,0,1,0,3,0,1,0,2,0,1,2,0,2,1,0,1,2,0,1,0,2,0,1,2,0,2,1,0,
%T 1,3,0,1,0,2,0,1,0,3,0,1,0,2,0,1,2,0,2,1,0,1,2,0,1,0,2,0,1,2,0,2,1,2,
%U 0,1,0,2,0,1,2,0,3,0,1,0,2,0,1,0,3,0,1
%N The lexicographically earliest infinite squarefree sequence of nonnegative integers that starts with 1, 3.
%H Joey Lakerdas-Gayle, <a href="/A356681/b356681.txt">Table of n, a(n) for n = 1..10000</a>
%H Siddharth Berera, Andrés Gómez-Colunga, Joey Lakerdas-Gayle, John López, Mauditra Matin, Daniel Roebuck, Eric Rowland, Noam Scully, and Juliet Whidden, <a href="https://arxiv.org/abs/2210.00508">The lexicographically least square-free word with a given prefix</a>, arXiv:2210.00508 [math.CO], 2022.
%o (Python)
%o # check if appending letter to the end of word introduces a square
%o def makes_square(word, letter):
%o new_word = word+[letter]
%o for l in range(1, len(new_word) // 2 + 1):
%o if new_word[-l:] == new_word[-2*l:-l]:
%o return True
%o return False
%o # returns a list of the first n letters of L(word)
%o def build_square_free(word, n):
%o new_word = word[:]
%o for i in range(n-len(word)):
%o next_letter = 0
%o while makes_square(new_word, next_letter):
%o next_letter += 1
%o new_word += [next_letter]
%o return new_word
%o # returns a list of the first n terms of A356681
%o def A356681_list(n):
%o return build_square_free([1,3], n)
%o print(A356681_list(87))
%Y Other word starts: A007814 (w=0), A356677 (w=1), A356678 (w=2), A356679 (w=3), A356680 (w=1,2), this sequence (w=1,3), A356682 (w=2,1).
%K nonn
%O 1,2
%A _Joey Lakerdas-Gayle_, Oct 18 2022