6 kyu
Rank Vector
757 of 2,163rtoal
Loading description...
Arrays
Sorting
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.
Haskell fork
C translation
Approved
Daamn, this was really challening for some reason. And then i check people with 2 lines of code. xD
approv2d
C# translation (author inactive)
approvius
Description should be language-agnostic (function name removed)
done
Node 14 support and random tests
.
python fork:
https://www.codewars.com/kumite/62c822e05bad7700420eba47?sel=62c822e05bad7700420eba47
Approved
Rust translation, including random tests.
approved
Good one.. thank you !
fixed above
No sample tests in JS
assert.deepEqual
should be usedNode 12. should be enabled
Done 👍
Ruby 3.0 should be enabled.
done
No random tests.
2 years issue
Added in Python. Currently missing in Haskell and JS.
added to JS there, so only missing in Haskell
Python's three tests seems wrong, my code is right but can't pass :)
This comment has been hidden.
This comment has been hidden.
Can the array be a tuple or a list of tuples as well, or can we assume it is a list? I don't know what I am missing. My code seems to work offline for all lists, but then there must be hidden cases.
To add....I only see three test cases. Is this as intended? Some of the discussions I am seeing mention a higher number of test cases.
The tests will only generate a list, also it is likely you see less test cases because the runner will not display the rest (i.e, halt operation) upon an assertion failure is detected.
My code is also failing on the test with this error,
expected: [6,3,3,3,1,1] but got: [6,2,2,2,1,1]
I might be missing something, but shouldn't
because 3 is the second largest number?
I'm coming to this conclusion based on this part of the instructions:
The interpretation is actually
My code keeps failing on the a test where the assert tells me, apparently, [6, 1, 1, 1, 1, 1] should equal [6, 3, 3, 3, 1, 1]
But according to the instructions this doesn't make sense. The first list can't result in the second list nor could the second list result in the first list.
You might be referring to the test that says
Perhaps your solution is returning
[6,1,1,1,1,1]
instead of the correct answer. That's why it is reporting that[6, 1, 1, 1, 1, 1] should equal [6, 3, 3, 3, 1, 1]
Ruby translation submitted :)
I added a bunch of random tests and was also wondering if adding negative numbers or other edge cases was worth the effort, but opted to keep it as faithful as possible to the original kata.
I hope my work is welcome, otherwise feel free to tell me where to correct it :)
This comment has been hidden.
This comment has been hidden.
i submited it [2, 1, 4, 3] should equal [3, 4, 1, 2], then i used the test mode to test this, it passed, and i run it in my computer, my solution return the correct answer too, and i can't figure out where is the problem?
This comment has been hidden.
I didn't know .sort() was this naughty (js). Hint: http://stackoverflow.com/questions/9592740/how-can-you-sort-an-array-without-mutating-the-original-array
In Haskell signature should be ranks :: Ord a => [a] -> [Int]. Class Ord already requires Eq.
It looks like the sixth test is incorrect, and according to this kata instructions it is impossible to pass it.
The tests seem fine in both JavaScript in Python. Care to share your solution? (Mark as having spoiler content)
This comment has been hidden.
[5, 3, 3, 3, 1, 1]
should result in[1, 2, 2, 2, 5, 5]
, yes. However, your solution is a little bit too complex. You don't need the range check or a set, or even a dict. Try to keep it simple. You just need the indices the sorted array.Thank you! I really make it too complex, when the solution is just oneliner.
thanks @hydepark, i was also making it overly complicated but your comment made me realise the solution can be simple.
This comment has been hidden.
There are 2 logical errors in your code:
The largest number starts from rank 1, followed by 2nd largest number etc... , but your code assigns the smallest number as rank 1.
Also, your code does not handle multi-way ties as it only checks the unique positioning of arrays instead of all elements' positioning