-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy path2023-03-17-samples-gpt-4-0314.jsonl
164 lines (164 loc) · 58.3 KB
/
2023-03-17-samples-gpt-4-0314.jsonl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
{"task_id": "HumanEval/0", "completion": " 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\n\n# Test cases\nprint(has_close_elements([1.0, 2.0, 3.0], 0.5)) # False\nprint(has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)) # True\nprint(has_close_elements([1.0, 2.0, 3.0], 1.1)) # True\nprint(has_close_elements([1.0, 2.0, 3.0], 1.0)) # False\nprint(has_close_elements([1.0, 2.0, 3.0], 2.1)) # True"}
{"task_id": "HumanEval/1", "completion": " paren_string = paren_string.replace(\" \", \"\")\n result = []\n stack = []\n current_group = \"\"\n\n for char in paren_string:\n if char == \"(\":\n if not stack:\n current_group += char\n stack.append(char)\n elif char == \")\":\n stack.pop()\n current_group += char\n if not stack:\n result.append(current_group)\n current_group = \"\"\n\n return result"}
{"task_id": "HumanEval/2", "completion": " return number - int(number)"}
{"task_id": "HumanEval/3", "completion": " 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": " mean = sum(numbers) / len(numbers)\n absolute_deviations = [abs(x - mean) for x in numbers]\n mad = sum(absolute_deviations) / len(absolute_deviations)\n return mad\n\n# Test cases\nprint(mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])) # Should print 1.0\nprint(mean_absolute_deviation([1.0, 3.0, 5.0, 7.0])) # Should print 2.0\nprint(mean_absolute_deviation([1.0, 1.0, 1.0, 1.0])) # Should print 0.0"}
{"task_id": "HumanEval/5", "completion": "result = []\n for i, num in enumerate(numbers):\n if i > 0:\n result.append(delimeter)\n result.append(num)\n return result\n\nif __name__ == \"__main__\":\n import doctest\n doctest.testmod()"}
{"task_id": "HumanEval/6", "completion": "stack = []\n result = []\n\n for group in paren_string.split():\n max_depth = 0\n depth = 0\n for char in group:\n if char == '(':\n depth += 1\n max_depth = max(max_depth, depth)\n elif char == ')':\n depth -= 1\n result.append(max_depth)\n\n return result\n\n# Test cases\nprint(parse_nested_parens('(()()) ((())) () ((())()())')) # [2, 3, 1, 3]\nprint(parse_nested_parens('()()()()')) # [1, 1, 1, 1]\nprint(parse_nested_parens('((((()))))')) # [5]\nprint(parse_nested_parens('((())())(())')) # [3, 2]\nprint(parse_nested_parens('')) # [0]"}
{"task_id": "HumanEval/7", "completion": " return [string for string in strings if substring in string]\n\n# Test cases\nprint(filter_by_substring([], 'a'))\nprint(filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a'))\nprint(filter_by_substring(['hello', 'world', 'python', 'programming'], 'o'))\nprint(filter_by_substring(['apple', 'banana', 'cherry', 'grape'], 'e'))\nprint(filter_by_substring(['cat', 'dog', 'fish', 'bird'], 'i'))"}
{"task_id": "HumanEval/8", "completion": " total_sum = 0\n total_product = 1\n\n for number in numbers:\n total_sum += number\n total_product *= number\n\n return (total_sum, total_product)"}
{"task_id": "HumanEval/9", "completion": " result = []\n max_number = float('-inf')\n\n for number in numbers:\n max_number = max(max_number, number)\n result.append(max_number)\n\n return result"}
{"task_id": "HumanEval/10", "completion": " if is_palindrome(string):\n return string\n\n for i in range(len(string)):\n if is_palindrome(string[i:]):\n return string + string[:i][::-1]\n\n return string + string[::-1]\n\nif __name__ == \"__main__\":\n import doctest\n doctest.testmod()"}
{"task_id": "HumanEval/11", "completion": "from typing import List\n\ndef string_xor(a: str, b: str) -> str:\n \"\"\" Input are two strings a and b consisting only of 1s and 0s.\n Perform binary XOR on these inputs and return result also as a string.\n >>> string_xor('010', '110')\n '100'\n \"\"\"\n result = ''\n for i in range(len(a)):\n if a[i] == b[i]:\n result += '0'\n else:\n result += '1'\n return result\n\nprint(string_xor('010', '110')) # '100'\nprint(string_xor('1010', '1101')) # '0111'\nprint(string_xor('1111', '0000')) # '1111'\nprint(string_xor('0000', '0000')) # '0000'\nprint(string_xor('101010', '110110')) # '011100'"}
{"task_id": "HumanEval/12", "completion": " if not strings:\n return None\n\n longest_string = strings[0]\n\n for string in strings:\n if len(string) > len(longest_string):\n longest_string = string\n\n return longest_string\n\n# Test cases\nprint(longest([]))\nprint(longest(['a', 'b', 'c']))\nprint(longest(['a', 'bb', 'ccc']))"}
{"task_id": "HumanEval/13", "completion": " while b:\n a, b = b, a % b\n return a"}
{"task_id": "HumanEval/14", "completion": " return [string[:i] for i in range(1, len(string) + 1)]"}
{"task_id": "HumanEval/15", "completion": " return \" \".join(str(i) for i in range(n+1))"}
{"task_id": "HumanEval/16", "completion": " string = string.lower()\n distinct_characters = set(string)\n return len(distinct_characters)"}
{"task_id": "HumanEval/17", "completion": " beats = []\n notes = music_string.split()\n\n for note in notes:\n if note == 'o':\n beats.append(4)\n elif note == 'o|':\n beats.append(2)\n elif note == '.|':\n beats.append(1)\n\n return beats"}
{"task_id": "HumanEval/18", "completion": "count = 0\nfor i in range(len(string) - len(substring) + 1):\n if string[i:i+len(substring)] == substring:\n count += 1\nreturn count"}
{"task_id": "HumanEval/19", "completion": " number_dict = {\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\n number_list = numbers.split()\n sorted_numbers = sorted(number_list, key=lambda x: number_dict[x])\n return ' '.join(sorted_numbers)"}
{"task_id": "HumanEval/20", "completion": " numbers.sort()\n min_diff = float('inf')\n closest_pair = (0, 0)\n\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_pair = (numbers[i], numbers[i + 1])\n\n return closest_pair"}
{"task_id": "HumanEval/21", "completion": "min_num = min(numbers)\nmax_num = max(numbers)\n\nreturn [(num - min_num) / (max_num - min_num) for num in numbers]"}
{"task_id": "HumanEval/22", "completion": " return [value for value in values if isinstance(value, int)]"}
{"task_id": "HumanEval/23", "completion": " return len(string)"}
{"task_id": "HumanEval/24", "completion": " for i in range(n-1, 0, -1):\n if n % i == 0:\n return i\n\nprint(largest_divisor(15))"}
{"task_id": "HumanEval/25", "completion": " 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": " result = []\n for number in numbers:\n if numbers.count(number) == 1:\n result.append(number)\n return result"}
{"task_id": "HumanEval/27", "completion": " flipped_string = \"\"\n for char in string:\n if char.islower():\n flipped_string += char.upper()\n else:\n flipped_string += char.lower()\n return flipped_string\n\n# Test cases\nprint(flip_case('Hello')) # 'hELLO'\nprint(flip_case('WORLD')) # 'world'\nprint(flip_case('Python3')) # 'pYTHON3'\nprint(flip_case('12345')) # '12345'\nprint(flip_case('')) # ''"}
{"task_id": "HumanEval/28", "completion": " result = \"\"\n for string in strings:\n result += string\n return result"}
{"task_id": "HumanEval/29", "completion": " return [string for string in strings if string.startswith(prefix)]\n\n# Test cases\nprint(filter_by_prefix([], 'a'))\nprint(filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a'))\nprint(filter_by_prefix(['apple', 'banana', 'avocado', 'apricot'], 'ap'))\nprint(filter_by_prefix(['hello', 'world', 'hi', 'how'], 'h'))\nprint(filter_by_prefix(['cat', 'dog', 'cow', 'camel'], 'c'))"}
{"task_id": "HumanEval/30", "completion": " positive_numbers = []\n for number in l:\n if number > 0:\n positive_numbers.append(number)\n return positive_numbers"}
{"task_id": "HumanEval/31", "completion": "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"}
{"task_id": "HumanEval/32", "completion": " if len(xs) % 2 == 0 and xs[-1] != 0:\n lower_bound = -100\n upper_bound = 100\n tolerance = 1e-6\n\n while upper_bound - lower_bound > tolerance:\n mid_point = (lower_bound + upper_bound) / 2\n poly_value = poly(xs, mid_point)\n\n if abs(poly_value) < tolerance:\n return mid_point\n elif poly_value > 0:\n upper_bound = mid_point\n else:\n lower_bound = mid_point\n\n return None"}
{"task_id": "HumanEval/33", "completion": "def sort_third(l: list):\n divisible_by_three = [l[i] for i in range(0, len(l), 3)]\n divisible_by_three.sort()\n result = []\n for i in range(len(l)):\n if i % 3 == 0:\n result.append(divisible_by_three.pop(0))\n else:\n result.append(l[i])\n return result\n\nprint(sort_third([1, 2, 3]))\nprint(sort_third([5, 6, 3, 4, 8, 9, 2]))"}
{"task_id": "HumanEval/34", "completion": " return sorted(set(l))"}
{"task_id": "HumanEval/35", "completion": " if len(l) == 0:\n return None\n max_value = l[0]\n for i in l:\n if i > max_value:\n max_value = i\n return max_value"}
{"task_id": "HumanEval/36", "completion": " count = 0\n for i in range(1, n):\n if i % 11 == 0 or i % 13 == 0:\n count += str(i).count('7')\n return count"}
{"task_id": "HumanEval/37", "completion": "even_values = [l[i] for i in range(0, len(l), 2)]\neven_values.sort()\n\nresult = []\nfor i in range(len(l)):\n if i % 2 == 0:\n result.append(even_values.pop(0))\n else:\n result.append(l[i])\n\nreturn result"}
{"task_id": "HumanEval/38", "completion": "# 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 in reverse order. Unless group has fewer elements than 3.\n groups = [(group[-1] + group[:-1]) if len(group) == 3 else group for group in groups]\n return \"\".join(groups)"}
{"task_id": "HumanEval/39", "completion": "def is_prime(num):\n if num < 2:\n return False\n for i in range(2, num):\n if num % i == 0:\n return False\n return True\n\ndef fibonacci(n):\n if n == 0:\n return 0\n elif n == 1:\n return 1\n else:\n return fibonacci(n-1) + fibonacci(n-2)\n\ndef prime_fib(n: int):\n prime_fibs = []\n i = 0\n while len(prime_fibs) < n:\n fib = fibonacci(i)\n if is_prime(fib):\n prime_fibs.append(fib)\n i += 1\n return prime_fibs[-1]"}
{"task_id": "HumanEval/40", "completion": "for i in range(len(l)):\n for j in range(i+1, len(l)):\n for k in range(j+1, len(l)):\n if l[i] + l[j] + l[k] == 0:\n return True\n return False"}
{"task_id": "HumanEval/41", "completion": "return n * (n - 1) // 2"}
{"task_id": "HumanEval/42", "completion": " return [x + 1 for x in l]"}
{"task_id": "HumanEval/43", "completion": "for i in range(len(l)):\n for j in range(i+1, len(l)):\n if l[i] + l[j] == 0:\n return True\n return False"}
{"task_id": "HumanEval/44", "completion": " if x == 0:\n return '0'\n digits = []\n while x:\n digits.append(str(x % base))\n x //= base\n return ''.join(digits[::-1])"}
{"task_id": "HumanEval/45", "completion": " return 0.5 * a * h"}
{"task_id": "HumanEval/46", "completion": " if n == 0:\n return 0\n elif n == 1:\n return 0\n elif n == 2:\n return 2\n elif n == 3:\n return 0\n\n a, b, c, d = 0, 0, 2, 0\n for _ in range(n - 3):\n a, b, c, d = b, c, d, a + b + c + d\n\n return d\n\n# Test cases\nprint(fib4(5)) # 4\nprint(fib4(6)) # 8\nprint(fib4(7)) # 14"}
{"task_id": "HumanEval/47", "completion": " l.sort()\n n = len(l)\n if n % 2 == 0:\n return (l[n//2 - 1] + l[n//2]) / 2\n else:\n return l[n//2]"}
{"task_id": "HumanEval/48", "completion": " text = text.lower()\n return text == text[::-1]"}
{"task_id": "HumanEval/49", "completion": " return pow(2, n, p)"}
{"task_id": "HumanEval/50", "completion": "return \"\".join([chr(((ord(ch) - 5 - ord(\"a\")) % 26) + ord(\"a\")) for ch in s])"}
{"task_id": "HumanEval/51", "completion": "vowels = \"aeiouAEIOU\"\n result = \"\"\n for char in text:\n if char not in vowels:\n result += char\n return result"}
{"task_id": "HumanEval/52", "completion": " for num in l:\n if num >= t:\n return False\n return True"}
{"task_id": "HumanEval/53", "completion": " return x + y\n\nif __name__ == \"__main__\":\n import doctest\n doctest.testmod()"}
{"task_id": "HumanEval/54", "completion": " return sorted(set(s0)) == sorted(set(s1))"}
{"task_id": "HumanEval/55", "completion": " if n == 0:\n return 0\n elif n == 1:\n return 1\n else:\n return fib(n-1) + fib(n-2)"}
{"task_id": "HumanEval/56", "completion": " count = 0\n for bracket in brackets:\n if bracket == \"<\":\n count += 1\n elif bracket == \">\":\n count -= 1\n if count < 0:\n return False\n return count == 0"}
{"task_id": "HumanEval/57", "completion": " if len(l) < 2:\n return True\n\n direction = l[1] - l[0]\n for i in range(2, len(l)):\n if direction == 0:\n direction = l[i] - l[i - 1]\n continue\n if (l[i] - l[i - 1]) * direction < 0:\n return False\n\n return True"}
{"task_id": "HumanEval/58", "completion": " common_elements = list(set(l1) & set(l2))\n return sorted(common_elements)"}
{"task_id": "HumanEval/59", "completion": "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\ndef largest_prime_factor(n: int):\n largest = 1\n for i in range(2, n + 1):\n if n % i == 0 and is_prime(i):\n largest = i\n return largest\n\nprint(largest_prime_factor(13195))\nprint(largest_prime_factor(2048))"}
{"task_id": "HumanEval/60", "completion": " return sum(range(1, n+1))\n\nif __name__ == \"__main__\":\n import doctest\n doctest.testmod()"}
{"task_id": "HumanEval/61", "completion": " count = 0\n for bracket in brackets:\n if bracket == \"(\":\n count += 1\n elif bracket == \")\":\n count -= 1\n if count < 0:\n return False\n return count == 0"}
{"task_id": "HumanEval/62", "completion": "def derivative(xs: list):\n return [i * xs[i] for i in range(1, len(xs))]"}
{"task_id": "HumanEval/63", "completion": "def fibfib(n: int):\n if n == 0:\n return 0\n elif n == 1:\n return 0\n elif n == 2:\n return 1\n else:\n fibfib_list = [0, 0, 1]\n for i in range(3, n+1):\n fibfib_list.append(fibfib_list[-1] + fibfib_list[-2] + fibfib_list[-3])\n return fibfib_list[-1]\n\nprint(fibfib(1))\nprint(fibfib(5))\nprint(fibfib(8))"}
{"task_id": "HumanEval/64", "completion": " vowels = \"aeiouAEIOU\"\n count = 0\n\n for char in s:\n if char in vowels:\n count += 1\n\n if s[-1] == \"y\" or s[-1] == \"Y\":\n count += 1\n\n return count\n\n# Test cases\nprint(vowels_count(\"abcde\")) # Should print 2\nprint(vowels_count(\"ACEDY\")) # Should print 3\nprint(vowels_count(\"y\")) # Should print 1\nprint(vowels_count(\"Y\")) # Should print 1\nprint(vowels_count(\"yellow\")) # Should print 2\nprint(vowels_count(\"YELLO\")) # Should print 2"}
{"task_id": "HumanEval/65", "completion": " x_str = str(x)\n num_digits = len(x_str)\n\n if shift > num_digits:\n return x_str[::-1]\n\n shifted_str = x_str[-shift:] + x_str[:-shift]\n return shifted_str\n\n# Test cases\nprint(circular_shift(12, 1)) # \"21\"\nprint(circular_shift(12, 2)) # \"12\"\nprint(circular_shift(12345, 3)) # \"34512\"\nprint(circular_shift(12345, 6)) # \"54321\""}
{"task_id": "HumanEval/66", "completion": " upper_sum = 0\n for char in s:\n if char.isupper():\n upper_sum += ord(char)\n return upper_sum"}
{"task_id": "HumanEval/67", "completion": "def fruit_distribution(s, n):\n s = s.split()\n apples = int(s[0])\n oranges = int(s[3])\n mangoes = n - apples - oranges\n return mangoes\n\nprint(fruit_distribution(\"5 apples and 6 oranges\", 19))\nprint(fruit_distribution(\"0 apples and 1 oranges\", 3))\nprint(fruit_distribution(\"2 apples and 3 oranges\", 100))\nprint(fruit_distribution(\"100 apples and 1 oranges\", 120))"}
{"task_id": "HumanEval/68", "completion": "def pluck(arr):\n if not arr:\n return []\n \n smallest_even = float('inf')\n smallest_index = -1\n \n for i, value in enumerate(arr):\n if value % 2 == 0 and value < smallest_even:\n smallest_even = value\n smallest_index = i\n \n if smallest_index == -1:\n return []\n else:\n return [smallest_even, smallest_index]\n\n# Test cases\nprint(pluck([4, 2, 3])) # [2, 1]\nprint(pluck([1, 2, 3])) # [2, 1]\nprint(pluck([])) # []\nprint(pluck([5, 0, 3, 0, 4, 2])) # [0, 1]"}
{"task_id": "HumanEval/69", "completion": "from collections import Counter\n\ndef search(lst):\n counter = Counter(lst)\n result = -1\n for key, value in counter.items():\n if key <= value:\n result = max(result, key)\n return result\n\nprint(search([4, 1, 2, 2, 3, 1])) # 2\nprint(search([1, 2, 2, 3, 3, 3, 4, 4, 4])) # 3\nprint(search([5, 5, 4, 4, 4])) # -1"}
{"task_id": "HumanEval/70", "completion": "def strange_sort_list(lst):\n if not lst:\n return []\n\n lst.sort()\n result = []\n\n while lst:\n result.append(lst.pop(0))\n if lst:\n result.append(lst.pop(-1))\n\n return result"}
{"task_id": "HumanEval/71", "completion": " if a + b > c and a + c > b and b + c > a:\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\n\nprint(triangle_area(3, 4, 5))\nprint(triangle_area(1, 2, 10))"}
{"task_id": "HumanEval/72", "completion": "def will_it_fly(q, w):\n if q == q[::-1] and sum(q) <= w:\n return True\n else:\n return False\n\nprint(will_it_fly([1, 2], 5)) # False\nprint(will_it_fly([3, 2, 3], 1)) # False\nprint(will_it_fly([3, 2, 3], 9)) # True\nprint(will_it_fly([3], 5)) # True"}
{"task_id": "HumanEval/73", "completion": "def smallest_change(arr):\n changes = 0\n i, j = 0, len(arr) - 1\n while i < j:\n if arr[i] != arr[j]:\n changes += 1\n i += 1\n j -= 1\n return changes"}
{"task_id": "HumanEval/74", "completion": "def total_match(lst1, lst2):\n total_chars_lst1 = sum(len(s) for s in lst1)\n total_chars_lst2 = sum(len(s) for s in lst2)\n\n if total_chars_lst1 < total_chars_lst2:\n return lst1\n else:\n return lst2\n\nprint(total_match([], []))\nprint(total_match(['hi', 'admin'], ['hI', 'Hi']))\nprint(total_match(['hi', 'admin'], ['hi', 'hi', 'admin', 'project']))\nprint(total_match(['hi', 'admin'], ['hI', 'hi', 'hi']))\nprint(total_match(['4'], ['1', '2', '3', '4', '5']))"}
{"task_id": "HumanEval/75", "completion": "def is_prime(n):\n if n < 2:\n return False\n for i in range(2, n):\n if n % i == 0:\n return False\n return True\n\ndef is_multiply_prime(a):\n if a < 2:\n return False\n prime_factors = []\n for i in range(2, a + 1):\n if is_prime(i) and a % i == 0:\n prime_factors.append(i)\n a = a // i\n if len(prime_factors) > 3:\n return False\n return len(prime_factors) == 3\n\nprint(is_multiply_prime(30)) # True\nprint(is_multiply_prime(42)) # True\nprint(is_multiply_prime(100)) # False\nprint(is_multiply_prime(2)) # False\nprint(is_multiply_prime(3)) # False"}
{"task_id": "HumanEval/76", "completion": "def is_simple_power(x, n):\n if n == 1:\n return False\n i = 0\n while n ** i <= x:\n if n ** i == x:\n return True\n i += 1\n return False\n\nprint(is_simple_power(1, 4))\nprint(is_simple_power(2, 2))\nprint(is_simple_power(8, 2))\nprint(is_simple_power(3, 2))\nprint(is_simple_power(3, 1))\nprint(is_simple_power(5, 3))"}
{"task_id": "HumanEval/77", "completion": "def iscube(a):\n if a < 0:\n a = -a\n root = round(a ** (1/3))\n return root ** 3 == a\n\nprint(iscube(1)) # True\nprint(iscube(2)) # False\nprint(iscube(-1)) # True\nprint(iscube(64)) # True\nprint(iscube(0)) # True\nprint(iscube(180)) # False"}
{"task_id": "HumanEval/78", "completion": "def hex_key(num):\n prime_hex_digits = ['2', '3', '5', '7', 'B', 'D']\n count = 0\n for digit in num:\n if digit in prime_hex_digits:\n count += 1\n return count\n\nprint(hex_key(\"AB\")) # 1\nprint(hex_key(\"1077E\")) # 2\nprint(hex_key(\"ABED1A33\")) # 4\nprint(hex_key(\"123456789ABCDEF0\")) # 6\nprint(hex_key(\"2020\")) # 2"}
{"task_id": "HumanEval/79", "completion": "def decimal_to_binary(decimal):\n binary = bin(decimal)[2:]\n return \"db\" + binary + \"db\"\n\nprint(decimal_to_binary(15)) # returns \"db1111db\"\nprint(decimal_to_binary(32)) # returns \"db100000db\""}
{"task_id": "HumanEval/80", "completion": "def is_happy(s):\n if len(s) < 3:\n return False\n for i in range(len(s) - 2):\n if s[i] == s[i + 1] or s[i] == s[i + 2] or s[i + 1] == s[i + 2]:\n return False\n return True\n\nprint(is_happy(\"a\")) # False\nprint(is_happy(\"aa\")) # False\nprint(is_happy(\"abcd\")) # True\nprint(is_happy(\"aabb\")) # False\nprint(is_happy(\"adb\")) # True\nprint(is_happy(\"xyy\")) # False"}
{"task_id": "HumanEval/81", "completion": "def numerical_letter_grade(grades):\n letter_grades = []\n for grade in grades:\n if grade == 4.0:\n letter_grades.append(\"A+\")\n elif 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(\"B+\")\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(\"C+\")\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(\"D+\")\n elif grade > 0.7:\n letter_grades.append(\"D\")\n elif grade > 0.0:\n letter_grades.append(\"D-\")\n else:\n letter_grades.append(\"E\")\n return letter_grades\n\nprint(numerical_letter_grade([4.0, 3, 1.7, 2, 3.5])) # ['A+', 'B', 'C-', 'C', 'A-']"}
{"task_id": "HumanEval/82", "completion": "def is_prime(n):\n if n < 2:\n return False\n for i in range(2, n):\n if n % i == 0:\n return False\n return True\n\ndef prime_length(string):\n return is_prime(len(string))\n\nprint(prime_length('Hello')) # True\nprint(prime_length('abcdcba')) # True\nprint(prime_length('kittens')) # True\nprint(prime_length('orange')) # False"}
{"task_id": "HumanEval/83", "completion": " count = 0\n start = 10**(n-1)\n end = 10**n\n for i in range(start, end):\n if str(i)[0] == '1' or str(i)[-1] == '1':\n count += 1\n return count"}
{"task_id": "HumanEval/84", "completion": "def solve(N):\n binary_n = bin(N)[2:]\n sum_of_digits = sum(int(digit) for digit in binary_n)\n return bin(sum_of_digits)[2:]\n\n# Test cases\nprint(solve(1000)) # Should print \"1\"\nprint(solve(150)) # Should print \"110\"\nprint(solve(147)) # Should print \"1100\""}
{"task_id": "HumanEval/85", "completion": " even_sum = 0\n for i in range(len(lst)):\n if i % 2 != 0 and lst[i] % 2 == 0:\n even_sum += lst[i]\n return even_sum\n\nprint(add([4, 2, 6, 7])) #==> 2\nprint(add([1, 4, 3, 6, 5, 8])) #==> 14\nprint(add([2, 4, 6, 8])) #==> 12\nprint(add([1, 3, 5, 7])) #==> 0\nprint(add([1, 2, 3, 4, 5, 6, 7, 8])) #==> 20"}
{"task_id": "HumanEval/86", "completion": "def anti_shuffle(s):\n words = s.split(' ')\n ordered_words = []\n for word in words:\n ordered_word = ''.join(sorted(word))\n ordered_words.append(ordered_word)\n return ' '.join(ordered_words)\n\nprint(anti_shuffle('Hi'))\nprint(anti_shuffle('hello'))\nprint(anti_shuffle('Hello World!!!'))"}
{"task_id": "HumanEval/87", "completion": "def get_row(lst, x):\n result = []\n for i, row in enumerate(lst):\n for j, elem in enumerate(row):\n if elem == x:\n result.append((i, j))\n result.sort(key=lambda x: (x[0], -x[1]))\n return result\n\nprint(get_row([\n [1,2,3,4,5,6],\n [1,2,3,4,1,6],\n [1,2,3,4,5,1]\n], 1))\nprint(get_row([], 1))\nprint(get_row([[], [1], [1, 2, 3]], 3))"}
{"task_id": "HumanEval/88", "completion": "def sort_array(array):\n if not array:\n return array\n sorted_array = array.copy()\n if (array[0] + array[-1]) % 2 == 0:\n sorted_array.sort(reverse=True)\n else:\n sorted_array.sort()\n return sorted_array\n\nprint(sort_array([]))\nprint(sort_array([5]))\nprint(sort_array([2, 4, 3, 0, 1, 5]))\nprint(sort_array([2, 4, 3, 0, 1, 5, 6]))"}
{"task_id": "HumanEval/89", "completion": " encrypted = ''\n for char in s:\n if char.isalpha():\n shift = 2 * 2\n char_code = ord(char) + shift\n if char.islower():\n encrypted += chr((char_code - 97) % 26 + 97)\n else:\n encrypted += chr((char_code - 65) % 26 + 65)\n else:\n encrypted += char\n return encrypted\n\nprint(encrypt('hi'))\nprint(encrypt('asdfghjkl'))\nprint(encrypt('gf'))\nprint(encrypt('et'))"}
{"task_id": "HumanEval/90", "completion": "def next_smallest(lst):\n if len(lst) < 2:\n return None\n lst = sorted(set(lst))\n if len(lst) < 2:\n return None\n return lst[1]"}
{"task_id": "HumanEval/91", "completion": " sentences = S.split(\".\")\n sentences += S.split(\"?\")\n sentences += S.split(\"!\")\n\n boredoms = 0\n for sentence in sentences:\n words = sentence.split()\n if len(words) > 0 and words[0] == \"I\":\n boredoms += 1\n\n return boredoms"}
{"task_id": "HumanEval/92", "completion": "def any_int(x, y, z):\n if isinstance(x, int) and isinstance(y, int) and isinstance(z, int):\n return (x + y == z) or (x + z == y) or (y + z == x)\n else:\n return False\n\nprint(any_int(5, 2, 7)) # True\nprint(any_int(3, 2, 2)) # False\nprint(any_int(3, -2, 1)) # True\nprint(any_int(3.6, -2.2, 2)) # False"}
{"task_id": "HumanEval/93", "completion": "def encode(message):\n vowels = 'aeiouAEIOU'\n encoded_message = ''\n \n for char in message:\n if char.isalpha():\n if char in vowels:\n if char.islower():\n encoded_message += chr(((ord(char) - ord('a') + 2) % 26) + ord('a'))\n else:\n encoded_message += chr(((ord(char) - ord('A') + 2) % 26) + ord('A'))\n else:\n if char.islower():\n encoded_message += char.upper()\n else:\n encoded_message += char.lower()\n else:\n encoded_message += char\n \n return encoded_message\n\nprint(encode('test'))\nprint(encode('This is a message'))"}
{"task_id": "HumanEval/94", "completion": "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\ndef skjkasdkd(lst):\n largest_prime = 0\n for num in lst:\n if is_prime(num) and num > largest_prime:\n largest_prime = num\n return sum(int(digit) for digit in str(largest_prime))\n\nprint(skjkasdkd([0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3]))\nprint(skjkasdkd([1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1]))\nprint(skjkasdkd([1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3]))\nprint(skjkasdkd([0,724,32,71,99,32,6,0,5,91,83,0,5,6]))\nprint(skjkasdkd([0,81,12,3,1,21]))\nprint(skjkasdkd([0,8,1,2,1,7]))"}
{"task_id": "HumanEval/95", "completion": "def check_dict_case(dict):\n if not dict:\n return False\n lower_case = 0\n upper_case = 0\n for key in dict:\n if not isinstance(key, str):\n return False\n if key.islower():\n lower_case += 1\n elif key.isupper():\n upper_case += 1\n else:\n return False\n if lower_case == len(dict) or upper_case == len(dict):\n return True\n else:\n return False\n\nprint(check_dict_case({\"a\":\"apple\", \"b\":\"banana\"}))\nprint(check_dict_case({\"a\":\"apple\", \"A\":\"banana\", \"B\":\"banana\"}))\nprint(check_dict_case({\"a\":\"apple\", 8:\"banana\", \"a\":\"apple\"}))\nprint(check_dict_case({\"Name\":\"John\", \"Age\":\"36\", \"City\":\"Houston\"}))\nprint(check_dict_case({\"STATE\":\"NC\", \"ZIP\":\"12345\" }))"}
{"task_id": "HumanEval/96", "completion": "def is_prime(num):\n if num < 2:\n return False\n for i in range(2, num):\n if num % i == 0:\n return False\n return True\n\ndef count_up_to(n):\n primes = []\n for i in range(n):\n if is_prime(i):\n primes.append(i)\n return primes\n\nprint(count_up_to(5))\nprint(count_up_to(11))\nprint(count_up_to(0))\nprint(count_up_to(20))\nprint(count_up_to(1))\nprint(count_up_to(18))"}
{"task_id": "HumanEval/97", "completion": "def multiply(a, b):\n a_units = abs(a) % 10\n b_units = abs(b) % 10\n return a_units * b_units\n\nprint(multiply(148, 412))\nprint(multiply(19, 28))\nprint(multiply(2020, 1851))\nprint(multiply(14, -15))"}
{"task_id": "HumanEval/98", "completion": " count = 0\n vowels = 'AEIOU'\n for i in range(0, len(s), 2):\n if s[i] in vowels:\n count += 1\n return count\n\n# Test cases\nprint(count_upper('aBCdEf')) # should return 1\nprint(count_upper('abcdefg')) # should return 0\nprint(count_upper('dBBE')) # should return 0\nprint(count_upper('AeIoU')) # should return 3\nprint(count_upper('')) # should return 0"}
{"task_id": "HumanEval/99", "completion": "def closest_integer(value):\n float_value = float(value)\n if float_value >= 0:\n return int(float_value + 0.5)\n else:\n return int(float_value - 0.5)\n\nprint(closest_integer(\"10\"))\nprint(closest_integer(\"15.3\"))\nprint(closest_integer(\"14.5\"))\nprint(closest_integer(\"-14.5\"))"}
{"task_id": "HumanEval/100", "completion": "def make_a_pile(n):\n pile = []\n for i in range(n):\n if n % 2 == 0:\n pile.append(n + 2 * i)\n else:\n pile.append(n + 2 * i)\n return pile\n\nprint(make_a_pile(3))\nprint(make_a_pile(4))\nprint(make_a_pile(5))\nprint(make_a_pile(6))\nprint(make_a_pile(7))"}
{"task_id": "HumanEval/101", "completion": "import re\n\ndef words_string(s):\n words = re.split(', | ', s)\n return words"}
{"task_id": "HumanEval/102", "completion": "def choose_num(x, y):\n if x > y:\n x, y = y, x\n for i in range(y, x - 1, -1):\n if i % 2 == 0:\n return i\n return -1\n\nprint(choose_num(12, 15)) # 14\nprint(choose_num(13, 12)) # -1\nprint(choose_num(5, 9)) # 8\nprint(choose_num(10, 10)) # 10\nprint(choose_num(7, 3)) # -1"}
{"task_id": "HumanEval/103", "completion": "def rounded_avg(n, m):\n if n > m:\n return -1\n else:\n total = 0\n count = 0\n for i in range(n, m+1):\n total += i\n count += 1\n avg = round(total / count)\n return bin(avg)\n\nprint(rounded_avg(1, 5))\nprint(rounded_avg(7, 5))\nprint(rounded_avg(10, 20))\nprint(rounded_avg(20, 33))"}
{"task_id": "HumanEval/104", "completion": "def unique_digits(x):\n def has_even_digit(n):\n return any(int(d) % 2 == 0 for d in str(n))\n\n return sorted([n for n in x if not has_even_digit(n)])\n\nprint(unique_digits([15, 33, 1422, 1]))\nprint(unique_digits([152, 323, 1422, 10]))\nprint(unique_digits([135, 357, 579, 111]))\nprint(unique_digits([246, 468, 810, 222]))\nprint(unique_digits([123, 456, 789, 0]))"}
{"task_id": "HumanEval/105", "completion": "def by_length(arr):\n num_to_word = {\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 \n arr = sorted([x for x in arr if 1 <= x <= 9], reverse=True)\n return [num_to_word[x] for x in arr]\n\n# Test cases\nprint(by_length([2, 1, 1, 4, 5, 8, 2, 3]))\nprint(by_length([]))\nprint(by_length([1, -1, 55]))"}
{"task_id": "HumanEval/106", "completion": "def f(n):\n def factorial(i):\n if i == 0:\n return 1\n else:\n return i * factorial(i - 1)\n\n def sum_numbers(i):\n return sum(range(1, i + 1))\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_numbers(i))\n return result\n\nprint(f(5)) # [1, 2, 6, 24, 15]"}
{"task_id": "HumanEval/107", "completion": "def is_palindrome(num):\n return str(num) == str(num)[::-1]\n\ndef even_odd_palindrome(n):\n even_count = 0\n odd_count = 0\n\n for i in range(1, n+1):\n if is_palindrome(i):\n if i % 2 == 0:\n even_count += 1\n else:\n odd_count += 1\n\n return (even_count, odd_count)\n\nprint(even_odd_palindrome(3)) # (1, 2)\nprint(even_odd_palindrome(12)) # (4, 6)"}
{"task_id": "HumanEval/108", "completion": "def count_nums(arr):\n def sum_of_digits(n):\n if n < 0:\n n = -n\n return -1 * (n % 10) + sum_of_digits(n // 10)\n elif n == 0:\n return 0\n else:\n return n % 10 + sum_of_digits(n // 10)\n\n count = 0\n for num in arr:\n if sum_of_digits(num) > 0:\n count += 1\n return count\n\nprint(count_nums([]) == 0)\nprint(count_nums([-1, 11, -11]) == 1)\nprint(count_nums([1, 1, 2]) == 3)"}
{"task_id": "HumanEval/109", "completion": "def move_one_ball(arr):\n if len(arr) == 0:\n return True\n count = 0\n for i in range(len(arr) - 1):\n if arr[i] > arr[i + 1]:\n count += 1\n if count > 1:\n return False\n if count == 1 and arr[-1] > arr[0]:\n return False\n return True"}
{"task_id": "HumanEval/110", "completion": "def exchange(lst1, lst2):\n odd_lst1 = [x for x in lst1 if x % 2 != 0]\n even_lst2 = [x for x in lst2 if x % 2 == 0]\n \n if len(odd_lst1) <= len(even_lst2):\n return \"YES\"\n else:\n return \"NO\"\n\nprint(exchange([1, 2, 3, 4], [1, 2, 3, 4])) # \"YES\"\nprint(exchange([1, 2, 3, 4], [1, 5, 3, 4])) # \"NO\"\nprint(exchange([1, 3, 5], [2, 4, 6])) # \"YES\"\nprint(exchange([1, 3, 5], [1, 3, 5])) # \"NO\"\nprint(exchange([2, 4, 6], [1, 3, 5])) # \"YES\""}
{"task_id": "HumanEval/111", "completion": " # Split the string into a list of letters\n letters = test.split()\n\n # Create an empty dictionary to store the letter counts\n letter_counts = {}\n\n # Iterate through the list of letters\n for letter in letters:\n # If the letter is already in the dictionary, increment its count\n if letter in letter_counts:\n letter_counts[letter] += 1\n # If the letter is not in the dictionary, add it with a count of 1\n else:\n letter_counts[letter] = 1\n\n # Find the maximum count of any letter\n max_count = 0\n for count in letter_counts.values():\n if count > max_count:\n max_count = count\n\n # Create a new dictionary containing only the letters with the maximum count\n max_count_letters = {}\n for letter, count in letter_counts.items():\n if count == max_count:\n max_count_letters[letter] = count\n\n return max_count_letters"}
{"task_id": "HumanEval/112", "completion": "def reverse_delete(s, c):\n result = ''.join([x for x in s if x not in c])\n return (result, result == result[::-1])\n\nprint(reverse_delete(\"abcde\", \"ae\"))\nprint(reverse_delete(\"abcdef\", \"b\"))\nprint(reverse_delete(\"abcdedcba\", \"ab\"))"}
{"task_id": "HumanEval/113", "completion": "def odd_count(lst):\n output = []\n for i in lst:\n odd_count = sum(1 for digit in i if int(digit) % 2 != 0)\n output.append(f\"the number of odd elements {odd_count}n the str{odd_count}ng {odd_count} of the {odd_count}nput.\")\n return output\n\nprint(odd_count(['1234567']))\nprint(odd_count(['3', \"11111111\"]))"}
{"task_id": "HumanEval/114", "completion": " if not nums:\n return 0\n\n min_sum = float('inf')\n for i in range(len(nums)):\n current_sum = 0\n for j in range(i, len(nums)):\n current_sum += nums[j]\n if current_sum < min_sum:\n min_sum = current_sum\n\n return min_sum"}
{"task_id": "HumanEval/115", "completion": "def max_fill(grid, capacity):\n total_water = sum([row.count(1) for row in grid])\n return math.ceil(total_water / capacity)"}
{"task_id": "HumanEval/116", "completion": "def sort_array(arr):\n return sorted(arr, key=lambda x: (bin(x).count('1'), x))"}
{"task_id": "HumanEval/117", "completion": "def select_words(s, n):\n if not s:\n return []\n \n words = s.split()\n result = []\n \n for word in words:\n consonants = 0\n for letter in word:\n if letter.lower() not in \"aeiou\":\n consonants += 1\n if consonants == n:\n result.append(word)\n \n return result"}
{"task_id": "HumanEval/118", "completion": "def get_closest_vowel(word):\n vowels = \"AEIOUaeiou\"\n closest_vowel = \"\"\n for i in range(len(word) - 1, 0, -1):\n if word[i] in vowels and word[i - 1] not in vowels and word[i + 1] not in vowels:\n closest_vowel = word[i]\n break\n return closest_vowel\n\nprint(get_closest_vowel(\"yogurt\")) # \"u\"\nprint(get_closest_vowel(\"FULL\")) # \"U\"\nprint(get_closest_vowel(\"quick\")) # \"\"\nprint(get_closest_vowel(\"ab\")) # \"\""}
{"task_id": "HumanEval/119", "completion": "for s1, s2 in [(lst[0], lst[1]), (lst[1], lst[0])]:\n balance = 0\n for c in s1 + s2:\n if c == '(':\n balance += 1\n else:\n balance -= 1\n if balance < 0:\n break\n if balance == 0:\n return 'Yes'\n return 'No'"}
{"task_id": "HumanEval/120", "completion": "def maximum(arr, k):\n arr.sort(reverse=True)\n return arr[:k]"}
{"task_id": "HumanEval/121", "completion": " odd_sum = 0\n for i in range(0, len(lst), 2):\n if lst[i] % 2 != 0:\n odd_sum += lst[i]\n return odd_sum"}
{"task_id": "HumanEval/122", "completion": "def add_elements(arr, k):\n sum = 0\n for i in range(k):\n if len(str(arr[i])) <= 2:\n sum += arr[i]\n return sum"}
{"task_id": "HumanEval/123", "completion": "def get_odd_collatz(n):\n odd_collatz = []\n while n != 1:\n if n % 2 == 1:\n odd_collatz.append(n)\n n = n // 2 if n % 2 == 0 else 3 * n + 1\n odd_collatz.append(1)\n return sorted(odd_collatz)\n\nprint(get_odd_collatz(5)) # [1, 5]\nprint(get_odd_collatz(6)) # [1, 3]\nprint(get_odd_collatz(7)) # [1, 7, 5, 3]\nprint(get_odd_collatz(8)) # [1]\nprint(get_odd_collatz(9)) # [1, 9, 5]"}
{"task_id": "HumanEval/124", "completion": " if not date:\n return False\n\n if len(date) != 10:\n return False\n\n if date[2] != '-' or date[5] != '-':\n return False\n\n month, day, year = date.split('-')\n\n if not month.isdigit() or not day.isdigit() or not year.isdigit():\n return False\n\n month = int(month)\n day = int(day)\n year = int(year)\n\n if month < 1 or month > 12:\n return False\n\n if month in [1, 3, 5, 7, 8, 10, 12]:\n if day < 1 or day > 31:\n return False\n elif month in [4, 6, 9, 11]:\n if day < 1 or day > 30:\n return False\n else: # month == 2\n if year % 4 == 0 and (year % 100 != 0 or year % 400 == 0):\n if day < 1 or day > 29:\n return False\n else:\n if day < 1 or day > 28:\n return False\n\n return True"}
{"task_id": "HumanEval/125", "completion": "def split_words(txt):\n if ' ' in txt:\n return txt.split()\n elif ',' in txt:\n return txt.split(',')\n else:\n return sum(1 for c in txt if c.islower() and (ord(c) - ord('a')) % 2 == 1)\n\nprint(split_words(\"Hello world!\")) # [\"Hello\", \"world!\"]\nprint(split_words(\"Hello,world!\")) # [\"Hello\", \"world!\"]\nprint(split_words(\"abcdef\")) # 3"}
{"task_id": "HumanEval/126", "completion": "def is_sorted(lst):\n if len(lst) == 1:\n return True\n for i in range(len(lst) - 1):\n if lst[i] > lst[i + 1]:\n return False\n if lst.count(lst[i]) > 2:\n return False\n return True\n\nprint(is_sorted([5])) # True\nprint(is_sorted([1, 2, 3, 4, 5])) # True\nprint(is_sorted([1, 3, 2, 4, 5])) # False\nprint(is_sorted([1, 2, 3, 4, 5, 6])) # True\nprint(is_sorted([1, 2, 3, 4, 5, 6, 7])) # True\nprint(is_sorted([1, 3, 2, 4, 5, 6, 7])) # False\nprint(is_sorted([1, 2, 2, 3, 3, 4])) # True\nprint(is_sorted([1, 2, 2, 2, 3, 4])) # False"}
{"task_id": "HumanEval/127", "completion": "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\ndef intersection(interval1, interval2):\n start = max(interval1[0], interval2[0])\n end = min(interval1[1], interval2[1])\n if start > end:\n return \"NO\"\n length = end - start\n if is_prime(length):\n return \"YES\"\n else:\n return \"NO\"\n\nprint(intersection((1, 2), (2, 3))) # \"NO\"\nprint(intersection((-1, 1), (0, 4))) # \"NO\"\nprint(intersection((-3, -1), (-5, 5))) # \"YES\""}
{"task_id": "HumanEval/128", "completion": "def prod_signs(arr):\n if not arr:\n return None\n sum_magnitudes = 0\n prod_signs = 1\n for num in arr:\n sum_magnitudes += abs(num)\n if num < 0:\n prod_signs *= -1\n elif num == 0:\n prod_signs = 0\n break\n return sum_magnitudes * prod_signs\n\nprint(prod_signs([1, 2, 2, -4])) # -9\nprint(prod_signs([0, 1])) # 0\nprint(prod_signs([])) # None"}
{"task_id": "HumanEval/129", "completion": "def minPath(grid, k):\n N = len(grid)\n min_path = [N * N + 1] * k\n visited = [[False] * N for _ in range(N)]\n\n def dfs(x, y, path, k):\n nonlocal min_path\n if k == 0:\n if path < min_path:\n min_path = path\n return\n if x < 0 or x >= N or y < 0 or y >= N or visited[x][y]:\n return\n visited[x][y] = True\n path.append(grid[x][y])\n dfs(x - 1, y, path, k - 1)\n dfs(x + 1, y, path, k - 1)\n dfs(x, y - 1, path, k - 1)\n dfs(x, y + 1, path, k - 1)\n path.pop()\n visited[x][y] = False\n\n for i in range(N):\n for j in range(N):\n dfs(i, j, [], k)\n\n return min_path"}
{"task_id": "HumanEval/130", "completion": "def tri(n):\n if n == 0:\n return [1]\n elif n == 1:\n return [1, 3]\n elif n == 2:\n return [1, 3, 2]\n else:\n result = [1, 3, 2]\n for i in range(3, n + 1):\n if i % 2 == 0:\n result.append(1 + i // 2)\n else:\n result.append(result[-1] + result[-2] + result[-3])\n return result\n\n# Test cases\nprint(tri(3)) # [1, 3, 2, 8]\nprint(tri(5)) # [1, 3, 2, 8, 3, 13]\nprint(tri(0)) # [1]\nprint(tri(1)) # [1, 3]\nprint(tri(2)) # [1, 3, 2]"}
{"task_id": "HumanEval/131", "completion": " product = 1\n odd_digits = False\n\n for digit in str(n):\n if int(digit) % 2 != 0:\n product *= int(digit)\n odd_digits = True\n\n if odd_digits:\n return product\n else:\n return 0"}
{"task_id": "HumanEval/132", "completion": "def is_nested(string):\n stack = []\n for char in string:\n if char == '[':\n stack.append(char)\n elif char == ']':\n if not stack:\n return False\n stack.pop()\n return len(stack) == 0"}
{"task_id": "HumanEval/133", "completion": "import math\n\ndef sum_squares(lst):\n return sum([math.ceil(x)**2 for x in lst])"}
{"task_id": "HumanEval/134", "completion": "def check_if_last_char_is_a_letter(txt):\n if len(txt) == 0:\n return False\n if txt[-1].isalpha() and (len(txt) == 1 or txt[-2] == \" \"):\n return True\n else:\n return False\n\nprint(check_if_last_char_is_a_letter(\"apple pie\")) # False\nprint(check_if_last_char_is_a_letter(\"apple pi e\")) # True\nprint(check_if_last_char_is_a_letter(\"apple pi e \")) # False\nprint(check_if_last_char_is_a_letter(\"\")) # False\nprint(check_if_last_char_is_a_letter(\"a\")) # True"}
{"task_id": "HumanEval/135", "completion": "def can_arrange(arr):\n largest_index = -1\n for i in range(1, len(arr)):\n if arr[i] < arr[i-1]:\n largest_index = i\n return largest_index\n\nprint(can_arrange([1,2,4,3,5])) # 3\nprint(can_arrange([1,2,3])) # -1\nprint(can_arrange([5,4,3,2,1])) # 1\nprint(can_arrange([1,3,5,4,2])) # 4\nprint(can_arrange([1])) # -1"}
{"task_id": "HumanEval/136", "completion": " largest_negative = None\n smallest_positive = None\n\n for num in lst:\n if num < 0:\n if largest_negative is None or num > largest_negative:\n largest_negative = num\n elif num > 0:\n if smallest_positive is None or num < smallest_positive:\n smallest_positive = num\n\n return (largest_negative, smallest_positive)\n\n# Test cases\nprint(largest_smallest_integers([2, 4, 1, 3, 5, 7])) # (None, 1)\nprint(largest_smallest_integers([])) # (None, None)\nprint(largest_smallest_integers([0])) # (None, None)\nprint(largest_smallest_integers([-2, -4, -1, -3, -5, -7])) # (-1, None)\nprint(largest_smallest_integers([-2, 4, -1, 3, -5, 7])) # (-1, 3)"}
{"task_id": "HumanEval/137", "completion": "def compare_one(a, b):\n # Convert strings to floats if necessary\n a_float = float(a.replace(',', '.')) if isinstance(a, str) else a\n b_float = float(b.replace(',', '.')) if isinstance(b, str) else b\n\n # Compare the floats\n if a_float > b_float:\n return a\n elif a_float < b_float:\n return b\n else:\n return None\n\nprint(compare_one(1, 2.5)) # \u279e 2.5\nprint(compare_one(1, \"2,3\")) # \u279e \"2,3\"\nprint(compare_one(\"5,1\", \"6\")) # \u279e \"6\"\nprint(compare_one(\"1\", 1)) # \u279e None"}
{"task_id": "HumanEval/138", "completion": " if n < 8:\n return False\n elif n % 2 == 0:\n return True\n else:\n return False\n\nprint(is_equal_to_sum_even(4)) # False\nprint(is_equal_to_sum_even(6)) # False\nprint(is_equal_to_sum_even(8)) # True\nprint(is_equal_to_sum_even(10)) # True\nprint(is_equal_to_sum_even(12)) # True"}
{"task_id": "HumanEval/139", "completion": " if n == 1:\n return 1\n else:\n return n * special_factorial(n - 1) * special_factorial(n - 2)"}
{"task_id": "HumanEval/140", "completion": "def fix_spaces(text):\n import re\n text = re.sub(' {2,}', '-', text)\n text = re.sub(' ', '_', text)\n return text\n\nprint(fix_spaces(\"Example\"))\nprint(fix_spaces(\"Example 1\"))\nprint(fix_spaces(\" Example 2\"))\nprint(fix_spaces(\" Example 3\"))"}
{"task_id": "HumanEval/141", "completion": "def file_name_check(file_name):\n import re\n\n # Check if there are more than three digits in the file's name\n if len(re.findall(r'\\d', file_name)) > 3:\n return 'No'\n\n # Check if the file's name contains exactly one dot\n if file_name.count('.') != 1:\n return 'No'\n\n # Split the file's name into two parts: before and after the dot\n name_parts = file_name.split('.')\n\n # Check if the substring before the dot is not empty and starts with a latin alphabet letter\n if not name_parts[0] or not name_parts[0][0].isalpha():\n return 'No'\n\n # Check if the substring after the dot is one of the allowed extensions\n if name_parts[1] not in ['txt', 'exe', 'dll']:\n return 'No'\n\n return 'Yes'\n\nprint(file_name_check(\"example.txt\")) # => 'Yes'\nprint(file_name_check(\"1example.dll\")) # => 'No'"}
{"task_id": "HumanEval/142", "completion": "def sum_squares(lst):\n result = 0\n for i, num in enumerate(lst):\n if i % 3 == 0:\n result += num ** 2\n elif i % 4 == 0:\n result += num ** 3\n else:\n result += num\n return result\n\nprint(sum_squares([1, 2, 3])) # Output: 6\nprint(sum_squares([])) # Output: 0\nprint(sum_squares([-1, -5, 2, -1, -5])) # Output: -126"}
{"task_id": "HumanEval/143", "completion": "def is_prime(n):\n if n < 2:\n return False\n for i in range(2, n):\n if n % i == 0:\n return False\n return True\n\ndef words_in_sentence(sentence):\n words = sentence.split()\n prime_words = [word for word in words if is_prime(len(word))]\n return ' '.join(prime_words)"}
{"task_id": "HumanEval/144", "completion": "def simplify(x, n):\n x_num, x_den = map(int, x.split('/'))\n n_num, n_den = map(int, n.split('/'))\n \n result_num = x_num * n_num\n result_den = x_den * n_den\n \n if result_num % result_den == 0:\n return True\n else:\n return False\n\nprint(simplify(\"1/5\", \"5/1\")) # True\nprint(simplify(\"1/6\", \"2/1\")) # False\nprint(simplify(\"7/10\", \"10/2\")) # False"}
{"task_id": "HumanEval/145", "completion": "def order_by_points(nums):\n def sum_of_digits(num):\n return sum(int(digit) for digit in str(abs(num)))\n\n return sorted(nums, key=lambda x: (sum_of_digits(x), nums.index(x)))\n\nprint(order_by_points([1, 11, -1, -11, -12]))\nprint(order_by_points([]))\nprint(order_by_points([56, 23, 89, 12, 34]))\nprint(order_by_points([-56, -23, -89, -12, -34]))\nprint(order_by_points([0, 0, 0, 0]))"}
{"task_id": "HumanEval/146", "completion": "def specialFilter(nums):\n count = 0\n for num in nums:\n if num > 10 and int(str(num)[0]) % 2 != 0 and int(str(num)[-1]) % 2 != 0:\n count += 1\n return count\n\nprint(specialFilter([15, -73, 14, -15])) # 1\nprint(specialFilter([33, -2, -3, 45, 21, 109])) # 2\nprint(specialFilter([11, 13, 15, 17, 19])) # 5\nprint(specialFilter([-11, -13, -15, -17, -19])) # 0\nprint(specialFilter([10, 20, 30, 40, 50])) # 0"}
{"task_id": "HumanEval/147", "completion": "def 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):\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 count += 1\n return count\n\nprint(get_max_triples(5)) # Output: 1\nprint(get_max_triples(6)) # Output: 3\nprint(get_max_triples(7)) # Output: 5\nprint(get_max_triples(8)) # Output: 7\nprint(get_max_triples(9)) # Output: 10"}
{"task_id": "HumanEval/148", "completion": " planets = [\"Mercury\", \"Venus\", \"Earth\", \"Mars\", \"Jupiter\", \"Saturn\", \"Uranus\", \"Neptune\"]\n\n if planet1 not in planets or planet2 not in planets:\n return ()\n\n planet1_index = planets.index(planet1)\n planet2_index = planets.index(planet2)\n\n if planet1_index > planet2_index:\n planet1_index, planet2_index = planet2_index, planet1_index\n\n return tuple(planets[planet1_index + 1:planet2_index])"}
{"task_id": "HumanEval/149", "completion": "def sorted_list_sum(lst):\n # Filter out odd length strings\n even_length_strings = [s for s in lst if len(s) % 2 == 0]\n\n # Sort the list by length and then alphabetically\n sorted_list = sorted(even_length_strings, key=lambda x: (len(x), x))\n\n return sorted_list\n\n# Test cases\nprint(sorted_list_sum([\"aa\", \"a\", \"aaa\"])) # => [\"aa\"]\nprint(sorted_list_sum([\"ab\", \"a\", \"aaa\", \"cd\"])) # => [\"ab\", \"cd\"]\nprint(sorted_list_sum([\"hello\", \"world\", \"python\", \"code\"])) # => [\"code\", \"python\"]\nprint(sorted_list_sum([\"apple\", \"banana\", \"cherry\", \"date\"])) # => [\"apple\", \"cherry\", \"banana\", \"date\"]\nprint(sorted_list_sum([\"a\", \"aa\", \"aaa\", \"aaaa\"])) # => [\"aa\", \"aaaa\"]"}
{"task_id": "HumanEval/150", "completion": "def is_prime(num):\n if num < 2:\n return False\n for i in range(2, num):\n if num % i == 0:\n return False\n return True\n\ndef x_or_y(n, x, y):\n if is_prime(n):\n return x\n else:\n return y\n\nprint(x_or_y(7, 34, 12)) # 34\nprint(x_or_y(15, 8, 5)) # 5"}
{"task_id": "HumanEval/151", "completion": "def double_the_difference(lst):\n if not lst:\n return 0\n else:\n return sum([x**2 for x in lst if x > 0 and x % 2 == 1])"}
{"task_id": "HumanEval/152", "completion": "def compare(game, guess):\n result = []\n for i in range(len(game)):\n result.append(abs(game[i] - guess[i]))\n return result\n\nprint(compare([1, 2, 3, 4, 5, 1], [1, 2, 3, 4, 2, -2]))\nprint(compare([0, 5, 0, 0, 0, 4], [4, 1, 1, 0, 0, -2]))"}
{"task_id": "HumanEval/153", "completion": "def Strongest_Extension(class_name, extensions):\n def strength(extension):\n CAP = sum(1 for c in extension if c.isupper())\n SM = sum(1 for c in extension if c.islower())\n return CAP - SM\n\n strongest_extension = max(extensions, key=strength)\n return f\"{class_name}.{strongest_extension}\"\n\nprint(Strongest_Extension('my_class', ['AA', 'Be', 'CC']))\nprint(Strongest_Extension('Slices', ['SErviNGSliCes', 'Cheese', 'StuFfed']))"}
{"task_id": "HumanEval/154", "completion": "def cycpattern_check(a , b):\n for i in range(len(b)):\n if b in a:\n return True\n b = b[1:] + b[0]\n return False\n\nprint(cycpattern_check(\"abcd\",\"abd\")) # False\nprint(cycpattern_check(\"hello\",\"ell\")) # True\nprint(cycpattern_check(\"whassup\",\"psus\")) # False\nprint(cycpattern_check(\"abab\",\"baa\")) # True\nprint(cycpattern_check(\"efef\",\"eeff\")) # False\nprint(cycpattern_check(\"himenss\",\"simen\")) # True"}
{"task_id": "HumanEval/155", "completion": " num = abs(num)\n even_count = 0\n odd_count = 0\n for digit in str(num):\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": "val = [\n 1000, 900, 500, 400,\n 100, 90, 50, 40,\n 10, 9, 5, 4,\n 1\n ]\nsyb = [\n \"m\", \"cm\", \"d\", \"cd\",\n \"c\", \"xc\", \"l\", \"xl\",\n \"x\", \"ix\", \"v\", \"iv\",\n \"i\"\n ]\nroman_num = ''\ni = 0\nwhile number > 0:\n for _ in range(number // val[i]):\n roman_num += syb[i]\n number -= val[i]\n i += 1\nreturn roman_num"}
{"task_id": "HumanEval/157", "completion": " sides = sorted([a, b, c])\n return sides[0] ** 2 + sides[1] ** 2 == sides[2] ** 2"}
{"task_id": "HumanEval/158", "completion": "def find_max(words):\n max_unique_chars = 0\n max_word = \"\"\n for word in words:\n unique_chars = len(set(word))\n if unique_chars > max_unique_chars:\n max_unique_chars = unique_chars\n max_word = word\n elif unique_chars == max_unique_chars:\n if word < max_word:\n max_word = word\n return max_word\n\nprint(find_max([\"name\", \"of\", \"string\"])) # \"string\"\nprint(find_max([\"name\", \"enam\", \"game\"])) # \"enam\"\nprint(find_max([\"aaaaaaa\", \"bb\", \"cc\"])) # \"aaaaaaa\"\nprint(find_max([\"abc\", \"def\", \"ghi\"])) # \"abc\"\nprint(find_max([\"xyz\", \"yxz\", \"zxy\"])) # \"xyz\""}
{"task_id": "HumanEval/159", "completion": "def eat(number, need, remaining):\n if remaining >= need:\n return [number + need, remaining - need]\n else:\n return [number + remaining, 0]"}
{"task_id": "HumanEval/160", "completion": "def do_algebra(operator, operand):\n expression = \"\"\n for i in range(len(operator)):\n expression += str(operand[i]) + operator[i]\n expression += str(operand[-1])\n return eval(expression)\n\n# Test cases\nprint(do_algebra(['+', '*', '-'], [2, 3, 4, 5])) # 9\nprint(do_algebra(['*', '+', '//'], [6, 2, 4, 2])) # 16\nprint(do_algebra(['**', '*', '+'], [2, 3, 2, 1])) # 13\nprint(do_algebra(['-', '+', '*'], [10, 5, 3, 2])) # 11\nprint(do_algebra(['//', '*', '+'], [8, 2, 3, 1])) # 13"}
{"task_id": "HumanEval/161", "completion": "def solve(s):\n if not any(c.isalpha() for c in s):\n return s[::-1]\n else:\n return ''.join(c.lower() if c.isupper() else c.upper() for c in s)"}
{"task_id": "HumanEval/162", "completion": "import hashlib\n\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()\n\n# Test cases\nprint(string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62')\nprint(string_to_md5('') == None)"}
{"task_id": "HumanEval/163", "completion": " if a > b:\n a, b = b, a\n even_digits = []\n for i in range(a, b + 1):\n if i % 2 == 0:\n even_digits.append(i)\n return even_digits\n\nprint(generate_integers(2, 8))\nprint(generate_integers(8, 2))\nprint(generate_integers(10, 14))"}