Skip to content

Commit 0517667

Browse files
authored
Update Day_17.md
1 parent 88da0db commit 0517667

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

Status/Day_17.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,26 @@ def binary_search_Ascending(array, target):
126126
Array = [1,5,8,10,12,13,55,66,73,78,82,85,88,99]
127127
print('The Value Found at Index:',binary_search_Ascending(Array, 82))
128128

129+
```
130+
---------------------
131+
**Solution by yuan1z: Python 3**
132+
```python
133+
idx = 0
134+
def bs(num,num_list):
135+
global idx
136+
if (len(num_list) == 1):
137+
if num_list[0] == num:
138+
return idx
139+
else:
140+
return "No exit in the list"
141+
elif num in num_list[:len(num_list)//2]:
142+
return bs(num,num_list[:len(num_list)//2])
143+
else:
144+
idx += len(num_list)//2
145+
return bs(num,num_list[len(num_list)//2:])
146+
147+
print(bs(66,[1,5,8,10,12,13,55,66,73,78,82,85,88,99,100]))
148+
129149
```
130150
---------------------
131151

@@ -190,4 +210,4 @@ print(rand_num)
190210

191211
[***go to next day***](https://github.com/darkprinx/100-plus-Python-programming-exercises-extended/blob/master/Status/Day_18.md "Day 18")
192212

193-
[***Discussion***](https://github.com/darkprinx/100-plus-Python-programming-exercises-extended/issues/3)
213+
[***Discussion***](https://github.com/darkprinx/100-plus-Python-programming-exercises-extended/issues/3)

0 commit comments

Comments
 (0)