Le nombre de tels mots est donné par inclusion-exclusion :

["Title: Understanding How Inclusion-Exclusion Determines the Number of Distinct Words", "Introduction\nIn combinatorics and algebra, counting the number of distinct elements in overlapping sets is a fundamental challenge. One powerful tool used to solve this problem is the inclusion-exclusion principle, particularly when calculating the size of sets defined by unique combinations—such as the number of distinct words formed from a given collection of character elements. This article explores how inclusion-exclusion helps determine the exact count of such unique words, highlighting both the theory and real-world applications.", "---", "### What Is the Inclusion-Exclusion Principle?", "The inclusion-exclusion principle is a counting technique that counts the number of elements in the union of multiple overlapping sets by successively adding and subtracting intersections to avoid double-counting.", "Formally, for sets ( A_1, A_2, \dots, A_n ):\n[\n|A_1 \cup A_2 \cup \dots \cup A_n| = \sum |A_i| - \sum |A_i \cap A_j| + \sum |A_i \cap A_j \cap A_k| - \cdots + (-1)^{n+1}|A_1 \cap A_2 \cap \cdots \cap A_n|\n]", "---", "### How Including-Exclusion Applies to Word Counting", "When generating distinct words from a multiset of letters, we often face repetitions among characters. Counting unique permutations without overcounting requires recognizing how different character groupings (subsets) form overlapping distributions.", "Consider constructing words from a multiset like letters with repetitions—say, "AAAB":\n- We have 3 A’s, 1 B.\n- Total permutations without distinctness: ( \frac{4!}{3!1!} = 4 )", "But suppose we define sets based on how many A’s appear:\n- ( A_1 ): words using exactly 1 A\n- ( A_2 ): words using exactly 2 A’s\n- ( A_3 ): words using exactly 3 A’s", "Using inclusion-exclusion, we compute how many unique words arise by counting exactly how many A’s are used—this directly avoids double-counting configurations with identical letter groupings.", "---", "### Step-by-Step Example", "Suppose the multiset is {A, A, B, C}.\nLet’s determine the number of unique algebraic expressions (words) formed by selecting subsets of letters (each expression uses a subset, no repetition unless original occurs multiple times).", "Let’s define sets:\n- ( S_0 ): words with 0 A’s\n- ( S_1 ): words with 1 A\n- ( S_2 ): words with 2 A’s (only possible one way, since only two A’s available)", "Each set corresponds to a unique grouping based on character count. By inclusion-exclusion:", "- Counting words with at least one A:\n ( |S_1| + |S_2| ), but avoiding overcount appears from set intersection logic.\n- Precise calculation uses inclusion-exclusion over overlapping character roles:\n [\n \ ext{Total distinct words} = \sum_{k=1}^{m} (-1)^{k+1} \sum_{\ ext{all k-subsets } T} \ ext{valid words using exactly } T\n ]\nThis ensures each arrangement appears only once.", "---", "### Mathematical Intuition Behind Uniqueness", "The inclusion-exclusion formula precisely captures how many ways subsets of characters form distinct outputs. It accounts for overlaps—like when multiple A’s are indistinguishable—and adjusts counts to reflect true multiplicity. This avoids errors introduced by naive product rules.", "---", "### Real-World Applications", "1. Cryptography:\n Analyzing unique keys or ciphertext permutations using multiset character analysis.\n2. Natural Language Processing:\n Modeling anagram counts or deduplicating generated text fragments.\n3. Operations Research:\n Optimization tasks where item repetition matters but uniqueness is essential.\n4. Genetics:\n Calculating distinct genetic sequences under identical nucleotide frequency.", "---", "### Practical Takeaways", "- The inclusion-exclusion principle is essential when counting distinct arrangements or combinations with repeated elements.\n- It enables accurate enumeration of unique words, permutations, or combinations by systematically excluding overcounts.\n- Whether in code generation, data deduplication, or combinatorics, mastering inclusion-exclusion demystifies complex counting problems.", "---", "Conclusion\nThe inclusion-exclusion principle provides a rigorous foundation for determining the number of distinct words formed from overlapping letter sets. By carefully accounting for intersections and dependencies, it ensures accurate counts that underpin numerous computational and theoretical advances. Next time you generate permutations or analyze combinatorial spaces, remember: inclusion-exclusion keeps your results unique and reliable.", "---", "Keywords: inclusion-exclusion principle, counting distinct words, multiset permutations, combinatorics, unique arrangements, algebra and combinatorics, mathematical counting, word formation, algorithmic counting.", "---", "Explore deeper: Toolkits like generating functions and advanced combinatorics expand on inclusion-exclusion, enabling even finer control over complex word-counting scenarios."]









