OFFSET
1
COMMENTS
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.)
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.
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
LINKS
Daniel Forgues, Table of n, a(n) for n = 1..50000
MATHEMATICA
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 *)
CROSSREFS
KEYWORD
sign
AUTHOR
Daniel Forgues, Mar 01 2017
STATUS
approved