On a tangent to a problem I've been working on, I've run into a combinatorial/partition-theoretic problem that I wondered if anyone had run into before. 


Let $N$ be a positive integer, and *ad-hoc*-ly call an (ordered) non-negative partition of $N$ into exactly $N$ parts 
$$
N=n\_1+n\_2+\cdots+n\_N
$$
*valid* if



* $0\leq n\_i\leq 2$ for all $i$; and


* $\sum\limits\_{k=1}^i n\_k<i$ for all $i<N$.



So these are something like partitions where the running total is always bounded by the number of terms added thus far. (So the running average of the elements of the partition is less than 1.) In particular, this forces $n\_1=0$ and $n\_N=2$.


I'm more interested in whether this notion of a "valid" partition has arisen previously in the literature than an explicit count of how many of them there are for a given $N$ (probably a reasonably straight-forward linear recurrence or something), so any such references would be appreciated.



Partitions into 0,1, and 2 with a partial sum condition.
This is [A168049](http://oeis.org/A168049) or, with slightly different indexing, the [Motzkin numbers](http://oeis.org/A001006). 


The general question of counting nondecreasing sequences which stay below the diagonal is very common in combinatorics and goes by the name Lukasiewicz words. Stanley has a good discussion Enumerative Combinatorics II, Sections 5.3 and 5.4 and I [wrote up some notes](http://www.math.lsa.umich.edu/~speyer/LagrangeInversion.pdf) when I taught this material last Fall. 


In general, to count Lukaswiecz sequences from $(0,0)$ to $(n,n)$, one uses the generating function relation
$$P = x W(P(x))$$
where $W = \sum w\_k x^k$ and sequences are counted with weight $w\_0^{a\_0} \cdots w\_i^{a\_i}$, where $a\_i$ is the number of times you increase by $i$. In your case, you want to permit increases by $(0,1,2)$, and not keep track of how many of each you are using, so you want to look at
$$P = x(1+P+P^2)$$
which has the solution $P(x) = (-1 + x + \sqrt{1 - 2 x - 3 x^2})/(2 x)$. Unlike the Catalan case, I don't think you can get any simpler than this.


To make my notes match up with your indexing, discard the final $2$ from your sequence, and take your $n\_i$ to be my $d\_i$, if I am not mistaken.


To add a bit of self promotion, call your sequence $a(n)$. It starts out $1$, $1$, $2$, $4$, $9$, $21$, $51$ ... Define $b(n)$ so that $a(n) = b(n) + b(n+1)$. So the $b$'s start out $1$, $0$, $1$, $1$, $3$, $6$, $15$, $36$ ... That sequence is [A005043](http://oeis.org/A005043) and I [blogged about it](http://sbseminar.wordpress.com/2010/10/06/a-peculiar-numerical-coincidence/).


