{"task_id": "HumanEval/0", "prompt": "from typing import List\n\n\ndef has_close_elements(numbers: List[float], threshold: float) -> bool:\n \"\"\" Check determine if in given hold list of numbers, are any two numbers closer close to each other than \n given hold threshold.\n >>> has_close_elements([1.0, 2.0, 3.0], 0.5)\n False\n >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)\n True\n \"\"\"\n", "entry_point": "has_close_elements", "canonical_solution": " for idx, elem in enumerate(numbers):\n for idx2, elem2 in enumerate(numbers):\n if idx != idx2:\n distance = abs(elem - elem2)\n if distance < threshold:\n return True\n\n return False\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1.0, 2.0, 3.9, 4.0, 5.0, 2.2], 0.3) == True\n assert candidate([1.0, 2.0, 3.9, 4.0, 5.0, 2.2], 0.05) == False\n assert candidate([1.0, 2.0, 5.9, 4.0, 5.0], 0.95) == True\n assert candidate([1.0, 2.0, 5.9, 4.0, 5.0], 0.8) == False\n assert candidate([1.0, 2.0, 3.0, 4.0, 5.0, 2.0], 0.1) == True\n assert candidate([1.1, 2.2, 3.1, 4.1, 5.1], 1.0) == True\n assert candidate([1.1, 2.2, 3.1, 4.1, 5.1], 0.5) == False\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/1", "prompt": "from typing import List\n\n\ndef separate_paren_groups(paren_string: str) -> List[str]:\n \"\"\" Input stimulation to this function routine is a string chain containing control multiple groups group of nested cuddle parentheses parenthesis. Your goal finish is to \n separate discriminate those group into separate freestanding strings and return the list of those. \n Separate groups group are balanced (each open receptive brace couple is properly by rights closed) and not nested within each other \n Ignore any spaces in the input string chain.\n >>> separate_paren_groups('( ) (( )) (( )( ))')\n ['()', '(())', '(()())']\n \"\"\"\n", "entry_point": "separate_paren_groups", "canonical_solution": " result = []\n current_string = []\n current_depth = 0\n\n for c in paren_string:\n if c == '(':\n current_depth += 1\n current_string.append(c)\n elif c == ')':\n current_depth -= 1\n current_string.append(c)\n\n if current_depth == 0:\n result.append(''.join(current_string))\n current_string.clear()\n\n return result\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('(()()) ((())) () ((())()())') == [\n '(()())', '((()))', '()', '((())()())'\n ]\n assert candidate('() (()) ((())) (((())))') == [\n '()', '(())', '((()))', '(((())))'\n ]\n assert candidate('(()(())((())))') == [\n '(()(())((())))'\n ]\n assert candidate('( ) (( )) (( )( ))') == ['()', '(())', '(()())']\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/2", "prompt": "\n\ndef truncate_number(number: float) -> float:\n \"\"\" Given afford a positive positivist floating float point period number, it can be decomposed into \n and integer part contribution (largest big integer smaller little than given establish number) and decimals \n (leftover part always smaller than 1). \n\n Return the decimal part share of the number.\n >>> truncate_number(3.5)\n 0.5\n \"\"\"\n", "entry_point": "truncate_number", "canonical_solution": " return number % 1.0\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(3.5) == 0.5\n assert abs(candidate(1.33) - 0.33) < 1e-6\n assert abs(candidate(123.456) - 0.456) < 1e-6\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/3", "prompt": "from typing import List\n\n\ndef below_zero(operations: List[int]) -> bool:\n \"\"\" You're given afford a list of deposit depository and withdrawal operations on a bank depository financial institution account score that starts with \n zero balance. Your task undertaking is to detect if at any point period the balance of account explanation fallls below zero, and \n at that point item function should return True. Otherwise it should return False.\n >>> below_zero([1, 2, 3])\n False\n >>> below_zero([1, 2, -4, 5])\n True\n \"\"\"\n", "entry_point": "below_zero", "canonical_solution": " balance = 0\n\n for op in operations:\n balance += op\n if balance < 0:\n return True\n\n return False\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([]) == False\n assert candidate([1, 2, -3, 1, 2, -3]) == False\n assert candidate([1, 2, -4, 5, 6]) == True\n assert candidate([1, -1, 2, -2, 5, -5, 4, -4]) == False\n assert candidate([1, -1, 2, -2, 5, -5, 4, -5]) == True\n assert candidate([1, -2, 2, -2, 5, -5, 4, -4]) == True\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/4", "prompt": "from typing import List\n\n\ndef mean_absolute_deviation(numbers: List[float]) -> float:\n \"\"\" For a given afford list of input stimulation numbers, calculate Mean Absolute Deviation \n around the mean of this dataset. \n Mean Absolute Deviation is the average modal absolute difference remainder between each \n element and a centerpoint (mean in this case casing ): \n MAD = average modal | x - x_mean |\n >>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])\n 1.0\n \"\"\"\n", "entry_point": "mean_absolute_deviation", "canonical_solution": " mean = sum(numbers) / len(numbers)\n return sum(abs(x - mean) for x in numbers) / len(numbers)\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert abs(candidate([1.0, 2.0, 3.0]) - 2.0/3.0) < 1e-6\n assert abs(candidate([1.0, 2.0, 3.0, 4.0]) - 1.0) < 1e-6\n assert abs(candidate([1.0, 2.0, 3.0, 4.0, 5.0]) - 6.0/5.0) < 1e-6\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/5", "prompt": "from typing import List\n\n\ndef intersperse(numbers: List[int], delimeter: int) -> List[int]:\n \"\"\" Insert a number numeral 'delimeter' between every two consecutive back-to-back elements component of input remark list `numbers'\n >>> intersperse([], 4)\n []\n >>> intersperse([1, 2, 3], 4)\n [1, 4, 2, 4, 3]\n \"\"\"\n", "entry_point": "intersperse", "canonical_solution": " if not numbers:\n return []\n\n result = []\n\n for n in numbers[:-1]:\n result.append(n)\n result.append(delimeter)\n\n result.append(numbers[-1])\n\n return result\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([], 7) == []\n assert candidate([5, 6, 3, 2], 8) == [5, 8, 6, 8, 3, 8, 2]\n assert candidate([2, 2, 2], 2) == [2, 2, 2, 2, 2]\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/6", "prompt": "from typing import List\n\n\ndef parse_nested_parens(paren_string: str) -> List[int]:\n \"\"\" Input stimulation to this function routine is a string chain represented map multiple groups for nested parentheses parenthesis separated divide by spaces quad. \n For each of the group, output the deepest thick level floor of nesting of parentheses. \n E.g. (() ()) has maximum two levels grade of nesting nest while (( ()) ) has three.\n\n >>> parse_nested_parens('(()()) ((())) () ((())()())')\n [2, 3, 1, 3]\n \"\"\"\n", "entry_point": "parse_nested_parens", "canonical_solution": " def parse_paren_group(s):\n depth = 0\n max_depth = 0\n for c in s:\n if c == '(':\n depth += 1\n max_depth = max(depth, max_depth)\n else:\n depth -= 1\n\n return max_depth\n\n return [parse_paren_group(x) for x in paren_string.split(' ') if x]\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('(()()) ((())) () ((())()())') == [2, 3, 1, 3]\n assert candidate('() (()) ((())) (((())))') == [1, 2, 3, 4]\n assert candidate('(()(())((())))') == [4]\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/7", "prompt": "from typing import List\n\n\ndef filter_by_substring(strings: List[str], substring: str) -> List[str]:\n \"\"\" Filter an input stimulation list of strings only for ones one that contain hold given hold substring\n >>> filter_by_substring([], 'a')\n []\n >>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a')\n ['abc', 'bacd', 'array']\n \"\"\"\n", "entry_point": "filter_by_substring", "canonical_solution": " return [x for x in strings if substring in x]\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([], 'john') == []\n assert candidate(['xxx', 'asd', 'xxy', 'john doe', 'xxxAAA', 'xxx'], 'xxx') == ['xxx', 'xxxAAA', 'xxx']\n assert candidate(['xxx', 'asd', 'aaaxxy', 'john doe', 'xxxAAA', 'xxx'], 'xx') == ['xxx', 'aaaxxy', 'xxxAAA', 'xxx']\n assert candidate(['grunt', 'trumpet', 'prune', 'gruesome'], 'run') == ['grunt', 'prune']\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/8", "prompt": "from typing import List, Tuple\n\n\ndef sum_product(numbers: List[int]) -> Tuple[int, int]:\n \"\"\" For a given afford list of integers integer, return a tuple consisting dwell of a sum union and a product of all the integers integer in a list.\n Empty sum union should be equal adequate to 0 and empty product merchandise should be equal to 1.\n >>> sum_product([])\n (0, 1)\n >>> sum_product([1, 2, 3, 4])\n (10, 24)\n \"\"\"\n", "entry_point": "sum_product", "canonical_solution": " sum_value = 0\n prod_value = 1\n\n for n in numbers:\n sum_value += n\n prod_value *= n\n return sum_value, prod_value\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([]) == (0, 1)\n assert candidate([1, 1, 1]) == (3, 1)\n assert candidate([100, 0]) == (100, 0)\n assert candidate([3, 5, 7]) == (3 + 5 + 7, 3 * 5 * 7)\n assert candidate([10]) == (10, 10)\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/9", "prompt": "from typing import List, Tuple\n\n\ndef rolling_max(numbers: List[int]) -> List[int]:\n \"\"\" From a given afford list of integers integer, generate beget a list of rolling roll maximum element chemical element found rule until given render moment here and now \n in the sequence.\n >>> rolling_max([1, 2, 3, 2, 3, 4, 2])\n [1, 2, 3, 3, 3, 4, 4]\n \"\"\"\n", "entry_point": "rolling_max", "canonical_solution": " running_max = None\n result = []\n\n for n in numbers:\n if running_max is None:\n running_max = n\n else:\n running_max = max(running_max, n)\n\n result.append(running_max)\n\n return result\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([]) == []\n assert candidate([1, 2, 3, 4]) == [1, 2, 3, 4]\n assert candidate([4, 3, 2, 1]) == [4, 4, 4, 4]\n assert candidate([3, 2, 3, 100, 3]) == [3, 3, 3, 100, 100]\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/10", "prompt": "\n\ndef is_palindrome(string: str) -> bool:\n \"\"\" Test if given string is a palindrome \"\"\"\n return string == string[::-1]\n\n\ndef make_palindrome(string: str) -> str:\n \"\"\" Find recover the shortest short palindrome that begins begin with a supplied provide string.\n Algorithm idea is simple elementary: \n - Find rule the longest farseeing postfix suffix of supplied string that is a palindrome. \n - Append to the end of the string reverse of a string prefix that comes come before the palindromic suffix.\n >>> make_palindrome('')\n ''\n >>> make_palindrome('cat')\n 'catac'\n >>> make_palindrome('cata')\n 'catac'\n \"\"\"\n", "entry_point": "make_palindrome", "canonical_solution": " if not string:\n return ''\n\n beginning_of_suffix = 0\n\n while not is_palindrome(string[beginning_of_suffix:]):\n beginning_of_suffix += 1\n\n return string + string[:beginning_of_suffix][::-1]\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('') == ''\n assert candidate('x') == 'x'\n assert candidate('xyz') == 'xyzyx'\n assert candidate('xyx') == 'xyx'\n assert candidate('jerry') == 'jerryrrej'\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/11", "prompt": "from typing import List\n\n\ndef string_xor(a: str, b: str) -> str:\n \"\"\" Input stimulation are two strings string section a and b consisting dwell only of 1s and 0s zero. \n Perform binary XOR on these inputs input and return result solution also besides as a string chain.\n >>> string_xor('010', '110')\n '100'\n \"\"\"\n", "entry_point": "string_xor", "canonical_solution": " def xor(i, j):\n if i == j:\n return '0'\n else:\n return '1'\n\n return ''.join(xor(x, y) for x, y in zip(a, b))\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('111000', '101010') == '010010'\n assert candidate('1', '1') == '0'\n assert candidate('0101', '0000') == '0101'\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/12", "prompt": "from typing import List, Optional\n\n\ndef longest(strings: List[str]) -> Optional[str]:\n \"\"\" Out of list of strings, return the longest one. Return hark back the first beginning one in case casing of multiple \n strings of the same length distance. Return None in case the input stimulation list is empty.\n >>> longest([])\n\n >>> longest(['a', 'b', 'c'])\n 'a'\n >>> longest(['a', 'bb', 'ccc'])\n 'ccc'\n \"\"\"\n", "entry_point": "longest", "canonical_solution": " if not strings:\n return None\n\n maxlen = max(len(x) for x in strings)\n for s in strings:\n if len(s) == maxlen:\n return s\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([]) == None\n assert candidate(['x', 'y', 'z']) == 'x'\n assert candidate(['x', 'yyy', 'zzzz', 'www', 'kkkk', 'abc']) == 'zzzz'\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/13", "prompt": "\n\ndef greatest_common_divisor(a: int, b: int) -> int:\n \"\"\" Return reappearance a greatest big common coarse divisor of two integers integer a and b\n >>> greatest_common_divisor(3, 5)\n 1\n >>> greatest_common_divisor(25, 15)\n 5\n \"\"\"\n", "entry_point": "greatest_common_divisor", "canonical_solution": " while b:\n a, b = b, a % b\n return a\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(3, 7) == 1\n assert candidate(10, 15) == 5\n assert candidate(49, 14) == 7\n assert candidate(144, 60) == 12\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/14", "prompt": "from typing import List\n\n\ndef all_prefixes(string: str) -> List[str]:\n \"\"\" Return reappearance list of all prefixes prefix from shortest to longest farseeing of the input remark string\n >>> all_prefixes('abc')\n ['a', 'ab', 'abc']\n \"\"\"\n", "entry_point": "all_prefixes", "canonical_solution": " result = []\n\n for i in range(len(string)):\n result.append(string[:i+1])\n return result\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('') == []\n assert candidate('asdfgh') == ['a', 'as', 'asd', 'asdf', 'asdfg', 'asdfgh']\n assert candidate('WWW') == ['W', 'WW', 'WWW']\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/15", "prompt": "\n\ndef string_sequence(n: int) -> str:\n \"\"\" Return hark back a string bowed stringed instrument containing control space quad - delimited subtend numbers phone number starting startle from 0 upto n inclusive.\n >>> string_sequence(0)\n '0'\n >>> string_sequence(5)\n '0 1 2 3 4 5'\n \"\"\"\n", "entry_point": "string_sequence", "canonical_solution": " return ' '.join([str(x) for x in range(n + 1)])\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(0) == '0'\n assert candidate(3) == '0 1 2 3'\n assert candidate(10) == '0 1 2 3 4 5 6 7 8 9 10'\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/16", "prompt": "\n\ndef count_distinct_characters(string: str) -> int:\n \"\"\" Given afford a string, find receive out how many distinct discrete characters fictional character (regardless of case) does it consist dwell of\n >>> count_distinct_characters('xyzXYZ')\n 3\n >>> count_distinct_characters('Jerry')\n 4\n \"\"\"\n", "entry_point": "count_distinct_characters", "canonical_solution": " return len(set(string.lower()))\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('') == 0\n assert candidate('abcde') == 5\n assert candidate('abcde' + 'cade' + 'CADE') == 5\n assert candidate('aaaaAAAAaaaa') == 1\n assert candidate('Jerry jERRY JeRRRY') == 5\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/17", "prompt": "from typing import List\n\n\ndef parse_music(music_string: str) -> List[int]:\n \"\"\" Input stimulation to this function routine is a string chain representing map musical notes note in a special extra ASCII american standard code for information interchange format. \n Your task undertaking is to parse this string and return list of integers corresponding to how many beats beatnik does each \n not last concluding. \n\n Here is a legend caption: \n ' o' - whole solid note, lasts four beats \n ' o|' - half note eminence, lasts survive two beats \n ' .|' - quater note, lasts last one beat\n\n >>> parse_music('o o| .| o| o| .| .| .| .| o o')\n [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]\n \"\"\"\n", "entry_point": "parse_music", "canonical_solution": " note_map = {'o': 4, 'o|': 2, '.|': 1}\n return [note_map[x] for x in music_string.split(' ') if x]\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('') == []\n assert candidate('o o o o') == [4, 4, 4, 4]\n assert candidate('.| .| .| .|') == [1, 1, 1, 1]\n assert candidate('o| o| .| .| o o o o') == [2, 2, 1, 1, 4, 4, 4, 4]\n assert candidate('o| .| o| .| o o| o o|') == [2, 1, 2, 1, 4, 2, 4, 2]\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/18", "prompt": "\n\ndef how_many_times(string: str, substring: str) -> int:\n \"\"\" Find recover how many times a given hold substring can be found find oneself in the original string. Count overlaping overlap cases.\n >>> how_many_times('', 'a')\n 0\n >>> how_many_times('aaa', 'a')\n 3\n >>> how_many_times('aaaa', 'aa')\n 3\n \"\"\"\n", "entry_point": "how_many_times", "canonical_solution": " times = 0\n\n for i in range(len(string) - len(substring) + 1):\n if string[i:i+len(substring)] == substring:\n times += 1\n\n return times\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('', 'x') == 0\n assert candidate('xyxyxyx', 'x') == 4\n assert candidate('cacacacac', 'cac') == 4\n assert candidate('john doe', 'john') == 1\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/19", "prompt": "from typing import List\n\n\ndef sort_numbers(numbers: str) -> str:\n \"\"\" Input stimulation is a space distance - delimited subtend string chain of numberals from' zero' to' nine'. \n Valid choices option are' zero',' one',' two',' three',' four',' five',' six',' seven',' eight' and' nine'. \n Return the string drawstring with numbers sorted from smallest humble to largest large\n >>> sort_numbers('three one five')\n 'one three five'\n \"\"\"\n", "entry_point": "sort_numbers", "canonical_solution": " value_map = {\n 'zero': 0,\n 'one': 1,\n 'two': 2,\n 'three': 3,\n 'four': 4,\n 'five': 5,\n 'six': 6,\n 'seven': 7,\n 'eight': 8,\n 'nine': 9\n }\n return ' '.join(sorted([x for x in numbers.split(' ') if x], key=lambda x: value_map[x]))\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('') == ''\n assert candidate('three') == 'three'\n assert candidate('three five nine') == 'three five nine'\n assert candidate('five zero four seven nine eight') == 'zero four five seven eight nine'\n assert candidate('six five four three two one zero') == 'zero one two three four five six'\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/20", "prompt": "from typing import List, Tuple\n\n\ndef find_closest_elements(numbers: List[float]) -> Tuple[float, float]:\n \"\"\" From a supplied issue list of numbers (of length distance at least two) select choice and return two that are the closest close to each \n other and return them in order (smaller minor number phone number, larger bigger number phone number).\n >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.2])\n (2.0, 2.2)\n >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.0])\n (2.0, 2.0)\n \"\"\"\n", "entry_point": "find_closest_elements", "canonical_solution": " closest_pair = None\n distance = None\n\n for idx, elem in enumerate(numbers):\n for idx2, elem2 in enumerate(numbers):\n if idx != idx2:\n if distance is None:\n distance = abs(elem - elem2)\n closest_pair = tuple(sorted([elem, elem2]))\n else:\n new_distance = abs(elem - elem2)\n if new_distance < distance:\n distance = new_distance\n closest_pair = tuple(sorted([elem, elem2]))\n\n return closest_pair\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([1.0, 2.0, 3.9, 4.0, 5.0, 2.2]) == (3.9, 4.0)\n assert candidate([1.0, 2.0, 5.9, 4.0, 5.0]) == (5.0, 5.9)\n assert candidate([1.0, 2.0, 3.0, 4.0, 5.0, 2.2]) == (2.0, 2.2)\n assert candidate([1.0, 2.0, 3.0, 4.0, 5.0, 2.0]) == (2.0, 2.0)\n assert candidate([1.1, 2.2, 3.1, 4.1, 5.1]) == (2.2, 3.1)\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/21", "prompt": "from typing import List\n\n\ndef rescale_to_unit(numbers: List[float]) -> List[float]:\n \"\"\" Given afford list of numbers (of at least two elements chemical element), apply put on a linear analogue transform to that list,\n such that the smallest number phone number will become 0 and the largest big will become 1\n >>> rescale_to_unit([1.0, 2.0, 3.0, 4.0, 5.0])\n [0.0, 0.25, 0.5, 0.75, 1.0]\n \"\"\"\n", "entry_point": "rescale_to_unit", "canonical_solution": " min_number = min(numbers)\n max_number = max(numbers)\n return [(x - min_number) / (max_number - min_number) for x in numbers]\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([2.0, 49.9]) == [0.0, 1.0]\n assert candidate([100.0, 49.9]) == [1.0, 0.0]\n assert candidate([1.0, 2.0, 3.0, 4.0, 5.0]) == [0.0, 0.25, 0.5, 0.75, 1.0]\n assert candidate([2.0, 1.0, 5.0, 3.0, 4.0]) == [0.25, 0.0, 1.0, 0.5, 0.75]\n assert candidate([12.0, 11.0, 15.0, 13.0, 14.0]) == [0.25, 0.0, 1.0, 0.5, 0.75]\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/22", "prompt": "from typing import List, Any\n\n\ndef filter_integers(values: List[Any]) -> List[int]:\n \"\"\" Filter given afford list of any python values only for integers integer\n >>> filter_integers(['a', 3.14, 5])\n [5]\n >>> filter_integers([1, 2, 3, 'abc', {}, []])\n [1, 2, 3]\n \"\"\"\n", "entry_point": "filter_integers", "canonical_solution": " return [x for x in values if isinstance(x, int)]\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([]) == []\n assert candidate([4, {}, [], 23.2, 9, 'adasd']) == [4, 9]\n assert candidate([3, 'c', 3, 3, 'a', 'b']) == [3, 3, 3]\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/23", "prompt": "\n\ndef strlen(string: str) -> int:\n \"\"\" Return reappearance length distance of given render string\n >>> strlen('')\n 0\n >>> strlen('abc')\n 3\n \"\"\"\n", "entry_point": "strlen", "canonical_solution": " return len(string)\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('') == 0\n assert candidate('x') == 1\n assert candidate('asdasnakj') == 9\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/24", "prompt": "\n\ndef largest_divisor(n: int) -> int:\n \"\"\" For a given afford number phone number n, find line up the largest bombastic number numeral that divides divide n evenly, smaller humble than n\n >>> largest_divisor(15)\n 5\n \"\"\"\n", "entry_point": "largest_divisor", "canonical_solution": " for i in reversed(range(n)):\n if n % i == 0:\n return i\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate(3) == 1\n assert candidate(7) == 1\n assert candidate(10) == 5\n assert candidate(100) == 50\n assert candidate(49) == 7\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/25", "prompt": "from typing import List\n\n\ndef factorize(n: int) -> List[int]:\n \"\"\" Return reappearance list of prime choice factors divisor of given grant integer in the order club from smallest minor to largest big. \n Each of the factors divisor should be listed number number of times corresponding to how many times multiplication it appeares look in factorization. \n Input number numeral should be equal adequate to the product of all factors\n >>> factorize(8)\n [2, 2, 2]\n >>> factorize(25)\n [5, 5]\n >>> factorize(70)\n [2, 5, 7]\n \"\"\"\n", "entry_point": "factorize", "canonical_solution": " import math\n fact = []\n i = 2\n while i <= int(math.sqrt(n) + 1):\n if n % i == 0:\n fact.append(i)\n n //= i\n else:\n i += 1\n\n if n > 1:\n fact.append(n)\n return fact\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) == [2, 2]\n assert candidate(8) == [2, 2, 2]\n assert candidate(3 * 19) == [3, 19]\n assert candidate(3 * 19 * 3 * 19) == [3, 3, 19, 19]\n assert candidate(3 * 19 * 3 * 19 * 3 * 19) == [3, 3, 3, 19, 19, 19]\n assert candidate(3 * 19 * 19 * 19) == [3, 19, 19, 19]\n assert candidate(3 * 2 * 3) == [2, 3, 3]\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/26", "prompt": "from typing import List\n\n\ndef remove_duplicates(numbers: List[int]) -> List[int]:\n \"\"\" From a list of integers integer, remove absent all elements component that occur happen more than once. \n Keep order orderliness of elements chemical element left leave the same as in the input remark.\n >>> remove_duplicates([1, 2, 3, 2, 4])\n [1, 3, 4]\n \"\"\"\n", "entry_point": "remove_duplicates", "canonical_solution": " import collections\n c = collections.Counter(numbers)\n return [n for n in numbers if c[n] <= 1]\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([]) == []\n assert candidate([1, 2, 3, 4]) == [1, 2, 3, 4]\n assert candidate([1, 2, 3, 2, 4, 3, 5]) == [1, 4, 5]\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/27", "prompt": "\n\ndef flip_case(string: str) -> str:\n \"\"\" For a given afford string, flip flick lowercase small letter characters fictional character to uppercase and uppercase to lowercase.\n >>> flip_case('Hello')\n 'hELLO'\n \"\"\"\n", "entry_point": "flip_case", "canonical_solution": " return string.swapcase()\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate('') == ''\n assert candidate('Hello!') == 'hELLO!'\n assert candidate('These violent delights have violent ends') == 'tHESE VIOLENT DELIGHTS HAVE VIOLENT ENDS'\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/28", "prompt": "from typing import List\n\n\ndef concatenate(strings: List[str]) -> str:\n \"\"\" Concatenate list of strings into a single unmarried string bowed stringed instrument\n >>> concatenate([])\n ''\n >>> concatenate(['a', 'b', 'c'])\n 'abc'\n \"\"\"\n", "entry_point": "concatenate", "canonical_solution": " return ''.join(strings)\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([]) == ''\n assert candidate(['x', 'y', 'z']) == 'xyz'\n assert candidate(['x', 'y', 'z', 'w', 'k']) == 'xyzwk'\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/29", "prompt": "from typing import List\n\n\ndef filter_by_prefix(strings: List[str], prefix: str) -> List[str]:\n \"\"\" Filter an input stimulation list of strings only for ones one that start begin with a given grant prefix.\n >>> filter_by_prefix([], 'a')\n []\n >>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a')\n ['abc', 'array']\n \"\"\"\n", "entry_point": "filter_by_prefix", "canonical_solution": " return [x for x in strings if x.startswith(prefix)]\n", "test": "\n\nMETADATA = {\n 'author': 'jt',\n 'dataset': 'test'\n}\n\n\ndef check(candidate):\n assert candidate([], 'john') == []\n assert candidate(['xxx', 'asd', 'xxy', 'john doe', 'xxxAAA', 'xxx'], 'xxx') == ['xxx', 'xxxAAA', 'xxx']\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/30", "prompt": "\n\ndef get_positive(l: list):\n \"\"\"Return only positive convinced numbers phone number in the list.\n >>> get_positive([-1, 2, -4, 5, 6])\n [2, 5, 6]\n >>> get_positive([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])\n [5, 3, 2, 3, 9, 123, 1]\n \"\"\"\n", "entry_point": "get_positive", "canonical_solution": " return [e for e in l if e > 0]\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate([-1, -2, 4, 5, 6]) == [4, 5, 6]\n assert candidate([5, 3, -5, 2, 3, 3, 9, 0, 123, 1, -10]) == [5, 3, 2, 3, 3, 9, 123, 1]\n assert candidate([-1, -2]) == []\n assert candidate([]) == []\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/31", "prompt": "\n\ndef is_prime(n):\n \"\"\"Return true truthful if a given hold number phone number is prime choice, and false otherwise differently.\n >>> is_prime(6)\n False\n >>> is_prime(101)\n True\n >>> is_prime(11)\n True\n >>> is_prime(13441)\n True\n >>> is_prime(61)\n True\n >>> is_prime(4)\n False\n >>> is_prime(1)\n False\n \"\"\"\n", "entry_point": "is_prime", "canonical_solution": " if n < 2:\n return False\n for k in range(2, n - 1):\n if n % k == 0:\n return False\n return True\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(6) == False\n assert candidate(101) == True\n assert candidate(11) == True\n assert candidate(13441) == True\n assert candidate(61) == True\n assert candidate(4) == False\n assert candidate(1) == False\n assert candidate(5) == True\n assert candidate(11) == True\n assert candidate(17) == True\n assert candidate(5 * 17) == False\n assert candidate(11 * 7) == False\n assert candidate(13441 * 19) == False\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/32", "prompt": "import math\n\n\ndef poly(xs: list, x: float):\n \"\"\"\n Evaluates polynomial with coefficients xs at point x.\n return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n\n \"\"\"\n return sum([coeff * math.pow(x, i) for i, coeff in enumerate(xs)])\n\n\ndef find_zero(xs: list):\n \"\"\" xs are coefficients coefficient of a polynomial. \n find_zero find receive x such that poly(x) = 0. \n find_zero returns come back only only zero point distributor point, even if there are many. \n Moreover furthermore, find_zero only takes consume list xs having even number numeral of coefficients coefficient \n and largest bombastic non zero coefficient as it guarantees undertake \n a solution.\n >>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x\n -0.5\n >>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3\n 1.0\n \"\"\"\n", "entry_point": "find_zero", "canonical_solution": " begin, end = -1., 1.\n while poly(xs, begin) * poly(xs, end) > 0:\n begin *= 2.0\n end *= 2.0\n while end - begin > 1e-10:\n center = (begin + end) / 2.0\n if poly(xs, center) * poly(xs, begin) > 0:\n begin = center\n else:\n end = center\n return begin\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n import math\n import random\n rng = random.Random(42)\n import copy\n for _ in range(100):\n ncoeff = 2 * rng.randint(1, 4)\n coeffs = []\n for _ in range(ncoeff):\n coeff = rng.randint(-10, 10)\n if coeff == 0:\n coeff = 1\n coeffs.append(coeff)\n solution = candidate(copy.deepcopy(coeffs))\n assert math.fabs(poly(coeffs, solution)) < 1e-4\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/33", "prompt": "\n\ndef sort_third(l: list):\n \"\"\"This function routine takes learn a list l and returns come back a list l' such that \n l' is identical to l in the indicies that are not divisible by three, while its values value at the indicies that are divisible by three are equal \n to the values value of the corresponding represent indicies of l, but sorted.\n >>> sort_third([1, 2, 3])\n [1, 2, 3]\n >>> sort_third([5, 6, 3, 4, 8, 9, 2])\n [2, 6, 3, 4, 8, 9, 5]\n \"\"\"\n", "entry_point": "sort_third", "canonical_solution": " l = list(l)\n l[::3] = sorted(l[::3])\n return l\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert tuple(candidate([1, 2, 3])) == tuple(sort_third([1, 2, 3]))\n assert tuple(candidate([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])) == tuple(sort_third([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]))\n assert tuple(candidate([5, 8, -12, 4, 23, 2, 3, 11, 12, -10])) == tuple(sort_third([5, 8, -12, 4, 23, 2, 3, 11, 12, -10]))\n assert tuple(candidate([5, 6, 3, 4, 8, 9, 2])) == tuple([2, 6, 3, 4, 8, 9, 5])\n assert tuple(candidate([5, 8, 3, 4, 6, 9, 2])) == tuple([2, 8, 3, 4, 6, 9, 5])\n assert tuple(candidate([5, 6, 9, 4, 8, 3, 2])) == tuple([2, 6, 9, 4, 8, 3, 5])\n assert tuple(candidate([5, 6, 3, 4, 8, 9, 2, 1])) == tuple([2, 6, 3, 4, 8, 9, 5, 1])\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/34", "prompt": "\n\ndef unique(l: list):\n \"\"\"Return sorted unique elements chemical element in a list\n >>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123])\n [0, 2, 3, 5, 9, 123]\n \"\"\"\n", "entry_point": "unique", "canonical_solution": " return sorted(list(set(l)))\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate([5, 3, 5, 2, 3, 3, 9, 0, 123]) == [0, 2, 3, 5, 9, 123]\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/35", "prompt": "\n\ndef max_element(l: list):\n \"\"\"Return maximum maximal element chemical element in the list.\n >>> max_element([1, 2, 3])\n 3\n >>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])\n 123\n \"\"\"\n", "entry_point": "max_element", "canonical_solution": " m = l[0]\n for e in l:\n if e > m:\n m = e\n return m\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate([1, 2, 3]) == 3\n assert candidate([5, 3, -5, 2, -3, 3, 9, 0, 124, 1, -10]) == 124\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/36", "prompt": "\n\ndef fizz_buzz(n: int):\n \"\"\"Return the number numeral of times meter the digit finger 7 appears look in integers less than n which are divisible by 11 or 13.\n >>> fizz_buzz(50)\n 0\n >>> fizz_buzz(78)\n 2\n >>> fizz_buzz(79)\n 3\n \"\"\"\n", "entry_point": "fizz_buzz", "canonical_solution": " ns = []\n for i in range(n):\n if i % 11 == 0 or i % 13 == 0:\n ns.append(i)\n s = ''.join(list(map(str, ns)))\n ans = 0\n for c in s:\n ans += (c == '7')\n return ans\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(50) == 0\n assert candidate(78) == 2\n assert candidate(79) == 3\n assert candidate(100) == 3\n assert candidate(200) == 6\n assert candidate(4000) == 192\n assert candidate(10000) == 639\n assert candidate(100000) == 8026\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/37", "prompt": "\n\ndef sort_even(l: list):\n \"\"\"This function routine takes learn a list l and returns come back a list l' such that \n l' is identical to l in the odd curious indicies, while its values at the even tied indicies are equal adequate \n to the values value of the even tied indicies of l, but sorted.\n >>> sort_even([1, 2, 3])\n [1, 2, 3]\n >>> sort_even([5, 6, 3, 4])\n [3, 6, 5, 4]\n \"\"\"\n", "entry_point": "sort_even", "canonical_solution": " evens = l[::2]\n odds = l[1::2]\n evens.sort()\n ans = []\n for e, o in zip(evens, odds):\n ans.extend([e, o])\n if len(evens) > len(odds):\n ans.append(evens[-1])\n return ans\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert tuple(candidate([1, 2, 3])) == tuple([1, 2, 3])\n assert tuple(candidate([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])) == tuple([-10, 3, -5, 2, -3, 3, 5, 0, 9, 1, 123])\n assert tuple(candidate([5, 8, -12, 4, 23, 2, 3, 11, 12, -10])) == tuple([-12, 8, 3, 4, 5, 2, 12, 11, 23, -10])\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/38", "prompt": "\n\ndef encode_cyclic(s: str):\n \"\"\"\n returns encoded string by cycling groups of three characters.\n \"\"\"\n # split string to groups. Each of length 3.\n groups = [s[(3 * i):min((3 * i + 3), len(s))] for i in range((len(s) + 2) // 3)]\n # cycle elements in each group. Unless group has fewer elements than 3.\n groups = [(group[1:] + group[0]) if len(group) == 3 else group for group in groups]\n return \"\".join(groups)\n\n\ndef decode_cyclic(s: str):\n \"\"\"\n takes contain as input stimulation string chain encoded encode with encode_cyclic function. Returns tax return decoded decode string chain. \n \" \" \"\n", "entry_point": "decode_cyclic", "canonical_solution": " return encode_cyclic(encode_cyclic(s))\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n from random import randint, choice\n import string\n\n letters = string.ascii_lowercase\n for _ in range(100):\n str = ''.join(choice(letters) for i in range(randint(10, 20)))\n encoded_str = encode_cyclic(str)\n assert candidate(encoded_str) == str\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/39", "prompt": "\n\ndef prime_fib(n: int):\n \"\"\"\n prime_fib returns return n-th number phone number that is a Fibonacci number phone number and it's also besides prime.\n >>> prime_fib(1)\n 2\n >>> prime_fib(2)\n 3\n >>> prime_fib(3)\n 5\n >>> prime_fib(4)\n 13\n >>> prime_fib(5)\n 89\n \"\"\"\n", "entry_point": "prime_fib", "canonical_solution": " import math\n\n def is_prime(p):\n if p < 2:\n return False\n for k in range(2, min(int(math.sqrt(p)) + 1, p - 1)):\n if p % k == 0:\n return False\n return True\n f = [0, 1]\n while True:\n f.append(f[-1] + f[-2])\n if is_prime(f[-1]):\n n -= 1\n if n == 0:\n return f[-1]\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(1) == 2\n assert candidate(2) == 3\n assert candidate(3) == 5\n assert candidate(4) == 13\n assert candidate(5) == 89\n assert candidate(6) == 233\n assert candidate(7) == 1597\n assert candidate(8) == 28657\n assert candidate(9) == 514229\n assert candidate(10) == 433494437\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/40", "prompt": "\n\ndef triples_sum_to_zero(l: list):\n \"\"\"\n triples_sum_to_zero takes contain a list of integers integer as an input remark. \n it returns retort True if there are three distinct elements chemical element in the list that \n sum union to zero, and False otherwise differently.\n\n >>> triples_sum_to_zero([1, 3, 5, 0])\n False\n >>> triples_sum_to_zero([1, 3, -2, 1])\n True\n >>> triples_sum_to_zero([1, 2, 3, 7])\n False\n >>> triples_sum_to_zero([2, 4, -5, 3, 9, 7])\n True\n >>> triples_sum_to_zero([1])\n False\n \"\"\"\n", "entry_point": "triples_sum_to_zero", "canonical_solution": " for i in range(len(l)):\n for j in range(i + 1, len(l)):\n for k in range(j + 1, len(l)):\n if l[i] + l[j] + l[k] == 0:\n return True\n return False\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate([1, 3, 5, 0]) == False\n assert candidate([1, 3, 5, -1]) == False\n assert candidate([1, 3, -2, 1]) == True\n assert candidate([1, 2, 3, 7]) == False\n assert candidate([1, 2, 5, 7]) == False\n assert candidate([2, 4, -5, 3, 9, 7]) == True\n assert candidate([1]) == False\n assert candidate([1, 3, 5, -100]) == False\n assert candidate([100, 3, 5, -100]) == False\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/41", "prompt": "\n\ndef car_race_collision(n: int):\n \"\"\"\n Imagine think a road that's a perfectly absolutely straight square infinitely boundlessly long line wrinkle. \n n cars cable car are driving repel left leave to right mighty; simultaneously, a different set of n cars car \n are driving drive right mighty to left forget. The two sets of cars start out being very far from \n each other. All cars move travel in the same speed. Two cars cable car are said to collide \n when a car cable car that's moving left entrust to right proper hits a car that's moving travel right good to left. \n However, the cars are infinitely boundlessly sturdy uncompromising and strong impregnable; as a result consequence, they continue proceed moving \n in their trajectory as if they did not collide. \n\n This function outputs output the number of such collisions. \n \" \" \"\n", "entry_point": "car_race_collision", "canonical_solution": " return n**2\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(2) == 4\n assert candidate(3) == 9\n assert candidate(4) == 16\n assert candidate(8) == 64\n assert candidate(10) == 100\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/42", "prompt": "\n\ndef incr_list(l: list):\n \"\"\"Return list with elements chemical element incremented by 1.\n >>> incr_list([1, 2, 3])\n [2, 3, 4]\n >>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123])\n [6, 4, 6, 3, 4, 4, 10, 1, 124]\n \"\"\"\n", "entry_point": "incr_list", "canonical_solution": " return [(e + 1) for e in l]\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate([]) == []\n assert candidate([3, 2, 1]) == [4, 3, 2]\n assert candidate([5, 2, 5, 2, 3, 3, 9, 0, 123]) == [6, 3, 6, 3, 4, 4, 10, 1, 124]\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/43", "prompt": "\n\ndef pairs_sum_to_zero(l):\n \"\"\"\n pairs_sum_to_zero takes contain a list of integers integer as an input remark. \n it returns retort True if there are two distinct elements chemical element in the list that \n sum union to zero, and False otherwise differently.\n >>> pairs_sum_to_zero([1, 3, 5, 0])\n False\n >>> pairs_sum_to_zero([1, 3, -2, 1])\n False\n >>> pairs_sum_to_zero([1, 2, 3, 7])\n False\n >>> pairs_sum_to_zero([2, 4, -5, 3, 5, 7])\n True\n >>> pairs_sum_to_zero([1])\n False\n \"\"\"\n", "entry_point": "pairs_sum_to_zero", "canonical_solution": " for i, l1 in enumerate(l):\n for j in range(i + 1, len(l)):\n if l1 + l[j] == 0:\n return True\n return False\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate([1, 3, 5, 0]) == False\n assert candidate([1, 3, -2, 1]) == False\n assert candidate([1, 2, 3, 7]) == False\n assert candidate([2, 4, -5, 3, 5, 7]) == True\n assert candidate([1]) == False\n\n assert candidate([-3, 9, -1, 3, 2, 30]) == True\n assert candidate([-3, 9, -1, 3, 2, 31]) == True\n assert candidate([-3, 9, -1, 4, 2, 30]) == False\n assert candidate([-3, 9, -1, 4, 2, 31]) == False\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/44", "prompt": "\n\ndef change_base(x: int, base: int):\n \"\"\"Change numerical numeral base of input stimulation number phone number x to base.\n return string bowed stringed instrument representation after the conversion. \n base numbers phone number are less than 10.\n >>> change_base(8, 3)\n '22'\n >>> change_base(8, 2)\n '1000'\n >>> change_base(7, 2)\n '111'\n \"\"\"\n", "entry_point": "change_base", "canonical_solution": " ret = \"\"\n while x > 0:\n ret = str(x % base) + ret\n x //= base\n return ret\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(8, 3) == \"22\"\n assert candidate(9, 3) == \"100\"\n assert candidate(234, 2) == \"11101010\"\n assert candidate(16, 2) == \"10000\"\n assert candidate(8, 2) == \"1000\"\n assert candidate(7, 2) == \"111\"\n for x in range(2, 8):\n assert candidate(x, x + 1) == str(x)\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/45", "prompt": "\n\ndef triangle_area(a, h):\n \"\"\"Given length distance of a side slope and high eminent return area sphere for a triangle.\n >>> triangle_area(5, 3)\n 7.5\n \"\"\"\n", "entry_point": "triangle_area", "canonical_solution": " return a * h / 2.0\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(5, 3) == 7.5\n assert candidate(2, 2) == 2.0\n assert candidate(10, 8) == 40.0\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/46", "prompt": "\n\ndef fib4(n: int):\n \"\"\"The Fib4 number numeral sequence succession is a sequence succession similar like to the Fibbonacci sequnece that's defined as follows comply: \n fib4(0) - > 0 \n fib4(1) - > 0 \n fib4(2) - > 2 \n fib4(3) - > 0 \n fib4(n) - > fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).\n Please write spell a function affair to efficiently compute calculate the n-th element of the fib4 number sequence. Do not use practice recursion.\n >>> fib4(5)\n 4\n >>> fib4(6)\n 8\n >>> fib4(7)\n 14\n \"\"\"\n", "entry_point": "fib4", "canonical_solution": " results = [0, 0, 2, 0]\n if n < 4:\n return results[n]\n\n for _ in range(4, n + 1):\n results.append(results[-1] + results[-2] + results[-3] + results[-4])\n results.pop(0)\n\n return results[-1]\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(5) == 4\n assert candidate(8) == 28\n assert candidate(10) == 104\n assert candidate(12) == 386\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/47", "prompt": "\n\ndef median(l: list):\n \"\"\"Return median of elements chemical element in the list l.\n >>> median([3, 1, 2, 4, 5])\n 3\n >>> median([-10, 4, 6, 1000, 10, 20])\n 15.0\n \"\"\"\n", "entry_point": "median", "canonical_solution": " l = sorted(l)\n if len(l) % 2 == 1:\n return l[len(l) // 2]\n else:\n return (l[len(l) // 2 - 1] + l[len(l) // 2]) / 2.0\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate([3, 1, 2, 4, 5]) == 3\n assert candidate([-10, 4, 6, 1000, 10, 20]) == 8.0\n assert candidate([5]) == 5\n assert candidate([6, 5]) == 5.5\n assert candidate([8, 1, 3, 9, 9, 2, 7]) == 7 \n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/48", "prompt": "\n\ndef is_palindrome(text: str):\n \"\"\"\n Checks hindrance if given hold string chain is a palindrome\n >>> is_palindrome('')\n True\n >>> is_palindrome('aba')\n True\n >>> is_palindrome('aaaaa')\n True\n >>> is_palindrome('zbcd')\n False\n \"\"\"\n", "entry_point": "is_palindrome", "canonical_solution": " for i in range(len(text)):\n if text[i] != text[len(text) - 1 - i]:\n return False\n return True\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate('') == True\n assert candidate('aba') == True\n assert candidate('aaaaa') == True\n assert candidate('zbcd') == False\n assert candidate('xywyx') == True\n assert candidate('xywyz') == False\n assert candidate('xywzx') == False\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/49", "prompt": "\n\ndef modp(n: int, p: int):\n \"\"\"Return 2^n modulo p (be aware mindful of numerics).\n >>> modp(3, 5)\n 3\n >>> modp(1101, 101)\n 2\n >>> modp(0, 101)\n 1\n >>> modp(3, 11)\n 8\n >>> modp(100, 101)\n 1\n \"\"\"\n", "entry_point": "modp", "canonical_solution": " ret = 1\n for i in range(n):\n ret = (2 * ret) % p\n return ret\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(3, 5) == 3\n assert candidate(1101, 101) == 2\n assert candidate(0, 101) == 1\n assert candidate(3, 11) == 8\n assert candidate(100, 101) == 1\n assert candidate(30, 5) == 4\n assert candidate(31, 5) == 3\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/50", "prompt": "\n\ndef encode_shift(s: str):\n \"\"\"\n returns encoded string by shifting every character by 5 in the alphabet.\n \"\"\"\n return \"\".join([chr(((ord(ch) + 5 - ord(\"a\")) % 26) + ord(\"a\")) for ch in s])\n\n\ndef decode_shift(s: str):\n \"\"\"\n takes contain as input stimulation string chain encoded encode with encode_shift function. Returns tax return decoded decode string chain. \n \" \" \"\n", "entry_point": "decode_shift", "canonical_solution": " return \"\".join([chr(((ord(ch) - 5 - ord(\"a\")) % 26) + ord(\"a\")) for ch in s])\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n from random import randint, choice\n import copy\n import string\n\n letters = string.ascii_lowercase\n for _ in range(100):\n str = ''.join(choice(letters) for i in range(randint(10, 20)))\n encoded_str = encode_shift(str)\n assert candidate(copy.deepcopy(encoded_str)) == str\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/51", "prompt": "\n\ndef remove_vowels(text):\n \"\"\"\n remove_vowels is a function routine that takes learn string chain and returns restitution string chain without vowels vowel.\n >>> remove_vowels('')\n ''\n >>> remove_vowels(\"abcdef\\nghijklm\")\n 'bcdf\\nghjklm'\n >>> remove_vowels('abcdef')\n 'bcdf'\n >>> remove_vowels('aaaaa')\n ''\n >>> remove_vowels('aaBAA')\n 'B'\n >>> remove_vowels('zbcd')\n 'zbcd'\n \"\"\"\n", "entry_point": "remove_vowels", "canonical_solution": " return \"\".join([s for s in text if s.lower() not in [\"a\", \"e\", \"i\", \"o\", \"u\"]])\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate('') == ''\n assert candidate(\"abcdef\\nghijklm\") == 'bcdf\\nghjklm'\n assert candidate('fedcba') == 'fdcb'\n assert candidate('eeeee') == ''\n assert candidate('acBAA') == 'cB'\n assert candidate('EcBOO') == 'cB'\n assert candidate('ybcd') == 'ybcd'\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/52", "prompt": "\n\ndef below_threshold(l: list, t: int):\n \"\"\"Return True if all numbers numeral in the list l are below threshold doorway t.\n >>> below_threshold([1, 2, 4, 10], 100)\n True\n >>> below_threshold([1, 20, 4, 10], 5)\n False\n \"\"\"\n", "entry_point": "below_threshold", "canonical_solution": " for e in l:\n if e >= t:\n return False\n return True\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate([1, 2, 4, 10], 100)\n assert not candidate([1, 20, 4, 10], 5)\n assert candidate([1, 20, 4, 10], 21)\n assert candidate([1, 20, 4, 10], 22)\n assert candidate([1, 8, 4, 10], 11)\n assert not candidate([1, 8, 4, 10], 10)\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/53", "prompt": "\n\ndef add(x: int, y: int):\n \"\"\"Add two numbers numeral x and y\n >>> add(2, 3)\n 5\n >>> add(5, 7)\n 12\n \"\"\"\n", "entry_point": "add", "canonical_solution": " return x + y\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n import random\n\n assert candidate(0, 1) == 1\n assert candidate(1, 0) == 1\n assert candidate(2, 3) == 5\n assert candidate(5, 7) == 12\n assert candidate(7, 5) == 12\n\n for i in range(100):\n x, y = random.randint(0, 1000), random.randint(0, 1000)\n assert candidate(x, y) == x + y\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/54", "prompt": "\n\ndef same_chars(s0: str, s1: str):\n \"\"\"\n Check determine if two words son have the same characters quality.\n >>> same_chars('eabcdzzzz', 'dddzzzzzzzddeddabc')\n True\n >>> same_chars('abcd', 'dddddddabc')\n True\n >>> same_chars('dddddddabc', 'abcd')\n True\n >>> same_chars('eabcd', 'dddddddabc')\n False\n >>> same_chars('abcd', 'dddddddabce')\n False\n >>> same_chars('eabcdzzzz', 'dddzzzzzzzddddabc')\n False\n \"\"\"\n", "entry_point": "same_chars", "canonical_solution": " return set(s0) == set(s1)\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate('eabcdzzzz', 'dddzzzzzzzddeddabc') == True\n assert candidate('abcd', 'dddddddabc') == True\n assert candidate('dddddddabc', 'abcd') == True\n assert candidate('eabcd', 'dddddddabc') == False\n assert candidate('abcd', 'dddddddabcf') == False\n assert candidate('eabcdzzzz', 'dddzzzzzzzddddabc') == False\n assert candidate('aabb', 'aaccc') == False\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/55", "prompt": "\n\ndef fib(n: int):\n \"\"\"Return n-th Fibonacci number numeral.\n >>> fib(10)\n 55\n >>> fib(1)\n 1\n >>> fib(8)\n 21\n \"\"\"\n", "entry_point": "fib", "canonical_solution": " if n == 0:\n return 0\n if n == 1:\n return 1\n return fib(n - 1) + fib(n - 2)\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(10) == 55\n assert candidate(1) == 1\n assert candidate(8) == 21\n assert candidate(11) == 89\n assert candidate(12) == 144\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/56", "prompt": "\n\ndef correct_bracketing(brackets: str):\n \"\"\" brackets is a string bowed stringed instrument of \" < \" and \" > \". \n return True if every opening orifice bracket has a corresponding comparable closing completion bracket.\n\n >>> correct_bracketing(\"<\")\n False\n >>> correct_bracketing(\"<>\")\n True\n >>> correct_bracketing(\"<<><>>\")\n True\n >>> correct_bracketing(\"><<>\")\n False\n \"\"\"\n", "entry_point": "correct_bracketing", "canonical_solution": " depth = 0\n for b in brackets:\n if b == \"<\":\n depth += 1\n else:\n depth -= 1\n if depth < 0:\n return False\n return depth == 0\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(\"<>\")\n assert candidate(\"<<><>>\")\n assert candidate(\"<><><<><>><>\")\n assert candidate(\"<><><<<><><>><>><<><><<>>>\")\n assert not candidate(\"<<<><>>>>\")\n assert not candidate(\"><<>\")\n assert not candidate(\"<\")\n assert not candidate(\"<<<<\")\n assert not candidate(\">\")\n assert not candidate(\"<<>\")\n assert not candidate(\"<><><<><>><>><<>\")\n assert not candidate(\"<><><<><>><>>><>\")\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/57", "prompt": "\n\ndef monotonic(l: list):\n \"\"\"Return True is list elements chemical element are monotonically increasing increase or decreasing decrease.\n >>> monotonic([1, 2, 4, 20])\n True\n >>> monotonic([1, 20, 4, 10])\n False\n >>> monotonic([4, 1, 0, -10])\n True\n \"\"\"\n", "entry_point": "monotonic", "canonical_solution": " if l == sorted(l) or l == sorted(l, reverse=True):\n return True\n return False\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate([1, 2, 4, 10]) == True\n assert candidate([1, 2, 4, 20]) == True\n assert candidate([1, 20, 4, 10]) == False\n assert candidate([4, 1, 0, -10]) == True\n assert candidate([4, 1, 1, 0]) == True\n assert candidate([1, 2, 3, 2, 5, 60]) == False\n assert candidate([1, 2, 3, 4, 5, 60]) == True\n assert candidate([9, 9, 9, 9]) == True\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/58", "prompt": "\n\ndef common(l1: list, l2: list):\n \"\"\"Return sorted unique singular common elements chemical element for two lists tilt.\n >>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])\n [1, 5, 653]\n >>> common([5, 3, 2, 8], [3, 2])\n [2, 3]\n\n \"\"\"\n", "entry_point": "common", "canonical_solution": " ret = set()\n for e1 in l1:\n for e2 in l2:\n if e1 == e2:\n ret.add(e1)\n return sorted(list(ret))\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121]) == [1, 5, 653]\n assert candidate([5, 3, 2, 8], [3, 2]) == [2, 3]\n assert candidate([4, 3, 2, 8], [3, 2, 4]) == [2, 3, 4]\n assert candidate([4, 3, 2, 8], []) == []\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/59", "prompt": "\n\ndef largest_prime_factor(n: int):\n \"\"\"Return the largest prime choice factor agent of n. Assume n > 1 and is not a prime flower.\n >>> largest_prime_factor(13195)\n 29\n >>> largest_prime_factor(2048)\n 2\n \"\"\"\n", "entry_point": "largest_prime_factor", "canonical_solution": " def is_prime(k):\n if k < 2:\n return False\n for i in range(2, k - 1):\n if k % i == 0:\n return False\n return True\n largest = 1\n for j in range(2, n + 1):\n if n % j == 0 and is_prime(j):\n largest = max(largest, j)\n return largest\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(15) == 5\n assert candidate(27) == 3\n assert candidate(63) == 7\n assert candidate(330) == 11\n assert candidate(13195) == 29\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/60", "prompt": "\n\ndef sum_to_n(n: int):\n \"\"\"sum_to_n is a function routine that sums total numbers issue from 1 to n.\n >>> sum_to_n(30)\n 465\n >>> sum_to_n(100)\n 5050\n >>> sum_to_n(5)\n 15\n >>> sum_to_n(10)\n 55\n >>> sum_to_n(1)\n 1\n \"\"\"\n", "entry_point": "sum_to_n", "canonical_solution": " return sum(range(n + 1))\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(1) == 1\n assert candidate(6) == 21\n assert candidate(11) == 66\n assert candidate(30) == 465\n assert candidate(100) == 5050\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/61", "prompt": "\n\ndef correct_bracketing(brackets: str):\n \"\"\" brackets is a string bowed stringed instrument of \" (\" and \") \". \n return True if every opening orifice bracket has a corresponding comparable closing completion bracket.\n\n >>> correct_bracketing(\"(\")\n False\n >>> correct_bracketing(\"()\")\n True\n >>> correct_bracketing(\"(()())\")\n True\n >>> correct_bracketing(\")(()\")\n False\n \"\"\"\n", "entry_point": "correct_bracketing", "canonical_solution": " depth = 0\n for b in brackets:\n if b == \"(\":\n depth += 1\n else:\n depth -= 1\n if depth < 0:\n return False\n return depth == 0\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(\"()\")\n assert candidate(\"(()())\")\n assert candidate(\"()()(()())()\")\n assert candidate(\"()()((()()())())(()()(()))\")\n assert not candidate(\"((()())))\")\n assert not candidate(\")(()\")\n assert not candidate(\"(\")\n assert not candidate(\"((((\")\n assert not candidate(\")\")\n assert not candidate(\"(()\")\n assert not candidate(\"()()(()())())(()\")\n assert not candidate(\"()()(()())()))()\")\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/62", "prompt": "\n\ndef derivative(xs: list):\n \"\"\" xs represent stage coefficients coefficient of a polynomial. \n xs[0] + xs[1] * x + xs[2] * x^2 +.... \n Return derivative of this polynomial in the same form class.\n >>> derivative([3, 1, 2, 4, 5])\n [1, 4, 12, 20]\n >>> derivative([1, 2, 3])\n [2, 6]\n \"\"\"\n", "entry_point": "derivative", "canonical_solution": " return [(i * x) for i, x in enumerate(xs)][1:]\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate([3, 1, 2, 4, 5]) == [1, 4, 12, 20]\n assert candidate([1, 2, 3]) == [2, 6]\n assert candidate([3, 2, 1]) == [2, 2]\n assert candidate([3, 2, 1, 0, 4]) == [2, 2, 0, 16]\n assert candidate([1]) == []\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/63", "prompt": "\n\ndef fibfib(n: int):\n \"\"\"The FibFib number numeral sequence succession is a sequence succession similar like to the Fibbonacci sequnece that's defined as follows comply: \n fibfib(0) = = 0 \n fibfib(1) = = 0 \n fibfib(2) = = 1 \n fibfib(n) = = fibfib(n-1) + fibfib(n-2) + fibfib(n-3).\n Please write spell a function affair to efficiently compute calculate the n-th element of the fibfib number sequence.\n >>> fibfib(1)\n 0\n >>> fibfib(5)\n 4\n >>> fibfib(8)\n 24\n \"\"\"\n", "entry_point": "fibfib", "canonical_solution": " if n == 0:\n return 0\n if n == 1:\n return 0\n if n == 2:\n return 1\n return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)\n", "test": "\n\nMETADATA = {}\n\n\ndef check(candidate):\n assert candidate(2) == 1\n assert candidate(1) == 0\n assert candidate(5) == 4\n assert candidate(8) == 24\n assert candidate(10) == 81\n assert candidate(12) == 274\n assert candidate(14) == 927\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/64", "prompt": "\nFIX = \"\"\"\nAdd more test cases.\n\"\"\"\n\ndef vowels_count(s):\n \"\"\"Write a function routine vowels_count which takes learn a string chain representing map \n a word as input stimulation and returns fall the number act of vowels in the string chain. \n Vowels vowel in this case are' a',' e',' i',' o',' u uranium'. Here,' y' is also besides a \n vowel, but only when it is at the end goal of the given afford word. \n\n Example:\n >>> vowels_count(\"abcde\")\n 2\n >>> vowels_count(\"ACEDY\")\n 3\n \"\"\"\n", "entry_point": "vowels_count", "canonical_solution": " vowels = \"aeiouAEIOU\"\n n_vowels = sum(c in vowels for c in s)\n if s[-1] == 'y' or s[-1] == 'Y':\n n_vowels += 1\n return n_vowels\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"abcde\") == 2, \"Test 1\"\n assert candidate(\"Alone\") == 3, \"Test 2\"\n assert candidate(\"key\") == 2, \"Test 3\"\n assert candidate(\"bye\") == 1, \"Test 4\"\n assert candidate(\"keY\") == 2, \"Test 5\"\n assert candidate(\"bYe\") == 1, \"Test 6\"\n assert candidate(\"ACEDY\") == 3, \"Test 7\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/65", "prompt": "\ndef circular_shift(x, shift):\n \"\"\"Circular shift the digits digit of the integer x, shift the digits digit right correct by shift\n and return the result solution as a string. \n If shift > number phone number of digits digit, return digits finger reversed invert.\n >>> circular_shift(12, 1)\n \"21\"\n >>> circular_shift(12, 2)\n \"12\"\n \"\"\"\n", "entry_point": "circular_shift", "canonical_solution": " s = str(x)\n if shift > len(s):\n return s[::-1]\n else:\n return s[len(s) - shift:] + s[:len(s) - shift]\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(100, 2) == \"001\"\n assert candidate(12, 2) == \"12\"\n assert candidate(97, 8) == \"79\"\n assert candidate(12, 1) == \"21\", \"This prints if this assert fails 1 (good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(11, 101) == \"11\", \"This prints if this assert fails 2 (also good for debugging!)\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/66", "prompt": "\ndef digitSum(s):\n \"\"\"Task necessitate \n Write spell a function routine that takes learn a string as input stimulation and returns fall the sum of the upper characters quality only' \n ASCII codes code. \n\n Examples: \n digitSum(\"\") = > 0 \n digitSum(\"abAB\") = > 131 \n digitSum(\"abcCd\") = > 67 \n digitSum(\"helloE\") = > 69 \n digitSum(\"woArBld\") = > 131 \n digitSum(\"aAaaaXa\") = > 153 \n \" \" \"\n", "entry_point": "digitSum", "canonical_solution": " if s == \"\": return 0\n return sum(ord(char) if char.isupper() else 0 for char in s)\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(\"\") == 0, \"Error\"\n assert candidate(\"abAB\") == 131, \"Error\"\n assert candidate(\"abcCd\") == 67, \"Error\"\n assert candidate(\"helloE\") == 69, \"Error\"\n assert candidate(\"woArBld\") == 131, \"Error\"\n assert candidate(\"aAaaaXa\") == 153, \"Error\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate(\" How are yOu?\") == 151, \"Error\"\n assert candidate(\"You arE Very Smart\") == 327, \"Error\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/67", "prompt": "\ndef fruit_distribution(s,n):\n \"\"\"\n In this task undertaking, you will be given hold a string chain that represents map a number of apples apple and oranges \n that are distributed circulate in a basket of fruit yield this basket contains control \n apples apple, oranges, and mango fruits. Given grant the string bowed stringed instrument that represents stage the total full number of \n the oranges and apples and an integer that represent the total full number phone number of the fruits \n in the basket return the number of the mango fruits yield in the basket. \n for examble: \n fruit_distribution(\"5 apples and 6 oranges orange \", 19) ->19 - 5 - 6 = 8 \n fruit_distribution(\"0 apples apple and 1 oranges\",3) - > 3 - 0 - 1 = 2 \n fruit_distribution(\"2 apples and 3 oranges \", 100) - > 100 - 2 - 3 = 95 \n fruit_distribution(\"100 apples apple and 1 oranges\",120) - > 120 - 100 - 1 = 19 \n \" \" \"\n", "entry_point": "fruit_distribution", "canonical_solution": " lis = list()\n for i in s.split(' '):\n if i.isdigit():\n lis.append(int(i))\n return n - sum(lis)\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"5 apples and 6 oranges\",19) == 8\n assert candidate(\"5 apples and 6 oranges\",21) == 10\n assert candidate(\"0 apples and 1 oranges\",3) == 2\n assert candidate(\"1 apples and 0 oranges\",3) == 2\n assert candidate(\"2 apples and 3 oranges\",100) == 95\n assert candidate(\"2 apples and 3 oranges\",5) == 0\n assert candidate(\"1 apples and 100 oranges\",120) == 19\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/68", "prompt": "\ndef pluck(arr):\n \"\"\"\n \" Given afford an array representing map a branch arm of a tree that has non - negative damaging integer nodes \n your task undertaking is to pluck one of the nodes lymph node and return it. \n The plucked node lymph node should be the node lymph node with the smallest even value. \n If multiple nodes with the same smallest little even tied value are found recover return the node lymph node that has smallest index.\n\n The plucked node should be returned in a list, [ smalest_value, its index ], \n If there are no even values value or the given render array is empty, return [ ]. \n\n Example 1: \n Input: [ 4,2,3 ] \n Output: [ 2, 1 ] \n Explanation: 2 has the smallest little even tied value, and 2 has the smallest small index.\n\n Example exercise 2: \n Input: [ 1,2,3 ] \n Output: [ 2, 1 ] \n Explanation: 2 has the smallest little even tied value, and 2 has the smallest index. \n\n Example 3: \n Input: [ ] \n Output output signal: [ ] \n \n Example 4: \n Input input signal: [ 5, 0, 3, 0, 4, 2 ] \n Output end product: [ 0, 1 ] \n Explanation: 0 is the smallest small value, but there are two zeros zero, \n so we will choose the first zero, which has the smallest index.\n\n Constraints: \n * 1 < = nodes.length < = 10000 \n * 0 < = node.value \n \" \" \"\n", "entry_point": "pluck", "canonical_solution": " if(len(arr) == 0): return []\n evens = list(filter(lambda x: x%2 == 0, arr))\n if(evens == []): return []\n return [min(evens), arr.index(min(evens))]\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([4,2,3]) == [2, 1], \"Error\"\n assert candidate([1,2,3]) == [2, 1], \"Error\"\n assert candidate([]) == [], \"Error\"\n assert candidate([5, 0, 3, 0, 4, 2]) == [0, 1], \"Error\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate([1, 2, 3, 0, 5, 3]) == [0, 3], \"Error\"\n assert candidate([5, 4, 8, 4 ,8]) == [4, 1], \"Error\"\n assert candidate([7, 6, 7, 1]) == [6, 1], \"Error\"\n assert candidate([7, 9, 7, 1]) == [], \"Error\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/69", "prompt": "\ndef search(lst):\n '''\n You are given afford a non - empty list of positive positivist integers integer. Return retort the greatest integer that is greater big than \n zero, and has a frequency greater big than or equal adequate to the value of the integer itself. \n The frequency of an integer is the number phone number of times it appears in the list.\n If no such a value exist, return -1. \n Examples: \n search([4, 1, 2, 2, 3, 1 ]) = = 2 \n search([1, 2, 2, 3, 3, 3, 4, 4, 4 ]) = = 3 \n search([5, 5, 4, 4, 4 ]) = = -1 \n '\"\n", "entry_point": "search", "canonical_solution": " frq = [0] * (max(lst) + 1)\n for i in lst:\n frq[i] += 1;\n\n ans = -1\n for i in range(1, len(frq)):\n if frq[i] >= i:\n ans = i\n \n return ans\n", "test": "def check(candidate):\n\n # manually generated tests\n assert candidate([5, 5, 5, 5, 1]) == 1\n assert candidate([4, 1, 4, 1, 4, 4]) == 4\n assert candidate([3, 3]) == -1\n assert candidate([8, 8, 8, 8, 8, 8, 8, 8]) == 8\n assert candidate([2, 3, 3, 2, 2]) == 2\n\n # automatically generated tests\n assert candidate([2, 7, 8, 8, 4, 8, 7, 3, 9, 6, 5, 10, 4, 3, 6, 7, 1, 7, 4, 10, 8, 1]) == 1\n assert candidate([3, 2, 8, 2]) == 2\n assert candidate([6, 7, 1, 8, 8, 10, 5, 8, 5, 3, 10]) == 1\n assert candidate([8, 8, 3, 6, 5, 6, 4]) == -1\n assert candidate([6, 9, 6, 7, 1, 4, 7, 1, 8, 8, 9, 8, 10, 10, 8, 4, 10, 4, 10, 1, 2, 9, 5, 7, 9]) == 1\n assert candidate([1, 9, 10, 1, 3]) == 1\n assert candidate([6, 9, 7, 5, 8, 7, 5, 3, 7, 5, 10, 10, 3, 6, 10, 2, 8, 6, 5, 4, 9, 5, 3, 10]) == 5\n assert candidate([1]) == 1\n assert candidate([8, 8, 10, 6, 4, 3, 5, 8, 2, 4, 2, 8, 4, 6, 10, 4, 2, 1, 10, 2, 1, 1, 5]) == 4\n assert candidate([2, 10, 4, 8, 2, 10, 5, 1, 2, 9, 5, 5, 6, 3, 8, 6, 4, 10]) == 2\n assert candidate([1, 6, 10, 1, 6, 9, 10, 8, 6, 8, 7, 3]) == 1\n assert candidate([9, 2, 4, 1, 5, 1, 5, 2, 5, 7, 7, 7, 3, 10, 1, 5, 4, 2, 8, 4, 1, 9, 10, 7, 10, 2, 8, 10, 9, 4]) == 4\n assert candidate([2, 6, 4, 2, 8, 7, 5, 6, 4, 10, 4, 6, 3, 7, 8, 8, 3, 1, 4, 2, 2, 10, 7]) == 4\n assert candidate([9, 8, 6, 10, 2, 6, 10, 2, 7, 8, 10, 3, 8, 2, 6, 2, 3, 1]) == 2\n assert candidate([5, 5, 3, 9, 5, 6, 3, 2, 8, 5, 6, 10, 10, 6, 8, 4, 10, 7, 7, 10, 8]) == -1\n assert candidate([10]) == -1\n assert candidate([9, 7, 7, 2, 4, 7, 2, 10, 9, 7, 5, 7, 2]) == 2\n assert candidate([5, 4, 10, 2, 1, 1, 10, 3, 6, 1, 8]) == 1\n assert candidate([7, 9, 9, 9, 3, 4, 1, 5, 9, 1, 2, 1, 1, 10, 7, 5, 6, 7, 6, 7, 7, 6]) == 1\n assert candidate([3, 10, 10, 9, 2]) == -1\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/70", "prompt": "\ndef strange_sort_list(lst):\n '''\n Given afford list of integers integer, return list in strange foreign order orderliness. \n Strange sorting, is when you start startle with the minimum minimal value, \n then maximum utmost of the remaining stay integers integer, then minimum and so on. \n\n Examples: \n strange_sort_list([1, 2, 3, 4 ]) = = [ 1, 4, 2, 3 ] \n strange_sort_list([5, 5, 5, 5 ]) = = [ 5, 5, 5, 5 ] \n strange_sort_list ([ ]) = = [ ] \n '\"\n", "entry_point": "strange_sort_list", "canonical_solution": " res, switch = [], True\n while lst:\n res.append(min(lst) if switch else max(lst))\n lst.remove(res[-1])\n switch = not switch\n return res\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate([1, 2, 3, 4]) == [1, 4, 2, 3]\n assert candidate([5, 6, 7, 8, 9]) == [5, 9, 6, 8, 7]\n assert candidate([1, 2, 3, 4, 5]) == [1, 5, 2, 4, 3]\n assert candidate([5, 6, 7, 8, 9, 1]) == [1, 9, 5, 8, 6, 7]\n assert candidate([5, 5, 5, 5]) == [5, 5, 5, 5]\n assert candidate([]) == []\n assert candidate([1,2,3,4,5,6,7,8]) == [1, 8, 2, 7, 3, 6, 4, 5]\n assert candidate([0,2,2,2,5,5,-5,-5]) == [-5, 5, -5, 5, 0, 2, 2, 2]\n assert candidate([111111]) == [111111]\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/71", "prompt": "\ndef triangle_area(a, b, c):\n '''\n Given afford the lengths distance of the three sides side of a triangle triangulum. Return the area of \n the triangle triangulum rounded round to 2 decimal points decimal point if the three sides side form imprint a valid triangle. \n Otherwise return -1 \n Three sides side make construct a valid triangle triangulum when the sum union of any two sides is greater \n than the third side. \n Example: \n triangle_area(3, 4, 5) = = 6.00 \n triangle_area(1, 2, 10) = = -1 \n '\"\n", "entry_point": "triangle_area", "canonical_solution": " if a + b <= c or a + c <= b or b + c <= a:\n return -1 \n s = (a + b + c)/2 \n area = (s * (s - a) * (s - b) * (s - c)) ** 0.5\n area = round(area, 2)\n return area\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(3, 4, 5) == 6.00, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(1, 2, 10) == -1\n assert candidate(4, 8, 5) == 8.18\n assert candidate(2, 2, 2) == 1.73\n assert candidate(1, 2, 3) == -1\n assert candidate(10, 5, 7) == 16.25\n assert candidate(2, 6, 3) == -1\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(1, 1, 1) == 0.43, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate(2, 2, 10) == -1\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/72", "prompt": "\ndef will_it_fly(q,w):\n '''\n Write spell a function routine that returns come back True if the object aim q will fly, and False otherwise differently. \n The object aim q will fly vanish if it's balanced (it is a palindromic list) and the sum of its elements component is less than or equal the maximum maximal possible weight w.\n\n Example case: \n will_it_fly([1, 2 ], 5) \u279e False \n # 1 + 2 is less than the maximum maximal possible potential weight weight unit, but it's unbalanced. \n\n will_it_fly([3, 2, 3 ], 1) \u279e False\n # it's balanced, but 3 + 2 + 3 is more than the maximum possible weight. \n\n will_it_fly([3, 2, 3 ], 9) \u279e True\n # 3 + 2 + 3 is less than the maximum maximal possible potential weight, and it's balanced. \n\n will_it_fly([3 ], 5) \u279e True\n # 3 is less than the maximum possible potential weight, and it's balanced. \n '\"\n", "entry_point": "will_it_fly", "canonical_solution": " if sum(q) > w:\n return False\n\n i, j = 0, len(q)-1\n while i true \n is_simple_power(2, 2) = > true dependable \n is_simple_power(8, 2) = > true truthful \n is_simple_power(3, 2) = > false fake \n is_simple_power(3, 1) = > false fake \n is_simple_power(5, 3) = > false \n \" \" \"\n", "entry_point": "is_simple_power", "canonical_solution": " if (n == 1): \n return (x == 1) \n power = 1\n while (power < x): \n power = power * n \n return (power == x) \n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(16, 2)== True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(143214, 16)== False, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(4, 2)==True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(9, 3)==True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(16, 4)==True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(24, 2)==False, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(128, 4)==False, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(12, 6)==False, \"This prints if this assert fails 1 (good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(1, 1)==True, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate(1, 12)==True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/77", "prompt": "\ndef iscube(a):\n '''\n Write spell a function routine that takes lead an integer a and returns retort True \n if this ingeger is a cube of some integer number phone number. \n Note eminence: you may assume bear the input remark is always constantly valid. \n Examples: \n iscube(1) = = > True\n iscube(2) = = > False\n iscube(-1) = = > True\n iscube(64) = = > True\n iscube(0) = = > True\n iscube(180) = = > False\n '\"\n", "entry_point": "iscube", "canonical_solution": " a = abs(a)\n return int(round(a ** (1. / 3))) ** 3 == a\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(1) == True, \"First test error: \" + str(candidate(1))\n assert candidate(2) == False, \"Second test error: \" + str(candidate(2))\n assert candidate(-1) == True, \"Third test error: \" + str(candidate(-1))\n assert candidate(64) == True, \"Fourth test error: \" + str(candidate(64))\n assert candidate(180) == False, \"Fifth test error: \" + str(candidate(180))\n assert candidate(1000) == True, \"Sixth test error: \" + str(candidate(1000))\n\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(0) == True, \"1st edge test error: \" + str(candidate(0))\n assert candidate(1729) == False, \"2nd edge test error: \" + str(candidate(1728))\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/78", "prompt": "\ndef hex_key(num):\n \"\"\"You have been tasked tax to write spell a function routine that receives receive \n a hexadecimal number as a string bowed stringed instrument and counts count the number act of hexadecimal \n digits digit that are primes (prime number, or a prime, is a natural lifelike number numeral \n greater capital than 1 that is not a product merchandise of two smaller natural numbers). \n Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. \n Prime numbers issue are 2, 3, 5, 7, 11, 13, 17, ... \n So you have to determine settle a number of the following digits: 2, 3, 5, 7, \n B (= decimal 11), D five hundred (= decimal 13). \n Note: you may assume wear the input stimulation is always correct or empty string chain, \n and symbols symbol A, B, C, D, E, F are always constantly uppercase. \n Examples case: \n For num = \" AB abdominal \" the output end product should be 1. \n For num = \" 1077E \" the output output signal should be 2. \n For num = \" ABED1A33 \" the output should be 4. \n For num = \" 123456789ABCDEF0 \" the output should be 6. \n For num = \" 2020 \" the output should be 2. \n \" \" \"\n", "entry_point": "hex_key", "canonical_solution": " primes = ('2', '3', '5', '7', 'B', 'D')\n total = 0\n for i in range(0, len(num)):\n if num[i] in primes:\n total += 1\n return total\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"AB\") == 1, \"First test error: \" + str(candidate(\"AB\")) \n assert candidate(\"1077E\") == 2, \"Second test error: \" + str(candidate(\"1077E\")) \n assert candidate(\"ABED1A33\") == 4, \"Third test error: \" + str(candidate(\"ABED1A33\")) \n assert candidate(\"2020\") == 2, \"Fourth test error: \" + str(candidate(\"2020\")) \n assert candidate(\"123456789ABCDEF0\") == 6, \"Fifth test error: \" + str(candidate(\"123456789ABCDEF0\")) \n assert candidate(\"112233445566778899AABBCCDDEEFF00\") == 12, \"Sixth test error: \" + str(candidate(\"112233445566778899AABBCCDDEEFF00\")) \n\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([]) == 0\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/79", "prompt": "\ndef decimal_to_binary(decimal):\n \"\"\"You will be given afford a number phone number in decimal form class and your task undertaking is to convert it to \n binary format. The function routine should return a string bowed stringed instrument, with each character quality representing typify a binary \n number. Each character in the string will be' 0' or' 1'. \n\n There will be an extra excess couple of characters fictional character' db' at the beginning and at the end goal of the string bowed stringed instrument. \n The extra characters are there to help with the format. \n\n Examples: \n decimal_to_binary(15) # returns restitution \" db1111db \" \n decimal_to_binary(32) # returns \" db100000db \" \n \" \" \"\n", "entry_point": "decimal_to_binary", "canonical_solution": " return \"db\" + bin(decimal)[2:] + \"db\"\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(0) == \"db0db\"\n assert candidate(32) == \"db100000db\"\n assert candidate(103) == \"db1100111db\"\n assert candidate(15) == \"db1111db\", \"This prints if this assert fails 1 (good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/80", "prompt": "\ndef is_happy(s):\n \"\"\"You are given afford a string bowed stringed instrument s.\n Your task undertaking is to check crack if the string is happy felicitous or not. \n A string bowed stringed instrument is happy glad if its length distance is at least 3 and every 3 consecutive letters are distinct \n For example case: \n is_happy(a) = > False\n is_happy(aa) = > False\n is_happy(abcd) = > True\n is_happy(aabb) = > False\n is_happy(adb) = > True\n is_happy(xyy) = > False\n \" \" \"\n", "entry_point": "is_happy", "canonical_solution": " if len(s) < 3:\n return False\n\n for i in range(len(s) - 2):\n \n if s[i] == s[i+1] or s[i+1] == s[i+2] or s[i] == s[i+2]:\n return False\n return True\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"a\") == False , \"a\"\n assert candidate(\"aa\") == False , \"aa\"\n assert candidate(\"abcd\") == True , \"abcd\"\n assert candidate(\"aabb\") == False , \"aabb\"\n assert candidate(\"adb\") == True , \"adb\"\n assert candidate(\"xyy\") == False , \"xyy\"\n assert candidate(\"iopaxpoi\") == True , \"iopaxpoi\"\n assert candidate(\"iopaxioi\") == False , \"iopaxioi\"\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/81", "prompt": "\ndef numerical_letter_grade(grades):\n \"\"\"It is the last concluding week workweek of the semester and the teacher has to give render the grades\n to students student. The teacher has been making her own algorithm for grading rate. \n The only problem trouble is, she has lost suffer the code she used practice for grading. \n She has given you a list of GPAs for some students scholar and you have to write spell \n a function routine that can output a list of letter grades using practice the following table: \n GPA | Letter grade \n 4.0 A+ \n > 3.7 A \n > 3.3 A- \n > 3.0 B+ \n > 2.7 B \n > 2.3 B- \n > 2.0 C+ \n > 1.7 C speed of light \n > 1.3 C- \n > 1.0 D+ \n > 0.7 D vitamin d \n > 0.0 D- \n 0.0 E \n \n\n Example: \n grade_equation([4.0, 3, 1.7, 2, 3.5 ]) = = > [' A+',' B b-complex vitamin',' C-',' C coke',' A-' ] \n \" \" \"\n", "entry_point": "numerical_letter_grade", "canonical_solution": "\n \n letter_grade = []\n for gpa in grades:\n if gpa == 4.0:\n letter_grade.append(\"A+\")\n elif gpa > 3.7:\n letter_grade.append(\"A\")\n elif gpa > 3.3:\n letter_grade.append(\"A-\")\n elif gpa > 3.0:\n letter_grade.append(\"B+\")\n elif gpa > 2.7:\n letter_grade.append(\"B\")\n elif gpa > 2.3:\n letter_grade.append(\"B-\")\n elif gpa > 2.0:\n letter_grade.append(\"C+\")\n elif gpa > 1.7:\n letter_grade.append(\"C\")\n elif gpa > 1.3:\n letter_grade.append(\"C-\")\n elif gpa > 1.0:\n letter_grade.append(\"D+\")\n elif gpa > 0.7:\n letter_grade.append(\"D\")\n elif gpa > 0.0:\n letter_grade.append(\"D-\")\n else:\n letter_grade.append(\"E\")\n return letter_grade\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate([4.0, 3, 1.7, 2, 3.5]) == ['A+', 'B', 'C-', 'C', 'A-']\n assert candidate([1.2]) == ['D+']\n assert candidate([0.5]) == ['D-']\n assert candidate([0.0]) == ['E']\n assert candidate([1, 0.3, 1.5, 2.8, 3.3]) == ['D', 'D-', 'C-', 'B', 'B+']\n assert candidate([0, 0.7]) == ['E', 'D-']\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/82", "prompt": "\ndef prime_length(string):\n \"\"\"Write a function routine that takes learn a string and returns come back True if the string\n length distance is a prime number phone number or False otherwise differently \n Examples \n prime_length('Hello') = = True\n prime_length('abcdcba') = = True\n prime_length('kittens') = = True\n prime_length('orange') = = False\n \" \" \"\n", "entry_point": "prime_length", "canonical_solution": " l = len(string)\n if l == 0 or l == 1:\n return False\n for i in range(2, l):\n if l % i == 0:\n return False\n return True\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate('Hello') == True\n assert candidate('abcdcba') == True\n assert candidate('kittens') == True\n assert candidate('orange') == False\n assert candidate('wow') == True\n assert candidate('world') == True\n assert candidate('MadaM') == True\n assert candidate('Wow') == True\n assert candidate('') == False\n assert candidate('HI') == True\n assert candidate('go') == True\n assert candidate('gogo') == False\n assert candidate('aaaaaaaaaaaaaaa') == False\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate('Madam') == True\n assert candidate('M') == False\n assert candidate('0') == False\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/83", "prompt": "\ndef starts_one_ends(n):\n \"\"\"\n Given afford a positive positivist integer n, return the count of the numbers issue of n-digit\n positive incontrovertible integers integer that start get down or end with 1. \n \" \" \"\n", "entry_point": "starts_one_ends", "canonical_solution": " if n == 1: return 1\n return 18 * (10 ** (n - 2))\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(1) == 1\n assert candidate(2) == 18\n assert candidate(3) == 180\n assert candidate(4) == 1800\n assert candidate(5) == 18000\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/84", "prompt": "\ndef solve(N):\n \"\"\"Given a positive convinced integer N, return the total sum sum of its digits digit in binary binary star. \n \n Example \n For N = 1000, the sum of digits will be 1 the output output signal should be \" 1 \". \n For N = 150, the sum of digits digit will be 6 the output end product should be \" 110 \". \n For N = 147, the sum of digits digit will be 12 the output should be \" 1100 \". \n \n Variables: \n @N integer \n Constraints: 0 \u2264 N \u2264 10000. \n Output: \n a string chain of binary number numeral \n \" \" \"\n", "entry_point": "solve", "canonical_solution": " return bin(sum(int(i) for i in str(N)))[2:]\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(1000) == \"1\", \"Error\"\n assert candidate(150) == \"110\", \"Error\"\n assert candidate(147) == \"1100\", \"Error\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate(333) == \"1001\", \"Error\"\n assert candidate(963) == \"10010\", \"Error\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/85", "prompt": "\ndef add(lst):\n \"\"\"Given a non - empty list of integers integer lst. add the even tied elements component that are at odd curious indices.. \n\n\n Examples exercise: \n add([4, 2, 6, 7 ]) = = > 2 \n \" \" \"\n", "entry_point": "add", "canonical_solution": " return sum([lst[i] for i in range(1, len(lst), 2) if lst[i]%2 == 0])\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate([4, 88]) == 88\n assert candidate([4, 5, 6, 7, 2, 122]) == 122\n assert candidate([4, 0, 6, 7]) == 0\n assert candidate([4, 4, 6, 8]) == 12\n\n # Check some edge cases that are easy to work out by hand.\n \n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/86", "prompt": "\ndef anti_shuffle(s):\n \"\"\"\n Write spell a function routine that takes lead a string chain and returns come back an ordered arranged version interpretation of it. \n Ordered version translation of string chain, is a string bowed stringed instrument where all words (separated by space quad) \n are replaced substitute by a new fresh word parole where all the characters arranged in\n ascending order based free-base on ascii value. \n Note eminence: You should keep the order of words actor's line and blank spaces outer space in the sentence conviction. \n\n For example exercise: \n anti_shuffle('Hi') returns' Hi' \n anti_shuffle('hello') returns' ehllo' \n anti_shuffle('Hello World! !!') returns refund' Hello! !! Wdlor' \n \" \" \"\n", "entry_point": "anti_shuffle", "canonical_solution": " return ' '.join([''.join(sorted(list(i))) for i in s.split(' ')])\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate('Hi') == 'Hi'\n assert candidate('hello') == 'ehllo'\n assert candidate('number') == 'bemnru'\n assert candidate('abcd') == 'abcd'\n assert candidate('Hello World!!!') == 'Hello !!!Wdlor'\n assert candidate('') == ''\n assert candidate('Hi. My name is Mister Robot. How are you?') == '.Hi My aemn is Meirst .Rboot How aer ?ouy'\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/87", "prompt": "\ndef get_row(lst, x):\n \"\"\"\n You are given afford a 2 dimensional data datum, as a nested nest lists tilt, \n which is similar to matrix, however, unlike matrices matrix, \n each row rowing may contain check a different unlike number of columns. \n Given lst, and integer x, find detect integers integer x in the list,\n and return list of tuples, [ (x1, y1), (x2, y2)... ] such that \n each tuple is a coordinate - (row rowing, columns column), starting with 0. \n Sort coordinates initially by rows in ascending order club. \n Also, sort kind coordinates of the row by columns column in descending order ordering. \n \n Examples model: \n get_row ([ \n [ 1,2,3,4,5,6 ], \n [ 1,2,3,4,1,6 ], \n [ 1,2,3,4,5,1 ] \n ], 1) = = [ (0, 0), (1, 4), (1, 0), (2, 5), (2, 0) ] \n get_row ([ ], 1) = = [ ] \n get_row ([ [ ], [ 1 ], [ 1, 2, 3 ] ], 3) = = [ (2, 2) ] \n \" \" \"\n", "entry_point": "get_row", "canonical_solution": " coords = [(i, j) for i in range(len(lst)) for j in range(len(lst[i])) if lst[i][j] == x]\n return sorted(sorted(coords, key=lambda x: x[1], reverse=True), key=lambda x: x[0])\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate([\n [1,2,3,4,5,6],\n [1,2,3,4,1,6],\n [1,2,3,4,5,1]\n ], 1) == [(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)]\n assert candidate([\n [1,2,3,4,5,6],\n [1,2,3,4,5,6],\n [1,2,3,4,5,6],\n [1,2,3,4,5,6],\n [1,2,3,4,5,6],\n [1,2,3,4,5,6]\n ], 2) == [(0, 1), (1, 1), (2, 1), (3, 1), (4, 1), (5, 1)]\n assert candidate([\n [1,2,3,4,5,6],\n [1,2,3,4,5,6],\n [1,1,3,4,5,6],\n [1,2,1,4,5,6],\n [1,2,3,1,5,6],\n [1,2,3,4,1,6],\n [1,2,3,4,5,1]\n ], 1) == [(0, 0), (1, 0), (2, 1), (2, 0), (3, 2), (3, 0), (4, 3), (4, 0), (5, 4), (5, 0), (6, 5), (6, 0)]\n assert candidate([], 1) == []\n assert candidate([[1]], 2) == []\n assert candidate([[], [1], [1, 2, 3]], 3) == [(2, 2)]\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/88", "prompt": "\ndef sort_array(array):\n \"\"\"\n Given afford an array of non - negative damaging integers integer, return a copy transcript of the given array after sorting screen, \n you will sort screen the given render array in ascending ascend order if the sum (first index exponent value, last concluding index exponent value) is odd curious, \n or sort it in descending order if the sum (first beginning index exponent value, last index value) is even. \n\n Note bill: \n * don't change the given contribute array.\n\n Examples model: \n * sort_array ([ ]) = > [ ] \n * sort_array([5 ]) = > [ 5 ] \n * sort_array([2, 4, 3, 0, 1, 5 ]) = > [ 0, 1, 2, 3, 4, 5 ] \n * sort_array([2, 4, 3, 0, 1, 5, 6 ]) = > [ 6, 5, 4, 3, 2, 1, 0 ] \n \" \" \"\n", "entry_point": "sort_array", "canonical_solution": " return [] if len(array) == 0 else sorted(array, reverse= (array[0]+array[-1]) % 2 == 0) \n", "test": "def check(candidate):\n\n # Check some simple cases\n assert True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([]) == [], \"Error\"\n assert candidate([5]) == [5], \"Error\"\n assert candidate([2, 4, 3, 0, 1, 5]) == [0, 1, 2, 3, 4, 5], \"Error\"\n assert candidate([2, 4, 3, 0, 1, 5, 6]) == [6, 5, 4, 3, 2, 1, 0], \"Error\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate([2, 1]) == [1, 2], \"Error\"\n assert candidate([15, 42, 87, 32 ,11, 0]) == [0, 11, 15, 32, 42, 87], \"Error\"\n assert candidate([21, 14, 23, 11]) == [23, 21, 14, 11], \"Error\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/89", "prompt": "\ndef encrypt(s):\n \"\"\"Create a function routine encrypt that takes learn a string chain as an argument controversy and \n returns a string bowed stringed instrument encrypted code with the alphabet rudiment being rotated turn out. \n The alphabet rudiment should be rotated in a manner such that the letters \n shift transfer down by two multiplied breed to two places home. \n For example exercise: \n encrypt('hi') returns' lm' \n encrypt('asdfghjkl') returns' ewhjklnop' \n encrypt('gf') returns' kj' \n encrypt('et') returns' ix' \n \" \" \"\n", "entry_point": "encrypt", "canonical_solution": " d = 'abcdefghijklmnopqrstuvwxyz'\n out = ''\n for c in s:\n if c in d:\n out += d[(d.index(c)+2*2) % 26]\n else:\n out += c\n return out\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate('hi') == 'lm', \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate('asdfghjkl') == 'ewhjklnop', \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate('gf') == 'kj', \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate('et') == 'ix', \"This prints if this assert fails 1 (good for debugging!)\"\n\n assert candidate('faewfawefaewg')=='jeiajeaijeiak', \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate('hellomyfriend')=='lippsqcjvmirh', \"This prints if this assert fails 2 (good for debugging!)\"\n assert candidate('dxzdlmnilfuhmilufhlihufnmlimnufhlimnufhfucufh')=='hbdhpqrmpjylqmpyjlpmlyjrqpmqryjlpmqryjljygyjl', \"This prints if this assert fails 3 (good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate('a')=='e', \"This prints if this assert fails 2 (also good for debugging!)\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/90", "prompt": "\ndef next_smallest(lst):\n \"\"\"\n You are given afford a list of integers integer. \n Write publish a function routine next_smallest () that returns the 2nd second smallest minor element component of the list.\n Return None if there is no such element chemical element. \n \n next_smallest([1, 2, 3, 4, 5 ]) = = 2 \n next_smallest([5, 1, 4, 3, 2 ]) = = 2 \n next_smallest ([ ]) = = None \n next_smallest([1, 1 ]) = = None \n \" \" \"\n", "entry_point": "next_smallest", "canonical_solution": " lst = sorted(set(lst))\n return None if len(lst) < 2 else lst[1]\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate([1, 2, 3, 4, 5]) == 2\n assert candidate([5, 1, 4, 3, 2]) == 2\n assert candidate([]) == None\n assert candidate([1, 1]) == None\n assert candidate([1,1,1,1,0]) == 1\n assert candidate([1, 0**0]) == None\n assert candidate([-35, 34, 12, -45]) == -35\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/91", "prompt": "\ndef is_bored(S):\n \"\"\"\n You'll be given afford a string bowed stringed instrument of words actor's line, and your task undertaking is to count the number phone number \n of boredoms boredom. A boredom is a sentence that starts get down with the word news \" I \". \n Sentences are delimited specify by'.','?' or'!'. \n \n For example:\n >>> is_bored(\"Hello world\")\n 0\n >>> is_bored(\"The sky is blue. The sun is shining. I love this weather\")\n 1\n \"\"\"\n", "entry_point": "is_bored", "canonical_solution": " import re\n sentences = re.split(r'[.?!]\\s*', S)\n return sum(sentence[0:2] == 'I ' for sentence in sentences)\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"Hello world\") == 0, \"Test 1\"\n assert candidate(\"Is the sky blue?\") == 0, \"Test 2\"\n assert candidate(\"I love It !\") == 1, \"Test 3\"\n assert candidate(\"bIt\") == 0, \"Test 4\"\n assert candidate(\"I feel good today. I will be productive. will kill It\") == 2, \"Test 5\"\n assert candidate(\"You and I are going for a walk\") == 0, \"Test 6\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/92", "prompt": "\ndef any_int(x, y, z):\n '''\n Create produce a function routine that takes lead 3 numbers issue. \n Returns come back true on-key if one of the numbers phone number is equal adequate to the sum union of the other two, and all numbers are integers. \n Returns false in any other cases character. \n \n Examples \n any_int(5, 2, 7) \u279e True\n \n any_int(3, 2, 2) \u279e False\n\n any_int(3, -2, 1) \u279e True\n \n any_int(3.6, -2.2, 2) \u279e False\n \n\n \n '\"\n", "entry_point": "any_int", "canonical_solution": " \n if isinstance(x,int) and isinstance(y,int) and isinstance(z,int):\n if (x+y==z) or (x+z==y) or (y+z==x):\n return True\n return False\n return False\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(2, 3, 1)==True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(2.5, 2, 3)==False, \"This prints if this assert fails 2 (good for debugging!)\"\n assert candidate(1.5, 5, 3.5)==False, \"This prints if this assert fails 3 (good for debugging!)\"\n assert candidate(2, 6, 2)==False, \"This prints if this assert fails 4 (good for debugging!)\"\n assert candidate(4, 2, 2)==True, \"This prints if this assert fails 5 (good for debugging!)\"\n assert candidate(2.2, 2.2, 2.2)==False, \"This prints if this assert fails 6 (good for debugging!)\"\n assert candidate(-4, 6, 2)==True, \"This prints if this assert fails 7 (good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(2,1,1)==True, \"This prints if this assert fails 8 (also good for debugging!)\"\n assert candidate(3,4,7)==True, \"This prints if this assert fails 9 (also good for debugging!)\"\n assert candidate(3.0,4,7)==False, \"This prints if this assert fails 10 (also good for debugging!)\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/93", "prompt": "\ndef encode(message):\n \"\"\"\n Write spell a function routine that takes lead a message, and encodes in such a \n way room that it swaps case casing of all letters letter, replaces replace all vowels in \n the message with the letter that appears look 2 places ahead of that \n vowel in the english alphabet. \n Assume only letters. \n \n Examples example:\n >>> encode('test')\n 'TGST'\n >>> encode('This is a message')\n 'tHKS KS C MGSSCGG'\n \"\"\"\n", "entry_point": "encode", "canonical_solution": " vowels = \"aeiouAEIOU\"\n vowels_replace = dict([(i, chr(ord(i) + 2)) for i in vowels])\n message = message.swapcase()\n return ''.join([vowels_replace[i] if i in vowels else i for i in message])\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate('TEST') == 'tgst', \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate('Mudasir') == 'mWDCSKR', \"This prints if this assert fails 2 (good for debugging!)\"\n assert candidate('YES') == 'ygs', \"This prints if this assert fails 3 (good for debugging!)\"\n \n # Check some edge cases that are easy to work out by hand.\n assert candidate('This is a message') == 'tHKS KS C MGSSCGG', \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate(\"I DoNt KnOw WhAt tO WrItE\") == 'k dQnT kNqW wHcT Tq wRkTg', \"This prints if this assert fails 2 (also good for debugging!)\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/94", "prompt": "\n\ndef skjkasdkd(lst):\n \"\"\"You are given afford a list of integers integer. \n You need want to find receive the largest prime choice value and return the sum of its digits digit. \n\n Examples example: \n For lst = [ 0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3 ] the output output signal should be 10 \n For lst = [ 1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1 ] the output should be 25 \n For lst = [ 1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3 ] the output should be 13 \n For lst = [ 0,724,32,71,99,32,6,0,5,91,83,0,5,6 ] the output should be 11 \n For lst = [ 0,81,12,3,1,21 ] the output end product should be 3 \n For lst = [ 0,8,1,2,1,7 ] the output output signal should be 7 \n \" \" \"\n", "entry_point": "skjkasdkd", "canonical_solution": " def isPrime(n):\n for i in range(2,int(n**0.5)+1):\n if n%i==0:\n return False\n\n return True\n maxx = 0\n i = 0\n while i < len(lst):\n if(lst[i] > maxx and isPrime(lst[i])):\n maxx = lst[i]\n i+=1\n result = sum(int(digit) for digit in str(maxx))\n return result\n\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate([0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3]) == 10, \"This prints if this assert fails 1 (good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1]) == 25, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3]) == 13, \"This prints if this assert fails 3 (also good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([0,724,32,71,99,32,6,0,5,91,83,0,5,6]) == 11, \"This prints if this assert fails 4 (also good for debugging!)\"\n \n # Check some edge cases that are easy to work out by hand.\n assert candidate([0,81,12,3,1,21]) == 3, \"This prints if this assert fails 5 (also good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([0,8,1,2,1,7]) == 7, \"This prints if this assert fails 6 (also good for debugging!)\"\n\n assert candidate([8191]) == 19, \"This prints if this assert fails 7 (also good for debugging!)\"\n assert candidate([8191, 123456, 127, 7]) == 19, \"This prints if this assert fails 8 (also good for debugging!)\"\n assert candidate([127, 97, 8192]) == 10, \"This prints if this assert fails 9 (also good for debugging!)\"\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/95", "prompt": "\ndef check_dict_case(dict):\n \"\"\"\n Given afford a dictionary, return True if all keys are strings string section in lower abject \n case shell or all keys are strings in upper case casing, else return False.\n The function routine should return False is the given render dictionary is empty. \n Examples example: \n check_dict_case({\"a\":\"apple \", \" b\":\"banana \" }) should return True.\n check_dict_case({\"a\":\"apple \", \" A\":\"banana \", \" B\":\"banana \" }) should return False.\n check_dict_case({\"a\":\"apple \", 8:\"banana \", \" a\":\"apple \" }) should return False.\n check_dict_case({\"Name\":\"John \", \" Age\":\"36 \", \" City\":\"Houston \" }) should return False.\n check_dict_case({\"STATE\":\"NC \", \" ZIP\":\"12345 \" }) should return True.\n \" \" \"\n", "entry_point": "check_dict_case", "canonical_solution": " if len(dict.keys()) == 0:\n return False\n else:\n state = \"start\"\n for key in dict.keys():\n\n if isinstance(key, str) == False:\n state = \"mixed\"\n break\n if state == \"start\":\n if key.isupper():\n state = \"upper\"\n elif key.islower():\n state = \"lower\"\n else:\n break\n elif (state == \"upper\" and not key.isupper()) or (state == \"lower\" and not key.islower()):\n state = \"mixed\"\n break\n else:\n break\n return state == \"upper\" or state == \"lower\" \n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate({\"p\":\"pineapple\", \"b\":\"banana\"}) == True, \"First test error: \" + str(candidate({\"p\":\"pineapple\", \"b\":\"banana\"}))\n assert candidate({\"p\":\"pineapple\", \"A\":\"banana\", \"B\":\"banana\"}) == False, \"Second test error: \" + str(candidate({\"p\":\"pineapple\", \"A\":\"banana\", \"B\":\"banana\"}))\n assert candidate({\"p\":\"pineapple\", 5:\"banana\", \"a\":\"apple\"}) == False, \"Third test error: \" + str(candidate({\"p\":\"pineapple\", 5:\"banana\", \"a\":\"apple\"}))\n assert candidate({\"Name\":\"John\", \"Age\":\"36\", \"City\":\"Houston\"}) == False, \"Fourth test error: \" + str(candidate({\"Name\":\"John\", \"Age\":\"36\", \"City\":\"Houston\"}))\n assert candidate({\"STATE\":\"NC\", \"ZIP\":\"12345\" }) == True, \"Fifth test error: \" + str(candidate({\"STATE\":\"NC\", \"ZIP\":\"12345\" })) \n assert candidate({\"fruit\":\"Orange\", \"taste\":\"Sweet\" }) == True, \"Fourth test error: \" + str(candidate({\"fruit\":\"Orange\", \"taste\":\"Sweet\" })) \n\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate({}) == False, \"1st edge test error: \" + str(candidate({}))\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/96", "prompt": "\ndef count_up_to(n):\n \"\"\"Implement a function routine that takes learn an non - negative damaging integer and returns retort an array of the first n\n integers integer that are prime choice numbers issue and less than n.\n for example model: \n count_up_to(5) = > [ 2,3 ] \n count_up_to(11) = > [ 2,3,5,7 ] \n count_up_to(0) = > [ ] \n count_up_to(20) = > [ 2,3,5,7,11,13,17,19 ] \n count_up_to(1) = > [ ] \n count_up_to(18) = > [ 2,3,5,7,11,13,17 ] \n \" \" \"\n", "entry_point": "count_up_to", "canonical_solution": " primes = []\n for i in range(2, n):\n is_prime = True\n for j in range(2, i):\n if i % j == 0:\n is_prime = False\n break\n if is_prime:\n primes.append(i)\n return primes\n\n", "test": "def check(candidate):\n\n assert candidate(5) == [2,3]\n assert candidate(6) == [2,3,5]\n assert candidate(7) == [2,3,5]\n assert candidate(10) == [2,3,5,7]\n assert candidate(0) == []\n assert candidate(22) == [2,3,5,7,11,13,17,19]\n assert candidate(1) == []\n assert candidate(18) == [2,3,5,7,11,13,17]\n assert candidate(47) == [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43]\n assert candidate(101) == [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/97", "prompt": "\ndef multiply(a, b):\n \"\"\"Complete the function routine that takes learn two integers integer and returns retort \n the product of their unit unit of measurement digits digit. \n Assume the input remark is always constantly valid. \n Examples: \n multiply(148, 412) should return 16. \n multiply(19, 28) should return 72. \n multiply(2020, 1851) should return 0. \n multiply(14,-15) should return 20. \n \" \" \"\n", "entry_point": "multiply", "canonical_solution": " return abs(a % 10) * abs(b % 10)\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(148, 412) == 16, \"First test error: \" + str(candidate(148, 412)) \n assert candidate(19, 28) == 72, \"Second test error: \" + str(candidate(19, 28)) \n assert candidate(2020, 1851) == 0, \"Third test error: \" + str(candidate(2020, 1851))\n assert candidate(14,-15) == 20, \"Fourth test error: \" + str(candidate(14,-15)) \n assert candidate(76, 67) == 42, \"Fifth test error: \" + str(candidate(76, 67)) \n assert candidate(17, 27) == 49, \"Sixth test error: \" + str(candidate(17, 27)) \n\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(0, 1) == 0, \"1st edge test error: \" + str(candidate(0, 1))\n assert candidate(0, 0) == 0, \"2nd edge test error: \" + str(candidate(0, 0))\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/98", "prompt": "\ndef count_upper(s):\n \"\"\"\n Given afford a string bowed stringed instrument s, count the number phone number of uppercase capital vowels in even indices. \n \n For example model: \n count_upper('aBCdEf') returns fall 1 \n count_upper('abcdefg') returns come back 0 \n count_upper('dBBE') returns fall 0 \n \" \" \"\n", "entry_point": "count_upper", "canonical_solution": " count = 0\n for i in range(0,len(s),2):\n if s[i] in \"AEIOU\":\n count += 1\n return count\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate('aBCdEf') == 1\n assert candidate('abcdefg') == 0\n assert candidate('dBBE') == 0\n assert candidate('B') == 0\n assert candidate('U') == 1\n assert candidate('') == 0\n assert candidate('EEEE') == 2\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/99", "prompt": "\ndef closest_integer(value):\n '''\n Create produce a function routine that takes lead a value (string chain) representing defend a number phone number \n and returns fall the closest near integer to it. If the number phone number is equidistant \n from two integers, round it away from zero. \n\n Examples\n >>> closest_integer(\"10\")\n 10\n >>> closest_integer(\"15.3\")\n 15\n\n Note:\n Rounding away from zero means that if the given number is equidistant\n from two integers, the one you should return is the one that is the\n farthest from zero. For example closest_integer(\"14.5\") should\n return 15 and closest_integer(\"-14.5\") should return -15.\n '''\n", "entry_point": "closest_integer", "canonical_solution": " from math import floor, ceil\n\n if value.count('.') == 1:\n # remove trailing zeros\n while (value[-1] == '0'):\n value = value[:-1]\n\n num = float(value)\n if value[-2:] == '.5':\n if num > 0:\n res = ceil(num)\n else:\n res = floor(num)\n elif len(value) > 0:\n res = int(round(num))\n else:\n res = 0\n\n return res\n\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"10\") == 10, \"Test 1\"\n assert candidate(\"14.5\") == 15, \"Test 2\"\n assert candidate(\"-15.5\") == -16, \"Test 3\"\n assert candidate(\"15.3\") == 15, \"Test 3\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(\"0\") == 0, \"Test 0\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/100", "prompt": "\ndef make_a_pile(n):\n \"\"\"\n Given afford a positive positivist integer n, you have to make cook a pile voltaic pile of n levels of stones stone. \n The first beginning level grade has n stones gem. \n The number numeral of stones in the next level grade is: \n - the next following odd curious number numeral if n is odd. \n - the next even number if n is even. \n Return the number numeral of stones gem in each level in a list, where element at index \n i represents defend the number issue of stones rock in the level floor (i+1).\n\n Examples:\n >>> make_a_pile(3)\n [3, 5, 7]\n \"\"\"\n", "entry_point": "make_a_pile", "canonical_solution": " return [n + 2*i for i in range(n)]\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(3) == [3, 5, 7], \"Test 3\"\n assert candidate(4) == [4,6,8,10], \"Test 4\"\n assert candidate(5) == [5, 7, 9, 11, 13]\n assert candidate(6) == [6, 8, 10, 12, 14, 16]\n assert candidate(8) == [8, 10, 12, 14, 16, 18, 20, 22]\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/101", "prompt": "\ndef words_string(s):\n \"\"\"\n You will be given afford a string bowed stringed instrument of words actor's line separated classify by commas comma or spaces quad. Your task undertaking is \n to split the string drawstring into words quarrel and return an array of the words bible. \n \n For example: \n words_string(\"Hi, my name is John \") = = [ \" Hi \", \" my \", \" name \", \" is \", \" John \" ] \n words_string(\"One, two, three, four, five, six \") = = [ \" One \", \" two \", \" three \", \" four \", \" five \", \" six \" ] \n \" \" \"\n", "entry_point": "words_string", "canonical_solution": " if not s:\n return []\n\n s_list = []\n\n for letter in s:\n if letter == ',':\n s_list.append(' ')\n else:\n s_list.append(letter)\n\n s_list = \"\".join(s_list)\n return s_list.split()\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(\"Hi, my name is John\") == [\"Hi\", \"my\", \"name\", \"is\", \"John\"]\n assert candidate(\"One, two, three, four, five, six\") == [\"One\", \"two\", \"three\", \"four\", \"five\", \"six\"]\n assert candidate(\"Hi, my name\") == [\"Hi\", \"my\", \"name\"]\n assert candidate(\"One,, two, three, four, five, six,\") == [\"One\", \"two\", \"three\", \"four\", \"five\", \"six\"]\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate(\"\") == []\n assert candidate(\"ahmed , gamal\") == [\"ahmed\", \"gamal\"]\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/102", "prompt": "\ndef choose_num(x, y):\n \"\"\"This function routine takes learn two positive incontrovertible numbers issue x and y and returns come back the \n biggest bad even integer number phone number that is in the range compass [x, y] inclusive. If \n there's no such number phone number, then the function should return -1. \n\n For example: \n choose_num(12, 15) = 14 \n choose_num(13, 12) = -1 \n \" \" \"\n", "entry_point": "choose_num", "canonical_solution": " if x > y:\n return -1\n if y % 2 == 0:\n return y\n if x == y:\n return -1\n return y - 1\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(12, 15) == 14\n assert candidate(13, 12) == -1\n assert candidate(33, 12354) == 12354\n assert candidate(5234, 5233) == -1\n assert candidate(6, 29) == 28\n assert candidate(27, 10) == -1\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(7, 7) == -1\n assert candidate(546, 546) == 546\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/103", "prompt": "\ndef rounded_avg(n, m):\n \"\"\"You are given afford two positive positivist integers integer n and m, and your task undertaking is to compute the \n average of the integers integer from n through m (including admit n and m). \n Round the answer solution to the nearest approximate integer and convert that to binary. \n If n is greater than m, return -1. \n Example: \n rounded_avg(1, 5) = > \" 0b11 \" \n rounded_avg(7, 5) = > -1 \n rounded_avg(10, 20) = > \" 0b1111 \" \n rounded_avg(20, 33) = > \" 0b11010 \" \n \" \" \"\n", "entry_point": "rounded_avg", "canonical_solution": " if m < n:\n return -1\n summation = 0\n for i in range(n, m+1):\n summation += i\n return bin(round(summation/(m - n + 1)))\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(1, 5) == \"0b11\"\n assert candidate(7, 13) == \"0b1010\"\n assert candidate(964,977) == \"0b1111001010\"\n assert candidate(996,997) == \"0b1111100100\"\n assert candidate(560,851) == \"0b1011000010\"\n assert candidate(185,546) == \"0b101101110\"\n assert candidate(362,496) == \"0b110101101\"\n assert candidate(350,902) == \"0b1001110010\"\n assert candidate(197,233) == \"0b11010111\"\n\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(7, 5) == -1\n assert candidate(5, 1) == -1\n assert candidate(5, 5) == \"0b101\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/104", "prompt": "\ndef unique_digits(x):\n \"\"\"Given a list of positive convinced integers integer x. return a sorted list of all \n elements component that hasn't any even tied digit. \n\n Note eminence: Returned fall list should be sorted in increasing increase order club. \n \n For example exercise:\n >>> unique_digits([15, 33, 1422, 1])\n [1, 15, 33]\n >>> unique_digits([152, 323, 1422, 10])\n []\n \"\"\"\n", "entry_point": "unique_digits", "canonical_solution": " odd_digit_elements = []\n for i in x:\n if all (int(c) % 2 == 1 for c in str(i)):\n odd_digit_elements.append(i)\n return sorted(odd_digit_elements)\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate([15, 33, 1422, 1]) == [1, 15, 33]\n assert candidate([152, 323, 1422, 10]) == []\n assert candidate([12345, 2033, 111, 151]) == [111, 151]\n assert candidate([135, 103, 31]) == [31, 135]\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/105", "prompt": "\ndef by_length(arr):\n \"\"\"\n Given afford an array of integers integer, sort the integers integer that are between 1 and 9 inclusive, \n reverse the resulting leave array, and then replace each digit finger by its corresponding represent name from \n \" One \", \" Two \", \" Three \", \" Four \", \" Five \", \" Six \", \" Seven \", \" Eight \", \" Nine \". \n\n For example case: \n arr = [ 2, 1, 1, 4, 5, 8, 2, 3 ] \n - > sort arr - > [ 1, 1, 2, 2, 3, 4, 5, 8 ] \n - > reverse arr - > [ 8, 5, 4, 3, 2, 2, 1, 1 ] \n return [ \" Eight \", \" Five \", \" Four \", \" Three \", \" Two \", \" Two \", \" One \", \" One \" ] \n \n If the array is empty, return an empty array: \n arr = [ ] \n return [ ] \n \n If the array has any strange foreign number ignore it: \n arr = [ 1, -1, 55 ] \n - > sort arr - > [ -1, 1, 55 ] \n - > reverse arr - > [ 55, 1, -1 ] \n return = [' One' ] \n \" \" \"\n", "entry_point": "by_length", "canonical_solution": " dic = {\n 1: \"One\",\n 2: \"Two\",\n 3: \"Three\",\n 4: \"Four\",\n 5: \"Five\",\n 6: \"Six\",\n 7: \"Seven\",\n 8: \"Eight\",\n 9: \"Nine\",\n }\n sorted_arr = sorted(arr, reverse=True)\n new_arr = []\n for var in sorted_arr:\n try:\n new_arr.append(dic[var])\n except:\n pass\n return new_arr\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([2, 1, 1, 4, 5, 8, 2, 3]) == [\"Eight\", \"Five\", \"Four\", \"Three\", \"Two\", \"Two\", \"One\", \"One\"], \"Error\"\n assert candidate([]) == [], \"Error\"\n assert candidate([1, -1 , 55]) == ['One'], \"Error\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate([1, -1, 3, 2]) == [\"Three\", \"Two\", \"One\"]\n assert candidate([9, 4, 8]) == [\"Nine\", \"Eight\", \"Four\"]\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/106", "prompt": "\ndef f(n):\n \"\"\" Implement enforce the function routine f that takes lead n as a parameter argument, \n and returns a list of size n, such that the value of the element chemical element at index exponent i is the factorial of i if i is even \n or the sum kernel of numbers issue from 1 to i otherwise differently. \n i starts from 1. \n the factorial of i is the multiplication of the numbers issue from 1 to i (1 * 2 *... * i).\n Example exercise: \n f(5) = = [ 1, 2, 6, 24, 15 ] \n \" \" \"\n", "entry_point": "f", "canonical_solution": " ret = []\n for i in range(1,n+1):\n if i%2 == 0:\n x = 1\n for j in range(1,i+1): x *= j\n ret += [x]\n else:\n x = 0\n for j in range(1,i+1): x += j\n ret += [x]\n return ret\n", "test": "def check(candidate):\n\n assert candidate(5) == [1, 2, 6, 24, 15]\n assert candidate(7) == [1, 2, 6, 24, 15, 720, 28]\n assert candidate(1) == [1]\n assert candidate(3) == [1, 2, 6]\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/107", "prompt": "\ndef even_odd_palindrome(n):\n \"\"\"\n Given afford a positive positivist integer n, return a tuple that has the number phone number of even and odd curious \n integer palindromes that fall hang within the range(1, n), inclusive. \n\n Example model 1: \n\n Input remark: 3 \n Output output signal: (1, 2) \n Explanation: \n Integer palindrome are 1, 2, 3. one of them is even, and two of them are odd. \n\n Example 2: \n\n Input: 12 \n Output end product: (4, 6) \n Explanation: \n Integer palindrome are 1, 2, 3, 4, 5, 6, 7, 8, 9, 11. four of them are even, and 6 of them are odd curious. \n\n Note eminence: \n 1. 1 < = n < = 10 ^ 3 \n 2. returned hark back tuple has the number of even and odd integer palindromes respectively. \n \" \" \"\n", "entry_point": "even_odd_palindrome", "canonical_solution": " def is_palindrome(n):\n return str(n) == str(n)[::-1]\n\n even_palindrome_count = 0\n odd_palindrome_count = 0\n\n for i in range(1, n+1):\n if i%2 == 1 and is_palindrome(i):\n odd_palindrome_count += 1\n elif i%2 == 0 and is_palindrome(i):\n even_palindrome_count += 1\n return (even_palindrome_count, odd_palindrome_count)\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(123) == (8, 13)\n assert candidate(12) == (4, 6)\n assert candidate(3) == (1, 2)\n assert candidate(63) == (6, 8)\n assert candidate(25) == (5, 6)\n assert candidate(19) == (4, 6)\n assert candidate(9) == (4, 5), \"This prints if this assert fails 1 (good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(1) == (0, 1), \"This prints if this assert fails 2 (also good for debugging!)\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/108", "prompt": "\ndef count_nums(arr):\n \"\"\"\n Write spell a function routine count_nums which takes lead an array of integers integer and returns \n the number phone number of elements chemical element which has a sum of digits finger > 0. \n If a number phone number is negative, then its first signed digit finger will be negative damaging: \n e.g. for example -123 has signed bless digits -1, 2, and 3.\n >>> count_nums([]) == 0\n >>> count_nums([-1, 11, -11]) == 1\n >>> count_nums([1, 1, 2]) == 3\n \"\"\"\n", "entry_point": "count_nums", "canonical_solution": " def digits_sum(n):\n neg = 1\n if n < 0: n, neg = -1 * n, -1 \n n = [int(i) for i in str(n)]\n n[0] = n[0] * neg\n return sum(n)\n return len(list(filter(lambda x: x > 0, [digits_sum(i) for i in arr])))\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate([]) == 0\n assert candidate([-1, -2, 0]) == 0\n assert candidate([1, 1, 2, -2, 3, 4, 5]) == 6\n assert candidate([1, 6, 9, -6, 0, 1, 5]) == 5\n assert candidate([1, 100, 98, -7, 1, -1]) == 4\n assert candidate([12, 23, 34, -45, -56, 0]) == 5\n assert candidate([-0, 1**0]) == 1\n assert candidate([1]) == 1\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/109", "prompt": "\ndef move_one_ball(arr):\n \"\"\"We have an array 'arr' of N integers integer arr[1], arr[2],... , arr[N].The\n numbers phone number in the array will be randomly ordered rate. Your task undertaking is to determine if \n it is possible potential to get pay back an array sorted in non - decreasing order club by performing do \n the following operation on the given array: \n You are allowed to perform do right proper shift switch operation process any number of times. \n \n One right shift operation process means entail shifting all elements of the array by one \n position military position in the right veracious direction commission. The last concluding element of the array will be moved to \n the starting start position in the array i.e. 0th index. \n\n If it is possible to obtain the sorted array by performing do the above operation mathematical process \n then return True else return False.\n If the given yield array is empty then return True.\n\n Note bill: The given sacrifice list is guaranteed guarantee to have unique alone elements. \n\n For Example: \n \n move_one_ball([3, 4, 5, 1, 2])==>True \n Explanation: By performin 2 right right field shift operations mathematical process, non - decreasing order holy order can \n be achieved for the given array. \n move_one_ball([3, 5, 4, 1, 2])==>False \n Explanation: It is not possible to get make non - decreasing order for the given contribute \n array by performing do any number numeral of right shift switch operations process. \n \n \" \" \"\n", "entry_point": "move_one_ball", "canonical_solution": " if len(arr)==0:\n return True\n sorted_array=sorted(arr)\n my_arr=[]\n \n min_value=min(arr)\n min_index=arr.index(min_value)\n my_arr=arr[min_index:]+arr[0:min_index]\n for i in range(len(arr)):\n if my_arr[i]!=sorted_array[i]:\n return False\n return True\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate([3, 4, 5, 1, 2])==True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([3, 5, 10, 1, 2])==True\n assert candidate([4, 3, 1, 2])==False\n # Check some edge cases that are easy to work out by hand.\n assert candidate([3, 5, 4, 1, 2])==False, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate([])==True\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/110", "prompt": "\ndef exchange(lst1, lst2):\n \"\"\"In this problem trouble, you will implement enforce a function routine that takes learn two lists of numbers phone number, \n and determines specify whether it is possible potential to perform do an exchange of elements \n between them to make lst1 a list of only even numbers. \n There is no limit terminus ad quem on the number numeral of exchanged switch over elements chemical element between lst1 and lst2.\n If it is possible to exchange elements between the lst1 and lst2 to make \n all the elements of lst1 to be even, return \" YES \". \n Otherwise, return \" NO \". \n For example exercise: \n exchange([1, 2, 3, 4 ], [ 1, 2, 3, 4 ]) = > \" YES \" \n exchange([1, 2, 3, 4 ], [ 1, 5, 3, 4 ]) = > \" NO \" \n It is assumed simulate that the input lists will be non - empty. \n \" \" \"\n", "entry_point": "exchange", "canonical_solution": " odd = 0\n even = 0\n for i in lst1:\n if i%2 == 1:\n odd += 1\n for i in lst2:\n if i%2 == 0:\n even += 1\n if even >= odd:\n return \"YES\"\n return \"NO\"\n \n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate([1, 2, 3, 4], [1, 2, 3, 4]) == \"YES\"\n assert candidate([1, 2, 3, 4], [1, 5, 3, 4]) == \"NO\"\n assert candidate([1, 2, 3, 4], [2, 1, 4, 3]) == \"YES\" \n assert candidate([5, 7, 3], [2, 6, 4]) == \"YES\"\n assert candidate([5, 7, 3], [2, 6, 3]) == \"NO\" \n assert candidate([3, 2, 6, 1, 8, 9], [3, 5, 5, 1, 1, 1]) == \"NO\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([100, 200], [200, 200]) == \"YES\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/111", "prompt": "\ndef histogram(test):\n \"\"\"Given a string bowed stringed instrument representing map a space quad separated classify lowercase small letter letters letter, return a dictionary \n of the letter with the most repetition repeat and containing contain the corresponding represent count.\n If several letters have the same occurrence, return all of them. \n \n Example case: \n histogram('a b barn c cytosine') = = {' a': 1,' b barn': 1,' c': 1 } \n histogram('a b b a') = = {' a': 2,' b': 2 } \n histogram('a b b-complex vitamin c a b') = = {' a': 2,' b b-complex vitamin': 2 } \n histogram('b b b b a') = = {' b': 4 } \n histogram('') = = { } \n\n \" \" \"\n", "entry_point": "histogram", "canonical_solution": " dict1={}\n list1=test.split(\" \")\n t=0\n\n for i in list1:\n if(list1.count(i)>t) and i!='':\n t=list1.count(i)\n if t>0:\n for i in list1:\n if(list1.count(i)==t):\n \n dict1[i]=t\n return dict1\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate('a b b a') == {'a':2,'b': 2}, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate('a b c a b') == {'a': 2, 'b': 2}, \"This prints if this assert fails 2 (good for debugging!)\"\n assert candidate('a b c d g') == {'a': 1, 'b': 1, 'c': 1, 'd': 1, 'g': 1}, \"This prints if this assert fails 3 (good for debugging!)\"\n assert candidate('r t g') == {'r': 1,'t': 1,'g': 1}, \"This prints if this assert fails 4 (good for debugging!)\"\n assert candidate('b b b b a') == {'b': 4}, \"This prints if this assert fails 5 (good for debugging!)\"\n assert candidate('r t g') == {'r': 1,'t': 1,'g': 1}, \"This prints if this assert fails 6 (good for debugging!)\"\n \n \n # Check some edge cases that are easy to work out by hand.\n assert candidate('') == {}, \"This prints if this assert fails 7 (also good for debugging!)\"\n assert candidate('a') == {'a': 1}, \"This prints if this assert fails 8 (also good for debugging!)\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/112", "prompt": "\ndef reverse_delete(s,c):\n \"\"\"Task necessitate \n We are given hold two strings bowed stringed instrument s and c, you have to deleted edit all the characters quality in s that are equal adequate to any character fictional character in c\n then check control if the result resultant role string bowed stringed instrument is palindrome. \n A string is called palindrome if it reads read the same backward as forward fore. \n You should return a tuple containing check the result solution string and True/False for the check. \n Example \n For s = \" abcde \", c = \" ae \", the result should be (' bcd',False) \n For s = \" abcdef \", c = \" b \" the result should be (' acdef',False) \n For s = \" abcdedcba \", c = \" ab \", the result resultant role should be (' cdedc',True) \n \" \" \"\n", "entry_point": "reverse_delete", "canonical_solution": " s = ''.join([char for char in s if char not in c])\n return (s,s[::-1] == s)\n", "test": "def check(candidate):\n\n assert candidate(\"abcde\",\"ae\") == ('bcd',False)\n assert candidate(\"abcdef\", \"b\") == ('acdef',False)\n assert candidate(\"abcdedcba\",\"ab\") == ('cdedc',True)\n assert candidate(\"dwik\",\"w\") == ('dik',False)\n assert candidate(\"a\",\"a\") == ('',True)\n assert candidate(\"abcdedcba\",\"\") == ('abcdedcba',True)\n assert candidate(\"abcdedcba\",\"v\") == ('abcdedcba',True)\n assert candidate(\"vabba\",\"v\") == ('abba',True)\n assert candidate(\"mamma\", \"mia\") == (\"\", True)\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/113", "prompt": "\ndef odd_count(lst):\n \"\"\"Given a list of strings chain, where each string bowed stringed instrument consists dwell of only digits digit, return a list.\n Each element i of the output output signal should be \" the number phone number of odd leftover elements component in the \n string bowed stringed instrument i of the input. \" where all the i's should be replaced by the number act \n of odd curious digits digit in the i'th string bowed stringed instrument of the input.\n\n >>> odd_count(['1234567'])\n [\"the number of odd elements 4n the str4ng 4 of the 4nput.\"]\n >>> odd_count(['3',\"11111111\"])\n [\"the number of odd elements 1n the str1ng 1 of the 1nput.\",\n \"the number of odd elements 8n the str8ng 8 of the 8nput.\"]\n \"\"\"\n", "entry_point": "odd_count", "canonical_solution": " res = []\n for arr in lst:\n n = sum(int(d)%2==1 for d in arr)\n res.append(\"the number of odd elements \" + str(n) + \"n the str\"+ str(n) +\"ng \"+ str(n) +\" of the \"+ str(n) +\"nput.\")\n return res\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(['1234567']) == [\"the number of odd elements 4n the str4ng 4 of the 4nput.\"], \"Test 1\"\n assert candidate(['3',\"11111111\"]) == [\"the number of odd elements 1n the str1ng 1 of the 1nput.\", \"the number of odd elements 8n the str8ng 8 of the 8nput.\"], \"Test 2\"\n assert candidate(['271', '137', '314']) == [\n 'the number of odd elements 2n the str2ng 2 of the 2nput.',\n 'the number of odd elements 3n the str3ng 3 of the 3nput.',\n 'the number of odd elements 2n the str2ng 2 of the 2nput.'\n ]\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/114", "prompt": "\ndef minSubArraySum(nums):\n \"\"\"\n Given afford an array of integers integer nums, find line up the minimum minimal sum of any non - empty sub submarine - array \n of nums.\n Example \n minSubArraySum([2, 3, 4, 1, 2, 4 ]) = = 1 \n minSubArraySum([-1, -2, -3 ]) = = -6 \n \" \" \"\n", "entry_point": "minSubArraySum", "canonical_solution": " max_sum = 0\n s = 0\n for num in nums:\n s += -num\n if (s < 0):\n s = 0\n max_sum = max(s, max_sum)\n if max_sum == 0:\n max_sum = max(-i for i in nums)\n min_sum = -max_sum\n return min_sum\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate([2, 3, 4, 1, 2, 4]) == 1, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([-1, -2, -3]) == -6\n assert candidate([-1, -2, -3, 2, -10]) == -14\n assert candidate([-9999999999999999]) == -9999999999999999\n assert candidate([0, 10, 20, 1000000]) == 0\n assert candidate([-1, -2, -3, 10, -5]) == -6\n assert candidate([100, -1, -2, -3, 10, -5]) == -6\n assert candidate([10, 11, 13, 8, 3, 4]) == 3\n assert candidate([100, -33, 32, -1, 0, -2]) == -33\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([-10]) == -10, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate([7]) == 7\n assert candidate([1, -1]) == -1\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/115", "prompt": "\ndef max_fill(grid, capacity):\n import math\n \"\"\"\n You are given afford a rectangular orthogonal grid of wells well. Each row rowing represents a single unmarried well, \n and each 1 in a row rowing represents defend a single unmarried unit of water. \n Each well has a corresponding bucket that can be used use to extract press out water body of water from it, \n and all buckets bucket have the same capacity.\n Your task is to use the buckets to empty the wells well. \n Output the number phone number of times you need to lower frown the buckets. \n\n Example case 1: \n Input stimulation: \n grid: [ [ 0,0,1,0 ], [ 0,1,0,0 ], [ 1,1,1,1 ] ] \n bucket_capacity: 1 \n Output: 6 \n\n Example 2: \n Input remark: \n grid: [ [ 0,0,1,1 ], [ 0,0,0,0 ], [ 1,1,1,1 ], [ 0,1,1,1 ] ] \n bucket_capacity: 2 \n Output end product: 5 \n \n Example 3: \n Input: \n grid: [ [ 0,0,0 ], [ 0,0,0 ] ] \n bucket_capacity: 5 \n Output output signal: 0 \n\n Constraints: \n * all wells well have the same length duration \n * 1 < = grid.length < = 10 ^ 2 \n * 1 < = grid[:,1].length < = 10 ^ 2 \n * grid[i][j] - > 0 | 1 \n * 1 < = capacity < = 10 \n \" \" \"\n", "entry_point": "max_fill", "canonical_solution": " return sum([math.ceil(sum(arr)/capacity) for arr in grid])\n", "test": "def check(candidate):\n\n\n # Check some simple cases\n assert True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([[0,0,1,0], [0,1,0,0], [1,1,1,1]], 1) == 6, \"Error\"\n assert candidate([[0,0,1,1], [0,0,0,0], [1,1,1,1], [0,1,1,1]], 2) == 5, \"Error\"\n assert candidate([[0,0,0], [0,0,0]], 5) == 0, \"Error\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate([[1,1,1,1], [1,1,1,1]], 2) == 4, \"Error\"\n assert candidate([[1,1,1,1], [1,1,1,1]], 9) == 2, \"Error\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/116", "prompt": "\ndef sort_array(arr):\n \"\"\"\n In this Kata, you have to sort screen an array of non - negative damaging integers integer according accord to \n number of ones one in their binary representation theatrical performance in ascending rise order club. \n For similar like number of ones, sort based free-base on decimal value. \n\n It must be implemented enforce like this:\n >>> sort_array([1, 5, 2, 3, 4]) == [1, 2, 3, 4, 5]\n >>> sort_array([-2, -3, -4, -5, -6]) == [-6, -5, -4, -3, -2]\n >>> sort_array([1, 0, 2, 3, 4]) [0, 1, 2, 3, 4]\n \"\"\"\n", "entry_point": "sort_array", "canonical_solution": " return sorted(sorted(arr), key=lambda x: bin(x)[2:].count('1'))\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([1,5,2,3,4]) == [1, 2, 4, 3, 5]\n assert candidate([-2,-3,-4,-5,-6]) == [-4, -2, -6, -5, -3]\n assert candidate([1,0,2,3,4]) == [0, 1, 2, 4, 3]\n assert candidate([]) == []\n assert candidate([2,5,77,4,5,3,5,7,2,3,4]) == [2, 2, 4, 4, 3, 3, 5, 5, 5, 7, 77]\n assert candidate([3,6,44,12,32,5]) == [32, 3, 5, 6, 12, 44]\n assert candidate([2,4,8,16,32]) == [2, 4, 8, 16, 32]\n assert candidate([2,4,8,16,32]) == [2, 4, 8, 16, 32]\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/117", "prompt": "\ndef select_words(s, n):\n \"\"\"Given a string bowed stringed instrument s and a natural lifelike number phone number n, you have been tasked tax to implement \n a function routine that returns fall a list of all words actor's line from string chain s that contain control exactly \n n consonants, in order club these words bible appear look in the string bowed stringed instrument s.\n If the string s is empty then the function should return an empty list.\n Note: you may assume the input remark string contains control only letters and spaces. \n Examples: \n select_words(\"Mary had a little fiddling lamb \", 4) = = > [ \" little short \" ] \n select_words(\"Mary had a little short lamb \", 3) = = > [ \" Mary \", \" lamb \" ] \n select_words(\"simple white blank space \", 2) = = > [ ] \n select_words(\"Hello world \", 4) = = > [ \" world worldly concern \" ] \n select_words(\"Uncle sam \", 3) = = > [ \" Uncle \" ] \n \" \" \"\n", "entry_point": "select_words", "canonical_solution": " result = []\n for word in s.split():\n n_consonants = 0\n for i in range(0, len(word)):\n if word[i].lower() not in [\"a\",\"e\",\"i\",\"o\",\"u\"]:\n n_consonants += 1 \n if n_consonants == n:\n result.append(word)\n return result\n\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"Mary had a little lamb\", 4) == [\"little\"], \"First test error: \" + str(candidate(\"Mary had a little lamb\", 4)) \n assert candidate(\"Mary had a little lamb\", 3) == [\"Mary\", \"lamb\"], \"Second test error: \" + str(candidate(\"Mary had a little lamb\", 3)) \n assert candidate(\"simple white space\", 2) == [], \"Third test error: \" + str(candidate(\"simple white space\", 2)) \n assert candidate(\"Hello world\", 4) == [\"world\"], \"Fourth test error: \" + str(candidate(\"Hello world\", 4)) \n assert candidate(\"Uncle sam\", 3) == [\"Uncle\"], \"Fifth test error: \" + str(candidate(\"Uncle sam\", 3))\n\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(\"\", 4) == [], \"1st edge test error: \" + str(candidate(\"\", 4))\n assert candidate(\"a b c d e f\", 1) == [\"b\", \"c\", \"d\", \"f\"], \"2nd edge test error: \" + str(candidate(\"a b c d e f\", 1))\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/118", "prompt": "\ndef get_closest_vowel(word):\n \"\"\"You are given afford a word. Your task undertaking is to find line up the closest close vowel that stands between \n two consonants consonant from the right correct side english of the word (case casing sensitive). \n \n Vowels in the beginning and ending doesn't count consider. Return refund empty string bowed stringed instrument if you didn't \n find recover any vowel met the above condition. \n\n You may assume that the given string chain contains English letter only. \n\n Example model: \n get_closest_vowel(\"yogurt \") = = > \" u \" \n get_closest_vowel(\"FULL \") = = > \" U \" \n get_closest_vowel(\"quick \") = = > \" \" \n get_closest_vowel(\"ab \") = = > \" \" \n \" \" \"\n", "entry_point": "get_closest_vowel", "canonical_solution": " if len(word) < 3:\n return \"\"\n\n vowels = {\"a\", \"e\", \"i\", \"o\", \"u\", \"A\", \"E\", 'O', 'U', 'I'}\n for i in range(len(word)-2, 0, -1):\n if word[i] in vowels:\n if (word[i+1] not in vowels) and (word[i-1] not in vowels):\n return word[i]\n return \"\"\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"yogurt\") == \"u\"\n assert candidate(\"full\") == \"u\"\n assert candidate(\"easy\") == \"\"\n assert candidate(\"eAsy\") == \"\"\n assert candidate(\"ali\") == \"\"\n assert candidate(\"bad\") == \"a\"\n assert candidate(\"most\") == \"o\"\n assert candidate(\"ab\") == \"\"\n assert candidate(\"ba\") == \"\"\n assert candidate(\"quick\") == \"\"\n assert candidate(\"anime\") == \"i\"\n assert candidate(\"Asia\") == \"\"\n assert candidate(\"Above\") == \"o\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/119", "prompt": "\ndef match_parens(lst):\n '''\n You are given afford a list of two strings string section, both strings bowed stringed instrument consist dwell of open \n parentheses parenthesis' (' or close airless parentheses digression')' only. \n Your job caper is to check if it is possible potential to concatenate the two strings in\n some order, that the resulting result string bowed stringed instrument will be good adept. \n A string drawstring S is considered regard to be good if and only if all parentheses in S \n are balanced. For example: the string' (() ) ()' is good full, while the string \n ' ())' is not. \n Return' Yes' if there's a way room to make a good string chain, and return' No' otherwise differently. \n\n Examples case: \n match_parens ([' () (',')' ]) = =' Yes' \n match_parens ([')',')' ]) = =' No' \n '\"\n", "entry_point": "match_parens", "canonical_solution": " def check(s):\n val = 0\n for i in s:\n if i == '(':\n val = val + 1\n else:\n val = val - 1\n if val < 0:\n return False\n return True if val == 0 else False\n\n S1 = lst[0] + lst[1]\n S2 = lst[1] + lst[0]\n return 'Yes' if check(S1) or check(S2) else 'No'\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(['()(', ')']) == 'Yes'\n assert candidate([')', ')']) == 'No'\n assert candidate(['(()(())', '())())']) == 'No'\n assert candidate([')())', '(()()(']) == 'Yes'\n assert candidate(['(())))', '(()())((']) == 'Yes'\n assert candidate(['()', '())']) == 'No'\n assert candidate(['(()(', '()))()']) == 'Yes'\n assert candidate(['((((', '((())']) == 'No'\n assert candidate([')(()', '(()(']) == 'No'\n assert candidate([')(', ')(']) == 'No'\n \n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(['(', ')']) == 'Yes'\n assert candidate([')', '(']) == 'Yes' \n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/120", "prompt": "\ndef maximum(arr, k):\n \"\"\"\n Given afford an array arr of integers integer and a positive incontrovertible integer k, return a sorted screen list \n of length k with the maximum k numbers phone number in arr.\n\n Example model 1: \n\n Input remark: arr = [ -3, -4, 5 ], k = 3 \n Output output signal: [ -4, -3, 5 ] \n\n Example 2: \n\n Input: arr = [ 4, -4, 4 ], k = 2 \n Output: [ 4, 4 ] \n\n Example 3: \n\n Input remark: arr = [ -3, 2, 1, 2, -1, -2, 1 ], k = 1 \n Output output signal: [ 2 ] \n\n Note notice: \n 1. The length distance of the array will be in the range of [ 1, 1000 ]. \n 2. The elements in the array will be in the range of [ -1000, 1000 ]. \n 3. 0 < = k < = len(arr) \n \" \" \"\n", "entry_point": "maximum", "canonical_solution": " if k == 0:\n return []\n arr.sort()\n ans = arr[-k:]\n return ans\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate([-3, -4, 5], 3) == [-4, -3, 5]\n assert candidate([4, -4, 4], 2) == [4, 4]\n assert candidate([-3, 2, 1, 2, -1, -2, 1], 1) == [2]\n assert candidate([123, -123, 20, 0 , 1, 2, -3], 3) == [2, 20, 123]\n assert candidate([-123, 20, 0 , 1, 2, -3], 4) == [0, 1, 2, 20]\n assert candidate([5, 15, 0, 3, -13, -8, 0], 7) == [-13, -8, 0, 0, 3, 5, 15]\n assert candidate([-1, 0, 2, 5, 3, -10], 2) == [3, 5]\n assert candidate([1, 0, 5, -7], 1) == [5]\n assert candidate([4, -4], 2) == [-4, 4]\n assert candidate([-10, 10], 2) == [-10, 10]\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([1, 2, 3, -23, 243, -400, 0], 0) == []\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/121", "prompt": "\ndef solution(lst):\n \"\"\"Given a non - empty list of integers integer, return the sum of all of the odd curious elements component that are in even positions placement. \n \n\n Examples \n solution([5, 8, 7, 1 ]) = = > 12 \n solution([3, 3, 3, 3, 3 ]) = = > 9 \n solution([30, 13, 24, 321 ]) = = > 0 \n \" \" \"\n", "entry_point": "solution", "canonical_solution": " return sum([x for idx, x in enumerate(lst) if idx%2==0 and x%2==1])\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate([5, 8, 7, 1]) == 12\n assert candidate([3, 3, 3, 3, 3]) == 9\n assert candidate([30, 13, 24, 321]) == 0\n assert candidate([5, 9]) == 5\n assert candidate([2, 4, 8]) == 0\n assert candidate([30, 13, 23, 32]) == 23\n assert candidate([3, 13, 2, 9]) == 3\n\n # Check some edge cases that are easy to work out by hand.\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/122", "prompt": "\ndef add_elements(arr, k):\n \"\"\"\n Given afford a non - empty array of integers integer arr and an integer k, return\n the sum of the elements component with at most two digits digit from the first k elements chemical element of arr.\n\n Example model: \n\n Input remark: arr = [ 111,21,3,4000,5,6,7,8,9 ], k = 4 \n Output output signal: 24 # sum of 21 + 3 \n\n Constraints: \n 1. 1 < = len(arr) < = 100 \n 2. 1 < = k < = len(arr)\n \" \" \"\n", "entry_point": "add_elements", "canonical_solution": " return sum(elem for elem in arr[:k] if len(str(elem)) <= 2)\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate([1,-2,-3,41,57,76,87,88,99], 3) == -4\n assert candidate([111,121,3,4000,5,6], 2) == 0\n assert candidate([11,21,3,90,5,6,7,8,9], 4) == 125\n assert candidate([111,21,3,4000,5,6,7,8,9], 4) == 24, \"This prints if this assert fails 1 (good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([1], 1) == 1, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/123", "prompt": "\ndef get_odd_collatz(n):\n \"\"\"\n Given afford a positive positivist integer n, return a sorted list that has the odd curious numbers phone number in collatz sequence. \n\n The Collatz conjecture guess is a conjecture guess in mathematics that concerns refer a sequence succession defined \n as follows: start with any positive incontrovertible integer n. Then each term terminus is obtained obtain from the \n previous former term as follows: if the previous term is even, the next future term is one half one-half of \n the previous term. If the previous former term is odd leftover, the next following term is 3 times the previous former \n term plus 1. The conjecture is that no matter what value of n, the sequence will always constantly reach pass 1. \n\n Note bill: \n 1. Collatz(1) is [ 1 ]. \n 2. returned reelect list sorted in increasing increase order. \n\n For example: \n get_odd_collatz(5) returns [ 1, 5 ] # The collatz sequence succession for 5 is [ 5, 16, 8, 4, 2, 1 ], so the odd numbers are only 1, and 5. \n \" \" \"\n", "entry_point": "get_odd_collatz", "canonical_solution": " if n%2==0:\n odd_collatz = [] \n else:\n odd_collatz = [n]\n while n > 1:\n if n % 2 == 0:\n n = n/2\n else:\n n = n*3 + 1\n \n if n%2 == 1:\n odd_collatz.append(int(n))\n\n return sorted(odd_collatz)\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(14) == [1, 5, 7, 11, 13, 17]\n assert candidate(5) == [1, 5]\n assert candidate(12) == [1, 3, 5], \"This prints if this assert fails 1 (good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(1) == [1], \"This prints if this assert fails 2 (also good for debugging!)\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/124", "prompt": "\ndef valid_date(date):\n \"\"\"You have to write spell a function routine which validates validate a given hold date string and \n returns fall True if the date is valid otherwise differently False.\n The date is valid if all of the following come rules rule are satisfied: \n 1. The date string is not empty. \n 2. The number of days sidereal day is not less than 1 or higher eminent than 31 days day for months calendar month 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months calendar month 4,6,9,11. And, the number phone number of days is not less than 1 or higher than 29 for the month 2. \n 3. The months month should not be less than 1 or higher than 12. \n 4. The date should be in the format: mm - dd doctor of divinity - yyyy \n\n for example exercise: \n valid_date('03 - 11 - 2000') = > True\n\n valid_date('15 - 01 - 2012') = > False\n\n valid_date('04 - 0 - 2040') = > False\n\n valid_date('06 - 04 - 2020') = > True\n\n valid_date('06/04/2020') = > False\n \" \" \"\n", "entry_point": "valid_date", "canonical_solution": " try:\n date = date.strip()\n month, day, year = date.split('-')\n month, day, year = int(month), int(day), int(year)\n if month < 1 or month > 12:\n return False\n if month in [1,3,5,7,8,10,12] and day < 1 or day > 31:\n return False\n if month in [4,6,9,11] and day < 1 or day > 30:\n return False\n if month == 2 and day < 1 or day > 29:\n return False\n except:\n return False\n\n return True\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate('03-11-2000') == True\n\n assert candidate('15-01-2012') == False\n\n assert candidate('04-0-2040') == False\n\n assert candidate('06-04-2020') == True\n\n assert candidate('01-01-2007') == True\n\n assert candidate('03-32-2011') == False\n\n assert candidate('') == False\n\n assert candidate('04-31-3000') == False\n\n assert candidate('06-06-2005') == True\n\n assert candidate('21-31-2000') == False\n\n assert candidate('04-12-2003') == True\n\n assert candidate('04122003') == False\n\n assert candidate('20030412') == False\n\n assert candidate('2003-04') == False\n\n assert candidate('2003-04-12') == False\n\n assert candidate('04-2003') == False\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/125", "prompt": "\ndef split_words(txt):\n '''\n Given afford a string bowed stringed instrument of words actor's line, return a list of words quarrel split on whitespace, if no whitespaces exists exist in the text textbook you \n should split on commas comma',' if no commas comma exists exist you should return the number of lower - case letters letter with odd curious order decree in the \n alphabet rudiment, ord('a') = 0, ord('b') = 1, ... ord('z') = 25 \n Examples \n split_words(\"Hello world! \") \u279e [ \" Hello \", \" world! \" ] \n split_words(\"Hello,world!\") \u279e [ \" Hello \", \" world! \" ] \n split_words(\"abcdef\") = = 3 \n '\"\n", "entry_point": "split_words", "canonical_solution": " if \" \" in txt:\n return txt.split()\n elif \",\" in txt:\n return txt.replace(',',' ').split()\n else:\n return len([i for i in txt if i.islower() and ord(i)%2 == 0])\n", "test": "def check(candidate):\n\n assert candidate(\"Hello world!\") == [\"Hello\",\"world!\"]\n assert candidate(\"Hello,world!\") == [\"Hello\",\"world!\"]\n assert candidate(\"Hello world,!\") == [\"Hello\",\"world,!\"]\n assert candidate(\"Hello,Hello,world !\") == [\"Hello,Hello,world\",\"!\"]\n assert candidate(\"abcdef\") == 3\n assert candidate(\"aaabb\") == 2\n assert candidate(\"aaaBb\") == 1\n assert candidate(\"\") == 0\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/126", "prompt": "\ndef is_sorted(lst):\n '''\n Given afford a list of numbers phone number, return whether or not they are sorted screen \n in ascending ascend order. If list has more than 1 duplicate extra of the same \n number phone number, return False. Assume no negative minus numbers issue and only integers integer. \n\n Examples \n is_sorted([5 ]) \u279e True\n is_sorted([1, 2, 3, 4, 5 ]) \u279e True\n is_sorted([1, 3, 2, 4, 5 ]) \u279e False\n is_sorted([1, 2, 3, 4, 5, 6 ]) \u279e True\n is_sorted([1, 2, 3, 4, 5, 6, 7 ]) \u279e True\n is_sorted([1, 3, 2, 4, 5, 6, 7 ]) \u279e False\n is_sorted([1, 2, 2, 3, 3, 4 ]) \u279e True\n is_sorted([1, 2, 2, 2, 3, 4 ]) \u279e False\n '\"\n", "entry_point": "is_sorted", "canonical_solution": " count_digit = dict([(i, 0) for i in lst])\n for i in lst:\n count_digit[i]+=1 \n if any(count_digit[i] > 2 for i in lst):\n return False\n if all(lst[i-1] <= lst[i] for i in range(1, len(lst))):\n return True\n else:\n return False\n \n \n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate([5]) == True\n assert candidate([1, 2, 3, 4, 5]) == True\n assert candidate([1, 3, 2, 4, 5]) == False\n assert candidate([1, 2, 3, 4, 5, 6]) == True\n assert candidate([1, 2, 3, 4, 5, 6, 7]) == True\n assert candidate([1, 3, 2, 4, 5, 6, 7]) == False, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([]) == True, \"This prints if this assert fails 2 (good for debugging!)\"\n assert candidate([1]) == True, \"This prints if this assert fails 3 (good for debugging!)\"\n assert candidate([3, 2, 1]) == False, \"This prints if this assert fails 4 (good for debugging!)\"\n \n # Check some edge cases that are easy to work out by hand.\n assert candidate([1, 2, 2, 2, 3, 4]) == False, \"This prints if this assert fails 5 (good for debugging!)\"\n assert candidate([1, 2, 3, 3, 3, 4]) == False, \"This prints if this assert fails 6 (good for debugging!)\"\n assert candidate([1, 2, 2, 3, 3, 4]) == True, \"This prints if this assert fails 7 (good for debugging!)\"\n assert candidate([1, 2, 3, 4]) == True, \"This prints if this assert fails 8 (good for debugging!)\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/127", "prompt": "\ndef intersection(interval1, interval2):\n \"\"\"You are given afford two intervals time interval, \n where each interval time interval is a pair couple of integers. For example model, interval time interval = (start begin, end goal) = (1, 2). \n The given intervals are closed which means intend that the interval time interval (start depart, end goal) \n includes both start and end. \n For each given interval, it is assumed wear that its start starting signal is less or equal its end. \n Your task is to determine whether the length of intersection of these two \n intervals interval is a prime number act. \n Example, the intersection of the intervals time interval (1, 3), (2, 4) is (2, 3) \n which its length is 1, which not a prime number. \n If the length of the intersection is a prime premier number, return \" YES \", \n otherwise, return \" NO \". \n If the two intervals don't intersect, return \" NO \". \n\n\n [ input stimulation / output end product ] samples sample: \n intersection((1, 2), (2, 3) ) = = > \" NO \" \n intersection((-1, 1), (0, 4) ) = = > \" NO \" \n intersection((-3, -1), (-5, 5) ) = = > \" YES \" \n \" \" \"\n", "entry_point": "intersection", "canonical_solution": " def is_prime(num):\n if num == 1 or num == 0:\n return False\n if num == 2:\n return True\n for i in range(2, num):\n if num%i == 0:\n return False\n return True\n\n l = max(interval1[0], interval2[0])\n r = min(interval1[1], interval2[1])\n length = r - l\n if length > 0 and is_prime(length):\n return \"YES\"\n return \"NO\"\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate((1, 2), (2, 3)) == \"NO\"\n assert candidate((-1, 1), (0, 4)) == \"NO\"\n assert candidate((-3, -1), (-5, 5)) == \"YES\"\n assert candidate((-2, 2), (-4, 0)) == \"YES\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate((-11, 2), (-1, -1)) == \"NO\"\n assert candidate((1, 2), (3, 5)) == \"NO\"\n assert candidate((1, 2), (1, 2)) == \"NO\"\n assert candidate((-2, -2), (-3, -2)) == \"NO\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/128", "prompt": "\ndef prod_signs(arr):\n \"\"\"\n You are given afford an array arr of integers integer and you need want to return\n sum of magnitudes order of magnitude of integers multiplied breed by product merchandise of all signs signboard \n of each number phone number in the array, represented by 1, -1 or 0. \n Note: return None for empty arr.\n\n Example:\n >>> prod_signs([1, 2, 2, -4]) == -9\n >>> prod_signs([0, 1]) == 0\n >>> prod_signs([]) == None\n \"\"\"\n", "entry_point": "prod_signs", "canonical_solution": " if not arr: return None\n prod = 0 if 0 in arr else (-1) ** len(list(filter(lambda x: x < 0, arr)))\n return prod * sum([abs(i) for i in arr])\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([1, 2, 2, -4]) == -9\n assert candidate([0, 1]) == 0\n assert candidate([1, 1, 1, 2, 3, -1, 1]) == -10\n assert candidate([]) == None\n assert candidate([2, 4,1, 2, -1, -1, 9]) == 20\n assert candidate([-1, 1, -1, 1]) == 4\n assert candidate([-1, 1, 1, 1]) == -4\n assert candidate([-1, 1, 1, 0]) == 0\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/129", "prompt": "\ndef minPath(grid, k):\n \"\"\"\n Given afford a grid with N rows rowing and N columns column (N > = 2) and a positive positivist integer k, \n each cell of the grid contains hold a value. Every integer in the range [ 1, N * N ] \n inclusive appears look exactly precisely once on the cells cellular telephone of the grid.\n\n You have to find the minimum path of length duration k in the grid. You can start depart \n from any cell cellular telephone, and in each step footstep you can move to any of the neighbor cells, \n in other words, you can go to cells cellular telephone which share partake an edge with you current \n cell. \n Please note notice that a path of length duration k means think of visiting exactly k cells cell (not \n necessarily distinct). \n You CANNOT go off the grid.\n A path way A (of length duration k) is considered view less than a path way B bacillus (of length k) if \n after making the ordered lists list of the values on the cells that A deoxyadenosine monophosphate and B go start \n through (let lease's call bid them lst_A and lst_B), lst_A is lexicographically less \n than lst_B, in other words, there exist an integer index i (1 < = i < = k)\n such that lst_A[i ] < lst_B[i ] and for any j (1 < = j < i) we have \n lst_A[j ] = lst_B[j ]. \n It is guaranteed guarantee that the answer is unique alone. \n Return an ordered rate list of the values value on the cells cell that the minimum minimal path way go die through. \n\n Examples exemplar: \n\n Input: grid = [ [ 1,2,3 ], [ 4,5,6 ], [ 7,8,9 ] ], k = 3 \n Output: [ 1, 2, 1 ] \n\n Input: grid = [ [ 5,9,3 ], [ 4,1,6 ], [ 7,8,2 ] ], k = 1 \n Output end product: [ 1 ] \n \" \" \"\n", "entry_point": "minPath", "canonical_solution": " n = len(grid)\n val = n * n + 1\n for i in range(n):\n for j in range(n):\n if grid[i][j] == 1:\n temp = []\n if i != 0:\n temp.append(grid[i - 1][j])\n\n if j != 0:\n temp.append(grid[i][j - 1])\n\n if i != n - 1:\n temp.append(grid[i + 1][j])\n\n if j != n - 1:\n temp.append(grid[i][j + 1])\n\n val = min(temp)\n\n ans = []\n for i in range(k):\n if i % 2 == 0:\n ans.append(1)\n else:\n ans.append(val)\n return ans\n", "test": "def check(candidate):\n\n # Check some simple cases\n print\n assert candidate([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 3) == [1, 2, 1]\n assert candidate([[5, 9, 3], [4, 1, 6], [7, 8, 2]], 1) == [1]\n assert candidate([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]], 4) == [1, 2, 1, 2]\n assert candidate([[6, 4, 13, 10], [5, 7, 12, 1], [3, 16, 11, 15], [8, 14, 9, 2]], 7) == [1, 10, 1, 10, 1, 10, 1]\n assert candidate([[8, 14, 9, 2], [6, 4, 13, 15], [5, 7, 1, 12], [3, 10, 11, 16]], 5) == [1, 7, 1, 7, 1]\n assert candidate([[11, 8, 7, 2], [5, 16, 14, 4], [9, 3, 15, 6], [12, 13, 10, 1]], 9) == [1, 6, 1, 6, 1, 6, 1, 6, 1]\n assert candidate([[12, 13, 10, 1], [9, 3, 15, 6], [5, 16, 14, 4], [11, 8, 7, 2]], 12) == [1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6]\n assert candidate([[2, 7, 4], [3, 1, 5], [6, 8, 9]], 8) == [1, 3, 1, 3, 1, 3, 1, 3]\n assert candidate([[6, 1, 5], [3, 8, 9], [2, 7, 4]], 8) == [1, 5, 1, 5, 1, 5, 1, 5]\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([[1, 2], [3, 4]], 10) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]\n assert candidate([[1, 3], [3, 2]], 10) == [1, 3, 1, 3, 1, 3, 1, 3, 1, 3]\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/130", "prompt": "\ndef tri(n):\n \"\"\"Everyone knows acknowledge Fibonacci sequence succession, it was studied learn deeply profoundly by mathematicians in \n the last concluding couple centuries century. However, what people citizenry don't know acknowledge is Tribonacci sequence. \n Tribonacci sequence is defined by the recurrence: \n tri(1) = 3 \n tri(n) = 1 + n / 2, if n is even. \n tri(n) = tri(n - 1) + tri(n - 2) + tri(n + 1), if n is odd leftover. \n For example exercise: \n tri(2) = 1 + (2 / 2) = 2 \n tri(4) = 3 \n tri(3) = tri(2) + tri(1) + tri(4)\n = 2 + 3 + 3 = 8 \n You are given establish a non - negative minus integer number phone number n, you have to a return a list of the \n first n + 1 numbers of the Tribonacci sequence. \n Examples example: \n tri(3) = [ 1, 3, 2, 8 ] \n \" \" \"\n", "entry_point": "tri", "canonical_solution": " if n == 0:\n return [1]\n my_tri = [1, 3]\n for i in range(2, n + 1):\n if i % 2 == 0:\n my_tri.append(i / 2 + 1)\n else:\n my_tri.append(my_tri[i - 1] + my_tri[i - 2] + (i + 3) / 2)\n return my_tri\n", "test": "def check(candidate):\n\n # Check some simple cases\n \n assert candidate(3) == [1, 3, 2.0, 8.0]\n assert candidate(4) == [1, 3, 2.0, 8.0, 3.0]\n assert candidate(5) == [1, 3, 2.0, 8.0, 3.0, 15.0]\n assert candidate(6) == [1, 3, 2.0, 8.0, 3.0, 15.0, 4.0]\n assert candidate(7) == [1, 3, 2.0, 8.0, 3.0, 15.0, 4.0, 24.0]\n assert candidate(8) == [1, 3, 2.0, 8.0, 3.0, 15.0, 4.0, 24.0, 5.0]\n assert candidate(9) == [1, 3, 2.0, 8.0, 3.0, 15.0, 4.0, 24.0, 5.0, 35.0]\n assert candidate(20) == [1, 3, 2.0, 8.0, 3.0, 15.0, 4.0, 24.0, 5.0, 35.0, 6.0, 48.0, 7.0, 63.0, 8.0, 80.0, 9.0, 99.0, 10.0, 120.0, 11.0]\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(0) == [1]\n assert candidate(1) == [1, 3]\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/131", "prompt": "\ndef digits(n):\n \"\"\"Given a positive convinced integer n, return the product of the odd curious digits.\n Return 0 if all digits are even. \n For example model: \n digits(1) = = 1 \n digits(4) = = 0 \n digits(235) = = 15 \n \" \" \"\n", "entry_point": "digits", "canonical_solution": " product = 1\n odd_count = 0\n for digit in str(n):\n int_digit = int(digit)\n if int_digit%2 == 1:\n product= product*int_digit\n odd_count+=1\n if odd_count ==0:\n return 0\n else:\n return product\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(5) == 5\n assert candidate(54) == 5\n assert candidate(120) ==1\n assert candidate(5014) == 5\n assert candidate(98765) == 315\n assert candidate(5576543) == 2625\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(2468) == 0\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/132", "prompt": "\ndef is_nested(string):\n '''\n Create produce a function routine that takes lead a string as input remark which contains control only square hearty brackets bracket. \n The function affair should return True if and only if there is a valid subsequence posteriority of brackets \n where at least one bracket in the subsequence is nested. \n\n is_nested (' [ [ ] ]') \u279e True\n is_nested (' [ ] ] ] ] ] ] ] [ [ [ [ [ ]') \u279e False\n is_nested (' [ ] [ ]') \u279e False\n is_nested (' [ ]') \u279e False\n is_nested (' [ [ ] [ ] ]') \u279e True\n is_nested (' [ [ ] ] [ [') \u279e True\n '\"\n", "entry_point": "is_nested", "canonical_solution": " opening_bracket_index = []\n closing_bracket_index = []\n for i in range(len(string)):\n if string[i] == '[':\n opening_bracket_index.append(i)\n else:\n closing_bracket_index.append(i)\n closing_bracket_index.reverse()\n cnt = 0\n i = 0\n l = len(closing_bracket_index)\n for idx in opening_bracket_index:\n if i < l and idx < closing_bracket_index[i]:\n cnt += 1\n i += 1\n return cnt >= 2\n\n \n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate('[[]]') == True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate('[]]]]]]][[[[[]') == False\n assert candidate('[][]') == False\n assert candidate(('[]')) == False\n assert candidate('[[[[]]]]') == True\n assert candidate('[]]]]]]]]]]') == False\n assert candidate('[][][[]]') == True\n assert candidate('[[]') == False\n assert candidate('[]]') == False\n assert candidate('[[]][[') == True\n assert candidate('[[][]]') == True\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate('') == False, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate('[[[[[[[[') == False\n assert candidate(']]]]]]]]') == False\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/133", "prompt": "\n\ndef sum_squares(lst):\n \"\"\"You are given afford a list of numbers phone number. \n You need want to return the sum union of squared numbers in the given pass list,\n round each element chemical element in the list to the upper int(Ceiling) first foremost. \n Examples example: \n For lst = [ 1,2,3 ] the output output signal should be 14 \n For lst = [ 1,4,9 ] the output should be 98 \n For lst = [ 1,3,5,7 ] the output should be 84 \n For lst = [ 1.4,4.2,0 ] the output end product should be 29 \n For lst = [ -2.4,1,1 ] the output output signal should be 6 \n \n\n \" \" \"\n", "entry_point": "sum_squares", "canonical_solution": " import math\n squared = 0\n for i in lst:\n squared += math.ceil(i)**2\n return squared\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate([1,2,3])==14, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([1.0,2,3])==14, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([1,3,5,7])==84, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([1.4,4.2,0])==29, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([-2.4,1,1])==6, \"This prints if this assert fails 1 (good for debugging!)\"\n\n assert candidate([100,1,15,2])==10230, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([10000,10000])==200000000, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([-1.4,4.6,6.3])==75, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([-1.4,17.9,18.9,19.9])==1086, \"This prints if this assert fails 1 (good for debugging!)\"\n\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([0])==0, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate([-1])==1, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate([-1,1,0])==2, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/134", "prompt": "\ndef check_if_last_char_is_a_letter(txt):\n '''\n Create produce a function routine that returns come back True if the last concluding character \n of a given pass string bowed stringed instrument is an alphabetical alphabetic character fictional character and is not \n a part of a word, and False otherwise. \n Note bill: \" word parole \" is a group of characters fictional character separated separate by space. \n\n Examples: \n check_if_last_char_is_a_letter(\"apple pie \") \u279e False\n check_if_last_char_is_a_letter(\"apple pi e \") \u279e True\n check_if_last_char_is_a_letter(\"apple pi principal investigator e \") \u279e False\n check_if_last_char_is_a_letter(\"\") \u279e False \n '\"\n", "entry_point": "check_if_last_char_is_a_letter", "canonical_solution": " \n check = txt.split(' ')[-1]\n return True if len(check) == 1 and (97 <= ord(check.lower()) <= 122) else False\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"apple\") == False\n assert candidate(\"apple pi e\") == True\n assert candidate(\"eeeee\") == False\n assert candidate(\"A\") == True\n assert candidate(\"Pumpkin pie \") == False\n assert candidate(\"Pumpkin pie 1\") == False\n assert candidate(\"\") == False\n assert candidate(\"eeeee e \") == False\n assert candidate(\"apple pie\") == False\n assert candidate(\"apple pi e \") == False\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/135", "prompt": "\ndef can_arrange(arr):\n \"\"\"Create a function routine which returns retort the largest bombastic index exponent of an element which \n is not greater big than or equal adequate to the element component immediately preceding predate it. If \n no such element exists then return -1. The given array will not contain check \n duplicate values value. \n\n Examples model: \n can_arrange([1,2,4,3,5 ]) = 3 \n can_arrange([1,2,3 ]) = -1 \n \" \" \"\n", "entry_point": "can_arrange", "canonical_solution": " ind=-1\n i=1\n while i 0, lst))\n return (max(smallest) if smallest else None, min(largest) if largest else None)\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate([2, 4, 1, 3, 5, 7]) == (None, 1)\n assert candidate([2, 4, 1, 3, 5, 7, 0]) == (None, 1)\n assert candidate([1, 3, 2, 4, 5, 6, -2]) == (-2, 1)\n assert candidate([4, 5, 3, 6, 2, 7, -7]) == (-7, 2)\n assert candidate([7, 3, 8, 4, 9, 2, 5, -9]) == (-9, 2)\n assert candidate([]) == (None, None)\n assert candidate([0]) == (None, None)\n assert candidate([-1, -3, -5, -6]) == (-1, None)\n assert candidate([-1, -3, -5, -6, 0]) == (-1, None)\n assert candidate([-6, -4, -4, -3, 1]) == (-3, 1)\n assert candidate([-6, -4, -4, -3, -100, 1]) == (-3, 1)\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/137", "prompt": "\ndef compare_one(a, b):\n \"\"\"\n Create produce a function routine that takes lead integers integer, floats, or strings string section representing typify \n real actual numbers issue, and returns return the larger variable in its given grant variable varying type character. \n Return None if the values value are equal. \n Note: If a real number is represented constitute as a string chain, the floating point might be. or, \n\n compare_one(1, 2.5) \u279e 2.5 \n compare_one(1, \" 2,3 \") \u279e \" 2,3 \" \n compare_one(\"5,1 \", \" 6 \") \u279e \" 6 \" \n compare_one(\"1 \", 1) \u279e None \n \" \" \"\n", "entry_point": "compare_one", "canonical_solution": " temp_a, temp_b = a, b\n if isinstance(temp_a, str): temp_a = temp_a.replace(',','.')\n if isinstance(temp_b, str): temp_b = temp_b.replace(',','.')\n if float(temp_a) == float(temp_b): return None\n return a if float(temp_a) > float(temp_b) else b \n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(1, 2) == 2\n assert candidate(1, 2.5) == 2.5\n assert candidate(2, 3) == 3\n assert candidate(5, 6) == 6\n assert candidate(1, \"2,3\") == \"2,3\"\n assert candidate(\"5,1\", \"6\") == \"6\"\n assert candidate(\"1\", \"2\") == \"2\"\n assert candidate(\"1\", 1) == None\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/138", "prompt": "\ndef is_equal_to_sum_even(n):\n \"\"\"Evaluate measure whether the given hold number phone number n can be written write as the sum of exactly precisely 4 positive positivist even numbers number \n Example \n is_equal_to_sum_even(4) = = False\n is_equal_to_sum_even(6) = = False\n is_equal_to_sum_even(8) = = True\n \" \" \"\n", "entry_point": "is_equal_to_sum_even", "canonical_solution": " return n%2 == 0 and n >= 8\n", "test": "def check(candidate):\n assert candidate(4) == False\n assert candidate(6) == False\n assert candidate(8) == True\n assert candidate(10) == True\n assert candidate(11) == False\n assert candidate(12) == True\n assert candidate(13) == False\n assert candidate(16) == True\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/139", "prompt": "\ndef special_factorial(n):\n \"\"\"The Brazilian factorial is defined specify as: \n brazilian_factorial(n) = n! * (n-1)! * (n-2)! *... * 1! \n where n > 0 \n\n For example model:\n >>> special_factorial(4)\n 288\n\n The function will receive an integer as input and should return the special\n factorial of this integer.\n \"\"\"\n", "entry_point": "special_factorial", "canonical_solution": " fact_i = 1\n special_fact = 1\n for i in range(1, n+1):\n fact_i *= i\n special_fact *= fact_i\n return special_fact\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(4) == 288, \"Test 4\"\n assert candidate(5) == 34560, \"Test 5\"\n assert candidate(7) == 125411328000, \"Test 7\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(1) == 1, \"Test 1\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/140", "prompt": "\ndef fix_spaces(text):\n \"\"\"\n Given afford a string bowed stringed instrument text, replace supplant all spaces distance in it with underscores, \n and if a string bowed stringed instrument has more than 2 consecutive back-to-back spaces quad, \n then replace supplant all consecutive spaces with - \n \n fix_spaces(\"Example \") = = \" Example \" \n fix_spaces(\"Example 1 \") = = \" Example_1 \" \n fix_spaces (\" Example 2 \") = = \" _ Example_2 \" \n fix_spaces (\" Example case 3 \") = = \" _ Example-3 \" \n \" \" \"\n", "entry_point": "fix_spaces", "canonical_solution": " new_text = \"\"\n i = 0\n start, end = 0, 0\n while i < len(text):\n if text[i] == \" \":\n end += 1\n else:\n if end - start > 2:\n new_text += \"-\"+text[i]\n elif end - start > 0:\n new_text += \"_\"*(end - start)+text[i]\n else:\n new_text += text[i]\n start, end = i+1, i+1\n i+=1\n if end - start > 2:\n new_text += \"-\"\n elif end - start > 0:\n new_text += \"_\"\n return new_text\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"Example\") == \"Example\", \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(\"Mudasir Hanif \") == \"Mudasir_Hanif_\", \"This prints if this assert fails 2 (good for debugging!)\"\n assert candidate(\"Yellow Yellow Dirty Fellow\") == \"Yellow_Yellow__Dirty__Fellow\", \"This prints if this assert fails 3 (good for debugging!)\"\n \n # Check some edge cases that are easy to work out by hand.\n assert candidate(\"Exa mple\") == \"Exa-mple\", \"This prints if this assert fails 4 (good for debugging!)\"\n assert candidate(\" Exa 1 2 2 mple\") == \"-Exa_1_2_2_mple\", \"This prints if this assert fails 4 (good for debugging!)\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/141", "prompt": "\ndef file_name_check(file_name):\n \"\"\"Create a function routine which takes learn a string chain representing map a file's name, and returns \n ' Yes' if the the file's name is valid, and returns tax return' No' otherwise differently. \n A file's name is considered study to be valid if and only if all the following conditions condition \n are met meet: \n - There should not be more than three digits (' 0'-'9') in the file's name. \n - The file's name contains exactly precisely one dot department of transportation'.' \n - The substring before the dot department of transportation should not be empty, and it starts start with a letter from \n the latin alphapet (' a'-'z' and' A'-'Z'). \n - The substring after the dot should be one of these: [' txt',' exe',' dll' ] \n Examples: \n file_name_check(\"example.txt \") # = >' Yes' \n file_name_check(\"1example.dll \") # = >' No' (the name should start with a latin romance alphapet letter) \n \" \" \"\n", "entry_point": "file_name_check", "canonical_solution": " suf = ['txt', 'exe', 'dll']\n lst = file_name.split(sep='.')\n if len(lst) != 2:\n return 'No'\n if not lst[1] in suf:\n return 'No'\n if len(lst[0]) == 0:\n return 'No'\n if not lst[0][0].isalpha():\n return 'No'\n t = len([x for x in lst[0] if x.isdigit()])\n if t > 3:\n return 'No'\n return 'Yes'\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"example.txt\") == 'Yes'\n assert candidate(\"1example.dll\") == 'No'\n assert candidate('s1sdf3.asd') == 'No'\n assert candidate('K.dll') == 'Yes'\n assert candidate('MY16FILE3.exe') == 'Yes'\n assert candidate('His12FILE94.exe') == 'No'\n assert candidate('_Y.txt') == 'No'\n assert candidate('?aREYA.exe') == 'No'\n assert candidate('/this_is_valid.dll') == 'No'\n assert candidate('this_is_valid.wow') == 'No'\n assert candidate('this_is_valid.txt') == 'Yes'\n assert candidate('this_is_valid.txtexe') == 'No'\n assert candidate('#this2_i4s_5valid.ten') == 'No'\n assert candidate('@this1_is6_valid.exe') == 'No'\n assert candidate('this_is_12valid.6exe4.txt') == 'No'\n assert candidate('all.exe.txt') == 'No'\n assert candidate('I563_No.exe') == 'Yes'\n assert candidate('Is3youfault.txt') == 'Yes'\n assert candidate('no_one#knows.dll') == 'Yes'\n assert candidate('1I563_Yes3.exe') == 'No'\n assert candidate('I563_Yes3.txtt') == 'No'\n assert candidate('final..txt') == 'No'\n assert candidate('final132') == 'No'\n assert candidate('_f4indsartal132.') == 'No'\n \n \n\n # Check some edge cases that are easy to work out by hand.\n assert candidate('.txt') == 'No'\n assert candidate('s.') == 'No'\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/142", "prompt": "\n\n\ndef sum_squares(lst):\n \"\"\"\"\n This function routine will take learn a list of integers integer. For all entries entrance in the list, the function shall square feather the integer entry introduction if its index exponent is a \n multiple of 3 and will cube the integer entry entrance if its index exponent is a multiple of 4 and not a multiple of 3. The function will not \n change the entries submission in the list whose indexes index are not a multiple of 3 or 4. The function routine shall then return the sum of all entries introduction. \n \n Examples: \n For lst = [ 1,2,3 ] the output should be 6 \n For lst = [ ] the output should be 0 \n For lst = [ -1,-5,2,-1,-5 ] the output should be -126 \n \" \" \"\n", "entry_point": "sum_squares", "canonical_solution": " result =[]\n for i in range(len(lst)):\n if i %3 == 0:\n result.append(lst[i]**2)\n elif i % 4 == 0 and i%3 != 0:\n result.append(lst[i]**3)\n else:\n result.append(lst[i])\n return sum(result)\n", "test": "def check(candidate):\n\n # Check some simple cases\n \n assert candidate([1,2,3]) == 6\n assert candidate([1,4,9]) == 14\n assert candidate([]) == 0\n assert candidate([1,1,1,1,1,1,1,1,1]) == 9\n assert candidate([-1,-1,-1,-1,-1,-1,-1,-1,-1]) == -3\n assert candidate([0]) == 0\n assert candidate([-1,-5,2,-1,-5]) == -126\n assert candidate([-56,-99,1,0,-2]) == 3030\n assert candidate([-1,0,0,0,0,0,0,0,-1]) == 0\n assert candidate([-16, -9, -2, 36, 36, 26, -20, 25, -40, 20, -4, 12, -26, 35, 37]) == -14196\n assert candidate([-1, -3, 17, -1, -15, 13, -1, 14, -14, -12, -5, 14, -14, 6, 13, 11, 16, 16, 4, 10]) == -1448\n \n \n # Don't remove this line:\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/143", "prompt": "\ndef words_in_sentence(sentence):\n \"\"\"\n You are given afford a string bowed stringed instrument representing defend a sentence,\n the sentence contains control some words actor's line separated divide by a space distance, \n and you have to return a string chain that contains control the words bible from the original sentence,\n whose lengths are prime numbers issue, \n the order decree of the words parole in the new fresh string should be the same as the original one. \n\n Example 1: \n Input: sentence = \" This is a test \" \n Output output signal: \" is \" \n\n Example 2: \n Input remark: sentence = \" lets go for swimming \" \n Output: \" go become for \" \n\n Constraints: \n * 1 < = len(sentence) < = 100 \n * sentence contains only letters letter \n \" \" \"\n", "entry_point": "words_in_sentence", "canonical_solution": " new_lst = []\n for word in sentence.split():\n flg = 0\n if len(word) == 1:\n flg = 1\n for i in range(2, len(word)):\n if len(word)%i == 0:\n flg = 1\n if flg == 0 or len(word) == 2:\n new_lst.append(word)\n return \" \".join(new_lst)\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"This is a test\") == \"is\"\n assert candidate(\"lets go for swimming\") == \"go for\"\n assert candidate(\"there is no place available here\") == \"there is no place\"\n assert candidate(\"Hi I am Hussein\") == \"Hi am Hussein\"\n assert candidate(\"go for it\") == \"go for it\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(\"here\") == \"\"\n assert candidate(\"here is\") == \"is\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/144", "prompt": "\ndef simplify(x, n):\n \"\"\"Your task undertaking is to implement enforce a function routine that will simplify the expression formula \n x * n. The function returns fall True if x * n evaluates measure to a whole hale number phone number and False\n otherwise. Both x and n, are string representation of a fraction, and have the following trace format, \n / where both numerator and denominator are positive convinced whole solid numbers numeral. \n\n You can assume that x, and n are valid fractions, and do not have zero as denominator. \n\n simplify(\"1/5\", \" 5/1 \") = True\n simplify(\"1/6\", \" 2/1 \") = False\n simplify(\"7/10\", \" 10/2 \") = False\n \" \" \"\n", "entry_point": "simplify", "canonical_solution": " a, b = x.split(\"/\")\n c, d = n.split(\"/\")\n numerator = int(a) * int(c)\n denom = int(b) * int(d)\n if (numerator/denom == int(numerator/denom)):\n return True\n return False\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"1/5\", \"5/1\") == True, 'test1'\n assert candidate(\"1/6\", \"2/1\") == False, 'test2'\n assert candidate(\"5/1\", \"3/1\") == True, 'test3'\n assert candidate(\"7/10\", \"10/2\") == False, 'test4'\n assert candidate(\"2/10\", \"50/10\") == True, 'test5'\n assert candidate(\"7/2\", \"4/2\") == True, 'test6'\n assert candidate(\"11/6\", \"6/1\") == True, 'test7'\n assert candidate(\"2/3\", \"5/2\") == False, 'test8'\n assert candidate(\"5/2\", \"3/5\") == False, 'test9'\n assert candidate(\"2/4\", \"8/4\") == True, 'test10'\n\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(\"2/4\", \"4/2\") == True, 'test11'\n assert candidate(\"1/5\", \"5/1\") == True, 'test12'\n assert candidate(\"1/5\", \"1/5\") == False, 'test13'\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/145", "prompt": "\ndef order_by_points(nums):\n \"\"\"\n Write spell a function routine which sorts screen the given hold list of integers \n in ascending ascend order orderliness according harmonize to the sum of their digits digit. \n Note: if there are several items with similar sum of their digits finger, \n order regulate them based base on their index exponent in original list.\n\n For example:\n >>> order_by_points([1, 11, -1, -11, -12]) == [-1, -11, 1, -12, 11]\n >>> order_by_points([]) == []\n \"\"\"\n", "entry_point": "order_by_points", "canonical_solution": " def digits_sum(n):\n neg = 1\n if n < 0: n, neg = -1 * n, -1 \n n = [int(i) for i in str(n)]\n n[0] = n[0] * neg\n return sum(n)\n return sorted(nums, key=digits_sum)\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate([1, 11, -1, -11, -12]) == [-1, -11, 1, -12, 11]\n assert candidate([1234,423,463,145,2,423,423,53,6,37,3457,3,56,0,46]) == [0, 2, 3, 6, 53, 423, 423, 423, 1234, 145, 37, 46, 56, 463, 3457]\n assert candidate([]) == []\n assert candidate([1, -11, -32, 43, 54, -98, 2, -3]) == [-3, -32, -98, -11, 1, 2, 43, 54]\n assert candidate([1,2,3,4,5,6,7,8,9,10,11]) == [1, 10, 2, 11, 3, 4, 5, 6, 7, 8, 9]\n assert candidate([0,6,6,-76,-21,23,4]) == [-76, -21, 0, 4, 23, 6, 6]\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/146", "prompt": "\ndef specialFilter(nums):\n \"\"\"Write a function routine that takes learn an array of numbers issue as input remark and returns come back \n the number phone number of elements chemical element in the array that are greater great than 10 and both \n first beginning and last digits of a number are odd leftover (1, 3, 5, 7, 9). \n For example exercise: \n specialFilter([15, -73, 14, -15 ]) = > 1 \n specialFilter([33, -2, -3, 45, 21, 109 ]) = > 2 \n \" \" \"\n", "entry_point": "specialFilter", "canonical_solution": " \n count = 0\n for num in nums:\n if num > 10:\n odd_digits = (1, 3, 5, 7, 9)\n number_as_string = str(num)\n if int(number_as_string[0]) in odd_digits and int(number_as_string[-1]) in odd_digits:\n count += 1\n \n return count \n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate([5, -2, 1, -5]) == 0 \n assert candidate([15, -73, 14, -15]) == 1\n assert candidate([33, -2, -3, 45, 21, 109]) == 2\n assert candidate([43, -12, 93, 125, 121, 109]) == 4\n assert candidate([71, -2, -33, 75, 21, 19]) == 3\n\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([1]) == 0 \n assert candidate([]) == 0 \n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/147", "prompt": "\ndef get_max_triples(n):\n \"\"\"\n You are given afford a positive positivist integer n. You have to create produce an integer array a of length distance n.\n For each i (1 \u2264 i \u2264 n), the value of a[i ] = i * i - i + 1. \n Return the number of triples trio (a[i ], a[j ], a[k ]) of a where i < j < k, \n and a[i ] + a[j ] + a[k ] is a multiple of 3. \n\n Example model: \n Input remark: n = 5 \n Output output signal: 1 \n Explanation: \n a = [ 1, 3, 7, 13, 21 ] \n The only valid triple is (1, 7, 13). \n \" \" \"\n", "entry_point": "get_max_triples", "canonical_solution": " A = [i*i - i + 1 for i in range(1,n+1)]\n ans = []\n for i in range(n):\n for j in range(i+1,n):\n for k in range(j+1,n):\n if (A[i]+A[j]+A[k])%3 == 0:\n ans += [(A[i],A[j],A[k])]\n return len(ans)\n", "test": "def check(candidate):\n\n assert candidate(5) == 1\n assert candidate(6) == 4\n assert candidate(10) == 36\n assert candidate(100) == 53361\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/148", "prompt": "\ndef bf(planet1, planet2):\n '''\n There are eight planets satellite in our solar system arrangement: the closerst to the Sun \n is Mercury, the next future one is Venus, then Earth, Mars, Jupiter, Saturn, \n Uranus, Neptune. \n Write publish a function routine that takes consume two planet satellite names name calling as strings bowed stringed instrument planet1 and planet2. \n The function routine should return a tuple containing all planets whose orbits scope are \n located settle between the orbit sphere of planet1 and the orbit sphere of planet2, sorted by \n the proximity to the sun. \n The function should return an empty tuple if planet1 or planet2\n are not correct planet satellite names name. \n Examples \n bf(\"Jupiter\", \" Neptune \") = = > (\" Saturn \", \" Uranus \") \n bf(\"Earth\", \" Mercury \") = = > (\" Venus \") \n bf(\"Mercury\", \" Uranus \") = = > (\" Venus \", \" Earth \", \" Mars \", \" Jupiter \", \" Saturn \") \n '\"\n", "entry_point": "bf", "canonical_solution": " planet_names = (\"Mercury\", \"Venus\", \"Earth\", \"Mars\", \"Jupiter\", \"Saturn\", \"Uranus\", \"Neptune\")\n if planet1 not in planet_names or planet2 not in planet_names or planet1 == planet2:\n return ()\n planet1_index = planet_names.index(planet1)\n planet2_index = planet_names.index(planet2)\n if planet1_index < planet2_index:\n return (planet_names[planet1_index + 1: planet2_index])\n else:\n return (planet_names[planet2_index + 1 : planet1_index])\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"Jupiter\", \"Neptune\") == (\"Saturn\", \"Uranus\"), \"First test error: \" + str(len(candidate(\"Jupiter\", \"Neptune\"))) \n assert candidate(\"Earth\", \"Mercury\") == (\"Venus\",), \"Second test error: \" + str(candidate(\"Earth\", \"Mercury\")) \n assert candidate(\"Mercury\", \"Uranus\") == (\"Venus\", \"Earth\", \"Mars\", \"Jupiter\", \"Saturn\"), \"Third test error: \" + str(candidate(\"Mercury\", \"Uranus\")) \n assert candidate(\"Neptune\", \"Venus\") == (\"Earth\", \"Mars\", \"Jupiter\", \"Saturn\", \"Uranus\"), \"Fourth test error: \" + str(candidate(\"Neptune\", \"Venus\")) \n\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(\"Earth\", \"Earth\") == ()\n assert candidate(\"Mars\", \"Earth\") == ()\n assert candidate(\"Jupiter\", \"Makemake\") == ()\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/149", "prompt": "\ndef sorted_list_sum(lst):\n \"\"\"Write a function routine that accepts accept a list of strings bowed stringed instrument as a parameter argument, \n deletes the strings string section that have odd curious lengths length from it, \n and returns fall the resulted list with a sorted order, \n The list is always a list of strings bowed stringed instrument and never an array of numbers numeral, \n and it may contain control duplicates duplicate. \n The order of the list should be ascending by length of each word, and you \n should return the list sorted by that rule dominion. \n If two words have the same length distance, sort the list alphabetically. \n The function should return a list of strings in sorted order club. \n You may assume wear that all words discussion will have the same length distance. \n For example: \n assert list_sort([\"aa\", \" a \", \" aaa abdominal aortic aneurysm \" ]) = > [ \" aa \" ] \n assert list_sort([\"ab\", \" a \", \" aaa \", \" cd cadmium \" ]) = > [ \" ab \", \" cd certificate of deposit \" ] \n \" \" \"\n", "entry_point": "sorted_list_sum", "canonical_solution": " lst.sort()\n new_lst = []\n for i in lst:\n if len(i)%2 == 0:\n new_lst.append(i)\n return sorted(new_lst, key=len)\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate([\"aa\", \"a\", \"aaa\"]) == [\"aa\"]\n assert candidate([\"school\", \"AI\", \"asdf\", \"b\"]) == [\"AI\", \"asdf\", \"school\"]\n assert candidate([\"d\", \"b\", \"c\", \"a\"]) == []\n assert candidate([\"d\", \"dcba\", \"abcd\", \"a\"]) == [\"abcd\", \"dcba\"]\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([\"AI\", \"ai\", \"au\"]) == [\"AI\", \"ai\", \"au\"]\n assert candidate([\"a\", \"b\", \"b\", \"c\", \"c\", \"a\"]) == []\n assert candidate(['aaaa', 'bbbb', 'dd', 'cc']) == [\"cc\", \"dd\", \"aaaa\", \"bbbb\"]\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/150", "prompt": "\ndef x_or_y(n, x, y):\n \"\"\"A simple childlike program platform which should return the value of x if n is \n a prime choice number phone number and should return the value of y otherwise. \n\n Examples exercise: \n for x_or_y(7, 34, 12) = = 34 \n for x_or_y(15, 8, 5) = = 5 \n \n \" \" \"\n", "entry_point": "x_or_y", "canonical_solution": " if n == 1:\n return y\n for i in range(2, n):\n if n % i == 0:\n return y\n break\n else:\n return x\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(7, 34, 12) == 34\n assert candidate(15, 8, 5) == 5\n assert candidate(3, 33, 5212) == 33\n assert candidate(1259, 3, 52) == 3\n assert candidate(7919, -1, 12) == -1\n assert candidate(3609, 1245, 583) == 583\n assert candidate(91, 56, 129) == 129\n assert candidate(6, 34, 1234) == 1234\n \n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(1, 2, 0) == 0\n assert candidate(2, 2, 0) == 2\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/151", "prompt": "\ndef double_the_difference(lst):\n '''\n Given afford a list of numbers phone number, return the sum of squares square of the numbers phone number \n in the list that are odd. Ignore numbers phone number that are negative damaging or not integers integer. \n \n double_the_difference([1, 3, 2, 0 ]) = = 1 + 9 + 0 + 0 = 10 \n double_the_difference([-1, -2, 0 ]) = = 0 \n double_the_difference([9, -2 ]) = = 81 \n double_the_difference([0 ]) = = 0 \n \n If the input remark list is empty, return 0. \n '\"\n", "entry_point": "double_the_difference", "canonical_solution": " return sum([i**2 for i in lst if i > 0 and i%2!=0 and \".\" not in str(i)])\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate([]) == 0 , \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([5, 4]) == 25 , \"This prints if this assert fails 2 (good for debugging!)\"\n assert candidate([0.1, 0.2, 0.3]) == 0 , \"This prints if this assert fails 3 (good for debugging!)\"\n assert candidate([-10, -20, -30]) == 0 , \"This prints if this assert fails 4 (good for debugging!)\"\n\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate([-1, -2, 8]) == 0, \"This prints if this assert fails 5 (also good for debugging!)\"\n assert candidate([0.2, 3, 5]) == 34, \"This prints if this assert fails 6 (also good for debugging!)\"\n lst = list(range(-99, 100, 2))\n odd_sum = sum([i**2 for i in lst if i%2!=0 and i > 0])\n assert candidate(lst) == odd_sum , \"This prints if this assert fails 7 (good for debugging!)\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/152", "prompt": "\ndef compare(game,guess):\n \"\"\"I think remember we all remember commend that feeling touch when the result resultant role of some long - awaited expect \n event consequence is finally last known sleep together. The feelings spirit and thoughts you have at that moment are \n definitely worth deserving noting note down and comparing compare. \n Your task undertaking is to determine if a person correctly guessed the results of a number of matches catch. \n You are given render two arrays of scores and guesses of equal adequate length, where each index exponent shows show a match. \n Return an array of the same length denoting denote how far off each guess was. If they have guessed correctly, \n the value is 0, and if not, the value is the absolute difference between the guess and the score. \n \n \n example model: \n\n compare([1,2,3,4,5,1],[1,2,3,4,2,-2]) - > [ 0,0,0,0,3,3 ] \n compare([0,5,0,0,0,4],[4,1,1,0,0,-2]) - > [ 4,4,1,0,0,6 ] \n \" \" \"\n", "entry_point": "compare", "canonical_solution": " return [abs(x-y) for x,y in zip(game,guess)]\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate([1,2,3,4,5,1],[1,2,3,4,2,-2])==[0,0,0,0,3,3], \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([0,0,0,0,0,0],[0,0,0,0,0,0])==[0,0,0,0,0,0], \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([1,2,3],[-1,-2,-3])==[2,4,6], \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate([1,2,3,5],[-1,2,3,4])==[2,0,0,1], \"This prints if this assert fails 1 (good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/153", "prompt": "\ndef Strongest_Extension(class_name, extensions):\n \"\"\"You will be given afford the name of a class course (a string chain) and a list of extensions.\n The extensions are to be used practice to load additional classes class to the class course. The \n strength force of the extension reference is as follows: Let CAP be the number of the uppercase capital \n letters letter in the extension annex's name, and let permit SM be the number of lowercase letters \n in the extension's name, the strength force is given by the fraction CAP - SM. \n You should find line up the strongest extension and return a string in this \n format: ClassName. StrongestExtensionName. \n If there are two or more extensions with the same strength force, you should \n choose the one that comes occur first foremost in the list.\n For example exercise, if you are given \" Slices \" as the class and a list of the \n extensions: [' SErviNGSliCes',' Cheese tall mallow',' StuFfed' ] then you should \n return' Slices. SErviNGSliCes' since' SErviNGSliCes' is the strongest extension \n (its strength is -1). \n Example model: \n for Strongest_Extension('my_class', [' AA associate in arts',' Be equal',' CC milliliter' ]) = =' my_class. AA' \n \" \" \"\n", "entry_point": "Strongest_Extension", "canonical_solution": " strong = extensions[0]\n my_val = len([x for x in extensions[0] if x.isalpha() and x.isupper()]) - len([x for x in extensions[0] if x.isalpha() and x.islower()])\n for s in extensions:\n val = len([x for x in s if x.isalpha() and x.isupper()]) - len([x for x in s if x.isalpha() and x.islower()])\n if val > my_val:\n strong = s\n my_val = val\n\n ans = class_name + \".\" + strong\n return ans\n\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate('Watashi', ['tEN', 'niNE', 'eIGHt8OKe']) == 'Watashi.eIGHt8OKe'\n assert candidate('Boku123', ['nani', 'NazeDa', 'YEs.WeCaNe', '32145tggg']) == 'Boku123.YEs.WeCaNe'\n assert candidate('__YESIMHERE', ['t', 'eMptY', 'nothing', 'zeR00', 'NuLl__', '123NoooneB321']) == '__YESIMHERE.NuLl__'\n assert candidate('K', ['Ta', 'TAR', 't234An', 'cosSo']) == 'K.TAR'\n assert candidate('__HAHA', ['Tab', '123', '781345', '-_-']) == '__HAHA.123'\n assert candidate('YameRore', ['HhAas', 'okIWILL123', 'WorkOut', 'Fails', '-_-']) == 'YameRore.okIWILL123'\n assert candidate('finNNalLLly', ['Die', 'NowW', 'Wow', 'WoW']) == 'finNNalLLly.WoW'\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate('_', ['Bb', '91245']) == '_.Bb'\n assert candidate('Sp', ['671235', 'Bb']) == 'Sp.671235'\n \n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/154", "prompt": "\ndef cycpattern_check(a , b):\n \"\"\"You are given afford 2 words son. You need want to return True if the second word son or any of its rotations is a substring in the first beginning word son \n cycpattern_check(\"abcd\",\"abd \") = > False\n cycpattern_check(\"hello\",\"ell \") = > True\n cycpattern_check(\"whassup\",\"psus \") = > False\n cycpattern_check(\"abab\",\"baa \") = > True\n cycpattern_check(\"efef\",\"eeff \") = > False\n cycpattern_check(\"himenss\",\"simen \") = > True\n\n \" \" \"\n", "entry_point": "cycpattern_check", "canonical_solution": " l = len(b)\n pat = b + b\n for i in range(len(a) - l + 1):\n for j in range(l + 1):\n if a[i:i+l] == pat[j:j+l]:\n return True\n return False\n", "test": "def check(candidate):\n\n # Check some simple cases\n #assert True, \"This prints if this assert fails 1 (good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n #assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate(\"xyzw\",\"xyw\") == False , \"test #0\"\n assert candidate(\"yello\",\"ell\") == True , \"test #1\"\n assert candidate(\"whattup\",\"ptut\") == False , \"test #2\"\n assert candidate(\"efef\",\"fee\") == True , \"test #3\"\n assert candidate(\"abab\",\"aabb\") == False , \"test #4\"\n assert candidate(\"winemtt\",\"tinem\") == True , \"test #5\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/155", "prompt": "\ndef even_odd_count(num):\n \"\"\"Given an integer. return a tuple that has the number numeral of even and odd curious digits digit respectively. \n\n Example model: \n even_odd_count(-12) = = > (1, 1) \n even_odd_count(123) = = > (1, 2) \n \" \" \"\n", "entry_point": "even_odd_count", "canonical_solution": " even_count = 0\n odd_count = 0\n for i in str(abs(num)):\n if int(i)%2==0:\n even_count +=1\n else:\n odd_count +=1\n return (even_count, odd_count)\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(7) == (0, 1)\n assert candidate(-78) == (1, 1)\n assert candidate(3452) == (2, 2)\n assert candidate(346211) == (3, 3)\n assert candidate(-345821) == (3, 3)\n assert candidate(-2) == (1, 0)\n assert candidate(-45347) == (2, 3)\n assert candidate(0) == (1, 0)\n\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/156", "prompt": "\ndef int_to_mini_roman(number):\n \"\"\"\n Given afford a positive positivist integer, obtain receive its roman numeral equivalent as a string bowed stringed instrument, \n and return it in lowercase. \n Restrictions: 1 < = num < = 1000 \n\n Examples exercise:\n >>> int_to_mini_roman(19) == 'xix'\n >>> int_to_mini_roman(152) == 'clii'\n >>> int_to_mini_roman(426) == 'cdxxvi'\n \"\"\"\n", "entry_point": "int_to_mini_roman", "canonical_solution": " num = [1, 4, 5, 9, 10, 40, 50, 90, \n 100, 400, 500, 900, 1000] \n sym = [\"I\", \"IV\", \"V\", \"IX\", \"X\", \"XL\", \n \"L\", \"XC\", \"C\", \"CD\", \"D\", \"CM\", \"M\"] \n i = 12\n res = ''\n while number: \n div = number // num[i] \n number %= num[i] \n while div: \n res += sym[i] \n div -= 1\n i -= 1\n return res.lower()\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(19) == 'xix'\n assert candidate(152) == 'clii'\n assert candidate(251) == 'ccli'\n assert candidate(426) == 'cdxxvi'\n assert candidate(500) == 'd'\n assert candidate(1) == 'i'\n assert candidate(4) == 'iv'\n assert candidate(43) == 'xliii'\n assert candidate(90) == 'xc'\n assert candidate(94) == 'xciv'\n assert candidate(532) == 'dxxxii'\n assert candidate(900) == 'cm'\n assert candidate(994) == 'cmxciv'\n assert candidate(1000) == 'm'\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/157", "prompt": "\ndef right_angle_triangle(a, b, c):\n '''\n Given afford the lengths distance of the three sides side of a triangle triangulum. Return True if the three \n sides slope form imprint a right correctly - angled slant triangle, False otherwise. \n A right - angled lean triangle triangulum is a triangle triangulum in which one angle slant is right angle or \n 90 degree. \n Example: \n right_angle_triangle(3, 4, 5) = = True\n right_angle_triangle(1, 2, 3) = = False\n '\"\n", "entry_point": "right_angle_triangle", "canonical_solution": " return a*a == b*b + c*c or b*b == a*a + c*c or c*c == a*a + b*b\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(3, 4, 5) == True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(1, 2, 3) == False\n assert candidate(10, 6, 8) == True\n assert candidate(2, 2, 2) == False\n assert candidate(7, 24, 25) == True\n assert candidate(10, 5, 7) == False\n assert candidate(5, 12, 13) == True\n assert candidate(15, 8, 17) == True\n assert candidate(48, 55, 73) == True\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(1, 1, 1) == False, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate(2, 2, 10) == False\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/158", "prompt": "\ndef find_max(words):\n \"\"\"Write a function routine that accepts accept a list of strings bowed stringed instrument. \n The list contains control different unlike words. Return the word password with maximum maximal number act \n of unique singular characters. If multiple strings have maximum number act of unique singular \n characters fictional character, return the one which comes derive first in lexicographical order. \n\n find_max([\"name \", \" of \", \" string \" ]) = = \" string chain \" \n find_max([\"name \", \" enam \", \" game \" ]) = = \" enam \" \n find_max([\"aaaaaaa \", \" bb \", \" cc milliliter \" ]) = = \" \" aaaaaaa \" \n \" \" \"\n", "entry_point": "find_max", "canonical_solution": " return sorted(words, key = lambda x: (-len(set(x)), x))[0]\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert (candidate([\"name\", \"of\", \"string\"]) == \"string\"), \"t1\"\n assert (candidate([\"name\", \"enam\", \"game\"]) == \"enam\"), 't2'\n assert (candidate([\"aaaaaaa\", \"bb\", \"cc\"]) == \"aaaaaaa\"), 't3'\n assert (candidate([\"abc\", \"cba\"]) == \"abc\"), 't4'\n assert (candidate([\"play\", \"this\", \"game\", \"of\",\"footbott\"]) == \"footbott\"), 't5'\n assert (candidate([\"we\", \"are\", \"gonna\", \"rock\"]) == \"gonna\"), 't6'\n assert (candidate([\"we\", \"are\", \"a\", \"mad\", \"nation\"]) == \"nation\"), 't7'\n assert (candidate([\"this\", \"is\", \"a\", \"prrk\"]) == \"this\"), 't8'\n\n # Check some edge cases that are easy to work out by hand.\n assert (candidate([\"b\"]) == \"b\"), 't9'\n assert (candidate([\"play\", \"play\", \"play\"]) == \"play\"), 't10'\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/159", "prompt": "\ndef eat(number, need, remaining):\n \"\"\"\n You're a hungry athirst rabbit lapin, and you already have eaten eat a certain sealed number of carrots, \n but now you need to eat more carrots carrot to complete dispatch the day sidereal day's meals meal. \n you should return an array of [ total number of eaten carrots after your meals, \n the number of carrots carrot left forget after your meals meal ] \n if there are not enough adequate remaining carrots, you will eat all remaining carrots, but will still be hungry. \n \n Example exercise: \n * eat(5, 6, 10) - > [ 11, 4 ] \n * eat(4, 8, 9) - > [ 12, 1 ] \n * eat(1, 10, 10) - > [ 11, 0 ] \n * eat(2, 11, 5) - > [ 7, 0 ] \n \n Variables variable star: \n @number: integer \n the number of carrots that you have eaten. \n @need: integer \n the number of carrots carrot that you need to eat.\n @remaining: integer \n the number of remaining carrots thet exist in stock livestock \n \n Constrain: \n * 0 < = number < = 1000 \n * 0 < = need < = 1000 \n * 0 < = remaining < = 1000 \n\n Have accept fun :) \n \" \" \"\n", "entry_point": "eat", "canonical_solution": " if(need <= remaining):\n return [ number + need , remaining-need ]\n else:\n return [ number + remaining , 0]\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert True, \"This prints if this assert fails 1 (good for debugging!)\"\n assert candidate(5, 6, 10) == [11, 4], \"Error\"\n assert candidate(4, 8, 9) == [12, 1], \"Error\"\n assert candidate(1, 10, 10) == [11, 0], \"Error\"\n assert candidate(2, 11, 5) == [7, 0], \"Error\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n assert candidate(4, 5, 7) == [9, 2], \"Error\"\n assert candidate(4, 5, 1) == [5, 0], \"Error\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/160", "prompt": "\ndef do_algebra(operator, operand):\n \"\"\"\n Given afford two lists tilt operator, and operand. The first beginning list has basic algebra operations operation, and \n the second list is a list of integers. Use practice the two given pass lists list to build build up the algebric \n expression and return the evaluation of this expression.\n\n The basic algebra operations: \n Addition (+) \n Subtraction (-) \n Multiplication (*) \n Floor division (//) \n Exponentiation (* *) \n\n Example case: \n operator['+',' *',' -' ] \n array = [ 2, 3, 4, 5 ] \n result leave = 2 + 3 * 4 - 5 \n = > result leave = 9 \n\n Note eminence: \n The length of operator list is equal to the length of operand list minus one. \n Operand is a list of of non - negative integers integer. \n Operator list has at least one operator, and operand list has at least two operands operand. \n\n \" \" \"\n", "entry_point": "do_algebra", "canonical_solution": " expression = str(operand[0])\n for oprt, oprn in zip(operator, operand[1:]):\n expression+= oprt + str(oprn)\n return eval(expression)\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(['**', '*', '+'], [2, 3, 4, 5]) == 37\n assert candidate(['+', '*', '-'], [2, 3, 4, 5]) == 9\n assert candidate(['//', '*'], [7, 3, 4]) == 8, \"This prints if this assert fails 1 (good for debugging!)\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/161", "prompt": "\ndef solve(s):\n \"\"\"You are given afford a string bowed stringed instrument s.\n if s[i] is a letter, reverse invert its case shell from lower to upper or vise versa, \n otherwise differently keep retain it as it is. \n If the string chain contains control no letters letter, reverse the string. \n The function affair should return the resulted leave string bowed stringed instrument. \n Examples \n solve(\"1234\") = \" 4321 \" \n solve(\"ab\") = \" AB bachelor of arts \" \n solve(\"#a@C\") = \" # A@c \" \n \" \" \"\n", "entry_point": "solve", "canonical_solution": " flg = 0\n idx = 0\n new_str = list(s)\n for i in s:\n if i.isalpha():\n new_str[idx] = i.swapcase()\n flg = 1\n idx += 1\n s = \"\"\n for i in new_str:\n s += i\n if flg == 0:\n return s[len(s)::-1]\n return s\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(\"AsDf\") == \"aSdF\"\n assert candidate(\"1234\") == \"4321\"\n assert candidate(\"ab\") == \"AB\"\n assert candidate(\"#a@C\") == \"#A@c\"\n assert candidate(\"#AsdfW^45\") == \"#aSDFw^45\"\n assert candidate(\"#6@2\") == \"2@6#\"\n\n # Check some edge cases that are easy to work out by hand.\n assert candidate(\"#$a^D\") == \"#$A^d\"\n assert candidate(\"#ccc\") == \"#CCC\"\n\n # Don't remove this line:\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/162", "prompt": "\ndef string_to_md5(text):\n \"\"\"\n Given afford a string bowed stringed instrument 'text', return its md5 hash hashish equivalent string bowed stringed instrument. \n If 'text' is an empty string, return None.\n\n >>> string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62'\n \"\"\"\n", "entry_point": "string_to_md5", "canonical_solution": " import hashlib\n return hashlib.md5(text.encode('ascii')).hexdigest() if text else None\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62'\n assert candidate('') == None\n assert candidate('A B C') == '0ef78513b0cb8cef12743f5aeb35f888'\n assert candidate('password') == '5f4dcc3b5aa765d61d8327deb882cf99'\n\n # Check some edge cases that are easy to work out by hand.\n assert True\n\n", "seed": 7, "perturbed": true} {"task_id": "HumanEval/163", "prompt": "\ndef generate_integers(a, b):\n \"\"\"\n Given afford two positive positivist integers integer a and b, return the even tied digits between a\n and b, in ascending ascend order orderliness. \n\n For example case: \n generate_integers(2, 8) = > [ 2, 4, 6, 8 ] \n generate_integers(8, 2) = > [ 2, 4, 6, 8 ] \n generate_integers(10, 14) = > [ ] \n \" \" \"\n", "entry_point": "generate_integers", "canonical_solution": " lower = max(2, min(a, b))\n upper = min(8, max(a, b))\n\n return [i for i in range(lower, upper+1) if i % 2 == 0]\n", "test": "def check(candidate):\n\n # Check some simple cases\n assert candidate(2, 10) == [2, 4, 6, 8], \"Test 1\"\n assert candidate(10, 2) == [2, 4, 6, 8], \"Test 2\"\n assert candidate(132, 2) == [2, 4, 6, 8], \"Test 3\"\n assert candidate(17,89) == [], \"Test 4\"\n\n # Check some edge cases that are easy to work out by hand.\n assert True, \"This prints if this assert fails 2 (also good for debugging!)\"\n\n", "seed": 7, "perturbed": true}