Given symbols $x$ and $y$, how many sequences of length $n$ are there such that the last symbol is $y$, there are at least as many $y$'s as $x$'s? Given symbols $x$ and $y$, how many sequences of length $n$ are there such that the last symbol is $y$, there are at least as many $y$'s as $x$'s?  
Is there a closed formula?
Any help would be appreciated.
 A: The answer will look a little different if $n$ is even than if $n$ is odd. Assume that $n\ge 2$, since tiny $n$ are easy to deal with. 
Let $n\ge 2$ be even, like $20$. Then we want $0$ to $9$ $x$'s in the first $19$ positions.  This is by symmetry the same number as the number of ways to have $0$ to $9$ $y$'s in the first $19$ positions.  But the sum of these ways is the number of subsets of a $n-1$-element set. Thus there are 
$$\frac{1}{2}2^{n-1}=2^{n-2}$$
 ways to select where the $x$'s will go.  
Let $n\ge 3$ be odd, like $21$. Then we want $0$ to $10$ $x$'s in the first $20$ positions. The total number of subsets of our set of $n-1$ positions is $2^{n-1}$. The number $w$ of ways to have fewer $x$'s than $y$'s is the same as the number of ways to have fewer $y$'s than $x$'s. So
$$2w+\binom{n-1}{(n-1)/2}=2^{n-1}.$$
It follows that $w=2^{n-2}-\frac{1}{2} \binom{n-1}{(n-1)/2}$.
Thus the number of ways to have at most one more $x$ than there are $y$'s in the first $n-1$ entries is
$$2^{n-2}+\frac{1}{2} \binom{n-1}{(n-1)/2}.$$
Remark: The intuition did not come from $x$'s and $y$'s, but from $H$ and $T$, heads and tails. And actually the figuring out what happens was done using probabilities: translating to the count came later. 
