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
1 changed files with 3 additions and 3 deletions

View File

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