Created
September 29, 2022 21:08
-
-
Save lwiecek/60e0c92de7ffc5a2f1054ac8f6cffbb8 to your computer and use it in GitHub Desktop.
blackjack
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
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