{"task_id": "Python/0", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef remove_duplicates(numbers: List[int]) -> List[int]:\n import collections\n c = collections.Counter(numbers)\n return [n for n in numbers if c[n] <= 1]\n```\n"} {"task_id": "Python/1", "prompt": "为以下Python代码生成单元测试\n```Python\ndef fruit_distribution(s,n):\n lis = list()\n for i in s.split(' '):\n if i.isdigit():\n lis.append(int(i))\n return n - sum(lis)\n```\n"} {"task_id": "Python/2", "prompt": "为以下Python代码生成单元测试\n```Python\ndef median(l: list):\n 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```\n"} {"task_id": "Python/3", "prompt": "为以下Python代码生成单元测试\n```Python\ndef decimal_to_binary(decimal):\n return \"db\" + bin(decimal)[2:] + \"db\"\n```\n"} {"task_id": "Python/4", "prompt": "为以下Python代码生成单元测试\n```Python\ndef flip_case(string: str) -> str:\n return string.swapcase()\n```\n"} {"task_id": "Python/5", "prompt": "为以下Python代码生成单元测试\n```Python\ndef select_words(s, n):\n 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\n"} {"task_id": "Python/6", "prompt": "为以下Python代码生成单元测试\n```Python\ndef strange_sort_list(lst):\n 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```\n"} {"task_id": "Python/7", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef filter_by_substring(strings: List[str], substring: str) -> List[str]:\n return [x for x in strings if substring in x]\n```\n"} {"task_id": "Python/8", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List, Tuple\n\n\ndef sum_product(numbers: List[int]) -> Tuple[int, int]:\n 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```\n"} {"task_id": "Python/9", "prompt": "为以下Python代码生成单元测试\n```Python\ndef iscube(a):\n a = abs(a)\n return int(round(a ** (1. / 3))) ** 3 == a\n```\n"} {"task_id": "Python/10", "prompt": "为以下Python代码生成单元测试\n```Python\ndef string_to_md5(text):\n import hashlib\n return hashlib.md5(text.encode('ascii')).hexdigest() if text else None\n```\n"} {"task_id": "Python/11", "prompt": "为以下Python代码生成单元测试\n```Python\ndef sort_third(l: list):\n l = list(l)\n l[::3] = sorted(l[::3])\n return l\n```\n"} {"task_id": "Python/12", "prompt": "为以下Python代码生成单元测试\n```Python\ndef is_palindrome(text: str):\n for i in range(len(text)):\n if text[i] != text[len(text) - 1 - i]:\n return False\n return True\n```\n"} {"task_id": "Python/13", "prompt": "为以下Python代码生成单元测试\n```Python\ndef do_algebra(operator, operand):\n expression = str(operand[0])\n for oprt, oprn in zip(operator, operand[1:]):\n expression+= oprt + str(oprn)\n return eval(expression)\n```\n"} {"task_id": "Python/14", "prompt": "为以下Python代码生成单元测试\n```Python\ndef is_bored(S):\n import re\n sentences = re.split(r'[.?!]\\s*', S)\n return sum(sentence[0:2] == 'I ' for sentence in sentences)\n```\n"} {"task_id": "Python/15", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List, Tuple\n\n\ndef find_closest_elements(numbers: List[float]) -> Tuple[float, float]:\n 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```\n"} {"task_id": "Python/16", "prompt": "为以下Python代码生成单元测试\n```Python\ndef modp(n: int, p: int):\n ret = 1\n for i in range(n):\n ret = (2 * ret) % p\n return ret\n```\n"} {"task_id": "Python/17", "prompt": "为以下Python代码生成单元测试\n```Python\ndef intersection(interval1, interval2):\n 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```\n"} {"task_id": "Python/18", "prompt": "为以下Python代码生成单元测试\n```Python\ndef f(n):\n 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```\n"} {"task_id": "Python/19", "prompt": "为以下Python代码生成单元测试\n```Python\ndef count_up_to(n):\n 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"} {"task_id": "Python/20", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef separate_paren_groups(paren_string: str) -> List[str]:\n 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```\n"} {"task_id": "Python/21", "prompt": "为以下Python代码生成单元测试\n```Python\ndef starts_one_ends(n):\n if n == 1: return 1\n return 18 * (10 ** (n - 2))\n```\n"} {"task_id": "Python/22", "prompt": "为以下Python代码生成单元测试\n```Python\ndef minSubArraySum(nums):\n 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```\n"} {"task_id": "Python/23", "prompt": "为以下Python代码生成单元测试\n```Python\ndef cycpattern_check(a , b):\n 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```\n"} {"task_id": "Python/24", "prompt": "为以下Python代码生成单元测试\n```Python\ndef is_multiply_prime(a):\n def is_prime(n):\n for j in range(2,n):\n if n%j == 0:\n return False\n return True\n\n for i in range(2,101):\n if not is_prime(i): continue\n for j in range(2,101):\n if not is_prime(j): continue\n for k in range(2,101):\n if not is_prime(k): continue\n if i*j*k == a: return True\n return False\n```\n"} {"task_id": "Python/25", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef intersperse(numbers: List[int], delimeter: int) -> List[int]:\n 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```\n"} {"task_id": "Python/26", "prompt": "为以下Python代码生成单元测试\n```Python\ndef valid_date(date):\n 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```\n"} {"task_id": "Python/27", "prompt": "为以下Python代码生成单元测试\n```Python\ndef greatest_common_divisor(a: int, b: int) -> int:\n while b:\n a, b = b, a % b\n return a\n```\n"} {"task_id": "Python/28", "prompt": "为以下Python代码生成单元测试\n```Python\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 return encode_cyclic(encode_cyclic(s))\n```\n"} {"task_id": "Python/29", "prompt": "为以下Python代码生成单元测试\n```Python\ndef get_odd_collatz(n):\n 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```\n"} {"task_id": "Python/30", "prompt": "为以下Python代码生成单元测试\n```Python\ndef right_angle_triangle(a, b, c):\n return a*a == b*b + c*c or b*b == a*a + c*c or c*c == a*a + b*b\n```\n"} {"task_id": "Python/31", "prompt": "为以下Python代码生成单元测试\n```Python\ndef pluck(arr):\n 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```\n"} {"task_id": "Python/32", "prompt": "为以下Python代码生成单元测试\n```Python\ndef sum_to_n(n: int):\n return sum(range(n + 1))\n```\n"} {"task_id": "Python/33", "prompt": "为以下Python代码生成单元测试\n```Python\ndef monotonic(l: list):\n if l == sorted(l) or l == sorted(l, reverse=True):\n return True\n return False\n```\n"} {"task_id": "Python/34", "prompt": "为以下Python代码生成单元测试\n```Python\ndef get_closest_vowel(word):\n 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```\n"} {"task_id": "Python/35", "prompt": "为以下Python代码生成单元测试\n```Python\ndef prod_signs(arr):\n 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```\n"} {"task_id": "Python/36", "prompt": "为以下Python代码生成单元测试\n```Python\ndef is_simple_power(x, n):\n if (n == 1): \n return (x == 1) \n power = 1\n while (power < x): \n power = power * n \n return (power == x) \n```\n"} {"task_id": "Python/37", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef mean_absolute_deviation(numbers: List[float]) -> float:\n mean = sum(numbers) / len(numbers)\n return sum(abs(x - mean) for x in numbers) / len(numbers)\n```\n"} {"task_id": "Python/38", "prompt": "为以下Python代码生成单元测试\n```Python\ndef unique_digits(x):\n 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```\n"} {"task_id": "Python/39", "prompt": "为以下Python代码生成单元测试\n```Python\ndef any_int(x, y, z):\n \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```\n"} {"task_id": "Python/40", "prompt": "为以下Python代码生成单元测试\n```Python\ndef is_prime(n):\n 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```\n"} {"task_id": "Python/41", "prompt": "为以下Python代码生成单元测试\n```Python\ndef next_smallest(lst):\n lst = sorted(set(lst))\n return None if len(lst) < 2 else lst[1]\n```\n"} {"task_id": "Python/42", "prompt": "为以下Python代码生成单元测试\n```Python\ndef odd_count(lst):\n 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```\n"} {"task_id": "Python/43", "prompt": "为以下Python代码生成单元测试\n```Python\ndef how_many_times(string: str, substring: str) -> int:\n 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```\n"} {"task_id": "Python/44", "prompt": "为以下Python代码生成单元测试\n```Python\ndef rounded_avg(n, m):\n 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```\n"} {"task_id": "Python/45", "prompt": "为以下Python代码生成单元测试\n```Python\ndef search(lst):\n 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```\n"} {"task_id": "Python/46", "prompt": "为以下Python代码生成单元测试\n```Python\ndef triangle_area(a, b, c):\n 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```\n"} {"task_id": "Python/47", "prompt": "为以下Python代码生成单元测试\n```Python\ndef exchange(lst1, lst2):\n 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"} {"task_id": "Python/48", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef all_prefixes(string: str) -> List[str]:\n result = []\n\n for i in range(len(string)):\n result.append(string[:i+1])\n return result\n```\n"} {"task_id": "Python/49", "prompt": "为以下Python代码生成单元测试\n```Python\ndef tri(n):\n 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```\n"} {"task_id": "Python/50", "prompt": "为以下Python代码生成单元测试\n```Python\ndef get_max_triples(n):\n 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```\n"} {"task_id": "Python/51", "prompt": "为以下Python代码生成单元测试\n```Python\ndef get_positive(l: list):\n return [e for e in l if e > 0]\n```\n"} {"task_id": "Python/52", "prompt": "为以下Python代码生成单元测试\n```Python\ndef special_factorial(n):\n 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```\n"} {"task_id": "Python/53", "prompt": "为以下Python代码生成单元测试\n```Python\ndef fizz_buzz(n: int):\n 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```\n"} {"task_id": "Python/54", "prompt": "为以下Python代码生成单元测试\n```Python\ndef check_dict_case(dict):\n 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```\n"} {"task_id": "Python/55", "prompt": "为以下Python代码生成单元测试\n```Python\ndef add_elements(arr, k):\n return sum(elem for elem in arr[:k] if len(str(elem)) <= 2)\n```\n"} {"task_id": "Python/56", "prompt": "为以下Python代码生成单元测试\n```Python\ndef max_fill(grid, capacity):\n import math\n return sum([math.ceil(sum(arr)/capacity) for arr in grid])\n```\n"} {"task_id": "Python/57", "prompt": "为以下Python代码生成单元测试\n```Python\ndef count_distinct_characters(string: str) -> int:\n return len(set(string.lower()))\n```\n"} {"task_id": "Python/58", "prompt": "为以下Python代码生成单元测试\n```Python\ndef split_words(txt):\n 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```\n"} {"task_id": "Python/59", "prompt": "为以下Python代码生成单元测试\n```Python\ndef largest_prime_factor(n: int):\n 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```\n"} {"task_id": "Python/60", "prompt": "为以下Python代码生成单元测试\n```Python\ndef sorted_list_sum(lst):\n 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```\n"} {"task_id": "Python/61", "prompt": "为以下Python代码生成单元测试\n```Python\ndef make_a_pile(n):\n return [n + 2*i for i in range(n)]\n```\n"} {"task_id": "Python/62", "prompt": "为以下Python代码生成单元测试\n```Python\ndef change_base(x: int, base: int):\n ret = \"\"\n while x > 0:\n ret = str(x % base) + ret\n x //= base\n return ret\n```\n"} {"task_id": "Python/63", "prompt": "为以下Python代码生成单元测试\n```Python\ndef sum_squares(lst):\n 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```\n"} {"task_id": "Python/64", "prompt": "为以下Python代码生成单元测试\n```Python\ndef by_length(arr):\n 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```\n"} {"task_id": "Python/65", "prompt": "为以下Python代码生成单元测试\n```Python\ndef eat(number, need, remaining):\n if(need <= remaining):\n return [ number + need , remaining-need ]\n else:\n return [ number + remaining , 0]\n```\n"} {"task_id": "Python/66", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef rescale_to_unit(numbers: List[float]) -> List[float]:\n min_number = min(numbers)\n max_number = max(numbers)\n return [(x - min_number) / (max_number - min_number) for x in numbers]\n```\n"} {"task_id": "Python/67", "prompt": "为以下Python代码生成单元测试\n```Python\ndef Strongest_Extension(class_name, extensions):\n 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\n"} {"task_id": "Python/68", "prompt": "为以下Python代码生成单元测试\n```Python\ndef incr_list(l: list):\n return [(e + 1) for e in l]\n```\n"} {"task_id": "Python/69", "prompt": "为以下Python代码生成单元测试\n```Python\nimport 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 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```\n"} {"task_id": "Python/70", "prompt": "为以下Python代码生成单元测试\n```Python\ndef is_sorted(lst):\n 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"} {"task_id": "Python/71", "prompt": "为以下Python代码生成单元测试\n```Python\ndef will_it_fly(q,w):\n if sum(q) > w:\n return False\n\n i, j = 0, len(q)-1\n while i str:\n return ''.join(strings)\n```\n"} {"task_id": "Python/75", "prompt": "为以下Python代码生成单元测试\n```Python\ndef sort_even(l: list):\n 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```\n"} {"task_id": "Python/76", "prompt": "为以下Python代码生成单元测试\n```Python\ndef minPath(grid, k):\n 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```\n"} {"task_id": "Python/77", "prompt": "为以下Python代码生成单元测试\n```Python\ndef compare(game,guess):\n return [abs(x-y) for x,y in zip(game,guess)]\n```\n"} {"task_id": "Python/78", "prompt": "为以下Python代码生成单元测试\n```Python\ndef bf(planet1, planet2):\n 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```\n"} {"task_id": "Python/79", "prompt": "为以下Python代码生成单元测试\n```Python\ndef derivative(xs: list):\n return [(i * x) for i, x in enumerate(xs)][1:]\n```\n"} {"task_id": "Python/80", "prompt": "为以下Python代码生成单元测试\n```Python\ndef string_sequence(n: int) -> str:\n return ' '.join([str(x) for x in range(n + 1)])\n```\n"} {"task_id": "Python/81", "prompt": "为以下Python代码生成单元测试\n```Python\ndef count_upper(s):\n count = 0\n for i in range(0,len(s),2):\n if s[i] in \"AEIOU\":\n count += 1\n return count\n```\n"} {"task_id": "Python/82", "prompt": "为以下Python代码生成单元测试\n```Python\ndef double_the_difference(lst):\n return sum([i**2 for i in lst if i > 0 and i%2!=0 and \".\" not in str(i)])\n```\n"} {"task_id": "Python/83", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef filter_by_prefix(strings: List[str], prefix: str) -> List[str]:\n return [x for x in strings if x.startswith(prefix)]\n```\n"} {"task_id": "Python/84", "prompt": "为以下Python代码生成单元测试\n```Python\ndef words_string(s):\n 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```\n"} {"task_id": "Python/85", "prompt": "为以下Python代码生成单元测试\n```Python\ndef get_row(lst, x):\n 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```\n"} {"task_id": "Python/86", "prompt": "为以下Python代码生成单元测试\n```Python\ndef reverse_delete(s,c):\n s = ''.join([char for char in s if char not in c])\n return (s,s[::-1] == s)\n```\n"} {"task_id": "Python/87", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef has_close_elements(numbers: List[float], threshold: float) -> bool:\n 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```\n"} {"task_id": "Python/88", "prompt": "为以下Python代码生成单元测试\n```Python\ndef smallest_change(arr):\n ans = 0\n for i in range(len(arr) // 2):\n if arr[i] != arr[len(arr) - i - 1]:\n ans += 1\n return ans\n```\n"} {"task_id": "Python/89", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef factorize(n: int) -> List[int]:\n 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```\n"} {"task_id": "Python/90", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List, Any\n\n\ndef filter_integers(values: List[Any]) -> List[int]:\n return [x for x in values if isinstance(x, int)]\n```\n"} {"task_id": "Python/91", "prompt": "为以下Python代码生成单元测试\n```Python\ndef truncate_number(number: float) -> float:\n return number % 1.0\n```\n"} {"task_id": "Python/92", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef parse_music(music_string: str) -> List[int]:\n note_map = {'o': 4, 'o|': 2, '.|': 1}\n return [note_map[x] for x in music_string.split(' ') if x]\n```\n"} {"task_id": "Python/93", "prompt": "为以下Python代码生成单元测试\n```Python\ndef sort_array(arr):\n return sorted(sorted(arr), key=lambda x: bin(x)[2:].count('1'))\n```\n"} {"task_id": "Python/94", "prompt": "为以下Python代码生成单元测试\n```Python\ndef generate_integers(a, b):\n 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```\n"} {"task_id": "Python/95", "prompt": "为以下Python代码生成单元测试\n```Python\ndef check_if_last_char_is_a_letter(txt):\n \n check = txt.split(' ')[-1]\n return True if len(check) == 1 and (97 <= ord(check.lower()) <= 122) else False\n```\n"} {"task_id": "Python/96", "prompt": "为以下Python代码生成单元测试\n```Python\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 return \"\".join([chr(((ord(ch) - 5 - ord(\"a\")) % 26) + ord(\"a\")) for ch in s])\n```\n"} {"task_id": "Python/97", "prompt": "为以下Python代码生成单元测试\n```Python\ndef prime_fib(n: int):\n 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```\n"} {"task_id": "Python/98", "prompt": "为以下Python代码生成单元测试\n```Python\ndef strlen(string: str) -> int:\n return len(string)\n```\n"} {"task_id": "Python/99", "prompt": "为以下Python代码生成单元测试\n```Python\ndef encode(message):\n 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```\n"} {"task_id": "Python/100", "prompt": "为以下Python代码生成单元测试\n```Python\ndef choose_num(x, y):\n 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```\n"} {"task_id": "Python/101", "prompt": "为以下Python代码生成单元测试\n```Python\ndef even_odd_count(num):\n 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```\n"} {"task_id": "Python/102", "prompt": "为以下Python代码生成单元测试\n```Python\ndef anti_shuffle(s):\n return ' '.join([''.join(sorted(list(i))) for i in s.split(' ')])\n```\n"} {"task_id": "Python/103", "prompt": "为以下Python代码生成单元测试\n```Python\ndef is_equal_to_sum_even(n):\n return n%2 == 0 and n >= 8\n```\n"} {"task_id": "Python/104", "prompt": "为以下Python代码生成单元测试\n```Python\ndef max_element(l: list):\n m = l[0]\n for e in l:\n if e > m:\n m = e\n return m\n```\n"} {"task_id": "Python/105", "prompt": "为以下Python代码生成单元测试\n```Python\ndef largest_divisor(n: int) -> int:\n for i in reversed(range(n)):\n if n % i == 0:\n return i\n```\n"} {"task_id": "Python/106", "prompt": "为以下Python代码生成单元测试\n```Python\ndef count_nums(arr):\n 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```\n"} {"task_id": "Python/107", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef sort_numbers(numbers: str) -> str:\n 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```\n"} {"task_id": "Python/108", "prompt": "为以下Python代码生成单元测试\n```Python\ndef largest_smallest_integers(lst):\n smallest = list(filter(lambda x: x < 0, lst))\n largest = list(filter(lambda x: x > 0, lst))\n return (max(smallest) if smallest else None, min(largest) if largest else None)\n```\n"} {"task_id": "Python/109", "prompt": "为以下Python代码生成单元测试\n```Python\ndef car_race_collision(n: int):\n return n**2\n```\n"} {"task_id": "Python/110", "prompt": "为以下Python代码生成单元测试\n```Python\ndef specialFilter(nums):\n \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```\n"} {"task_id": "Python/111", "prompt": "为以下Python代码生成单元测试\n```Python\ndef solution(lst):\n return sum([x for idx, x in enumerate(lst) if idx%2==0 and x%2==1])\n```\n"} {"task_id": "Python/112", "prompt": "为以下Python代码生成单元测试\n```Python\ndef same_chars(s0: str, s1: str):\n return set(s0) == set(s1)\n```\n"} {"task_id": "Python/113", "prompt": "为以下Python代码生成单元测试\n```Python\ndef prime_length(string):\n 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```\n"} {"task_id": "Python/114", "prompt": "为以下Python代码生成单元测试\n```Python\ndef digitSum(s):\n if s == \"\": return 0\n return sum(ord(char) if char.isupper() else 0 for char in s)\n```\n"} {"task_id": "Python/115", "prompt": "为以下Python代码生成单元测试\n```Python\ndef closest_integer(value):\n 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\n"} {"task_id": "Python/116", "prompt": "为以下Python代码生成单元测试\n```Python\ndef encrypt(s):\n 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```\n"} {"task_id": "Python/117", "prompt": "为以下Python代码生成单元测试\n```Python\ndef can_arrange(arr):\n ind=-1\n i=1\n while i float(temp_b) else b \n```\n"} {"task_id": "Python/126", "prompt": "为以下Python代码生成单元测试\n```Python\ndef words_in_sentence(sentence):\n 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```\n"} {"task_id": "Python/127", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef string_xor(a: str, b: str) -> str:\n 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```\n"} {"task_id": "Python/128", "prompt": "为以下Python代码生成单元测试\n```Python\ndef move_one_ball(arr):\n 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```\n"} {"task_id": "Python/129", "prompt": "为以下Python代码生成单元测试\n```Python\ndef solve(s):\n 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```\n"} {"task_id": "Python/130", "prompt": "为以下Python代码生成单元测试\n```Python\ndef remove_vowels(text):\n return \"\".join([s for s in text if s.lower() not in [\"a\", \"e\", \"i\", \"o\", \"u\"]])\n```\n"} {"task_id": "Python/131", "prompt": "为以下Python代码生成单元测试\n```Python\ndef digits(n):\n 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```\n"} {"task_id": "Python/132", "prompt": "为以下Python代码生成单元测试\n```Python\ndef numerical_letter_grade(grades):\n\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```\n"} {"task_id": "Python/133", "prompt": "为以下Python代码生成单元测试\n```Python\ndef fibfib(n: int):\n 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```\n"} {"task_id": "Python/134", "prompt": "为以下Python代码生成单元测试\n```Python\ndef add(lst):\n return sum([lst[i] for i in range(1, len(lst), 2) if lst[i]%2 == 0])\n```\n"} {"task_id": "Python/135", "prompt": "为以下Python代码生成单元测试\n```Python\ndef maximum(arr, k):\n if k == 0:\n return []\n arr.sort()\n ans = arr[-k:]\n return ans\n```\n"} {"task_id": "Python/136", "prompt": "为以下Python代码生成单元测试\n```Python\ndef skjkasdkd(lst):\n 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"} {"task_id": "Python/137", "prompt": "为以下Python代码生成单元测试\n```Python\ndef simplify(x, n):\n 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```\n"} {"task_id": "Python/138", "prompt": "为以下Python代码生成单元测试\n```Python\ndef match_parens(lst):\n 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```\n"} {"task_id": "Python/139", "prompt": "为以下Python代码生成单元测试\n```Python\ndef histogram(test):\n 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```\n"} {"task_id": "Python/140", "prompt": "为以下Python代码生成单元测试\n```Python\ndef total_match(lst1, lst2):\n l1 = 0\n for st in lst1:\n l1 += len(st)\n \n l2 = 0\n for st in lst2:\n l2 += len(st)\n \n if l1 <= l2:\n return lst1\n else:\n return lst2\n```\n"} {"task_id": "Python/141", "prompt": "为以下Python代码生成单元测试\n```Python\ndef circular_shift(x, shift):\n 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```\n"} {"task_id": "Python/142", "prompt": "为以下Python代码生成单元测试\n```Python\ndef file_name_check(file_name):\n 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```\n"} {"task_id": "Python/143", "prompt": "为以下Python代码生成单元测试\n```Python\nFIX = \"\"\"\nAdd more test cases.\n\"\"\"\n\ndef vowels_count(s):\n 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```\n"} {"task_id": "Python/144", "prompt": "为以下Python代码生成单元测试\n```Python\ndef is_nested(string):\n 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\n"} {"task_id": "Python/145", "prompt": "为以下Python代码生成单元测试\n```Python\ndef even_odd_palindrome(n):\n 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```\n"} {"task_id": "Python/146", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef below_zero(operations: List[int]) -> bool:\n balance = 0\n\n for op in operations:\n balance += op\n if balance < 0:\n return True\n\n return False\n```\n"} {"task_id": "Python/147", "prompt": "为以下Python代码生成单元测试\n```Python\ndef below_threshold(l: list, t: int):\n for e in l:\n if e >= t:\n return False\n return True\n```\n"} {"task_id": "Python/148", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef parse_nested_parens(paren_string: str) -> List[int]:\n 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```\n"} {"task_id": "Python/149", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List, Tuple\n\n\ndef rolling_max(numbers: List[int]) -> List[int]:\n 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```\n"} {"task_id": "Python/150", "prompt": "为以下Python代码生成单元测试\n```Python\ndef int_to_mini_roman(number):\n 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```\n"} {"task_id": "Python/151", "prompt": "为以下Python代码生成单元测试\n```Python\ndef fix_spaces(text):\n 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```\n"} {"task_id": "Python/152", "prompt": "为以下Python代码生成单元测试\n```Python\ndef fib(n: int):\n if n == 0:\n return 0\n if n == 1:\n return 1\n return fib(n - 1) + fib(n - 2)\n```\n"} {"task_id": "Python/153", "prompt": "为以下Python代码生成单元测试\n```Python\ndef correct_bracketing(brackets: str):\n 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```\n"} {"task_id": "Python/154", "prompt": "为以下Python代码生成单元测试\n```Python\ndef fib4(n: int):\n 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```\n"} {"task_id": "Python/155", "prompt": "为以下Python代码生成单元测试\n```Python\ndef order_by_points(nums):\n 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```\n"} {"task_id": "Python/156", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List, Optional\n\n\ndef longest(strings: List[str]) -> Optional[str]:\n 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```\n"}