uaveiro-leci/1ano/1semestre/fp/aula09/binarySearch.py

11 lines
280 B
Python
Raw Normal View History

2023-01-16 11:17:05 +00:00
import bisect
with open("wordlist.txt", "r") as f:
word_list: list[str] = f.read().split()
begin_index: int = bisect.bisect_left(word_list, "ea")
end_index: int = bisect.bisect_left(word_list, "eb")
print(f"Words started with 'ea': {end_index - begin_index}")