4 kyu
Complex CSV Parser
890 of 930OverZealous
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.
suggested edge cases that a first version of my code did not handle correctly, but passed anyways:
"1,2,,\n3,4"
-->[ [ '1', '2', '', '' ], [ '3', '4' ] ]
"1,2,,"
-->[ ['1', '2', '', ''] ]
"a,b,c\n"
-->[ ['a', 'b', 'c'], [''] ]
"\n\n\n"
-->[ [''], [''], [''], [''] ]
If you're not testing this, why is this mentioned in the description?
Could someone convert this into python please?
There's already a library in Python for this which would be a pain to forbid, and nobody's going to translate anything just because you ask.
I want to translate it on Python and Java
This comment has been hidden.
Just forget about it. Forbidding modules in python is actually a pain and not reliable (I know it: I built the fucking tool...)
The random tests does not cover all cases. See @steffan153 solution
Also if there is any way I could help on a translate let me know, I haven't ever made one before, but I could try to make a C++ one or even Python, just would need a little guidance to start.
Ah this kata is so underrated, definitely one of my favorite ones thus far! Thank OverZealous!
You're welcome, glad you enjoyed it!
Nice kata, but please correct the spelling. "At it's simplest" should be "At its simplest".
Fixed
This comment has been hidden.
Usually people use JSPerf: http://jsperf.com
Note that the site had been out of maintenance for quite some time though (you can't fork a test anymore because it's broken), but I guess it's still the only shop in the town, so yeah.
I don't know how to replace "/"
Nice kata! Thx for it =)
Well, I guess there are several bugs. The quota and test cases live in different dimensions than the requirements :-)
BUG #1: According to the requirements the double quota at the end of the line should be end of quota not part of comment. BUG #2: Test scenario for BUG #1 is tested only after separator change. Error says it is problem with separator which is not true. BUG #3: According to the requirements you can report error about unclosed comments only at the end of input. (eg: ",,,,\n,,,,) BUG #4: Several times I had "Unknown error" - without any other info about it. BUG #5: This website not works with tools like uBlock :-) BUG #6: Looks like kata search not works at all. This kata cannot be found there. Also no JavaScript 1kyu, 2kyu or 3kyu in search?
However, It was fun to solve it. Maybe I will do some other too if find some time :-)
It doesn't look like the right place to report this. Anyway, it works for me. JavaScript, "csv" - 3 katas found, including this one. And 3 x 1-kyu and 10 x 2-kyu approved JS katas, plus betas.
Yes, you are right but looks like they solved it. Now I can search it.
Also getting BUG #1, any progress on this?
I guess they don't fix it, or even they can't fix it. If they fix it they shloud eject all solutions that passed tests but not requirements :-) So I guess we should think like this: "It is not BUG it is a feature :-)". Now they can only change requirements (description) not test cases to keep all solutions.
This comment has been hidden.
Awesome kata! Learned a lot about Regex.
Nice kata. Super frustrating but only due to extensive test cases. Took me longer to complete than some 2kyu katas. Well done!
This comment has been hidden.
I added your tests in for the regex characters.
I don't understand the purpose of the second one, since I already have non-random tests for inline quoted characters. Yes, it's possible someone could manually solve for that test, but that actually seems like more work that doing it correctly.
Thanks for your feedback!
This comment has been hidden.
Yeah, I think that the risk factor is light enough that it isn't worth more tests just for that. I mean, if the successfully pass everything else, but then screw up the replacement, it's kinda silly.
I would love to tackle this in Ruby...
OP left the building, translations will come eventually if the right person stumbles upon the right kata at the right time ^^, closing!
Not sure why this test failed :/
Test Failed: Expected: [["1","two, too","3"],["4","5","6"]], instead got: [["1","two, too","3"],["4","5","6"]]
I can't see why it would fail, either. Did you ever figure anything out?
I re-ran that test again under both JS and CS, and I didn't have any issues from my end.
There is a comma at the end of the array. Maybe that is why.
That was pretty fun, although a bit frustrating (mostly because I'm not super used to using CS). I ended up accidentally using Haskell-style function application twice and wasted 5-10 minutes trying to find the bug both times...
A really good test of using the regexp lookahead functionality, I never get a chance to use it as much as this asked for.
I didn't use a single if or else to solve it :) Felt like a great problem
Calling on jhoffner or other moderator to approve my kata... :-)
Approved after 7 years of beta. O_O
Awesome! Thank you! I didn't feel comfortable approving my own kata—and I've been pretty busy over on the Qualified side for the last... uh, 5 years.
wow 7 years
It seems that the first test ("should handle an empty file") takes an inordinately long time to complete, my code times out every time when that test should give a success. If I return [[]] instead of [[""]] with an empty input string, it (and every other test) completes without a hitch.
Not sure if this is a problem with the test or the test library.
I just tested it, it worked fine for me. Simply throwing this into the top of Your Test Fixtures should show this:
I tested it against my code several times, and had no timeouts. My guess is that it's just a coincidence.
If you are still having issues, then most likely your algorithm has something that's getting stuck in an infinite loop. One thing that might help is to add a counter to one or more of your loops, and break out if the counter exceeds some rational number, like 50. You can then use
console.log()
to check on your variables and see if something is getting stuck.I have, and it works fine there, it's only happening when I submit the code.
If I comment out these lines:
it finishes in less than a millisecond (used new Date().getTime()), if I put it back in OR modify the algorithm so that it returns [[""]] without the if, it times out.
Oh, there's a list of the tests, the zeroes are milliseconds elapsed between function begin and return:
This comment has been hidden.
First, I didn't realize this was coffeescript you were failing on, in case that matters.
I just tested it under coffeescript, with my solution but adding your
if
block to the top. It consistently finishes within a second or two, both under "My Test Fixtures" and when submitting the code. I have never had a time out. It's not my kata or tests.Can you reproduce the timeout if you only have the
if
block in your function? In other words, if this is all that you submit:If that works consistently (ie: the first test passes every time), then the error still must be within your code somewhere.
Sorry, I don't know what else to suggest. :-\
Right, sorry, this was my bad, I didn't realize the tests were divided into different categories, and it was some test on the second category that caused an infinite loop (probably nested quotes).
I'm glad you were able to solve it!
There's still a "minor issue" vote on this, but I haven't had any feedback in a while. Can this get moved up for moderator approval?
Nice one! I'm only sorry I couldn't find an elegant way to solve it but the problem seems to require a high cyclomatic complexity (lots of if/then/else)
This was a great one ... enjoyed it a lot.
I've had one problem though. I'm not sure where the problem is but I got an error message when trying to run the test fixture (unfortunately, i didn't write down the message but it was something like "cannot use the method 'push' on null"). originally, i thought it was in my code but i tested it and it was running fine. To make sure, i removed all "push" calls from my solution and ran it again. The error message still came up. In the end, I decided to delete your example of test fixture and wrote a simple one myself. this one ran without problems. So, I don't know where the problem is but it looks like it didn't like running your test fixture example.
Nevertheless, it's a great kata. i'll mark it ready once you find out what the problem is.
Interesting. I looked into it, I think it's a bug within the CodeWars testing framework itself. If you remove the
it()
wrappers, the test code runs fine. The test code hasn't changed since I put this up a while ago, so something must have changed within the framework.OK, it looks like I can wrap them in a
describe()
block and the error goes away. Thanks for the find!cool. didn't know about it. It's now "ready".
If there's nothing else wrong with this kata, it would be nice to have the remaining issue removed. :-) Otherwise, I'd be happy to tweak it.
I enjoyed that one. We need more like this and less of the time bomb / prediction / none shall pass type.
Alternatively, we could support kata we like without discouraging the authors of those we don't. There's an audience for both types. Maybe we need to be able to filter by kata type.
It's just my personal opinion and far be it from me to discourage anyone from contributing. I have only written one Kata so far, so if anyone needs to contribute more Kata of the kind that I like, then it's me :-)
Actually, the ones I mention are all marked as 'game' so it's already relatively easy to tune them out.
Cool, apologies. I misread the tone of "we need less like these ones".
The given function template contains a headerRow parameter which shouldn't be there.
Good catch. That's what happens when you change your mind part-way through..
this lacks examples in the description.
Ah, good point. I will add some.
I added some examples into the description. Along with the sample test cases, is that better?