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.
Here's an explanation of this Kata:
This Kata has far more information than necessary in order to solve it, and is fairly simple once you understand what you are supposed to do. Your task is to complete the AI() function to create a very simplistic "AI" that plays a game.
The AI() function has one parameter, which is named "game" by default. There are two different methods you can use on this parameter to get information about the game, inspectTG() and status(). Both of these methods return objects.
inspectTG() returns an object of the form:
The objects in the objects array are of the following form:
In this array, you will find an object with a type of "goal". The location array contains two float values which tell you the left and right borders of the "goal" object. Negative values indicate that the goal is to the left of your player, and positive values indicate it is to the right. Your objective is to navigate to this object through the use of the press() method. Arguments passed to the press() method should contain at least one of the following commands, with each command followed by a number:
Each of the commands should be followed by either an integer or a float that indicates how long the "movement button" should be pushed in seconds. Each second will move the player 10 units in whichever direction is indicated, or if the command is an "X" or an "x", the "button" needs to be pressed for a minimum of 1 second when the player is located within the bounds of the "goal" in order to complete the level. Multiple commands can be strung together and passed as a single parameter in the form of a string, and the game will process them in the order they appear. Each command has two options that can be used interchangeably. There is no difference.
Example:
The first part, "←3.5" will cause the player to first move to the left for 3.5 seconds, at a speed of 10 units per second, so the player will move a total of 350 units left. Then the player will move right for 4 seconds (">4"), again at a speed of 10 units per second, so the player will move a total of 400 units right (ending up 50 units to the right of their original position). The level complete button will then be pushed for one second ("x1"). If the level complete button is pushed when the player is not within the bounds of the goal, the player will die. If the button is pushed when the player is within the bounds of the goal, then the player will proceed to the next level, unless they are on the final level, in which case they will win the game.
The AI() function must guide the player through every level successfully in order to pass this Kata. In order to determine how many levels remain, you can make use of the status() function mentioned earlier which will return an object of the form:
You can either use this method, or the fact that both the inspectTG() method and the push() method will return "All Cleared!" when you have completed all of the levels in order to determine whether there are more levels remaining.
I don't want to be too hard on the creator of this Kata, because I get the impression that they put a fair amount of work into creating this, and I know it is an extra challenge to write instructions in a second language, because it's very clear that English is not their first language, but after reading over the instructions several times I still have absolutely no idea what I'm supposed to be doing. I guess I'll come back to this Kata eventually for the sake of completion and figure it out through trial and error, but simply interpreting the instructions alone feels like a challenge worthy of a 1 KYU-ranked Kata, and I don't have the motivation for that right now.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
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.
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.
fixed
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.
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.
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.
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:
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:
Hope that helps!
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.
I'm glad you liked it. thanks for the praise! cheers. DM
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.
Loading more items...