{"task_id": "HumanEval/0", "completion": "\nfrom typing import List\ndef has_close_elements(numbers: List[float], threshold: float) -> bool:\n \n for i in range(len(numbers)):\n for j in range(i+1, len(numbers)):\n if abs(numbers[i]-numbers[j]) < threshold:\n return True\n return False"} {"task_id": "HumanEval/1", "completion": "\nfrom typing import List\n\ndef separate_paren_groups(paren_string: str) -> List[str]:\n \n paren_list = paren_string.split()\n paren_list = [\"()\" if \"(\" not in paren else \"(())\" for paren in paren_list]\n return paren_list"} {"task_id": "HumanEval/2", "completion": "\ndef truncate_number(number: float) -> float:\n \n integer_part = int(number)\n decimal_part = number - integer_part\n return decimal_part"} {"task_id": "HumanEval/3", "completion": "\nfrom typing import List\ndef below_zero(operations: List[int]) -> bool:\n \n balance = 0\n for operation in operations:\n balance += operation\n if balance < 0:\n return True\n return False"} {"task_id": "HumanEval/4", "completion": "\nfrom typing import List\ndef mean_absolute_deviation(numbers: List[float]) -> float:\n \n # \u8ba1\u7b97\u5e73\u5747\u503c\n mean = sum(numbers) / len(numbers)\n # \u8ba1\u7b97\u6bcf\u4e2a\u5143\u7d20\u4e0e\u5e73\u5747\u503c\u7684\u7edd\u5bf9\u5dee\u5f02\n differences = [abs(x - mean) for x in numbers]\n # \u8ba1\u7b97\u5e73\u5747\u7edd\u5bf9\u504f\u5dee\n mad = sum(differences) / len(differences)\n return mad"} {"task_id": "HumanEval/5", "completion": "\nfrom typing import List\n\ndef intersperse(numbers, delimeter):\n \n result = []\n for i in range(len(numbers)):\n result.extend([numbers[i]] + [delimiter] * (len(numbers) - i - 1))\n return result"} {"task_id": "HumanEval/6", "completion": "\nfrom typing import List\n\ndef parse_nested_parens(paren_string):\n \n stack = []\n result = []\n for paren in paren_string.split():\n max_level = 0\n current_level = 0\n for char in paren:\n if char == '(':\n current_level += 1\n max_level = max(max_level, current_level)\n elif char == ')':\n current_level -= 1\n result.append(max_level)\n return result"} {"task_id": "HumanEval/7", "completion": "\nfrom typing import List\ndef filter_by_substring(strings: List[str], substring: str) -> List[str]:\n \n result = []\n for s in strings:\n if substring in s:\n result.append(s)\n return result"} {"task_id": "HumanEval/8", "completion": "\nfrom typing import List, Tuple\ndef sum_product(numbers: List[int]) -> Tuple[int, int]:\n \n if not numbers:\n return 0, 1\n total = sum(numbers)\n product = 1\n for number in numbers:\n product *= number\n return total, product"} {"task_id": "HumanEval/9", "completion": "\nfrom typing import List, Tuple\n\ndef rolling_max(numbers):\n \n result = []\n max_value = float('-inf')\n for i in range(len(numbers)):\n if numbers[i] > max_value:\n max_value = numbers[i]\n result.append(max_value)\n return result"} {"task_id": "HumanEval/10", "completion": "\ndef is_palindrome(string: str) -> bool:\n \n return string == string[::-1]\ndef make_palindrome(string: str) -> str:\n \"\"\"\u5728\u7ed9\u5b9a\u5b57\u7b26\u4e32\u7684\u672b\u5c3e\u6dfb\u52a0\u6700\u5c11\u7684\u5b57\u7b26\uff0c\u751f\u6210\u56de\u6587\u5b57\u7b26\u4e32\u3002\u7b97\u6cd5\u601d\u8def\u7b80\u5355\uff1a\u9996\u5148\u627e\u5230\u5b57\u7b26\u4e32\u7684\u6700\u957f\u540e\u7f00\uff0c\u5982\u679c\u662f\u56de\u6587\uff0c\u5c06\u627e\u5230\u7684\u56de\u6587\u540e\u7f00\u524d\u9762\u7684\u5b57\u7b26\u4e32\u53cd\u8f6c\uff0c\u8ffd\u52a0\u5230\u7ed9\u5b9a\u5b57\u7b26\u4e32\u7684\u672b\u5c3e\u3002\n >>> make_palindrome('')\n ''\n >>> make_palindrome('cat')\n 'catac'\n >>> make_palindrome('cata')\n 'catac'\n \"\"\"\n n = len(string)\n for i in range(n-1, -1, -1):\n if is_palindrome(string[i:]):\n return string[:i] + string[i:][::-1] + string[i:]"} {"task_id": "HumanEval/11", "completion": "\nfrom typing import List\ndef string_xor(a: str, b: str) -> str:\n \n res = \"\"\n for i in range(len(a)):\n if a[i] == b[i]:\n res += \"0\"\n else:\n res += \"1\"\n return res"} {"task_id": "HumanEval/12", "completion": "\nfrom typing import List, Optional\ndef longest(strings: List[str]) -> Optional[str]:\n \n if not strings:\n return None\n longest_string = strings[0]\n for string in strings:\n if len(string) > len(longest_string):\n longest_string = string\n return longest_string"} {"task_id": "HumanEval/13", "completion": "\ndef greatest_common_divisor(a: int, b: int) -> int:\n \n while b != 0:\n a, b = b, a % b\n return a"} {"task_id": "HumanEval/14", "completion": "\nfrom typing import List\ndef all_prefixes(string: str) -> List[str]:\n \n prefixes = []\n for i in range(len(string)):\n prefix = string[:i+1]\n if prefix not in prefixes:\n prefixes.append(prefix)\n return prefixes"} {"task_id": "HumanEval/15", "completion": "\ndef string_sequence(n: int) -> str:\n \n return ' '.join(str(i) for i in range(n+1))"} {"task_id": "HumanEval/16", "completion": "\ndef count_distinct_characters(string: str) -> int:\n \n # \u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5c0f\u5199\uff0c\u65b9\u4fbf\u7edf\u8ba1\n string = string.lower()\n # \u4f7f\u7528\u96c6\u5408\u6765\u5b58\u50a8\u4e0d\u540c\u7684\u5b57\u7b26\n distinct_characters = set()\n # \u904d\u5386\u5b57\u7b26\u4e32\uff0c\u5c06\u6bcf\u4e2a\u5b57\u7b26\u6dfb\u52a0\u5230\u96c6\u5408\u4e2d\n for char in string:\n distinct_characters.add(char)\n # \u8fd4\u56de\u96c6\u5408\u7684\u5927\u5c0f\uff0c\u5373\u4e0d\u540c\u5b57\u7b26\u7684\u6570\u91cf\n return len(distinct_characters)"} {"task_id": "HumanEval/17", "completion": "\nfrom typing import List\n\ndef parse_music(music_string):\n \n note_lengths = []\n note_list = music_string.split('|')\n for note in note_list:\n note_length = 0\n if 'o' in note:\n note_length = 4\n elif 'o|' in note:\n note_length = 2\n elif '|' in note:\n note_length = 1\n note_lengths.append(note_length)\n return note_lengths"} {"task_id": "HumanEval/18", "completion": "\ndef how_many_times(string: str, substring: str) -> int:\n \n count = 0\n start = 0\n while True:\n index = string.find(substring, start)\n if index == -1:\n break\n count += 1\n start = index + 1\n return count"} {"task_id": "HumanEval/19", "completion": "\nfrom typing import List\n\ndef sort_numbers(numbers):\n \n word_dict = {\n 'zero': 'zero',\n 'one': 'one',\n 'two': 'two',\n 'three': 'three',\n 'four': 'four',\n 'five': 'five',\n 'six': 'six',\n 'seven': 'seven',\n 'eight': 'eight',\n 'nine': 'nine'\n }\n \n sorted_numbers = sorted(numbers.split())\n sorted_words = [word_dict[num] for num in sorted_numbers]\n \n return ' '.join(sorted_words)"} {"task_id": "HumanEval/20", "completion": "\nfrom typing import List, Tuple\n\ndef find_closest_elements(numbers):\n \n # \u5c06\u6570\u5b57\u5217\u8868\u6309\u5347\u5e8f\u6392\u5e8f\n numbers.sort()\n \n # \u521d\u59cb\u5316\u6700\u5c0f\u5dee\u503c\u4e3a\u6b63\u65e0\u7a77\u5927\n min_diff = float('inf')\n \n # \u521d\u59cb\u5316\u6700\u63a5\u8fd1\u7684\u4e24\u4e2a\u6570\u5b57\n closest_nums = (None, None)\n \n # \u904d\u5386\u6570\u5b57\u5217\u8868\uff0c\u6bd4\u8f83\u76f8\u90bb\u4e24\u4e2a\u6570\u5b57\u7684\u5dee\u503c\uff0c\u66f4\u65b0\u6700\u5c0f\u5dee\u503c\u548c\u6700\u63a5\u8fd1\u7684\u4e24\u4e2a\u6570\u5b57\n for i in range(len(numbers) - 1):\n diff = numbers[i+1] - numbers[i]\n if diff < min_diff:\n min_diff = diff\n closest_nums = (numbers[i], numbers[i+1])\n \n return closest_nums"} {"task_id": "HumanEval/21", "completion": "\nfrom typing import List\ndef rescale_to_unit(numbers: List[float]) -> List[float]:\n \n min_num = min(numbers)\n max_num = max(numbers)\n rescaled = [(num - min_num) / (max_num - min_num) for num in numbers]\n return rescaled"} {"task_id": "HumanEval/22", "completion": "\nfrom typing import List, Any\ndef filter_integers(values: List[Any]) -> List[int]:\n \n return [x for x in values if isinstance(x, int)]"} {"task_id": "HumanEval/23", "completion": "\ndef strlen(string: str) -> int:\n \n return len(string)"} {"task_id": "HumanEval/24", "completion": "\ndef largest_divisor(n: int) -> int:\n \n for i in range(n - 1, 0, -1):\n if n % i == 0:\n return i\n return None"} {"task_id": "HumanEval/25", "completion": "\nfrom typing import List\ndef factorize(n: int) -> List[int]:\n \n factors = []\n i = 2\n while i * i <= n:\n if n % i:\n i += 1\n else:\n n //= i\n factors.append(i)\n if n > 1:\n factors.append(n)\n return factors"} {"task_id": "HumanEval/26", "completion": "\nfrom typing import List\n\ndef remove_duplicates(numbers):\n \n count_dict = {}\n result = []\n for num in numbers:\n if num not in count_dict:\n count_dict[num] = 1\n else:\n count_dict[num] += 1\n for num in numbers:\n if count_dict[num] == 1:\n result.append(num)\n return result"} {"task_id": "HumanEval/27", "completion": "\ndef flip_case(string: str) -> str:\n \n result = ''\n for char in string:\n if char.islower():\n result += char.upper()\n elif char.isupper():\n result += char.lower()\n else:\n result += char\n return result"} {"task_id": "HumanEval/28", "completion": "\nfrom typing import List\ndef concatenate(strings: List[str]) -> str:\n \n return ''.join(strings)"} {"task_id": "HumanEval/29", "completion": "\nfrom typing import List\ndef filter_by_prefix(strings: List[str], prefix: str) -> List[str]:\n \n result = []\n for s in strings:\n if s.startswith(prefix):\n result.append(s)\n return result"} {"task_id": "HumanEval/30", "completion": "\ndef get_positive(l: list):\n \n return [num for num in l if num > 0]"} {"task_id": "HumanEval/31", "completion": "\ndef is_prime(n):\n \n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True"} {"task_id": "HumanEval/32", "completion": "\nimport math\n\ndef poly(xs: list, x: float):\n \n return sum([coeff * math.pow(x, i) for i, coeff in enumerate(xs)])\ndef find_zero(xs: list):\n \"\"\"xs\u662f\u591a\u9879\u5f0f\u7684\u7cfb\u6570\u3002find_zero\u8fd4\u56depoly\uff08x\uff09= 0\u65f6\u7684\u89e3\u3002find_zero\u53ea\u8fd4\u56de\u96f6\u70b9\uff0c\u5373\u4f7f\u6709\u5f88\u591a\u3002\u6b64\u5916\uff0cfind_zero\u4ec5\u63a5\u53d7\u5177\u6709\u5076\u6570\u7cfb\u6570\u548c\u6700\u5927\u975e\u96f6\u7cfb\u6570\u7684\u5217\u8868 x\uff0c\u56e0\u4e3a\u5b83\u4fdd\u8bc1\u4e86\u6709\u89e3\u3002\n >>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x\n -0.5\n >>> round(find_zero([-6, 11, -6, 1]), 2) # f(x) = (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3\n 1.0\n \"\"\"\n n = len(xs)\n if n % 2 == 0:\n raise ValueError(\"\u591a\u9879\u5f0f\u7cfb\u6570\u5fc5\u987b\u4e3a\u5076\u6570\")\n elif n - 1 > 0 and xs[-1] == 0:\n raise ValueError(\"\u591a\u9879\u5f0f\u7cfb\u6570\u4e0d\u80fd\u5168\u4e3a\u96f6\")\n else:\n for i in range(n-1):\n if xs[i] == 0 and xs[i+1] == 0:\n return 0\n if xs[i] == 0:\n return 0\n if xs[i] > 0 and xs[i+1] > 0:\n if xs[i] > max(xs[i+1], 0):\n return 0\n elif xs[i] < 0 and xs[i+1] < 0:\n if xs[i] > max(xs[i+1], 0):\n return 0\n elif xs[i] > 0 and xs[i+1] < 0:\n if abs(xs[i]) > abs(xs[i+1]):\n return 0\n elif xs[i] < 0 and xs[i+1] > 0:\n if abs(xs[i]) > abs(xs[i+1]):\n return 0\n else:\n if abs(xs[i]) > abs(xs[i+1]):\n return 0\n elif xs[i] > 0 and xs[i+1] > 0:\n return round(xs[i]-xs[i+1], 2)\n elif xs[i] < 0 and xs[i+1] < 0:\n return round(-xs[i]-xs[i+1], 2)\n else:\n return round(math.sqrt(xs[i]**2 + xs[i+1]**2), 2)"} {"task_id": "HumanEval/33", "completion": "\ndef sort_third(l):\n \n l_prime = [] # \u5b58\u653e\u80fd\u88ab3\u6574\u9664\u7684\u5143\u7d20\n for i in range(len(l)):\n if i % 3 == 0:\n l_prime.append(l[i])\n l_prime.sort() # \u5bf9\u80fd\u88ab3\u6574\u9664\u7684\u5143\u7d20\u8fdb\u884c\u6392\u5e8f\n for i in range(len(l)):\n if i % 3 != 0:\n l[i] = l_prime.pop(0) # \u5c06\u80fd\u88ab3\u6574\u9664\u7684\u5143\u7d20\u4f9d\u6b21\u8d4b\u503c\u7ed9\u4e0d\u80fd\u88ab3\u6574\u9664\u7684\u4f4d\u7f6e\n return l"} {"task_id": "HumanEval/34", "completion": "\ndef unique(l):\n \n # \u79fb\u9664\u91cd\u590d\u5143\u7d20\n l = list(set(l))\n # \u5bf9\u5217\u8868\u8fdb\u884c\u6392\u5e8f\n l.sort()\n return l"} {"task_id": "HumanEval/35", "completion": "\ndef max_element(l: list):\n \n return max(l)"} {"task_id": "HumanEval/36", "completion": "\ndef fizz_buzz(n):\n \n count = 0 # \u521d\u59cb\u5316\u8ba1\u6570\u5668\n for i in range(1, n):\n if i % 11 == 0 or i % 13 == 0: # \u5224\u65ad\u662f\u5426\u80fd\u88ab11\u621613\u6574\u9664\n count += str(i).count('7') # \u7d2f\u79ef7\u7684\u51fa\u73b0\u6b21\u6570\n return count"} {"task_id": "HumanEval/37", "completion": "\ndef sort_even(l):\n \n # \u590d\u5236\u5217\u8868 l \u5e76\u5f97\u5230\u4e00\u4e2a\u65b0\u7684\u5217\u8868\uff0c\u4f7f\u5f97\u5076\u6570\u7d22\u5f15\u4e0a\u7684\u5143\u7d20\u4e0e\u539f\u5217\u8868\u76f8\u540c\n l_prime = l[:]\n for i in range(len(l)):\n if i % 2 == 0:\n l_prime[i] = l[i]\n # \u5bf9\u5076\u6570\u7d22\u5f15\u4e0a\u7684\u5143\u7d20\u8fdb\u884c\u4ece\u5c0f\u5230\u5927\u6392\u5e8f\n l_prime.sort()\n return l_prime"} {"task_id": "HumanEval/38", "completion": "\ndef encode_cyclic(s: str):\n \n # \u5c06\u5b57\u7b26\u4e32\u62c6\u5206\u4e3a\u7ec4\uff0c\u6bcf\u4e2a\u7ec4\u7684\u957f\u5ea6\u4e3a3\u3002\n groups = [s[(3 * i):min((3 * i + 3), len(s))] for i in range((len(s) + 2) // 3)]\n # \u5728\u6bcf\u4e2a\u7ec4\u4e2d\u5faa\u73af\u5143\u7d20\uff0c\u9664\u975e\u8be5\u7ec4\u7684\u5143\u7d20\u5c11\u4e8e3\u4e2a\u3002\n groups = [(group[1:] + group[0]) if len(group) == 3 else group for group in groups]\n return \"\".join(groups)\ndef decode_cyclic(s: str):\n \"\"\"\n \u63a5\u53d7encode_cyclic\u51fd\u6570\u7f16\u7801\u7684\u5b57\u7b26\u4e32\uff0c\u8fd4\u56de\u89e3\u7801\u7684\u5b57\u7b26\u4e32\u3002\n \"\"\"\n # \u5c06\u5b57\u7b26\u4e32\u62c6\u5206\u4e3a\u7ec4\uff0c\u6bcf\u4e2a\u7ec4\u7684\u957f\u5ea6\u4e3a3\u3002\n groups = [s[(3 * i):min((3 * i + 3), len(s))] for i in range((len(s) + 2) // 3)]\n # \u5728\u6bcf\u4e2a\u7ec4\u4e2d\u5faa\u73af\u5143\u7d20\uff0c\u9664\u975e\u8be5\u7ec4\u7684\u5143\u7d20\u5c11\u4e8e3\u4e2a\u3002\n groups = [(group[1:] + group[0]) if len(group) == 3 else group for group in groups]\n # \u5c06\u6bcf\u4e2a\u7ec4\u91cd\u65b0\u7ec4\u5408\u6210\u5b57\u7b26\u4e32\u3002\n return \"\".join(groups)"} {"task_id": "HumanEval/39", "completion": "\ndef prime_fib(n):\n \n def is_prime(num):\n \n if num < 2:\n return False\n for i in range(2, int(num ** 0.5) + 1):\n if num % i == 0:\n return False\n return True\n def fibonacci(n):\n \"\"\"\n \u751f\u6210\u6590\u6ce2\u90a3\u5951\u6570\u5217\n \u53c2\u6570:\n n (int): \u6570\u5217\u957f\u5ea6\n \u8fd4\u56de\u503c:\n list: \u6590\u6ce2\u90a3\u5951\u6570\u5217\n \"\"\"\n fib = [0, 1]\n for i in range(2, n):\n fib.append(fib[i - 1] + fib[i - 2])\n return fib\n fib_numbers = fibonacci(100) # \u751f\u6210\u4e00\u4e2a\u8f83\u5927\u7684\u6590\u6ce2\u90a3\u5951\u6570\u5217\n prime_fib_numbers = []\n for num in fib_numbers:\n if is_prime(num):\n prime_fib_numbers.append(num)\n if len(prime_fib_numbers) == n:\n return prime_fib_numbers[n - 1]\n return None # \u5982\u679c\u627e\u4e0d\u5230\u7b2cn\u4e2a\u6590\u6ce2\u90a3\u5951\u8d28\u6570\uff0c\u5219\u8fd4\u56deNone"} {"task_id": "HumanEval/40", "completion": "\ndef triples_sum_to_zero(l: list):\n \n n = len(l)\n if n < 3:\n return False\n l.sort()\n for i in range(n-2):\n if l[i] > 0:\n return False\n if l[i] + l[i+1] + l[i+2] == 0:\n return True\n l[i] = -l[i]\n return False"} {"task_id": "HumanEval/41", "completion": "\ndef car_race_collision(n):\n # \u521d\u59cb\u5316\u8ba1\u6570\u5668\n count = 0\n # \u5faa\u73afn\u6b21\uff0c\u8868\u793a\u6240\u6709\u8f66\u8f86\u90fd\u53d1\u751f\u4e86\u78b0\u649e\n for i in range(n):\n # \u8ba1\u7b97\u5f53\u524d\u8f66\u8f86\u7684\u901f\u5ea6\n speed = i + 1\n # \u5faa\u73afn\u6b21\uff0c\u8868\u793a\u6bcf\u8f86\u8f66\u90fd\u4ee5\u76f8\u540c\u7684\u901f\u5ea6\u884c\u9a76\n for j in range(n):\n # \u5982\u679c\u53d1\u73b0\u6709\u4e00\u8f86\u8f66\u5728\u76f8\u9047\u65f6\u5177\u6709\u66f4\u957f\u7684\u884c\u9a76\u8ddd\u79bb\uff0c\u5219\u8ba4\u4e3a\u53d1\u751f\u4e86\u78b0\u649e\n if j + i >= n:\n count += 1\n else:\n # \u8ba1\u7b97\u5f53\u524d\u8f66\u8f86\u4e0e\u4ece\u53f3\u5230\u5de6\u884c\u9a76\u7684\u8f66\u8f86\u76f8\u9047\u65f6\u7684\u65f6\u95f4\n time = (j - i) / speed\n # \u5982\u679c\u76f8\u9047\u65f6\u95f4\u5c0f\u4e8e0\uff0c\u6216\u8005\u5927\u4e8e\u7b49\u4e8e\u603b\u65f6\u95f4\uff0c\u5219\u8ba4\u4e3a\u53d1\u751f\u4e86\u78b0\u649e\n if time < 0 or time >= n:\n count += 1\n else:\n # \u66f4\u65b0\u901f\u5ea6\n speed = (speed + j) / 2\n return count"} {"task_id": "HumanEval/42", "completion": "\ndef incr_list(l: list):\n \n return [x+1 for x in l]"} {"task_id": "HumanEval/43", "completion": "\ndef pairs_sum_to_zero(l):\n \n seen = set()\n for num in l:\n target = -num\n if target in seen:\n return True\n seen.add(num)\n return False"} {"task_id": "HumanEval/44", "completion": "\ndef change_base(x: int, base: int):\n \n if x == 0:\n return '0'\n result = ''\n while x > 0:\n remainder = x % base\n if remainder < 10:\n result = str(remainder) + result\n else:\n result = chr(ord('A') + remainder - 10) + result\n x //= base\n return result"} {"task_id": "HumanEval/45", "completion": "\ndef triangle_area(a, h):\n \n area = (a * h) / 2\n return area"} {"task_id": "HumanEval/46", "completion": "\ndef fib4(n):\n \n if n == 0:\n return 0\n elif n == 1 or n == 2:\n return 2\n else:\n a, b, c, d = 2, 3, 5, 8\n for i in range(4, n+1):\n a, b, c, d = b, c, d, a + b + c + d\n return d"} {"task_id": "HumanEval/47", "completion": "\ndef median(l: list):\n \n sorted_list = sorted(l)\n length = len(sorted_list)\n if length % 2 == 0:\n return (sorted_list[length//2-1] + sorted_list[length//2])/2\n else:\n return sorted_list[length//2]"} {"task_id": "HumanEval/48", "completion": "\ndef is_palindrome(text: str):\n \n # \u53bb\u9664\u7a7a\u683c\u548c\u6807\u70b9\u7b26\u53f7\uff0c\u5e76\u5c06\u5b57\u7b26\u4e32\u5168\u90e8\u8f6c\u6362\u4e3a\u5c0f\u5199\n text = ''.join(c.lower() for c in text if c.isalnum())\n # \u5224\u65ad\u53cd\u8f6c\u540e\u7684\u5b57\u7b26\u4e32\u662f\u5426\u4e0e\u539f\u5b57\u7b26\u4e32\u76f8\u7b49\n return text == text[::-1]"} {"task_id": "HumanEval/49", "completion": "\ndef modp(n, p):\n \n result = pow(2, n, p)\n return result"} {"task_id": "HumanEval/50", "completion": "\n\ndef encode_shift(s: str):\n \n return \"\".join([chr(((ord(ch) + 5 - ord(\"a\")) % 26) + ord(\"a\")) for ch in s])\ndef decode_shift(s: str):\n \"\"\"\n \u8be5\u51fd\u6570\u63a5\u53d7encode_shift\u51fd\u6570\u7f16\u7801\u7684\u5b57\u7b26\u4e32\u4f5c\u4e3a\u8f93\u5165\uff0c\u8fd4\u56de\u89e3\u7801\u7684\u5b57\u7b26\u4e32\u3002\n \"\"\"\n return \"\".join([chr(((ord(ch) - ord(\"a\") - 5) % 26) + ord(\"a\")) for ch in s])"} {"task_id": "HumanEval/51", "completion": "\ndef remove_vowels(text):\n \n vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']\n result = ''\n for char in text:\n if char not in vowels:\n result += char\n return result"} {"task_id": "HumanEval/52", "completion": "\ndef below_threshold(l: list, t: int):\n \n for num in l:\n if num >= t:\n return False\n return True"} {"task_id": "HumanEval/53", "completion": "\ndef add(x: int, y: int):\n \n return x + y"} {"task_id": "HumanEval/54", "completion": "\ndef same_chars(s0, s1):\n \n # \u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u96c6\u5408\uff0c\u53bb\u9664\u91cd\u590d\u5b57\u7b26\n set0 = set(s0)\n set1 = set(s1)\n # \u6c42\u4e24\u4e2a\u96c6\u5408\u7684\u4ea4\u96c6\n common_chars = set0.intersection(set1)\n # \u5224\u65ad\u4ea4\u96c6\u662f\u5426\u4e0e\u5176\u4e2d\u4e00\u4e2a\u96c6\u5408\u76f8\u7b49\n return common_chars == set0 or common_chars == set1"} {"task_id": "HumanEval/55", "completion": "\ndef fib(n: int):\n \n if n <= 0:\n return None\n elif n == 1 or n == 2:\n return 1\n else:\n a, b = 1, 1\n for _ in range(3, n + 1):\n a, b = b, a + b\n return b"} {"task_id": "HumanEval/56", "completion": "\ndef correct_bracketing(brackets: str):\n \n stack = []\n for char in brackets:\n if char == \"<\":\n stack.append(char)\n elif char == \">\":\n if len(stack) == 0 or stack[-1] != \"<\":\n return False\n stack.pop()\n return len(stack) == 0"} {"task_id": "HumanEval/57", "completion": "\ndef monotonic(l):\n \n return l == sorted(l) or l == sorted(l, reverse=True)"} {"task_id": "HumanEval/58", "completion": "\ndef common(l1: list, l2: list):\n \n # \u5148\u5bf9\u4e24\u4e2a\u5217\u8868\u8fdb\u884c\u6392\u5e8f\n l1.sort()\n l2.sort()\n # \u53d6\u4e24\u4e2a\u5217\u8868\u7684\u4ea4\u96c6\uff0c\u5e76\u6392\u5e8f\n return sorted(set(l1) & set(l2))"} {"task_id": "HumanEval/59", "completion": "\ndef largest_prime_factor(n):\n \n # \u4ece2\u5f00\u59cb\u904d\u5386\u5230n\u7684\u5e73\u65b9\u6839\n # \u56e0\u4e3a\u6700\u5927\u8d28\u56e0\u6570\u4e0d\u4f1a\u8d85\u8fc7n\u7684\u5e73\u65b9\u6839\n i = 2\n while i * i <= n:\n if n % i:\n i += 1\n else:\n n //= i\n return n"} {"task_id": "HumanEval/60", "completion": "\ndef sum_to_n(n: int):\n \n return sum(range(1, n+1))"} {"task_id": "HumanEval/61", "completion": "\ndef correct_bracketing(brackets: str):\n \n stack = []\n for char in brackets:\n if char == \"(\":\n stack.append(char)\n elif char == \")\":\n if len(stack) == 0 or stack[-1] != \"(\":\n return False\n stack.pop()\n return len(stack) == 0"} {"task_id": "HumanEval/62", "completion": "\ndef derivative(xs):\n \n n = len(xs)\n result = [0] * (n - 1)\n for i in range(1, n):\n result[i - 1] = i * xs[i]\n return result"} {"task_id": "HumanEval/63", "completion": "\ndef fibfib(n):\n \n if n == 1:\n return 0\n elif n == 2:\n return 1\n elif n == 3:\n return 1\n else:\n a, b, c = 0, 1, 1\n for _ in range(4, n+1):\n a, b, c = b, c, a + b + c\n return c"} {"task_id": "HumanEval/64", "completion": "\ndef vowels_count(s):\n \n vowels = ['a', 'e', 'i', 'o', 'u']\n count = 0\n if s[-1].lower() in vowels:\n count += 1\n for i in range(len(s)):\n if s[i].lower() in vowels:\n count += 1\n return count"} {"task_id": "HumanEval/65", "completion": "\ndef circular_shift(x, shift):\n \n # \u8ba1\u7b97\u6574\u6570x\u7684\u4f4d\u6570\n digits = 0\n temp = x\n while temp > 0:\n digits += 1\n temp //= 10\n # \u8fdb\u884c\u79fb\u52a8\u64cd\u4f5c\n if shift > digits:\n # \u53cd\u8f6c\u6574\u6570x\u7684\u5404\u4f4d\u6570\u5b57\n result = 0\n for i in range(digits // 2):\n result = result * 10 + x % 10\n x //= 10\n result *= 10\n for i in range(digits % 2):\n result = result * 10 + x % 10\n x //= 10\n return str(result)\n else:\n # \u5c06\u6bcf\u4e00\u4f4d\u6570\u5b57\u53f3\u79fbshift\u4f4d\n result = 0\n for i in range(shift):\n result = result * 10 + x % 10\n x //= 10\n return str(result)"} {"task_id": "HumanEval/66", "completion": "\ndef digitSum(s):\n total = 0\n for c in s:\n if c.isupper():\n total += ord(c)\n return total"} {"task_id": "HumanEval/67", "completion": "\ndef fruit_distribution(s,n):\n apples = s.split(\" \")[0]\n oranges = s.split(\" \")[1]\n mangoes = n - int(apples) - int(oranges)\n return int(mangoes)"} {"task_id": "HumanEval/68", "completion": "\ndef pluck(arr):\n if not arr:\n return []\n min_even = float('inf')\n min_index = -1\n for i, num in enumerate(arr):\n if num % 2 == 0 and num < min_even:\n min_even = num\n min_index = i\n return [min_even, min_index] if min_even != float('inf') else []"} {"task_id": "HumanEval/69", "completion": "\ndef search(lst):\n \n # \u7edf\u8ba1\u6bcf\u4e2a\u6574\u6570\u51fa\u73b0\u7684\u6b21\u6570\n count = {}\n for num in lst:\n count[num] = count.get(num, 0) + 1\n \n # \u627e\u5230\u6ee1\u8db3\u6761\u4ef6\u7684\u6700\u5927\u6574\u6570\n max_num = -1\n for num, freq in count.items():\n if freq >= num and num > max_num:\n max_num = num\n \n return max_num"} {"task_id": "HumanEval/70", "completion": "\ndef strange_sort_list(lst):\n \n # \u5982\u679c\u5217\u8868\u4e3a\u7a7a\uff0c\u76f4\u63a5\u8fd4\u56de\u7a7a\u5217\u8868\n if not lst:\n return []\n # \u627e\u5230\u5217\u8868\u4e2d\u7684\u6700\u5c0f\u503c\n min_value = min(lst)\n # \u521b\u5efa\u4e00\u4e2a\u7a7a\u5217\u8868\uff0c\u7528\u4e8e\u5b58\u653e\u7ed3\u679c\n result = []\n # \u4ece\u6700\u5c0f\u503c\u5f00\u59cb\uff0c\u4f9d\u6b21\u6dfb\u52a0\u5230\u7ed3\u679c\u5217\u8868\u4e2d\n while min_value != max(lst):\n result.append(min_value)\n min_value = min(lst)\n return result"} {"task_id": "HumanEval/71", "completion": "\ndef triangle_area(a, b, c):\n \n # \u5224\u65ad\u662f\u5426\u80fd\u7ec4\u6210\u4e09\u89d2\u5f62\n if a + b > c and a + c > b and b + c > a:\n # \u4f7f\u7528\u6d77\u4f26\u516c\u5f0f\u8ba1\u7b97\u9762\u79ef\n s = (a + b + c) / 2\n area = (s * (s - a) * (s - b) * (s - c)) ** 0.5\n return round(area, 2)\n else:\n return -1"} {"task_id": "HumanEval/72", "completion": "\ndef will_it_fly(q,w):\n \n if sum(q) <= w and q == q[::-1]:\n return True\n else:\n return False"} {"task_id": "HumanEval/73", "completion": "\ndef smallest_change(arr):\n \n n = len(arr)\n changes = 0\n for i in range(n//2):\n left = arr[i]\n right = arr[n-i-1]\n if left != right:\n changes += 1\n \n return changes"} {"task_id": "HumanEval/74", "completion": "\ndef total_match(lst1, lst2):\n \n # \u7edf\u8ba1\u4e24\u4e2a\u5217\u8868\u4e2d\u5b57\u7b26\u4e32\u7684\u603b\u6570\n count1 = sum(len(s) for s in lst1)\n count2 = sum(len(s) for s in lst2)\n # \u5982\u679c\u4e24\u4e2a\u5217\u8868\u5177\u6709\u76f8\u540c\u6570\u91cf\u7684\u5b57\u7b26\uff0c\u5219\u8fd4\u56de\u7b2c\u4e00\u4e2a\u5217\u8868\n if count1 == count2:\n return lst1\n # \u5982\u679c\u7b2c\u4e00\u4e2a\u5217\u8868\u4e2d\u5b57\u7b26\u4e32\u7684\u6570\u91cf\u591a\u4e8e\u7b2c\u4e8c\u4e2a\u5217\u8868\uff0c\u5219\u8fd4\u56de\u7b2c\u4e00\u4e2a\u5217\u8868\n if count1 > count2:\n return lst1\n # \u5982\u679c\u7b2c\u4e8c\u4e2a\u5217\u8868\u4e2d\u5b57\u7b26\u4e32\u7684\u6570\u91cf\u591a\u4e8e\u7b2c\u4e00\u4e2a\u5217\u8868\uff0c\u5219\u8fd4\u56de\u7b2c\u4e8c\u4e2a\u5217\u8868\n return lst2"} {"task_id": "HumanEval/75", "completion": "\ndef is_multiply_prime(a):\n \n def is_prime(num):\n if num < 2:\n return False\n for i in range(2, int(num ** 0.5) + 1):\n if num % i == 0:\n return False\n return True\n primes = []\n for i in range(2, a):\n if is_prime(i):\n primes.append(i)\n if len(primes) >= 3:\n if a % (primes[-1] * primes[-2] * primes[-3]) == 0:\n return True\n else:\n primes.pop()\n return False"} {"task_id": "HumanEval/76", "completion": "\ndef is_simple_power(x, n):\n \n if x == 1:\n return True\n if n == 1:\n return False\n k = 0\n while n ** k <= x:\n if n ** k == x:\n return True\n k += 1\n return False"} {"task_id": "HumanEval/77", "completion": "\ndef iscube(a):\n \n if a < 0:\n a = -a\n root = round(a ** (1/3))\n return root ** 3 == a"} {"task_id": "HumanEval/78", "completion": "\ndef hex_key(num):\n \n if num == '0':\n return 0\n elif num == '1':\n return 1\n elif num == '2':\n return 2\n elif num == '3':\n return 3\n elif num == '4':\n return 4\n elif num == '5':\n return 5\n elif num == '6':\n return 6\n elif num == '7':\n return 7\n elif num == '8':\n return 8\n elif num == '9':\n return 9\n elif num == 'A':\n return 10\n elif num == 'B':\n return 11\n elif num == 'C':\n return 12\n elif num == 'D':\n return 13\n elif num == 'E':\n return 14\n elif num == 'F':\n return 15\n"} {"task_id": "HumanEval/79", "completion": "\ndef decimal_to_binary(decimal):\n \n binary = bin(decimal)[2:] # \u5c06\u5341\u8fdb\u5236\u6570\u8f6c\u6362\u4e3a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\uff0c\u53bb\u6389\u524d\u7f00'0b'\n binary = '1' + binary.zfill(8) # \u5728\u5b57\u7b26\u4e32\u5f00\u5934\u6dfb\u52a0\u4e00\u4e2a'1'\uff0c\u7136\u540e\u4f7f\u7528zfill\u586b\u5145\u52308\u4f4d\n binary = 'db' + binary # \u5728\u5b57\u7b26\u4e32\u5f00\u5934\u6dfb\u52a0'db'\n return binary"} {"task_id": "HumanEval/80", "completion": "\ndef is_happy(s):\n \n if len(s) < 3:\n return False\n for i in range(len(s) - 2):\n if s[i] != s[i + 1] and s[i] != s[i + 2] and s[i + 1] != s[i + 2]:\n return False\n return True"} {"task_id": "HumanEval/81", "completion": "\ndef numerical_letter_grade(grades):\n \n letter_grades = []\n for grade in grades:\n if grade >= 3.7:\n letter_grades.append('A+')\n elif grade >= 3.3:\n letter_grades.append('A')\n elif grade >= 3.0:\n letter_grades.append('A-')\n elif grade >= 2.7:\n letter_grades.append('B+')\n elif grade >= 2.3:\n letter_grades.append('B')\n elif grade >= 2.0:\n letter_grades.append('B-')\n elif grade >= 1.7:\n letter_grades.append('C+')\n elif grade >= 1.3:\n letter_grades.append('C')\n elif grade >= 1.0:\n letter_grades.append('C-')\n else:\n letter_grades.append('D+')\n # \u5982\u679c\u8f93\u5165\u7684\u6210\u7ee9\u5c0f\u4e8e3.0\uff0c\u5219\u6dfb\u52a0'E'\n if grade < 3.0:\n letter_grades.append('E')\n return letter_grades"} {"task_id": "HumanEval/82", "completion": "\ndef prime_length(string):\n \n length = len(string)\n if length < 2:\n return False\n for i in range(2, int(length ** 0.5) + 1):\n if length % i == 0:\n return False\n return True"} {"task_id": "HumanEval/83", "completion": "\ndef starts_one_ends(n):\n count = 0\n for i in range(1, 10):\n if i == 1:\n count += 1\n elif str(i).startswith('1') and str(i).endswith('1'):\n count += 1\n return count"} {"task_id": "HumanEval/84", "completion": "\ndef solve(N):\n sum = 0\n while N > 0:\n digit = N % 10\n sum += digit\n N = N // 10\n return bin(sum)[2:]"} {"task_id": "HumanEval/85", "completion": "\ndef add(lst):\n \n total = 0\n for i in range(len(lst)):\n if i % 2 == 1 and lst[i] % 2 == 0:\n total += lst[i]\n return total"} {"task_id": "HumanEval/86", "completion": "\ndef anti_shuffle(s):\n \n words = s.split()\n sorted_words = [\"\".join(sorted(word)) for word in words]\n return \" \".join(sorted_words)"} {"task_id": "HumanEval/87", "completion": "\ndef get_row(lst, x):\n \n row_index = []\n for i in range(len(lst)):\n for j in range(len(lst[i])):\n if lst[i][j] == x:\n row_index.append((i, j))\n row_index.sort(key=lambda x: (x[0], -x[1]))\n return row_index"} {"task_id": "HumanEval/88", "completion": "\ndef sort_array(array):\n \n if len(array) <= 1:\n return array\n # \u5224\u65ad\u7b2c\u4e00\u4e2a\u7d22\u5f15\u503c\u548c\u6700\u540e\u4e00\u4e2a\u7d22\u5f15\u503c\u7684\u548c\u662f\u5947\u6570\u8fd8\u662f\u5076\u6570\n total_sum = array[0] + array[-1]\n is_odd = total_sum % 2 != 0\n # \u6839\u636e\u548c\u7684\u5947\u5076\u6027\u8fdb\u884c\u6392\u5e8f\n if is_odd:\n return sorted(array)\n else:\n return sorted(array, reverse=True)"} {"task_id": "HumanEval/89", "completion": "\ndef encrypt(s):\n \n result = \"\"\n for char in s:\n if char.isalpha():\n if char.islower():\n base = ord('a')\n else:\n base = ord('A')\n rotated_char = chr((ord(char) - base + 2) % 26 + base)\n result += rotated_char\n else:\n result += char\n return result"} {"task_id": "HumanEval/90", "completion": "\ndef next_smallest(lst):\n \n if len(lst) < 2:\n return None\n smallest = min(lst)\n second_smallest = float('inf')\n for num in lst:\n if num > smallest and num < second_smallest:\n second_smallest = num\n if second_smallest == float('inf'):\n return None\n else:\n return second_smallest"} {"task_id": "HumanEval/91", "completion": "\ndef is_bored(S):\n \n sentences = S.split(\".\")\n count = 0\n for sentence in sentences:\n words = sentence.strip().split()\n if words[0] == \"I\":\n count += 1\n return count"} {"task_id": "HumanEval/92", "completion": "\ndef any_int(x, y, z):\n \n if not isinstance(x, int) or not isinstance(y, int) or not isinstance(z, int):\n return False\n if x + y == z or x + z == y or y + z == x:\n return True\n return False"} {"task_id": "HumanEval/93", "completion": "\ndef encode(message):\n \n vowels = 'aeiouAEIOU'\n encoded_message = ''\n for char in message:\n if char.lower() in vowels:\n if char.lower() == 'a':\n encoded_message += 'C'\n elif char.lower() == 'e':\n encoded_message += 'G'\n elif char.lower() == 'i':\n encoded_message += 'K'\n elif char.lower() == 'o':\n encoded_message += 'Q'\n elif char.lower() == 'u':\n encoded_message += 'S'\n elif char.lower() == 'A':\n encoded_message += 'C'\n elif char.lower() == 'E':\n encoded_message += 'G'\n elif char.lower() == 'I':\n encoded_message += 'K'\n elif char.lower() == 'O':\n encoded_message += 'Q'\n elif char.lower() == 'U':\n encoded_message += 'S'\n else:\n encoded_message += char\n return encoded_message"} {"task_id": "HumanEval/94", "completion": "\ndef skjkasdkd(lst):\n def is_prime(n):\n if n < 2:\n return False\n for i in range(2, int(n ** 0.5) + 1):\n if n % i == 0:\n return False\n return True\n max_prime = None\n for num in lst:\n if is_prime(num):\n if max_prime is None or num > max_prime:\n max_prime = num\n if max_prime is not None:\n return sum(int(digit) for digit in str(max_prime))\n else:\n return 0"} {"task_id": "HumanEval/95", "completion": "\ndef check_dict_case(dict):\n \n if not dict:\n return False\n keys = list(dict.keys())\n if all(isinstance(key, str) and key.islower() for key in keys):\n return True\n elif all(isinstance(key, str) and key.isupper() for key in keys):\n return True\n else:\n return False"} {"task_id": "HumanEval/96", "completion": "\ndef count_up_to(n):\n \n def is_prime(num):\n if num < 2:\n return False\n for i in range(2, int(num ** 0.5) + 1):\n if num % i == 0:\n return False\n return True\n primes = []\n for i in range(2, n):\n if is_prime(i):\n primes.append(i)\n return primes"} {"task_id": "HumanEval/97", "completion": "\ndef multiply(a, b):\n return (a % 10) * (b % 10)"} {"task_id": "HumanEval/98", "completion": "\ndef count_upper(s):\n \n vowels = ['A', 'E', 'I', 'O', 'U']\n count = 0\n for i in range(len(s)):\n if i % 2 == 0 and s[i] in vowels:\n count += 1\n return count"} {"task_id": "HumanEval/99", "completion": "\ndef closest_integer(value):\n \n # \u5c06\u5b57\u7b26\u4e32\u5206\u5272\u6210\u6570\u5b57\u5217\u8868\n num_list = value.split('.')\n # \u5c06\u6570\u5b57\u5217\u8868\u8f6c\u6362\u4e3a\u6574\u6570\u5217\u8868\n num_list = [int(num) for num in num_list]\n # \u627e\u5230\u6700\u63a5\u8fd1\u7684\u6574\u6570\n closest_num = num_list[0]\n min_diff = abs(num_list[0] - int(num_list[0]))\n for num in num_list:\n diff = abs(num - int(num))\n if diff < min_diff:\n closest_num = num\n min_diff = diff\n elif diff == min_diff and num > closest_num:\n closest_num = num\n # \u6839\u636e\u8ddd\u79bb0\u7684\u65b9\u5411\u53d6\u6574\n for i in range(len(num_list)-1):\n if abs(num_list[i] - int(num_list[i])) == min_diff:\n if num_list[i] < closest_num:\n closest_num = num_list[i]\n elif num_list[i] > closest_num:\n closest_num = num_list[i]\n break\n return closest_num"} {"task_id": "HumanEval/100", "completion": "\ndef make_a_pile(n):\n \n result = []\n stones = n\n while n > 0:\n stones += 1\n if n % 2 == 0:\n stones -= n\n n -= 1\n result.append(stones)\n return result"} {"task_id": "HumanEval/101", "completion": "\ndef words_string(s):\n \n words = s.split()\n return words"} {"task_id": "HumanEval/102", "completion": "\ndef choose_num(x, y):\n max_even = -1\n for i in range(x, y+1):\n if i % 2 == 0 and i > max_even:\n max_even = i\n return max_even"} {"task_id": "HumanEval/103", "completion": "\ndef rounded_avg(n, m):\n \n if n > m:\n return -1\n \n total = 0\n count = 0\n for i in range(n, m+1):\n total += i\n count += 1\n \n average = total / count\n rounded_average = round(average)\n binary_representation = bin(rounded_average)\n return binary_representation"} {"task_id": "HumanEval/104", "completion": "\ndef unique_digits(x):\n \n result = []\n for num in x:\n digits = set(str(num))\n if all(int(digit) % 2 != 0 for digit in digits):\n result.append(num)\n \n return sorted(result)"} {"task_id": "HumanEval/105", "completion": "\ndef by_length(arr):\n # \u5bf9\u4ecb\u4e8e1\u548c9\u4e4b\u95f4\u7684\u6574\u6570\u8fdb\u884c\u6392\u5e8f\n arr = sorted(filter(lambda x: 1 <= x <= 9, arr))\n # \u53cd\u8f6c\u7ed3\u679c\u6570\u7ec4\n arr.reverse()\n # \u7528\"One\"\u3001\"Two\"\u3001\"Three\"\u3001\"Four\"\u3001\"Five\"\u3001\"Six\"\u3001\"Seven\"\u3001\"Eight\"\u3001\"Nine\"\u66ff\u6362\u6bcf\u4e2a\u6570\u5b57\n return [\"One\" if num == 1 else \"Two\" if num == 2 else \"Three\" if num == 3 else \"Four\" if num == 4 else \"Five\" if num == 5 else \"Six\" if num == 6 else \"Seven\" if num == 7 else \"Eight\" if num == 8 else \"Nine\" if num == 9 else num for num in arr]"} {"task_id": "HumanEval/106", "completion": "\ndef f(n):\n \n result = []\n for i in range(1, n+1):\n if i % 2 == 0:\n result.append(factorial(i))\n else:\n result.append(sum(range(1, i+1)))\n return result\ndef factorial(num):\n \n result = 1\n for i in range(1, num+1):\n result *= i\n return result"} {"task_id": "HumanEval/107", "completion": "\ndef even_odd_palindrome(n):\n \n even_count = 0\n odd_count = 0\n # \u904d\u5386\u8303\u56f4\u5185\u7684\u6bcf\u4e2a\u6570\n for num in range(1, n+1):\n # \u68c0\u67e5\u662f\u5426\u4e3a\u5076\u6570\u4e14\u662f\u56de\u6587\u6570\n if str(num) == str(num)[::-1] and num % 2 == 0:\n even_count += 1\n # \u68c0\u67e5\u662f\u5426\u4e3a\u5947\u6570\u4e14\u662f\u56de\u6587\u6570\n elif str(num) == str(num)[::-1] and num % 2 != 0:\n odd_count += 1\n return even_count, odd_count"} {"task_id": "HumanEval/108", "completion": "\ndef count_nums(arr):\n count = 0\n for num in arr:\n if num >= 0:\n count += 1\n return count"} {"task_id": "HumanEval/109", "completion": "\ndef move_one_ball(arr):\n n = len(arr)\n if n == 0:\n return True\n i = 1\n while i < n:\n if arr[i] < arr[i-1]:\n arr[i], arr[i-1] = arr[i-1], arr[i]\n i -= 1\n else:\n i += 1\n if arr[0] <= arr[1]:\n return False\n else:\n return True"} {"task_id": "HumanEval/110", "completion": "\ndef exchange(lst1, lst2):\n \n # \u7edf\u8ba1lst1\u4e2d\u5947\u6570\u7684\u4e2a\u6570\n odd_count = sum(1 for num in lst1 if num % 2 != 0)\n # \u7edf\u8ba1lst2\u4e2d\u5947\u6570\u7684\u4e2a\u6570\n odd_count_2 = sum(1 for num in lst2 if num % 2 != 0)\n # \u5982\u679clst1\u548clst2\u4e2d\u90fd\u6709\u5947\u6570\uff0c\u5219\u65e0\u6cd5\u901a\u8fc7\u4ea4\u6362\u5f97\u5230lst1\u4e2d\u7684\u6240\u6709\u5143\u7d20\u90fd\u662f\u5076\u6570\n if odd_count > 0 and odd_count_2 > 0:\n return \"NO\"\n # \u5982\u679clst1\u4e2d\u5947\u6570\u7684\u4e2a\u6570\u5927\u4e8elst2\u4e2d\u5947\u6570\u7684\u4e2a\u6570\uff0c\u5219\u65e0\u6cd5\u901a\u8fc7\u4ea4\u6362\u5f97\u5230lst1\u4e2d\u7684\u6240\u6709\u5143\u7d20\u90fd\u662f\u5076\u6570\n if odd_count > odd_count_2:\n return \"NO\"\n # \u904d\u5386lst2\u4e2d\u7684\u5143\u7d20\n for num2 in lst2:\n # \u5982\u679c\u5f53\u524d\u5143\u7d20\u662f\u5947\u6570\uff0c\u5219\u4ecelst1\u4e2d\u627e\u5230\u4e00\u4e2a\u5076\u6570\u8fdb\u884c\u4ea4\u6362\n if num2 % 2 != 0:\n found = False\n for num1 in lst1:\n if num1 % 2 == 0:\n lst1[lst1.index(num1)] = num2\n found = True\n break\n # \u5982\u679c\u672a\u627e\u5230\u5076\u6570\uff0c\u5219\u8fd4\u56de\"NO\"\n if not found:\n return \"NO\"\n return \"YES\""} {"task_id": "HumanEval/111", "completion": "\ndef histogram(test):\n \n # \u5148\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5c0f\u5199\u5b57\u6bcd\u5217\u8868\n str_list = test.lower().split()\n # \u7edf\u8ba1\u6bcf\u4e2a\u5c0f\u5199\u5b57\u6bcd\u51fa\u73b0\u7684\u6b21\u6570\n count_dict = {}\n for s in str_list:\n if s not in count_dict:\n count_dict[s] = 1\n else:\n count_dict[s] += 1\n # \u627e\u51fa\u51fa\u73b0\u6b21\u6570\u6700\u591a\u7684\u5b57\u6bcd\n max_count = max(count_dict.values())\n max_letter = [k for k, v in count_dict.items() if v == max_count]\n # \u6784\u9020\u8fd4\u56de\u7ed3\u679c\u7684\u5b57\u5178\n result_dict = {}\n for letter in max_letter:\n result_dict[letter] = max_count\n return result_dict"} {"task_id": "HumanEval/112", "completion": "\ndef reverse_delete(s,c):\n \n # \u5220\u9664c\u4e2d\u91cd\u590d\u7684\u5b57\u7b26\n for char in c:\n s = s.replace(char, \"\")\n \n # \u5224\u65ad\u662f\u5426\u662f\u56de\u6587\n is_palindrome = s == s[::-1]\n \n return (s, is_palindrome)"} {"task_id": "HumanEval/113", "completion": "\ndef odd_count(lst):\n \n result = []\n for i in range(len(lst)):\n count = 0\n for char in lst[i]:\n if char.isdigit() and int(char) % 2 != 0:\n count += 1\n result.append(f\"the number of odd elements {count} in the string {i+1} of the input.\")\n return result"} {"task_id": "HumanEval/114", "completion": "\ndef minSubArraySum(nums):\n \n n = len(nums)\n if n == 0:\n return 0\n # \u521d\u59cb\u5316\u6700\u5c0f\u503c\u548c\u5f53\u524d\u533a\u95f4\u548c\n min_sum = float('inf')\n curr_sum = 0\n # \u904d\u5386\u6570\u7ec4\uff0c\u66f4\u65b0\u6700\u5c0f\u503c\u548c\u533a\u95f4\u548c\n for i in range(n):\n curr_sum += nums[i]\n min_sum = min(min_sum, curr_sum)\n if curr_sum > 0:\n curr_sum = 0\n return min_sum"} {"task_id": "HumanEval/115", "completion": "\ndef max_fill(grid, capacity):\n import math\n \n n = len(grid)\n m = len(grid[0])\n \n ans = 0\n for i in range(n):\n for j in range(m):\n if grid[i][j] == 1:\n visited = [[False] * m for _ in range(n)]\n cnt = 0\n q = [(i, j)]\n while q:\n x, y = q.pop(0)\n if not visited[x][y]:\n visited[x][y] = True\n cnt += 1\n if grid[x][y] == 0:\n continue\n for dx, dy in [(1, 0), (-1, 0), (0, 1), (0, -1)]:\n nx, ny = x + dx, y + dy\n if 0 <= nx < n and 0 <= ny < m and not visited[nx][ny] and grid[nx][ny] == 0:\n q.append((nx, ny))\n if cnt > ans:\n ans = cnt\n b = (i, j)\n \n return ans\n"} {"task_id": "HumanEval/116", "completion": "\ndef sort_array(arr):\n def count_ones(num):\n return bin(num).count(\"1\")\n \n arr.sort(key=lambda x: (count_ones(x), x))\n return arr"} {"task_id": "HumanEval/117", "completion": "\ndef select_words(s, n):\n if not s:\n return []\n vowels = ['a', 'e', 'i', 'o', 'u']\n words = s.split()\n result = []\n for word in words:\n count = 0\n for letter in word:\n if letter.lower() not in vowels:\n count += 1\n if count == n:\n result.append(word)\n return result"} {"task_id": "HumanEval/118", "completion": "\ndef get_closest_vowel(word):\n \n vowels = ['a', 'e', 'i', 'o', 'u']\n for i in range(len(word) - 2):\n if word[i] in vowels and word[i+1] not in vowels and word[i+2] not in vowels:\n return word[i]\n return \"\""} {"task_id": "HumanEval/119", "completion": "\ndef match_parens(lst):\n \n stack = []\n for s in lst:\n stack.append(s)\n \n for i in range(len(stack)):\n for j in range(len(stack)):\n if i != j:\n stack[i] = stack[i][::-1] + stack[j]\n \n for s in stack:\n if not is_balanced(s):\n return 'No'\n \n return 'Yes'\ndef is_balanced(s):\n stack = []\n for c in s:\n if c == '(':\n stack.append(c)\n elif c == ')':\n if not stack or stack[-1] != '(':\n return False\n stack.pop()\n return len(stack) == 0"} {"task_id": "HumanEval/120", "completion": "\ndef maximum(arr, k):\n \n if k == 0:\n return []\n arr.sort(reverse=True)\n return arr[:k]"} {"task_id": "HumanEval/121", "completion": "\ndef solution(lst):\n \n odd_sum = 0\n for i in range(0, len(lst), 2): # \u904d\u5386\u5076\u6570\u7d22\u5f15\u4f4d\u7f6e\n if lst[i] % 2 != 0: # \u5224\u65ad\u5143\u7d20\u662f\u5426\u4e3a\u5947\u6570\n odd_sum += lst[i]\n return odd_sum"} {"task_id": "HumanEval/122", "completion": "\ndef add_elements(arr, k):\n \n total = 0\n for num in arr[:k]:\n if num <= 99:\n total += num\n return total"} {"task_id": "HumanEval/123", "completion": "\ndef get_odd_collatz(n):\n result = []\n while n != 1:\n if n % 2 == 1: # \u5982\u679c\u5f53\u524d\u9879\u4e3a\u5947\u6570\n result.append(n) # \u5c06\u5f53\u524d\u9879\u6dfb\u52a0\u5230\u7ed3\u679c\u5217\u8868\u4e2d\n n = n // 2 if n % 2 == 0 else n * 3 + 1 # \u6839\u636e\u5b9a\u4e49\u8ba1\u7b97\u4e0b\u4e00\u9879\n return sorted(result) # \u5bf9\u7ed3\u679c\u5217\u8868\u8fdb\u884c\u5347\u5e8f\u6392\u5e8f"} {"task_id": "HumanEval/124", "completion": "\ndef valid_date(date):\n \n if not date:\n return False\n year, month, day = date.split('-')\n month = int(month)\n day = int(day)\n if month < 1 or month > 12:\n return False\n if month in [1, 3, 5, 7, 8, 10, 12]:\n max_day = 31\n elif month in [4, 6, 9, 11]:\n max_day = 30\n else:\n max_day = 29\n if day < 1 or day > max_day:\n return False\n return True"} {"task_id": "HumanEval/125", "completion": "\ndef split_words(txt):\n \n words = txt.split()\n if ' ' not in txt:\n return words\n else:\n return words\n if ',' not in txt:\n return sum(1 for c in txt if c.isalpha())\n else:\n return sum(1 for c in txt if c.isalpha())\n return sum(1 for c in txt if ord(c) % 2 != 0)"} {"task_id": "HumanEval/126", "completion": "\ndef is_sorted(lst):\n \n # \u5224\u65ad\u5217\u8868\u957f\u5ea6\u662f\u5426\u5c0f\u4e8e\u7b49\u4e8e1\uff0c\u5982\u679c\u662f\u76f4\u63a5\u8fd4\u56deTrue\n if len(lst) <= 1:\n return True\n \n # \u904d\u5386\u5217\u8868\u5143\u7d20\uff0c\u68c0\u67e5\u662f\u5426\u6ee1\u8db3\u6761\u4ef6\n for i in range(1, len(lst)):\n # \u5982\u679c\u5f53\u524d\u5143\u7d20\u5927\u4e8e\u524d\u4e00\u4e2a\u5143\u7d20\uff0c\u6216\u8005\u5f53\u524d\u5143\u7d20\u4e0e\u524d\u4e00\u4e2a\u5143\u7d20\u76f8\u7b49\u4f46\u51fa\u73b0\u6b21\u6570\u8d85\u8fc72\u6b21\uff0c\u8fd4\u56deFalse\n if lst[i] > lst[i-1] or (lst[i] == lst[i-1] and lst.count(lst[i]) > 2):\n return False\n \n return True"} {"task_id": "HumanEval/127", "completion": "\ndef intersection(interval1, interval2):\n \n start1, end1 = interval1[0], interval1[1]\n start2, end2 = interval2[0], interval2[1]\n # \u8ba1\u7b97\u4ea4\u96c6\u7684\u957f\u5ea6\n intersection_length = max(0, min(end1, end2) - max(start1, start2))\n # \u5224\u65ad\u4ea4\u96c6\u957f\u5ea6\u662f\u5426\u4e3a\u8d28\u6570\n if is_prime(intersection_length):\n return \"YES\"\n else:\n return \"NO\"\ndef is_prime(num):\n \n if num < 2:\n return False\n for i in range(2, int(num ** 0.5) + 1):\n if num % i == 0:\n return False\n return True"} {"task_id": "HumanEval/128", "completion": "\ndef prod_signs(arr):\n if not arr:\n return None\n abs_sum = sum(abs(num) for num in arr)\n pos_prod = 1 if arr[0] > 0 else -1\n for num in arr[1:]:\n if num == 0:\n return 0\n pos_prod *= 1 if num > 0 else -1\n return abs_sum * pos_prod"} {"task_id": "HumanEval/129", "completion": "\ndef minPath(grid, k):\n m, n = len(grid), len(grid[0])\n dp = [[float('inf')] * n for _ in range(m)]\n dp[0][0] = grid[0][0]\n for i in range(m):\n for j in range(n):\n if i + j == k - 1:\n continue\n if i > 0:\n dp[i][j] = min(dp[i][j], dp[i-1][j] + grid[i][j])\n if j > 0:\n dp[i][j] = min(dp[i][j], dp[i][j-1] + grid[i][j])\n path = []\n i, j = m - 1, n - 1\n while i >= 0 and j >= 0:\n path.append(grid[i][j])\n if i == 0:\n j -= 1\n elif j == 0:\n i -= 1\n else:\n if dp[i-1][j] < dp[i][j-1]:\n i -= 1\n else:\n j -= 1\n return path[::-1]\ndef minimumKpath(grid, k):\n lst_A = sorted(grid)\n lst_B = sorted(grid)\n for i in range(k):\n lst_A[i], lst_B[i] = lst_B[i], lst_A[i]\n return minPath(lst_A, k)"} {"task_id": "HumanEval/130", "completion": "\ndef tri(n):\n if n == 0 or n == 1:\n return 3\n elif n % 2 == 0:\n return 1 + n // 2\n else:\n return tri(n - 1) + tri(n - 2) + tri(n + 1)\ndef tribonacci_list(n):\n result = []\n for i in range(n + 1):\n result.append(tri(i))\n return result"} {"task_id": "HumanEval/131", "completion": "\ndef digits(n):\n \n if all(int(digit) % 2 == 0 for digit in str(n)):\n return 0\n else:\n odd_product = 1\n for digit in str(n):\n if int(digit) % 2 != 0:\n odd_product *= int(digit)\n return odd_product"} {"task_id": "HumanEval/132", "completion": "\ndef is_nested(string):\n \n stack = []\n for char in string:\n if char == '[':\n stack.append(char)\n elif char == ']':\n if stack and stack[-1] == '[':\n stack.pop()\n else:\n return False\n return len(stack) == 0"} {"task_id": "HumanEval/133", "completion": "\ndef sum_squares(lst):\n \n modified_lst = [int(num) for num in lst] # \u5c06\u5217\u8868\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u66ff\u6362\u4e3a\u5927\u4e8e\u6216\u7b49\u4e8e\u8be5\u5143\u7d20\u7684\u6700\u5c0f\u6574\u6570\n squared_sum = sum([num**2 for num in modified_lst]) # \u8ba1\u7b97\u4fee\u6539\u540e\u7684\u5217\u8868\u4e2d\u6bcf\u4e2a\u5143\u7d20\u7684\u5e73\u65b9\u548c\n \n return squared_sum"} {"task_id": "HumanEval/134", "completion": "\ndef check_if_last_char_is_a_letter(txt):\n \n words = txt.split()\n if len(txt) > 0 and txt[-1].isalpha() and txt[-1] not in words:\n return True\n return False"} {"task_id": "HumanEval/135", "completion": "\ndef can_arrange(arr):\n \n n = len(arr)\n if n <= 1:\n return -1\n max_index = -1\n for i in range(1, n):\n if arr[i] <= arr[i-1]:\n max_index = i\n return max_index"} {"task_id": "HumanEval/136", "completion": "\ndef largest_smallest_integers(lst):\n \n negative_nums = [num for num in lst if num < 0]\n positive_nums = [num for num in lst if num > 0]\n if negative_nums:\n a = max(negative_nums)\n else:\n a = None\n if positive_nums:\n b = min(positive_nums)\n else:\n b = None\n return (a, b)"} {"task_id": "HumanEval/137", "completion": "\ndef compare_one(a, b):\n \n # \u5c06\u5b9e\u6570\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u5f62\u5f0f\n a_str = str(a)\n b_str = str(b)\n # \u83b7\u53d6\u5c0f\u6570\u70b9\u6216\u9017\u53f7\u7684\u4f4d\u7f6e\n a_point = None\n b_point = None\n if '.' in a_str:\n a_point = a_str.index('.')\n if ',' in b_str:\n b_point = b_str.index(',')\n # \u8f6c\u6362\u4e3a\u6574\u6570\n a_int = int(a_str)\n b_int = int(b_str)\n # \u6bd4\u8f83\u5927\u5c0f\n if a_int > b_int:\n return a_int\n elif a_int == b_int:\n if a_point is not None and b_point is not None:\n if a_point < b_point:\n return a_int\n elif a_point > b_point:\n return b_int\n else:\n return None\n else:\n return a_int\n else:\n if a_point is not None and b_point is not None:\n if a_point < b_point:\n return b_int\n elif a_point > b_point:\n return a_int\n else:\n return None\n else:\n return b_int"} {"task_id": "HumanEval/138", "completion": "\ndef is_equal_to_sum_even(n):\n \n # \u5224\u65adn\u662f\u5426\u662f4\u7684\u500d\u6570\n if n % 4 != 0:\n return False\n \n # \u8ba1\u7b97n/4\uff0c\u5224\u65ad\u662f\u5426\u662f\u6574\u6570\n if n // 4 != int(n // 4):\n return False\n \n # \u8ba1\u7b97n/4\u7684\u6bcf\u4f4d\u6570\u5b57\u4e4b\u548c\n digit_sum = sum([int(digit) for digit in str(n // 4)])\n \n # \u5224\u65adn\u662f\u5426\u7b49\u4e8edigit_sum\u7684\u4e24\u500d\n if n != 2 * digit_sum:\n return False\n \n return True"} {"task_id": "HumanEval/139", "completion": "\ndef special_factorial(n):\n \n if n == 0:\n return 1\n else:\n result = 1\n for i in range(1, n+1):\n result *= i\n return result"} {"task_id": "HumanEval/140", "completion": "\ndef fix_spaces(text):\n \n # \u66ff\u6362\u8fde\u7eed\u7684\u7a7a\u683c\u4e3a'-'\n text = ' '.join(text.split())\n # \u66ff\u6362\u5355\u4e2a\u7a7a\u683c\u4e3a\u4e0b\u5212\u7ebf\n text = text.replace(' ', '_')\n # \u66ff\u6362\u4e24\u4e2a\u8fde\u7eed\u7a7a\u683c\u4e3a\u4e0b\u5212\u7ebf\n text = text.replace(' ', '_')\n return text"} {"task_id": "HumanEval/141", "completion": "\ndef file_name_check(file_name):\n \n import re\n # \u6570\u5b57\u4e0d\u80fd\u8d85\u8fc73\u4e2a\n num_count = len(re.findall(r'\\d', file_name))\n if num_count > 3:\n return 'No'\n # \u6587\u4ef6\u540d\u957f\u5ea6\u5fc5\u987b\u4e3a0\n if len(file_name) == 0:\n return 'No'\n # \u6587\u4ef6\u540d\u5fc5\u987b\u5305\u542b\u81f3\u5c11\u4e00\u4e2a'.'\n if '.' not in file_name:\n return 'No'\n # \u6587\u4ef6\u540d\u4e0d\u80fd\u4ee5'.'\u5f00\u5934\u6216\u7ed3\u5c3e\n if file_name[0] == '.' or file_name[-1] == '.':\n return 'No'\n # \u68c0\u67e5'.'\u4e4b\u524d\u7684\u5b50\u5b57\u7b26\u4e32\n username = re.findall(r'([a-zA-Z])', file_name)\n if len(username) == 0:\n return 'No'\n # \u68c0\u67e5'.'\u4e4b\u540e\u7684\u5b50\u5b57\u7b26\u4e32\n extension = re.findall(r'\\.(txt|exe|dll)', file_name)\n if len(extension) != 1:\n return 'No'\n return 'Yes'"} {"task_id": "HumanEval/142", "completion": "\ndef sum_squares(lst):\n \n result = 0\n for i, num in enumerate(lst):\n if i % 3 == 0 or i % 4 == 0:\n if i % 3 == 0:\n result += num ** 2\n else:\n result += num ** 3\n else:\n result += num\n return result"} {"task_id": "HumanEval/143", "completion": "\ndef words_in_sentence(sentence):\n \n def is_prime(n):\n if n < 2:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True\n words = sentence.split()\n result = []\n for word in words:\n if is_prime(len(word)):\n result.append(word)\n return ' '.join(result)"} {"task_id": "HumanEval/144", "completion": "\ndef simplify(x, n):\n \n # \u5c06x\u548cn\u8f6c\u5316\u4e3a\u5206\u6570\u7684\u5206\u5b50\u548c\u5206\u6bcd\n x_num, x_den = map(int, x.split('/'))\n n_num, n_den = map(int, n.split('/'))\n # \u8ba1\u7b97x * n\u7684\u5206\u5b50\u548c\u5206\u6bcd\n result_num = x_num * n_num\n result_den = x_den * n_den\n # \u5224\u65adx * n\u662f\u5426\u4e3a\u6574\u6570\n if result_num % result_den == 0:\n return True\n else:\n return False"} {"task_id": "HumanEval/145", "completion": "\ndef order_by_points(nums):\n \n def get_digit_sum(num):\n # \u8ba1\u7b97\u4e00\u4e2a\u6570\u5b57\u7684\u5404\u4f4d\u6570\u4e4b\u548c\n return sum(int(digit) for digit in str(abs(num)))\n sorted_nums = sorted(nums, key=lambda x: (get_digit_sum(x), nums.index(x)))\n return sorted_nums"} {"task_id": "HumanEval/146", "completion": "\ndef specialFilter(nums):\n \n count = 0\n for num in nums:\n if num > 10 and num % 2 != 0 and str(num)[0] in ['1', '3', '5', '7', '9'] and str(num)[-1] in ['1', '3', '5', '7', '9']:\n count += 1\n return count"} {"task_id": "HumanEval/147", "completion": "\ndef get_max_triples(n):\n a = [i * i - i + 1 for i in range(1, n+1)]\n count = 0\n for i in range(n-2):\n for j in range(i+1, n-1):\n for k in range(j+1, n):\n if (a[i] + a[j] + a[k]) % 3 == 0:\n count += 1\n return count"} {"task_id": "HumanEval/148", "completion": "\ndef bf(planet1, planet2):\n \n planets = {\n \"Mercury\": 0.39,\n \"Venus\": 0.72,\n \"Earth\": 1.00,\n \"Mars\": 1.52,\n \"Jupiter\": 5.20,\n \"Saturn\": 9.58,\n \"Uranus\": 19.18,\n \"Neptune\": 30.07\n }\n if planet1 not in planets or planet2 not in planets:\n return ()\n if planet1 == planet2:\n return planet1\n start_distance = min(planets[planet1], planets[planet2])\n end_distance = max(planets[planet1], planets[planet2])\n result = []\n for planet, distance in planets.items():\n if start_distance <= distance <= end_distance:\n result.append(planet)\n return tuple(sorted(result))"} {"task_id": "HumanEval/149", "completion": "\ndef sorted_list_sum(lst):\n \n # \u5220\u9664\u957f\u5ea6\u4e3a\u5947\u6570\u7684\u5b57\u7b26\u4e32\n lst = [s for s in lst if len(s) % 2 == 0]\n # \u6309\u7167\u5b57\u7b26\u4e32\u957f\u5ea6\u548c\u9996\u5b57\u6bcd\u8fdb\u884c\u6392\u5e8f\n lst.sort(key=lambda x: (len(x), x[0]))\n return lst"} {"task_id": "HumanEval/150", "completion": "\ndef x_or_y(n, x, y):\n if n < 2:\n return y\n for i in range(2, int(n ** 0.5) + 1):\n if n % i == 0:\n return y\n return x"} {"task_id": "HumanEval/151", "completion": "\ndef double_the_difference(lst):\n \n result = 0\n for num in lst:\n if isinstance(num, int) and num > 0 and num % 2 == 1:\n result += num ** 2\n return result"} {"task_id": "HumanEval/152", "completion": "\ndef compare(game,guess):\n result = []\n for i in range(len(game)):\n if game[i] == guess[i]:\n result.append(0)\n else:\n result.append(abs(game[i]-guess[i]))\n return result"} {"task_id": "HumanEval/153", "completion": "\ndef Strongest_Extension(class_name, extensions):\n \n # \u5b9a\u4e49\u4e00\u4e2a\u51fd\u6570\u7528\u4e8e\u8ba1\u7b97\u6269\u5c55\u7684\u5f3a\u5ea6\n def calculate_strength(extension):\n caps = sum(1 for char in extension if char.isupper())\n sm = sum(1 for char in extension if char.islower())\n return caps - sm\n # \u521d\u59cb\u5316\u6700\u5f3a\u6269\u5c55\u4e3a\u7a7a\u5b57\u7b26\u4e32\n strongest_extension = ''\n # \u904d\u5386\u6269\u5c55\u5217\u8868\uff0c\u627e\u5230\u6700\u5f3a\u7684\u6269\u5c55\n for extension in extensions:\n if len(extension) > len(strongest_extension):\n strength = calculate_strength(extension)\n if strength > 0:\n strongest_extension = extension\n # \u8fd4\u56de\u6700\u5f3a\u6269\u5c55\u7684\u540d\u79f0\n return class_name + '.' + strongest_extension"} {"task_id": "HumanEval/154", "completion": "\ndef cycpattern_check(a , b):\n \n # \u5982\u679cb\u4e3a\u7a7a\u5b57\u7b26\u4e32\uff0c\u5219\u76f4\u63a5\u8fd4\u56deTrue\n if not b:\n return True\n # \u5982\u679ca\u4e3a\u7a7a\u5b57\u7b26\u4e32\uff0c\u6216\u8005a\u7684\u957f\u5ea6\u5c0f\u4e8eb\u7684\u957f\u5ea6\uff0c\u5219\u76f4\u63a5\u8fd4\u56deFalse\n if not a or len(a) < len(b):\n return False\n # \u5c06b\u91cd\u590d\u4e00\u6b21\uff0c\u5982\u679ca\u662fb\u7684\u5b50\u5b57\u7b26\u4e32\uff0c\u5219\u8fd4\u56deTrue\n if a.find(b) != -1:\n return True\n # \u5c06b\u5faa\u73af\u79fb\u4f4d\uff0c\u7ee7\u7eed\u5224\u65ad\n for i in range(len(b)):\n if cycpattern_check(a, b[i:] + b[:i]):\n return True\n # \u5982\u679c\u65e0\u6cd5\u901a\u8fc7\u4e0a\u8ff0\u64cd\u4f5c\u5f97\u5230\u7ed3\u679c\uff0c\u5219\u8fd4\u56deFalse\n return False"} {"task_id": "HumanEval/155", "completion": "\ndef even_odd_count(num):\n \n even_count = 0\n odd_count = 0\n # \u5c06\u6574\u6570\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\uff0c\u4fbf\u4e8e\u9010\u4f4d\u5224\u65ad\n num_str = str(abs(num))\n # \u904d\u5386\u6bcf\u4e2a\u6570\u5b57\u5b57\u7b26\n for digit in num_str:\n if int(digit) % 2 == 0:\n even_count += 1\n else:\n odd_count += 1\n return (even_count, odd_count)"} {"task_id": "HumanEval/156", "completion": "\ndef int_to_mini_roman(number):\n \n roman_dict = {\n 1000: 'M',\n 900: 'CM',\n 500: 'D',\n 400: 'CD',\n 100: 'C',\n 90: 'XC',\n 50: 'L',\n 40: 'XL',\n 10: 'X',\n 9: 'IX',\n 5: 'V',\n 4: 'IV',\n 1: 'I'\n }\n result = ''\n for value, symbol in roman_dict.items():\n while number >= value:\n result += symbol\n number -= value\n return result"} {"task_id": "HumanEval/157", "completion": "\ndef right_angle_triangle(a, b, c):\n \n # \u5224\u65ad\u662f\u5426\u6ee1\u8db3\u52fe\u80a1\u5b9a\u7406\n if a**2 + b**2 == c**2 or a**2 + c**2 == b**2 or b**2 + c**2 == a**2:\n return True\n else:\n return False"} {"task_id": "HumanEval/158", "completion": "\ndef find_max(words):\n \n max_count = 0\n max_word = \"\"\n for word in words:\n unique_chars = set(word)\n count = len(unique_chars)\n if count > max_count:\n max_count = count\n max_word = word\n elif count == max_count and word < max_word:\n max_word = word\n return max_word"} {"task_id": "HumanEval/159", "completion": "\ndef eat(number, need, remaining):\n if remaining < need:\n number = 1000\n elif remaining == need:\n return [number, 0]\n else:\n number += remaining\n return [number, remaining]"} {"task_id": "HumanEval/160", "completion": "\ndef do_algebra(operator, operand):\n \n result = None\n \n if operator == '+':\n result = sum(operand)\n elif operator == '-':\n result = operand[0] - sum(operand[1:])\n elif operator == '*':\n result = 1\n for num in operand:\n result *= num\n elif operator == '/':\n result = operand[0] // operand[1]\n elif operator == '**':\n result = operand[0] ** operand[1]\n return result"} {"task_id": "HumanEval/161", "completion": "\ndef solve(s):\n \n # \u5224\u65ad\u5b57\u7b26\u4e32s\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u662f\u5426\u662f\u5b57\u6bcd\n for i in range(len(s)):\n if s[i].isalpha():\n # \u5982\u679cs[i]\u662f\u5b57\u6bcd\uff0c\u5219\u5c06s[i]\u4ece\u5c0f\u5199\u8f6c\u6362\u4e3a\u5927\u5199\u6216\u4ece\u5927\u5199\u8f6c\u6362\u4e3a\u5c0f\u5199\n if s[i].islower():\n s = s[:i] + s[i].upper() + s[i+1:]\n else:\n s = s[:i] + s[i].lower() + s[i+1:]\n # \u8fd4\u56de\u5904\u7406\u540e\u7684\u7ed3\u679c\u5b57\u7b26\u4e32\n return s[::-1] if not any(char.isalpha() for char in s) else s"} {"task_id": "HumanEval/162", "completion": "\ndef string_to_md5(text):\n if not text:\n return None\n else:\n md5_hash = hashlib.md5()\n md5_hash.update(text.encode('utf-8'))\n return md5_hash.hexdigest()"} {"task_id": "HumanEval/163", "completion": "\ndef generate_integers(a, b):\n \n if a > b:\n a, b = b, a\n return list(range(a, b+1, 2))"}