Datasets:

Languages:
code
ArXiv:
Tags:
code
License:
Muennighoff commited on
Commit
c9a4e2f
1 Parent(s): e306346
data/python/data/humanevalbugs.jsonl CHANGED
@@ -57,7 +57,7 @@
57
  {"task_id": "Python/56", "prompt": "\n\ndef correct_bracketing(brackets: str):\n \"\"\" brackets is a string of \"<\" and \">\".\n return True if every opening bracket has a corresponding closing bracket.\n\n >>> correct_bracketing(\"<\")\n False\n >>> correct_bracketing(\"<>\")\n True\n >>> correct_bracketing(\"<<><>>\")\n True\n >>> correct_bracketing(\"><<>\")\n False\n \"\"\"\n", "canonical_solution": " depth = 0\n for b in brackets:\n if b == \"<\":\n depth += 1\n else:\n depth -= 1\n if depth < 0:\n return False\n return depth == 0\n", "test": "\n\nMETADATA = {}\n\n\ndef check(correct_bracketing):\n assert correct_bracketing(\"<>\")\n assert correct_bracketing(\"<<><>>\")\n assert correct_bracketing(\"<><><<><>><>\")\n assert correct_bracketing(\"<><><<<><><>><>><<><><<>>>\")\n assert not correct_bracketing(\"<<<><>>>>\")\n assert not correct_bracketing(\"><<>\")\n assert not correct_bracketing(\"<\")\n assert not correct_bracketing(\"<<<<\")\n assert not correct_bracketing(\">\")\n assert not correct_bracketing(\"<<>\")\n assert not correct_bracketing(\"<><><<><>><>><<>\")\n assert not correct_bracketing(\"<><><<><>><>>><>\")\n\ncheck(correct_bracketing)", "text": " brackets is a string of \"<\" and \">\".\n return True if every opening bracket has a corresponding closing bracket.\n\n >>> correct_bracketing(\"<\")\n False\n >>> correct_bracketing(\"<>\")\n True\n >>> correct_bracketing(\"<<><>>\")\n True\n >>> correct_bracketing(\"><<>\")\n False", "declaration": "def correct_bracketing(brackets: str):\n", "example_test": "def check(correct_bracketing):\n assert correct_bracketing(\"<>\")\n assert correct_bracketing(\"<<><>>\")\n assert not correct_bracketing(\"><<>\")\n assert not correct_bracketing(\"<\")\ncheck(correct_bracketing)\n", "buggy_solution": " depth = 0\n for b in brackets:\n if b == \">\":\n depth += 1\n else:\n depth -= 1\n if depth < 0:\n return False\n return depth == 0\n", "bug_type": "operator misuse", "failure_symptoms": "incorrect output", "entry_point": "correct_bracketing"}
58
  {"task_id": "Python/57", "prompt": "\n\ndef monotonic(l: list):\n \"\"\"Return True is list elements are monotonically increasing or decreasing.\n >>> monotonic([1, 2, 4, 20])\n True\n >>> monotonic([1, 20, 4, 10])\n False\n >>> monotonic([4, 1, 0, -10])\n True\n \"\"\"\n", "canonical_solution": " if l == sorted(l) or l == sorted(l, reverse=True):\n return True\n return False\n", "test": "\n\nMETADATA = {}\n\n\ndef check(monotonic):\n assert monotonic([1, 2, 4, 10]) == True\n assert monotonic([1, 2, 4, 20]) == True\n assert monotonic([1, 20, 4, 10]) == False\n assert monotonic([4, 1, 0, -10]) == True\n assert monotonic([4, 1, 1, 0]) == True\n assert monotonic([1, 2, 3, 2, 5, 60]) == False\n assert monotonic([1, 2, 3, 4, 5, 60]) == True\n assert monotonic([9, 9, 9, 9]) == True\n\ncheck(monotonic)", "text": " Return True is list elements are monotonically increasing or decreasing.\n >>> monotonic([1, 2, 4, 20])\n True\n >>> monotonic([1, 20, 4, 10])\n False\n >>> monotonic([4, 1, 0, -10])\n True", "declaration": "def monotonic(l: list):\n", "example_test": "def check(monotonic):\n assert monotonic([1, 2, 4, 10]) == True\n assert monotonic([1, 20, 4, 10]) == False\n assert monotonic([4, 1, 0, -10]) == True\ncheck(monotonic)\n", "buggy_solution": " if l == sorted(l) or l == sorted(l, reverse=True):\n return False\n return True\n", "bug_type": "operator misuse", "failure_symptoms": "incorrect output", "entry_point": "monotonic"}
59
  {"task_id": "Python/58", "prompt": "\n\ndef common(l1: list, l2: list):\n \"\"\"Return sorted unique common elements for two lists.\n >>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])\n [1, 5, 653]\n >>> common([5, 3, 2, 8], [3, 2])\n [2, 3]\n\n \"\"\"\n", "canonical_solution": " ret = set()\n for e1 in l1:\n for e2 in l2:\n if e1 == e2:\n ret.add(e1)\n return sorted(list(ret))\n", "test": "\n\nMETADATA = {}\n\n\ndef check(common):\n assert common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121]) == [1, 5, 653]\n assert common([5, 3, 2, 8], [3, 2]) == [2, 3]\n assert common([4, 3, 2, 8], [3, 2, 4]) == [2, 3, 4]\n assert common([4, 3, 2, 8], []) == []\n\ncheck(common)", "text": " Return sorted unique common elements for two lists.\n >>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])\n [1, 5, 653]\n >>> common([5, 3, 2, 8], [3, 2])\n [2, 3]", "declaration": "def common(l1: list, l2: list):\n", "example_test": "def check(common):\n assert common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121]) == [1, 5, 653]\n assert common([5, 3, 2, 8], [3, 2]) == [2, 3]\ncheck(common)\n", "buggy_solution": " ret = set()\n for e1 in l1:\n for e2 in l2:\n ret.add(e1)\n return sorted(list(ret))\n", "bug_type": "missing logic", "failure_symptoms": "incorrect output", "entry_point": "common"}
60
- {"task_id": "Python/59", "prompt": "\n\ndef largest_prime_factor(n: int):\n \"\"\"Return the largest prime factor of n. Assume n > 1 and is not a prime.\n >>> largest_prime_factor(13195)\n 29\n >>> largest_prime_factor(2048)\n 2\n \"\"\"\n", "canonical_solution": " def is_prime(k):\n if k < 2:\n return False\n for i in range(2, k - 1):\n if k % i == 0:\n return False\n return True\n largest = 1\n for j in range(2, n + 1):\n if n % j == 0 and is_prime(j):\n largest = max(largest, j)\n return largest\n", "test": "\n\nMETADATA = {}\n\n\ndef check(largest_prime_factor):\n assert largest_prime_factor(15) == 5\n assert largest_prime_factor(27) == 3\n assert largest_prime_factor(63) == 7\n assert largest_prime_factor(330) == 11\n assert largest_prime_factor(13195) == 29\n\ncheck(largest_prime_factor)", "text": " Return the largest prime factor of n. Assume n > 1 and is not a prime.\n >>> largest_prime_factor(13195)\n 29\n >>> largest_prime_factor(2048)\n 2", "declaration": "def largest_prime_factor(n: int):\n", "example_test": "def check(largest_prime_factor):\n assert largest_prime_factor(2048) == 2\n assert largest_prime_factor(13195) == 29\ncheck(largest_prime_factor)\n", "buggy_solution": " def is_prime(k):\n if k < 2:\n return False\n for i in range(2, k - 1):\n if k % i == 0:\n return False\n return True\n largest = 1\n for j in range(2, n + 1):\n if n % j == 0 and is_prime(j):\n largest = max(largest, j)\n return largest\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output", "entry_point": "largest_prime_factor"}
61
  {"task_id": "Python/60", "prompt": "\n\ndef sum_to_n(n: int):\n \"\"\"sum_to_n is a function that sums numbers from 1 to n.\n >>> sum_to_n(30)\n 465\n >>> sum_to_n(100)\n 5050\n >>> sum_to_n(5)\n 15\n >>> sum_to_n(10)\n 55\n >>> sum_to_n(1)\n 1\n \"\"\"\n", "canonical_solution": " return sum(range(n + 1))\n", "test": "\n\nMETADATA = {}\n\n\ndef check(sum_to_n):\n assert sum_to_n(1) == 1\n assert sum_to_n(6) == 21\n assert sum_to_n(11) == 66\n assert sum_to_n(30) == 465\n assert sum_to_n(100) == 5050\n\ncheck(sum_to_n)", "text": " sum_to_n is a function that sums numbers from 1 to n.\n >>> sum_to_n(30)\n 465\n >>> sum_to_n(100)\n 5050\n >>> sum_to_n(5)\n 15\n >>> sum_to_n(10)\n 55\n >>> sum_to_n(1)\n 1", "declaration": "def sum_to_n(n: int):\n", "example_test": "def check(sum_to_n):\n assert sum_to_n(1) == 1\n assert sum_to_n(5) == 15\n assert sum_to_n(10) == 55\n assert sum_to_n(30) == 465\n assert sum_to_n(100) == 5050\ncheck(sum_to_n)\n", "buggy_solution": " return sum(range(n))\n", "bug_type": "value misuse", "failure_symptoms": "incorrect output", "entry_point": "sum_to_n"}
62
  {"task_id": "Python/61", "prompt": "\n\ndef correct_bracketing(brackets: str):\n \"\"\" brackets is a string of \"(\" and \")\".\n return True if every opening bracket has a corresponding closing bracket.\n\n >>> correct_bracketing(\"(\")\n False\n >>> correct_bracketing(\"()\")\n True\n >>> correct_bracketing(\"(()())\")\n True\n >>> correct_bracketing(\")(()\")\n False\n \"\"\"\n", "canonical_solution": " depth = 0\n for b in brackets:\n if b == \"(\":\n depth += 1\n else:\n depth -= 1\n if depth < 0:\n return False\n return depth == 0\n", "test": "\n\nMETADATA = {}\n\n\ndef check(correct_bracketing):\n assert correct_bracketing(\"()\")\n assert correct_bracketing(\"(()())\")\n assert correct_bracketing(\"()()(()())()\")\n assert correct_bracketing(\"()()((()()())())(()()(()))\")\n assert not correct_bracketing(\"((()())))\")\n assert not correct_bracketing(\")(()\")\n assert not correct_bracketing(\"(\")\n assert not correct_bracketing(\"((((\")\n assert not correct_bracketing(\")\")\n assert not correct_bracketing(\"(()\")\n assert not correct_bracketing(\"()()(()())())(()\")\n assert not correct_bracketing(\"()()(()())()))()\")\n\ncheck(correct_bracketing)", "text": " brackets is a string of \"(\" and \")\".\n return True if every opening bracket has a corresponding closing bracket.\n\n >>> correct_bracketing(\"(\")\n False\n >>> correct_bracketing(\"()\")\n True\n >>> correct_bracketing(\"(()())\")\n True\n >>> correct_bracketing(\")(()\")\n False", "declaration": "def correct_bracketing(brackets: str):\n", "example_test": "def check(correct_bracketing):\n assert correct_bracketing(\"()\")\n assert correct_bracketing(\"(()())\")\n assert not correct_bracketing(\")(()\")\n assert not correct_bracketing(\"(\")\ncheck(correct_bracketing)\n", "buggy_solution": " depth = 0\n for b in brackets:\n if b == \"(\":\n depth += 1\n else:\n depth -= 1\n if depth < 0:\n return True\n return depth == 0\n", "bug_type": "operator misuse", "failure_symptoms": "incorrect output", "entry_point": "correct_bracketing"}
63
  {"task_id": "Python/62", "prompt": "\n\ndef derivative(xs: list):\n \"\"\" xs represent coefficients of a polynomial.\n xs[0] + xs[1] * x + xs[2] * x^2 + ....\n Return derivative of this polynomial in the same form.\n >>> derivative([3, 1, 2, 4, 5])\n [1, 4, 12, 20]\n >>> derivative([1, 2, 3])\n [2, 6]\n \"\"\"\n", "canonical_solution": " return [(i * x) for i, x in enumerate(xs)][1:]\n", "test": "\n\nMETADATA = {}\n\n\ndef check(derivative):\n assert derivative([3, 1, 2, 4, 5]) == [1, 4, 12, 20]\n assert derivative([1, 2, 3]) == [2, 6]\n assert derivative([3, 2, 1]) == [2, 2]\n assert derivative([3, 2, 1, 0, 4]) == [2, 2, 0, 16]\n assert derivative([1]) == []\n\ncheck(derivative)", "text": " xs represent coefficients of a polynomial.\n xs[0] + xs[1] * x + xs[2] * x^2 + ....\n Return derivative of this polynomial in the same form.\n >>> derivative([3, 1, 2, 4, 5])\n [1, 4, 12, 20]\n >>> derivative([1, 2, 3])\n [2, 6]", "declaration": "def derivative(xs: list):\n", "example_test": "def check(derivative):\n assert derivative([3, 1, 2, 4, 5]) == [1, 4, 12, 20]\n assert derivative([1, 2, 3]) == [2, 6]\ncheck(derivative)\n", "buggy_solution": " return [(i * x) for i, x in enumerate(xs)]\n", "bug_type": "value misuse", "failure_symptoms": "incorrect output", "entry_point": "derivative"}
 
57
  {"task_id": "Python/56", "prompt": "\n\ndef correct_bracketing(brackets: str):\n \"\"\" brackets is a string of \"<\" and \">\".\n return True if every opening bracket has a corresponding closing bracket.\n\n >>> correct_bracketing(\"<\")\n False\n >>> correct_bracketing(\"<>\")\n True\n >>> correct_bracketing(\"<<><>>\")\n True\n >>> correct_bracketing(\"><<>\")\n False\n \"\"\"\n", "canonical_solution": " depth = 0\n for b in brackets:\n if b == \"<\":\n depth += 1\n else:\n depth -= 1\n if depth < 0:\n return False\n return depth == 0\n", "test": "\n\nMETADATA = {}\n\n\ndef check(correct_bracketing):\n assert correct_bracketing(\"<>\")\n assert correct_bracketing(\"<<><>>\")\n assert correct_bracketing(\"<><><<><>><>\")\n assert correct_bracketing(\"<><><<<><><>><>><<><><<>>>\")\n assert not correct_bracketing(\"<<<><>>>>\")\n assert not correct_bracketing(\"><<>\")\n assert not correct_bracketing(\"<\")\n assert not correct_bracketing(\"<<<<\")\n assert not correct_bracketing(\">\")\n assert not correct_bracketing(\"<<>\")\n assert not correct_bracketing(\"<><><<><>><>><<>\")\n assert not correct_bracketing(\"<><><<><>><>>><>\")\n\ncheck(correct_bracketing)", "text": " brackets is a string of \"<\" and \">\".\n return True if every opening bracket has a corresponding closing bracket.\n\n >>> correct_bracketing(\"<\")\n False\n >>> correct_bracketing(\"<>\")\n True\n >>> correct_bracketing(\"<<><>>\")\n True\n >>> correct_bracketing(\"><<>\")\n False", "declaration": "def correct_bracketing(brackets: str):\n", "example_test": "def check(correct_bracketing):\n assert correct_bracketing(\"<>\")\n assert correct_bracketing(\"<<><>>\")\n assert not correct_bracketing(\"><<>\")\n assert not correct_bracketing(\"<\")\ncheck(correct_bracketing)\n", "buggy_solution": " depth = 0\n for b in brackets:\n if b == \">\":\n depth += 1\n else:\n depth -= 1\n if depth < 0:\n return False\n return depth == 0\n", "bug_type": "operator misuse", "failure_symptoms": "incorrect output", "entry_point": "correct_bracketing"}
58
  {"task_id": "Python/57", "prompt": "\n\ndef monotonic(l: list):\n \"\"\"Return True is list elements are monotonically increasing or decreasing.\n >>> monotonic([1, 2, 4, 20])\n True\n >>> monotonic([1, 20, 4, 10])\n False\n >>> monotonic([4, 1, 0, -10])\n True\n \"\"\"\n", "canonical_solution": " if l == sorted(l) or l == sorted(l, reverse=True):\n return True\n return False\n", "test": "\n\nMETADATA = {}\n\n\ndef check(monotonic):\n assert monotonic([1, 2, 4, 10]) == True\n assert monotonic([1, 2, 4, 20]) == True\n assert monotonic([1, 20, 4, 10]) == False\n assert monotonic([4, 1, 0, -10]) == True\n assert monotonic([4, 1, 1, 0]) == True\n assert monotonic([1, 2, 3, 2, 5, 60]) == False\n assert monotonic([1, 2, 3, 4, 5, 60]) == True\n assert monotonic([9, 9, 9, 9]) == True\n\ncheck(monotonic)", "text": " Return True is list elements are monotonically increasing or decreasing.\n >>> monotonic([1, 2, 4, 20])\n True\n >>> monotonic([1, 20, 4, 10])\n False\n >>> monotonic([4, 1, 0, -10])\n True", "declaration": "def monotonic(l: list):\n", "example_test": "def check(monotonic):\n assert monotonic([1, 2, 4, 10]) == True\n assert monotonic([1, 20, 4, 10]) == False\n assert monotonic([4, 1, 0, -10]) == True\ncheck(monotonic)\n", "buggy_solution": " if l == sorted(l) or l == sorted(l, reverse=True):\n return False\n return True\n", "bug_type": "operator misuse", "failure_symptoms": "incorrect output", "entry_point": "monotonic"}
59
  {"task_id": "Python/58", "prompt": "\n\ndef common(l1: list, l2: list):\n \"\"\"Return sorted unique common elements for two lists.\n >>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])\n [1, 5, 653]\n >>> common([5, 3, 2, 8], [3, 2])\n [2, 3]\n\n \"\"\"\n", "canonical_solution": " ret = set()\n for e1 in l1:\n for e2 in l2:\n if e1 == e2:\n ret.add(e1)\n return sorted(list(ret))\n", "test": "\n\nMETADATA = {}\n\n\ndef check(common):\n assert common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121]) == [1, 5, 653]\n assert common([5, 3, 2, 8], [3, 2]) == [2, 3]\n assert common([4, 3, 2, 8], [3, 2, 4]) == [2, 3, 4]\n assert common([4, 3, 2, 8], []) == []\n\ncheck(common)", "text": " Return sorted unique common elements for two lists.\n >>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])\n [1, 5, 653]\n >>> common([5, 3, 2, 8], [3, 2])\n [2, 3]", "declaration": "def common(l1: list, l2: list):\n", "example_test": "def check(common):\n assert common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121]) == [1, 5, 653]\n assert common([5, 3, 2, 8], [3, 2]) == [2, 3]\ncheck(common)\n", "buggy_solution": " ret = set()\n for e1 in l1:\n for e2 in l2:\n ret.add(e1)\n return sorted(list(ret))\n", "bug_type": "missing logic", "failure_symptoms": "incorrect output", "entry_point": "common"}
60
+ {"task_id": "Python/59", "prompt": "\n\ndef largest_prime_factor(n: int):\n \"\"\"Return the largest prime factor of n. Assume n > 1 and is not a prime.\n >>> largest_prime_factor(13195)\n 29\n >>> largest_prime_factor(2048)\n 2\n \"\"\"\n", "canonical_solution": " def is_prime(k):\n if k < 2:\n return False\n for i in range(2, k - 1):\n if k % i == 0:\n return False\n return True\n largest = 1\n for j in range(2, n + 1):\n if n % j == 0 and is_prime(j):\n largest = max(largest, j)\n return largest\n", "test": "\n\nMETADATA = {}\n\n\ndef check(largest_prime_factor):\n assert largest_prime_factor(15) == 5\n assert largest_prime_factor(27) == 3\n assert largest_prime_factor(63) == 7\n assert largest_prime_factor(330) == 11\n assert largest_prime_factor(13195) == 29\n\ncheck(largest_prime_factor)", "text": " Return the largest prime factor of n. Assume n > 1 and is not a prime.\n >>> largest_prime_factor(13195)\n 29\n >>> largest_prime_factor(2048)\n 2", "declaration": "def largest_prime_factor(n: int):\n", "example_test": "def check(largest_prime_factor):\n assert largest_prime_factor(2048) == 2\n assert largest_prime_factor(13195) == 29\ncheck(largest_prime_factor)\n", "buggy_solution": " def is_prime(k):\n if k < 2:\n return False\n for i in range(2, k - 1):\n if k % i == 0:\n return False\n return True\n largest = 1\n for j in range(2, n + 1):\n if n % j == 0 and is_prime(n):\n largest = max(largest, j)\n return largest\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output", "entry_point": "largest_prime_factor"}
61
  {"task_id": "Python/60", "prompt": "\n\ndef sum_to_n(n: int):\n \"\"\"sum_to_n is a function that sums numbers from 1 to n.\n >>> sum_to_n(30)\n 465\n >>> sum_to_n(100)\n 5050\n >>> sum_to_n(5)\n 15\n >>> sum_to_n(10)\n 55\n >>> sum_to_n(1)\n 1\n \"\"\"\n", "canonical_solution": " return sum(range(n + 1))\n", "test": "\n\nMETADATA = {}\n\n\ndef check(sum_to_n):\n assert sum_to_n(1) == 1\n assert sum_to_n(6) == 21\n assert sum_to_n(11) == 66\n assert sum_to_n(30) == 465\n assert sum_to_n(100) == 5050\n\ncheck(sum_to_n)", "text": " sum_to_n is a function that sums numbers from 1 to n.\n >>> sum_to_n(30)\n 465\n >>> sum_to_n(100)\n 5050\n >>> sum_to_n(5)\n 15\n >>> sum_to_n(10)\n 55\n >>> sum_to_n(1)\n 1", "declaration": "def sum_to_n(n: int):\n", "example_test": "def check(sum_to_n):\n assert sum_to_n(1) == 1\n assert sum_to_n(5) == 15\n assert sum_to_n(10) == 55\n assert sum_to_n(30) == 465\n assert sum_to_n(100) == 5050\ncheck(sum_to_n)\n", "buggy_solution": " return sum(range(n))\n", "bug_type": "value misuse", "failure_symptoms": "incorrect output", "entry_point": "sum_to_n"}
62
  {"task_id": "Python/61", "prompt": "\n\ndef correct_bracketing(brackets: str):\n \"\"\" brackets is a string of \"(\" and \")\".\n return True if every opening bracket has a corresponding closing bracket.\n\n >>> correct_bracketing(\"(\")\n False\n >>> correct_bracketing(\"()\")\n True\n >>> correct_bracketing(\"(()())\")\n True\n >>> correct_bracketing(\")(()\")\n False\n \"\"\"\n", "canonical_solution": " depth = 0\n for b in brackets:\n if b == \"(\":\n depth += 1\n else:\n depth -= 1\n if depth < 0:\n return False\n return depth == 0\n", "test": "\n\nMETADATA = {}\n\n\ndef check(correct_bracketing):\n assert correct_bracketing(\"()\")\n assert correct_bracketing(\"(()())\")\n assert correct_bracketing(\"()()(()())()\")\n assert correct_bracketing(\"()()((()()())())(()()(()))\")\n assert not correct_bracketing(\"((()())))\")\n assert not correct_bracketing(\")(()\")\n assert not correct_bracketing(\"(\")\n assert not correct_bracketing(\"((((\")\n assert not correct_bracketing(\")\")\n assert not correct_bracketing(\"(()\")\n assert not correct_bracketing(\"()()(()())())(()\")\n assert not correct_bracketing(\"()()(()())()))()\")\n\ncheck(correct_bracketing)", "text": " brackets is a string of \"(\" and \")\".\n return True if every opening bracket has a corresponding closing bracket.\n\n >>> correct_bracketing(\"(\")\n False\n >>> correct_bracketing(\"()\")\n True\n >>> correct_bracketing(\"(()())\")\n True\n >>> correct_bracketing(\")(()\")\n False", "declaration": "def correct_bracketing(brackets: str):\n", "example_test": "def check(correct_bracketing):\n assert correct_bracketing(\"()\")\n assert correct_bracketing(\"(()())\")\n assert not correct_bracketing(\")(()\")\n assert not correct_bracketing(\"(\")\ncheck(correct_bracketing)\n", "buggy_solution": " depth = 0\n for b in brackets:\n if b == \"(\":\n depth += 1\n else:\n depth -= 1\n if depth < 0:\n return True\n return depth == 0\n", "bug_type": "operator misuse", "failure_symptoms": "incorrect output", "entry_point": "correct_bracketing"}
63
  {"task_id": "Python/62", "prompt": "\n\ndef derivative(xs: list):\n \"\"\" xs represent coefficients of a polynomial.\n xs[0] + xs[1] * x + xs[2] * x^2 + ....\n Return derivative of this polynomial in the same form.\n >>> derivative([3, 1, 2, 4, 5])\n [1, 4, 12, 20]\n >>> derivative([1, 2, 3])\n [2, 6]\n \"\"\"\n", "canonical_solution": " return [(i * x) for i, x in enumerate(xs)][1:]\n", "test": "\n\nMETADATA = {}\n\n\ndef check(derivative):\n assert derivative([3, 1, 2, 4, 5]) == [1, 4, 12, 20]\n assert derivative([1, 2, 3]) == [2, 6]\n assert derivative([3, 2, 1]) == [2, 2]\n assert derivative([3, 2, 1, 0, 4]) == [2, 2, 0, 16]\n assert derivative([1]) == []\n\ncheck(derivative)", "text": " xs represent coefficients of a polynomial.\n xs[0] + xs[1] * x + xs[2] * x^2 + ....\n Return derivative of this polynomial in the same form.\n >>> derivative([3, 1, 2, 4, 5])\n [1, 4, 12, 20]\n >>> derivative([1, 2, 3])\n [2, 6]", "declaration": "def derivative(xs: list):\n", "example_test": "def check(derivative):\n assert derivative([3, 1, 2, 4, 5]) == [1, 4, 12, 20]\n assert derivative([1, 2, 3]) == [2, 6]\ncheck(derivative)\n", "buggy_solution": " return [(i * x) for i, x in enumerate(xs)]\n", "bug_type": "value misuse", "failure_symptoms": "incorrect output", "entry_point": "derivative"}