login
The number of 3's minus the number of 2's among the first n terms of A342101.
0

%I #25 Jun 18 2021 09:08:42

%S 0,-1,0,0,1,1,0,0,1,1,0,1,1,1,0,0,1,1,0,1,1,2,2,1,1,1,0,1,1,1,0,0,1,1,

%T 0,1,1,2,2,1,1,2,2,1,2,2,2,1,1,1,0,1,1,2,2,1,1,1,0,1,1,1,0,0,1,1,0,1,

%U 1,2,2,1,1,2,2,1,2,2,2,1,1,2,2,1,2,2,3

%N The number of 3's minus the number of 2's among the first n terms of A342101.

%C It appears that the sequence never goes below -1 and increases without bound.

%C It appears that if the first appearance of a number x occurs at index n and the first appearance of x+1 appears at index m then m/n approaches 4 as x increases.

%H Kevin Ryde, <a href="https://user42.tuxfamily.org/seq-A342101-middle-delete/index.html">PARI/GP Code and Notes</a>.

%e A342101 = [1, 2, 3, 1, 3, ...]. By the fifth term of A342101 we see 2 terms with value 3, and a single term with value 2, so a(5) = 2 - 1 = 1.

%t Block[{a = {}, s = Nest[Join[#, Drop[#, {(Length[#] + 1)/2}]] &, Range[3], 6], c}, Array[Set[c[#], 0] &, 3]; Do[c[ s[[i]] ]++; AppendTo[a, c[3] - c[2]], {i, Min[Length@ s, 104]}]; a] (* _Michael De Vlieger_, May 01 2021 *)

%o (Kotlin)

%o fun a(iter: Int): List<Int> = runningSum(twosVersusThrees(iter))

%o fun runningSum(a: List<Int>) = a.drop(1).fold(listOf(a[0])) { acc, cur ->

%o acc + (acc.last() + cur)

%o }

%o fun twosVersusThrees(iter: Int): List<Int> = removeMiddle(listOf(0,-1,1), iter)

%o fun removeMiddle(initial: List<Int>, iter: Int): List<Int> {

%o if (iter < 2) return initial

%o val prev = removeMiddle(initial, iter-1)

%o return prev + prev.subList(0, (prev.size - 1) / 2) + prev.subList((prev.size + 1) /2, prev.size)

%o }

%o (PARI) See links.

%Y Cf. A342101.

%K sign

%O 1,22

%A _Matthew Malone_, Apr 15 2021