When 2 lines in a poem ends with the same (or similiar) sound we have a rhyme. When studying poetry at highschool we were taught that there exists only 4 rhyme types, however I suspect they are much more!
We choose to encode rhymes as single characters so the following poem:
My wagon sinking under grass so tall
The flowery petals in foam on me fall
has a A-A rhyme.
2 lines should not be more far from each other than another 2 lines because otherwise we cannot "hear" the rhyme.
So we can view a 10 lines poem like a sequence of 10 characters, where each character has no more than any other 2 characters before a identical one occurs
In example a valid sequence is:
ABACBCDBDB
But a not valid sequence is:
AAABBBBBB A
Because the last "A" is not "rhymed" with anything (no nearby A).
Some other valid sequences
AAAAAAAAAA
AABBCCDDEE
ABBABBBBBB
Since we have 10 lines, we cannot have more than 5 characters, so how many rhymes are really possible in 10 lines?
Let us consider this by solving the more general question of how many rhyme schemes are possible for an $n$ line poem. To do this, we note the following rule:
So, for instance the poem $ABBABB$ can be extended by adding an $A$ or $B$ or $C$, since $A$ and $B$ have already appeared. In particular, we may characterize . For instance, if the poem terminates in $XXX$ where $X$ is some rhyme, we may either append $X$ to it, or some new rhyme $Y$. We will denote this relation by saying $$XXX\rightarrow XXX\text{ or }XXY$$ since a suffix of $XXX$ may be transformed to either $XXX$ or $XXY$ by appending a character. We will note that when using variables, we have $XXY\cong YYX$ since each defines the same partition, just with the variable characters $X$ and $Y$ switched. We can write out all of the evolution rules as follows: $$XXX\rightarrow XXX \text{ or }XXY$$ $$XXY\rightarrow XYX \text{ or }XYY\text{ or }XYZ$$ $$XYX\rightarrow YXX\cong XYY \text{ or }YXY\cong XYX\text{ or }YXZ\cong XYZ$$ $$XYY\rightarrow YYX\cong XXY \text{ or }YYY\cong XXX\text{ or }YYZ\cong XXY$$ $$XYZ\rightarrow YZX\cong XYZ\text{ or }YZY\cong XYX \text{ or }YZZ\cong XYY \text{ or }YZW\cong XYZ.$$ Note that knowing which of the rules we use at each step suffices to characterize the poem. For instance, the end of the string $ABBABB$ is of the form $XYY$. If we apply the rule $XYY\rightarrow YYZ$ we get $ABBABBC$. Then, since $YYZ\cong XXY$, the end of the string is still of the form $XXY$. If we then applied the rule $XXY\rightarrow XYX$, we would get $ABBABBCB$. We may see that this will always be well-defined, since every character $X,\,Y,\,Z,\,W$ has a specific assigned rhyme based on the suffix or is assigned to a new rhyme.
We can collect the information on the transitions by considering that all the possible suffixes are of the forms $$XXX,\,XXY,\,XYX,\,XYY,\,XYZ.$$ We can write how many transitions from each of these suffixes to each other suffix and collect this in a matrix: $$M=\begin{bmatrix}1 & 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 1 & 1 \\ 0 & 0 & 1 & 1 & 1 \\ 1 & 2 & 0 & 0 & 0 \\ 0 & 0 & 1 & 1 & 2 \end{bmatrix}$$ For instance, the $2$ in the fourth row of the second column indicates that there are two transitions from a suffix of the fourth form $XYY$ to a suffix of the second form $XXY$ (in particular, the transformations to $YYX$ or $YYZ$ do this). Now, let $V$ be the vector $(1,1,1,1,1)$. We can show that the product $$VM^{k}$$ is a vector whose components list how many $3+k$ line poems have a suffix of each of the given forms. For instance for $k=0$, the vector $(1,1,1,1,1)$ tells us that there is one three line poem with each suffix. For $k=1$ we get the vector $(2,3,3,3,4)$ meaning that there are two four line poems ending with $XXX$ and four ending with $XYZ$ and $3$ ending with every other suffix. For $k=7$ we get the vector $(1545, 2609, 3420, 3420, 4964)$ and the sum of the entries is $15958$, meaning there are $15958$ rhyme patterns for ten line poems.