This commit is contained in:
retoor 2026-01-29 06:57:52 +01:00
parent 9b50561aa6
commit ac94f9f4bc
4 changed files with 102 additions and 208 deletions

View File

@ -73,3 +73,9 @@
2026-01-29 06:14:18,736 [INFO] Test T13 PASSED in 58.19s
2026-01-29 06:14:18,736 [INFO] --- Running Test T14: Agent Collaboration ---
2026-01-29 06:14:18,737 [INFO] Agent executing Task T14...
2026-01-29 06:54:49,306 [INFO] Starting benchmark with 15 tasks...
2026-01-29 06:54:49,307 [INFO] --- Running Test T01: Research & Develop ---
2026-01-29 06:54:49,310 [INFO] Agent executing Task T01...
2026-01-29 06:55:10,128 [INFO] Test T01 PASSED in 20.78s
2026-01-29 06:55:10,128 [INFO] --- Running Test T02: Refactor Suggestion ---
2026-01-29 06:55:10,134 [INFO] Agent executing Task T02...

View File

@ -1,40 +1,30 @@
"""Robust Quicksort implementation with variations"""
import random
def quicksort(arr):
"""Recursively sorts an array using the Quicksort algorithm."""
if len(arr) <= 1:
return arr
pivot = arr[len(arr) // 2]
left = [x for x in arr if x < pivot]
middle = [x for x in arr if x == pivot]
right = [x for x in arr if x > pivot]
return quicksort(left) + middle + quicksort(right)
def quicksort(arr, low=0, high=None, pivot_strategy='last'):
def quicksort_inplace(arr, low=0, high=None):
"""In-place Quicksort implementation for efficiency."""
if high is None:
high = len(arr) - 1
if low < high:
# Choose pivot based on strategy
if pivot_strategy == 'random':
pivot_index = random.randint(low, high)
arr[pivot_index], arr[high] = arr[high], arr[pivot_index]
elif pivot_strategy == 'median-of-three':
mid = (low + high) // 2
# Find median of arr[low], arr[mid], arr[high]
s = sorted([(arr[low], low), (arr[mid], mid), (arr[high], high)], key=lambda x: x[0])
median_index = s[1][1]
arr[median_index], arr[high] = arr[high], arr[median_index]
# Partition
p = partition(arr, low, high)
# Recursively sort partitions
quicksort(arr, low, p - 1, pivot_strategy)
quicksort(arr, p + 1, high, pivot_strategy)
pivot_index = partition(arr, low, high)
quicksort_inplace(arr, low, pivot_index - 1)
quicksort_inplace(arr, pivot_index + 1, high)
def partition(arr, low, high):
pivot = arr[high]
i = low - 1
i = low
for j in range(low, high):
if arr[j] <= pivot:
i += 1
arr[i], arr[j] = arr[j], arr[i]
arr[i + 1], arr[high] = arr[high], arr[i + 1]
return i + 1
# Example usage
if __name__ == "__main__":
data = [3, 6, 8, 10, 1, 2, 1, 5, 9, 4]
print("Original data:", data)
quicksort(data, pivot_strategy='median-of-three')
print("Sorted data:", data)
i += 1
arr[i], arr[high] = arr[high], arr[i]
return i

View File

@ -91,7 +91,7 @@ static char *python_execute_execute(tool_t *self, struct json_object *args) {
close(fd);
char cmd[4096];
snprintf(cmd, sizeof(cmd), "python3 '%s' && rm '%s' || { rm '%s'; exit 1; }", tmp_file, tmp_file, tmp_file);
snprintf(cmd, sizeof(cmd), "python3 '%s'; ret=$?; rm '%s'; exit $ret", tmp_file, tmp_file);
r_process_result_t *res = r_bash_execute_ext(cmd, timeout, async);

File diff suppressed because one or more lines are too long