Add perfect cube binary search#10477
Merged
tianyizheng02 merged 7 commits intoTheAlgorithms:masterfrom Oct 23, 2023
Merged
Conversation
tianyizheng02
requested changes
Oct 16, 2023
Contributor
tianyizheng02
left a comment
There was a problem hiding this comment.
Could you modify your algorithm to support negative numbers? For instance, -27 = (-3)^3
Contributor
Author
|
Hi, thanks for the reply - I've made the changes, let me know if everything's OK now. To add support for negative perfect cubes to the other non binary search algorithm in the same file, I can open another PR. |
tianyizheng02
requested changes
Oct 17, 2023
maths/perfect_cube.py
Outdated
Comment on lines
26
to
29
| >>> perfect_cube_binary_search("a") | ||
| Traceback (most recent call last): | ||
| ... | ||
| TypeError: '<=' not supported between instances of 'int' and 'str' |
Contributor
There was a problem hiding this comment.
Please add your own TypeError check for invalid inputs like this rather than relying on the built-in error message for <=
Contributor
Author
|
A TypeError check was added, thanks for the reply. |
tianyizheng02
approved these changes
Oct 23, 2023
Contributor
Ugh, not this file again... |
Contributor
|
Thanks for your contribution! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your change:
This pull request adds a new algorithm within the existing perfect_cube.py file, including a doctest. While similar files such as perfect_square.py have added an improved time complexity binary search algorithm, perfect_cube.py lacks another faster algorithm that can be used as an alternative. This PR aims to bring the set of algorithms up to standard (such as perfect_square.py) with a new binary search implementation.
Checklist: