6 kyu
Alternating sort
371barghest
Loading description...
Algorithms
Arrays
Sorting
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.
JavaScript Translation. Modifies the description to make it language agnostic.
Parity can be relevant for solutions which try to process the input in chunks of 2 elements and risk miscalculating the end, skip the last element or run into out of bounds access.
or maybe solutions which try to split some array in half and get it wrong on odd lengths.
Oh makes sense. Either case the random tests guarantee both odd and even lengths
Very nice kata to figure out, great.
python new test framework is required. updated in this fork
Approved
Nice!
input is vulnerable to mutation, in the random tests
Should be fixed by now. Thanks!
Your tests never include duplicate values. Better test that as well.
Done. Thanks!
Got this:
I'm sure you confused mine and yours. My solution definitely doesn't include zeros. Because I do what the problem asks, output only negative and positive values.
yes, expected and actual are effectively swapped in the random tests. And 0 can show up from time to time in some of those.
Adapted the description to include "non-negative" values and fixed test cases. Thanks!
Hi,
Interesting one. You should add some edge cases, though:
Thanks, I've added fixed tests that account for all three of these cases as well as random tests for "only negative" and "only positive" arrays.
Ah, I forgot one important edge case: what about 0? => you have to tell if you considere it positive or negative (positive, looking at your solution) and put some tests with it. Note that your random tests may not generate any zero, otherwise, ZED's solution would never have passed.
This comment has been hidden.
Zero isn't positive or negative and shouldn't be "considered" as such. The judge solution uses
>= 0
, so the kata should say "non-negative" instead of "positive".that would depend on who you are talking too, unfortunately. That's why it should be told plainly in the description.