{
  "name": "quixbugs-python-quicksort",
  "description": "Fix bug in: quicksort",
  "dataset": "quixbugs",
  "instruction": "There is a Python file called quicksort.py in the current directory. It contains a buggy implementation of the quicksort algorithm. Find and fix the bug. The fix should be minimal - typically a single line change. Do not rewrite the entire function.",
  "setup_files": {
    "quicksort.py": "def quicksort(arr):\n    if not arr:\n        return []\n\n    pivot = arr[0]\n    lesser = quicksort([x for x in arr[1:] if x < pivot])\n    greater = quicksort([x for x in arr[1:] if x > pivot])\n    return lesser + [pivot] + greater\n\n\"\"\"\nQuickSort\n\n\nInput:\n    arr: A list of ints\n\nOutput:\n    The elements of arr in sorted order\n\"\"\"\n",
    "test_quicksort.py": "import sys\n\nfrom quicksort import quicksort\n\nFUNC_NAME = \"quicksort\"\ntest_cases = [[[[1, 2, 6, 72, 7, 33, 4]], [1, 2, 4, 6, 7, 33, 72]], [[[3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3]], [1, 1, 2, 3, 3, 3, 4, 5, 5, 5, 6, 7, 8, 9, 9, 9]], [[[5, 4, 3, 2, 1]], [1, 2, 3, 4, 5]], [[[5, 4, 3, 1, 2]], [1, 2, 3, 4, 5]], [[[8, 1, 14, 9, 15, 5, 4, 3, 7, 17, 11, 18, 2, 12, 16, 13, 6, 10]], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]], [[[9, 4, 5, 2, 17, 14, 10, 6, 15, 8, 12, 13, 16, 3, 1, 7, 11]], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]], [[[13, 14, 7, 16, 9, 5, 24, 21, 19, 17, 12, 10, 1, 15, 23, 25, 11, 3, 2, 6, 22, 8, 20, 4, 18]], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]], [[[8, 5, 15, 7, 9, 14, 11, 12, 10, 6, 2, 4, 13, 1, 3]], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]], [[[4, 3, 7, 6, 5, 2, 1]], [1, 2, 3, 4, 5, 6, 7]], [[[4, 3, 1, 5, 2]], [1, 2, 3, 4, 5]], [[[5, 4, 2, 3, 6, 7, 1]], [1, 2, 3, 4, 5, 6, 7]], [[[10, 16, 6, 1, 14, 19, 15, 2, 9, 4, 18, 17, 12, 3, 11, 8, 13, 5, 7]], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]], [[[10, 16, 6, 1, 14, 19, 15, 2, 9, 4, 18]], [1, 2, 4, 6, 9, 10, 14, 15, 16, 18, 19]]]\n\npassed = 0\nfailed = 0\nfor tc in test_cases:\n    inputs = tc[0]\n    expected = tc[1]\n    try:\n        result = quicksort(*inputs)\n        if result == expected:\n            passed += 1\n        else:\n            print(f\"FAIL: {FUNC_NAME}({inputs}) = {result}, expected {expected}\")\n            failed += 1\n    except Exception as e:\n        print(f\"ERROR: {FUNC_NAME}({inputs}) raised {e}\")\n        failed += 1\n\nprint(f\"{passed}/{passed+failed} tests passed\")\nif failed > 0:\n    sys.exit(1)\n"
  },
  "verify": "cd $BENCH_WORK_DIR && python3 test_quicksort.py",
  "timeout": 180000,
  "tags": [
    "quixbugs",
    "python",
    "bug-fix"
  ]
}