# "To be or not to be" permutations

The question is, how many ways to rearrange letters of "to be or not to be that is the question" so, that we would get:

• 1 8-letter word
• 1 4-letter word
• 2 3-letter words
• 6 2-letter words

Words can be in any order, and of course doesnt have to mean anything. ie "ot eb ro question to be that is not the" is suitable variant.

I figure that first step would be to count all permutations of string(len 39) - $39!$

Then

• space count 9
• t count 7
• o count 5
• b count 2
• e count 4
• r count 1
• n count 2
• h count 2
• a count 1
• i count 2
• q count 1
• u count 1
• s count 2

And since letters can actually be in any order(lets forget spaces) - $39!/(7!5!2!4!1!2!2!1!2!1!1!2!)=39!/(7!5!2!4!2!2!2!2!)$

But spaces puzzle me, those can be in any order, but there is restriction of not putting space as a first letter, as a last letter and no doublespaces.

How to formalize those restrictions?

Count permutations of the letters separately, ignoring where the spaces are, and then multiply with the number of permutations of the word lengths multiset $\{2,2,2,3,2,2,4,2,3,8\}$.