Beta
Rotated string
188 of 363pinelopi
Loading description...
Algorithms
Strings
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.
Everything worked fine on Python. It's an interesting kata, well done.
possible duplicate ?
Tests should use python test framework: https://docs.codewars.com/languages/python/codewars-test
Python test updated, Random test added.
The description is abstract, just random examples won't do the job, for instance an empty string returns true, why didn't you put it in the description?
I think the case for an empty string is that "" rotated any n number of times is "", so if the first string is "" and the second string "", it must be true. I don't know if it is necessary for the example tests to show that edge case, although I do agree that the description could be a little clearer about the the bounds on the inputs (like string size, etc.).
The description of the challenge is not very complete, only giving examples of what consitutes a rotated string and not the definition of a rotated string. I had to read it a couple of times to figure out what they were. Saying whether a string was right or left rotated confused me slightly as that led me to expect the program to also differentiate what strings were right and left rotated. You can keep that there, but make it clear that it isn't required in the program, only for the knowledge of a rotated string.
Why would you need to differentiate what kind of rotation it was? IMHO it's not a kata issue, it's your wrong interpretation.
in my opinion, a kata should be descriptive enough to not allow for "different interpretation" from most of its takerstakers
Yes, it IS my wrong interpretation Chrono, but my point stands. You want to remove ambiguity. Yes, I'm wrong. My suggestion there was to have it to where less people will be wrong. Miscommunication goes both ways.
Suggest a better description then, kata's author is active so he can improve it.
I suppose if I'm going to argue that it is poor that I should offer a better solution. Here's what I propose then:
Write a function that takes as arguments two strings and returns positive (
True/true/1
) if one string is a rotation of the other or else returns negative (False/false/0
). A pair of strings are rotations of each other if they are the same string OR if you can take the letters from either end and move them (preserving their order) to the opposite end you took them from. Examples:For example:
Keep in mind you only have to return
true
for rotations andfalse
for non-rotatations (or their equivalent boolean values in your language).I think that would do better as the kata description. A few more words, but I think they clear things up. Agreed? I'm open to hear what you have to say, you have more experience on this site than me.
I'm mostly ok with it (I wouldn't say what you have to return twice, but if you think it's really needed...), but I'm not sure if "ohell" is left rotation of "hello" (I know the author said that), I'd say that's a right rotation, here is my interpretation (and I saw it like that in some places too):
Now let's see what @antrianis thinks.
Well said. You are probably right in that it doesn't need to be stated twice, and I don't think it's NEEDED, but helpful. I kept the author's "left" and "right" rotation and just assumed that they were correct, but it might just be better overall if it's omitted. That would remove my concern of stating the return twice and remove information irrelevant to the problem. Anyways, I am off to sleep for tonight. I think what we have works well if the author looks at this and updates it.
issue 6 years old, author incactive, 322 warriors solved it, translated to other 2 languages, I am presuming, based on these fact, that description is ok. I am closing this issue, as it is stopping kata with 88% rate from further progress in beta process. If anyone disagree, please do suggestion or fork with better description.
Whats being passed as the parameters for the second test???
Use
print
to figure it out.exactly what i did. For each test, i printed out the two parameters and a number (to see if spaces were passed too) and for that specific one, it looked like 2 spaces were passed, either one of the two had 2 spaces and the other has none, or they each have a space. But when i tested if they were actually spaces, it failed, so they cant be spaces. For some reason there are two spaces there and then the number. Edit: I just tested it with empty sttings and it works. But why did it show me two spaces and then the number? I even copied and pasted and it pasted two spaces instead of nothing? Also the kata definately should've specified what should happen with empty strings
This comment has been hidden.
Needs random test cases
Has them now.
Remove the extra brace at the end of the test case.
Fixed. Thanks for reporting.
Test class doesn't not compile (because has extra brace). Is it correct?
This seems to be solved a long time ago.
Needs random test cases :)
Has them now.
Still no random tests in python.
Python test updated, Random test added.
I don't know if "string rotation" is a common concept but I haven't heard of it. Due to lack of explanation the solution involves more guesswork then it should in my opnion.
Your issue ;-)
Example test case does not compile
Fixed. Thanks for reporting.
Needns nore explaining information about "edge" cases. Extra brace in tests.
There is an extra braces in the java test cases
Fixed. Thanks for reporting.
Also, translated into Java.
Agree with all the above. For now there is too much guesswork involved in solving this kata.
Please describe what exactly is meant by "rotation" it's not clear from the context and word alone.
Also test-cases don't give nice information about what went wrong.
JS translation kumited.
This comment has been hidden.