hacktoberfest-2018/code/shutstart.py

20 lines
366 B
Python
Raw Normal View History

2018-10-06 05:24:26 +00:00
def binary(a, tv):
minimum = 0
maximum = len(a) - 1
while minimum < maximum:
guess = round((minimum + maximum)/2)
if a[guess] == tv:
return guess
elif a[guess] < tv:
minimum = guess + 1
else:
maximum = guess - 1
return -1
arr = []
ind = binary(arr, 4)
print("index:")
print(ind)