It is a task of your code to figure out when it should count the Aces as 11 or 1
When choosing their values, the priority is that the sum is the closest to 21, without exceeding
Example
if the initial hand is
"A", "A" = 22, with 22 points the player should lose, however, since "A" may also worth "1" the new value of the hand should be
"A", "A" = 12, 12 since one of the "A" worth 1, now let's suppose the player hit a new card(draw a card) and got a "10"
"A", "A", "10" = 22, again, with 22 points the player should lose, but one of the Aces still worth 11, so it is changed to 1
"A", "A", "10" = 12, If the player hits again and get a "K"
"A", "A", "10", "K" = 22, now the player lose since both "A" worth 1, but the player has over 21 points.
As you can see in comments further below, the source of the function feedback was hidden on purpose. I am not the author of this kata, but your assumption is right.
.
Thanks man, free points! ;)
Understanding the kata is the kata.
.
irony
And now you are a 1kyu! awesome!
What language?
Same problem with me..how did you managed?
.
@isqua Would you mind changing the 'should handle basic cases' to use
Test.asserEquals
in javascript too?Negative numbers should be handled as regular, - * - = + .
Not an issue.
.
It is a task of your code to figure out when it should count the Aces as 11 or 1
When choosing their values, the priority is that the sum is the closest to 21, without exceeding
Example
if the initial hand is
"A", "A" = 22
, with 22 points the player should lose, however, since "A" may also worth "1" the new value of the hand should be"A", "A" = 12
, 12 since one of the "A" worth 1, now let's suppose the player hit a new card(draw a card) and got a "10""A", "A", "10" = 22
, again, with 22 points the player should lose, but one of the Aces still worth 11, so it is changed to 1"A", "A", "10" = 12
, If the player hits again and get a "K""A", "A", "10", "K" = 22
, now the player lose since both "A" worth 1, but the player has over 21 points.As you can see in comments further below, the source of the function
feedback
was hidden on purpose. I am not the author of this kata, but your assumption is right.Loading more items...