OFFSET
1,2
COMMENTS
The original source for this sequence was the problem 'perlbrac' in the 2009 USACO Holiday Contest (http://ace.delos.com/HOL09) which asked contestants to find the longest sequences of this type that they possibly could. a(n) is the upper bound on the length of such a sequence for a given n.
FORMULA
Replacing each element x of a solution by ((a x + b) mod n) also gives a solution if gcd(a,n) = 1. - Bert Dobbelaere, Apr 18 2019
EXAMPLE
For example, in the sequence 0, 1, 2, 1, 0, 1, 2 (length 7) consisting of integers in the range [0..2], no two adjacent segments of equal length (e.g., 0, 1, 2 and 1, 0, 1) have the same sum modulo 3. There is also no longer sequence with this property, hence a(3) = 7.
From Bert Dobbelaere, Apr 18 2019: (Start)
Lexicographically earliest solutions represented as digit strings.
n a(n)
1 1 0
2 3 010
3 7 0102010
4 16 0130102013101201
5 33 010214243213143040102142432131430
6 35 01024021240241402401024021240241402
7 47 01021614636032312426404301021614636032312426404
8 61 0120135461316135364357463523745020571465756571764713467127313
(End)
CROSSREFS
KEYWORD
hard,more,nonn
AUTHOR
Brian Bi (bbi5291(AT)gmail.com), Jun 19 2009
EXTENSIONS
Definition and source corrected by Brian Bi (bbi5291(AT)gmail.com), Sep 19 2009
a(7)-a(8) from Bert Dobbelaere, Apr 18 2019
STATUS
approved