Beta
Flatten A Nested Dictionary That Contains Lists
48el-iot
Loading description...
Recursion
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.
Challenging! Especially the possibility of a key's being int or string makes it even more compelling. Nice kata.
Lack of small preloaded tests, especially tests on arrays.
Debugging huge random tests is quite a pain.
what about the possibility of having a list as first layer? (note: it would need a slight change in the description)
This behavior isn't specified in the description (and is highly arguable): the original key was an int, but it hasn't been converted to a string in your solution. For now it's undescribed, but moreover, that sounds inconsistent to me (because if the first key is an int and you find another layer below, it will be cconverted to a string. So for homogeneity purpose, all keys in the output should be strings).
Side note: currently, the way the test suite is splitted (is it even splited..?) isn't correct: everything appears in a "random tests" block. => ?
Some readings you might find useful: https://github.com/Codewars/codewars.com/wiki/Codewars-Python-Test-Framework-V2
Hi,
Unfortunately, that's a duplicate of an old kata (which is JS only, that's why you didn't find it... if you searched for duplicates... x) ). Moreover, it would need:
Because of the "duplicate" problem, you should unpublish yours. You can still train your authoring with it, but don't expect it to be approved. The better way would be to translate the other one (tho, that woul dneed to handle some things in there: iirc that kata has some issues)
cheers.
Where is the link to the duplicate though? ;-)
mmm... Seems like the one I was thnking about w as actually doing the opposite operation. So, the duplicate aspect isn't a problem (or there are others I don't know about), but the other points still stand.
This is the closest I can find: https://www.codewars.com/kata/lets-flat-them-out It doesn't have lists.
I believe this would be a duplicate (including the list aspect, although they are handled in a slightly different way).
https://www.codewars.com/kata/5824daf7c4d7f388600002a3
It's an old JavaScript-only beta, though. Not sure if that would be enough of a reason to retire this one.
Thanks for the feedback guys! I've added some more random tests, including tests with longer keys (including some keys that are just symbols). I also added a description of how to handle empty-lists and empty dictionaries (they can exist in the nested structure, but only as values / endpoints because they aren't hashable (in python, at least). Does this help the kata, in your opinion? What more should I add if I am (stubbornly) hopeful that it will get published?
I just looked at the test suite and...
x/
those are not random tests, they are fixed tests. => look at some others katas you solved (recent one if possible) and study how the random tests are done.
Note: in your case, you'll have to compute the expected solution before you send the data to the user (or you'll need to make a deep copy of the structure)