6 kyu
Rotate Array
1,645 of 2,221cjmcgraw
Loading description...
Arrays
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.
tasty :)
Thanks for the kata, compliments, I really appreciated it.
D translation
(author is inactive)
C translation (author gone)
approved
Description does not mention anything on how to handle empty arrays
No sample tests for empty arrays while it is being tested in python
There is a fixed test including an empty array. An empty array doesn't need any particular mention, just do the task: return a given array with the elements inside the array rotated n spaces.
Well, it's better to put it in sample tests too as most users will be scratching their heads on why sample tests work but not fixed tests ~~
And how having users scratching their heads because their code fails on an edge case is an issue? This happened to me tons of times; this is normal and this is right.
Python translation, including random tests + description made language neutral (author is inactive).
Approved, though I think Java version does not have empty arrays in test cases, while Python does.
This comment has been hidden.
Java: No random tests.
some of my test cases are passes except like this:
testDoubleRotate_DoubleArray class java.lang.Double cannot be cast to class java.lang.Integer (java.lang.Double and java.lang.Integer are in module java.base of loader 'bootstrap')
tell me how to resolve this
This comment has been hidden.
what's mean , Double rotation. I can't image what n is in this test
Implementing generics could be tons of fun here.
Too late.
Took my 1 hour but great kata.
I'd suggest to add some edge test cases to this kata:
I already implemented those for java in my submission. Pasting them here in case you want to make use of them:
This comment has been hidden.
What does it mean if I get back a number? I've been getting back "1" or "5" for some of the test cases.
I encountered a similar result and realized that it was an out of bounds error. (i.e. the number indicated the index of an array I was incorrectly attempting to access)
How do you think the space complexity of creating a new array?
JS translation available.
Hi, I've added a Python translation, if you want to approve it, instructions for the approval process are here.
Approved with fork above
Actually not, my translation was written from sratch, this one seems to have disappeared.
I think you should state if modifications to the input array are allowed, i.e. returning the same array instead of creating a new one.
I agree, it should explicitly say in place or a new array.