Ad
  • Custom User Avatar
  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    As mentioned by several commenters below, as of this message, the Java version of this Kata is broken. In order to pass the tests, if you compute any values that exceed the max value for an int, instead just put 2147483647 (the max value for an int) in the applicable index of the array.

  • Default User Avatar

    Seven cards are placed on a table. Each card has an O on one side and an X on the opposite side. Three of the cards have the X side facing up, and the other four have the O side facing up, however you can't see which cards are which. Your task is to divide the cards into 2 piles that each contain an equal number of cards with an X facing up. Although you cannot see the cards, you are allowed to flip each card or leave it as it is. The cards are labelled "C1" through "C7". Return an array containing two subarrays which, between the two of them, contain all seven cards, either as they are (i.e. "C3") or flipped (i.e. "C3.flip").

    This is a puzzle more than a programming challenge. If you are confused, I would advise experimenting by dividing the cards into two piles of varying sizes, and working through the possibilities for what the end results will be by flipping different amounts of cards, keeping in mind that you don't know which side is originally facing up on each card.

  • Default User Avatar
  • Default User Avatar

    A player only wins with blackjack if the croupier does not also have blackjack. If everyone has blackjack, then the players all lose. The croupier is not considered a player, so you never return them in the list of winners.

  • Default User Avatar

    You are showing ['A', 'A', '7', '7', 'K'] as the hand for the croupier, but the croupier should always only start than 2 cards. If the croupier is starting with more than 2 cards, then I agree that the test case is incorrect, however if you added the two '7's and the 'K' yourself, then that is a mistake on your part.

    Assuming that the croupier starts with ['A', 'A'], this would add up to 22 if both are valued at 11, so in this case, one of the 'A's would have a value of 1, and the other would have a value of 11, for a total of 12. After this, the croupier would draw the first '7', which would bring their score to 19. Since 19 >= 17, the croupier does not draw any additional cards, and their score is higher than player 1's score of 18, so player 1 loses. Player 2 and player 3 both have scores over 21, so neither of them win either.

  • Default User Avatar

    In the case above, only player1 has black jack. Black Jack means only two cards, one being an ace ('A'), and the other any card that is worth 10 points. In the case above, the croupier starts with an '8' and a '2', adding to 10, so they will draw another card and get an ace ('A'), which makes their total score 21. Even though they have 21, they got there with 3 cards, not 2, so it is not considered Black Jack.

  • Default User Avatar

    I'm not sure if the rules have been updated since you wrote this, but they are currently in the description. They are as follows:

    1. If a player has blackjack (meaning only two cards, one an "A" and the other a card worth 10 points) and the dealer does not, then the player wins.
    2. If the player's score is less than or equal to 21, but greater than the dealer's score, then the player wins.
    3. If the player's score is less than or equal to 21, and the dealer's score is greater than 21, then the player wins.

    In all other cases, the game is either a draw, or the dealer wins. For the purposes of this Kata, a loss and a draw are treated the same way, and you are only concerned with wins. To be more specific about losing and drawing conditions:

    1. If a player's score is greater than 21, they lose, regardless of the dealer's score.
    2. If both the dealer and the player have blackjack, it is a draw.
    3. If the dealer's score is greater than or equal to the player's score, and both scores are less than or equal to 21, but neither the player nor the dealer have black jack, then it is either a draw if the scores are the same, or the dealer wins if the dealer's score is greater.

    Hope that helps!

  • Default User Avatar

    Though I agree that the description could be improved, it is not asking you to write code for the player behavior, just the dealer. In this scenario, the players have already drawn all of their cards, and you simply have to write code for a function that draws cards for the dealer until their total score is 17 or higher, and then returns a list of which players won according to the rules given.

  • Custom User Avatar

    I'm glad you liked it. thanks for the praise! cheers. DM

  • Default User Avatar

    Hope you don't mind me marking these comments as spoilers, but I personally felt that the way this edge case is handled in the description was one of the most satisfying features of this Kata. I felt that figuring out that this edge case exists adds an extra challenge to this Kata, but that the description is pretty clear about how it should be handled when you discover it, as long as you read carefully.

  • Default User Avatar

    Of all the Kata I have done on this site, I have to say that this has been one of the best. The description is well written and clear, with a nice story to make it interesting, yet it is succint enough to make reading it not feel like a chore. Additionally, there is one particular edge case that, although it is alluded to in the description, is not made overly explicit. The result is that those trying to solve this Kata will have to reason it out on their own, but when they do, will find that the instructions for handling it were actually there in the description all along. That's a tough balance to achieve, as most descriptions either give away all of the secrets, and so end up being less challenging than they otherwise would be, or don't properly explain how to handle the edge cases, so figuring them out ends up devolving into trial and error. Excellent job with this one!

  • Default User Avatar

    According to the rules laid out in the description, 3 riders would be required. The first rider starts at station 1 and rides the 6 miles to station 2. This rider then attempts to ride the 43 miles to station 3, but never makes it, since that is station x. The second rider would then travel the 43 miles from station 3 to station 2, rescuing the first rider along the way. After arriving at station 2, the second rider rides the 43 miles back to station 3, for a total of 86 miles. There are still 38 miles to the final station, which would exceed the 100 mile limit for the second rider, so then a third rider would carry the mail bag to the final station.

  • Loading more items...