Skip to content

Create slowsort.py #3865

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

Merged
merged 13 commits into from
Feb 9, 2021
Merged

Create slowsort.py #3865

merged 13 commits into from
Feb 9, 2021

Conversation

DjaouadNM
Copy link
Contributor

@DjaouadNM DjaouadNM commented Nov 5, 2020

added slowsort algorithm implementation to sorts

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

added slowsort algorithm implementation to sorts
@DjaouadNM DjaouadNM requested a review from l3str4nge as a code owner November 5, 2020 18:28
@mrmaxguns
Copy link
Member

I believe this algorithm has been already added here.

@DjaouadNM
Copy link
Contributor Author

The algorithm you linked to is Bogosort, which is an entirely different algorithm, but it is also called Slowsort at times.

@mrmaxguns
Copy link
Member

Oh, ok. Sorry for the misunderstanding

@DjaouadNM
Copy link
Contributor Author

DjaouadNM commented Nov 5, 2020

No worries, you could look at the code and notice the differences, you could also check Bogosort and Slowsort at Wikipedia.

@mrmaxguns
Copy link
Member

Isort failed, looks like you need to reorder the imports

@DjaouadNM
Copy link
Contributor Author

Done!

@mrmaxguns
Copy link
Member

Thanks for contributing to open source 👍

@cclauss could you review and merge this pull request?

@TheAlgorithms TheAlgorithms deleted a comment from cclauss Dec 2, 2020
@dhruvmanila
Copy link
Member

@algorithms-keeper review

@ghost ghost added the require descriptive names This PR needs descriptive function and/or variable names label Dec 11, 2020
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will only modify the labels accordingly.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

from typing import Optional


def slowsort(sequence: list, i: Optional[int] = None, j: Optional[int] = None) -> None:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide descriptive name for the parameter: i

Please provide descriptive name for the parameter: j

@ghost ghost added awaiting reviews This PR is ready to be reviewed tests are failing Do not merge until tests pass and removed require descriptive names This PR needs descriptive function and/or variable names awaiting reviews This PR is ready to be reviewed labels Dec 11, 2020
@ghost ghost added awaiting reviews This PR is ready to be reviewed and removed tests are failing Do not merge until tests pass labels Dec 11, 2020
@stale
Copy link

stale bot commented Jan 11, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added stale Used to mark an issue or pull request stale. and removed stale Used to mark an issue or pull request stale. labels Jan 11, 2021
@mrmaxguns
Copy link
Member

A maintainer should probably merge this PR unless there's an issue; we don't want valid pull requests to be closed as stale 😞

@cclauss
Copy link
Member

cclauss commented Feb 5, 2021

@mrmaxguns If you believe that this PR is ready to be landed, please click the Review changes button at https://github.com/TheAlgorithms/Python/pull/3865/files and Approve.

Copy link
Member

@mrmaxguns mrmaxguns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request is good to good to go:

  • Unique
  • Docstrings
  • Type hints
  • Readability
  • Doctests

Copy link
Contributor

@amaank404 amaank404 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks good to go, although i would like to ask if it is prone to recursion error

@cclauss
Copy link
Member

cclauss commented Feb 9, 2021

@mateuszz0000 Is this ready to land?

@DjaouadNM
Copy link
Contributor Author

this looks good to go, although i would like to ask if it is prone to recursion error

Nothing but a maximum recursion depth exceeded with large lists, but this is the case with all recursive functions (in Python), and this algorithm isn't really made for practical use, so it isn't a necessary thing to use sys.setrecursionlimit to try and overcome the error.

Copy link
Member

@cclauss cclauss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a fan of purposefully inefficient algorithms of little utility (esp. sleep_sort!) -- perhaps the humourous nature is beyond my comprehension. Heating the planet with inefficient algorithms is what TheAlgorithms are trying to avoid. But this one has been batted about long enough so let's land it...

@cclauss cclauss merged commit 4903a65 into TheAlgorithms:master Feb 9, 2021
@ghost ghost removed awaiting reviews This PR is ready to be reviewed labels Feb 9, 2021
peRFectBeliever pushed a commit to peRFectBeliever/Python that referenced this pull request Apr 1, 2021
* Create slowsort.py

added slowsort algorithm implementation to sorts

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py
Panquesito7 pushed a commit to Panquesito7/Python that referenced this pull request May 13, 2021
* Create slowsort.py

added slowsort algorithm implementation to sorts

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py
shermanhui pushed a commit to shermanhui/Python that referenced this pull request Oct 22, 2021
* Create slowsort.py

added slowsort algorithm implementation to sorts

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py

* Update slowsort.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants