diff --git "a/all/mbpp_convert_300.json" "b/all/mbpp_convert_300.json" new file mode 100644--- /dev/null +++ "b/all/mbpp_convert_300.json" @@ -0,0 +1,2102 @@ +[ + { + "task_id": "601", + "prompt": "class Pair(object):\n def __init__(self, a, b):\n self.a = a\n self.b = b\n\ndef max_chain_length(arr, n):\n \"\"\" Find the longest chain which can be formed from the given set of pairs.\n >>> max_chain_length([Pair(5, 24), Pair(15, 25), Pair(27, 40), Pair(50, 60)], 4)\n 3\n >>> max_chain_length([Pair(1, 2), Pair(3, 4), Pair(5, 6), Pair(7, 8)], 4)\n 4\n \"\"\"\n", + "canonical_solution": " max = 0\n mcl = [1 for i in range(n)]\n for i in range(1, n):\n for j in range(0, i):\n if (arr[i].a > arr[j].b and mcl[i] < mcl[j] + 1):\n mcl[i] = mcl[j] + 1\n for i in range(n):\n if (max < mcl[i]):\n max = mcl[i]\n return max\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([Pair(5, 24), Pair(15, 25), Pair(27, 40), Pair(50, 60)], 4) == 3\n assert candidate([Pair(1, 2), Pair(3, 4), Pair(5, 6), Pair(7, 8)], 4) == 4\n assert candidate([Pair(19, 10), Pair(11, 12), Pair(13, 14), Pair(15, 16), Pair(31, 54)], 5) == 5\n", + "entry_point": "max_chain_length" + }, + { + "task_id": "HumanEval\\/602", + "prompt": "def first_repeated_char(str1: str) -> str:\n \"\"\" Find the first repeated character in a given string.\n >>> first_repeated_char(\"abcabc\")\n 'a'\n >>> first_repeated_char(\"abc\")\n 'None'\n >>> first_repeated_char(\"123123\")\n '1'\n \"\"\"\n", + "canonical_solution": " for index, c in enumerate(str1):\n if str1[:index+1].count(c) > 1:\n return c\n return \"None\"\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"abcabc\") == \"a\"\n assert candidate(\"abc\") == \"None\"\n assert candidate(\"123123\") == \"1\"\n", + "entry_point": "first_repeated_char" + }, + { + "task_id": "603", + "prompt": "def get_ludic(n):\n \"\"\" Write a function to get a lucid number smaller than or equal to n.\n >>> get_ludic(10)\n [1, 2, 3, 5, 7]\n >>> get_ludic(25)\n [1, 2, 3, 5, 7, 11, 13, 17, 23, 25]\n >>> get_ludic(45)\n [1, 2, 3, 5, 7, 11, 13, 17, 23, 25, 29, 37, 41, 43]\n \"\"\"\n", + "canonical_solution": " ludics = []\n for i in range(1, n + 1):\n ludics.append(i)\n index = 1\n while(index != len(ludics)):\n first_ludic = ludics[index]\n remove_index = index + first_ludic\n while(remove_index < len(ludics)):\n ludics.remove(ludics[remove_index])\n remove_index = remove_index + first_ludic - 1\n index += 1\n return ludics\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(10) == [1, 2, 3, 5, 7]\n assert candidate(25) == [1, 2, 3, 5, 7, 11, 13, 17, 23, 25]\n assert candidate(45) == [1, 2, 3, 5, 7, 11, 13, 17, 23, 25, 29, 37, 41, 43]\n", + "entry_point": "get_ludic" + }, + { + "task_id": "HumanEval\\/604", + "prompt": "def reverse_words(s: str) -> str:\n \"\"\" Reverse words in a given string\n >>> reverse_words(\"python program\")\n 'program python'\n >>> reverse_words(\"java language\")\n 'language java'\n >>> reverse_words(\"indian man\")\n 'man indian'\n \"\"\"\n", + "canonical_solution": " return ' '.join(reversed(s.split()))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"python program\") == \"program python\"\n assert candidate(\"java language\") == \"language java\"\n assert candidate(\"indian man\") == \"man indian\"\n", + "entry_point": "reverse_words" + }, + { + "task_id": "HumanEval\\/605", + "prompt": "def prime_num(num: int) -> bool:\n \"\"\" Check if the given integer is a prime number.\n >>> prime_num(13)\n True\n >>> prime_num(7)\n True\n >>> prime_num(-1010)\n False\n \"\"\"\n", + "canonical_solution": " if num <= 1:\n return False\n for i in range(2, int(num ** 0.5) + 1):\n if num % i == 0:\n return False\n return True\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(13) == True\n assert candidate(7) == True\n assert candidate(-1010) == False\n", + "entry_point": "prime_num" + }, + { + "task_id": "HumanEval\\/606", + "prompt": "import math\n\ndef radian_degree(degree: float) -> float:\n \"\"\" Convert degrees to radians\n >>> radian_degree(90)\n 1.5707963267948966\n >>> radian_degree(60)\n 1.0471975511965976\n >>> radian_degree(120)\n 2.0943951023931953\n \"\"\"\n", + "canonical_solution": " return degree * (math.pi / 180)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(90) == 1.5707963267948966\n assert candidate(60) == 1.0471975511965976\n assert candidate(120) == 2.0943951023931953\n", + "entry_point": "radian_degree" + }, + { + "task_id": "HumanEval\\/607", + "prompt": "import re\n\ndef find_literals(text: str, pattern: str) -> tuple:\n \"\"\" Search a literals string in a string and find the location within the original string where the pattern occurs by using regex.\n >>> find_literals('The quick brown fox jumps over the lazy dog.', 'fox')\n ('fox', 16, 19)\n >>> find_literals('Its been a very crazy procedure right', 'crazy')\n ('crazy', 16, 21)\n >>> find_literals('Hardest choices required strongest will', 'will')\n ('will', 35, 39)\n \"\"\"\n", + "canonical_solution": " match = re.search(pattern, text)\n s = match.start()\n e = match.end()\n return (match.re.pattern, s, e)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('The quick brown fox jumps over the lazy dog.', 'fox') == ('fox', 16, 19)\n assert candidate('Its been a very crazy procedure right', 'crazy') == ('crazy', 16, 21)\n assert candidate('Hardest choices required strongest will', 'will') == ('will', 35, 39)\n", + "entry_point": "find_literals" + }, + { + "task_id": "HumanEval\\/608", + "prompt": "def bell_Number(n: int) -> int:\n \"\"\"Calculate the nth Bell number.\n >>> bell_Number(2)\n 2\n >>> bell_Number(3)\n 5\n >>> bell_Number(4)\n 15\n \"\"\"\n", + "canonical_solution": " bell = [[0 for i in range(n+1)] for j in range(n+1)]\n bell[0][0] = 1\n for i in range(1, n+1):\n bell[i][0] = bell[i-1][i-1]\n for j in range(1, i+1):\n bell[i][j] = bell[i-1][j-1] + bell[i][j-1]\n return bell[n][0]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(2) == 2\n assert candidate(3) == 5\n assert candidate(4) == 15\n", + "entry_point": "bell_Number" + }, + { + "task_id": "609", + "prompt": "def floor_Min(A: int, B: int, N: int) -> int:\n \"\"\" Find the minimum possible value for the given periodic function.\n >>> floor_Min(10, 20, 30)\n 15\n >>> floor_Min(1, 2, 1)\n 0\n >>> floor_Min(11, 10, 9)\n 9\n \"\"\"\n", + "canonical_solution": " x = max(B - 1, N)\n return (A * x) // B\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(10, 20, 30) == 15\n assert candidate(1, 2, 1) == 0\n assert candidate(11, 10, 9) == 9\n", + "entry_point": "floor_Min" + }, + { + "task_id": "HumanEval\\/610", + "prompt": "from typing import List\n\n\ndef remove_kth_element(list1: List[int], L: int) -> List[int]:\n \"\"\" Remove the k'th element from a given list\n >>> remove_kth_element([1,1,2,3,4,4,5,1], 3)\n [1, 1, 3, 4, 4, 5, 1]\n >>> remove_kth_element([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4], 4)\n [0, 0, 1, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4]\n >>> remove_kth_element([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10], 5)\n [10, 10, 15, 19, 18, 17, 26, 26, 17, 18, 10]\n \"\"\"\n", + "canonical_solution": " return list1[:L-1] + list1[L:]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1,1,2,3,4,4,5,1], 3) == [1, 1, 3, 4, 4, 5, 1]\n assert candidate([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4], 4) == [0, 0, 1, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4]\n assert candidate([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10], 5) == [10, 10, 15, 19, 18, 17, 26, 26, 17, 18, 10]\n", + "entry_point": "remove_kth_element" + }, + { + "task_id": "611", + "prompt": "def max_of_nth(test_list: list, N: int) -> int:\n \"\"\" Find the maximum of nth column from the given tuple list.\n >>> max_of_nth([(5, 6, 7), (1, 3, 5), (8, 9, 19)], 2)\n 19\n >>> max_of_nth([(6, 7, 8), (2, 4, 6), (9, 10, 20)], 1)\n 10\n \"\"\"\n", + "canonical_solution": " res = max([sub[N] for sub in test_list])\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([(5, 6, 7), (1, 3, 5), (8, 9, 19)], 2) == 19\n assert candidate([(6, 7, 8), (2, 4, 6), (9, 10, 20)], 1) == 10\n assert candidate([(7, 8, 9), (3, 5, 7), (10, 11, 21)], 1) == 11\n", + "entry_point": "max_of_nth" + }, + { + "task_id": "HumanEval\\/612", + "prompt": "from typing import List\n\n\ndef merge(lst: List[List]) -> List[List]:\n \"\"\" Merge the first and last elements separately in a list of lists.\n >>> merge([['x', 'y'], ['a', 'b'], ['m', 'n']])\n [['x', 'a', 'm'], ['y', 'b', 'n']]\n >>> merge([[1, 2], [3, 4], [5, 6], [7, 8]])\n [[1, 3, 5, 7], [2, 4, 6, 8]]\n \"\"\"\n", + "canonical_solution": " return [list(ele) for ele in list(zip(*lst))]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([['x', 'y'], ['a', 'b'], ['m', 'n']]) == [['x', 'a', 'm'], ['y', 'b', 'n']]\n assert candidate([[1, 2], [3, 4], [5, 6], [7, 8]]) == [[1, 3, 5, 7], [2, 4, 6, 8]]\n assert candidate([['x', 'y', 'z'], ['a', 'b', 'c'], ['m', 'n', 'o']]) == [['x', 'a', 'm'], ['y', 'b', 'n'], ['z', 'c', 'o']]\n", + "entry_point": "merge" + }, + { + "task_id": "HumanEval\\/613", + "prompt": "from typing import List, Tuple\n\n\ndef maximum_value(test_list: List[Tuple[str, List[int]]]) -> List[Tuple[str, int]]:\n \"\"\" Write a function to find the maximum value in record list as tuple attribute in the given tuple list.\n >>> maximum_value([('key1', [3, 4, 5]), ('key2', [1, 4, 2]), ('key3', [9, 3])])\n [('key1', 5), ('key2', 4), ('key3', 9)]\n >>> maximum_value([('key1', [4, 5, 6]), ('key2', [2, 5, 3]), ('key3', [10, 4])])\n [('key1', 6), ('key2', 5), ('key3', 10)]\n \"\"\"\n", + "canonical_solution": " return [(key, max(lst)) for key, lst in test_list]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([('key1', [3, 4, 5]), ('key2', [1, 4, 2]), ('key3', [9, 3])]) == [('key1', 5), ('key2', 4), ('key3', 9)]\n assert candidate([('key1', [4, 5, 6]), ('key2', [2, 5, 3]), ('key3', [10, 4])]) == [('key1', 6), ('key2', 5), ('key3', 10)]\n assert candidate([('key1', [5, 6, 7]), ('key2', [3, 6, 4]), ('key3', [11, 5])]) == [('key1', 7), ('key2', 6), ('key3', 11)]\n", + "entry_point": "maximum_value" + }, + { + "task_id": "HumanEval\\/614", + "prompt": "def cummulative_sum(test_list: List[Tuple[int, ...]]) -> int:\n \"\"\" Write a function to find the cumulative sum of all the values that are present in the given tuple list.\n >>> cummulative_sum([(1, 3), (5, 6, 7), (2, 6)])\n 30\n >>> cummulative_sum([(2, 4), (6, 7, 8), (3, 7)])\n 37\n >>> cummulative_sum([(3, 5), (7, 8, 9), (4, 8)])\n 44\n \"\"\"\n", + "canonical_solution": " return sum(map(sum, test_list))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([(1, 3), (5, 6, 7), (2, 6)]) == 30\n assert candidate([(2, 4), (6, 7, 8), (3, 7)]) == 37\n assert candidate([(3, 5), (7, 8, 9), (4, 8)]) == 44\n", + "entry_point": "cummulative_sum" + }, + { + "task_id": "HumanEval\\/615", + "prompt": "def average_tuple(nums):\n \"\"\" Write a function to find average value of the numbers in a given tuple of tuples.\n >>> average_tuple(((10, 10, 10, 12), (30, 45, 56, 45), (81, 80, 39, 32), (1, 2, 3, 4)))\n [30.5, 34.25, 27.0, 23.25]\n >>> average_tuple(((1, 1, -5), (30, -15, 56), (81, -60, -39), (-10, 2, 3)))\n [25.5, -18.0, 3.75]\n >>> average_tuple(((100, 100, 100, 120), (300, 450, 560, 450), (810, 800, 390, 320), (10, 20, 30, 40)))\n [305.0, 342.5, 270.0, 232.5]\n \"\"\"\n", + "canonical_solution": " result = [sum(x) / len(x) for x in zip(*nums)]\n return result\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(((10, 10, 10, 12), (30, 45, 56, 45), (81, 80, 39, 32), (1, 2, 3, 4))) == [30.5, 34.25, 27.0, 23.25]\n assert candidate(((1, 1, -5), (30, -15, 56), (81, -60, -39), (-10, 2, 3))) == [25.5, -18.0, 3.75]\n assert candidate(((100, 100, 100, 120), (300, 450, 560, 450), (810, 800, 390, 320), (10, 20, 30, 40))) == [305.0, 342.5, 270.0, 232.5]\n", + "entry_point": "average_tuple" + }, + { + "task_id": "HumanEval\\/616", + "prompt": "def tuple_modulo(test_tup1: tuple, test_tup2: tuple) -> tuple:\n \"\"\" Perform the modulo of tuple elements in the given two tuples.\n >>> tuple_modulo((10, 4, 5, 6), (5, 6, 7, 5))\n (0, 4, 5, 1)\n >>> tuple_modulo((11, 5, 6, 7), (6, 7, 8, 6))\n (5, 5, 6, 1)\n >>> tuple_modulo((12, 6, 7, 8), (7, 8, 9, 7))\n (5, 6, 7, 1)\n \"\"\"\n", + "canonical_solution": " res = tuple(ele1 % ele2 for ele1, ele2 in zip(test_tup1, test_tup2))\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate((10, 4, 5, 6), (5, 6, 7, 5)) == (0, 4, 5, 1)\n assert candidate((11, 5, 6, 7), (6, 7, 8, 6)) == (5, 5, 6, 1)\n assert candidate((12, 6, 7, 8), (7, 8, 9, 7)) == (5, 6, 7, 1)\n", + "entry_point": "tuple_modulo" + }, + { + "task_id": "HumanEval\\/617", + "prompt": "def min_Jumps(a: int, b: int, d: int) -> float:\n \"\"\" Calculate the number of jumps required of given length to reach a point (d, 0) from origin in a 2d plane.\n >>> min_Jumps(3, 4, 11)\n 3.5\n >>> min_Jumps(3, 4, 0)\n 0\n >>> min_Jumps(11, 14, 11)\n 1\n \"\"\"\n", + "canonical_solution": " temp = a\n a = min(a, b)\n b = max(temp, b)\n if (d >= b):\n return (d + b - 1) / b\n if (d == 0):\n return 0\n if (d == a):\n return 1\n else:\n return 2\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(3, 4, 11) == 3.5\n assert candidate(3, 4, 0) == 0\n assert candidate(11, 14, 11) == 1\n", + "entry_point": "min_Jumps" + }, + { + "task_id": "HumanEval\\/618", + "prompt": "from typing import List\n\n\ndef div_list(nums1: List[float], nums2: List[float]) -> List[float]:\n \"\"\" Divide two lists element-wise using map and lambda function.\n >>> div_list([4,5,6],[1, 2, 3])\n [4.0, 2.5, 2.0]\n >>> div_list([3,2],[1,4])\n [3.0, 0.5]\n >>> div_list([90,120],[50,70])\n [1.8, 1.7142857142857142]\n \"\"\"\n", + "canonical_solution": " result = map(lambda x, y: x / y, nums1, nums2)\n return list(result)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([4,5,6],[1, 2, 3]) == [4.0, 2.5, 2.0]\n assert candidate([3,2],[1,4]) == [3.0, 0.5]\n assert candidate([90,120],[50,70]) == [1.8, 1.7142857142857142]\n", + "entry_point": "div_list" + }, + { + "task_id": "HumanEval\\/619", + "prompt": "def move_num(test_str: str) -> str:\n \"\"\" Move all the numbers in the string to the end of it.\n >>> move_num('I1love143you55three3000thousand')\n 'Iloveyouthreethousand1143553000'\n >>> move_num('Avengers124Assemble')\n 'AvengersAssemble124'\n >>> move_num('Its11our12path13to14see15things16do17things')\n 'Itsourpathtoseethingsdothings11121314151617'\n \"\"\"\n", + "canonical_solution": " res = ''\n dig = ''\n for ele in test_str:\n if ele.isdigit():\n dig += ele\n else:\n res += ele\n res += dig\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('I1love143you55three3000thousand') == 'Iloveyouthreethousand1143553000'\n assert candidate('Avengers124Assemble') == 'AvengersAssemble124'\n assert candidate('Its11our12path13to14see15things16do17things') == 'Itsourpathtoseethingsdothings11121314151617'\n", + "entry_point": "move_num" + }, + { + "task_id": "HumanEval\\/620", + "prompt": "def largest_subset(a, n):\n \"\"\" Find the largest subset where each pair is divisible\n >>> largest_subset([1, 3, 6, 13, 17, 18], 6)\n 4\n >>> largest_subset([10, 5, 3, 15, 20], 5)\n 3\n >>> largest_subset([18, 1, 3, 6, 13, 17], 6)\n 4\n \"\"\"\n", + "canonical_solution": " dp = [0 for i in range(n)]\n dp[n - 1] = 1;\n for i in range(n - 2, -1, -1):\n mxm = 0;\n for j in range(i + 1, n):\n if a[j] % a[i] == 0 or a[i] % a[j] == 0:\n mxm = max(mxm, dp[j])\n dp[i] = 1 + mxm\n return max(dp)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 3, 6, 13, 17, 18], 6) == 4\n assert candidate([10, 5, 3, 15, 20], 5) == 3\n assert candidate([18, 1, 3, 6, 13, 17], 6) == 4\n", + "entry_point": "largest_subset" + }, + { + "task_id": "621", + "prompt": "from typing import List\n\n\ndef increment_numerics(test_list: List[str], K: int) -> List[str]:\n \"\"\" Increment the numeric values in the given strings by K.\n >>> increment_numerics([\"MSM\", \"234\", \"is\", \"98\", \"123\", \"best\", \"4\"], 6)\n ['MSM', '240', 'is', '104', '129', 'best', '10']\n >>> increment_numerics([\"Dart\", \"356\", \"is\", \"88\", \"169\", \"Super\", \"6\"], 12)\n ['Dart', '368', 'is', '100', '181', 'Super', '18']\n \"\"\"\n", + "canonical_solution": " return [str(int(ele) + K) if ele.isdigit() else ele for ele in test_list]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([\"MSM\", \"234\", \"is\", \"98\", \"123\", \"best\", \"4\"], 6) == ['MSM', '240', 'is', '104', '129', 'best', '10']\n assert candidate([\"Dart\", \"356\", \"is\", \"88\", \"169\", \"Super\", \"6\"], 12) == ['Dart', '368', 'is', '100', '181', 'Super', '18']\n assert candidate([\"Flutter\", \"451\", \"is\", \"44\", \"96\", \"Magnificent\", \"12\"], 33) == ['Flutter', '484', 'is', '77', '129', 'Magnificent', '45']\n", + "entry_point": "increment_numerics" + }, + { + "task_id": "622", + "prompt": "def get_median(arr1, arr2, n):\n \"\"\"Find the median of two sorted arrays of the same size.\n >>> get_median([1, 12, 15, 26, 38], [2, 13, 17, 30, 45], 5)\n 16.0\n >>> get_median([2, 4, 8, 9], [7, 13, 19, 28], 4)\n 8.5\n >>> get_median([3, 6, 14, 23, 36, 42], [2, 18, 27, 39, 49, 55], 6)\n 25.0\n \"\"\"\n", + "canonical_solution": " i = 0\n j = 0\n m1 = -1\n m2 = -1\n count = 0\n while count < n + 1:\n count += 1\n if i == n:\n m1 = m2\n m2 = arr2[0]\n break\n elif j == n:\n m1 = m2\n m2 = arr1[0]\n break\n if arr1[i] <= arr2[j]:\n m1 = m2\n m2 = arr1[i]\n i += 1\n else:\n m1 = m2\n m2 = arr2[j]\n j += 1\n return (m1 + m2)/2\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 12, 15, 26, 38], [2, 13, 17, 30, 45], 5) == 16.0\n assert candidate([2, 4, 8, 9], [7, 13, 19, 28], 4) == 8.5\n assert candidate([3, 6, 14, 23, 36, 42], [2, 18, 27, 39, 49, 55], 6) == 25.0\n", + "entry_point": "get_median" + }, + { + "task_id": "HumanEval\\/623", + "prompt": "from typing import List\n\n\ndef nth_nums(nums: List[int], n: int) -> List[int]:\n \"\"\" Find the n-th power of individual elements in a list using lambda function.\n >>> nth_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 2)\n [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]\n >>> nth_nums([10, 20, 30], 3)\n [1000, 8000, 27000]\n >>> nth_nums([12, 15], 5)\n [248832, 759375]\n \"\"\"\n", + "canonical_solution": " return list(map(lambda x: x ** n, nums))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 2) == [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]\n assert candidate([10, 20, 30], 3) == [1000, 8000, 27000]\n assert candidate([12, 15], 5) == [248832, 759375]\n", + "entry_point": "nth_nums" + }, + { + "task_id": "HumanEval\\/624", + "prompt": "def is_upper(string: str) -> str:\n \"\"\" Convert the given string to upper case.\n >>> is_upper(\"person\")\n 'PERSON'\n >>> is_upper(\"final\")\n 'FINAL'\n >>> is_upper(\"Valid\")\n 'VALID'\n \"\"\"\n", + "canonical_solution": " return string.upper()\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"person\") == 'PERSON'\n assert candidate(\"final\") == 'FINAL'\n assert candidate(\"Valid\") == 'VALID'\n", + "entry_point": "is_upper" + }, + { + "task_id": "HumanEval\\/625", + "prompt": "from typing import List\n\n\ndef swap_List(newList: List[int]) -> List[int]:\n \"\"\" Interchange first and last elements in a given list\n >>> swap_List([1,2,3])\n [3,2,1]\n >>> swap_List([1,2,3,4,4])\n [4,2,3,4,1]\n >>> swap_List([4,5,6])\n [6,5,4]\n \"\"\"\n", + "canonical_solution": " size = len(newList)\n temp = newList[0]\n newList[0] = newList[size - 1]\n newList[size - 1] = temp\n return newList\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1,2,3]) == [3,2,1]\n assert candidate([1,2,3,4,4]) == [4,2,3,4,1]\n assert candidate([4,5,6]) == [6,5,4]\n", + "entry_point": "swap_List" + }, + { + "task_id": "HumanEval\\/626", + "prompt": "def triangle_area(r: float) -> float:\n \"\"\" Calculate the area of the largest triangle that can be inscribed in a semicircle of radius r.\n >>> triangle_area(0)\n 0\n >>> triangle_area(-1)\n -1\n >>> triangle_area(2)\n 2.0\n \"\"\"\n", + "canonical_solution": " if r < 0:\n return -1\n return r * r / 2\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(0) == 0\n assert candidate(-1) == -1\n assert candidate(2) == 2.0\n", + "entry_point": "triangle_area" + }, + { + "task_id": "HumanEval\\/627", + "prompt": "def find_First_Missing(array, start, end):\n \"\"\"Find the smallest missing number from the given sorted array.\n >>> find_First_Missing([0, 1, 2, 3], 0, 3)\n 4\n >>> find_First_Missing([0, 1, 2, 6, 9], 0, 4)\n 3\n >>> find_First_Missing([2, 3, 5, 8, 9], 0, 4)\n 0\n \"\"\"\n", + "canonical_solution": " if (start > end):\n return end + 1\n if (start != array[start]):\n return start\n mid = int((start + end) / 2)\n if (array[mid] == mid):\n return find_First_Missing(array, mid + 1, end)\n return find_First_Missing(array, start, mid)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([0, 1, 2, 3], 0, 3) == 4\n assert candidate([0, 1, 2, 6, 9], 0, 4) == 3\n assert candidate([2, 3, 5, 8, 9], 0, 4) == 0\n", + "entry_point": "find_First_Missing" + }, + { + "task_id": "HumanEval\\/628", + "prompt": "def replace_spaces(string: str) -> str:\n \"\"\" Replace all spaces in the given string with '%20'.\n >>> replace_spaces('My Name is Dawood')\n 'My%20Name%20is%20Dawood'\n >>> replace_spaces('I am a Programmer')\n 'I%20am%20a%20Programmer'\n >>> replace_spaces('I love Coding')\n 'I%20love%20Coding'\n \"\"\"\n", + "canonical_solution": " string = string.strip()\n return string.replace(' ', '%20')\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('My Name is Dawood') == 'My%20Name%20is%20Dawood'\n assert candidate('I am a Programmer') == 'I%20am%20a%20Programmer'\n assert candidate('I love Coding') == 'I%20love%20Coding'\n", + "entry_point": "replace_spaces" + }, + { + "task_id": "HumanEval\\/629", + "prompt": "from typing import List, Union\n\n\ndef Split(lst: List[Union[int, float]]) -> List[int]:\n \"\"\" Find even numbers from a mixed list\n >>> Split([1, 2, 3, 4, 5])\n [2, 4]\n >>> Split([4, 5, 6, 7, 8, 0, 1])\n [4, 6, 8, 0]\n >>> Split([8, 12, 15, 19])\n [8, 12]\n \"\"\"\n", + "canonical_solution": " ev_li = []\n for i in lst:\n if isinstance(i, int) and i % 2 == 0:\n ev_li.append(i)\n return ev_li\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 2, 3, 4, 5]) == [2, 4]\n assert candidate([4, 5, 6, 7, 8, 0, 1]) == [4, 6, 8, 0]\n assert candidate([8, 12, 15, 19]) == [8, 12]\n", + "entry_point": "Split" + }, + { + "task_id": "HumanEval\\/630", + "prompt": "from typing import List, Tuple\n\n\ndef get_coordinates(test_tup: Tuple[int, int]) -> List[List[int]]:\n \"\"\" Extract all the adjacent coordinates of the given coordinate tuple.\n >>> get_coordinates((3, 4))\n [[2, 3], [2, 4], [2, 5], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5]]\n >>> get_coordinates((4, 5))\n [[3, 4], [3, 5], [3, 6], [4, 4], [4, 5], [4, 6], [5, 4], [5, 5], [5, 6]]\n \"\"\"\n", + "canonical_solution": " def adjac(ele, sub=[]):\n if not ele:\n yield sub\n else:\n yield from [idx for j in range(ele[0] - 1, ele[0] + 2)\n for idx in adjac(ele[1:], sub + [j])]\n res = list(adjac(test_tup))\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate((3, 4)) == [[2, 3], [2, 4], [2, 5], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5]]\n assert candidate((4, 5)) == [[3, 4], [3, 5], [3, 6], [4, 4], [4, 5], [4, 6], [5, 4], [5, 5], [5, 6]]\n assert candidate((5, 6)) == [[4, 5], [4, 6], [4, 7], [5, 5], [5, 6], [5, 7], [6, 5], [6, 6], [6, 7]]\n", + "entry_point": "get_coordinates" + }, + { + "task_id": "HumanEval\\/631", + "prompt": "import re\n\ndef replace_spaces(text: str) -> str:\n \"\"\" Replace whitespaces with an underscore and vice versa in a given string using regex.\n >>> replace_spaces('Jumanji The Jungle')\n 'Jumanji_The_Jungle'\n >>> replace_spaces('The Avengers')\n 'The_Avengers'\n >>> replace_spaces('Fast and Furious')\n 'Fast_and_Furious'\n \"\"\"\n", + "canonical_solution": " text = re.sub(r' ', '_', text)\n text = re.sub(r'_', ' ', text)\n return text\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('Jumanji The Jungle') == 'Jumanji_The_Jungle'\n assert candidate('The Avengers') == 'The_Avengers'\n assert candidate('Fast and Furious') == 'Fast_and_Furious'\n", + "entry_point": "replace_spaces" + }, + { + "task_id": "HumanEval\\/632", + "prompt": "from typing import List\n\n\ndef move_zero(num_list: List[int]) -> List[int]:\n \"\"\" Move all zeroes to the end of the given list\n >>> move_zero([1,0,2,0,3,4])\n [1,2,3,4,0,0]\n >>> move_zero([2,3,2,0,0,4,0,5,0])\n [2,3,2,4,5,0,0,0,0]\n >>> move_zero([0,1,0,1,1])\n [1,1,1,0,0]\n \"\"\"\n", + "canonical_solution": " a = [0 for i in range(num_list.count(0))]\n x = [i for i in num_list if i != 0]\n x.extend(a)\n return x\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1,0,2,0,3,4]) == [1,2,3,4,0,0]\n assert candidate([2,3,2,0,0,4,0,5,0]) == [2,3,2,4,5,0,0,0,0]\n assert candidate([0,1,0,1,1]) == [1,1,1,0,0]\n", + "entry_point": "move_zero" + }, + { + "task_id": "HumanEval\\/633", + "prompt": "from typing import List\n\n\ndef pair_OR_Sum(arr: List[int], n: int) -> int:\n \"\"\" Write a python function to find the sum of xor of all pairs of numbers in the given array.\n >>> pair_OR_Sum([5,9,7,6], 4)\n 47\n >>> pair_OR_Sum([7,3,5], 3)\n 12\n >>> pair_OR_Sum([7,3], 2)\n 4\n \"\"\"\n", + "canonical_solution": " ans = 0\n for i in range(0, n):\n for j in range(i + 1, n):\n ans = ans + (arr[i] ^ arr[j])\n return ans\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([5,9,7,6], 4) == 47\n assert candidate([7,3,5], 3) == 12\n assert candidate([7,3], 2) == 4\n", + "entry_point": "pair_OR_Sum" + }, + { + "task_id": "HumanEval\\/634", + "prompt": "def even_Power_Sum(n: int) -> int:\n \"\"\"Calculate the sum of the fourth power of the first n even natural numbers.\n >>> even_Power_Sum(2)\n 272\n >>> even_Power_Sum(3)\n 1568\n >>> even_Power_Sum(4)\n 5664\n \"\"\"\n", + "canonical_solution": " sum = 0\n for i in range(1, n + 1):\n j = 2 * i\n sum += j ** 4\n return sum\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(2) == 272\n assert candidate(3) == 1568\n assert candidate(4) == 5664\n", + "entry_point": "even_Power_Sum" + }, + { + "task_id": "HumanEval\\/635", + "prompt": "import heapq as hq\n\n\ndef heap_sort(iterable):\n \"\"\" Push all values into a heap and then pop off the smallest values one at a time.\n >>> heap_sort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])\n [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n >>> heap_sort([25, 35, 22, 85, 14, 65, 75, 25, 58])\n [14, 22, 25, 25, 35, 58, 65, 75, 85]\n >>> heap_sort([7, 1, 9, 5])\n [1, 5, 7, 9]\n \"\"\"\n", + "canonical_solution": " h = []\n for value in iterable:\n hq.heappush(h, value)\n return [hq.heappop(h) for i in range(len(h))]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 3, 5, 7, 9, 2, 4, 6, 8, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate([25, 35, 22, 85, 14, 65, 75, 25, 58]) == [14, 22, 25, 25, 35, 58, 65, 75, 85]\n assert candidate([7, 1, 9, 5]) == [1, 5, 7, 9]\n", + "entry_point": "heap_sort" + }, + { + "task_id": "HumanEval\\/636", + "prompt": "def Check_Solution(a: int, b: int, c: int) -> str:\n \"\"\" Check if roots of a quadratic equation are reciprocal of each other.\n >>> Check_Solution(2, 0, 2)\n 'Yes'\n >>> Check_Solution(2, -5, 2)\n 'Yes'\n >>> Check_Solution(1, 2, 3)\n 'No'\n \"\"\"\n", + "canonical_solution": " if a == c:\n return \"Yes\"\n else:\n return \"No\"\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(2, 0, 2) == 'Yes'\n assert candidate(2, -5, 2) == 'Yes'\n assert candidate(1, 2, 3) == 'No'\n", + "entry_point": "Check_Solution" + }, + { + "task_id": "HumanEval\\/637", + "prompt": "def noprofit_noloss(actual_cost: int, sale_amount: int) -> bool:\n \"\"\" Check whether the given amount has no profit and no loss\n >>> noprofit_noloss(1500, 1200)\n False\n >>> noprofit_noloss(100, 100)\n True\n >>> noprofit_noloss(2000, 5000)\n False\n \"\"\"\n", + "canonical_solution": " return sale_amount == actual_cost\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(1500, 1200) == False\n assert candidate(100, 100) == True\n assert candidate(2000, 5000) == False\n", + "entry_point": "noprofit_noloss" + }, + { + "task_id": "HumanEval\\/638", + "prompt": "import math\n\ndef wind_chill(v: float, t: float) -> int:\n \"\"\" Calculate the wind chill index given the wind speed v (in km/h) and the temperature t (in degrees Celsius).\n >>> wind_chill(120, 35)\n 40\n >>> wind_chill(40, 70)\n 86\n >>> wind_chill(10, 100)\n 116\n \"\"\"\n", + "canonical_solution": " windchill = 13.12 + 0.6215*t - 11.37*math.pow(v, 0.16) + 0.3965*t*math.pow(v, 0.16)\n return int(round(windchill, 0))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(120, 35) == 40\n assert candidate(40, 70) == 86\n assert candidate(10, 100) == 116\n", + "entry_point": "wind_chill" + }, + { + "task_id": "HumanEval\\/639", + "prompt": "from typing import List\n\n\ndef sample_nam(sample_names: List[str]) -> int:\n \"\"\" Write a function to sum the length of the names of a given list of names after removing the names that start with a lowercase letter.\n >>> sample_nam(['sally', 'Dylan', 'rebecca', 'Diana', 'Joanne', 'keith'])\n 16\n >>> sample_nam([\"php\", \"res\", \"Python\", \"abcd\", \"Java\", \"aaa\"])\n 10\n >>> sample_nam([\"abcd\", \"Python\", \"abba\", \"aba\"])\n 6\n \"\"\"\n", + "canonical_solution": " sample_names = list(filter(lambda el: el[0].isupper() and el[1:].islower(), sample_names))\n return len(''.join(sample_names))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(['sally', 'Dylan', 'rebecca', 'Diana', 'Joanne', 'keith']) == 16\n assert candidate([\"php\", \"res\", \"Python\", \"abcd\", \"Java\", \"aaa\"]) == 10\n assert candidate([\"abcd\", \"Python\", \"abba\", \"aba\"]) == 6\n", + "entry_point": "sample_nam" + }, + { + "task_id": "HumanEval\\/640", + "prompt": "import re\nfrom typing import List\n\n\ndef remove_parenthesis(items: List[str]) -> str:\n \"\"\" Remove the parenthesis area in a string\n >>> remove_parenthesis([\"python (chrome)\"])\n 'python'\n >>> remove_parenthesis([\"string(.abc)\"])\n 'string'\n >>> remove_parenthesis([\"alpha(num)\"])\n 'alpha'\n \"\"\"\n", + "canonical_solution": " return re.sub(r\" ?\\([^)]+\\)\", \"\", items[0])\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([\"python (chrome)\"]) == 'python'\n assert candidate([\"string(.abc)\"]) == 'string'\n assert candidate([\"alpha(num)\"]) == 'alpha'\n", + "entry_point": "remove_parenthesis" + }, + { + "task_id": "HumanEval\\/641", + "prompt": "def is_nonagonal(n: int) -> int:\n \"\"\" Calculate the nth nonagonal number\n >>> is_nonagonal(10)\n 325\n >>> is_nonagonal(15)\n 750\n >>> is_nonagonal(18)\n 1089\n \"\"\"\n", + "canonical_solution": " return int(n * (7 * n - 5) / 2)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(10) == 325\n assert candidate(15) == 750\n assert candidate(18) == 1089\n", + "entry_point": "is_nonagonal" + }, + { + "task_id": "HumanEval\\/642", + "prompt": "def remove_similar_row(test_list):\n \"\"\"Remove similar rows from the given tuple matrix.\n >>> remove_similar_row([[(4, 5), (3, 2)], [(2, 2), (4, 6)], [(3, 2), (4, 5)]] )\n {((2, 2), (4, 6)), ((3, 2), (4, 5))}\n >>> remove_similar_row([[(5, 6), (4, 3)], [(3, 3), (5, 7)], [(4, 3), (5, 6)]] )\n {((4, 3), (5, 6)), ((3, 3), (5, 7))}\n >>> remove_similar_row([[(6, 7), (5, 4)], [(4, 4), (6, 8)], [(5, 4), (6, 7)]] )\n {((4, 4), (6, 8)), ((5, 4), (6, 7))}\n \"\"\"\n", + "canonical_solution": " res = set(sorted([tuple(sorted(set(sub))) for sub in test_list]))\n return (res)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([[(4, 5), (3, 2)], [(2, 2), (4, 6)], [(3, 2), (4, 5)]]) == {((2, 2), (4, 6)), ((3, 2), (4, 5))}\n assert candidate([[(5, 6), (4, 3)], [(3, 3), (5, 7)], [(4, 3), (5, 6)]]) == {((4, 3), (5, 6)), ((3, 3), (5, 7))}\n assert candidate([[(6, 7), (5, 4)], [(4, 4), (6, 8)], [(5, 4), (6, 7)]]) == {((4, 4), (6, 8)), ((5, 4), (6, 7))}\n", + "entry_point": "remove_similar_row" + }, + { + "task_id": "HumanEval\\/643", + "prompt": "import re\n\ndef text_match_wordz_middle(text: str) -> str:\n \"\"\" Match a word containing 'z', not at the start or end of the word.\n >>> text_match_wordz_middle(\"pythonzabc.\")\n 'Found a match!'\n >>> text_match_wordz_middle(\"xyzabc.\")\n 'Found a match!'\n >>> text_match_wordz_middle(\" lang .\")\n 'Not matched!'\n \"\"\"\n", + "canonical_solution": " patterns = '\\\\Bz\\\\B'\n if re.search(patterns, text):\n return 'Found a match!'\n else:\n return 'Not matched!'\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"pythonzabc.\") == 'Found a match!'\n assert candidate(\"xyzabc.\") == 'Found a match!'\n assert candidate(\" lang .\") == 'Not matched!'\n", + "entry_point": "text_match_wordz_middle" + }, + { + "task_id": "HumanEval\\/644", + "prompt": "from typing import List\n\n\ndef reverse_Array_Upto_K(input: List[int], k: int) -> List[int]:\n \"\"\" Reverse an array up to a given position k\n >>> reverse_Array_Upto_K([1, 2, 3, 4, 5, 6], 4)\n [4, 3, 2, 1, 5, 6]\n >>> reverse_Array_Upto_K([4, 5, 6, 7], 2)\n [5, 4, 6, 7]\n >>> reverse_Array_Upto_K([9, 8, 7, 6, 5], 3)\n [7, 8, 9, 6, 5]\n \"\"\"\n", + "canonical_solution": " return (input[k-1::-1] + input[k:])\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 2, 3, 4, 5, 6], 4) == [4, 3, 2, 1, 5, 6]\n assert candidate([4, 5, 6, 7], 2) == [5, 4, 6, 7]\n assert candidate([9, 8, 7, 6, 5], 3) == [7, 8, 9, 6, 5]\n", + "entry_point": "reverse_Array_Upto_K" + }, + { + "task_id": "HumanEval\\/645", + "prompt": "def find_k_product(test_list, K):\n \"\"\"Find the product of the kth index in the given tuples.\n >>> find_k_product([(5, 6, 7), (1, 3, 5), (8, 9, 19)], 2)\n 665\n >>> find_k_product([(6, 7, 8), (2, 4, 6), (9, 10, 20)], 1)\n 280\n >>> find_k_product([(7, 8, 9), (3, 5, 7), (10, 11, 21)], 0)\n 210\n \"\"\"\n def get_product(val):\n res = 1\n for ele in val:\n res *= ele\n return res\n res = get_product([sub[K] for sub in test_list])\n return res\n", + "canonical_solution": " def get_product(val):\n res = 1\n for ele in val:\n res *= ele\n return res\n res = get_product([sub[K] for sub in test_list])\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([(5, 6, 7), (1, 3, 5), (8, 9, 19)], 2) == 665\n assert candidate([(6, 7, 8), (2, 4, 6), (9, 10, 20)], 1) == 280\n assert candidate([(7, 8, 9), (3, 5, 7), (10, 11, 21)], 0) == 210\n", + "entry_point": "find_k_product" + }, + { + "task_id": "HumanEval\\/646", + "prompt": "def No_of_cubes(N: int, K: int) -> int:\n \"\"\" Calculate the number of cubes of size K in a cube of size N.\n >>> No_of_cubes(2, 1)\n 8\n >>> No_of_cubes(5, 2)\n 64\n >>> No_of_cubes(1, 1)\n 1\n \"\"\"\n", + "canonical_solution": " No = (N - K + 1)\n return No ** 3\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(2, 1) == 8\n assert candidate(5, 2) == 64\n assert candidate(1, 1) == 1\n", + "entry_point": "No_of_cubes" + }, + { + "task_id": "HumanEval\\/647", + "prompt": "import re\n\n\ndef split_upperstring(text: str) -> list:\n \"\"\" Split a string at uppercase letters.\n >>> split_upperstring(\"PythonProgramLanguage\")\n ['Python', 'Program', 'Language']\n >>> split_upperstring(\"PythonProgram\")\n ['Python', 'Program']\n >>> split_upperstring(\"ProgrammingLanguage\")\n ['Programming', 'Language']\n \"\"\"\n", + "canonical_solution": " return re.findall('[A-Z][^A-Z]*', text)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"PythonProgramLanguage\") == ['Python', 'Program', 'Language']\n assert candidate(\"PythonProgram\") == ['Python', 'Program']\n assert candidate(\"ProgrammingLanguage\") == ['Programming', 'Language']\n", + "entry_point": "split_upperstring" + }, + { + "task_id": "HumanEval\\/648", + "prompt": "from typing import List\n\n\ndef exchange_elements(lst: List[int]) -> List[int]:\n \"\"\" Exchange the position of every n-th value with (n+1)th value in a given list.\n >>> exchange_elements([0,1,2,3,4,5])\n [1, 0, 3, 2, 5, 4]\n >>> exchange_elements([5,6,7,8,9,10])\n [6, 5, 8, 7, 10, 9]\n \"\"\"\n", + "canonical_solution": " from itertools import zip_longest, chain\n return list(chain.from_iterable(zip_longest(lst[1::2], lst[::2])))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([0,1,2,3,4,5]) == [1, 0, 3, 2, 5, 4]\n assert candidate([5,6,7,8,9,10]) == [6, 5, 8, 7, 10, 9]\n assert candidate([25,35,45,55,75,95]) == [35, 25, 55, 45, 95, 75]\n", + "entry_point": "exchange_elements" + }, + { + "task_id": "HumanEval\\/649", + "prompt": "from typing import List\n\n\ndef sum_Range_list(nums: List[int], m: int, n: int) -> int:\n \"\"\" Calculate the sum of the numbers in a list between the indices of a specified range.\n >>> sum_Range_list([2, 1, 5, 6, 8, 3, 4, 9, 10, 11, 8, 12], 8, 10)\n 29\n >>> sum_Range_list([1, 2, 3, 4, 5], 1, 2)\n 5\n >>> sum_Range_list([1, 0, 1, 2, 5, 6], 4, 5)\n 11\n \"\"\"\n", + "canonical_solution": " sum_range = 0\n for i in range(m, n+1, 1):\n sum_range += nums[i]\n return sum_range\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([2, 1, 5, 6, 8, 3, 4, 9, 10, 11, 8, 12], 8, 10) == 29\n assert candidate([1, 2, 3, 4, 5], 1, 2) == 5\n assert candidate([1, 0, 1, 2, 5, 6], 4, 5) == 11\n", + "entry_point": "sum_Range_list" + }, + { + "task_id": "HumanEval\\/650", + "prompt": "def are_Equal(arr1: list, arr2: list, n: int, m: int) -> bool:\n \"\"\" Check whether the given two arrays are equal or not.\n >>> are_Equal([1,2,3],[3,2,1],3,3)\n True\n >>> are_Equal([1,1,1],[2,2,2],3,3)\n False\n >>> are_Equal([8,9],[4,5,6],2,3)\n False\n \"\"\"\n", + "canonical_solution": " if n != m:\n return False\n arr1.sort()\n arr2.sort()\n for i in range(n):\n if arr1[i] != arr2[i]:\n return False\n return True\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1,2,3],[3,2,1],3,3) == True\n assert candidate([1,1,1],[2,2,2],3,3) == False\n assert candidate([8,9],[4,5,6],2,3) == False\n", + "entry_point": "are_Equal" + }, + { + "task_id": "HumanEval\\/651", + "prompt": "def check_subset(test_tup1: tuple, test_tup2: tuple) -> bool:\n \"\"\" Check if one tuple is a subset of another tuple\n >>> check_subset((10, 4, 5, 6), (5, 10))\n True\n >>> check_subset((1, 2, 3, 4), (5, 6))\n False\n >>> check_subset((7, 8, 9, 10), (10, 8))\n True\n \"\"\"\n", + "canonical_solution": " return set(test_tup2).issubset(test_tup1)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate((10, 4, 5, 6), (5, 10)) == True\n assert candidate((1, 2, 3, 4), (5, 6)) == False\n assert candidate((7, 8, 9, 10), (10, 8)) == True\n", + "entry_point": "check_subset" + }, + { + "task_id": "HumanEval\\/652", + "prompt": "def matrix_to_list(test_list):\n \"\"\" Flatten the given tuple matrix into the tuple list with each tuple representing each column.\n >>> matrix_to_list([[(4, 5), (7, 8)], [(10, 13), (18, 17)], [(0, 4), (10, 1)]])\n '[(4, 7, 10, 18, 0, 10), (5, 8, 13, 17, 4, 1)]'\n \"\"\"\n", + "canonical_solution": " temp = [ele for sub in test_list for ele in sub]\n res = list(zip(*temp))\n return str(res)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([[(4, 5), (7, 8)], [(10, 13), (18, 17)], [(0, 4), (10, 1)]]) == '[(4, 7, 10, 18, 0, 10), (5, 8, 13, 17, 4, 1)]'\n assert candidate([[(5, 6), (8, 9)], [(11, 14), (19, 18)], [(1, 5), (11, 2)]]) == '[(5, 8, 11, 19, 1, 11), (6, 9, 14, 18, 5, 2)]'\n assert candidate([[(6, 7), (9, 10)], [(12, 15), (20, 21)], [(23, 7), (15, 8)]]) == '[(6, 9, 12, 20, 23, 15), (7, 10, 15, 21, 7, 8)]'\n", + "entry_point": "matrix_to_list" + }, + { + "task_id": "HumanEval\\/653", + "prompt": "from collections import defaultdict\n\n\ndef grouping_dictionary(l):\n \"\"\" Group a sequence of key-value pairs into a dictionary of lists\n >>> grouping_dictionary([('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)])\n {'yellow': [1, 3], 'blue': [2, 4], 'red': [1]}\n \"\"\"\n", + "canonical_solution": " d = defaultdict(list)\n for k, v in l:\n d[k].append(v)\n return d\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)]) == {'yellow': [1, 3], 'blue': [2, 4], 'red': [1]}\n assert candidate([('yellow', 10), ('blue', 20), ('yellow', 30), ('blue', 40), ('red', 10)]) == {'yellow': [10, 30], 'blue': [20, 40], 'red': [10]}\n assert candidate([('yellow', 15), ('blue', 25), ('yellow', 35), ('blue', 45), ('red', 15)]) == {'yellow': [15, 35], 'blue': [25, 45], 'red': [15]}\n", + "entry_point": "grouping_dictionary" + }, + { + "task_id": "HumanEval\\/654", + "prompt": "\n\ndef rectangle_perimeter(l: int, b: int) -> int:\n \"\"\" Calculate the perimeter of a rectangle given its length and breadth.\n >>> rectangle_perimeter(10, 20)\n 60\n >>> rectangle_perimeter(10, 5)\n 30\n >>> rectangle_perimeter(4, 2)\n 12\n \"\"\"\n", + "canonical_solution": " return 2 * (l + b)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(10, 20) == 60\n assert candidate(10, 5) == 30\n assert candidate(4, 2) == 12\n", + "entry_point": "rectangle_perimeter" + }, + { + "task_id": "HumanEval\\/655", + "prompt": "def fifth_Power_Sum(n: int) -> int:\n \"\"\" Calculate the sum of the fifth power of n natural numbers\n >>> fifth_Power_Sum(2)\n 33\n >>> fifth_Power_Sum(4)\n 1300\n >>> fifth_Power_Sum(3)\n 276\n \"\"\"\n", + "canonical_solution": " sm = 0\n for i in range(1, n+1):\n sm += i**5\n return sm\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(2) == 33\n assert candidate(4) == 1300\n assert candidate(3) == 276\n", + "entry_point": "fifth_Power_Sum" + }, + { + "task_id": "HumanEval\\/656", + "prompt": "def find_Min_Sum(a: List[int], b: List[int], n: int) -> int:\n \"\"\" Write a python function to find the minimum sum of absolute differences of two arrays.\n >>> find_Min_Sum([3,2,1],[2,1,3],3)\n 0\n >>> find_Min_Sum([1,2,3],[4,5,6],3)\n 9\n >>> find_Min_Sum([4,1,8,7],[2,3,6,5],4)\n 6\n \"\"\"\n", + "canonical_solution": " a.sort()\n b.sort()\n sum = 0\n for i in range(n):\n sum = sum + abs(a[i] - b[i])\n return sum\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([3,2,1],[2,1,3],3) == 0\n assert candidate([1,2,3],[4,5,6],3) == 9\n assert candidate([4,1,8,7],[2,3,6,5],4) == 6\n", + "entry_point": "find_Min_Sum" + }, + { + "task_id": "HumanEval\\/657", + "prompt": "import math\n\ndef first_Digit(n: int) -> int:\n \"\"\"Find the first digit in factorial of a given number.\n >>> first_Digit(5)\n 1\n >>> first_Digit(10)\n 3\n >>> first_Digit(7)\n 5\n \"\"\"\n", + "canonical_solution": " fact = 1\n for i in range(2, n + 1):\n fact *= i\n while fact % 10 == 0:\n fact //= 10\n while fact >= 10:\n fact //= 10\n return fact\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(5) == 1\n assert candidate(10) == 3\n assert candidate(7) == 5\n", + "entry_point": "first_Digit" + }, + { + "task_id": "HumanEval\\/658", + "prompt": "from typing import List\n\n\ndef max_occurrences(list1: List[int]) -> int:\n \"\"\" Find the item with maximum occurrences in a given list\n >>> max_occurrences([2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,4,6,9,1,2])\n 2\n >>> max_occurrences([1, 3,5, 7,1, 3,13, 15, 17,5, 7,9,1, 11])\n 1\n >>> max_occurrences([1, 2, 3,2, 4, 5,1, 1, 1])\n 1\n \"\"\"\n", + "canonical_solution": " max_val = 0\n result = list1[0] \n for i in list1:\n occu = list1.count(i)\n if occu > max_val:\n max_val = occu\n result = i \n return result\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,4,6,9,1,2]) == 2\n assert candidate([1, 3,5, 7,1, 3,13, 15, 17,5, 7,9,1, 11]) == 1\n assert candidate([1, 2, 3,2, 4, 5,1, 1, 1]) == 1\n", + "entry_point": "max_occurrences" + }, + { + "task_id": "HumanEval\\/659", + "prompt": "from typing import List\n\n\ndef Repeat(x: List[int]) -> List[int]:\n \"\"\" Return a list of duplicate integers from the input list.\n >>> Repeat([10, 20, 30, 20, 20, 30, 40, 50, -20, 60, 60, -20, -20])\n [20, 30, -20, 60]\n >>> Repeat([-1, 1, -1, 8])\n [-1]\n >>> Repeat([1, 2, 3, 1, 2])\n [1, 2]\n \"\"\"\n", + "canonical_solution": " _size = len(x)\n repeated = []\n for i in range(_size):\n k = i + 1\n for j in range(k, _size):\n if x[i] == x[j] and x[i] not in repeated:\n repeated.append(x[i])\n return repeated\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([10, 20, 30, 20, 20, 30, 40, 50, -20, 60, 60, -20, -20]) == [20, 30, -20, 60]\n assert candidate([-1, 1, -1, 8]) == [-1]\n assert candidate([1, 2, 3, 1, 2]) == [1, 2]\n", + "entry_point": "Repeat" + }, + { + "task_id": "HumanEval\\/660", + "prompt": "def find_Points(l1: int, r1: int, l2: int, r2: int) -> tuple:\n \"\"\" Choose points from two ranges such that no point lies in both the ranges.\n >>> find_Points(5, 10, 1, 5)\n (1, 10)\n >>> find_Points(3, 5, 7, 9)\n (3, 9)\n >>> find_Points(1, 5, 2, 8)\n (1, 8)\n \"\"\"\n", + "canonical_solution": " x = min(l1, l2) if (l1 != l2) else -1\n y = max(r1, r2) if (r1 != r2) else -1\n return (x, y)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(5, 10, 1, 5) == (1, 10)\n assert candidate(3, 5, 7, 9) == (3, 9)\n assert candidate(1, 5, 2, 8) == (1, 8)\n", + "entry_point": "find_Points" + }, + { + "task_id": "HumanEval\\/661", + "prompt": "from typing import List\n\n\ndef max_sum_of_three_consecutive(arr: List[int], n: int) -> int:\n \"\"\" Write a function to find the maximum sum that can be formed which has no three consecutive elements present.\n >>> max_sum_of_three_consecutive([100, 1000, 100, 1000, 1], 5)\n 2101\n >>> max_sum_of_three_consecutive([3000, 2000, 1000, 3, 10], 5)\n 5013\n >>> max_sum_of_three_consecutive([1, 2, 3, 4, 5, 6, 7, 8], 8)\n 27\n \"\"\"\n", + "canonical_solution": " sum = [0 for k in range(n)]\n if n >= 1:\n sum[0] = arr[0]\n if n >= 2:\n sum[1] = arr[0] + arr[1]\n if n > 2:\n sum[2] = max(sum[1], max(arr[1] + arr[2], arr[0] + arr[2]))\n for i in range(3, n):\n sum[i] = max(max(sum[i-1], sum[i-2] + arr[i]), arr[i] + arr[i-1] + sum[i-3])\n return sum[n-1]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([100, 1000, 100, 1000, 1], 5) == 2101\n assert candidate([3000, 2000, 1000, 3, 10], 5) == 5013\n assert candidate([1, 2, 3, 4, 5, 6, 7, 8], 8) == 27\n", + "entry_point": "max_sum_of_three_consecutive" + }, + { + "task_id": "HumanEval\\/662", + "prompt": "def sorted_dict(dict1):\n \"\"\" Sorts each list in the dictionary.\n >>> sorted_dict({'n1': [2, 3, 1], 'n2': [5, 1, 2], 'n3': [3, 2, 4]})\n {'n1': [1, 2, 3], 'n2': [1, 2, 5], 'n3': [2, 3, 4]}\n \"\"\"\n", + "canonical_solution": " sorted_dict = {x: sorted(y) for x, y in dict1.items()}\n return sorted_dict\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate({'n1': [2, 3, 1], 'n2': [5, 1, 2], 'n3': [3, 2, 4]}) == {'n1': [1, 2, 3], 'n2': [1, 2, 5], 'n3': [2, 3, 4]}\n assert candidate({'n1': [25,37,41], 'n2': [41,54,63], 'n3': [29,38,93]}) == {'n1': [25, 37, 41], 'n2': [41, 54, 63], 'n3': [29, 38, 93]}\n assert candidate({'n1': [58,44,56], 'n2': [91,34,58], 'n3': [100,200,300]}) == {'n1': [44, 56, 58], 'n2': [34, 58, 91], 'n3': [100, 200, 300]}\n", + "entry_point": "sorted_dict" + }, + { + "task_id": "HumanEval\\/663", + "prompt": "import sys\n\ndef find_max_val(n: int, x: int, y: int) -> int:\n \"\"\" Find the largest possible value of k such that k modulo x is y.\n >>> find_max_val(15, 10, 5)\n 15\n >>> find_max_val(187, 10, 5)\n 185\n >>> find_max_val(16, 11, 1)\n 12\n \"\"\"\n", + "canonical_solution": " ans = -sys.maxsize\n for k in range(n + 1):\n if (k % x == y):\n ans = max(ans, k)\n return (ans if (ans >= 0 and ans <= n) else -1)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(15, 10, 5) == 15\n assert candidate(187, 10, 5) == 185\n assert candidate(16, 11, 1) == 12\n", + "entry_point": "find_max_val" + }, + { + "task_id": "HumanEval\\/664", + "prompt": "def average_Even(n: int) -> int:\n \"\"\" Calculate the average of even numbers up to a given even number n.\n >>> average_Even(2)\n 2\n >>> average_Even(4)\n 3\n >>> average_Even(100)\n 51\n \"\"\"\n", + "canonical_solution": " if n % 2 != 0:\n return \"Invalid Input\"\n sm = 0\n count = 0\n while n >= 2:\n count += 1\n sm += n\n n -= 2\n return sm // count\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(2) == 2\n assert candidate(4) == 3\n assert candidate(100) == 51\n", + "entry_point": "average_Even" + }, + { + "task_id": "HumanEval\\/665", + "prompt": "from typing import List\n\n\ndef move_last(num_list: List[int]) -> List[int]:\n \"\"\" Shift first element to the end of given list\n >>> move_last([1,2,3,4])\n [2,3,4,1]\n >>> move_last([2,3,4,1,5,0])\n [3,4,1,5,0,2]\n >>> move_last([5,4,3,2,1])\n [4,3,2,1,5]\n \"\"\"\n", + "canonical_solution": " return num_list[1:] + num_list[:1]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1,2,3,4]) == [2,3,4,1]\n assert candidate([2,3,4,1,5,0]) == [3,4,1,5,0,2]\n assert candidate([5,4,3,2,1]) == [4,3,2,1,5]\n", + "entry_point": "move_last" + }, + { + "task_id": "HumanEval\\/666", + "prompt": "def count_char(string: str, char: str) -> int:\n \"\"\" Count occurrence of a character in a string.\n >>> count_char(\"Python\", 'o')\n 1\n >>> count_char(\"little\", 't')\n 2\n >>> count_char(\"assert\", 's')\n 2\n \"\"\"\n", + "canonical_solution": " count = 0\n for i in range(len(string)):\n if(string[i] == char):\n count = count + 1\n return count\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"Python\", 'o') == 1\n assert candidate(\"little\", 't') == 2\n assert candidate(\"assert\", 's') == 2\n", + "entry_point": "count_char" + }, + { + "task_id": "HumanEval\\/667", + "prompt": "def Check_Vow(string: str, vowels: str) -> int:\n \"\"\" Count number of vowels in the string.\n >>> Check_Vow('corner', 'AaEeIiOoUu')\n 2\n >>> Check_Vow('valid', 'AaEeIiOoUu')\n 2\n >>> Check_Vow('true', 'AaEeIiOoUu')\n 2\n \"\"\"\n", + "canonical_solution": " final = [each for each in string if each in vowels]\n return len(final)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('corner', 'AaEeIiOoUu') == 2\n assert candidate('valid', 'AaEeIiOoUu') == 2\n assert candidate('true', 'AaEeIiOoUu') == 2\n", + "entry_point": "Check_Vow" + }, + { + "task_id": "HumanEval\\/668", + "prompt": "import re\n\ndef replace(string: str, char: str) -> str:\n \"\"\" Replace multiple occurrences of a character by a single occurrence.\n >>> replace('peep', 'e')\n 'pep'\n >>> replace('Greek', 'e')\n 'Grek'\n >>> replace('Moon', 'o')\n 'Mon'\n \"\"\"\n", + "canonical_solution": " pattern = char + '{2,}'\n string = re.sub(pattern, char, string)\n return string\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('peep', 'e') == 'pep'\n assert candidate('Greek', 'e') == 'Grek'\n assert candidate('Moon', 'o') == 'Mon'\n", + "entry_point": "replace" + }, + { + "task_id": "HumanEval\\/669", + "prompt": "import re\n\ndef check_IP(Ip: str) -> str:\n \"\"\"Check whether the given IP address is valid or not using regex.\n >>> check_IP(\"192.168.0.1\")\n 'Valid IP address'\n >>> check_IP(\"366.1.2.2\")\n 'Invalid IP address'\n \"\"\"\n", + "canonical_solution": " regex = r'^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\\\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$'\n if re.search(regex, Ip):\n return \"Valid IP address\"\n else:\n return \"Invalid IP address\"\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"192.168.0.1\") == 'Valid IP address'\n assert candidate(\"110.234.52.124\") == 'Valid IP address'\n assert candidate(\"366.1.2.2\") == 'Invalid IP address'\n", + "entry_point": "check_IP" + }, + { + "task_id": "HumanEval\\/670", + "prompt": "from typing import List\n\n\ndef decreasing_trend(nums: List[int]) -> bool:\n \"\"\" Check whether a sequence of numbers has a decreasing trend or not.\n >>> decreasing_trend([-4, -3, -2, -1])\n True\n >>> decreasing_trend([1, 2, 3])\n True\n >>> decreasing_trend([3, 2, 1])\n False\n \"\"\"\n", + "canonical_solution": " return nums == sorted(nums, reverse=True)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([-4, -3, -2, -1]) == True\n assert candidate([1, 2, 3]) == True\n assert candidate([3, 2, 1]) == False\n", + "entry_point": "decreasing_trend" + }, + { + "task_id": "HumanEval\\/671", + "prompt": "import math\n\ndef get_Pos_Of_Right_most_Set_Bit(n):\n return int(math.log2(n & -n) + 1)\n\ndef set_Right_most_Unset_Bit(n):\n \"\"\" Set the right most unset bit in the binary representation of n.\n >>> set_Right_most_Unset_Bit(21)\n 23\n >>> set_Right_most_Unset_Bit(11)\n 15\n >>> set_Right_most_Unset_Bit(15)\n 15\n \"\"\"\n if n == 0:\n return 1\n if (n & (n + 1)) == 0:\n return n\n pos = get_Pos_Of_Right_most_Set_Bit(~n)\n return (1 << (pos - 1)) | n\n", + "canonical_solution": " if n == 0:\n return 1\n if (n & (n + 1)) == 0:\n return n\n pos = get_Pos_Of_Right_most_Set_Bit(~n)\n return (1 << (pos - 1)) | n\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(21) == 23\n assert candidate(11) == 15\n assert candidate(15) == 15\n", + "entry_point": "set_Right_most_Unset_Bit" + }, + { + "task_id": "HumanEval\\/672", + "prompt": "def max_of_three(num1: int, num2: int, num3: int) -> int:\n \"\"\" Find the maximum of three numbers\n >>> max_of_three(10, 20, 30)\n 30\n >>> max_of_three(55, 47, 39)\n 55\n >>> max_of_three(10, 49, 30)\n 49\n \"\"\"\n", + "canonical_solution": " if (num1 >= num2) and (num1 >= num3):\n return num1\n elif (num2 >= num1) and (num2 >= num3):\n return num2\n else:\n return num3\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(10, 20, 30) == 30\n assert candidate(55, 47, 39) == 55\n assert candidate(10, 49, 30) == 49\n", + "entry_point": "max_of_three" + }, + { + "task_id": "HumanEval\\/673", + "prompt": "from typing import List\n\n\ndef convert(lst: List[int]) -> int:\n \"\"\" Convert a list of multiple integers into a single integer.\n >>> convert([1, 2, 3])\n 123\n >>> convert([4, 5, 6])\n 456\n \"\"\"\n", + "canonical_solution": " s = [str(i) for i in lst]\n res = int(\"\".join(s))\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 2, 3]) == 123\n assert candidate([4, 5, 6]) == 456\n assert candidate([7, 8, 9]) == 789\n", + "entry_point": "convert" + }, + { + "task_id": "HumanEval\\/674", + "prompt": "from collections import OrderedDict\n\ndef remove_duplicate(string: str) -> str:\n \"\"\" Remove duplicate words from a given string using collections module.\n >>> remove_duplicate(\"Python Exercises Practice Solution Exercises\")\n 'Python Exercises Practice Solution'\n >>> remove_duplicate(\"Python Exercises Practice Solution Python\")\n 'Python Exercises Practice Solution'\n >>> remove_duplicate(\"Python Exercises Practice Solution Practice\")\n 'Python Exercises Practice Solution'\n \"\"\"\n", + "canonical_solution": " result = ' '.join(OrderedDict((w,w) for w in string.split()).keys())\n return result\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"Python Exercises Practice Solution Exercises\") == \"Python Exercises Practice Solution\"\n assert candidate(\"Python Exercises Practice Solution Python\") == \"Python Exercises Practice Solution\"\n assert candidate(\"Python Exercises Practice Solution Practice\") == \"Python Exercises Practice Solution\"\n", + "entry_point": "remove_duplicate" + }, + { + "task_id": "HumanEval\\/675", + "prompt": "def sum_nums(x: int, y: int, m: int, n: int) -> int:\n \"\"\" Add two integers and return 20 if the sum is within the given range.\n >>> sum_nums(2, 10, 11, 20)\n 20\n >>> sum_nums(15, 17, 1, 10)\n 32\n >>> sum_nums(10, 15, 5, 30)\n 20\n \"\"\"\n", + "canonical_solution": " sum_nums = x + y\n if sum_nums in range(m, n):\n return 20\n else:\n return sum_nums\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(2, 10, 11, 20) == 20\n assert candidate(15, 17, 1, 10) == 32\n assert candidate(10, 15, 5, 30) == 20\n", + "entry_point": "sum_nums" + }, + { + "task_id": "HumanEval\\/676", + "prompt": "import re\n\ndef remove_extra_char(text1: str) -> str:\n \"\"\" Remove everything except alphanumeric characters from the given string by using regex.\n >>> remove_extra_char('**//Google Android// - 12. ')\n 'GoogleAndroid12'\n >>> remove_extra_char('****//Google Flutter//*** - 36. ')\n 'GoogleFlutter36'\n >>> remove_extra_char('**//Google Firebase// - 478. ')\n 'GoogleFirebase478'\n \"\"\"\n", + "canonical_solution": " pattern = re.compile('[\\W_]+')\n return pattern.sub('', text1)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('**//Google Android// - 12. ') == 'GoogleAndroid12'\n assert candidate('****//Google Flutter//*** - 36. ') == 'GoogleFlutter36'\n assert candidate('**//Google Firebase// - 478. ') == 'GoogleFirebase478'\n", + "entry_point": "remove_extra_char" + }, + { + "task_id": "HumanEval\\/677", + "prompt": "def validity_triangle(a: int, b: int, c: int) -> bool:\n \"\"\" Check if the triangle is valid or not\n >>> validity_triangle(60, 50, 90)\n False\n >>> validity_triangle(45, 75, 60)\n True\n >>> validity_triangle(30, 50, 100)\n True\n \"\"\"\n", + "canonical_solution": " total = a + b + c\n return total == 180\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(60, 50, 90) == False\n assert candidate(45, 75, 60) == True\n assert candidate(30, 50, 100) == True\n", + "entry_point": "validity_triangle" + }, + { + "task_id": "HumanEval\\/678", + "prompt": "def remove_spaces(str1: str) -> str:\n \"\"\" Remove spaces from a given string\n >>> remove_spaces(\"a b c\")\n 'abc'\n >>> remove_spaces(\"1 2 3\")\n '123'\n \"\"\"\n", + "canonical_solution": " return str1.replace(' ', '')\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"a b c\") == \"abc\"\n assert candidate(\"1 2 3\") == \"123\"\n assert candidate(\" b c\") == \"bc\"\n", + "entry_point": "remove_spaces" + }, + { + "task_id": "HumanEval\\/679", + "prompt": "def access_key(dictionary, key):\n \"\"\" Access dictionary key��s element by index\n >>> access_key({'physics': 80, 'math': 90, 'chemistry': 86}, 0)\n 'physics'\n >>> access_key({'python': 10, 'java': 20, 'C++': 30}, 2)\n 'C++'\n >>> access_key({'program': 15, 'computer': 45}, 1)\n 'computer'\n \"\"\"\n", + "canonical_solution": " return list(dictionary)[key]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate({'physics': 80, 'math': 90, 'chemistry': 86}, 0) == 'physics'\n assert candidate({'python': 10, 'java': 20, 'C++': 30}, 2) == 'C++'\n assert candidate({'program': 15, 'computer': 45}, 1) == 'computer'\n", + "entry_point": "access_key" + }, + { + "task_id": "HumanEval\\/680", + "prompt": "from typing import List\n\n\ndef increasing_trend(nums: List[int]) -> bool:\n \"\"\" Check whether a sequence of numbers has an increasing trend or not.\n >>> increasing_trend([1, 2, 3, 4])\n True\n >>> increasing_trend([4, 3, 2, 1])\n False\n >>> increasing_trend([0, 1, 4, 9])\n True\n \"\"\"\n", + "canonical_solution": " return sorted(nums) == nums\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 2, 3, 4]) == True\n assert candidate([4, 3, 2, 1]) == False\n assert candidate([0, 1, 4, 9]) == True\n", + "entry_point": "increasing_trend" + }, + { + "task_id": "HumanEval\\/681", + "prompt": "def smallest_Divisor(n: int) -> int:\n \"\"\" Find the smallest prime divisor of a number n\n >>> smallest_Divisor(10)\n 2\n >>> smallest_Divisor(25)\n 5\n >>> smallest_Divisor(31)\n 31\n \"\"\"\n", + "canonical_solution": " if n % 2 == 0:\n return 2\n i = 3\n while i * i <= n:\n if n % i == 0:\n return i\n i += 2\n return n\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(10) == 2\n assert candidate(25) == 5\n assert candidate(31) == 31\n", + "entry_point": "smallest_Divisor" + }, + { + "task_id": "HumanEval\\/682", + "prompt": "from typing import List\n\n\ndef mul_list(nums1: List[int], nums2: List[int]) -> List[int]:\n \"\"\" Multiply two lists using map and lambda function.\n >>> mul_list([1, 2, 3], [4, 5, 6])\n [4, 10, 18]\n >>> mul_list([1, 2], [3, 4])\n [3, 8]\n >>> mul_list([90, 120], [50, 70])\n [4500, 8400]\n \"\"\"\n", + "canonical_solution": " result = map(lambda x, y: x * y, nums1, nums2)\n return list(result)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 2, 3], [4, 5, 6]) == [4, 10, 18]\n assert candidate([1, 2], [3, 4]) == [3, 8]\n assert candidate([90, 120], [50, 70]) == [4500, 8400]\n", + "entry_point": "mul_list" + }, + { + "task_id": "HumanEval\\/683", + "prompt": "def sum_Square(n: int) -> bool:\n \"\"\" Check whether the given number can be represented by sum of two squares or not.\n >>> sum_Square(25)\n True\n >>> sum_Square(24)\n False\n >>> sum_Square(17)\n True\n \"\"\"\n", + "canonical_solution": " i = 1\n while i*i <= n:\n j = 1\n while j*j <= n:\n if i*i + j*j == n:\n return True\n j += 1\n i += 1\n return False\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(25) == True\n assert candidate(24) == False\n assert candidate(17) == True\n", + "entry_point": "sum_Square" + }, + { + "task_id": "HumanEval\\/684", + "prompt": "def count_Char(str, x):\n \"\"\" Count occurrences of a character in a repeated string.\n >>> count_Char(\"abcac\", 'a')\n 4\n >>> count_Char(\"abca\", 'c')\n 2\n >>> count_Char(\"aba\", 'a')\n 7\n \"\"\"\n", + "canonical_solution": " count = 0\n for i in range(len(str)):\n if (str[i] == x):\n count += 1\n n = 10\n repititions = n // len(str)\n count = count * repititions\n l = n % len(str)\n for i in range(l):\n if (str[i] == x):\n count += 1\n return count\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"abcac\", 'a') == 4\n assert candidate(\"abca\", 'c') == 2\n assert candidate(\"aba\", 'a') == 7\n", + "entry_point": "count_Char" + }, + { + "task_id": "HumanEval\\/685", + "prompt": "def sum_Of_Primes(n: int) -> int:\n \"\"\"Write a python function to find sum of prime numbers between 1 to n.\n >>> sum_Of_Primes(10)\n 17\n >>> sum_Of_Primes(20)\n 77\n >>> sum_Of_Primes(5)\n 10\n \"\"\"\n", + "canonical_solution": " prime = [True] * (n + 1)\n p = 2\n while p * p <= n:\n if prime[p] == True:\n i = p * 2\n while i <= n:\n prime[i] = False\n i += p\n p += 1\n sum = 0\n for i in range(2, n + 1):\n if prime[i]:\n sum += i\n return sum\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(10) == 17\n assert candidate(20) == 77\n assert candidate(5) == 10\n", + "entry_point": "sum_Of_Primes" + }, + { + "task_id": "HumanEval\\/686", + "prompt": "from collections import defaultdict\n\n\ndef freq_element(test_tup):\n \"\"\" Find the frequency of each element in the given list\n >>> freq_element((4, 5, 4, 5, 6, 6, 5, 5, 4))\n '{4: 3, 5: 4, 6: 2}'\n >>> freq_element((7, 8, 8, 9, 4, 7, 6, 5, 4))\n '{7: 2, 8: 2, 9: 1, 4: 2, 6: 1, 5: 1}'\n >>> freq_element((1, 4, 3, 1, 4, 5, 2, 6, 2, 7))\n '{1: 2, 4: 2, 3: 1, 5: 1, 2: 2, 6: 1, 7: 1}'\n \"\"\"\n", + "canonical_solution": " res = defaultdict(int)\n for ele in test_tup:\n res[ele] += 1\n return str(dict(res))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate((4, 5, 4, 5, 6, 6, 5, 5, 4)) == '{4: 3, 5: 4, 6: 2}'\n assert candidate((7, 8, 8, 9, 4, 7, 6, 5, 4)) == '{7: 2, 8: 2, 9: 1, 4: 2, 6: 1, 5: 1}'\n assert candidate((1, 4, 3, 1, 4, 5, 2, 6, 2, 7)) == '{1: 2, 4: 2, 3: 1, 5: 1, 2: 2, 6: 1, 7: 1}'\n", + "entry_point": "freq_element" + }, + { + "task_id": "HumanEval\\/687", + "prompt": "def recur_gcd(a: int, b: int) -> int:\n \"\"\" Find the greatest common divisor (gcd) of two integers using recursion.\n >>> recur_gcd(12, 14)\n 2\n >>> recur_gcd(13, 17)\n 1\n >>> recur_gcd(9, 3)\n 3\n \"\"\"\n", + "canonical_solution": " low = min(a, b)\n high = max(a, b)\n if low == 0:\n return high\n elif low == 1:\n return 1\n else:\n return recur_gcd(low, high % low)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(12, 14) == 2\n assert candidate(13, 17) == 1\n assert candidate(9, 3) == 3\n", + "entry_point": "recur_gcd" + }, + { + "task_id": "HumanEval\\/688", + "prompt": "import cmath\n\ndef len_complex(a: float, b: float) -> float:\n \"\"\" Calculate the length of a complex number given its real and imaginary parts.\n >>> len_complex(3, 4)\n 5.0\n >>> len_complex(9, 10)\n 13.45362404707371\n >>> len_complex(7, 9)\n 11.40175425099138\n \"\"\"\n", + "canonical_solution": " cn = complex(a, b)\n length = abs(cn)\n return length\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(3, 4) == 5.0\n assert candidate(9, 10) == 13.45362404707371\n assert candidate(7, 9) == 11.40175425099138\n", + "entry_point": "len_complex" + }, + { + "task_id": "HumanEval\\/689", + "prompt": "def min_jumps(arr, n):\n \"\"\" Find the minimum number of jumps to reach the end of the array for the given array of integers where each element represents the max number of steps that can be made forward from that element.\n >>> min_jumps([1, 3, 6, 1, 0, 9], 6)\n 3\n >>> min_jumps([1, 3, 5, 8, 9, 2, 6, 7, 6, 8, 9], 11)\n 3\n >>> min_jumps([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 11)\n 10\n \"\"\"\n", + "canonical_solution": " jumps = [0 for i in range(n)]\n if (n == 0) or (arr[0] == 0):\n return float('inf')\n jumps[0] = 0\n for i in range(1, n):\n jumps[i] = float('inf')\n for j in range(i):\n if (i <= j + arr[j]) and (jumps[j] != float('inf')):\n jumps[i] = min(jumps[i], jumps[j] + 1)\n break\n return jumps[n-1]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 3, 6, 1, 0, 9], 6) == 3\n assert candidate([1, 3, 5, 8, 9, 2, 6, 7, 6, 8, 9], 11) == 3\n assert candidate([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 11) == 10\n", + "entry_point": "min_jumps" + }, + { + "task_id": "HumanEval\\/690", + "prompt": "from typing import List\n\n\ndef mul_consecutive_nums(nums: List[int]) -> List[int]:\n \"\"\" Multiply consecutive numbers of a given list\n >>> mul_consecutive_nums([1, 1, 3, 4, 4, 5, 6, 7])\n [1, 3, 12, 16, 20, 30, 42]\n >>> mul_consecutive_nums([4, 5, 8, 9, 6, 10])\n [20, 40, 72, 54, 60]\n \"\"\"\n", + "canonical_solution": " result = [b*a for a, b in zip(nums[:-1], nums[1:])]\n return result\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 1, 3, 4, 4, 5, 6, 7]) == [1, 3, 12, 16, 20, 30, 42]\n assert candidate([4, 5, 8, 9, 6, 10]) == [20, 40, 72, 54, 60]\n assert candidate([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 6, 12, 20, 30, 42, 56, 72, 90]\n", + "entry_point": "mul_consecutive_nums" + }, + { + "task_id": "task_691", + "prompt": "from itertools import groupby\n\ndef group_element(test_list):\n \"\"\" Group the 1st elements on the basis of 2nd elements in the given tuple list.\n >>> group_element([(6, 5), (2, 7), (2, 5), (8, 7), (9, 8), (3, 7)])\n {5: [6, 2], 7: [2, 8, 3], 8: [9]}\n \"\"\"\n", + "canonical_solution": " res = dict()\n for key, val in groupby(sorted(test_list, key=lambda ele: ele[1]), key=lambda ele: ele[1]):\n res[key] = [ele[0] for ele in val]\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([(6, 5), (2, 7), (2, 5), (8, 7), (9, 8), (3, 7)]) == {5: [6, 2], 7: [2, 8, 3], 8: [9]}\n assert candidate([(7, 6), (3, 8), (3, 6), (9, 8), (10, 9), (4, 8)]) == {6: [7, 3], 8: [3, 9, 4], 9: [10]}\n assert candidate([(8, 7), (4, 9), (4, 7), (10, 9), (11, 10), (5, 9)]) == {7: [8, 4], 9: [4, 10, 5], 10: [11]}\n", + "entry_point": "group_element" + }, + { + "task_id": "HumanEval\\/692", + "prompt": "def last_Two_Digits(N: int) -> int:\n \"\"\" Find the last two digits in factorial of a given number.\n >>> last_Two_Digits(7)\n 40\n >>> last_Two_Digits(5)\n 20\n >>> last_Two_Digits(2)\n 2\n \"\"\"\n", + "canonical_solution": " if (N >= 10):\n return 0\n fac = 1\n for i in range(1, N + 1):\n fac = (fac * i) % 100\n return fac\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(7) == 40\n assert candidate(5) == 20\n assert candidate(2) == 2\n", + "entry_point": "last_Two_Digits" + }, + { + "task_id": "693", + "prompt": "import re\n\ndef remove_multiple_spaces(text1: str) -> str:\n \"\"\" Remove multiple spaces in a string by using regex\n >>> remove_multiple_spaces('Google Assistant')\n 'Google Assistant'\n >>> remove_multiple_spaces('Quad Core')\n 'Quad Core'\n >>> remove_multiple_spaces('ChromeCast Built-in')\n 'ChromeCast Built-in'\n \"\"\"\n", + "canonical_solution": " return re.sub(' +', ' ', text1)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('Google Assistant') == 'Google Assistant'\n assert candidate('Quad Core') == 'Quad Core'\n assert candidate('ChromeCast Built-in') == 'ChromeCast Built-in'\n", + "entry_point": "remove_multiple_spaces" + }, + { + "task_id": "HumanEval\\/694", + "prompt": "def extract_unique(test_dict):\n \"\"\" Extract unique values from the given dictionary values.\n >>> extract_unique({'msm' : [5, 6, 7, 8],'is' : [10, 11, 7, 5],'best' : [6, 12, 10, 8],'for' : [1, 2, 5]})\n [1, 2, 5, 6, 7, 8, 10, 11, 12]\n \"\"\"\n", + "canonical_solution": " res = list(sorted({ele for val in test_dict.values() for ele in val}))\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate({'msm' : [5, 6, 7, 8],'is' : [10, 11, 7, 5],'best' : [6, 12, 10, 8],'for' : [1, 2, 5]}) == [1, 2, 5, 6, 7, 8, 10, 11, 12]\n assert candidate({'Built' : [7, 1, 9, 4],'for' : [11, 21, 36, 14, 9],'ISP' : [4, 1, 21, 39, 47],'TV' : [1, 32, 38]}) == [1, 4, 7, 9, 11, 14, 21, 32, 36, 38, 39, 47]\n assert candidate({'F' : [11, 13, 14, 17],'A' : [12, 11, 15, 18],'N' : [19, 21, 15, 36],'G' : [37, 36, 35]}) == [11, 12, 13, 14, 15, 17, 18, 19, 21, 35, 36, 37]\n", + "entry_point": "extract_unique" + }, + { + "task_id": "HumanEval\\/695", + "prompt": "def check_greater(test_tup1: tuple, test_tup2: tuple) -> bool:\n \"\"\" Check if each element of the second tuple is greater than its corresponding index in the first tuple.\n >>> check_greater((10, 4, 5), (13, 5, 18))\n True\n >>> check_greater((1, 2, 3), (2, 1, 4))\n False\n >>> check_greater((4, 5, 6), (5, 6, 7))\n True\n \"\"\"\n", + "canonical_solution": " res = all(x < y for x, y in zip(test_tup1, test_tup2))\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate((10, 4, 5), (13, 5, 18)) == True\n assert candidate((1, 2, 3), (2, 1, 4)) == False\n assert candidate((4, 5, 6), (5, 6, 7)) == True\n", + "entry_point": "check_greater" + }, + { + "task_id": "HumanEval\\/696", + "prompt": "from typing import List\n\n\ndef zip_list(list1: List[List[int]], list2: List[List[int]]) -> List[List[int]]:\n \"\"\" Zip two given lists of lists.\n >>> zip_list([[1, 3], [5, 7], [9, 11]], [[2, 4], [6, 8], [10, 12, 14]])\n [[1, 3, 2, 4], [5, 7, 6, 8], [9, 11, 10, 12, 14]]\n >>> zip_list([[1, 2], [3, 4], [5, 6]], [[7, 8], [9, 10], [11, 12]])\n [[1, 2, 7, 8], [3, 4, 9, 10], [5, 6, 11, 12]]\n >>> zip_list([['a','b'],['c','d']], [['e','f'],['g','h']])\n [['a','b','e','f'],['c','d','g','h']]\n \"\"\"\n", + "canonical_solution": " return [a + b for a, b in zip(list1, list2)]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([[1, 3], [5, 7], [9, 11]], [[2, 4], [6, 8], [10, 12, 14]]) == [[1, 3, 2, 4], [5, 7, 6, 8], [9, 11, 10, 12, 14]]\n assert candidate([[1, 2], [3, 4], [5, 6]], [[7, 8], [9, 10], [11, 12]]) == [[1, 2, 7, 8], [3, 4, 9, 10], [5, 6, 11, 12]]\n assert candidate([['a','b'],['c','d']], [['e','f'],['g','h']]) == [['a','b','e','f'],['c','d','g','h']]\n", + "entry_point": "zip_list" + }, + { + "task_id": "HumanEval\\/697", + "prompt": "from typing import List\n\n\ndef count_even(array_nums: List[int]) -> int:\n \"\"\" Write a function to find number of even elements in the given list using lambda function.\n >>> count_even([1, 2, 3, 5, 7, 8, 9, 10])\n 3\n >>> count_even([10,15,14,13,-18,12,-20])\n 5\n >>> count_even([1, 2, 4, 8, 9])\n 3\n \"\"\"\n", + "canonical_solution": " return len(list(filter(lambda x: (x % 2 == 0), array_nums)))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 2, 3, 5, 7, 8, 9, 10]) == 3\n assert candidate([10, 15, 14, 13, -18, 12, -20]) == 5\n assert candidate([1, 2, 4, 8, 9]) == 3\n", + "entry_point": "count_even" + }, + { + "task_id": "698", + "prompt": "def sort_dict_item(test_dict):\n \"\"\" Sort dictionary items by tuple product of keys for the given dictionary with tuple keys.\n >>> sort_dict_item({(5, 6) : 3, (2, 3) : 9, (8, 4): 10, (6, 4): 12})\n {(2, 3): 9, (6, 4): 12, (5, 6): 3, (8, 4): 10}\n \"\"\"\n", + "canonical_solution": " res = {key: test_dict[key] for key in sorted(test_dict.keys(), key=lambda ele: ele[1] * ele[0])}\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate({(5, 6): 3, (2, 3): 9, (8, 4): 10, (6, 4): 12}) == {(2, 3): 9, (6, 4): 12, (5, 6): 3, (8, 4): 10}\n assert candidate({(6, 7): 4, (3, 4): 10, (9, 5): 11, (7, 5): 13}) == {(3, 4): 10, (7, 5): 13, (6, 7): 4, (9, 5): 11}\n assert candidate({(7, 8): 5, (4, 5): 11, (10, 6): 12, (8, 6): 14}) == {(4, 5): 11, (8, 6): 14, (7, 8): 5, (10, 6): 12}\n", + "entry_point": "sort_dict_item" + }, + { + "task_id": "HumanEval\\/699", + "prompt": "def min_Swaps(str1: str, str2: str) -> int:\n \"\"\"Find the minimum number of swaps required to convert one binary string to another.\n >>> min_Swaps(\"1101\", \"1110\")\n 1\n >>> min_Swaps(\"1111\", \"0100\")\n \"Not Possible\"\n >>> min_Swaps(\"1110000\", \"0001101\")\n 3\n \"\"\"\n", + "canonical_solution": " count = 0\n for i in range(len(str1)):\n if str1[i] != str2[i]:\n count += 1\n if count % 2 == 0:\n return count // 2\n else:\n return \"Not Possible\"\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"1101\", \"1110\") == 1\n assert candidate(\"1111\", \"0100\") == \"Not Possible\"\n assert candidate(\"1110000\", \"0001101\") == 3\n", + "entry_point": "min_Swaps" + }, + { + "task_id": "HumanEval\\/700", + "prompt": "from typing import List, Union\n\n\ndef count_range_in_list(li: List[Union[int, str]], min_val: Union[int, str], max_val: Union[int, str]) -> int:\n \"\"\" Count the number of elements in a list which are within a specific range\n >>> count_range_in_list([10,20,30,40,40,40,70,80,99],40,100)\n 6\n >>> count_range_in_list(['a','b','c','d','e','f'],'a','e')\n 5\n >>> count_range_in_list([7,8,9,15,17,19,45],15,20)\n 3\n \"\"\"\n", + "canonical_solution": " ctr = 0\n for x in li:\n if min_val <= x <= max_val:\n ctr += 1\n return ctr\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([10,20,30,40,40,40,70,80,99],40,100) == 6\n assert candidate(['a','b','c','d','e','f'],'a','e') == 5\n assert candidate([7,8,9,15,17,19,45],15,20) == 3\n", + "entry_point": "count_range_in_list" + }, + { + "task_id": "HumanEval\\/701", + "prompt": "from typing import List\n\n\ndef equilibrium_index(arr: List[int]) -> int:\n \"\"\" Find the equilibrium index of the given array\n >>> equilibrium_index([1, 2, 3, 4, 1, 2, 3])\n 3\n >>> equilibrium_index([-7, 1, 5, 2, -4, 3, 0])\n 3\n >>> equilibrium_index([1, 2, 3])\n -1\n \"\"\"\n", + "canonical_solution": " total_sum = sum(arr)\n left_sum = 0\n for i, num in enumerate(arr):\n total_sum -= num\n if left_sum == total_sum:\n return i\n left_sum += num\n return -1\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 2, 3, 4, 1, 2, 3]) == 3\n assert candidate([-7, 1, 5, 2, -4, 3, 0]) == 3\n assert candidate([1, 2, 3]) == -1\n", + "entry_point": "equilibrium_index" + }, + { + "task_id": "702", + "prompt": "def removals(arr: List[int], n: int, k: int) -> int:\n \"\"\" Write a function to find the minimum number of elements that should be removed such that amax-amin<=k.\n >>> removals([1, 3, 4, 9, 10, 11, 12, 17, 20], 9, 4)\n 5\n >>> removals([1, 5, 6, 2, 8], 5, 2)\n 3\n >>> removals([1, 2, 3, 4, 5, 6], 6, 3)\n 2\n \"\"\"\n", + "canonical_solution": " arr.sort()\n ans = n - 1\n for i in range(n):\n j = find_ind(arr[i], i, n, k, arr)\n if j != -1:\n ans = min(ans, n - (j - i + 1))\n return ans\n\ndef find_ind(key: int, i: int, n: int, k: int, arr: List[int]) -> int:\n ind = -1\n start = i + 1\n end = n - 1\n while start < end:\n mid = (start + end) // 2\n if arr[mid] - key <= k:\n ind = mid\n start = mid + 1\n else:\n end = mid\n return ind\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 3, 4, 9, 10, 11, 12, 17, 20], 9, 4) == 5\n assert candidate([1, 5, 6, 2, 8], 5, 2) == 3\n assert candidate([1, 2, 3, 4, 5, 6], 6, 3) == 2\n", + "entry_point": "removals" + }, + { + "task_id": "HumanEval\\/703", + "prompt": "def is_key_present(d: dict, x: int) -> bool:\n \"\"\" Check whether the given key is present in the dictionary or not.\n >>> is_key_present({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60}, 5)\n True\n >>> is_key_present({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60}, 10)\n False\n \"\"\"\n", + "canonical_solution": " return x in d\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60}, 5) == True\n assert candidate({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60}, 6) == True\n assert candidate({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60}, 10) == False\n", + "entry_point": "is_key_present" + }, + { + "task_id": "HumanEval\\/704", + "prompt": "def harmonic_sum(n: int) -> float:\n \"\"\" Calculate the harmonic sum of n-1.\n >>> harmonic_sum(10)\n 2.9289682539682538\n >>> harmonic_sum(4)\n 2.083333333333333\n >>> harmonic_sum(7)\n 2.5928571428571425\n \"\"\"\n", + "canonical_solution": " if n < 2:\n return 1\n else:\n return 1 / n + harmonic_sum(n - 1)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(10) == 2.9289682539682538\n assert candidate(4) == 2.083333333333333\n assert candidate(7) == 2.5928571428571425\n", + "entry_point": "harmonic_sum" + }, + { + "task_id": "HumanEval\\/705", + "prompt": "from typing import List\n\n\ndef sort_sublists(list1: List[List[int]]) -> List[List[int]]:\n \"\"\" Sort a list of lists by length and value\n >>> sort_sublists([[2], [0], [1, 3], [0, 7], [9, 11], [13, 15, 17]])\n [[0], [2], [0, 7], [1, 3], [9, 11], [13, 15, 17]]\n >>> sort_sublists([[1], [2, 3], [4, 5, 6], [7], [10, 11]])\n [[1], [7], [2, 3], [10, 11], [4, 5, 6]]\n >>> sort_sublists([[\"python\"],[\"java\",\"C\",\"C++\"],[\"DBMS\"],[\"SQL\",\"HTML\"]])\n [['DBMS'], ['python'], ['SQL', 'HTML'], ['java', 'C', 'C++']]\n \"\"\"\n", + "canonical_solution": " list1.sort()\n list1.sort(key=len)\n return list1\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([[2], [0], [1, 3], [0, 7], [9, 11], [13, 15, 17]]) == [[0], [2], [0, 7], [1, 3], [9, 11], [13, 15, 17]]\n assert candidate([[1], [2, 3], [4, 5, 6], [7], [10, 11]]) == [[1], [7], [2, 3], [10, 11], [4, 5, 6]]\n assert candidate([[\"python\"],[\"java\",\"C\",\"C++\"],[\"DBMS\"],[\"SQL\",\"HTML\"]]) == [['DBMS'], ['python'], ['SQL', 'HTML'], ['java', 'C', 'C++']]\n", + "entry_point": "sort_sublists" + }, + { + "task_id": "HumanEval\\/706", + "prompt": "def is_subset(arr1, m, arr2, n):\n \"\"\" Determine if arr2 is a subset of arr1\n >>> is_subset([11, 1, 13, 21, 3, 7], 6, [11, 3, 7, 1], 4)\n True\n >>> is_subset([1, 2, 3, 4, 5, 6], 6, [1, 2, 4], 3)\n True\n >>> is_subset([10, 5, 2, 23, 19], 5, [19, 5, 3], 3)\n False\n \"\"\"\n", + "canonical_solution": " hashset = set()\n for i in range(0, m):\n hashset.add(arr1[i])\n for i in range(0, n):\n if arr2[i] in hashset:\n continue\n else:\n return False\n return True\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([11, 1, 13, 21, 3, 7], 6, [11, 3, 7, 1], 4) == True\n assert candidate([1, 2, 3, 4, 5, 6], 6, [1, 2, 4], 3) == True\n assert candidate([10, 5, 2, 23, 19], 5, [19, 5, 3], 3) == False\n", + "entry_point": "is_subset" + }, + { + "task_id": "HumanEval\\/707", + "prompt": "def count_Set_Bits(n: int) -> int:\n \"\"\" Count the total set bits from 1 to n.\n >>> count_Set_Bits(16)\n 33\n >>> count_Set_Bits(2)\n 2\n >>> count_Set_Bits(14)\n 28\n \"\"\"\n", + "canonical_solution": " n += 1\n powerOf2 = 2\n cnt = n // 2\n while powerOf2 <= n:\n totalPairs = n // powerOf2\n cnt += (totalPairs // 2) * powerOf2\n if totalPairs & 1:\n cnt += (n % powerOf2)\n powerOf2 <<= 1\n return cnt\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(16) == 33\n assert candidate(2) == 2\n assert candidate(14) == 28\n", + "entry_point": "count_Set_Bits" + }, + { + "task_id": "HumanEval\\/708", + "prompt": "from typing import List\n\n\ndef Convert(string: str) -> List[str]:\n \"\"\" Convert a string to a list of words\n >>> Convert('python program')\n ['python', 'program']\n >>> Convert('Data Analysis')\n ['Data', 'Analysis']\n \"\"\"\n", + "canonical_solution": " return list(string.split(\" \"))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('python program') == ['python', 'program']\n assert candidate('Data Analysis') == ['Data', 'Analysis']\n assert candidate('Hadoop Training') == ['Hadoop', 'Training']\n", + "entry_point": "Convert" + }, + { + "task_id": "709", + "prompt": "from collections import defaultdict\n\ndef get_unique(test_list):\n \"\"\"Write a function to count unique keys for each value present in the tuple.\n >>> get_unique([(3, 4), (1, 2), (2, 4), (8, 2), (7, 2), (8, 1), (9, 1), (8, 4), (10, 4)])\n '{4: 4, 2: 3, 1: 2}'\n \"\"\"\n", + "canonical_solution": " res = defaultdict(list)\n for sub in test_list:\n res[sub[1]].append(sub[0])\n res = dict(res)\n res_dict = dict()\n for key in res:\n res_dict[key] = len(list(set(res[key])))\n return str(res_dict)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([(3, 4), (1, 2), (2, 4), (8, 2), (7, 2), (8, 1), (9, 1), (8, 4), (10, 4)]) == '{4: 4, 2: 3, 1: 2}'\n assert candidate([(4, 5), (2, 3), (3, 5), (9, 3), (8, 3), (9, 2), (10, 2), (9, 5), (11, 5)]) == '{5: 4, 3: 3, 2: 2}'\n assert candidate([(6, 5), (3, 4), (2, 6), (11, 1), (8, 22), (8, 11), (4, 3), (14, 3), (11, 6)]) == '{5: 1, 4: 1, 6: 2, 1: 1, 22: 1, 11: 1, 3: 2}'\n", + "entry_point": "get_unique" + }, + { + "task_id": "HumanEval\\/710", + "prompt": "def front_and_rear(test_tup: tuple) -> tuple:\n \"\"\" Return a tuple containing the first and last elements of the given tuple.\n >>> front_and_rear((10, 4, 5, 6, 7))\n (10, 7)\n >>> front_and_rear((1, 2, 3, 4, 5))\n (1, 5)\n >>> front_and_rear((6, 7, 8, 9, 10))\n (6, 10)\n \"\"\"\n", + "canonical_solution": " res = (test_tup[0], test_tup[-1])\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate((10, 4, 5, 6, 7)) == (10, 7)\n assert candidate((1, 2, 3, 4, 5)) == (1, 5)\n assert candidate((6, 7, 8, 9, 10)) == (6, 10)\n", + "entry_point": "front_and_rear" + }, + { + "task_id": "HumanEval\\/711", + "prompt": "def product_Equal(n: int) -> bool:\n \"\"\" Check whether the product of digits of a number at even and odd places is equal or not.\n >>> product_Equal(2841)\n True\n >>> product_Equal(1234)\n False\n >>> product_Equal(1212)\n False\n \"\"\"\n", + "canonical_solution": " if n < 10:\n return False\n prodOdd = 1; prodEven = 1\n while n > 0:\n digit = n % 10\n prodOdd *= digit\n n = n//10\n if n == 0:\n break\n digit = n % 10\n prodEven *= digit\n n = n//10\n return prodOdd == prodEven\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(2841) == True\n assert candidate(1234) == False\n assert candidate(1212) == False\n", + "entry_point": "product_Equal" + }, + { + "task_id": "HumanEval\\/712", + "prompt": "import itertools\n\n\ndef remove_duplicate(list1):\n \"\"\" Remove duplicates from a list of lists\n >>> remove_duplicate([[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]])\n [[10, 20], [30, 56, 25], [33], [40]]\n >>> remove_duplicate(['a', 'b', 'a', 'c', 'c'])\n ['a', 'b', 'c']\n >>> remove_duplicate([1, 3, 5, 6, 3, 5, 6, 1])\n [1, 3, 5, 6]\n \"\"\"\n", + "canonical_solution": " list1.sort()\n return list(list1 for list1,_ in itertools.groupby(list1))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]]) == [[10, 20], [30, 56, 25], [33], [40]]\n assert candidate(['a', 'b', 'a', 'c', 'c']) == ['a', 'b', 'c']\n assert candidate([1, 3, 5, 6, 3, 5, 6, 1]) == [1, 3, 5, 6]\n", + "entry_point": "remove_duplicate" + }, + { + "task_id": "HumanEval\\/713", + "prompt": "def check_valid(test_tup: tuple) -> bool:\n \"\"\" Check if the given tuple contains all valid values or not.\n >>> check_valid((True, True, True, True))\n True\n >>> check_valid((True, False, True, True))\n False\n \"\"\"\n", + "canonical_solution": " return not any(map(lambda ele: not ele, test_tup))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate((True, True, True, True)) == True\n assert candidate((True, False, True, True)) == False\n assert candidate((True, True, True, True)) == True\n", + "entry_point": "check_valid" + }, + { + "task_id": "HumanEval\\/714", + "prompt": "def count_Fac(n: int) -> int:\n \"\"\" Count the number of distinct power of prime factor of given number.\n >>> count_Fac(24)\n 3\n >>> count_Fac(12)\n 2\n >>> count_Fac(4)\n 1\n \"\"\"\n", + "canonical_solution": " m = n\n count = 0\n i = 2\n while((i * i) <= m):\n total = 0\n while (n % i == 0):\n n /= i\n total += 1\n temp = 0\n j = 1\n while((temp + j) <= total):\n temp += j\n count += 1\n j += 1\n i += 1\n if (n != 1):\n count += 1\n return count\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(24) == 3\n assert candidate(12) == 2\n assert candidate(4) == 1\n", + "entry_point": "count_Fac" + }, + { + "task_id": "HumanEval\\/715", + "prompt": "def str_to_tuple(test_str: str) -> tuple:\n \"\"\" Convert the given string of integers into a tuple.\n >>> str_to_tuple(\"1, -5, 4, 6, 7\")\n (1, -5, 4, 6, 7)\n >>> str_to_tuple(\"1, 2, 3, 4, 5\")\n (1, 2, 3, 4, 5)\n \"\"\"\n", + "canonical_solution": " res = tuple(map(int, test_str.split(', ')))\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"1, -5, 4, 6, 7\") == (1, -5, 4, 6, 7)\n assert candidate(\"1, 2, 3, 4, 5\") == (1, 2, 3, 4, 5)\n assert candidate(\"4, 6, 9, 11, 13, 14\") == (4, 6, 9, 11, 13, 14)\n", + "entry_point": "str_to_tuple" + }, + { + "task_id": "HumanEval\\/716", + "prompt": "def rombus_perimeter(a: int) -> int:\n \"\"\" Calculate the perimeter of a rhombus given the length of one side.\n >>> rombus_perimeter(10)\n 40\n >>> rombus_perimeter(5)\n 20\n >>> rombus_perimeter(4)\n 16\n \"\"\"\n", + "canonical_solution": " return 4 * a\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(10) == 40\n assert candidate(5) == 20\n assert candidate(4) == 16\n", + "entry_point": "rombus_perimeter" + }, + { + "task_id": "HumanEval\\/717", + "prompt": "import math\nfrom typing import List\n\n\ndef sd_calc(data: List[float]) -> float:\n \"\"\" Calculate the standard deviation of a list of numbers.\n >>> sd_calc([4, 2, 5, 8, 6])\n 2.23606797749979\n >>> sd_calc([1,2,3,4,5,6,7])\n 2.160246899469287\n >>> sd_calc([5,9,10,15,6,4])\n 4.070217029430577\n \"\"\"\n", + "canonical_solution": " n = len(data)\n if n <= 1:\n return 0.0\n mean = sum(data) / n\n variance = sum((x - mean) ** 2 for x in data) / (n - 1)\n return math.sqrt(variance)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([4, 2, 5, 8, 6]) == 2.23606797749979\n assert candidate([1, 2, 3, 4, 5, 6, 7]) == 2.160246899469287\n assert candidate([5, 9, 10, 15, 6, 4]) == 4.070217029430577\n", + "entry_point": "sd_calc" + }, + { + "task_id": "HumanEval\\/718", + "prompt": "from typing import List\n\n\ndef alternate_elements(list1: List) -> List:\n \"\"\" Create a list taking alternate elements from another given list.\n >>> alternate_elements(['red', 'black', 'white', 'green', 'orange'])\n ['red', 'white', 'orange']\n >>> alternate_elements([2, 0, 3, 4, 0, 2, 8, 3, 4, 2])\n [2, 3, 0, 8, 4]\n >>> alternate_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])\n [1, 3, 5, 7, 9]\n \"\"\"\n", + "canonical_solution": " return list1[::2]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(['red', 'black', 'white', 'green', 'orange']) == ['red', 'white', 'orange']\n assert candidate([2, 0, 3, 4, 0, 2, 8, 3, 4, 2]) == [2, 3, 0, 8, 4]\n assert candidate([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 3, 5, 7, 9]\n", + "entry_point": "alternate_elements" + }, + { + "task_id": "HumanEval\\/719", + "prompt": "import re\n\ndef text_match(text: str) -> str:\n \"\"\" Match a string that has an 'a' followed by zero or more 'b's.\n >>> text_match('ac')\n 'Found a match!'\n >>> text_match('dc')\n 'Not matched!'\n >>> text_match('abba')\n 'Found a match!'\n \"\"\"\n", + "canonical_solution": " patterns = 'ab*?'\n if re.search(patterns, text):\n return 'Found a match!'\n else:\n return 'Not matched!'\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('ac') == 'Found a match!'\n assert candidate('dc') == 'Not matched!'\n assert candidate('abba') == 'Found a match!'\n", + "entry_point": "text_match" + }, + { + "task_id": "HumanEval\\/720", + "prompt": "def add_dict_to_tuple(test_tup, test_dict):\n \"\"\" Add a dictionary to the tuple\n >>> add_dict_to_tuple((4, 5, 6), {\"MSAM\" : 1, \"is\" : 2, \"best\" : 3})\n (4, 5, 6, {'MSAM': 1, 'is': 2, 'best': 3})\n >>> add_dict_to_tuple((1, 2, 3), {\"UTS\" : 2, \"is\" : 3, \"Worst\" : 4})\n (1, 2, 3, {'UTS': 2, 'is': 3, 'Worst': 4})\n \"\"\"\n", + "canonical_solution": " test_tup = list(test_tup)\n test_tup.append(test_dict)\n test_tup = tuple(test_tup)\n return test_tup\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate((4, 5, 6), {\"MSAM\" : 1, \"is\" : 2, \"best\" : 3}) == (4, 5, 6, {'MSAM': 1, 'is': 2, 'best': 3})\n assert candidate((1, 2, 3), {\"UTS\" : 2, \"is\" : 3, \"Worst\" : 4}) == (1, 2, 3, {'UTS': 2, 'is': 3, 'Worst': 4})\n assert candidate((8, 9, 10), {\"POS\" : 3, \"is\" : 4, \"Okay\" : 5}) == (8, 9, 10, {'POS': 3, 'is': 4, 'Okay': 5})\n", + "entry_point": "add_dict_to_tuple" + }, + { + "task_id": "HumanEval\\/721", + "prompt": "def maxAverageOfPath(cost, N):\n \"\"\"Find a path with the maximum average over all existing paths for the given square matrix of size n*n.\n >>> maxAverageOfPath([[1, 2, 3], [6, 5, 4], [7, 3, 9]], 3)\n 5.2\n >>> maxAverageOfPath([[2, 3, 4], [7, 6, 5], [8, 4, 10]], 3)\n 6.2\n \"\"\"\n", + "canonical_solution": " dp = [[0 for i in range(N + 1)] for j in range(N + 1)]\n dp[0][0] = cost[0][0]\n for i in range(1, N):\n dp[i][0] = dp[i - 1][0] + cost[i][0]\n for j in range(1, N):\n dp[0][j] = dp[0][j - 1] + cost[0][j]\n for i in range(1, N):\n for j in range(1, N):\n dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + cost[i][j]\n return dp[N - 1][N - 1] / (2 * N - 1)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([[1, 2, 3], [6, 5, 4], [7, 3, 9]], 3) == 5.2\n assert candidate([[2, 3, 4], [7, 6, 5], [8, 4, 10]], 3) == 6.2\n assert candidate([[3, 4, 5], [8, 7, 6], [9, 5, 11]], 3) == 7.2\n", + "entry_point": "maxAverageOfPath" + }, + { + "task_id": "722", + "prompt": "def filter_data(students, h, w):\n \"\"\" Filter the height and width of students stored in a dictionary.\n >>> filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)}, 6.0, 70)\n {'Cierra Vega': (6.2, 70)}\n >>> filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)}, 5.9, 67)\n {'Cierra Vega': (6.2, 70), 'Kierra Gentry': (6.0, 68)}\n \"\"\"\n", + "canonical_solution": " result = {k: s for k, s in students.items() if s[0] >= h and s[1] >= w}\n return result\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)}, 6.0, 70) == {'Cierra Vega': (6.2, 70)}\n assert candidate({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)}, 5.9, 67) == {'Cierra Vega': (6.2, 70), 'Kierra Gentry': (6.0, 68)}\n assert candidate({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)}, 5.7, 64) == {'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)}\n", + "entry_point": "filter_data" + }, + { + "task_id": "HumanEval\\/723", + "prompt": "from operator import eq\nfrom typing import List\n\n\ndef count_same_pair(nums1: List[int], nums2: List[int]) -> int:\n \"\"\" Write a function to count the same pair in two given lists using map function.\n >>> count_same_pair([1, 2, 3, 4, 5, 6, 7, 8],[2, 2, 3, 1, 2, 6, 7, 9])\n 4\n >>> count_same_pair([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8],[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])\n 11\n >>> count_same_pair([2, 4, -6, -9, 11, -12, 14, -5, 17],[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])\n 1\n \"\"\"\n", + "canonical_solution": " result = sum(map(eq, nums1, nums2))\n return result\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 2, 3, 4, 5, 6, 7, 8],[2, 2, 3, 1, 2, 6, 7, 9]) == 4\n assert candidate([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8],[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8]) == 11\n assert candidate([2, 4, -6, -9, 11, -12, 14, -5, 17],[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8]) == 1\n", + "entry_point": "count_same_pair" + }, + { + "task_id": "HumanEval\\/724", + "prompt": "def power_base_sum(base: int, power: int) -> int:\n \"\"\" Calculate the sum of all digits of the base to the specified power.\n >>> power_base_sum(2, 100)\n 115\n >>> power_base_sum(8, 10)\n 37\n >>> power_base_sum(8, 15)\n 62\n \"\"\"\n", + "canonical_solution": " return sum([int(i) for i in str(pow(base, power))])\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(2, 100) == 115\n assert candidate(8, 10) == 37\n assert candidate(8, 15) == 62\n", + "entry_point": "power_base_sum" + }, + { + "task_id": "725", + "prompt": "import re\n\ndef extract_quotation(text1):\n \"\"\" Extract values between quotation marks of the given string by using regex.\n >>> extract_quotation('Cortex \"A53\" Based \"multi\" tasking \"Processor\"')\n ['A53', 'multi', 'Processor']\n >>> extract_quotation('Cast your \"favorite\" entertainment \"apps\"')\n ['favorite', 'apps']\n >>> extract_quotation('Watch content \"4k Ultra HD\" resolution with \"HDR 10\" Support')\n ['4k Ultra HD', 'HDR 10']\n \"\"\"\n", + "canonical_solution": " return re.findall(r'\"(.*?)\"', text1)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('Cortex \"A53\" Based \"multi\" tasking \"Processor\"') == ['A53', 'multi', 'Processor']\n assert candidate('Cast your \"favorite\" entertainment \"apps\"') == ['favorite', 'apps']\n assert candidate('Watch content \"4k Ultra HD\" resolution with \"HDR 10\" Support') == ['4k Ultra HD', 'HDR 10']\n", + "entry_point": "extract_quotation" + }, + { + "task_id": "HumanEval\\/726", + "prompt": "def multiply_elements(test_tup: tuple) -> tuple:\n \"\"\" Multiply the adjacent elements of the given tuple\n >>> multiply_elements((1, 5, 7, 8, 10))\n (5, 35, 56, 80)\n >>> multiply_elements((2, 4, 5, 6, 7))\n (8, 20, 30, 42)\n >>> multiply_elements((12, 13, 14, 9, 15))\n (156, 182, 126, 135)\n \"\"\"\n", + "canonical_solution": " res = tuple(i * j for i, j in zip(test_tup, test_tup[1:]))\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate((1, 5, 7, 8, 10)) == (5, 35, 56, 80)\n assert candidate((2, 4, 5, 6, 7)) == (8, 20, 30, 42)\n assert candidate((12, 13, 14, 9, 15)) == (156, 182, 126, 135)\n", + "entry_point": "multiply_elements" + }, + { + "task_id": "HumanEval\\/727", + "prompt": "import re\n\ndef remove_char(S: str) -> str:\n \"\"\" Remove all characters from the string except letters and numbers using regex.\n >>> remove_char(\"123abcjw:, .@! eiw\")\n '123abcjweiw'\n >>> remove_char(\"Hello1234:, ! Howare33u\")\n 'Hello1234Howare33u'\n >>> remove_char(\"Cool543Triks@:, Make@987Trips\")\n 'Cool543TriksMake987Trips'\n \"\"\"\n", + "canonical_solution": " result = re.sub('[\\W_]+', '', S)\n return result\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"123abcjw:, .@! eiw\") == '123abcjweiw'\n assert candidate(\"Hello1234:, ! Howare33u\") == 'Hello1234Howare33u'\n assert candidate(\"Cool543Triks@:, Make@987Trips\") == 'Cool543TriksMake987Trips'\n", + "entry_point": "remove_char" + }, + { + "task_id": "HumanEval\\/728", + "prompt": "from typing import List\n\n\ndef sum_list(lst1: List[int], lst2: List[int]) -> List[int]:\n \"\"\" Sum elements in two lists element-wise\n >>> sum_list([10, 20, 30], [15, 25, 35])\n [25, 45, 65]\n >>> sum_list([1, 2, 3], [5, 6, 7])\n [6, 8, 10]\n >>> sum_list([15, 20, 30], [15, 45, 75])\n [30, 65, 105]\n \"\"\"\n", + "canonical_solution": " return [lst1[i] + lst2[i] for i in range(len(lst1))]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([10, 20, 30], [15, 25, 35]) == [25, 45, 65]\n assert candidate([1, 2, 3], [5, 6, 7]) == [6, 8, 10]\n assert candidate([15, 20, 30], [15, 45, 75]) == [30, 65, 105]\n", + "entry_point": "sum_list" + }, + { + "task_id": "HumanEval\\/729", + "prompt": "from typing import List\n\n\ndef add_list(nums1: List[int], nums2: List[int]) -> List[int]:\n \"\"\" Add two lists using map and lambda function\n >>> add_list([1, 2, 3], [4, 5, 6])\n [5, 7, 9]\n >>> add_list([1, 2], [3, 4])\n [4, 6]\n >>> add_list([10, 20], [50, 70])\n [60, 90]\n \"\"\"\n", + "canonical_solution": " result = map(lambda x, y: x + y, nums1, nums2)\n return list(result)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 2, 3], [4, 5, 6]) == [5, 7, 9]\n assert candidate([1, 2], [3, 4]) == [4, 6]\n assert candidate([10, 20], [50, 70]) == [60, 90]\n", + "entry_point": "add_list" + }, + { + "task_id": "HumanEval\\/730", + "prompt": "from itertools import groupby\nfrom typing import List, Union\n\n\ndef consecutive_duplicates(nums: List[Union[int, str]]) -> List[Union[int, str]]:\n \"\"\" Remove consecutive duplicates from a list.\n >>> consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4])\n [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4]\n >>> consecutive_duplicates([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10])\n [10, 15, 19, 18, 17, 26, 17, 18, 10]\n >>> consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd'])\n ['a', 'b', 'c', 'd']\n \"\"\"\n", + "canonical_solution": " return [key for key, group in groupby(nums)]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4]\n assert candidate([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10]) == [10, 15, 19, 18, 17, 26, 17, 18, 10]\n assert candidate(['a', 'a', 'b', 'c', 'd', 'd']) == ['a', 'b', 'c', 'd']\n", + "entry_point": "consecutive_duplicates" + }, + { + "task_id": "HumanEval\\/731", + "prompt": "import math\n\ndef lateralsurface_cone(r: float, h: float) -> float:\n \"\"\" Calculate the lateral surface area of a cone given its radius and height.\n >>> lateralsurface_cone(5, 12)\n 204.20352248333654\n >>> lateralsurface_cone(10, 15)\n 566.3586699569488\n >>> lateralsurface_cone(19, 17)\n 1521.8090132193388\n \"\"\"\n", + "canonical_solution": " l = math.sqrt(r * r + h * h)\n LSA = math.pi * r * l\n return LSA\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(5, 12) == 204.20352248333654\n assert candidate(10, 15) == 566.3586699569488\n assert candidate(19, 17) == 1521.8090132193388\n", + "entry_point": "lateralsurface_cone" + }, + { + "task_id": "732", + "prompt": "import re\n\ndef replace_specialchar(text: str) -> str:\n \"\"\" Replace all occurrences of spaces, commas, or dots with a colon.\n >>> replace_specialchar('Python language, Programming language.')\n 'Python:language::Programming:language:'\n >>> replace_specialchar('a b c,d e f')\n 'a:b:c:d:e:f'\n >>> replace_specialchar('ram reshma,ram rahim')\n 'ram:reshma:ram:rahim'\n \"\"\"\n", + "canonical_solution": " return re.sub(\"[ ,.]\", \":\", text)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('Python language, Programming language.') == 'Python:language::Programming:language:'\n assert candidate('a b c,d e f') == 'a:b:c:d:e:f'\n assert candidate('ram reshma,ram rahim') == 'ram:reshma:ram:rahim'\n", + "entry_point": "replace_specialchar" + }, + { + "task_id": "HumanEval\\/733", + "prompt": "from typing import List\n\n\ndef find_first_occurrence(A: List[int], x: int) -> int:\n \"\"\" Find the index of the first occurrence of a given number in a sorted array\n >>> find_first_occurrence([2, 5, 5, 5, 6, 6, 8, 9, 9, 9], 5)\n 1\n >>> find_first_occurrence([2, 3, 5, 5, 6, 6, 8, 9, 9, 9], 5)\n 2\n >>> find_first_occurrence([2, 4, 1, 5, 6, 6, 8, 9, 9, 9], 6)\n 4\n \"\"\"\n", + "canonical_solution": " (left, right) = (0, len(A) - 1)\n result = -1\n while left <= right:\n mid = (left + right) // 2\n if x == A[mid]:\n result = mid\n right = mid - 1\n elif x < A[mid]:\n right = mid - 1\n else:\n left = mid + 1\n return result\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([2, 5, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 1\n assert candidate([2, 3, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 2\n assert candidate([2, 4, 1, 5, 6, 6, 8, 9, 9, 9], 6) == 4\n", + "entry_point": "find_first_occurrence" + }, + { + "task_id": "HumanEval\\/734", + "prompt": "def sum_Of_Subarray_Prod(arr: List[int], n: int) -> int:\n \"\"\" Calculate the sum of products of all possible subarrays.\n >>> sum_Of_Subarray_Prod([1, 2, 3], 3)\n 20\n >>> sum_Of_Subarray_Prod([1, 2], 2)\n 5\n >>> sum_Of_Subarray_Prod([1, 2, 3, 4], 4)\n 84\n \"\"\"\n", + "canonical_solution": " ans = 0\n res = 0\n i = n - 1\n while (i >= 0):\n incr = arr[i]*(1 + res)\n ans += incr\n res = incr\n i -= 1\n return (ans)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 2, 3], 3) == 20\n assert candidate([1, 2], 2) == 5\n assert candidate([1, 2, 3, 4], 4) == 84\n", + "entry_point": "sum_Of_Subarray_Prod" + }, + { + "task_id": "HumanEval\\/735", + "prompt": "def toggle_middle_bits(n):\n \"\"\" Toggle bits of the number except the first and the last bit.\n >>> toggle_middle_bits(9)\n 15\n >>> toggle_middle_bits(10)\n 12\n >>> toggle_middle_bits(11)\n 13\n \"\"\"\n", + "canonical_solution": " def set_middle_bits(n):\n n |= n >> 1;\n n |= n >> 2;\n n |= n >> 4;\n n |= n >> 8;\n n |= n >> 16;\n return (n >> 1) ^ 1\n if (n == 1):\n return 1\n return n ^ set_middle_bits(n)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(9) == 15\n assert candidate(10) == 12\n assert candidate(11) == 13\n", + "entry_point": "toggle_middle_bits" + }, + { + "task_id": "HumanEval\\/736", + "prompt": "import bisect\n\n\ndef left_insertion(a, x):\n \"\"\" Locate the left insertion point for a specified value in sorted order.\n >>> left_insertion([1,2,4,5], 6)\n 4\n >>> left_insertion([1,2,4,5], 3)\n 2\n >>> left_insertion([1,2,4,5], 7)\n 4\n \"\"\"\n", + "canonical_solution": " i = bisect.bisect_left(a, x)\n return i\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1,2,4,5], 6) == 4\n assert candidate([1,2,4,5], 3) == 2\n assert candidate([1,2,4,5], 7) == 4\n", + "entry_point": "left_insertion" + }, + { + "task_id": "HumanEval\\/737", + "prompt": "import re\n\ndef check_str(string: str) -> str:\n \"\"\" Check whether the given string is starting with a vowel or not using regex.\n >>> check_str(\"annie\")\n 'Valid'\n >>> check_str(\"dawood\")\n 'Invalid'\n >>> check_str(\"Else\")\n 'Valid'\n \"\"\"\n", + "canonical_solution": " regex = '^[aeiouAEIOU][A-Za-z0-9_]*'\n if re.search(regex, string):\n return \"Valid\"\n else:\n return \"Invalid\"\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"annie\") == 'Valid'\n assert candidate(\"dawood\") == 'Invalid'\n assert candidate(\"Else\") == 'Valid'\n", + "entry_point": "check_str" + }, + { + "task_id": "HumanEval\\/738", + "prompt": "def geometric_sum(n: int) -> float:\n \"\"\" Calculate the geometric sum of n-1.\n >>> geometric_sum(7)\n 1.9921875\n >>> geometric_sum(4)\n 1.9375\n >>> geometric_sum(8)\n 1.99609375\n \"\"\"\n", + "canonical_solution": " if n < 0:\n return 0\n else:\n return 1 / (pow(2, n)) + geometric_sum(n - 1)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(7) == 1.9921875\n assert candidate(4) == 1.9375\n assert candidate(8) == 1.99609375\n", + "entry_point": "geometric_sum" + }, + { + "task_id": "HumanEval\\/739", + "prompt": "import math\n\ndef find_Index(n: int) -> int:\n \"\"\" Find the index of the smallest triangular number with n digits.\n >>> find_Index(2)\n 4\n >>> find_Index(3)\n 14\n >>> find_Index(4)\n 45\n \"\"\"\n", + "canonical_solution": " x = math.sqrt(2 * math.pow(10, (n - 1)))\n return round(x)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(2) == 4\n assert candidate(3) == 14\n assert candidate(4) == 45\n", + "entry_point": "find_Index" + }, + { + "task_id": "HumanEval\\/740", + "prompt": "def tuple_to_dict(test_tup):\n \"\"\" Convert the given tuple to a key-value dictionary using adjacent elements.\n >>> tuple_to_dict((1, 5, 7, 10, 13, 5))\n {1: 5, 7: 10, 13: 5}\n >>> tuple_to_dict((1, 2, 3, 4, 5, 6))\n {1: 2, 3: 4, 5: 6}\n \"\"\"\n", + "canonical_solution": " res = dict(test_tup[idx : idx + 2] for idx in range(0, len(test_tup), 2))\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate((1, 5, 7, 10, 13, 5)) == {1: 5, 7: 10, 13: 5}\n assert candidate((1, 2, 3, 4, 5, 6)) == {1: 2, 3: 4, 5: 6}\n assert candidate((7, 8, 9, 10, 11, 12)) == {7: 8, 9: 10, 11: 12}\n", + "entry_point": "tuple_to_dict" + }, + { + "task_id": "HumanEval\\/741", + "prompt": "def all_Characters_Same(s: str) -> bool:\n \"\"\" Check whether all the characters in the string are the same.\n >>> all_Characters_Same(\"python\")\n False\n >>> all_Characters_Same(\"aaa\")\n True\n >>> all_Characters_Same(\"data\")\n False\n \"\"\"\n", + "canonical_solution": " n = len(s)\n for i in range(1, n):\n if s[i] != s[0]:\n return False\n return True\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"python\") == False\n assert candidate(\"aaa\") == True\n assert candidate(\"data\") == False\n", + "entry_point": "all_Characters_Same" + }, + { + "task_id": "HumanEval\\/742", + "prompt": "import math\n\ndef area_tetrahedron(side: float) -> float:\n \"\"\" Calculate the area of a tetrahedron given the length of its side.\n >>> area_tetrahedron(3)\n 15.588457268119894\n >>> area_tetrahedron(20)\n 692.8203230275509\n >>> area_tetrahedron(10)\n 173.20508075688772\n \"\"\"\n", + "canonical_solution": " return math.sqrt(3) * (side * side)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(3) == 15.588457268119894\n assert candidate(20) == 692.8203230275509\n assert candidate(10) == 173.20508075688772\n", + "entry_point": "area_tetrahedron" + }, + { + "task_id": "HumanEval\\/743", + "prompt": "from typing import List\n\n\ndef rotate_right(list1: List[int], m: int, n: int) -> List[int]:\n \"\"\" Rotate a given list by specified number of items to the right direction.\n >>> rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3, 4)\n [8, 9, 10, 1, 2, 3, 4, 5, 6]\n >>> rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 2, 2)\n [9, 10, 1, 2, 3, 4, 5, 6, 7, 8]\n >>> rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 5, 2)\n [6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8]\n \"\"\"\n", + "canonical_solution": " result = list1[-(m):] + list1[:-(n)]\n return result\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3, 4) == [8, 9, 10, 1, 2, 3, 4, 5, 6]\n assert candidate([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 2, 2) == [9, 10, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 5, 2) == [6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8]\n", + "entry_point": "rotate_right" + }, + { + "task_id": "HumanEval\\/744", + "prompt": "def check_none(test_tup: tuple) -> bool:\n \"\"\" Check if the given tuple has any None value or not.\n >>> check_none((10, 4, 5, 6, None))\n True\n >>> check_none((7, 8, 9, 11, 14))\n False\n >>> check_none((1, 2, 3, 4, None))\n True\n \"\"\"\n", + "canonical_solution": " return any(map(lambda ele: ele is None, test_tup))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate((10, 4, 5, 6, None)) == True\n assert candidate((7, 8, 9, 11, 14)) == False\n assert candidate((1, 2, 3, 4, None)) == True\n", + "entry_point": "check_none" + }, + { + "task_id": "HumanEval\\/745", + "prompt": "def divisible_by_digits(startnum: int, endnum: int) -> list:\n \"\"\" Find numbers within a given range where every number is divisible by every digit it contains.\n >>> divisible_by_digits(1, 22)\n [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]\n >>> divisible_by_digits(1, 15)\n [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15]\n >>> divisible_by_digits(20, 25)\n [22, 24]\n \"\"\"\n", + "canonical_solution": " return [n for n in range(startnum, endnum+1) if not any(map(lambda x: int(x) == 0 or n%int(x) != 0, str(n)))]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(1, 22) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]\n assert candidate(1, 15) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15]\n assert candidate(20, 25) == [22, 24]\n", + "entry_point": "divisible_by_digits" + }, + { + "task_id": "HumanEval\\/746", + "prompt": "def sector_area(r: float, a: float) -> float:\n \"\"\" Calculate the area of a sector given the radius and angle in degrees.\n Returns None if the angle is 360 degrees or more.\n >>> sector_area(4, 45)\n 6.285714285714286\n >>> sector_area(9, 45)\n 31.82142857142857\n >>> sector_area(9, 360)\n None\n \"\"\"\n", + "canonical_solution": " pi = 22/7\n if a >= 360:\n return None\n sectorarea = (pi * r**2) * (a / 360)\n return sectorarea\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(4, 45) == 6.285714285714286\n assert candidate(9, 45) == 31.82142857142857\n assert candidate(9, 360) == None\n", + "entry_point": "sector_area" + }, + { + "task_id": "HumanEval\\/747", + "prompt": "def lcs_of_three(X: str, Y: str, Z: str, m: int, n: int, o: int) -> int:\n \"\"\" Write a function to find the longest common subsequence for the given three string sequence.\n >>> lcs_of_three('AGGT12', '12TXAYB', '12XBA', 6, 7, 5)\n 2\n >>> lcs_of_three('Reels', 'Reelsfor', 'ReelsforReels', 5, 8, 13)\n 5\n >>> lcs_of_three('abcd1e2', 'bc12ea', 'bd1ea', 7, 6, 5)\n 3\n \"\"\"\n", + "canonical_solution": " L = [[[0 for i in range(o+1)] for j in range(n+1)] for k in range(m+1)]\n for i in range(m+1):\n for j in range(n+1):\n for k in range(o+1):\n if (i == 0 or j == 0 or k == 0):\n L[i][j][k] = 0\n elif (X[i-1] == Y[j-1] and X[i-1] == Z[k-1]):\n L[i][j][k] = L[i-1][j-1][k-1] + 1\n else:\n L[i][j][k] = max(max(L[i-1][j][k], L[i][j-1][k]), L[i][j][k-1])\n return L[m][n][o]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('AGGT12', '12TXAYB', '12XBA', 6, 7, 5) == 2\n assert candidate('Reels', 'Reelsfor', 'ReelsforReels', 5, 8, 13) == 5\n assert candidate('abcd1e2', 'bc12ea', 'bd1ea', 7, 6, 5) == 3\n", + "entry_point": "lcs_of_three" + }, + { + "task_id": "HumanEval\\/748", + "prompt": "import re\n\ndef capital_words_spaces(str1: str) -> str:\n \"\"\" Write a function to put spaces between words starting with capital letters in a given string by using regex.\n >>> capital_words_spaces(\"Python\")\n 'Python'\n >>> capital_words_spaces(\"PythonProgrammingExamples\")\n 'Python Programming Examples'\n >>> capital_words_spaces(\"GetReadyToBeCodingFreak\")\n 'Get Ready To Be Coding Freak'\n \"\"\"\n", + "canonical_solution": " return re.sub(r\"(\\w)([A-Z])\", r\"\\1 \\2\", str1)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"Python\") == 'Python'\n assert candidate(\"PythonProgrammingExamples\") == 'Python Programming Examples'\n assert candidate(\"GetReadyToBeCodingFreak\") == 'Get Ready To Be Coding Freak'\n", + "entry_point": "capital_words_spaces" + }, + { + "task_id": "HumanEval\\/749", + "prompt": "from typing import List\n\n\ndef sort_numeric_strings(nums_str: List[str]) -> List[int]:\n \"\"\" Sort a given list of strings of numbers numerically.\n >>> sort_numeric_strings(['4','12','45','7','0','100','200','-12','-500'])\n [-500, -12, 0, 4, 7, 12, 45, 100, 200]\n >>> sort_numeric_strings(['2','3','8','4','7','9','8','2','6','5','1','6','1','2','3','4','6','9','1','2'])\n [1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8, 9, 9]\n >>> sort_numeric_strings(['1','3','5','7','1', '3','13', '15', '17','5', '7 ','9','1', '11'])\n [1, 1, 1, 3, 3, 5, 5, 7, 7, 9, 11, 13, 15, 17]\n \"\"\"\n", + "canonical_solution": " result = [int(x) for x in nums_str]\n result.sort()\n return result\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(['4','12','45','7','0','100','200','-12','-500']) == [-500, -12, 0, 4, 7, 12, 45, 100, 200]\n assert candidate(['2','3','8','4','7','9','8','2','6','5','1','6','1','2','3','4','6','9','1','2']) == [1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8, 9, 9]\n assert candidate(['1','3','5','7','1', '3','13', '15', '17','5', '7 ','9','1', '11']) == [1, 1, 1, 3, 3, 5, 5, 7, 7, 9, 11, 13, 15, 17]\n", + "entry_point": "sort_numeric_strings" + }, + { + "task_id": "HumanEval\\/750", + "prompt": "from typing import List, Tuple\n\n\ndef add_tuple(test_list: List[int], test_tup: Tuple[int, ...]) -> List[int]:\n \"\"\" Add the given tuple to the given list\n >>> add_tuple([5, 6, 7], (9, 10))\n [5, 6, 7, 9, 10]\n >>> add_tuple([6, 7, 8], (10, 11))\n [6, 7, 8, 10, 11]\n >>> add_tuple([7, 8, 9], (11, 12))\n [7, 8, 9, 11, 12]\n \"\"\"\n", + "canonical_solution": " test_list += test_tup\n return test_list\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([5, 6, 7], (9, 10)) == [5, 6, 7, 9, 10]\n assert candidate([6, 7, 8], (10, 11)) == [6, 7, 8, 10, 11]\n assert candidate([7, 8, 9], (11, 12)) == [7, 8, 9, 11, 12]\n", + "entry_point": "add_tuple" + }, + { + "task_id": "HumanEval\\/751", + "prompt": "def check_min_heap(arr, i):\n \"\"\" Check if the given array represents a min heap starting from index i.\n >>> check_min_heap([1, 2, 3, 4, 5, 6], 0)\n True\n >>> check_min_heap([2, 3, 4, 5, 10, 15], 0)\n True\n >>> check_min_heap([2, 10, 4, 5, 3, 15], 0)\n False\n \"\"\"\n", + "canonical_solution": " if 2 * i + 2 > len(arr):\n return True\n left_child = (arr[i] <= arr[2 * i + 1]) and check_min_heap(arr, 2 * i + 1)\n right_child = (2 * i + 2 == len(arr)) or (arr[i] <= arr[2 * i + 2] and check_min_heap(arr, 2 * i + 2))\n return left_child and right_child\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 2, 3, 4, 5, 6], 0) == True\n assert candidate([2, 3, 4, 5, 10, 15], 0) == True\n assert candidate([2, 10, 4, 5, 3, 15], 0) == False\n", + "entry_point": "check_min_heap" + }, + { + "task_id": "HumanEval\\/752", + "prompt": "def jacobsthal_num(n: int) -> int:\n \"\"\" Calculate the nth Jacobsthal number\n >>> jacobsthal_num(5)\n 11\n >>> jacobsthal_num(2)\n 1\n >>> jacobsthal_num(4)\n 5\n \"\"\"\n", + "canonical_solution": " dp = [0] * (n + 1)\n dp[0] = 0\n dp[1] = 1\n for i in range(2, n+1):\n dp[i] = dp[i - 1] + 2 * dp[i - 2]\n return dp[n]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(5) == 11\n assert candidate(2) == 1\n assert candidate(4) == 5\n", + "entry_point": "jacobsthal_num" + }, + { + "task_id": "HumanEval\\/753", + "prompt": "from typing import List, Tuple\n\n\ndef min_k(test_list: List[Tuple[str, int]], K: int) -> List[Tuple[str, int]]:\n \"\"\" Write a function to find minimum k records from tuple list.\n >>> min_k([('Manjeet', 10), ('Akshat', 4), ('Akash', 2), ('Nikhil', 8)], 2)\n [('Akash', 2), ('Akshat', 4)]\n >>> min_k([('Sanjeev', 11), ('Angat', 5), ('Akash', 3), ('Nepin', 9)], 3)\n [('Akash', 3), ('Angat', 5), ('Nepin', 9)]\n >>> min_k([('tanmay', 14), ('Amer', 11), ('Ayesha', 9), ('SKD', 16)], 1)\n [('Ayesha', 9)]\n \"\"\"\n", + "canonical_solution": " res = sorted(test_list, key=lambda x: x[1])[:K]\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([('Manjeet', 10), ('Akshat', 4), ('Akash', 2), ('Nikhil', 8)], 2) == [('Akash', 2), ('Akshat', 4)]\n assert candidate([('Sanjeev', 11), ('Angat', 5), ('Akash', 3), ('Nepin', 9)], 3) == [('Akash', 3), ('Angat', 5), ('Nepin', 9)]\n assert candidate([('tanmay', 14), ('Amer', 11), ('Ayesha', 9), ('SKD', 16)], 1) == [('Ayesha', 9)]\n", + "entry_point": "min_k" + }, + { + "task_id": "754", + "prompt": "def extract_index_list(l1, l2, l3):\n \"\"\" Write a function to find common index elements from three lists.\n >>> extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])\n [1, 7]\n >>> extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 6, 5],[0, 1, 2, 3, 4, 6, 7])\n [1, 6]\n >>> extract_index_list([1, 1, 3, 4, 6, 5, 6],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])\n [1, 5]\n \"\"\"\n", + "canonical_solution": " result = []\n for m, n, o in zip(l1, l2, l3):\n if (m == n == o):\n result.append(m)\n return result\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7]) == [1, 7]\n assert candidate([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 6, 5],[0, 1, 2, 3, 4, 6, 7]) == [1, 6]\n assert candidate([1, 1, 3, 4, 6, 5, 6],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7]) == [1, 5]\n", + "entry_point": "extract_index_list" + }, + { + "task_id": "HumanEval\\/755", + "prompt": "from typing import List\n\n\ndef second_smallest(numbers: List[int]) -> int:\n \"\"\" Find the second smallest number in a list\n >>> second_smallest([1, 2, -8, -2, 0, -2])\n -2\n >>> second_smallest([1, 1, -0.5, 0, 2, -2, -2])\n -0.5\n >>> second_smallest([2, 2])\n None\n \"\"\"\n", + "canonical_solution": " if len(numbers) < 2:\n return None\n if len(numbers) == 2 and numbers[0] == numbers[1]:\n return None\n dup_items = set()\n uniq_items = []\n for x in numbers:\n if x not in dup_items:\n uniq_items.append(x)\n dup_items.add(x)\n uniq_items.sort()\n return uniq_items[1]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 2, -8, -2, 0, -2]) == -2\n assert candidate([1, 1, -0.5, 0, 2, -2, -2]) == -0.5\n assert candidate([2, 2]) == None\n", + "entry_point": "second_smallest" + }, + { + "task_id": "HumanEval\\/756", + "prompt": "import re\n\ndef text_match_zero_one(text: str) -> str:\n \"\"\" Write a function that matches a string that has an 'a' followed by zero or one 'b'.\n >>> text_match_zero_one('ac')\n 'Found a match!'\n >>> text_match_zero_one('dc')\n 'Not matched!'\n >>> text_match_zero_one('abbbba')\n 'Found a match!'\n \"\"\"\n", + "canonical_solution": " patterns = 'ab?'\n if re.search(patterns, text):\n return 'Found a match!'\n else:\n return 'Not matched!'\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('ac') == 'Found a match!'\n assert candidate('dc') == 'Not matched!'\n assert candidate('abbbba') == 'Found a match!'\n", + "entry_point": "text_match_zero_one" + }, + { + "task_id": "HumanEval\\/757", + "prompt": "from typing import List\n\n\ndef count_reverse_pairs(test_list: List[str]) -> str:\n \"\"\" Count the pairs of reverse strings in the given string list\n >>> count_reverse_pairs([\"julia\", \"best\", \"tseb\", \"for\", \"ailuj\"])\n '2'\n >>> count_reverse_pairs([\"geeks\", \"best\", \"for\", \"skeeg\"])\n '1'\n >>> count_reverse_pairs([\"makes\", \"best\", \"sekam\", \"for\", \"rof\"])\n '2'\n \"\"\"\n", + "canonical_solution": " res = sum([1 for idx in range(0, len(test_list)) for idxn in range(idx, len(test_list)) if test_list[idxn] == str(''.join(list(reversed(test_list[idx]))))])\n return str(res)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([\"julia\", \"best\", \"tseb\", \"for\", \"ailuj\"]) == '2'\n assert candidate([\"geeks\", \"best\", \"for\", \"skeeg\"]) == '1'\n assert candidate([\"makes\", \"best\", \"sekam\", \"for\", \"rof\"]) == '2'\n", + "entry_point": "count_reverse_pairs" + }, + { + "task_id": "758", + "prompt": "from typing import List\n\n\ndef unique_sublists(list1: List[List[int]]) -> dict:\n \"\"\" Write a function to count number of unique lists within a list.\n >>> unique_sublists([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]])\n {(1, 3): 2, (5, 7): 2, (13, 15, 17): 1, (9, 11): 1}\n >>> unique_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])\n {('green', 'orange'): 2, ('black',): 1, ('white',): 1}\n \"\"\"\n", + "canonical_solution": " result = {}\n for l in list1:\n result.setdefault(tuple(l), list()).append(1)\n for a, b in result.items():\n result[a] = sum(b)\n return result\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]]) == {(1, 3): 2, (5, 7): 2, (13, 15, 17): 1, (9, 11): 1}\n assert candidate([['green', 'orange'], ['black'], ['green', 'orange'], ['white']]) == {('green', 'orange'): 2, ('black',): 1, ('white',): 1}\n assert candidate([[10, 20, 30, 40], [60, 70, 50, 50], [90, 100, 200]]) == {(10, 20, 30, 40): 1, (60, 70, 50, 50): 1, (90, 100, 200): 1}\n", + "entry_point": "unique_sublists" + }, + { + "task_id": "HumanEval\\/759", + "prompt": "import re\n\ndef is_decimal(num: str) -> bool:\n \"\"\" Check if the string is a decimal with a precision of 2\n >>> is_decimal('123.11')\n True\n >>> is_decimal('e666.86')\n False\n >>> is_decimal('3.124587')\n False\n \"\"\"\n", + "canonical_solution": " dnumre = re.compile(r\"^[0-9]+(\\.[0-9]{1,2})?$\")\n result = dnumre.search(num)\n return bool(result)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('123.11') == True\n assert candidate('e666.86') == False\n assert candidate('3.124587') == False\n", + "entry_point": "is_decimal" + }, + { + "task_id": "HumanEval\\/760", + "prompt": "from typing import List\n\n\ndef unique_Element(arr: List[int], n: int) -> str:\n \"\"\" Check whether an array contains only one distinct element or not.\n >>> unique_Element([1, 1, 1], 3)\n 'YES'\n >>> unique_Element([1, 2, 1, 2], 4)\n 'NO'\n >>> unique_Element([1, 2, 3, 4, 5], 5)\n 'NO'\n \"\"\"\n", + "canonical_solution": " s = set(arr)\n if len(s) == 1:\n return 'YES'\n else:\n return 'NO'\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 1, 1], 3) == 'YES'\n assert candidate([1, 2, 1, 2], 4) == 'NO'\n assert candidate([1, 2, 3, 4, 5], 5) == 'NO'\n", + "entry_point": "unique_Element" + }, + { + "task_id": "HumanEval\\/761", + "prompt": "def arc_length(d: float, a: float) -> float:\n \"\"\" Calculate the arc length of an angle.\n >>> arc_length(9, 45)\n 3.5357142857142856\n >>> arc_length(9, 480)\n None\n >>> arc_length(5, 270)\n 11.785714285714285\n \"\"\"\n", + "canonical_solution": " pi = 22 / 7\n if a >= 360:\n return None\n arclength = (pi * d) * (a / 360)\n return arclength\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(9, 45) == 3.5357142857142856\n assert candidate(9, 480) == None\n assert candidate(5, 270) == 11.785714285714285\n", + "entry_point": "arc_length" + }, + { + "task_id": "HumanEval\\/762", + "prompt": "def check_monthnumber_number(monthnum3: int) -> bool:\n \"\"\" Check whether the given month number contains 30 days or not.\n >>> check_monthnumber_number(6)\n True\n >>> check_monthnumber_number(2)\n False\n >>> check_monthnumber_number(12)\n False\n \"\"\"\n", + "canonical_solution": " return monthnum3 in {4, 6, 9, 11}\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(6) == True\n assert candidate(2) == False\n assert candidate(12) == False\n", + "entry_point": "check_monthnumber_number" + }, + { + "task_id": "HumanEval\\/763", + "prompt": "from typing import List\n\n\ndef find_Min_Diff(arr: List[int], n: int) -> int:\n \"\"\" Find the minimum difference between any two elements in a given array\n >>> find_Min_Diff([1,5,3,19,18,25], 6)\n 1\n >>> find_Min_Diff([4,3,2,6], 4)\n 1\n >>> find_Min_Diff([30,5,20,9], 4)\n 4\n \"\"\"\n", + "canonical_solution": " arr = sorted(arr)\n diff = 10**20\n for i in range(n-1):\n if arr[i+1] - arr[i] < diff:\n diff = arr[i+1] - arr[i]\n return diff\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1,5,3,19,18,25], 6) == 1\n assert candidate([4,3,2,6], 4) == 1\n assert candidate([30,5,20,9], 4) == 4\n", + "entry_point": "find_Min_Diff" + }, + { + "task_id": "764", + "prompt": "def number_ctr(str):\n \"\"\" Count numeric values in a given string\n >>> number_ctr('program2bedone')\n 1\n >>> number_ctr('3wonders')\n 1\n >>> number_ctr('123')\n 3\n \"\"\"\n", + "canonical_solution": " number_ctr = 0\n for i in range(len(str)):\n if str[i] >= '0' and str[i] <= '9':\n number_ctr += 1\n return number_ctr\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('program2bedone') == 1\n assert candidate('3wonders') == 1\n assert candidate('123') == 3\n", + "entry_point": "number_ctr" + }, + { + "task_id": "HumanEval\\/765", + "prompt": "import math\n\ndef is_polite(n: int) -> int:\n \"\"\" Write a function to find nth polite number.\n >>> is_polite(7)\n 11\n >>> is_polite(4)\n 7\n >>> is_polite(9)\n 13\n \"\"\"\n", + "canonical_solution": " n = n + 1\n return int(n + (math.log((n + math.log(n, 2)), 2)))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(7) == 11\n assert candidate(4) == 7\n assert candidate(9) == 13\n", + "entry_point": "is_polite" + }, + { + "task_id": "HumanEval\\/766", + "prompt": "from typing import List, Tuple\n\n\ndef pair_wise(l1: List[int]) -> List[Tuple[int, int]]:\n \"\"\" Iterate over all pairs of consecutive items in a given list\n >>> pair_wise([1,1,2,3,3,4,4,5])\n [(1, 1), (1, 2), (2, 3), (3, 3), (3, 4), (4, 4), (4, 5)]\n >>> pair_wise([1,5,7,9,10])\n [(1, 5), (5, 7), (7, 9), (9, 10)]\n >>> pair_wise([1,2,3,4,5,6,7,8,9,10])\n [(1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), (8, 9), (9, 10)]\n \"\"\"\n", + "canonical_solution": " temp = []\n for i in range(len(l1) - 1):\n current_element, next_element = l1[i], l1[i + 1]\n x = (current_element, next_element)\n temp.append(x)\n return temp\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1,1,2,3,3,4,4,5]) == [(1, 1), (1, 2), (2, 3), (3, 3), (3, 4), (4, 4), (4, 5)]\n assert candidate([1,5,7,9,10]) == [(1, 5), (5, 7), (7, 9), (9, 10)]\n assert candidate([1,2,3,4,5,6,7,8,9,10]) == [(1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), (8, 9), (9, 10)]\n", + "entry_point": "pair_wise" + }, + { + "task_id": "HumanEval\\/767", + "prompt": "from typing import List\n\n\ndef get_Pairs_Count(arr: List[int], n: int, sum: int) -> int:\n \"\"\" Count the number of pairs in the array whose sum is equal to 'sum'.\n >>> get_Pairs_Count([1, 1, 1, 1], 4, 2)\n 6\n >>> get_Pairs_Count([1, 5, 7, -1, 5], 5, 6)\n 3\n >>> get_Pairs_Count([1, -2, 3], 3, 1)\n 1\n \"\"\"\n", + "canonical_solution": " count = 0\n for i in range(0, n):\n for j in range(i + 1, n):\n if arr[i] + arr[j] == sum:\n count += 1\n return count\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 1, 1, 1], 4, 2) == 6\n assert candidate([1, 5, 7, -1, 5], 5, 6) == 3\n assert candidate([1, -2, 3], 3, 1) == 1\n", + "entry_point": "get_Pairs_Count" + }, + { + "task_id": "HumanEval\\/768", + "prompt": "def check_Odd_Parity(x: int) -> bool:\n \"\"\" Check for odd parity of a given number\n >>> check_Odd_Parity(13)\n True\n >>> check_Odd_Parity(21)\n True\n >>> check_Odd_Parity(18)\n False\n \"\"\"\n", + "canonical_solution": " parity = 0\n while (x != 0):\n x = x & (x - 1)\n parity += 1\n return parity % 2 == 1\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(13) == True\n assert candidate(21) == True\n assert candidate(18) == False\n", + "entry_point": "check_Odd_Parity" + }, + { + "task_id": "HumanEval\\/769", + "prompt": "from typing import List\n\n\ndef Diff(li1: List[int], li2: List[int]) -> List[int]:\n \"\"\" Get the difference between two lists\n >>> Diff([10, 15, 20, 25, 30, 35, 40], [25, 40, 35])\n [10, 20, 30, 15]\n >>> Diff([1,2,3,4,5], [6,7,1])\n [2, 3, 4, 5, 6, 7]\n >>> Diff([1,2,3], [6,7,1])\n [2, 3, 6, 7]\n \"\"\"\n", + "canonical_solution": " return list(set(li1) - set(li2)) + list(set(li2) - set(li1))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([10, 15, 20, 25, 30, 35, 40], [25, 40, 35]) == [10, 20, 30, 15]\n assert candidate([1,2,3,4,5], [6,7,1]) == [2, 3, 4, 5, 6, 7]\n assert candidate([1,2,3], [6,7,1]) == [2, 3, 6, 7]\n", + "entry_point": "Diff" + }, + { + "task_id": "HumanEval\\/770", + "prompt": "def odd_Num_Sum(n: int) -> int:\n \"\"\"Calculate the sum of the fourth power of the first n odd natural numbers.\n >>> odd_Num_Sum(2)\n 82\n >>> odd_Num_Sum(3)\n 707\n >>> odd_Num_Sum(4)\n 3108\n \"\"\"\n", + "canonical_solution": " j = 0\n sm = 0\n for i in range(1, n + 1):\n j = (2 * i - 1)\n sm = sm + (j * j * j * j)\n return sm\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(2) == 82\n assert candidate(3) == 707\n assert candidate(4) == 3108\n", + "entry_point": "odd_Num_Sum" + }, + { + "task_id": "HumanEval\\/771", + "prompt": "from collections import deque\n\n\ndef check_expression(exp: str) -> bool:\n \"\"\" Check if the given expression is balanced or not.\n >>> check_expression(\"{()}[{}]\")\n True\n >>> check_expression(\"{()}[{]\")\n False\n >>> check_expression(\"{()}[{}][]({})\")\n True\n \"\"\"\n", + "canonical_solution": " if len(exp) & 1:\n return False\n stack = deque()\n for ch in exp:\n if ch == '(' or ch == '{' or ch == '[':\n stack.append(ch)\n if ch == ')' or ch == '}' or ch == ']':\n if not stack:\n return False\n top = stack.pop()\n if (top == '(' and ch != ')') or (top == '{' and ch != '}' or (top == '[' and ch != ']')):\n return False\n return not stack\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"{()}[{}]\") == True\n assert candidate(\"{()}[{]\") == False\n assert candidate(\"{()}[{}][]({})\") == True\n", + "entry_point": "check_expression" + }, + { + "task_id": "HumanEval\\/772", + "prompt": "def remove_length(test_str: str, K: int) -> str:\n \"\"\" Remove all the words with k length in the given string.\n >>> remove_length('The person is most value tet', 3)\n 'person is most value'\n >>> remove_length('If you told me about this ok', 4)\n 'If you me about ok'\n >>> remove_length('Forces of darkeness is come into the play', 4)\n 'Forces of darkeness is the'\n \"\"\"\n", + "canonical_solution": " temp = test_str.split()\n res = [ele for ele in temp if len(ele) != K]\n res = ' '.join(res)\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('The person is most value tet', 3) == 'person is most value'\n assert candidate('If you told me about this ok', 4) == 'If you me about ok'\n assert candidate('Forces of darkeness is come into the play', 4) == 'Forces of darkeness is the'\n", + "entry_point": "remove_length" + }, + { + "task_id": "HumanEval\\/773", + "prompt": "import re\n\ndef occurance_substring(text: str, pattern: str) -> tuple:\n \"\"\" Find the occurrence and position of the substrings within a string.\n >>> occurance_substring('python programming, python language', 'python')\n ('python', 0, 6)\n >>> occurance_substring('python programming,programming language', 'programming')\n ('programming', 7, 18)\n >>> occurance_substring('python programming,programming language', 'language')\n ('language', 31, 39)\n \"\"\"\n", + "canonical_solution": " for match in re.finditer(pattern, text):\n s = match.start()\n e = match.end()\n return (text[s:e], s, e)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('python programming, python language', 'python') == ('python', 0, 6)\n assert candidate('python programming,programming language', 'programming') == ('programming', 7, 18)\n assert candidate('python programming,programming language', 'language') == ('language', 31, 39)\n", + "entry_point": "occurance_substring" + }, + { + "task_id": "task_774", + "prompt": "import re\n\ndef check_email(email: str) -> str:\n \"\"\"Check if the string is a valid email address or not using regex.\n >>> check_email(\"ankitrai326@gmail.com\")\n 'Valid Email'\n >>> check_email(\"my.ownsite@ourearth.org\")\n 'Valid Email'\n >>> check_email(\"ankitaoie326.com\")\n 'Invalid Email'\n \"\"\"\n regex = '^[a-z0-9]+[\\._]?[a-z0-9]+[@]\\w+[.]\\w{2,3}$'\n if re.search(regex, email):\n return \"Valid Email\"\n else:\n return \"Invalid Email\"\n", + "canonical_solution": " regex = '^[a-z0-9]+[\\._]?[a-z0-9]+[@]\\w+[.]\\w{2,3}$'\n if re.search(regex, email):\n return \"Valid Email\"\n else:\n return \"Invalid Email\"\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"ankitrai326@gmail.com\") == 'Valid Email'\n assert candidate(\"my.ownsite@ourearth.org\") == 'Valid Email'\n assert candidate(\"ankitaoie326.com\") == 'Invalid Email'\n", + "entry_point": "check_email" + }, + { + "task_id": "HumanEval\\/775", + "prompt": "from typing import List\n\n\ndef odd_position(nums: List[int]) -> bool:\n \"\"\" Check whether every odd index contains odd numbers of a given list.\n >>> odd_position([2,1,4,3,6,7,6,3])\n True\n >>> odd_position([4,1,2])\n True\n >>> odd_position([1,2,3])\n False\n \"\"\"\n", + "canonical_solution": " return all(nums[i]%2==i%2 for i in range(len(nums)))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([2,1,4,3,6,7,6,3]) == True\n assert candidate([4,1,2]) == True\n assert candidate([1,2,3]) == False\n", + "entry_point": "odd_position" + }, + { + "task_id": "HumanEval\\/776", + "prompt": "def count_vowels(test_str: str) -> int:\n \"\"\"Write a function to count those characters which have vowels as their neighbors in the given string.\n >>> count_vowels('bestinstareels')\n 7\n >>> count_vowels('partofthejourneyistheend')\n 12\n >>> count_vowels('amazonprime')\n 5\n \"\"\"\n", + "canonical_solution": " res = 0\n vow_list = ['a', 'e', 'i', 'o', 'u']\n for idx in range(1, len(test_str) - 1):\n if test_str[idx] not in vow_list and (test_str[idx - 1] in vow_list or test_str[idx + 1] in vow_list):\n res += 1\n if test_str[0] not in vow_list and test_str[1] in vow_list:\n res += 1\n if test_str[-1] not in vow_list and test_str[-2] in vow_list:\n res += 1\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('bestinstareels') == 7\n assert candidate('partofthejourneyistheend') == 12\n assert candidate('amazonprime') == 5\n", + "entry_point": "count_vowels" + }, + { + "task_id": "HumanEval\\/777", + "prompt": "def find_Sum(arr: list, n: int) -> int:\n \"\"\" Write a python function to find the sum of non-repeated elements in a given array.\n >>> find_Sum([1,2,3,1,1,4,5,6],8)\n 21\n >>> find_Sum([1,10,9,4,2,10,10,45,4],9)\n 71\n >>> find_Sum([12,10,9,45,2,10,10,45,10],9)\n 78\n \"\"\"\n", + "canonical_solution": " arr.sort()\n sum = arr[0]\n for i in range(0, n-1):\n if (arr[i] != arr[i+1]):\n sum = sum + arr[i+1]\n return sum\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1,2,3,1,1,4,5,6],8) == 21\n assert candidate([1,10,9,4,2,10,10,45,4],9) == 71\n assert candidate([12,10,9,45,2,10,10,45,10],9) == 78\n", + "entry_point": "find_Sum" + }, + { + "task_id": "HumanEval\\/778", + "prompt": "from itertools import groupby\n\ndef pack_consecutive_duplicates(list1):\n \"\"\" Pack consecutive duplicates of a given list elements into sublists.\n >>> pack_consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4])\n [[0, 0], [1], [2], [3], [4, 4], [5], [6, 6, 6], [7], [8], [9], [4, 4]]\n >>> pack_consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd'])\n [['a', 'a'], ['b'], ['c'], ['d', 'd']]\n \"\"\"\n", + "canonical_solution": " return [list(group) for key, group in groupby(list1)]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4]) == [[0, 0], [1], [2], [3], [4, 4], [5], [6, 6, 6], [7], [8], [9], [4, 4]]\n assert candidate([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10]) == [[10, 10], [15], [19], [18, 18], [17], [26, 26], [17], [18], [10]]\n assert candidate(['a', 'a', 'b', 'c', 'd', 'd']) == [['a', 'a'], ['b'], ['c'], ['d', 'd']]\n", + "entry_point": "pack_consecutive_duplicates" + }, + { + "task_id": "HumanEval\\/779", + "prompt": "from typing import List, Tuple, Dict\n\n\ndef unique_sublists(list1: List[List[int]]) -> Dict[Tuple[int, ...], int]:\n \"\"\" Count the number of unique lists within a list.\n >>> unique_sublists([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]])\n {(1, 3): 2, (5, 7): 2, (13, 15, 17): 1, (9, 11): 1}\n >>> unique_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])\n {('green', 'orange'): 2, ('black',): 1, ('white',): 1}\n >>> unique_sublists([[1, 2], [3, 4], [4, 5], [6, 7]])\n {(1, 2): 1, (3, 4): 1, (4, 5): 1, (6, 7): 1}\n \"\"\"\n", + "canonical_solution": " result = {}\n for l in list1:\n result.setdefault(tuple(l), 0)\n result[tuple(l)] += 1\n return result\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]]) == {(1, 3): 2, (5, 7): 2, (13, 15, 17): 1, (9, 11): 1}\n assert candidate([['green', 'orange'], ['black'], ['green', 'orange'], ['white']]) == {('green', 'orange'): 2, ('black',): 1, ('white',): 1}\n assert candidate([[1, 2], [3, 4], [4, 5], [6, 7]]) == {(1, 2): 1, (3, 4): 1, (4, 5): 1, (6, 7): 1}\n", + "entry_point": "unique_sublists" + }, + { + "task_id": "HumanEval\\/780", + "prompt": "from itertools import combinations\n\n\ndef find_combinations(test_list):\n \"\"\" Find the combinations of sums with tuples in the given tuple list.\n >>> find_combinations([(2, 4), (6, 7), (5, 1), (6, 10)])\n [(8, 11), (7, 5), (8, 14), (11, 8), (12, 17), (11, 11)]\n >>> find_combinations([(3, 5), (7, 8), (6, 2), (7, 11)])\n [(10, 13), (9, 7), (10, 16), (13, 10), (14, 19), (13, 13)]\n \"\"\"\n", + "canonical_solution": " res = [(b1 + a1, b2 + a2) for (a1, a2), (b1, b2) in combinations(test_list, 2)]\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([(2, 4), (6, 7), (5, 1), (6, 10)]) == [(8, 11), (7, 5), (8, 14), (11, 8), (12, 17), (11, 11)]\n assert candidate([(3, 5), (7, 8), (6, 2), (7, 11)]) == [(10, 13), (9, 7), (10, 16), (13, 10), (14, 19), (13, 13)]\n assert candidate([(4, 6), (8, 9), (7, 3), (8, 12)]) == [(12, 15), (11, 9), (12, 18), (15, 12), (16, 21), (15, 15)]\n", + "entry_point": "find_combinations" + }, + { + "task_id": "HumanEval\\/781", + "prompt": "import math\n\ndef count_Divisors(n: int) -> str:\n \"\"\" Check whether the count of divisors is even or odd.\n >>> count_Divisors(10)\n 'Even'\n >>> count_Divisors(100)\n 'Odd'\n >>> count_Divisors(125)\n 'Even'\n \"\"\"\n", + "canonical_solution": " count = 0\n for i in range(1, int(math.sqrt(n)) + 2):\n if n % i == 0:\n if n // i == i:\n count += 1\n else:\n count += 2\n return \"Even\" if count % 2 == 0 else \"Odd\"\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(10) == 'Even'\n assert candidate(100) == 'Odd'\n assert candidate(125) == 'Even'\n", + "entry_point": "count_Divisors" + }, + { + "task_id": "HumanEval\\/782", + "prompt": "def Odd_Length_Sum(arr):\n \"\"\"Find the sum of all odd length subarrays.\n >>> Odd_Length_Sum([1,2,4])\n 14\n >>> Odd_Length_Sum([1,2,1,2])\n 15\n >>> Odd_Length_Sum([1,7])\n 8\n \"\"\"\n", + "canonical_solution": " Sum = 0\n l = len(arr)\n for i in range(l):\n Sum += ((((i + 1) *(l - i) + 1) // 2) * arr[i])\n return Sum\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1,2,4]) == 14\n assert candidate([1,2,1,2]) == 15\n assert candidate([1,7]) == 8\n", + "entry_point": "Odd_Length_Sum" + }, + { + "task_id": "HumanEval\\/783", + "prompt": "def rgb_to_hsv(r: int, g: int, b: int) -> tuple:\n \"\"\" Convert RGB color to HSV color\n >>> rgb_to_hsv(255, 255, 255)\n (0, 0.0, 100.0)\n >>> rgb_to_hsv(0, 215, 0)\n (120.0, 100.0, 84.31372549019608)\n >>> rgb_to_hsv(10, 215, 110)\n (149.26829268292684, 95.34883720930233, 84.31372549019608)\n \"\"\"\n", + "canonical_solution": " r, g, b = r/255.0, g/255.0, b/255.0\n mx = max(r, g, b)\n mn = min(r, g, b)\n df = mx-mn\n if mx == mn:\n h = 0\n elif mx == r:\n h = (60 * ((g-b)/df) + 360) % 360\n elif mx == g:\n h = (60 * ((b-r)/df) + 120) % 360\n elif mx == b:\n h = (60 * ((r-g)/df) + 240) % 360\n if mx == 0:\n s = 0\n else:\n s = (df/mx)*100\n v = mx*100\n return h, s, v\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(255, 255, 255) == (0, 0.0, 100.0)\n assert candidate(0, 215, 0) == (120.0, 100.0, 84.31372549019608)\n assert candidate(10, 215, 110) == (149.26829268292684, 95.34883720930233, 84.31372549019608)\n", + "entry_point": "rgb_to_hsv" + }, + { + "task_id": "HumanEval\\/784", + "prompt": "from typing import List\n\n\ndef mul_even_odd(list1: List[int]) -> int:\n \"\"\" Write a function to find the product of first even and odd number of a given list.\n >>> mul_even_odd([1,3,5,7,4,1,6,8])\n 4\n >>> mul_even_odd([1,2,3,4,5,6,7,8,9,10])\n 2\n >>> mul_even_odd([1,5,7,9,10])\n 10\n \"\"\"\n", + "canonical_solution": " first_even = next((el for el in list1 if el%2==0),-1)\n first_odd = next((el for el in list1 if el%2!=0),-1)\n return (first_even*first_odd)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1,3,5,7,4,1,6,8]) == 4\n assert candidate([1,2,3,4,5,6,7,8,9,10]) == 2\n assert candidate([1,5,7,9,10]) == 10\n", + "entry_point": "mul_even_odd" + }, + { + "task_id": "HumanEval\\/785", + "prompt": "def tuple_str_int(test_str: str) -> tuple:\n \"\"\" Convert a tuple string to an integer tuple.\n >>> tuple_str_int(\"(7, 8, 9)\")\n (7, 8, 9)\n >>> tuple_str_int(\"(1, 2, 3)\")\n (1, 2, 3)\n >>> tuple_str_int(\"(4, 5, 6)\")\n (4, 5, 6)\n \"\"\"\n", + "canonical_solution": " res = tuple(int(num) for num in test_str.replace('(', '').replace(')', '').replace('...', '').split(', '))\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"(7, 8, 9)\") == (7, 8, 9)\n assert candidate(\"(1, 2, 3)\") == (1, 2, 3)\n assert candidate(\"(4, 5, 6)\") == (4, 5, 6)\n", + "entry_point": "tuple_str_int" + }, + { + "task_id": "HumanEval\\/786", + "prompt": "import bisect\n\ndef right_insertion(a, x):\n \"\"\" Locate the right insertion point for a specified value in sorted order.\n >>> right_insertion([1,2,4,5], 6)\n 4\n >>> right_insertion([1,2,4,5], 3)\n 2\n >>> right_insertion([1,2,4,5], 7)\n 4\n \"\"\"\n", + "canonical_solution": " i = bisect.bisect_right(a, x)\n return i\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1,2,4,5], 6) == 4\n assert candidate([1,2,4,5], 3) == 2\n assert candidate([1,2,4,5], 7) == 4\n", + "entry_point": "right_insertion" + }, + { + "task_id": "HumanEval\\/787", + "prompt": "import re\n\ndef text_match_three(text: str) -> str:\n \"\"\" Match a string that has an 'a' followed by three 'b'.\n >>> text_match_three(\"ac\")\n 'Not matched!'\n >>> text_match_three(\"dc\")\n 'Not matched!'\n >>> text_match_three(\"abbbba\")\n 'Found a match!'\n \"\"\"\n", + "canonical_solution": " patterns = 'ab{3}?'\n if re.search(patterns, text):\n return 'Found a match!'\n else:\n return 'Not matched!'\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"ac\") == 'Not matched!'\n assert candidate(\"dc\") == 'Not matched!'\n assert candidate(\"abbbba\") == 'Found a match!'\n", + "entry_point": "text_match_three" + }, + { + "task_id": "HumanEval\\/788", + "prompt": "from typing import List, Tuple\n\n\ndef new_tuple(test_list: List[str], test_str: str) -> Tuple[str, ...]:\n \"\"\" Create a new tuple from the given string and list\n >>> new_tuple([\"WEB\", \"is\"], \"best\")\n ('WEB', 'is', 'best')\n >>> new_tuple([\"We\", \"are\"], \"Developers\")\n ('We', 'are', 'Developers')\n \"\"\"\n", + "canonical_solution": " res = tuple(test_list + [test_str])\n return (res)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([\"WEB\", \"is\"], \"best\") == ('WEB', 'is', 'best')\n assert candidate([\"We\", \"are\"], \"Developers\") == ('We', 'are', 'Developers')\n assert candidate([\"Part\", \"is\"], \"Wrong\") == ('Part', 'is', 'Wrong')\n", + "entry_point": "new_tuple" + }, + { + "task_id": "HumanEval\\/789", + "prompt": "from math import tan, pi\n\ndef perimeter_polygon(s: int, l: float) -> float:\n \"\"\" Calculate the perimeter of a regular polygon with s sides each of length l.\n >>> perimeter_polygon(4, 20)\n 80\n >>> perimeter_polygon(10, 15)\n 150\n >>> perimeter_polygon(9, 7)\n 63\n \"\"\"\n", + "canonical_solution": " perimeter = s * l\n return perimeter\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(4, 20) == 80\n assert candidate(10, 15) == 150\n assert candidate(9, 7) == 63\n", + "entry_point": "perimeter_polygon" + }, + { + "task_id": "HumanEval\\/790", + "prompt": "from typing import List\n\n\ndef even_position(nums: List[int]) -> bool:\n \"\"\" Check whether every even index contains even numbers of a given list.\n >>> even_position([3,2,1])\n False\n >>> even_position([1,2,3])\n False\n >>> even_position([2,1,4])\n True\n \"\"\"\n", + "canonical_solution": " return all(nums[i]%2==i%2 for i in range(len(nums)))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([3,2,1]) == False\n assert candidate([1,2,3]) == False\n assert candidate([2,1,4]) == True\n", + "entry_point": "even_position" + }, + { + "task_id": "HumanEval\\/791", + "prompt": "def remove_nested(test_tup: tuple) -> tuple:\n \"\"\" Remove the nested record from the given tuple.\n >>> remove_nested((1, 5, 7, (4, 6), 10))\n (1, 5, 7, 10)\n >>> remove_nested((2, 6, 8, (5, 7), 11))\n (2, 6, 8, 11)\n >>> remove_nested((3, 7, 9, (6, 8), 12))\n (3, 7, 9, 12)\n \"\"\"\n", + "canonical_solution": " res = tuple()\n for count, ele in enumerate(test_tup):\n if not isinstance(ele, tuple):\n res = res + (ele, )\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate((1, 5, 7, (4, 6), 10)) == (1, 5, 7, 10)\n assert candidate((2, 6, 8, (5, 7), 11)) == (2, 6, 8, 11)\n assert candidate((3, 7, 9, (6, 8), 12)) == (3, 7, 9, 12)\n", + "entry_point": "remove_nested" + }, + { + "task_id": "HumanEval\\/792", + "prompt": "from typing import List\n\n\ndef count_list(input_list: List[List]) -> int:\n \"\"\" Count the number of lists in a given list of lists.\n >>> count_list([[1, 3], [5, 7], [9, 11], [13, 15, 17]])\n 4\n >>> count_list([[1,2],[2,3],[4,5]])\n 3\n >>> count_list([[1,0],[2,0]])\n 2\n \"\"\"\n", + "canonical_solution": " return len(input_list)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([[1, 3], [5, 7], [9, 11], [13, 15, 17]]) == 4\n assert candidate([[1,2],[2,3],[4,5]]) == 3\n assert candidate([[1,0],[2,0]]) == 2\n", + "entry_point": "count_list" + }, + { + "task_id": "HumanEval\\/793", + "prompt": "from typing import List\n\n\ndef last(arr: List[int], x: int, n: int) -> int:\n \"\"\" Find the last position of an element in a sorted array\n >>> last([1,2,3], 1, 3)\n 0\n >>> last([1,1,1,2,3,4], 1, 6)\n 2\n >>> last([2,3,2,3,6,8,9], 3, 8)\n 3\n \"\"\"\n", + "canonical_solution": " low = 0\n high = n - 1\n res = -1\n while (low <= high):\n mid = (low + high) // 2\n if arr[mid] > x:\n high = mid - 1\n elif arr[mid] < x:\n low = mid + 1\n else:\n res = mid\n low = mid + 1\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1,2,3], 1, 3) == 0\n assert candidate([1,1,1,2,3,4], 1, 6) == 2\n assert candidate([2,3,2,3,6,8,9], 3, 8) == 3\n", + "entry_point": "last" + }, + { + "task_id": "HumanEval\\/794", + "prompt": "import re\n\ndef text_starta_endb(text: str) -> str:\n \"\"\" Match a string that has an 'a' followed by anything, ending in 'b'.\n >>> text_starta_endb(\"aabbbb\")\n 'Found a match!'\n >>> text_starta_endb(\"aabAbbbc\")\n 'Not matched!'\n >>> text_starta_endb(\"accddbbjjj\")\n 'Not matched!'\n \"\"\"\n", + "canonical_solution": " patterns = 'a.*?b$'\n if re.search(patterns, text):\n return 'Found a match!'\n else:\n return 'Not matched!'\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"aabbbb\") == 'Found a match!'\n assert candidate(\"aabAbbbc\") == 'Not matched!'\n assert candidate(\"accddbbjjj\") == 'Not matched!'\n", + "entry_point": "text_starta_endb" + }, + { + "task_id": "HumanEval\\/795", + "prompt": "import heapq\nfrom typing import List, Dict\n\n\ndef cheap_items(items: List[Dict[str, float]], n: int) -> List[Dict[str, float]]:\n \"\"\" Find the n cheapest price items from a given dataset using heap queue algorithm.\n >>> cheap_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}],1)\n [{'name': 'Item-1', 'price': 101.1}]\n >>> cheap_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}],2)\n [{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}]\n >>> cheap_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}, {'name': 'Item-3', 'price': 45.09},{'name': 'Item-4', 'price': 22.75}],1)\n [{'name': 'Item-4', 'price': 22.75}]\n \"\"\"\n", + "canonical_solution": " return heapq.nsmallest(n, items, key=lambda s: s['price'])\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}],1) == [{'name': 'Item-1', 'price': 101.1}]\n assert candidate([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}],2) == [{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}]\n assert candidate([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}, {'name': 'Item-3', 'price': 45.09},{'name': 'Item-4', 'price': 22.75}],1) == [{'name': 'Item-4', 'price': 22.75}]\n", + "entry_point": "cheap_items" + }, + { + "task_id": "HumanEval\\/796", + "prompt": "def return_sum(dict):\n \"\"\" Write function to find the sum of all items in the given dictionary.\n >>> return_sum({'a': 100, 'b':200, 'c':300})\n 600\n >>> return_sum({'a': 25, 'b':18, 'c':45})\n 88\n >>> return_sum({'a': 36, 'b':39, 'c':49})\n 124\n \"\"\"\n", + "canonical_solution": " sum = 0\n for i in dict.values():\n sum = sum + i\n return sum\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate({'a': 100, 'b':200, 'c':300}) == 600\n assert candidate({'a': 25, 'b':18, 'c':45}) == 88\n assert candidate({'a': 36, 'b':39, 'c':49}) == 124\n", + "entry_point": "return_sum" + }, + { + "task_id": "HumanEval\\/797", + "prompt": "def sum_Odd(n):\n terms = (n + 1) // 2\n sum1 = terms * terms\n return sum1\n\ndef sum_in_Range(l, r):\n \"\"\" Find the sum of all odd natural numbers within the range l and r.\n >>> sum_in_Range(2, 5)\n 8\n >>> sum_in_Range(5, 7)\n 12\n >>> sum_in_Range(7, 13)\n 40\n \"\"\"\n", + "canonical_solution": " return sum_Odd(r) - sum_Odd(l - 1)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(2, 5) == 8\n assert candidate(5, 7) == 12\n assert candidate(7, 13) == 40\n", + "entry_point": "sum_in_Range" + }, + { + "task_id": "HumanEval\\/798", + "prompt": "from typing import List\n\n\ndef _sum(arr: List[int]) -> int:\n \"\"\" Find the sum of an array of integers\n >>> _sum([1, 2, 3])\n 6\n >>> _sum([15, 12, 13, 10])\n 50\n >>> _sum([0, 1, 2])\n 3\n \"\"\"\n", + "canonical_solution": " sum=0\n for i in arr:\n sum = sum + i\n return(sum)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 2, 3]) == 6\n assert candidate([15, 12, 13, 10]) == 50\n assert candidate([0, 1, 2]) == 3\n", + "entry_point": "_sum" + }, + { + "task_id": "HumanEval\\/799", + "prompt": "INT_BITS = 32\n\ndef left_Rotate(n, d):\n \"\"\" Left rotate the bits of a given number n by d positions.\n >>> left_Rotate(16, 2)\n 64\n >>> left_Rotate(10, 2)\n 40\n >>> left_Rotate(99, 3)\n 792\n \"\"\"\n", + "canonical_solution": " return (n << d) | (n >> (INT_BITS - d))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(16, 2) == 64\n assert candidate(10, 2) == 40\n assert candidate(99, 3) == 792\n", + "entry_point": "left_Rotate" + }, + { + "task_id": "HumanEval\\/800", + "prompt": "import re\n\ndef remove_all_spaces(text: str) -> str:\n \"\"\" Remove all whitespaces from a string\n >>> remove_all_spaces('python program')\n 'pythonprogram'\n >>> remove_all_spaces('python programming language')\n 'pythonprogramminglanguage'\n >>> remove_all_spaces('python program')\n 'pythonprogram'\n \"\"\"\n", + "canonical_solution": " return re.sub(r'\\s+', '', text)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('python program') == 'pythonprogram'\n assert candidate('python programming language') == 'pythonprogramminglanguage'\n assert candidate('python program') == 'pythonprogram'\n", + "entry_point": "remove_all_spaces" + }, + { + "task_id": "HumanEval\\/801", + "prompt": "def test_three_equal(x: int, y: int, z: int) -> int:\n \"\"\" Count the number of equal numbers from three given integers.\n >>> test_three_equal(1, 1, 1)\n 3\n >>> test_three_equal(-1, -2, -3)\n 0\n >>> test_three_equal(1, 2, 2)\n 2\n \"\"\"\n", + "canonical_solution": " result = set([x, y, z])\n if len(result) == 3:\n return 0\n else:\n return (4 - len(result))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(1, 1, 1) == 3\n assert candidate(-1, -2, -3) == 0\n assert candidate(1, 2, 2) == 2\n", + "entry_point": "test_three_equal" + }, + { + "task_id": "HumanEval\\/802", + "prompt": "def count_Rotation(arr: list, n: int) -> int:\n \"\"\" Count the number of rotations required to generate a sorted array\n >>> count_Rotation([3,2,1], 3)\n 1\n >>> count_Rotation([4,5,1,2,3], 5)\n 2\n >>> count_Rotation([7,8,9,1,2,3], 6)\n 3\n \"\"\"\n", + "canonical_solution": " for i in range(1, n):\n if arr[i] < arr[i - 1]:\n return i\n return 0\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([3,2,1], 3) == 1\n assert candidate([4,5,1,2,3], 5) == 2\n assert candidate([7,8,9,1,2,3], 6) == 3\n", + "entry_point": "count_Rotation" + }, + { + "task_id": "HumanEval\\/803", + "prompt": "def is_Perfect_Square(n: int) -> bool:\n \"\"\" Check whether the given number is a perfect square or not.\n >>> is_Perfect_Square(10)\n False\n >>> is_Perfect_Square(36)\n True\n >>> is_Perfect_Square(14)\n False\n \"\"\"\n", + "canonical_solution": " i = 1\n while (i * i <= n):\n if ((n % i == 0) and (n / i == i)):\n return True\n i = i + 1\n return False\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(10) == False\n assert candidate(36) == True\n assert candidate(14) == False\n", + "entry_point": "is_Perfect_Square" + }, + { + "task_id": "HumanEval\\/804", + "prompt": "from typing import List\n\n\ndef is_Product_Even(arr: List[int], n: int) -> bool:\n \"\"\" Check whether the product of numbers is even or not\n >>> is_Product_Even([1, 2, 3], 3)\n True\n >>> is_Product_Even([1, 2, 1, 4], 4)\n True\n >>> is_Product_Even([1, 1], 2)\n False\n \"\"\"\n", + "canonical_solution": " for i in range(0, n):\n if ((arr[i] & 1) == 0):\n return True\n return False\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 2, 3], 3) == True\n assert candidate([1, 2, 1, 4], 4) == True\n assert candidate([1, 1], 2) == False\n", + "entry_point": "is_Product_Even" + }, + { + "task_id": "HumanEval\\/805", + "prompt": "from typing import List\n\n\ndef max_sum_list(lists: List[List[int]]) -> List[int]:\n \"\"\" Write a function to find the list in a list of lists whose sum of elements is the highest.\n >>> max_sum_list([[1,2,3], [4,5,6], [10,11,12], [7,8,9]])\n [10, 11, 12]\n >>> max_sum_list([[3,2,1], [6,5,4], [12,11,10]])\n [12,11,10]\n >>> max_sum_list([[2,3,1]])\n [2,3,1]\n \"\"\"\n", + "canonical_solution": " return max(lists, key=sum)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([[1,2,3], [4,5,6], [10,11,12], [7,8,9]]) == [10, 11, 12]\n assert candidate([[3,2,1], [6,5,4], [12,11,10]]) == [12,11,10]\n assert candidate([[2,3,1]]) == [2,3,1]\n", + "entry_point": "max_sum_list" + }, + { + "task_id": "HumanEval\\/806", + "prompt": "def max_run_uppercase(test_str: str) -> int:\n \"\"\"Write a function to find maximum run of uppercase characters in the given string.\n >>> max_run_uppercase('GeMKSForGERksISBESt')\n 5\n >>> max_run_uppercase('PrECIOusMOVemENTSYT')\n 6\n >>> max_run_uppercase('GooGLEFluTTER')\n 4\n \"\"\"\n", + "canonical_solution": " cnt = 0\n res = 0\n for idx in range(0, len(test_str)):\n if test_str[idx].isupper():\n cnt += 1\n else:\n res = max(res, cnt)\n cnt = 0\n res = max(res, cnt)\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('GeMKSForGERksISBESt') == 5\n assert candidate('PrECIOusMOVemENTSYT') == 6\n assert candidate('GooGLEFluTTER') == 4\n", + "entry_point": "max_run_uppercase" + }, + { + "task_id": "HumanEval\\/807", + "prompt": "from typing import List\n\n\ndef first_odd(nums: List[int]) -> int:\n \"\"\" Find the first odd number in a given list of numbers.\n >>> first_odd([1, 3, 5])\n 1\n >>> first_odd([2, 4, 1, 3])\n 1\n >>> first_odd([8, 9, 1])\n 9\n \"\"\"\n", + "canonical_solution": " first_odd = next((el for el in nums if el%2!=0),-1)\n return first_odd\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 3, 5]) == 1\n assert candidate([2, 4, 1, 3]) == 1\n assert candidate([8, 9, 1]) == 9\n", + "entry_point": "first_odd" + }, + { + "task_id": "HumanEval\\/808", + "prompt": "def check_K(test_tup: tuple, K: int) -> bool:\n \"\"\" Check if the given tuple contains the element K\n >>> check_K((10, 4, 5, 6, 8), 6)\n True\n >>> check_K((1, 2, 3, 4, 5, 6), 7)\n False\n >>> check_K((7, 8, 9, 44, 11, 12), 11)\n True\n \"\"\"\n", + "canonical_solution": " res = False\n for ele in test_tup:\n if ele == K:\n res = True\n break\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate((10, 4, 5, 6, 8), 6) == True\n assert candidate((1, 2, 3, 4, 5, 6), 7) == False\n assert candidate((7, 8, 9, 44, 11, 12), 11) == True\n", + "entry_point": "check_K" + }, + { + "task_id": "HumanEval\\/809", + "prompt": "def check_smaller(test_tup1: tuple, test_tup2: tuple) -> bool:\n \"\"\" Check if each element of second tuple is smaller than its corresponding index in first tuple.\n >>> check_smaller((1, 2, 3), (2, 3, 4))\n False\n >>> check_smaller((4, 5, 6), (3, 4, 5))\n True\n >>> check_smaller((11, 12, 13), (10, 11, 12))\n True\n \"\"\"\n", + "canonical_solution": " return all(x > y for x, y in zip(test_tup1, test_tup2))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate((1, 2, 3), (2, 3, 4)) == False\n assert candidate((4, 5, 6), (3, 4, 5)) == True\n assert candidate((11, 12, 13), (10, 11, 12)) == True\n", + "entry_point": "check_smaller" + }, + { + "task_id": "HumanEval\\/810", + "prompt": "from collections import Counter\n\n\ndef count_variable(a: int, b: int, c: int, d: int) -> list:\n \"\"\" Write a function to iterate over elements repeating each as many times as its count.\n >>> count_variable(4, 2, 0, -2)\n ['p', 'p', 'p', 'p', 'q', 'q']\n >>> count_variable(0, 1, 2, 3)\n ['q', 'r', 'r', 's', 's', 's']\n \"\"\"\n", + "canonical_solution": " c = Counter(p=a, q=b, r=c, s=d)\n return list(c.elements())\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(4, 2, 0, -2) == ['p', 'p', 'p', 'p', 'q', 'q']\n assert candidate(0, 1, 2, 3) == ['q', 'r', 'r', 's', 's', 's']\n assert candidate(11, 15, 12, 23) == ['p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's']\n", + "entry_point": "count_variable" + }, + { + "task_id": "HumanEval\\/811", + "prompt": "from typing import List, Tuple\n\n\ndef check_identical(test_list1: List[Tuple[int, int]], test_list2: List[Tuple[int, int]]) -> bool:\n \"\"\" Check if two lists of tuples are identical or not.\n >>> check_identical([(10, 4), (2, 5)], [(10, 4), (2, 5)])\n True\n >>> check_identical([(1, 2), (3, 7)], [(12, 14), (12, 45)])\n False\n >>> check_identical([(2, 14), (12, 25)], [(2, 14), (12, 25)])\n True\n \"\"\"\n", + "canonical_solution": " return test_list1 == test_list2\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([(10, 4), (2, 5)], [(10, 4), (2, 5)]) == True\n assert candidate([(1, 2), (3, 7)], [(12, 14), (12, 45)]) == False\n assert candidate([(2, 14), (12, 25)], [(2, 14), (12, 25)]) == True\n", + "entry_point": "check_identical" + }, + { + "task_id": "HumanEval\\/812", + "prompt": "import re\n\ndef road_rd(street: str) -> str:\n \"\"\" Abbreviate 'road' as 'rd.' in a given string\n >>> road_rd('ravipadu Road')\n 'ravipadu Rd.'\n >>> road_rd('palnadu Road')\n 'palnadu Rd.'\n >>> road_rd('eshwar enclave Road')\n 'eshwar enclave Rd.'\n \"\"\"\n", + "canonical_solution": " return re.sub('Road$', 'Rd.', street)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('ravipadu Road') == 'ravipadu Rd.'\n assert candidate('palnadu Road') == 'palnadu Rd.'\n assert candidate('eshwar enclave Road') == 'eshwar enclave Rd.'\n", + "entry_point": "road_rd" + }, + { + "task_id": "HumanEval\\/813", + "prompt": "def string_length(str1: str) -> int:\n \"\"\" Calculate the length of the string\n >>> string_length('python')\n 6\n >>> string_length('program')\n 7\n >>> string_length('language')\n 8\n \"\"\"\n", + "canonical_solution": " count = 0\n for char in str1:\n count += 1\n return count\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('python') == 6\n assert candidate('program') == 7\n assert candidate('language') == 8\n", + "entry_point": "string_length" + }, + { + "task_id": "HumanEval\\/814", + "prompt": "def rombus_area(p: float, q: float) -> float:\n \"\"\" Calculate the area of a rhombus given the lengths of its diagonals p and q.\n >>> rombus_area(10, 20)\n 100.0\n >>> rombus_area(10, 5)\n 25.0\n >>> rombus_area(4, 2)\n 4.0\n \"\"\"\n", + "canonical_solution": " return (p * q) / 2\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(10, 20) == 100.0\n assert candidate(10, 5) == 25.0\n assert candidate(4, 2) == 4.0\n", + "entry_point": "rombus_area" + }, + { + "task_id": "HumanEval\\/815", + "prompt": "from typing import List\n\n\ndef sort_by_dnf(arr: List[int], n: int) -> List[int]:\n \"\"\" Sort the given array consisting of only 0, 1, and 2 without using any sorting algorithm.\n >>> sort_by_dnf([1,2,0,1,0,1,2,1,1], 9)\n [0, 0, 1, 1, 1, 1, 1, 2, 2]\n >>> sort_by_dnf([1,0,0,1,2,1,2,2,1,0], 10)\n [0, 0, 0, 1, 1, 1, 1, 2, 2, 2]\n >>> sort_by_dnf([2,2,1,0,0,0,1,1,2,1], 10)\n [0, 0, 0, 1, 1, 1, 1, 2, 2, 2]\n \"\"\"\n", + "canonical_solution": " low=0\n mid=0\n high=n-1\n while mid <= high:\n if arr[mid] == 0:\n arr[low], arr[mid] = arr[mid], arr[low]\n low = low + 1\n mid = mid + 1\n elif arr[mid] == 1:\n mid = mid + 1\n else:\n arr[mid], arr[high] = arr[high], arr[mid]\n high = high - 1\n return arr\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1,2,0,1,0,1,2,1,1], 9) == [0, 0, 1, 1, 1, 1, 1, 2, 2]\n assert candidate([1,0,0,1,2,1,2,2,1,0], 10) == [0, 0, 0, 1, 1, 1, 1, 2, 2, 2]\n assert candidate([2,2,1,0,0,0,1,1,2,1], 10) == [0, 0, 0, 1, 1, 1, 1, 2, 2, 2]\n", + "entry_point": "sort_by_dnf" + }, + { + "task_id": "HumanEval\\/816", + "prompt": "\n\ndef clear_tuple(test_tup: tuple) -> tuple:\n \"\"\" Clear the values of the given tuple\n >>> clear_tuple((1, 5, 3, 6, 8))\n ()\n >>> clear_tuple((2, 1, 4, 5, 6))\n ()\n \"\"\"\n", + "canonical_solution": " return ()\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate((1, 5, 3, 6, 8)) == ()\n assert candidate((2, 1, 4, 5, 6)) == ()\n assert candidate((3, 2, 5, 6, 8)) == ()\n", + "entry_point": "clear_tuple" + }, + { + "task_id": "HumanEval\\/817", + "prompt": "from typing import List\n\n\ndef div_of_nums(nums: List[int], m: int, n: int) -> List[int]:\n \"\"\" Find numbers divisible by m or n from a list of numbers using lambda function.\n >>> div_of_nums([19, 65, 57, 39, 152, 639, 121, 44, 90, 190], 19, 13)\n [19, 65, 57, 39, 152, 190]\n >>> div_of_nums([1, 2, 3, 5, 7, 8, 10], 2, 5)\n [2, 5, 8, 10]\n >>> div_of_nums([10, 15, 14, 13, 18, 12, 20], 10, 5)\n [10, 15, 20]\n \"\"\"\n", + "canonical_solution": " result = list(filter(lambda x: (x % m == 0 or x % n == 0), nums))\n return result\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([19, 65, 57, 39, 152, 639, 121, 44, 90, 190], 19, 13) == [19, 65, 57, 39, 152, 190]\n assert candidate([1, 2, 3, 5, 7, 8, 10], 2, 5) == [2, 5, 8, 10]\n assert candidate([10, 15, 14, 13, 18, 12, 20], 10, 5) == [10, 15, 20]\n", + "entry_point": "div_of_nums" + }, + { + "task_id": "HumanEval\\/818", + "prompt": "def lower_ctr(str: str) -> int:\n \"\"\" Count lower case letters in a given string\n >>> lower_ctr('abc')\n 3\n >>> lower_ctr('string')\n 6\n >>> lower_ctr('Python')\n 5\n \"\"\"\n", + "canonical_solution": " lower_ctr = 0\n for i in range(len(str)):\n if str[i] >= 'a' and str[i] <= 'z': lower_ctr += 1\n return lower_ctr\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('abc') == 3\n assert candidate('string') == 6\n assert candidate('Python') == 5\n", + "entry_point": "lower_ctr" + }, + { + "task_id": "HumanEval\\/819", + "prompt": "from typing import List, Tuple\n\n\ndef count_duplic(lists: List[int]) -> Tuple[List[int], List[int]]:\n \"\"\" Count the frequency of consecutive duplicate elements in a given list of numbers.\n >>> count_duplic([1,2,2,2,4,4,4,5,5,5,5])\n ([1, 2, 4, 5], [1, 3, 3, 4])\n >>> count_duplic([2,2,3,1,2,6,7,9])\n ([2, 3, 1, 2, 6, 7, 9], [2, 1, 1, 1, 1, 1, 1])\n >>> count_duplic([2,1,5,6,8,3,4,9,10,11,8,12])\n ([2, 1, 5, 6, 8, 3, 4, 9, 10, 11, 8, 12], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])\n \"\"\"\n", + "canonical_solution": " element = []\n frequency = []\n if not lists:\n return element, frequency\n running_count = 1\n for i in range(len(lists)-1):\n if lists[i] == lists[i+1]:\n running_count += 1\n else:\n frequency.append(running_count)\n element.append(lists[i])\n running_count = 1\n frequency.append(running_count)\n element.append(lists[i+1])\n return element, frequency\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1,2,2,2,4,4,4,5,5,5,5]) == ([1, 2, 4, 5], [1, 3, 3, 4])\n assert candidate([2,2,3,1,2,6,7,9]) == ([2, 3, 1, 2, 6, 7, 9], [2, 1, 1, 1, 1, 1, 1])\n assert candidate([2,1,5,6,8,3,4,9,10,11,8,12]) == ([2, 1, 5, 6, 8, 3, 4, 9, 10, 11, 8, 12], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])\n", + "entry_point": "count_duplic" + }, + { + "task_id": "HumanEval\\/820", + "prompt": "def check_monthnum_number(monthnum1: int) -> bool:\n \"\"\" Check whether the given month number contains 28 days or not.\n >>> check_monthnum_number(2)\n True\n >>> check_monthnum_number(1)\n False\n >>> check_monthnum_number(3)\n False\n \"\"\"\n", + "canonical_solution": " if monthnum1 == 2:\n return True\n else:\n return False\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(2) == True\n assert candidate(1) == False\n assert candidate(3) == False\n", + "entry_point": "check_monthnum_number" + }, + { + "task_id": "HumanEval\\/821", + "prompt": "import collections as ct\n\ndef merge_dictionaries(dict1, dict2):\n \"\"\" Merge two dictionaries into a single expression\n >>> merge_dictionaries({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" })\n {'B': 'Black', 'R': 'Red', 'P': 'Pink', 'G': 'Green', 'W': 'White'}\n >>> merge_dictionaries({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" },{ \"O\": \"Orange\", \"W\": \"White\", \"B\": \"Black\" })\n {'O': 'Orange', 'P': 'Pink', 'B': 'Black', 'W': 'White', 'R': 'Red'}\n >>> merge_dictionaries({ \"G\": \"Green\", \"W\": \"White\" },{ \"O\": \"Orange\", \"W\": \"White\", \"B\": \"Black\" })\n {'W': 'White', 'O': 'Orange', 'G': 'Green', 'B': 'Black'}\n \"\"\"\n", + "canonical_solution": " merged_dict = dict(ct.ChainMap({}, dict1, dict2))\n return merged_dict\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" }) == {'B': 'Black', 'R': 'Red', 'P': 'Pink', 'G': 'Green', 'W': 'White'}\n assert candidate({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" },{ \"O\": \"Orange\", \"W\": \"White\", \"B\": \"Black\" }) == {'O': 'Orange', 'P': 'Pink', 'B': 'Black', 'W': 'White', 'R': 'Red'}\n assert candidate({ \"G\": \"Green\", \"W\": \"White\" },{ \"O\": \"Orange\", \"W\": \"White\", \"B\": \"Black\" }) == {'W': 'White', 'O': 'Orange', 'G': 'Green', 'B': 'Black'}\n", + "entry_point": "merge_dictionaries" + }, + { + "task_id": "HumanEval\\/822", + "prompt": "import re\n\ndef pass_validity(p: str) -> bool:\n \"\"\" Return true if the password is valid.\n >>> pass_validity(\"password\")\n False\n >>> pass_validity(\"Password@10\")\n True\n >>> pass_validity(\"password@10\")\n False\n \"\"\"\n", + "canonical_solution": " x = True\n while x: \n if (len(p)<6 or len(p)>12):\n break\n elif not re.search(\"[a-z]\",p):\n break\n elif not re.search(\"[0-9]\",p):\n break\n elif not re.search(\"[A-Z]\",p):\n break\n elif not re.search(\"[$#@]\",p):\n break\n elif re.search(\"\\s\",p):\n break\n else:\n return True\n x=False\n break\n\n if x:\n return False\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"password\") == False\n assert candidate(\"Password@10\") == True\n assert candidate(\"password@10\") == False\n", + "entry_point": "pass_validity" + }, + { + "task_id": "HumanEval\\/823", + "prompt": "import re\n\ndef check_substring(string: str, sample: str) -> str:\n \"\"\" Check if the given string starts with a substring using regex.\n >>> check_substring(\"dreams for dreams makes life fun\", \"makes\")\n 'string doesnt start with the given substring'\n >>> check_substring(\"Hi there how are you Hi alex\", \"Hi\")\n 'string starts with the given substring'\n >>> check_substring(\"Its been a long day\", \"been\")\n 'string doesnt start with the given substring'\n \"\"\"\n", + "canonical_solution": " if sample in string:\n y = \"\\A\" + sample\n x = re.search(y, string)\n if x:\n return \"string starts with the given substring\"\n else:\n return \"string doesnt start with the given substring\"\n else:\n return \"entered string isnt a substring\"\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"dreams for dreams makes life fun\", \"makes\") == 'string doesnt start with the given substring'\n assert candidate(\"Hi there how are you Hi alex\", \"Hi\") == 'string starts with the given substring'\n assert candidate(\"Its been a long day\", \"been\") == 'string doesnt start with the given substring'\n", + "entry_point": "check_substring" + }, + { + "task_id": "HumanEval\\/824", + "prompt": "from typing import List\n\n\ndef remove_even(l: List[int]) -> List[int]:\n \"\"\" Remove even numbers from a given list\n >>> remove_even([1,3,5,2])\n [1,3,5]\n >>> remove_even([5,6,7])\n [5,7]\n >>> remove_even([1,2,3,4])\n [1,3]\n \"\"\"\n", + "canonical_solution": " return [x for x in l if x % 2 != 0]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1,3,5,2]) == [1,3,5]\n assert candidate([5,6,7]) == [5,7]\n assert candidate([1,2,3,4]) == [1,3]\n", + "entry_point": "remove_even" + }, + { + "task_id": "HumanEval\\/825", + "prompt": "from typing import List\n\n\ndef access_elements(nums: List[int], list_index: List[int]) -> List[int]:\n \"\"\" Access multiple elements of specified index from a given list\n >>> access_elements([2,3,8,4,7,9],[0,3,5])\n [2, 4, 9]\n >>> access_elements([1, 2, 3, 4, 5],[1,2])\n [2, 3]\n >>> access_elements([1,0,2,3],[0,1])\n [1, 0]\n \"\"\"\n", + "canonical_solution": " return [nums[i] for i in list_index]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([2,3,8,4,7,9],[0,3,5]) == [2, 4, 9]\n assert candidate([1, 2, 3, 4, 5],[1,2]) == [2, 3]\n assert candidate([1,0,2,3],[0,1]) == [1, 0]\n", + "entry_point": "access_elements" + }, + { + "task_id": "HumanEval\\/826", + "prompt": "def check_Type_Of_Triangle(a: int, b: int, c: int) -> str:\n \"\"\" Determine the type of triangle given its sides.\n >>> check_Type_Of_Triangle(1, 2, 3)\n 'Obtuse-angled Triangle'\n >>> check_Type_Of_Triangle(2, 2, 2)\n 'Acute-angled Triangle'\n >>> check_Type_Of_Triangle(1, 0, 1)\n 'Right-angled Triangle'\n \"\"\"\n", + "canonical_solution": " sqa = pow(a, 2)\n sqb = pow(b, 2)\n sqc = pow(c, 2)\n if (sqa == sqa + sqb or sqb == sqa + sqc or sqc == sqa + sqb):\n return \"Right-angled Triangle\"\n elif (sqa > sqc + sqb or sqb > sqa + sqc or sqc > sqa + sqb):\n return \"Obtuse-angled Triangle\"\n else:\n return \"Acute-angled Triangle\"\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(1, 2, 3) == 'Obtuse-angled Triangle'\n assert candidate(2, 2, 2) == 'Acute-angled Triangle'\n assert candidate(1, 0, 1) == 'Right-angled Triangle'\n", + "entry_point": "check_Type_Of_Triangle" + }, + { + "task_id": "HumanEval\\/827", + "prompt": "from typing import List\n\n\ndef sum_column(list1: List[List[int]], C: int) -> int:\n \"\"\" Write a function to sum a specific column of a list in a given list of lists.\n >>> sum_column([[1,2,3,2],[4,5,6,2],[7,8,9,5]], 0)\n 12\n >>> sum_column([[1,2,3,2],[4,5,6,2],[7,8,9,5]], 1)\n 15\n >>> sum_column([[1,2,3,2],[4,5,6,2],[7,8,9,5]], 3)\n 9\n \"\"\"\n", + "canonical_solution": " result = sum(row[C] for row in list1)\n return result\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([[1,2,3,2],[4,5,6,2],[7,8,9,5]], 0) == 12\n assert candidate([[1,2,3,2],[4,5,6,2],[7,8,9,5]], 1) == 15\n assert candidate([[1,2,3,2],[4,5,6,2],[7,8,9,5]], 3) == 9\n", + "entry_point": "sum_column" + }, + { + "task_id": "HumanEval\\/828", + "prompt": "def count_alpha_dig_spl(string: str) -> tuple:\n \"\"\" Count alphabets, digits, and special characters in a given string.\n >>> count_alpha_dig_spl(\"abc!@#123\")\n (3, 3, 3)\n >>> count_alpha_dig_spl(\"dgsuy@#$%&1255\")\n (5, 4, 5)\n \"\"\"\n", + "canonical_solution": " alphabets = digits = special = 0\n for i in range(len(string)):\n if string[i].isalpha():\n alphabets += 1\n elif string[i].isdigit():\n digits += 1\n else:\n special += 1\n return (alphabets, digits, special)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"abc!@#123\") == (3, 3, 3)\n assert candidate(\"dgsuy@#$%&1255\") == (5, 4, 5)\n assert candidate(\"fjdsif627348#%$^&\") == (6, 6, 5)\n", + "entry_point": "count_alpha_dig_spl" + }, + { + "task_id": "HumanEval\\/829", + "prompt": "from collections import Counter\nfrom typing import List\n\n\ndef second_frequent(input: List[str]) -> str:\n \"\"\"Find the second most repeated (or frequent) string in the given sequence.\n >>> second_frequent(['aaa','bbb','ccc','bbb','aaa','aaa'])\n 'bbb'\n >>> second_frequent(['abc','bcd','abc','bcd','bcd','bcd'])\n 'abc'\n >>> second_frequent(['cdma','gsm','hspa','gsm','cdma','cdma'])\n 'gsm'\n \"\"\"\n", + "canonical_solution": " dict = Counter(input)\n value = sorted(dict.values(), reverse=True)\n second_large = value[1]\n for (key, val) in dict.items():\n if val == second_large:\n return (key)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(['aaa','bbb','ccc','bbb','aaa','aaa']) == 'bbb'\n assert candidate(['abc','bcd','abc','bcd','bcd','bcd']) == 'abc'\n assert candidate(['cdma','gsm','hspa','gsm','cdma','cdma']) == 'gsm'\n", + "entry_point": "second_frequent" + }, + { + "task_id": "HumanEval\\/830", + "prompt": "import math\n\ndef round_up(a: float, digits: int) -> float:\n \"\"\" Round up a number to specific digits\n >>> round_up(123.01247, 0)\n 124.0\n >>> round_up(123.01247, 1)\n 123.1\n >>> round_up(123.01247, 2)\n 123.02\n \"\"\"\n", + "canonical_solution": " n = 10**-digits\n return round(math.ceil(a / n) * n, digits)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(123.01247, 0) == 124.0\n assert candidate(123.01247, 1) == 123.1\n assert candidate(123.01247, 2) == 123.02\n", + "entry_point": "round_up" + }, + { + "task_id": "HumanEval\\/831", + "prompt": "from typing import List\n\n\ndef count_Pairs(arr: List[int], n: int) -> int:\n \"\"\" Count equal element pairs from the given array\n >>> count_Pairs([1, 1, 1, 1], 4)\n 6\n >>> count_Pairs([1, 5, 1], 3)\n 1\n >>> count_Pairs([3, 2, 1, 7, 8, 9], 6)\n 0\n \"\"\"\n", + "canonical_solution": " cnt = 0\n for i in range(n):\n for j in range(i + 1, n):\n if arr[i] == arr[j]:\n cnt += 1\n return cnt\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 1, 1, 1], 4) == 6\n assert candidate([1, 5, 1], 3) == 1\n assert candidate([3, 2, 1, 7, 8, 9], 6) == 0\n", + "entry_point": "count_Pairs" + }, + { + "task_id": "HumanEval\\/832", + "prompt": "import re\n\ndef extract_max(input: str) -> int:\n \"\"\" Extract the maximum numeric value from a string by using regex.\n >>> extract_max('100klh564abc365bg')\n 564\n >>> extract_max('hello300how546mer231')\n 546\n >>> extract_max('its233beenalong343journey234')\n 343\n \"\"\"\n", + "canonical_solution": " numbers = re.findall('\\\\d+', input)\n numbers = map(int, numbers)\n return max(numbers)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('100klh564abc365bg') == 564\n assert candidate('hello300how546mer231') == 546\n assert candidate('its233beenalong343journey234') == 343\n", + "entry_point": "extract_max" + }, + { + "task_id": "HumanEval\\/833", + "prompt": "def get_key(d: dict) -> list:\n \"\"\" Return the keys of the dictionary as a list.\n >>> get_key({1:'python',2:'java'})\n [1, 2]\n >>> get_key({10:'red',20:'blue',30:'black'})\n [10, 20, 30]\n >>> get_key({27:'language',39:'java',44:'little'})\n [27, 39, 44]\n \"\"\"\n", + "canonical_solution": " return list(d.keys())\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate({1:'python',2:'java'}) == [1, 2]\n assert candidate({10:'red',20:'blue',30:'black'}) == [10, 20, 30]\n assert candidate({27:'language',39:'java',44:'little'}) == [27, 39, 44]\n", + "entry_point": "get_key" + }, + { + "task_id": "HumanEval\\/834", + "prompt": "def generate_matrix(n: int) -> List[List[int]]:\n \"\"\" Generate a square matrix filled with elements from 1 to n^2 in spiral order.\n >>> generate_matrix(3)\n [[1, 2, 3], [8, 9, 4], [7, 6, 5]]\n >>> generate_matrix(2)\n [[1, 2], [4, 3]]\n \"\"\"\n", + "canonical_solution": " if n <= 0:\n return []\n matrix = [row[:] for row in [[0] * n] * n]\n row_st, row_ed = 0, n - 1\n col_st, col_ed = 0, n - 1\n current = 1\n while True:\n if current > n * n:\n break\n for c in range(col_st, col_ed + 1):\n matrix[row_st][c] = current\n current += 1\n row_st += 1\n for r in range(row_st, row_ed + 1):\n matrix[r][col_ed] = current\n current += 1\n col_ed -= 1\n for c in range(col_ed, col_st - 1, -1):\n matrix[row_ed][c] = current\n current += 1\n row_ed -= 1\n for r in range(row_ed, row_st - 1, -1):\n matrix[r][col_st] = current\n current += 1\n col_st += 1\n return matrix\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(3) == [[1, 2, 3], [8, 9, 4], [7, 6, 5]]\n assert candidate(2) == [[1, 2], [4, 3]]\n assert candidate(7) == [[1, 2, 3, 4, 5, 6, 7], [24, 25, 26, 27, 28, 29, 8], [23, 40, 41, 42, 43, 30, 9], [22, 39, 48, 49, 44, 31, 10], [21, 38, 47, 46, 45, 32, 11], [20, 37, 36, 35, 34, 33, 12], [19, 18, 17, 16, 15, 14, 13]]\n", + "entry_point": "generate_matrix" + }, + { + "task_id": "HumanEval\\/835", + "prompt": "def slope(x1: float, y1: float, x2: float, y2: float) -> float:\n \"\"\" Calculate the slope of a line given two points (x1, y1) and (x2, y2).\n >>> slope(4, 2, 2, 5)\n -1.5\n >>> slope(2, 4, 4, 6)\n 1.0\n >>> slope(1, 2, 4, 2)\n 0.0\n \"\"\"\n", + "canonical_solution": " return (y2 - y1) / (x2 - x1)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(4, 2, 2, 5) == -1.5\n assert candidate(2, 4, 4, 6) == 1.0\n assert candidate(1, 2, 4, 2) == 0.0\n", + "entry_point": "slope" + }, + { + "task_id": "HumanEval\\/836", + "prompt": "from sys import maxsize\n\ndef max_sub_array_sum(a: list, size: int) -> int:\n \"\"\"Find the length of the subarray having maximum sum.\n >>> max_sub_array_sum([-2, -3, 4, -1, -2, 1, 5, -3], 8)\n 5\n >>> max_sub_array_sum([1, -2, 1, 1, -2, 1], 6)\n 2\n >>> max_sub_array_sum([-1, -2, 3, 4, 5], 5)\n 3\n \"\"\"\n", + "canonical_solution": " max_so_far = -maxsize - 1\n max_ending_here = 0\n start = 0\n end = 0\n s = 0\n for i in range(0, size):\n max_ending_here += a[i]\n if max_so_far < max_ending_here:\n max_so_far = max_ending_here\n start = s\n end = i\n if max_ending_here < 0:\n max_ending_here = 0\n s = i + 1\n return (end - start + 1)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([-2, -3, 4, -1, -2, 1, 5, -3], 8) == 5\n assert candidate([1, -2, 1, 1, -2, 1], 6) == 2\n assert candidate([-1, -2, 3, 4, 5], 5) == 3\n", + "entry_point": "max_sub_array_sum" + }, + { + "task_id": "HumanEval\\/837", + "prompt": "def cube_Sum(n: int) -> int:\n \"\"\" Calculate the cube sum of the first n odd natural numbers.\n >>> cube_Sum(2)\n 28\n >>> cube_Sum(3)\n 153\n >>> cube_Sum(4)\n 496\n \"\"\"\n", + "canonical_solution": " sum = 0\n for i in range(n):\n sum += (2*i+1)**3\n return sum\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(2) == 28\n assert candidate(3) == 153\n assert candidate(4) == 496\n", + "entry_point": "cube_Sum" + }, + { + "task_id": "HumanEval\\/838", + "prompt": "def min_Swaps(s1: str, s2: str) -> int:\n \"\"\" Write a python function to find minimum number swaps required to make two binary strings equal.\n >>> min_Swaps(\"0011\",\"1111\")\n 1\n >>> min_Swaps(\"00011\",\"01001\")\n 2\n >>> min_Swaps(\"111\",\"111\")\n 0\n \"\"\"\n", + "canonical_solution": " c0 = 0; c1 = 0;\n for i in range(len(s1)) :\n if (s1[i] == '0' and s2[i] == '1') :\n c0 += 1;\n elif (s1[i] == '1' and s2[i] == '0') :\n c1 += 1;\n result = c0 // 2 + c1 // 2;\n if (c0 % 2 == 0 and c1 % 2 == 0) :\n return result;\n elif ((c0 + c1) % 2 == 0) :\n return result + 2;\n else :\n return -1;\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"0011\",\"1111\") == 1\n assert candidate(\"00011\",\"01001\") == 2\n assert candidate(\"111\",\"111\") == 0\n", + "entry_point": "min_Swaps" + }, + { + "task_id": "HumanEval\\/839", + "prompt": "from typing import List, Tuple\n\ndef sort_tuple(tup: List[Tuple[str, int]]) -> List[Tuple[str, int]]:\n \"\"\" Sort the tuples alphabetically by the first item of each tuple.\n >>> sort_tuple([(\"Amana\", 28), (\"Zenat\", 30), (\"Abhishek\", 29),(\"Nikhil\", 21), (\"B\", \"C\")])\n [('Abhishek', 29), ('Amana', 28), ('B', 'C'), ('Nikhil', 21), ('Zenat', 30)]\n \"\"\"\n", + "canonical_solution": " return sorted(tup, key=lambda x: x[0])\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([(\"Amana\", 28), (\"Zenat\", 30), (\"Abhishek\", 29),(\"Nikhil\", 21), (\"B\", \"C\")]) == [('Abhishek', 29), ('Amana', 28), ('B', 'C'), ('Nikhil', 21), ('Zenat', 30)]\n assert candidate([(\"aaaa\", 28), (\"aa\", 30), (\"bab\", 29), (\"bb\", 21), (\"csa\", \"C\")]) == [('aa', 30), ('aaaa', 28), ('bab', 29), ('bb', 21), ('csa', 'C')]\n assert candidate([(\"Sarala\", 28), (\"Ayesha\", 30), (\"Suman\", 29),(\"Sai\", 21), (\"G\", \"H\")]) == [('Ayesha', 30), ('G', 'H'), ('Sai', 21), ('Sarala', 28), ('Suman', 29)]\n", + "entry_point": "sort_tuple" + }, + { + "task_id": "HumanEval\\/840", + "prompt": "def Check_Solution(a: int, b: int, c: int) -> str:\n \"\"\" Check whether the roots of a quadratic equation are numerically equal but opposite in sign or not.\n >>> Check_Solution(2, 0, -1)\n 'Yes'\n >>> Check_Solution(1, -5, 6)\n 'No'\n >>> Check_Solution(2, 0, 2)\n 'Yes'\n \"\"\"\n", + "canonical_solution": " if b == 0:\n return \"Yes\"\n else:\n return \"No\"\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(2, 0, -1) == 'Yes'\n assert candidate(1, -5, 6) == 'No'\n assert candidate(2, 0, 2) == 'Yes'\n", + "entry_point": "Check_Solution" + }, + { + "task_id": "HumanEval\\/841", + "prompt": "def get_inv_count(arr, n):\n \"\"\" Count the number of inversions in the given array\n >>> get_inv_count([1, 20, 6, 4, 5], 5)\n 5\n >>> get_inv_count([8, 4, 2, 1], 4)\n 6\n >>> get_inv_count([3, 1, 2], 3)\n 2\n \"\"\"\n", + "canonical_solution": " inv_count = 0\n for i in range(n):\n for j in range(i + 1, n):\n if (arr[i] > arr[j]):\n inv_count += 1\n return inv_count\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 20, 6, 4, 5], 5) == 5\n assert candidate([8, 4, 2, 1], 4) == 6\n assert candidate([3, 1, 2], 3) == 2\n", + "entry_point": "get_inv_count" + }, + { + "task_id": "842", + "prompt": "def get_odd_occurence(arr, arr_size):\n \"\"\"Find the number which occurs for odd number of times in the given array.\n >>> get_odd_occurence([2, 3, 5, 4, 5, 2, 4, 3, 5, 2, 4, 4, 2], 13)\n 5\n >>> get_odd_occurence([1, 2, 3, 2, 3, 1, 3], 7)\n 3\n >>> get_odd_occurence([5, 7, 2, 7, 5, 2, 5], 7)\n 5\n \"\"\"\n", + "canonical_solution": " for i in range(0, arr_size):\n count = 0\n for j in range(0, arr_size):\n if arr[i] == arr[j]:\n count += 1\n if (count % 2 != 0):\n return arr[i]\n return -1\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([2, 3, 5, 4, 5, 2, 4, 3, 5, 2, 4, 4, 2], 13) == 5\n assert candidate([1, 2, 3, 2, 3, 1, 3], 7) == 3\n assert candidate([5, 7, 2, 7, 5, 2, 5], 7) == 5\n", + "entry_point": "get_odd_occurence" + }, + { + "task_id": "HumanEval\\/843", + "prompt": "import heapq\n\n\ndef nth_super_ugly_number(n: int, primes: List[int]) -> int:\n \"\"\" Write a function to find the nth super ugly number from a given prime list of size k using heap queue algorithm.\n >>> nth_super_ugly_number(12, [2, 7, 13, 19])\n 32\n >>> nth_super_ugly_number(10, [2, 7, 13, 19])\n 26\n >>> nth_super_ugly_number(100, [2, 7, 13, 19])\n 5408\n \"\"\"\n", + "canonical_solution": " uglies = [1]\n def gen(prime):\n for ugly in uglies:\n yield ugly * prime\n merged = heapq.merge(*map(gen, primes))\n while len(uglies) < n:\n ugly = next(merged)\n if ugly != uglies[-1]:\n uglies.append(ugly)\n return uglies[-1]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(12, [2, 7, 13, 19]) == 32\n assert candidate(10, [2, 7, 13, 19]) == 26\n assert candidate(100, [2, 7, 13, 19]) == 5408\n", + "entry_point": "nth_super_ugly_number" + }, + { + "task_id": "HumanEval\\/844", + "prompt": "def get_Number(n: int, k: int) -> int:\n \"\"\" Find the k-th element in an array containing odd elements first and then even elements.\n >>> get_Number(8, 5)\n 2\n >>> get_Number(7, 2)\n 3\n >>> get_Number(5, 2)\n 3\n \"\"\"\n", + "canonical_solution": " arr = [0] * n\n i = 0\n odd = 1\n while odd <= n:\n arr[i] = odd\n i += 1\n odd += 2\n even = 2\n while even <= n:\n arr[i] = even\n i += 1\n even += 2\n return arr[k - 1]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(8, 5) == 2\n assert candidate(7, 2) == 3\n assert candidate(5, 2) == 3\n", + "entry_point": "get_Number" + }, + { + "task_id": "HumanEval\\/845", + "prompt": "import math\n\ndef find_Digits(n: int) -> int:\n \"\"\" Calculate the number of digits in the factorial of a given number n.\n >>> find_Digits(7)\n 4\n >>> find_Digits(5)\n 3\n >>> find_Digits(4)\n 2\n \"\"\"\n", + "canonical_solution": " if n < 0:\n return 0\n if n <= 1:\n return 1\n x = (n * math.log10(n / math.e) + math.log10(2 * math.pi * n) / 2.0)\n return math.floor(x) + 1\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(7) == 4\n assert candidate(5) == 3\n assert candidate(4) == 2\n", + "entry_point": "find_Digits" + }, + { + "task_id": "HumanEval\\/846", + "prompt": "def find_platform(arr, dep, n):\n \"\"\"Find the minimum number of platforms required for a railway/bus station.\n >>> find_platform([900, 940, 950, 1100, 1500, 1800], [910, 1200, 1120, 1130, 1900, 2000], 6)\n 3\n >>> find_platform([100, 200, 300, 400], [700, 800, 900, 1000], 4)\n 4\n >>> find_platform([5, 6, 7, 8], [4, 3, 2, 1], 4)\n 1\n \"\"\"\n", + "canonical_solution": " arr.sort()\n dep.sort()\n plat_needed = 1\n result = 1\n i = 1\n j = 0\n while (i < n and j < n):\n if (arr[i] <= dep[j]):\n plat_needed += 1\n i += 1\n elif (arr[i] > dep[j]):\n plat_needed -= 1\n j += 1\n if (plat_needed > result):\n result = plat_needed\n return result\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([900, 940, 950, 1100, 1500, 1800], [910, 1200, 1120, 1130, 1900, 2000], 6) == 3\n assert candidate([100, 200, 300, 400], [700, 800, 900, 1000], 4) == 4\n assert candidate([5, 6, 7, 8], [4, 3, 2, 1], 4) == 1\n", + "entry_point": "find_platform" + }, + { + "task_id": "HumanEval\\/847", + "prompt": "def lcopy(xs):\n \"\"\" Copy a list from a singleton tuple\n >>> lcopy([1, 2, 3])\n [1, 2, 3]\n >>> lcopy([4, 8, 2, 10, 15, 18])\n [4, 8, 2, 10, 15, 18]\n \"\"\"\n", + "canonical_solution": " return xs[:]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 2, 3]) == [1, 2, 3]\n assert candidate([4, 8, 2, 10, 15, 18]) == [4, 8, 2, 10, 15, 18]\n assert candidate([4, 5, 6]) == [4, 5, 6]\n", + "entry_point": "lcopy" + }, + { + "task_id": "HumanEval\\/848", + "prompt": "def area_trapezium(base1: float, base2: float, height: float) -> float:\n \"\"\" Calculate the area of a trapezium given the lengths of the two bases and the height.\n >>> area_trapezium(6, 9, 4)\n 30.0\n >>> area_trapezium(10, 20, 30)\n 450.0\n >>> area_trapezium(15, 25, 35)\n 700.0\n \"\"\"\n", + "canonical_solution": " return 0.5 * (base1 + base2) * height\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(6, 9, 4) == 30.0\n assert candidate(10, 20, 30) == 450.0\n assert candidate(15, 25, 35) == 700.0\n", + "entry_point": "area_trapezium" + }, + { + "task_id": "HumanEval\\/849", + "prompt": "def Sum(N: int) -> int:\n \"\"\" Find the sum of all prime divisors of a given number N.\n >>> Sum(60)\n 10\n >>> Sum(39)\n 16\n >>> Sum(40)\n 7\n \"\"\"\n", + "canonical_solution": " SumOfPrimeDivisors = [0]*(N + 1)\n for i in range(2, N + 1):\n if SumOfPrimeDivisors[i] == 0:\n for j in range(i, N + 1, i):\n SumOfPrimeDivisors[j] += i\n return SumOfPrimeDivisors[N]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(60) == 10\n assert candidate(39) == 16\n assert candidate(40) == 7\n", + "entry_point": "Sum" + }, + { + "task_id": "HumanEval\\/850", + "prompt": "def is_triangleexists(a: int, b: int, c: int) -> bool:\n \"\"\" Check if a triangle of positive area is possible with the given angles.\n >>> is_triangleexists(50, 60, 70)\n True\n >>> is_triangleexists(90, 45, 45)\n True\n >>> is_triangleexists(150, 30, 70)\n False\n \"\"\"\n", + "canonical_solution": " if a != 0 and b != 0 and c != 0 and (a + b + c) == 180:\n if (a + b) >= c or (b + c) >= a or (a + c) >= b:\n return True\n else:\n return False\n else:\n return False\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(50, 60, 70) == True\n assert candidate(90, 45, 45) == True\n assert candidate(150, 30, 70) == False\n", + "entry_point": "is_triangleexists" + }, + { + "task_id": "HumanEval\\/851", + "prompt": "def Sum_of_Inverse_Divisors(N: int, Sum: float) -> float:\n \"\"\" Calculate the sum of inverse of divisors.\n >>> Sum_of_Inverse_Divisors(6, 12)\n 2.0\n >>> Sum_of_Inverse_Divisors(9, 13)\n 1.44\n >>> Sum_of_Inverse_Divisors(1, 4)\n 4.0\n \"\"\"\n", + "canonical_solution": " ans = float(Sum) * 1.0 / float(N)\n return round(ans, 2)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(6, 12) == 2.0\n assert candidate(9, 13) == 1.44\n assert candidate(1, 4) == 4.0\n", + "entry_point": "Sum_of_Inverse_Divisors" + }, + { + "task_id": "HumanEval\\/852", + "prompt": "from typing import List\n\n\ndef remove_negs(num_list: List[int]) -> List[int]:\n \"\"\" Remove negative numbers from a list\n >>> remove_negs([1,-2,3,-4])\n [1, 3]\n >>> remove_negs([1,2,3,-4])\n [1, 2, 3]\n >>> remove_negs([4,5,-6,7,-8])\n [4, 5, 7]\n \"\"\"\n", + "canonical_solution": " return [item for item in num_list if item >= 0]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1,-2,3,-4]) == [1, 3]\n assert candidate([1,2,3,-4]) == [1, 2, 3]\n assert candidate([4,5,-6,7,-8]) == [4, 5, 7]\n", + "entry_point": "remove_negs" + }, + { + "task_id": "HumanEval\\/853", + "prompt": "import math\n\ndef sum_of_odd_Factors(n: int) -> int:\n \"\"\" Write a python function to find sum of odd factors of a number.\n >>> sum_of_odd_Factors(30)\n 24\n >>> sum_of_odd_Factors(18)\n 13\n >>> sum_of_odd_Factors(2)\n 1\n \"\"\"\n", + "canonical_solution": " res = 1\n while n % 2 == 0:\n n = n // 2\n for i in range(3, int(math.sqrt(n) + 1)):\n count = 0\n curr_sum = 1\n curr_term = 1\n while n % i == 0:\n count += 1\n n = n // i\n curr_term *= i\n curr_sum += curr_term\n res *= curr_sum\n if n >= 2:\n res *= (1 + n)\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(30) == 24\n assert candidate(18) == 13\n assert candidate(2) == 1\n", + "entry_point": "sum_of_odd_Factors" + }, + { + "task_id": "HumanEval\\/854", + "prompt": "import heapq as hq\nfrom typing import List\n\n\ndef raw_heap(rawheap: List[int]) -> List[int]:\n \"\"\" Convert an arbitrary list into a heap using heap queue algorithm.\n >>> raw_heap([25, 44, 68, 21, 39, 23, 89])\n [21, 25, 23, 44, 39, 68, 89]\n >>> raw_heap([25, 35, 22, 85, 14, 65, 75, 25, 58])\n [14, 25, 22, 25, 35, 65, 75, 85, 58]\n >>> raw_heap([4, 5, 6, 2])\n [2, 4, 6, 5]\n \"\"\"\n", + "canonical_solution": " hq.heapify(rawheap)\n return rawheap\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([25, 44, 68, 21, 39, 23, 89]) == [21, 25, 23, 44, 39, 68, 89]\n assert candidate([25, 35, 22, 85, 14, 65, 75, 25, 58]) == [14, 25, 22, 25, 35, 65, 75, 85, 58]\n assert candidate([4, 5, 6, 2]) == [2, 4, 6, 5]\n", + "entry_point": "raw_heap" + }, + { + "task_id": "HumanEval\\/855", + "prompt": "def check_Even_Parity(x: int) -> bool:\n \"\"\" Check for even parity of a given number.\n >>> check_Even_Parity(10)\n True\n >>> check_Even_Parity(11)\n False\n >>> check_Even_Parity(18)\n True\n \"\"\"\n", + "canonical_solution": " parity = 0\n while (x != 0):\n x = x & (x - 1)\n parity += 1\n return parity % 2 == 0\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(10) == True\n assert candidate(11) == False\n assert candidate(18) == True\n", + "entry_point": "check_Even_Parity" + }, + { + "task_id": "HumanEval\\/856", + "prompt": "def find_Min_Swaps(arr: list, n: int) -> int:\n \"\"\" Write a python function to find minimum adjacent swaps required to sort binary array.\n >>> find_Min_Swaps([1,0,1,0], 4)\n 3\n >>> find_Min_Swaps([0,1,0], 3)\n 1\n >>> find_Min_Swaps([0,0,1,1,0], 5)\n 2\n \"\"\"\n", + "canonical_solution": " noOfZeroes = [0] * n\n count = 0\n noOfZeroes[n - 1] = 1 - arr[n - 1]\n for i in range(n-2,-1,-1):\n noOfZeroes[i] = noOfZeroes[i + 1]\n if arr[i] == 0:\n noOfZeroes[i] += 1\n for i in range(n):\n if arr[i] == 1:\n count += noOfZeroes[i]\n return count\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1,0,1,0], 4) == 3\n assert candidate([0,1,0], 3) == 1\n assert candidate([0,0,1,1,0], 5) == 2\n", + "entry_point": "find_Min_Swaps" + }, + { + "task_id": "HumanEval\\/857", + "prompt": "from typing import List\n\n\ndef listify_list(list1: List[str]) -> List[List[str]]:\n \"\"\" List out the list of given strings individually using map function.\n >>> listify_list(['Red', 'Blue', 'Black', 'White', 'Pink'])\n [['R', 'e', 'd'], ['B', 'l', 'u', 'e'], ['B', 'l', 'a', 'c', 'k'], ['W', 'h', 'i', 't', 'e'], ['P', 'i', 'n', 'k']]\n >>> listify_list(['python'])\n [['p', 'y', 't', 'h', 'o', 'n']]\n \"\"\"\n", + "canonical_solution": " return list(map(list, list1))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(['Red', 'Blue', 'Black', 'White', 'Pink']) == [['R', 'e', 'd'], ['B', 'l', 'u', 'e'], ['B', 'l', 'a', 'c', 'k'], ['W', 'h', 'i', 't', 'e'], ['P', 'i', 'n', 'k']]\n assert candidate(['python']) == [['p', 'y', 't', 'h', 'o', 'n']]\n assert candidate([' red ', 'green',' black', 'blue ',' orange', 'brown']) == [[' ', 'r', 'e', 'd', ' '], ['g', 'r', 'e', 'e', 'n'], [' ', 'b', 'l', 'a', 'c', 'k'], ['b', 'l', 'u', 'e', ' '], [' ', 'o', 'r', 'a', 'n', 'g', 'e'], ['b', 'r', 'o', 'w', 'n']]\n", + "entry_point": "listify_list" + }, + { + "task_id": "HumanEval\\/858", + "prompt": "def count_list(input_list):\n \"\"\" Count number of lists in a given list of lists and square the count.\n >>> count_list([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])\n 25\n >>> count_list([[1, 3], [5, 7], [9, 11], [13, 15, 17]])\n 16\n >>> count_list([[2, 4], [[6,8], [4,5,8]], [10, 12, 14]])\n 9\n \"\"\"\n", + "canonical_solution": " return (len(input_list))**2\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]]) == 25\n assert candidate([[1, 3], [5, 7], [9, 11], [13, 15, 17]]) == 16\n assert candidate([[2, 4], [[6,8], [4,5,8]], [10, 12, 14]]) == 9\n", + "entry_point": "count_list" + }, + { + "task_id": "HumanEval\\/859", + "prompt": "from typing import List\nfrom itertools import combinations\n\n\ndef sub_lists(my_list: List) -> List[List]:\n \"\"\" Generate all sublists of a given list\n >>> sub_lists([10, 20, 30, 40])\n [[], [10], [20], [30], [40], [10, 20], [10, 30], [10, 40], [20, 30], [20, 40], [30, 40], [10, 20, 30], [10, 20, 40], [10, 30, 40], [20, 30, 40], [10, 20, 30, 40]]\n >>> sub_lists(['X', 'Y', 'Z'])\n [[], ['X'], ['Y'], ['Z'], ['X', 'Y'], ['X', 'Z'], ['Y', 'Z'], ['X', 'Y', 'Z']]\n >>> sub_lists([1, 2, 3])\n [[], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]]\n \"\"\"\n", + "canonical_solution": " subs = []\n for i in range(0, len(my_list)+1):\n temp = [list(x) for x in combinations(my_list, i)]\n if len(temp) > 0:\n subs.extend(temp)\n return subs\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([10, 20, 30, 40]) == [[], [10], [20], [30], [40], [10, 20], [10, 30], [10, 40], [20, 30], [20, 40], [30, 40], [10, 20, 30], [10, 20, 40], [10, 30, 40], [20, 30, 40], [10, 20, 30, 40]]\n assert candidate(['X', 'Y', 'Z']) == [[], ['X'], ['Y'], ['Z'], ['X', 'Y'], ['X', 'Z'], ['Y', 'Z'], ['X', 'Y', 'Z']]\n assert candidate([1, 2, 3]) == [[], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]]\n", + "entry_point": "sub_lists" + }, + { + "task_id": "HumanEval\\/860", + "prompt": "import re\n\n\ndef check_alphanumeric(string: str) -> str:\n \"\"\" Check whether the given string is ending with only alphanumeric characters or not using regex.\n >>> check_alphanumeric(\"dawood@\")\n 'Discard'\n >>> check_alphanumeric(\"skdmsam326\")\n 'Accept'\n >>> check_alphanumeric(\"cooltricks@\")\n 'Discard'\n \"\"\"\n", + "canonical_solution": " regex = '[a-zA-Z0-9]$'\n if re.search(regex, string):\n return \"Accept\"\n else:\n return \"Discard\"\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"dawood@\") == 'Discard'\n assert candidate(\"skdmsam326\") == 'Accept'\n assert candidate(\"cooltricks@\") == 'Discard'\n", + "entry_point": "check_alphanumeric" + }, + { + "task_id": "861", + "prompt": "from collections import Counter\nfrom typing import List\n\n\ndef anagram_lambda(texts: List[str], str: str) -> List[str]:\n \"\"\" Find all anagrams of a string in a given list of strings using lambda function.\n >>> anagram_lambda([\"bcda\", \"abce\", \"cbda\", \"cbea\", \"adcb\"], \"abcd\")\n ['bcda', 'cbda', 'adcb']\n >>> anagram_lambda([\"recitals\", \"python\"], \"articles\")\n [\"recitals\"]\n >>> anagram_lambda([\"keep\", \"abcdef\", \"xyz\"], \"peek\")\n [\"keep\"]\n \"\"\"\n", + "canonical_solution": " result = list(filter(lambda x: (Counter(str) == Counter(x)), texts))\n return result\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([\"bcda\", \"abce\", \"cbda\", \"cbea\", \"adcb\"], \"abcd\") == ['bcda', 'cbda', 'adcb']\n assert candidate([\"recitals\", \"python\"], \"articles\") == [\"recitals\"]\n assert candidate([\"keep\", \"abcdef\", \"xyz\"], \"peek\") == [\"keep\"]\n", + "entry_point": "anagram_lambda" + }, + { + "task_id": "HumanEval\\/862", + "prompt": "from collections import Counter\nimport re\n\ndef n_common_words(text: str, n: int) -> list:\n \"\"\" Write a function to find the occurrences of n most common words in a given text.\n >>> n_common_words(\"python is a programming language\", 1)\n [('python', 1)]\n >>> n_common_words(\"python is a programming language\", 5)\n [('python', 1), ('is', 1), ('a', 1), ('programming', 1), ('language', 1)]\n \"\"\"\n", + "canonical_solution": " words = re.findall('\\w+', text)\n n_common_words = Counter(words).most_common(n)\n return list(n_common_words)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"python is a programming language\", 1) == [('python', 1)]\n assert candidate(\"python is a programming language\", 5) == [('python', 1), ('is', 1), ('a', 1), ('programming', 1), ('language', 1)]\n", + "entry_point": "n_common_words" + }, + { + "task_id": "HumanEval\\/863", + "prompt": "def find_longest_conseq_subseq(arr: List[int], n: int) -> int:\n \"\"\"Find the length of the longest sub-sequence such that elements in the subsequences are consecutive integers.\n >>> find_longest_conseq_subseq([1, 2, 2, 3], 4)\n 3\n >>> find_longest_conseq_subseq([1, 9, 3, 10, 4, 20, 2], 7)\n 4\n >>> find_longest_conseq_subseq([36, 41, 56, 35, 44, 33, 34, 92, 43, 32, 42], 11)\n 5\n \"\"\"\n", + "canonical_solution": " ans = 0\n count = 0\n arr.sort()\n v = []\n v.append(arr[0])\n for i in range(1, n):\n if (arr[i] != arr[i - 1]):\n v.append(arr[i])\n for i in range(len(v)):\n if (i > 0 and v[i] == v[i - 1] + 1):\n count += 1\n else:\n count = 1\n ans = max(ans, count)\n return ans\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 2, 2, 3], 4) == 3\n assert candidate([1, 9, 3, 10, 4, 20, 2], 7) == 4\n assert candidate([36, 41, 56, 35, 44, 33, 34, 92, 43, 32, 42], 11) == 5\n", + "entry_point": "find_longest_conseq_subseq" + }, + { + "task_id": "HumanEval\\/864", + "prompt": "from typing import List\n\n\ndef palindrome_lambda(texts: List[str]) -> List[str]:\n \"\"\" Find palindromes in a given list of strings using lambda function.\n >>> palindrome_lambda([\"php\", \"res\", \"Python\", \"abcd\", \"Java\", \"aaa\"])\n ['php', 'aaa']\n >>> palindrome_lambda([\"abcd\", \"Python\", \"abba\", \"aba\"])\n ['abba', 'aba']\n \"\"\"\n", + "canonical_solution": " return list(filter(lambda x: (x == \"\".join(reversed(x))), texts))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([\"php\", \"res\", \"Python\", \"abcd\", \"Java\", \"aaa\"]) == ['php', 'aaa']\n assert candidate([\"abcd\", \"Python\", \"abba\", \"aba\"]) == ['abba', 'aba']\n assert candidate([\"abcd\", \"abbccbba\", \"abba\", \"aba\"]) == ['abbccbba', 'abba', 'aba']\n", + "entry_point": "palindrome_lambda" + }, + { + "task_id": "HumanEval\\/865", + "prompt": "from typing import List\n\n\ndef ntimes_list(nums: List[int], n: int) -> List[int]:\n \"\"\" Multiply each element in the list by n using map function\n >>> ntimes_list([1, 2, 3, 4, 5, 6, 7], 3)\n [3, 6, 9, 12, 15, 18, 21]\n >>> ntimes_list([1, 2, 3, 4, 5, 6, 7], 4)\n [4, 8, 12, 16, 20, 24, 28]\n \"\"\"\n", + "canonical_solution": " result = map(lambda x: n * x, nums)\n return list(result)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 2, 3, 4, 5, 6, 7], 3) == [3, 6, 9, 12, 15, 18, 21]\n assert candidate([1, 2, 3, 4, 5, 6, 7], 4) == [4, 8, 12, 16, 20, 24, 28]\n assert candidate([1, 2, 3, 4, 5, 6, 7], 10) == [10, 20, 30, 40, 50, 60, 70]\n", + "entry_point": "ntimes_list" + }, + { + "task_id": "HumanEval\\/866", + "prompt": "def check_monthnumb(monthname2: str) -> bool:\n \"\"\" Check whether the given month name contains 31 days or not.\n >>> check_monthnumb(\"February\")\n False\n >>> check_monthnumb(\"January\")\n True\n >>> check_monthnumb(\"March\")\n True\n \"\"\"\n", + "canonical_solution": " if monthname2 in [\"January\", \"March\", \"May\", \"July\", \"August\", \"October\", \"December\"]:\n return True\n else:\n return False\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"February\") == False\n assert candidate(\"January\") == True\n assert candidate(\"March\") == True\n", + "entry_point": "check_monthnumb" + }, + { + "task_id": "HumanEval\\/867", + "prompt": "def min_Num(arr: list, n: int) -> int:\n \"\"\" Add a minimum number such that the sum of array becomes even.\n >>> min_Num([1,2,3,4,5,6,7,8,9],9)\n 1\n >>> min_Num([1,2,3,4,5,6,7,8],8)\n 2\n >>> min_Num([1,2,3],3)\n 2\n \"\"\"\n", + "canonical_solution": " odd = 0\n for i in range(n):\n if (arr[i] % 2):\n odd += 1\n if (odd % 2):\n return 1\n return 2\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1,2,3,4,5,6,7,8,9],9) == 1\n assert candidate([1,2,3,4,5,6,7,8],8) == 2\n assert candidate([1,2,3],3) == 2\n", + "entry_point": "min_Num" + }, + { + "task_id": "HumanEval\\/868", + "prompt": "def length_Of_Last_Word(a: str) -> int:\n \"\"\" Find the length of the last word in a given string.\n >>> length_Of_Last_Word(\"python language\")\n 8\n >>> length_Of_Last_Word(\"PHP\")\n 3\n >>> length_Of_Last_Word(\"\")\n 0\n \"\"\"\n", + "canonical_solution": " l = 0\n x = a.strip()\n for i in range(len(x)):\n if x[i] == \" \":\n l = 0\n else:\n l += 1\n return l\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"python language\") == 8\n assert candidate(\"PHP\") == 3\n assert candidate(\"\") == 0\n", + "entry_point": "length_Of_Last_Word" + }, + { + "task_id": "869", + "prompt": "from typing import List\n\n\ndef remove_list_range(list1: List[List[int]], leftrange: int, rigthrange: int) -> List[List[int]]:\n \"\"\" Remove sublists from a given list of lists, which are outside a given range.\n >>> remove_list_range([[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7], [9, 11], [13, 14, 15, 17]], 13, 17)\n [[13, 14, 15, 17]]\n >>> remove_list_range([[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7], [9, 11], [13, 14, 15, 17]], 1, 3)\n [[2], [1, 2, 3]]\n >>> remove_list_range([[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7], [9, 11], [13, 14, 15, 17]], 0, 7)\n [[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7]]\n \"\"\"\n", + "canonical_solution": " result = [i for i in list1 if (min(i) >= leftrange and max(i) <= rigthrange)]\n return result\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7], [9, 11], [13, 14, 15, 17]], 13, 17) == [[13, 14, 15, 17]]\n assert candidate([[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7], [9, 11], [13, 14, 15, 17]], 1, 3) == [[2], [1, 2, 3]]\n assert candidate([[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7], [9, 11], [13, 14, 15, 17]], 0, 7) == [[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7]]\n", + "entry_point": "remove_list_range" + }, + { + "task_id": "HumanEval\\/870", + "prompt": "from typing import List\n\n\ndef sum_positivenum(nums: List[int]) -> int:\n \"\"\" Calculate the sum of the positive numbers of a given list of numbers using lambda function.\n >>> sum_positivenum([2, 4, -6, -9, 11, -12, 14, -5, 17])\n 48\n >>> sum_positivenum([10,15,-14,13,-18,12,-20])\n 50\n >>> sum_positivenum([19, -65, 57, 39, 152,-639, 121, 44, 90, -190])\n 522\n \"\"\"\n", + "canonical_solution": " return sum(filter(lambda x: x > 0, nums))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([2, 4, -6, -9, 11, -12, 14, -5, 17]) == 48\n assert candidate([10, 15, -14, 13, -18, 12, -20]) == 50\n assert candidate([19, -65, 57, 39, 152, -639, 121, 44, 90, -190]) == 522\n", + "entry_point": "sum_positivenum" + }, + { + "task_id": "HumanEval\\/871", + "prompt": "def are_Rotations(string1: str, string2: str) -> bool:\n \"\"\" Check whether the given strings are rotations of each other\n >>> are_Rotations('abc', 'cba')\n False\n >>> are_Rotations('abcd', 'cdba')\n False\n >>> are_Rotations('abacd', 'cdaba')\n True\n \"\"\"\n", + "canonical_solution": " size1 = len(string1)\n size2 = len(string2)\n if size1 != size2:\n return False\n temp = string1 + string1\n return string2 in temp\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('abc', 'cba') == False\n assert candidate('abcd', 'cdba') == False\n assert candidate('abacd', 'cdaba') == True\n", + "entry_point": "are_Rotations" + }, + { + "task_id": "HumanEval\\/872", + "prompt": "def check_subset(list1, list2):\n \"\"\" Check if a nested list is a subset of another nested list.\n >>> check_subset([[1, 3], [5, 7], [9, 11], [13, 15, 17]], [[1, 3], [13, 15, 17]])\n True\n >>> check_subset([[1, 2], [2, 3], [3, 4], [5, 6]], [[3, 4], [5, 6]])\n True\n >>> check_subset([[[1, 2], [2, 3]], [[3, 4], [5, 7]]], [[[3, 4], [5, 6]]])\n False\n \"\"\"\n", + "canonical_solution": " return all(map(list1.__contains__, list2))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([[1, 3], [5, 7], [9, 11], [13, 15, 17]], [[1, 3], [13, 15, 17]]) == True\n assert candidate([[1, 2], [2, 3], [3, 4], [5, 6]], [[3, 4], [5, 6]]) == True\n assert candidate([[[1, 2], [2, 3]], [[3, 4], [5, 7]]], [[[3, 4], [5, 6]]]) == False\n", + "entry_point": "check_subset" + }, + { + "task_id": "HumanEval\\/873", + "prompt": "def fibonacci(n: int) -> int:\n \"\"\"Write a function to solve the fibonacci sequence using recursion.\n >>> fibonacci(7)\n 13\n >>> fibonacci(8)\n 21\n >>> fibonacci(9)\n 34\n \"\"\"\n", + "canonical_solution": " if n == 1 or n == 2:\n return 1\n else:\n return fibonacci(n - 1) + fibonacci(n - 2)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(7) == 13\n assert candidate(8) == 21\n assert candidate(9) == 34\n", + "entry_point": "fibonacci" + }, + { + "task_id": "HumanEval\\/874", + "prompt": "def check_Concat(str1: str, str2: str) -> bool:\n \"\"\" Check if the string str1 is a concatenation of the string str2\n >>> check_Concat(\"abcabcabc\", \"abc\")\n True\n >>> check_Concat(\"abcab\", \"abc\")\n False\n >>> check_Concat(\"aba\", \"ab\")\n False\n \"\"\"\n", + "canonical_solution": " N = len(str1)\n M = len(str2)\n if (N % M != 0):\n return False\n for i in range(N):\n if (str1[i] != str2[i % M]):\n return False\n return True\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"abcabcabc\", \"abc\") == True\n assert candidate(\"abcab\", \"abc\") == False\n assert candidate(\"aba\", \"ab\") == False\n", + "entry_point": "check_Concat" + }, + { + "task_id": "HumanEval\\/875", + "prompt": "from typing import List, Tuple\n\n\ndef min_difference(test_list: List[Tuple[int, int]]) -> int:\n \"\"\" Write a function to find the minimum difference in the tuple pairs of given tuples.\n >>> min_difference([(3, 5), (1, 7), (10, 3), (1, 2)])\n 1\n >>> min_difference([(4, 6), (12, 8), (11, 4), (2, 13)])\n 2\n >>> min_difference([(5, 17), (3, 9), (12, 5), (3, 24)])\n 6\n \"\"\"\n", + "canonical_solution": " temp = [abs(b - a) for a, b in test_list]\n res = min(temp)\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([(3, 5), (1, 7), (10, 3), (1, 2)]) == 1\n assert candidate([(4, 6), (12, 8), (11, 4), (2, 13)]) == 2\n assert candidate([(5, 17), (3, 9), (12, 5), (3, 24)]) == 6\n", + "entry_point": "min_difference" + }, + { + "task_id": "HumanEval\\/876", + "prompt": "def lcm(x: int, y: int) -> int:\n \"\"\"Find the least common multiple of two positive integers.\n >>> lcm(4, 6)\n 12\n >>> lcm(15, 17)\n 255\n >>> lcm(2, 6)\n 6\n \"\"\"\n", + "canonical_solution": " if x > y:\n z = x\n else:\n z = y\n while(True):\n if((z % x == 0) and (z % y == 0)):\n lcm = z\n break\n z += 1\n return lcm\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(4, 6) == 12\n assert candidate(15, 17) == 255\n assert candidate(2, 6) == 6\n", + "entry_point": "lcm" + }, + { + "task_id": "HumanEval\\/877", + "prompt": "def sort_String(str: str) -> str:\n \"\"\" Sort the given string in alphabetical order.\n >>> sort_String(\"cba\")\n 'abc'\n >>> sort_String(\"data\")\n 'aadt'\n >>> sort_String(\"zxy\")\n 'xyz'\n \"\"\"\n", + "canonical_solution": " return ''.join(sorted(str))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"cba\") == \"abc\"\n assert candidate(\"data\") == \"aadt\"\n assert candidate(\"zxy\") == \"xyz\"\n", + "entry_point": "sort_String" + }, + { + "task_id": "HumanEval\\/878", + "prompt": "def check_tuples(test_tuple: tuple, K: list) -> bool:\n \"\"\" Check if the given tuple contains only elements from the list K\n >>> check_tuples((3, 5, 6, 5, 3, 6), [3, 6, 5])\n True\n >>> check_tuples((4, 5, 6, 4, 6, 5), [4, 5, 6])\n True\n >>> check_tuples((9, 8, 7, 6, 8, 9), [9, 8, 1])\n False\n \"\"\"\n", + "canonical_solution": " return all(ele in K for ele in test_tuple)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate((3, 5, 6, 5, 3, 6), [3, 6, 5]) == True\n assert candidate((4, 5, 6, 4, 6, 5), [4, 5, 6]) == True\n assert candidate((9, 8, 7, 6, 8, 9), [9, 8, 1]) == False\n", + "entry_point": "check_tuples" + }, + { + "task_id": "HumanEval\\/879", + "prompt": "import re\n\ndef text_match(text: str) -> str:\n \"\"\" Write a function that matches a string that has an 'a' followed by anything, ending in 'b' by using regex.\n >>> text_match(\"aabbbbd\")\n 'Not matched!'\n >>> text_match(\"aabAbbbc\")\n 'Not matched!'\n >>> text_match(\"accddbbjjjb\")\n 'Found a match!'\n \"\"\"\n", + "canonical_solution": " patterns = 'a.*?b$'\n if re.search(patterns, text):\n return 'Found a match!'\n else:\n return 'Not matched!'\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"aabbbbd\") == 'Not matched!'\n assert candidate(\"aabAbbbc\") == 'Not matched!'\n assert candidate(\"accddbbjjjb\") == 'Found a match!'\n", + "entry_point": "text_match" + }, + { + "task_id": "HumanEval\\/880", + "prompt": "def Check_Solution(a: int, b: int, c: int) -> str:\n \"\"\"Find number of solutions in quadratic equation\n >>> Check_Solution(2, 5, 2)\n '2 solutions'\n >>> Check_Solution(1, 1, 1)\n 'No solutions'\n >>> Check_Solution(1, 2, 1)\n '1 solution'\n \"\"\"\n", + "canonical_solution": " if ((b*b) - (4*a*c)) > 0:\n return \"2 solutions\"\n elif ((b*b) - (4*a*c)) == 0:\n return \"1 solution\"\n else:\n return \"No solutions\"\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(2, 5, 2) == '2 solutions'\n assert candidate(1, 1, 1) == 'No solutions'\n assert candidate(1, 2, 1) == '1 solution'\n", + "entry_point": "Check_Solution" + }, + { + "task_id": "HumanEval\\/881", + "prompt": "from typing import List\n\n\ndef sum_even_odd(list1: List[int]) -> int:\n \"\"\" Write a function to find the sum of first even and odd number of a given list.\n >>> sum_even_odd([1,3,5,7,4,1,6,8])\n 5\n >>> sum_even_odd([1,2,3,4,5,6,7,8,9,10])\n 3\n >>> sum_even_odd([1,5,7,9,10])\n 11\n \"\"\"\n", + "canonical_solution": " first_even = next((el for el in list1 if el%2==0),-1)\n first_odd = next((el for el in list1 if el%2!=0),-1)\n return (first_even+first_odd)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1,3,5,7,4,1,6,8]) == 5\n assert candidate([1,2,3,4,5,6,7,8,9,10]) == 3\n assert candidate([1,5,7,9,10]) == 11\n", + "entry_point": "sum_even_odd" + }, + { + "task_id": "HumanEval\\/882", + "prompt": "def parallelogram_perimeter(b: int, h: int) -> int:\n \"\"\" Calculate the perimeter of a parallelogram given base and height.\n >>> parallelogram_perimeter(10, 20)\n 60\n >>> parallelogram_perimeter(15, 20)\n 70\n >>> parallelogram_perimeter(8, 9)\n 34\n \"\"\"\n", + "canonical_solution": " return 2 * (b + h)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(10, 20) == 60\n assert candidate(15, 20) == 70\n assert candidate(8, 9) == 34\n", + "entry_point": "parallelogram_perimeter" + }, + { + "task_id": "HumanEval\\/883", + "prompt": "from typing import List\n\n\ndef div_of_nums(nums: List[int], m: int, n: int) -> List[int]:\n \"\"\" Find numbers divisible by m and n from a list of numbers using lambda function.\n >>> div_of_nums([19, 65, 57, 39, 152, 639, 121, 44, 90, 190], 2, 4)\n [152, 44]\n >>> div_of_nums([1, 2, 3, 5, 7, 8, 10], 2, 5)\n [10]\n >>> div_of_nums([10, 15, 14, 13, 18, 12, 20], 10, 5)\n [10, 20]\n \"\"\"\n", + "canonical_solution": " return list(filter(lambda x: (x % m == 0 and x % n == 0), nums))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([19, 65, 57, 39, 152, 639, 121, 44, 90, 190], 2, 4) == [152, 44]\n assert candidate([1, 2, 3, 5, 7, 8, 10], 2, 5) == [10]\n assert candidate([10, 15, 14, 13, 18, 12, 20], 10, 5) == [10, 20]\n", + "entry_point": "div_of_nums" + }, + { + "task_id": "HumanEval\\/884", + "prompt": "def all_Bits_Set_In_The_Given_Range(n: int, l: int, r: int) -> bool:\n \"\"\" Check whether all the bits are set within a given range.\n >>> all_Bits_Set_In_The_Given_Range(10, 2, 1)\n True\n >>> all_Bits_Set_In_The_Given_Range(5, 2, 4)\n False\n >>> all_Bits_Set_In_The_Given_Range(22, 2, 3)\n True\n \"\"\"\n", + "canonical_solution": " num = ((1 << r) - 1) ^ ((1 << (l - 1)) - 1)\n new_num = n & num\n if (num == new_num):\n return True\n return False\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(10, 2, 1) == True\n assert candidate(5, 2, 4) == False\n assert candidate(22, 2, 3) == True\n", + "entry_point": "all_Bits_Set_In_The_Given_Range" + }, + { + "task_id": "HumanEval\\/885", + "prompt": "def is_Isomorphic(str1: str, str2: str) -> bool:\n \"\"\" Check whether the two given strings are isomorphic to each other\n >>> is_Isomorphic(\"paper\", \"title\")\n True\n >>> is_Isomorphic(\"ab\", \"ba\")\n True\n >>> is_Isomorphic(\"ab\", \"aa\")\n False\n \"\"\"\n", + "canonical_solution": " dict_str1 = {}\n dict_str2 = {}\n for i, value in enumerate(str1):\n dict_str1[value] = dict_str1.get(value,[]) + [i]\n for j, value in enumerate(str2):\n dict_str2[value] = dict_str2.get(value,[]) + [j]\n if sorted(dict_str1.values()) == sorted(dict_str2.values()):\n return True\n else:\n return False\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"paper\", \"title\") == True\n assert candidate(\"ab\", \"ba\") == True\n assert candidate(\"ab\", \"aa\") == False\n", + "entry_point": "is_Isomorphic" + }, + { + "task_id": "HumanEval\\/886", + "prompt": "def sum_num(numbers: list) -> float:\n \"\"\" Calculate the average of a list of numbers\n >>> sum_num([8, 2, 3, 0, 7])\n 4.0\n >>> sum_num([-10, -20, -30])\n -20.0\n >>> sum_num([19, 15, 18])\n 17.333333333333332\n \"\"\"\n", + "canonical_solution": " total = 0\n for x in numbers:\n total += x\n return total / len(numbers)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([8, 2, 3, 0, 7]) == 4.0\n assert candidate([-10, -20, -30]) == -20.0\n assert candidate([19, 15, 18]) == 17.333333333333332\n", + "entry_point": "sum_num" + }, + { + "task_id": "HumanEval\\/887", + "prompt": "def is_odd(n: int) -> bool:\n \"\"\" Check whether the given number is odd using bitwise operator.\n >>> is_odd(5)\n True\n >>> is_odd(6)\n False\n >>> is_odd(7)\n True\n \"\"\"\n", + "canonical_solution": " return (n & 1) == 1\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(5) == True\n assert candidate(6) == False\n assert candidate(7) == True\n", + "entry_point": "is_odd" + }, + { + "task_id": "HumanEval\\/888", + "prompt": "def substract_elements(test_tup1, test_tup2):\n \"\"\" Subtract the elements of the given nested tuples.\n >>> substract_elements(((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3)))\n ((-5, -4), (1, -4), (1, 8), (-6, 7))\n \"\"\"\n", + "canonical_solution": " res = tuple(tuple(a - b for a, b in zip(tup1, tup2)) for tup1, tup2 in zip(test_tup1, test_tup2))\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))) == ((-5, -4), (1, -4), (1, 8), (-6, 7))\n assert candidate(((13, 4), (14, 6), (13, 10), (12, 11)), ((19, 8), (14, 10), (12, 2), (18, 4))) == ((-6, -4), (0, -4), (1, 8), (-6, 7))\n assert candidate(((19, 5), (18, 7), (19, 11), (17, 12)), ((12, 9), (17, 11), (13, 3), (19, 5))) == ((7, -4), (1, -4), (6, 8), (-2, 7))\n", + "entry_point": "substract_elements" + }, + { + "task_id": "HumanEval\\/889", + "prompt": "from typing import List\n\n\ndef reverse_list_lists(lists: List[List[int]]) -> List[List[int]]:\n \"\"\" Reverse each list in a given list of lists\n >>> reverse_list_lists([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]])\n [[4, 3, 2, 1], [8, 7, 6, 5], [12, 11, 10, 9], [16, 15, 14, 13]]\n >>> reverse_list_lists([[1,2],[2,3],[3,4]])\n [[2,1],[3,2],[4,3]]\n >>> reverse_list_lists([[10,20],[30,40]])\n [[20,10],[40,30]]\n \"\"\"\n", + "canonical_solution": " return [l[::-1] for l in lists]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == [[4, 3, 2, 1], [8, 7, 6, 5], [12, 11, 10, 9], [16, 15, 14, 13]]\n assert candidate([[1,2],[2,3],[3,4]]) == [[2,1],[3,2],[4,3]]\n assert candidate([[10,20],[30,40]]) == [[20,10],[40,30]]\n", + "entry_point": "reverse_list_lists" + }, + { + "task_id": "890", + "prompt": "def find_Extra(arr1, arr2, n):\n \"\"\"Find the index of an extra element present in one sorted array.\n >>> find_Extra([1,2,3,4],[1,2,3],3)\n 3\n >>> find_Extra([2,4,6,8,10],[2,4,6,8],4)\n 4\n >>> find_Extra([1,3,5,7,9,11],[1,3,5,7,9],5)\n 5\n \"\"\"\n", + "canonical_solution": " for i in range(0, n):\n if arr1[i] != arr2[i]:\n return i\n return n\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1,2,3,4],[1,2,3],3) == 3\n assert candidate([2,4,6,8,10],[2,4,6,8],4) == 4\n assert candidate([1,3,5,7,9,11],[1,3,5,7,9],5) == 5\n", + "entry_point": "find_Extra" + }, + { + "task_id": "HumanEval\\/891", + "prompt": "def same_Length(A: int, B: int) -> bool:\n \"\"\" Check whether the given two numbers have the same number of digits or not.\n >>> same_Length(12, 1)\n False\n >>> same_Length(2, 2)\n True\n >>> same_Length(10, 20)\n True\n \"\"\"\n", + "canonical_solution": " while (A > 0 and B > 0):\n A = A / 10\n B = B / 10\n if (A == 0 and B == 0):\n return True\n return False\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(12, 1) == False\n assert candidate(2, 2) == True\n assert candidate(10, 20) == True\n", + "entry_point": "same_Length" + }, + { + "task_id": "HumanEval\\/892", + "prompt": "import re\n\ndef remove_spaces(text: str) -> str:\n \"\"\" Remove multiple spaces in a string\n >>> remove_spaces('python program')\n 'python program'\n >>> remove_spaces('python programming language')\n 'python programming language'\n >>> remove_spaces('python program')\n 'python program'\n \"\"\"\n", + "canonical_solution": " return re.sub(' +', ' ', text)\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('python program') == 'python program'\n assert candidate('python programming language') == 'python programming language'\n assert candidate('python program') == 'python program'\n", + "entry_point": "remove_spaces" + }, + { + "task_id": "HumanEval\\/893", + "prompt": "from typing import List\n\n\ndef Extract(lst: List[List[int]]) -> List[int]:\n \"\"\" Get the last element of each sublist\n >>> Extract([[1, 2, 3], [4, 5], [6, 7, 8, 9]])\n [3, 5, 9]\n >>> Extract([['x', 'y', 'z'], ['m'], ['a', 'b'], ['u', 'v']])\n ['z', 'm', 'b', 'v']\n \"\"\"\n", + "canonical_solution": " return [item[-1] for item in lst]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([[1, 2, 3], [4, 5], [6, 7, 8, 9]]) == [3, 5, 9]\n assert candidate([['x', 'y', 'z'], ['m'], ['a', 'b'], ['u', 'v']]) == ['z', 'm', 'b', 'v']\n assert candidate([[1, 2, 3], [4, 5]]) == [3, 5]\n", + "entry_point": "Extract" + }, + { + "task_id": "HumanEval\\/894", + "prompt": "def float_to_tuple(test_str: str) -> tuple:\n \"\"\" Convert the given string of float type into a tuple.\n >>> float_to_tuple(\"1.2, 1.3, 2.3, 2.4, 6.5\")\n (1.2, 1.3, 2.3, 2.4, 6.5)\n >>> float_to_tuple(\"2.3, 2.4, 5.6, 5.4, 8.9\")\n (2.3, 2.4, 5.6, 5.4, 8.9)\n >>> float_to_tuple(\"0.3, 0.5, 7.8, 9.4\")\n (0.3, 0.5, 7.8, 9.4)\n \"\"\"\n", + "canonical_solution": " res = tuple(map(float, test_str.split(', ')))\n return res\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"1.2, 1.3, 2.3, 2.4, 6.5\") == (1.2, 1.3, 2.3, 2.4, 6.5)\n assert candidate(\"2.3, 2.4, 5.6, 5.4, 8.9\") == (2.3, 2.4, 5.6, 5.4, 8.9)\n assert candidate(\"0.3, 0.5, 7.8, 9.4\") == (0.3, 0.5, 7.8, 9.4)\n", + "entry_point": "float_to_tuple" + }, + { + "task_id": "HumanEval\\/895", + "prompt": "def max_sum_subseq(A):\n \"\"\"Write a function to find the maximum sum of subsequences of given array with no adjacent elements.\n >>> max_sum_subseq([1, 2, 9, 4, 5, 0, 4, 11, 6])\n 26\n >>> max_sum_subseq([1, 2, 9, 5, 6, 0, 5, 12, 7])\n 28\n >>> max_sum_subseq([1, 3, 10, 5, 6, 0, 6, 14, 21])\n 44\n \"\"\"\n n = len(A)\n if n == 1:\n return A[0]\n look_up = [None] * n\n look_up[0] = A[0]\n look_up[1] = max(A[0], A[1])\n for i in range(2, n):\n look_up[i] = max(look_up[i - 1], look_up[i - 2] + A[i])\n look_up[i] = max(look_up[i], A[i])\n return look_up[n - 1]\n", + "canonical_solution": " n = len(A)\n if n == 1:\n return A[0]\n look_up = [None] * n\n look_up[0] = A[0]\n look_up[1] = max(A[0], A[1])\n for i in range(2, n):\n look_up[i] = max(look_up[i - 1], look_up[i - 2] + A[i])\n look_up[i] = max(look_up[i], A[i])\n return look_up[n - 1]\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 2, 9, 4, 5, 0, 4, 11, 6]) == 26\n assert candidate([1, 2, 9, 5, 6, 0, 5, 12, 7]) == 28\n assert candidate([1, 3, 10, 5, 6, 0, 6, 14, 21]) == 44\n", + "entry_point": "max_sum_subseq" + }, + { + "task_id": "HumanEval\\/896", + "prompt": "from typing import List, Tuple\n\n\ndef sort_list_last(tuples: List[Tuple[int, int]]) -> List[Tuple[int, int]]:\n \"\"\" Sort a list in increasing order by the last element in each tuple from a given list of non-empty tuples.\n >>> sort_list_last([(2, 5), (1, 2), (4, 4), (2, 3), (2, 1)])\n [(2, 1), (1, 2), (2, 3), (4, 4), (2, 5)]\n >>> sort_list_last([(9,8), (4, 7), (3,5), (7,9), (1,2)])\n [(1, 2), (3, 5), (4, 7), (9, 8), (7, 9)]\n \"\"\"\n", + "canonical_solution": " return sorted(tuples, key=lambda n: n[-1])\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([(2, 5), (1, 2), (4, 4), (2, 3), (2, 1)]) == [(2, 1), (1, 2), (2, 3), (4, 4), (2, 5)]\n assert candidate([(9, 8), (4, 7), (3, 5), (7, 9), (1, 2)]) == [(1, 2), (3, 5), (4, 7), (9, 8), (7, 9)]\n assert candidate([(20, 50), (10, 20), (40, 40)]) == [(10, 20), (40, 40), (20, 50)]\n", + "entry_point": "sort_list_last" + }, + { + "task_id": "HumanEval\\/897", + "prompt": "def is_Word_Present(sentence: str, word: str) -> bool:\n \"\"\" Check whether the word is present in a given sentence or not.\n >>> is_Word_Present(\"machine learning\", \"machine\")\n True\n >>> is_Word_Present(\"easy\", \"fun\")\n False\n >>> is_Word_Present(\"python language\", \"code\")\n False\n \"\"\"\n", + "canonical_solution": " s = sentence.split(\" \")\n for i in s:\n if (i == word):\n return True\n return False\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(\"machine learning\", \"machine\") == True\n assert candidate(\"easy\", \"fun\") == False\n assert candidate(\"python language\", \"code\") == False\n", + "entry_point": "is_Word_Present" + }, + { + "task_id": "HumanEval\\/898", + "prompt": "from itertools import groupby\nfrom typing import List\n\n\ndef extract_elements(numbers: List[int], n: int) -> List[int]:\n \"\"\" Extract specified number of elements from a given list, which follow each other continuously.\n >>> extract_elements([1, 1, 3, 4, 4, 5, 6, 7], 2)\n [1, 4]\n >>> extract_elements([0, 1, 2, 3, 4, 4, 4, 4, 5, 7], 4)\n [4]\n >>> extract_elements([0, 0, 0, 0, 0], 5)\n [0]\n \"\"\"\n", + "canonical_solution": " result = [i for i, j in groupby(numbers) if len(list(j)) == n]\n return result\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1, 1, 3, 4, 4, 5, 6, 7], 2) == [1, 4]\n assert candidate([0, 1, 2, 3, 4, 4, 4, 4, 5, 7], 4) == [4]\n assert candidate([0, 0, 0, 0, 0], 5) == [0]\n", + "entry_point": "extract_elements" + }, + { + "task_id": "HumanEval\\/899", + "prompt": "def check(arr: list, n: int) -> bool:\n \"\"\" Check whether an array can be sorted or not by picking only the corner elements.\n >>> check([3,2,1,2,3,4], 6)\n True\n >>> check([2,1,4,5,1], 5)\n True\n >>> check([1,2,2,1,2,3], 6)\n True\n \"\"\"\n", + "canonical_solution": " g = 0\n for i in range(1, n):\n if (arr[i] - arr[i - 1] > 0 and g == 1):\n return False\n if (arr[i] - arr[i - 1] < 0):\n g = 1\n return True\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([3,2,1,2,3,4], 6) == True\n assert candidate([2,1,4,5,1], 5) == True\n assert candidate([1,2,2,1,2,3], 6) == True\n", + "entry_point": "check" + }, + { + "task_id": "HumanEval\\/900", + "prompt": "import re\n\ndef match_num(string: str) -> bool:\n \"\"\" Check if the string starts with the number 5\n >>> match_num('5-2345861')\n True\n >>> match_num('6-2345861')\n False\n >>> match_num('78910')\n False\n \"\"\"\n", + "canonical_solution": " text = re.compile(r\"^5\")\n return bool(text.match(string))\n", + "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('5-2345861') == True\n assert candidate('6-2345861') == False\n assert candidate('78910') == False\n", + "entry_point": "match_num" + } +] \ No newline at end of file