Rust - Basic combinatorics + some number theory
Basic permutation with repetition to find possible anagrams of each word. The answer is the product of that modulo 10^9 + 7\n\nThe challenge lies in the actual 
Basic permutation with repetition to find possible anagrams of each word. The answer is the product of that modulo 10^9 + 7\n\nThe challenge lies in the actual computation of the factorials modulo a large number, specifically in dealing with the divisors. Using Fermat\'s little theorem it\'s possible to compute the modular inverses (invmod in the code) so we can just multiply everything:\n# Code\n```\nconst P: usize = 1_000_000_007;\n\nimpl Solution {\n    pub fn count_anagrams(s: String) -> i32 {\n        // computes x such that ax = 1 (mod p)\n        // leverages Fermat\'s little theorem: a^(p-1) = 1 (mod p)\n        // IOW x = a^(p-2) % p\n        fn invmod(mut a: usize, p: usize) -> usize {\n            let mut res = 1;\n            let mut curr = a;\n            let mut power = p - 2;\n            while power > 0 {\n                if power & 1 == 1 { \n                    res = (res * curr) % p;\n                }\n                power >>= 1;\n                curr = (curr * curr) % p;\n            }\n            res\n        }\n        fn anagrams(word: &str) -> usize {\n            let (mut anagrams, mut counts) = (1_usize, vec![0; 128]);\n            for b in word.bytes() {\n                counts[b as usize] += 1;\n            }\n            (2..=word.len()).for_each(|i| { anagrams = (anagrams * i) % P; });\n            for c in counts {\n                (2..=c).for_each(|i| { anagrams = (anagrams * invmod(i, P)) % P; })\n            }\n            anagrams\n        }\n        s.split_ascii_whitespace()\n            .fold(1_usize, |a, word| (a * anagrams(word) % P)) as i32\n    }\n}\n\n```
['Rust']