7 kyu
Normalize the jagged array
253оkabe
Loading description...
Arrays
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.
Approved it as 7 kyu.
Feels like a
2016
kata, lolNice kata! Hope it gets approved soon.
nice kata, the only suggestion I could give is maybe don't stuck the fill_value only to None? But can be more customed? thanks
This comment has been hidden.
well, about the fill_value, it seems None is the only used value. I saw the discussions below, but giving a default argument in python implies the value may change, so it should be tested as well (while keeping the data types consistent, like, fill with some integers if arrays of numbers are used, or fill with strings for aray of strings, ...)
another missing fixed tests: with an empty subarray.
This comment has been hidden.
This comment has been hidden.
Fork approved. Test data still needs to be grouped better in sample tests though.
Okay, any suggestions about this? Cuz variant suggest by B4B can be less readable than current ones.
This comment has been hidden.
seems to be fixed finally. I closing it but if something not good, reraise new one.
This suggestion reraised as an issue:
It needs to be considered and explained how this kata is meant to be translated to strongly typed languages.
Design-wise, I think it would be much nicer if the filling value was passed in as a parameter, potentially with a default value of "no value" in languages which allow for this. So in Python, the function would be
def normalize(arr, fill_with=None)
. This would make translation to strongly typed languages like C++, Java, Scala, Haskell, much easier.Implemented!
This part still should be language-agnostic
Implement a function normalize(arr) that takes a jagged array as an input and outputs its normalized version.
( by removingnormalize(arr)
since function and parameter names differ among languages, users can view them in trainer so no need to mention them explicitly)Done
Description should be language-agnostic
Implement a function normalize(arr) that takes a jagged array as an input and outputs its normalized version.
&& the usage ofNone
in the examples (should mentionNone
/nil
/null
depending on your language)Done
It would be already worth to consider, and potentially suggest somewhere, somewhow (maybe even in an answer to this comment) how this kata is meant to be translated to strongly typed languages.
Design-wise, I think it would be much nicer if the filling value was passed in as a parameter, potentially with a default value of "no value" in languages which allow for this. So in Python, the function would be
def normalize(arr, fill_with=None)
. This would make translation to strongly typed languages like C++, Java, Scala, Haskell, much easier.I agree, this also makes it feel more like a "real world" task. Comparable is
itertools.zip_longest
which has an inputfillvalue=None
Will implement it later today
I am going to reraise this suggestion as an issue, because otherwise I think we could end up with a mess in translations.
Surely the result for input
[]
should be[]
? I don't understand how you get[[]]
.Oops, fixed!
Random tests are susceptible to input mutation.
Example
Fixed
There should be a test case of an empty array (
N = 0
is perfectly valid as input). Some solutions will break in this case.Fixed
Normalized empty array should be
[]
, in my opinion.