Skip to content

Instantly share code, notes, and snippets.

@lwiecek
Created September 29, 2022 21:08
Show Gist options
  • Save lwiecek/60e0c92de7ffc5a2f1054ac8f6cffbb8 to your computer and use it in GitHub Desktop.
Save lwiecek/60e0c92de7ffc5a2f1054ac8f6cffbb8 to your computer and use it in GitHub Desktop.
blackjack
def blackjack(*abc):
val = sum(abc)
if val <= 21:
return val
if 11 in abc:
val -= 10
if val <= 21:
return val
return 'BUST'
assert blackjack(5, 6, 7) == 18
assert blackjack(9, 9, 9) == 'BUST'
assert blackjack(9, 9, 11) == 19
assert blackjack(11, 11, 11) == 'BUST'
assert blackjack(10, 10, 11) == 21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment