6 kyu
Grouping integers into a nested list
458 of 631the_Hamster
Loading description...
Fundamentals
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.
Good one!
Scala translation
Approved
That might be a new record lmao.
How much of it did you sanity check?
Some. :] I checked diffs, glanced at the example solution and example tests, looked at the random tests and decided not to look too hard ( you obviously worked from the Python tests. I simplified quite a bit for Haskell and JS, because I don't think highly biased tests add much value ), and approved.
Eh, realistically it'd be the same generator with one less parameter anyway.
No, it is to group the numbers. Sorting in place is something entirely different.
Fixed
Not even the description examples stick to this, and the example and fixed tests don't either. ( I don't understand at all why this was even specified. )
This should at least be changed to "non-negative", or preferably could be abandoned altogether.
technically, all the keys are positive, afaik (...or 0, yeah). But that's a pointless requirement, yes.
Fixed
JavaScript translation
Haskell translation
This comment has been hidden.
you are using global variables, don't do that. they keep their values between function calls
python new test framework is required. updated in this fork
approved
Typos in description:
Fixed
How can you sort them in place if you need to create new lists?
And you're not sorting either, you're grouping.
Author is just not using canonical terms for what is happening here.
Fixed
@the_Hamster
,groupInts -> group_ints
Your example test cases seem over-complicated and inconsistent. You are creating lists of actual and expected values, assigning them names, creating another list of all of the tests, iterating over them and then unpacking them into
assert_equals
calls. After all of that, you then put two more test cases in the proper format below the loop.Why not just skip all that and go to the
assert_equals
calls directly (as the Codewars Python docs show)?Also, the spacing inside of each 'test' list is giving PEP8 warnings using PyCharm:
You could simply rewrite the
Example Test Cases
like this:Simple fix to go from 16 lines to 10 (you could get it down to 7 lines total if you don't care about line lengths exceeding 80 characters). Easy to read, no need to name variables and it stays consistent with almost every other Python katas
Example Test Case
style.Thanks!
Okay done. groupInts = group_ints
ps. I do know that the white spaces after brackets is bad practice, but to me personally I find it more readable; and moreover, having a bracket out there in narnia helps me avoid missing brackets when using simple text editors. Nonetheless, I've made that change too.
@the_Hamster
,I appreciate you taking the time to fix both issues, it helps to keep the Python katas consistent across Codewars. The downvote was a nice touch too.
Thanks!