I would like to get a general expression for arranging n letters such that any similar letters in them never come together (except SPACE).
For example :
Lets take AABBCCC and three spaces(represented by '-'). So we have 10 spaces to arrange these. Now the number of ways we can arrange this so that never two A's or two B's or two C's come next to each other, but the SPACES can come together and two letters seperated by a space are not considered together (So we can have two A's together if there is a SPACE in between them).
So we can arrange as ABC---ACBC, CA-BCA--BC, A-ABC-CB-C, etc. But can't arrange as CA-BBC-A-C (B together), A-B--CABCC (C together), AAB---CCBC (A & C together), etc.
It could be solved for every solution seperately, but I require a general expression for this such that we feed the total number of terms (10 in e.g.), no of distinct entities with the number of repetitions(in e.g. we have 2 A's, 2 B's and 3 C's and 3 SPACES) and get the solution.
This is because I need to make a computer program as my project on this topic and I am unable to figure out a way for this.
Any help would be appreciated.