Skip to content

Instantly share code, notes, and snippets.

@qwertysmack
Created February 8, 2016 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qwertysmack/8be5e38c7cb26a0ed2ab to your computer and use it in GitHub Desktop.
Save qwertysmack/8be5e38c7cb26a0ed2ab to your computer and use it in GitHub Desktop.
Calculate maximum available snooker break
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