Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Add type hints and tests. #2461
Conversation
Sort collection and remove the assertion logic. Co-authored-by: Christian Clauss <cclauss@me.com>
| print(f"Iterative search: {target} found at positions: {result1}") | ||
| print(f"Recursive search: {target} found at positions: {result2}") |
cclauss
Sep 22, 2020
Member
Does this provide the right answer if the user inputs an out-of-order list?
NumberPiOso
Sep 22, 2020
Author
Contributor
It does not, I think it is better to return to the assert_sorted logic.
NumberPiOso
Sep 22, 2020
Author
Contributor
I guess my error could be avoided by testing that part of the code, however the use of inputs make it hard to test. Do you know any way that the main could be tested ?
cclauss
Sep 22, 2020
•
Member
Sure.
def perform_searches(collection: List[int], target: int) -> None:
# put lines 159, 160, and 162-168 under this function and
# then you can test `perform_searches()` all day long.
NumberPiOso
Sep 24, 2020
Author
Contributor
Ok, I guess thats the same than testing each one of the two searches functions.
I meant something to try to test different user inputs via the input function, not when the collection is already defined.
|
Please resolve conflicts. |
|
Good to go ! @cclauss sorry for the delay. |
|
Hey, if possible can you update the variable names to |
|
I hope we are good to go. |
|
Yes! Thank you for your contribution! :) |
Continuing in line with #2128.
Add type hints and doctests corrected some little changes things that are not Python idiomatic.
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}.