Last active
April 16, 2018 16:56
-
-
Save gotraveltoworld/dc8d352e994780006ce6eaefd7ac384c to your computer and use it in GitHub Desktop.
Python bisect practice
This file contains 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
from bisect import bisect, insort | |
# Return the index. | |
def in_bisect(sorted_list, target_value): | |
i = bisect(sorted_list, target_value) | |
return i | |
# Return the new list. | |
def insert_by_bisect(sorted_list, target_value): | |
i = insort(sorted_list, target_value) | |
return sorted_list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment