Commit 58b1117d by BellCodeEditor

save project

parent 5271c9f1
Showing with 16 additions and 0 deletions
num_list = [1, 3, 5, 8, 11, 15, 17, 18, 20, 21]
l=0
r=len(num_list)-1
go=20
while l<=r:
mid=(l+r)//2
guess=num_list[mid]
if guess==go:
print(mid)
exit()
elif guess<go:
l+=1
else:
r-=1
print("no")
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment