Created
October 8, 2020 07:02
-
-
Save sevperez/f01986272f6342adcf7ffae4657d6e6f to your computer and use it in GitHub Desktop.
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
def binary_search(items, target): | |
left = 0 | |
right = len(items) - 1 | |
while left <= right: | |
mid = (left + right) // 2 | |
if items[mid] == target: | |
return True | |
if items[mid] > target: | |
right = mid - 1 | |
else: | |
left = mid + 1 | |
return False | |
company_languages = ["C++", "Clojure", "JavaScript", "Python", "Ruby"] | |
candidate_language = "Python" | |
if binary_search(company_languages, candidate_language): | |
print(f"We use {candidate_language} too!") | |
else: | |
print(f"Are you willing to learn another language?") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment