Commit 3a9024da by BellCodeEditor

auto save

parent bb8205fa
Showing with 12 additions and 11 deletions
...@@ -3,13 +3,14 @@ num_list = [1, 3, 5, 8, 11, 15, 17, 18, 20, 21] ...@@ -3,13 +3,14 @@ num_list = [1, 3, 5, 8, 11, 15, 17, 18, 20, 21]
bingo_num=8 bingo_num=8
low=0 low=0
high=len(num_list)-1 high=len(num_list)-1
while low<=high: def
mid=(low+high)//2 while low<=high:
guess_num=num_list[mid] mid=(low+high)//2
if guess_num == bingo_num: guess_num=num_list[mid]
print("SB:"+str(mid)) if guess_num == bingo_num:
break print("SB:"+str(mid))
elif guess_num<bingo_num: break
low=mid+1 elif guess_num<bingo_num:
elif guess_num>bingo_num: low=mid+1
high=mid-1 elif guess_num>bingo_num:
\ No newline at end of file high=mid-1
\ 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