How many different ways a string of '$n$' length can be divided into '$r$' number of non-overlapping non-empty segments?

94 Views Asked by At

I was trying to figure out some computation regarding string operations. Suppose, I have a string of length $n$ and I want to split the string into $m$ number of non-overlapping segments. How many different ways, I can do that? Let take an example to be more specific and understandable

Assume a string ($w$) of length $n$. Say, here $n=12$. So let $w$ be like = $ABCDEFGHIJKL$. Now, I select $m=5$, So, I can split the string $w$ into 5 non-overlapping segments while the position of the character in the string can not be interchanged.

There is another condition that the length of each segment must be $\geq 1$. So, my 5 segments can hold the following length as follows
{1,1,1,1,8}
{1,1,1,2,7}
{1,1,1,3,6}
.

.

. continued. From the above, you can see that there is no repetition, overlapping and all segments are non-empty.

So, is there any mathematical permutation/combination formula to figure out the total number of ways I can partition the string in the non-overlapping, non-empty segments with no repetition? I will be pleased and indebted to your kind help. Thank you.