6 kyu
Simple palindrome game
54 of 144KenKamau
Loading description...
Strings
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.
There should be fixed and sample tests like this one where the first string has 3 or more occurences of the same character that is not in the second string within all languages
Probability of random tests to generate such cases should also be increased
The statement is unclear. Please clarify that P1 and P2 are creating one string (I first read it as P1 a string separate from P2), that they are adding characters to the end of the string (is this correct?), and that you assume optimal strategy with full information (they see each other's hands). Interesting problem otherwise!
I've updated the description. Confirm it's OK.
I would spell the details out, maybe like this:
In this Kata, two players, Alice and Bob, are playing a palindrome game. Alice starts with string1, Bob starts with string2, and the board starts out as an empty string. Alice and Bob take turns; during a turn, a player selects a letter from his or her string, removes it from the string, and appends it to the board; if the board becomes a palindrome (of length >= 2), the player wins. Alice makes the first move. Since Bob has the disadvantage of playing second, then he wins automatically if letters run out and the board is never a palindrome. Note also that each player can see the other player's letters.
The problem will be presented as solve(string1,string2). Return 1 if Alice wins and 2 it Bob wins.
Description updated.
Many thanks, much clearer now! Let me go solve it;)
Ok. Good luck!
I got this in the random tests:
Falsifiable (after 41 tests): expected: 2 but got: 1 "xehtzzbajpcze" "cjjsshesortelnxefoqgdogybqurdiqtyo"
The character 'z' does not belong to the second string, and the first string has more then one. So, couldn't P1 win by picking 'z', and then again another 'z' after whathever P2 does?
The Haskell reference solution was incorrect. It should be good now.
Thanks! It works now, indeed.
damn, I wanna start this one but it looks complex.
No its not! It's a 6kyu for a reason.
Ask youself, what does it take for P1 to form a palindrome? And then understand that in all other scenarios, P2 must win. It's a piece of cake!
Nice one. One missing fixed test, though (I stumbbled on it in the random ones):
Very good. Will add it.
Done!
cannot i just take a
g
from string1 and anotherg
from string2?Let me look at it.
Hi Zed, should be good now.
Is there some order requirments i am missing?
The description was not very clear. I have completely changed it. Let me know if it now makes sense.
Now i finally get your idea
I'd say the description could still be improved. I understood it as if each player were removing a character at a time from his/her own string to form a palindrome with the remaining letters.
However, now I see that each player is selecting letters to help build one common string until it becomes a palindrome (if possible). So I think some kind of indication that players are contributing letters to a common string would be helpful.
Thanks. I will update
And tenchnically a string of length 1 is a palindrome...
I have updated the description.
The example gives the impression that characters should be taken in order, but your below comment says not.
Neither the Description nor the tests specify when to return
1
and when2
when both are possible.Missing the
puzzle
tag .. :/I have updated the description. Let me know if it works.
Is it clear now? See the new description.
Perfectly clear! :D
why
s1="eyfjy", s2="ooigvo"
should return1
?BTW: no sample tests ;-)
Let me look into it.
I have updated the description. Let me know if it works.
Is it clear now? See the new description.
Saw it. Solution submitted ;-)