fix(curriculum): editable regions in workshop binary search (#67780)

This commit is contained in:
Aditya Singh 2026-06-03 13:19:05 +05:30 committed by GitHub
parent 5828f78de5
commit e951b72d72
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 41 additions and 35 deletions

View File

@ -31,8 +31,8 @@ You should create a `path_to_target` variable set to an empty list within your `
## --seed-contents--
```py
--fcc-editable-region--
def binary_search(search_list, value):
--fcc-editable-region--
pass
--fcc-editable-region--
```

View File

@ -60,9 +60,9 @@ Your `high` variable should be set to `len(search_list) - 1`.
## --seed-contents--
```py
--fcc-editable-region--
def binary_search(search_list, value):
path_to_target = []
--fcc-editable-region--
--fcc-editable-region--
```

View File

@ -37,6 +37,7 @@ def binary_search(search_list, value):
path_to_target = []
low = 0
high = len(search_list) - 1
--fcc-editable-region--
--fcc-editable-region--

View File

@ -35,9 +35,9 @@ def binary_search(search_list, value):
path_to_target = []
low = 0
high = len(search_list) - 1
--fcc-editable-region--
while low <= high:
--fcc-editable-region--
pass
--fcc-editable-region--
```

View File

@ -34,10 +34,9 @@ def binary_search(search_list, value):
low = 0
high = len(search_list) - 1
--fcc-editable-region--
while low <= high:
mid = (low + high) // 2
--fcc-editable-region--
--fcc-editable-region--
```

View File

@ -32,10 +32,10 @@ def binary_search(search_list, value):
low = 0
high = len(search_list) - 1
--fcc-editable-region--
while low <= high:
mid = (low + high) // 2
value_at_middle = search_list[mid]
--fcc-editable-region--
--fcc-editable-region--
```

View File

@ -49,6 +49,7 @@ def binary_search(search_list, value):
mid = (low + high) // 2
value_at_middle = search_list[mid]
path_to_target.append(value_at_middle)
--fcc-editable-region--
--fcc-editable-region--

View File

@ -47,15 +47,15 @@ def binary_search(search_list, value):
path_to_target = []
low = 0
high = len(search_list) - 1
while low <= high:
mid = (low + high) // 2
value_at_middle = search_list[mid]
path_to_target.append(value_at_middle)
--fcc-editable-region--
if value == value_at_middle:
return path_to_target
--fcc-editable-region--
--fcc-editable-region--
```

View File

@ -47,12 +47,13 @@ def binary_search(search_list, value):
mid = (low + high) // 2
value_at_middle = search_list[mid]
path_to_target.append(value_at_middle)
if value == value_at_middle:
return path_to_target
break
return []
--fcc-editable-region--
--fcc-editable-region--

View File

@ -38,13 +38,14 @@ def binary_search(search_list, value):
mid = (low + high) // 2
value_at_middle = search_list[mid]
path_to_target.append(value_at_middle)
--fcc-editable-region--
if value == value_at_middle:
return path_to_target
--fcc-editable-region--
--fcc-editable-region--
--fcc-editable-region--
break
return []
print(binary_search([1, 2, 3, 4, 5], 3))

View File

@ -36,14 +36,15 @@ def binary_search(search_list, value):
mid = (low + high) // 2
value_at_middle = search_list[mid]
path_to_target.append(value_at_middle)
if value == value_at_middle:
return path_to_target
--fcc-editable-region--
elif value > value_at_middle:
pass
--fcc-editable-region--
pass
--fcc-editable-region--
break
return []
print(binary_search([1, 2, 3, 4, 5], 3))

View File

@ -30,12 +30,12 @@ def binary_search(search_list, value):
path_to_target = []
low = 0
high = len(search_list) - 1
while low <= high:
mid = (low + high) // 2
value_at_middle = search_list[mid]
path_to_target.append(value_at_middle)
if value == value_at_middle:
return path_to_target
elif value > value_at_middle:
@ -43,8 +43,9 @@ def binary_search(search_list, value):
--fcc-editable-region--
break
--fcc-editable-region--
return []
return []
print(binary_search([1, 2, 3, 4, 5], 3))
print(binary_search([1, 2, 3, 4, 5, 9], 4))
```

View File

@ -35,21 +35,21 @@ def binary_search(search_list, value):
path_to_target = []
low = 0
high = len(search_list) - 1
while low <= high:
mid = (low + high) // 2
value_at_middle = search_list[mid]
path_to_target.append(value_at_middle)
if value == value_at_middle:
return path_to_target
elif value > value_at_middle:
low = mid + 1
else:
high = mid - 1
return []
return []
print(binary_search([1, 2, 3, 4, 5], 3))
print(binary_search([1, 2, 3, 4, 5, 9], 4))
--fcc-editable-region--

View File

@ -33,19 +33,19 @@ def binary_search(search_list, value):
path_to_target = []
low = 0
high = len(search_list) - 1
while low <= high:
mid = (low + high) // 2
value_at_middle = search_list[mid]
path_to_target.append(value_at_middle)
if value == value_at_middle:
return path_to_target
elif value > value_at_middle:
low = mid + 1
else:
high = mid - 1
--fcc-editable-region--
return []
--fcc-editable-region--

View File

@ -37,11 +37,12 @@ def binary_search(search_list, value):
path_to_target = []
low = 0
high = len(search_list) - 1
while low <= high:
mid = (low + high) // 2
value_at_middle = search_list[mid]
path_to_target.append(value_at_middle)
if value == value_at_middle:
--fcc-editable-region--
return path_to_target
@ -50,7 +51,7 @@ def binary_search(search_list, value):
low = mid + 1
else:
high = mid - 1
return [], "Value not found"
print(binary_search([1, 2, 3, 4, 5], 3))
@ -65,19 +66,19 @@ def binary_search(search_list, value):
path_to_target = []
low = 0
high = len(search_list) - 1
while low <= high:
mid = (low + high) // 2
value_at_middle = search_list[mid]
path_to_target.append(value_at_middle)
if value == value_at_middle:
return path_to_target, f"Value found at index {mid}"
elif value > value_at_middle:
low = mid + 1
else:
high = mid - 1
return [], "Value not found"
print(binary_search([1, 2, 3, 4, 5], 3))