Created
February 8, 2016 21:39
-
-
Save qwertysmack/8be5e38c7cb26a0ed2ab to your computer and use it in GitHub Desktop.
Calculate maximum available snooker break
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
def max_break(reds_remaining, colour=0): | |
""" | |
:param reds_remaining: number of reds left on table | |
:param colour: (optional) point value of current colour | |
:return: return maximum available snooker break | |
""" | |
colours = sum(range(2, 8)) | |
if reds_remaining > 0: | |
reds_and_blacks = reds_remaining * 8 | |
return reds_and_blacks + colours + colour | |
elif reds_remaining == 0 and colour == 0: | |
print "please enter current colour value" | |
else: | |
return sum(range(colour, 8)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment