OFFSET
1,3
LINKS
Gavin Lupo, Table of n, a(n) for n = 1..10000
Gavin Lupo, Image of the first 100000 terms.
EXAMPLE
a(1) = 1.
a(2) = 1.
a(3) = 2. How many 1's so far are adjacent to a 1? = 2.
a(4) = 1. How many 2's so far are adjacent to a 1? = 1.
a(5) = 2. How many 1's so far are adjacent to a 2? = 2.
a(6) = 2. How many 2's so far are adjacent to a 1? = 2.
MATHEMATICA
K = {1, 1}; While[Length@K < 87, A = Position[K, Last@K]; c = 0; For[a = 1, a <= Length@A, a++, If[K[[A[[a]] - 1]] == {K[[Length@K - 1]]} || K[[A[[a]] + 1]] == {K[[Length@K - 1]]}, c++]]; AppendTo[K, c]]; Print[K] (* Samuel Harkness, May 08 2023 *)
PROG
(Python)
from itertools import islice
from collections import Counter
def agen(): # generator of terms
aprev, an, anext, c = 0, 1, 1, Counter({(1, 1)})
while True:
aprev, an, anext = an, anext, c[an, anext]
c[an, anext] += 1
if aprev != anext: c[anext, an] += 1
yield an
print(list(islice(agen(), 100))) # Michael S. Branicky, May 02 2023
CROSSREFS
KEYWORD
AUTHOR
Gavin Lupo, May 01 2023
STATUS
approved