login
A different representation (1 mapped to 1, 2 mapped to -1) of the Linus sequence (A006345): a(n) "breaks the pattern" by avoiding the longest doubled suffix.
5

%I #40 Oct 13 2017 00:28:27

%S 1,-1,1,1,-1,-1,1,-1,1,1,-1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,1,1,-1,-1,

%T 1,1,1,-1,1,1,-1,-1,1,-1,1,1,-1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,1,1,

%U -1,-1,1,-1,-1,-1,1,1,-1,1,-1,-1,1,1,-1,-1,-1,1,-1,-1,1,1,-1,1,-1,-1,1,-1,1,1,-1,-1,1,-1,-1,-1,1,1,-1,1,-1,-1,1,1

%N A different representation (1 mapped to 1, 2 mapped to -1) of the Linus sequence (A006345): a(n) "breaks the pattern" by avoiding the longest doubled suffix.

%C Sequence of forward or backward steps of a walker/dancer who wants to avoid as much as possible repeating his/her step pattern. To find a(n), consider either a 1 (step forward) or a -1 (step backward). For each, find the longest repeated suffix, that is, for each of a(n) = 1, -1, find the longest sequence s (of steps) with the property that the sequence a(1), ..., a(n) ends with ss. Use the digit that results in the shorter such suffix. a(1) = 1. The empty sequence of length 0 is the shortest possible suffix and is trivially doubled. Note that this doesn't result in exactly Linus's choices. (See comment from K. Ramsey, kramsey(AT)aol.com on A006345.)

%C There appears to be (on average) slightly more 1 (forward steps) than -1 (backward steps): the partial sums (A283144) keep slowly increasing (as a global trend), though non-monotically.

%C On average, it seems that (# of 1s up to n) - (# of -1s up to n) -> infinity as n -> infinity (as O(log n)?). - _Daniel Forgues_, Apr 10 2017

%H Daniel Forgues, <a href="/A283131/b283131.txt">Table of n, a(n) for n = 1..50000</a>

%F a(n) = 3 - 2*A006345(n) = 1 - 2*A157238(n).

%t a[1] = 1; a[2] = -1; suffix[lst_] := If[MatchQ[lst, {___, b__, b__}], lst /. {___, b__, b__} :> {b}, {}]; a[n_] := a[n] = Module[{aa, lg1, lg2}, aa = Array[a, n - 1]; lg1 = suffix[Append[aa, 1]] // Length; lg2 = suffix[Append[aa, -1]] // Length; If[lg1 <= lg2, 1, -1]]; Array[a, 105] (* _Robert G. Wilson v_, Mar 19 2017 after _Jean-François Alcover_ in A006345 *)

%Y Cf. A006345, A157238, A283144 (partial sums).

%K sign

%O 1

%A _Daniel Forgues_, Mar 01 2017