4 kyu
Beggar Thy Neighbour
Loading description...
Games
Algorithms
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Java Translation
Suggestion: At the end of the description, after "with player 2 eventually winning", add something like "so the program should return 1, the player's index."
I think this will prevent the confusion that many people have encountered, as indicated futher down in the discourse below. The description does state at the top that the index should be returned, but it's easy to forget this by the time you get to the bottom.
Great kata, thanks.
Hi @ChristianECooper - thanks for a great kata, with just the right balance of designing-to-debugging!
On a personal note, as a beginner programmer, I remember reading these kind of katas a few weeks ago and having no idea where to start but after practicing on Codewars I'm finding that I'm starting to break things down systematically now and it all becomes much more approachable.
So, to anyone 5-6 kyu reading the Discourse for advice, stick with this kata if you are struggling - it's really worthwhile and good practice.
Great kata with the right amount of difficulty. Thanks to the author.
Really satisfying thanks :) I love a kata where you can simulate it in real life to help!
sorry for the stupid question, but what if a player ran out of cards in his hand? does he lose immediately? I think I don't understand...
Yes, you run out of cards, you lose. The winner is the player that ends up with all the cards.
Additional question: If a player has to pay a particular size penalty, but they don't have enough cards in their hand, do they lose immediately? Or do they play the cards they do have, which might include a special?
By solving the kata, it seems the answer is "they play the cards they do have, which might include a special".
Suggested by Blind4Basics 3 years ago, but description is still very confusing:
Hmmm, the description clearly says that you must return the index of the winning player. I'll go an make that bold for a bit more clarity.
0-based index or 1-based index? If players are called "Player 1" and "player 2", one can expect 1-based index.
imho, maybe a simple way of clarification, would be to rename input arguments from "hand_1 / hand_2" to "hand_0 / hand_1" ?
PS: i ran into the same issue when solving this kata :-)
The question is if for example , during a penalty, I have to play 2 cards and the first one is a special card. So do I have to play the second one then or the penalty will be reversed without playing it?
Did you ever figure this out?
Play reverses immediately, no need to pay the seond penalty
this should really be part of the description
This comment has been hidden.
Player 0 plays the 6, then the Jack. The Jack means that player 1 has to pay a penalty of one card or lose. Is player 1's next card a J, Q, K or A?
So it doesn't matter that the player 0 can't pay the full penalty of 5? They just play the cards they have and the game continues?
Fun kata.
@ChristianECooper
, have you considered translating this to other languages (or do you accept translations)?I'm happy to accept translations :)
Fun Kata :)
Very interesting/pleasant one.
...Though it presents an important lack in the description: You forgot to explain what was the excpected return format: by reading it, I expected to have to return 1 or 2, not 0 or 1...!
EDIT: btw, you might want to modify the way you organized the presentation ot the tests (describe/it). Currently, we get that:
Added use of 'it', better late than never. :)
This kata was fun, thanks! :)
You're welcome! :)