Created
February 29, 2016 14:12
-
-
Save DownGoat/abd8cbf4a18c9647f184 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/python3.4 | |
import sys | |
import operator | |
import functools | |
def prob3(amount, pile): | |
return functools.reduce(operator.mul, [(amount - x) / (pile - x) for x in range(0, 3)]) * 100 | |
def prob2(amount, pile): | |
other = pile - amount | |
p1 = (amount / pile) * ((amount - 1) / (pile - 1)) * (other / (pile - 2)) | |
p2 = (amount / pile) * (other / (pile - 1)) * ((amount - 1) / (pile - 2)) | |
p3 = (other / pile) * (amount / (pile - 1)) * ((amount - 1) / (pile - 2)) | |
return (p1 + p2 + p3) * 100 | |
def prob1(amount, pile): | |
other = pile - amount | |
p1 = (amount / pile) * (other / (pile - 1)) * ((other - 1) / (pile - 2)) | |
p2 = (other / pile) * (amount / (pile - 1)) * ((other - 1) / (pile - 2)) | |
p3 = (other / pile) * ((other - 1) / (pile - 1)) * (amount / (pile - 2)) | |
return (p1 + p2 + p3) * 100 | |
CARDS = 17 | |
DRAW_PILE = int(sys.argv[1]) | |
LIB_DRAW = int(sys.argv[2]) | |
print("Draw Pile: {0}".format(DRAW_PILE)) | |
print("LIB Draw Pile: {0}\n\n".format(LIB_DRAW)) | |
print("###LIB CARDS###") | |
lib_pos_3 = prob3(LIB_DRAW, DRAW_PILE) | |
print("3 LIB cards: {0}".format(lib_pos_3)) | |
lib_pos_2 = prob2(LIB_DRAW, DRAW_PILE) | |
print("2 LIB cards: {0}".format(lib_pos_2)) | |
lib_pos_1 = prob1(LIB_DRAW, DRAW_PILE) | |
print("1 LIB cards: {0}".format(lib_pos_1)) | |
print("\n###FACIST CARDS###") | |
facist_pos_3 = prob3(DRAW_PILE - LIB_DRAW, DRAW_PILE) | |
print("3 FACIST cards: {0}".format(facist_pos_3)) | |
print("2 FACIST cards: {0}".format(100 - lib_pos_1)) | |
print("1 FACIST cards: {0}".format(100 - lib_pos_2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment