cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A331975 Lexicographically earliest sequence of distinct positive integers such that three successive digits are always distinct.

This page as a plain text file.
%I A331975 #18 Jul 01 2022 05:33:36
%S A331975 1,2,3,4,5,6,7,8,9,10,21,30,12,31,20,13,24,15,23,14,25,16,27,18,26,17,
%T A331975 28,19,32,40,29,34,50,35,41,36,42,37,43,51,38,45,39,46,52,47,53,48,54,
%U A331975 60,49,56,70,57,61,58,62,59,63,71,64,72,65,73,67,80,68,74,69,75,81,76,82,78,90,79,83,91,84
%N A331975 Lexicographically earliest sequence of distinct positive integers such that three successive digits are always distinct.
%H A331975 Carole Dubois, <a href="/A331975/b331975.txt">Table of n, a(n) for n = 1..5000</a>
%e A331975 As a(10) = 10, a(11) cannot start with a 1 or have a 0 in second position; thus a(11) = 21;
%e A331975 as a(11) = 21, a(12) cannot start with a 1 or a 2; thus a(12) = 30;
%e A331975 as a(12) = 30, a(13) = 12, smallest available integer not leading to an immediate contradiction;
%e A331975 as a(13) = 12, a(14) cannot start with 1 or 2; thus a(14) = 31, smallest available integer not leading to an immediate contradiction. Etc.
%o A331975 (Python)
%o A331975 from itertools import islice
%o A331975 def ok(s): return all(len(set(s[i:i+3]))==3 for i in range(len(s)-2))
%o A331975 def agen(): # generator of terms
%o A331975     aset, s, k, mink = {1}, "x1", 1, 2
%o A331975     while True:
%o A331975         yield k
%o A331975         k, avoid = mink, set(s)
%o A331975         while k in aset or not ok(s + str(k)): k += 1
%o A331975         aset.add(k)
%o A331975         s = (s + str(k))[-3:]
%o A331975         while mink in aset: mink += 1
%o A331975 print(list(islice(agen(), 79))) # _Michael S. Branicky_, Jun 30 2022
%Y A331975 Cf. A331215 (a variant with 4 successive distinct digits instead of 3).
%K A331975 base,nonn
%O A331975 1,2
%A A331975 _Eric Angelini_ and _Carole Dubois_, Feb 03 2020