Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
In Blackjack, each ace can be either 1 or 11, and we want the highest score that does not exceed 21. If we count both aces as 11, we get
11 + 11 = 22which busts. Therefore, we have to demote one ace from 11 to 1, giving us1 + 11 = 12. We can't make both aces worth 10 each because aces can only be 1 or 11, never 10. The code starts optimistically with both aces as 11 (score=22), then realizes we're busted and demotes one ace by subtracting 10 score (score = 12), which is the highest valid score we can get.Carefully check your logic, you might be calculating ace values incorrectly or not demoting them when you bust
Your code is returning 46 because it's not demoting the Ace from 11 to 1. Make sure your logic converts Aces from 11 => 1 when the score is busted, even if you'll still be over 21. You want the minimum bust, not just any bust.
Done in this fork
xshould equalymeans that your code returnedx, but the test expected your code to returny. You might be reading that backwards.score_hand(['A','A']) expected 20 not 12
The 'A' is variable, basically always equal to 1 unless you need the extra 10 then you can tack it on (10 that is). There is only a few cases where you want the 'A' to be 11.
[ 'A', '7', 'K', '8', '10' ]
expected 46 to equal 36
is this right?
Approved
python new test framework
The aces part left my brain smoking lol........
i thought all aces are considered 1 point. I have already solved the problem, thanks
It's in the instructions:
You choose how to count it to your benefit. Google "Blackjack rules" or click over the link to Wikipedia in the description.
why the {'8', 'A', 'A'} combination is 20 but not 10? where is can read about this rules?
Simpler than I thought
Thanks for this interesting kata anyway :)
Loading more items...