-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
- Loading branch information
1 parent
91078a7
commit 3c49977
Showing
1 changed file
with
8 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
# --8<-- [start:solution1] | ||
from math import factorial | ||
from fractions import Fraction | ||
from math import factorial | ||
|
||
|
||
def calc_prob(): | ||
prob = 4 | ||
for i in range(13): | ||
print(i, 13-i) | ||
numerator = (13 - i) * Fraction(factorial(39 - 3 * i), factorial(3) * factorial(36 - 3 * i)) | ||
denominator = Fraction(factorial(52 - 4 * i), factorial(4) * factorial(48 - 4 * i)) | ||
print(i, 13 - i) | ||
numerator = (13 - i) * Fraction( | ||
factorial(39 - 3 * i), factorial(3) * factorial(36 - 3 * i) | ||
) | ||
denominator = Fraction( | ||
factorial(52 - 4 * i), factorial(4) * factorial(48 - 4 * i) | ||
) | ||
prob *= Fraction(numerator, denominator) | ||
return prob |