5 kyu
Grab CSV Columns
526 of 1,164xDranik
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.
Nice one, well done.
Description should be language-agnostic
Does not mention the output format when mapping to a non-existent column (giving examples without explanation is a "no-no")
the info actually was in here, but lost in the wall of text...=> used bullet points
CS:
No random tests
Using
Test.expect
Even your code is right the test doesn't pass.
Please provide more context, so far CS, JS, Python and Ruby have no issues ! (Just tested with my code)
C translation. author inactive.
approved
No random tests.
assertEquals
should be used.done and done
It is not mentioned that the keys have to be unique and sorted.
Done.
Added: The columns of the result must be ordered and not repeated.
So I have all the normal cases working and I also solved a case with a repeated indice, but now in the random tests I am seeing cases where the expected result is the reverse of what I generate, or the second and third elements are swapped or, everything is shifted to the left or right, are these the special cases people are talking about? and can anyone give me a hint on the reason for the different cases, I'm sure there must be a pattern but I'm not seeing anything in the numbers?
I stopped working on this days ago thinking i was doing something wrong only to realize today that the instructions were insufficient. Nice kata but you should have let us know all the corner cases to expect.
I get the expected results but some tests still fail. tried trim() but still doesnt pass.
As it is said below, the tests cases are overdetermined compared to the description.
The hidden conditions are interesting, but they have to be plainly explained ! To not considere it as an issue (that I almost used to post this comment...), the kata should at least be tagged with
puzzle
or it should be explicitly said that there might be some undescribed behaviours to take care of, outisde of the scope of the sample tests.description says "The columns of the result must be ordered and not repeated." as of now
This comment has been hidden.
I was just going to write that, verbatim.
Just want to second this -- ebbruns description of the issue is good, and I think either the description should be updated or those corner cases should be abolished from the random tests (personally I don't think that they add much)
Please use
assertEquals
. This way instead of the message "Expected ''" We get something helpful, like "Expected '', got 17". :)This comment has been hidden.
I've copy and run your code, it works and passed all tests. So no problem ;-)
Haha, thanks, now I know I'm not crazy, but I still get an error from the test cases for some reason.
Nice kata; translated into both Ruby and Python and I would gladly add some more (and random) tests to the JS version, if the author is ok with it :)
@GiacomoSorbi
,Python 3 isn't compatible (four
xrange
's) but for some odd reason it is actually available in the dropdown menu when you go toTrain
! Obviously, it breaks whenever it hits the random tests but I just thought that was weird.Try now ;)
@GiacomoSorbi
,Sorry for the delayed response! Thanks for making that fix, I just tried it and it seems to work just fine!
I was just looking for this message in my discourse history when I saw your reply. I just bumped into the same issue on another kata and wanted to also reference this one in a GitHub issue. Python 3 is technically unavailable because of
xrange
but you can select Python 3 from the dropdown menu (on the other kata).Anyways, thanks again!
The solutions to this kata are interesting because they highlight how you can write more terse but less efficient code. The most upvoted solutions to this problem all skip the step of optimizing the column map up front, and instead use indexOf to test each column against the map on each iteration - very inefficient. Optimizing the map first to create a valid lookup table is a superior approach, even if it's a few more lines of code and means you can't solve it in a single statement.
This is not a criticism of the kata at all but sort of an observation that codewars users seem to prefer short/"clever" solutions to more efficient ones. I wonder if there's some way to develop katas that can build the notion of good algorithmic design vs. just typing the least into the solution.
This comment has been hidden.
This comment has been hidden.
Thanks for the feedback! I've changed all the test cases to use Test.expect with a helpful message when the solution doesn't match.. In the message i escaped the \ character so you can now see the new lines. Let me know if it's helpful :)
I'm seeing the newline now, that's great! However, I'm not seeing the erroneous answer any longer. If you could add that back in, I'd be willing to mark you as good to go out the door.
The reason it's showing now is because I switched Test.assertEquals to Test.expect with a custom message showing the new line character. Unfortunately Test.expect doesn't show the answer when done correctly. Which would be more helpful?
I'd say the Test.expect. Seeing the '\n' appear should provide enough of a clue given system constraints. I'll go ahead and switch my vote. Thanks for your awesome work!
Np, thanks again for your feedback :)