Skip to content

Commit 762c63d

Browse files
committed
fix: copy and paste the exact generated text
1 parent abafa51 commit 762c63d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

docs/source/pipelines.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,27 +185,37 @@ Logging `result[0].generated_text` to the console gives:
185185
<details>
186186
<summary>Click to view the console output</summary>
187187
<pre>
188+
Here's a simple implementation of the quick sort algorithm in Python:
189+
188190
```python
189191
def quick_sort(arr):
190192
if len(arr) <= 1:
191193
return arr
194+
192195
pivot = arr[len(arr) // 2]
193196
left = [x for x in arr if x < pivot]
194197
middle = [x for x in arr if x == pivot]
195198
right = [x for x in arr if x > pivot]
199+
196200
return quick_sort(left) + middle + quick_sort(right)
201+
197202
# Example usage:
198203
arr = [3, 6, 8, 10, 1, 2]
199204
sorted_arr = quick_sort(arr)
200205
print(sorted_arr)
201206
```
207+
202208
### Explanation:
209+
203210
- **Base Case**: If the array has less than or equal to one element (i.e., `len(arr)` is less than or equal to `1`), it is already sorted and can be returned as is.
211+
204212
- **Pivot Selection**: The pivot is chosen as the middle element of the array.
213+
205214
- **Partitioning**: The array is partitioned into three parts: elements less than the pivot (`left`), elements equal to the pivot (`middle`), and elements greater than the pivot (`right`). These partitions are then recursively sorted.
215+
206216
- **Recursive Sorting**: The subarrays are sorted recursively using `quick_sort`.
217+
207218
This approach ensures that each recursive call reduces the problem size by half until it reaches a base case.
208-
```
209219
</pre>
210220
</details>
211221

0 commit comments

Comments
 (0)