-
-
Notifications
You must be signed in to change notification settings - Fork 46.8k
Refactor cycle_sort #2072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor cycle_sort #2072
Conversation
""" | ||
>>> cycle_sort([4, 3, 2, 1]) | ||
[1, 2, 3, 4] | ||
|
||
>>> cycle_sort([-4, 20, 0, -50, 100, -1]) | ||
[-50, -4, -1, 0, 20, 100] | ||
|
||
>>> cycle_sort([-.1, -.2, 1.3, -.8]) | ||
[-0.8, -0.2, -0.1, 1.3] | ||
|
||
>>> cycle_sort([]) | ||
[] | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please break this into two PRs? The first PR should add the tests (lines 8 thru 20) and once that lands, the second PR could refactor the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please break this into two PRs? The first PR should add the tests (lines 8 thru 20) and once that lands, the second PR could refactor the code.
Sure but it's worth it? Refactor consist only removing boilerplate code and variable names. |
Yes. It is. This is a great habit to get into. Add tests first and make sure the code works as you expected. Once the tests pass make your changes and make sure that the tests continue to pass. This is the way that the pros always do it. |
* Refactor cycle_sort * Undo changes to keep only doctests
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}
.