Fix argument order in multinomial() example (gh-132557)

This commit is contained in:
Raymond Hettinger 2025-04-15 11:50:52 -05:00 committed by GitHub
parent e94d168473
commit 818b6a9ead
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1129,8 +1129,8 @@ The following recipes have a more mathematical flavor:
def multinomial(*counts): def multinomial(*counts):
"Number of distinct arrangements of a multiset." "Number of distinct arrangements of a multiset."
# Counter('abracadabra').values() -> 5 2 1 1 2 # Counter('abracadabra').values() → 5 2 2 1 1
# multinomial(5, 2, 1, 1, 2) → 83160 # multinomial(5, 2, 2, 1, 1) → 83160
return prod(map(comb, accumulate(counts), counts)) return prod(map(comb, accumulate(counts), counts))
@ -1736,7 +1736,7 @@ The following recipes have a more mathematical flavor:
>>> ''.join(it) >>> ''.join(it)
'DEF1' 'DEF1'
>>> multinomial(5, 2, 1, 1, 2) >>> multinomial(5, 2, 2, 1, 1)
83160 83160
>>> word = 'coffee' >>> word = 'coffee'
>>> multinomial(*Counter(word).values()) == len(set(permutations(word))) >>> multinomial(*Counter(word).values()) == len(set(permutations(word)))