How many ternary strings with at most k ones and k minus ones
Consider for with the following set
I want to determine the cardinality of S. I know that there are number of strings with exactly k ones and likewise number of strings with exactly k ones and likewise number of strings with exactly k minus ones. But I have to remove the strings where we have for example k one's and more than k minus ones. I think I have to use the Principle of Inclusion and Exclusion. I'm REALLY stuck on this problem. Hope someone can help me.
Example: let and . Then we have
and so we have .