6 kyu
Sparse array split function
106appsincaps
Loading description...
Fundamentals
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.
I passed the test but I get two errors when I attempt the solution. The problem is, I don't know what the inputs are. I am unable to debug the test at this point. Printing the console log does not help as it does not clearly show which ones are arrays among the test inputs. Maybe I am unclear about the expected results of sparse array but at this point I find it difficult to debug my code. Does anyone have a useful tip or pointer that could help me?
FIRST ERROR: Should return a split array: [[null],[null,null,0,""],[[null,null,null],[]]] Log Given array: ,,,,,,,,,,,,,,,,,,,,,,,,,,,,, END OF GIVEN Result: ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
SECOND ERROR: Should return a split array: [] Log Given array: 1,2,,3,4,,5,6,,7,8,,9 END OF GIVEN Result: 1,2,3,4,5,6,7,8,,9
This comment has been hidden.
One of the test cases is broken:
Receiving: [ null, <1 empty item>, undefined, null, 0, '', <1 empty item>, [ <3 empty items> ], [] ] Expected: [[null],[null,null,0,""],[ [null,null,null],[] ]]
True! Somehow an undefined turned into a null. :)
This comment has been hidden.
Why in case of this input
[ null, <1 empty item>, undefined, null, 0, '', <1 empty item>, [ <3 empty items> ], [] ]
function should return[[null], [null, null, 0, ""], [[null, null, null], [] ]]
instead of[ [ null ], [ undefined, null, 0, '' ], [ [ <3 empty items> ], [] ]
? I think it's a mistake in kata.I think one of the test cases is broken.
Receiving: [ null, <1 empty item>, undefined, null, 0, '', <1 empty item>, [ <3 empty items> ], [] ] Expected: [[null],[null,null,0,""],[ [null,null,null],[] ]]
I get that it splits at the empty item, so [ [null] ]. However, after that, it just gets confusing. If [undefined, null, 0, ''] should evaluate to [null, null, 0, ""], then I would need to be able to check for 'undefined' in a way that doesn't catch empty fields. Not possible in Javascript. Empty fields /are/ undefined. So it should be [ [null], [null, 0, ''] ... ] ?
It's also telling that in 3 years this kata was only completed successfully 14 times, and that at 6 kyu.
This comment has been hidden.
Kata is very much doable, as said above using
JSON.stringify
will not do, you have to distinguish empty items some other way, also the low solution count seems to come from the fact that only recently this kata has left the beta stage.In that case I'm just not getting it. I'll move on to another kata for now.
This comment has been hidden.
tests are using
test.expect
instead ofchai.assert.deepEqual
If the original array is dense, for consistency
.split()
should return an array consisting of a copy of the original array.So return this.slice()
My suggestion was
[ this.slice() ]
. It was about returning a consistently typed value.I see. Yes, you're right.
Die vervelende neiging heb ik vaker. Mijn verontschuldigingen daarvoor. :yum: