Sequences with 3 letters For a positive integer $n$ I would like to construct long sequences consisting of    0, 1 and 2's such that for any two subsequences consisting of $n$ consecutive elements the number of 0's , 1's or 2's are different.
Since there are $\binom{n+2}{2}$ different triples of nonnegative integers summing up to $n$ such a sequence has length at most $\binom{n+2}{2}+n-1$. For $n\leq 3$ it is possible to construct such sequences of this length:
$$\begin{eqnarray}
n=1&:& 012\\
n=2&:& 0112200\\
n=3&:& 011122200012
\end{eqnarray}$$
For $n\geq 4$ however I am unable to construct such sequences nor proving that there does not exist one. For given $n$ what is the maximal length of such a sequence? How can we construct it? I would be grateful for both the cases where $n$ is small as well as the asymptotics $n\rightarrow \infty $. 
 A: Here is a sketch of a proof that there are no such complete sequences for $n>4$.
Consider the graph where the vertices are the triples of nonnegative integers that sum to $n$ and construct
an edge between two vertices when one can get  from one to the other by incrementing one element and decrementing another.
This graph looks like a triangle tiled by smaller triangles, in particular it is planar, so two paths cannot cross without intersecting.
A solution of the original problem induces a hamiltonian path on this graph.
Now look at the extreme vertices of the triangle $(0,0,n)$, $(0,n,0)$, and $(n,0,0)$.  In the original problem, a path of length n that starts
or ends at one of these points must end or start at the opposite edge.  As the induced path cannot cross itself, if the three vertices are all
on a path, they must occur adjacent to each other, so the path looks like wlog $*0^n1^n2^n*$.  This means that two sides of the triangle are occupied so
neither the prefix nor the suffix can be longer than $(n-1)$, and if $n>4$ there are more than $2n-2$ elements that don't lie on the two edges.
ADDED:
I have translated this problem into a somewhat annoying javascript toy.  This makes it somewhat easier to see the structure in Robert Israel's solutions.  I am fairly convinced (but still cannot prove) that the size of the optimal solution grows quadratically, and I would not be surprised if the optimal solution covered all but a linear in $n$ number of combinations.
A: It is perhaps equally natural to consider sequences wrapping around cyclically, like a de Bruijn sequence. In that case there is a simple reason why it won't work for $n=3$.
Clearly 000111222, or cyclically
$$\begin{eqnarray*} 0 & \,0\,0 & 1\\
2&&1\\
2&2&1\end{eqnarray*}$$
must be a homomorphic image of our cycle.
The patterns we need are (considered as multi-sets):
$$000,
001,
011,
111,
112,
122,
222,
220,
200$$
which are all present in the cycle. The one that is missing is
012. There is nowhere to insert one digit to achieve the pattern 012 without losing other patterns.
(On the other hand, in a binary alphabet you could just do $0^n1^n$ and it works.)
