login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Lexicographically least sequence over the positive integers with the property that there are no two consecutive blocks of the same length and same sum.
2

%I #18 May 01 2022 07:23:15

%S 1,2,1,3,1,2,1,4,2,1,2,5,2,1,3,1,2,1,3,4,1,2,1,7,2,3,1,2,1,5,1,2,1,8,

%T 2,4,2,3,2,1,5,4,3,7,2,1,4,2,5,3,1,2,1,3,4,1,2,1,4,5,3,2,1,7,4,6,2,6,

%U 3,6,1,6,2,3,2,1,2,8,3,1,2,1,3,1,2,7,1

%N Lexicographically least sequence over the positive integers with the property that there are no two consecutive blocks of the same length and same sum.

%H Alois P. Heinz, <a href="/A242923/b242923.txt">Table of n, a(n) for n = 1..10000</a>

%F a(9) = 2 because choosing a(9) = 1 gives the blocks (3,1,2) and (1,4,1), which are both of length 3 and sum to 6.

%p b:= proc(n) option remember; local i, t, ok;

%p if n<2 then n

%p else for t from 1+b(n-1) do ok:=true;

%p for i to n/2 while ok

%p do ok:=b(n-2*i)+t <> 2*b(n-i) od;

%p if ok then return t fi

%p od

%p fi

%p end:

%p a:= n-> b(n) -b(n-1):

%p seq(a(n), n=1..120); # _Alois P. Heinz_, May 26 2014

%t b[n_] := b[n] = Module[{i, t, ok}, If[n<2, n, For[t = 1+b[n-1], True, t++, ok = True; For[i = 1, i <= n/2 && ok, i++, ok = b[n-2i] + t != 2b[n-i]]; If[ok, Return[t]]]]];

%t a[n_] := b[n] - b[n-1];

%t Array[a, 120] (* _Jean-François Alcover_, Nov 13 2020, after _Alois P. Heinz_ *)

%Y First difference of A242921.

%Y Cf. A191818.

%K nonn

%O 1,2

%A _Jeffrey Shallit_, May 26 2014