-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlarge70-completion.jsonl_results.jsonl
75 lines (75 loc) · 52.6 KB
/
large70-completion.jsonl_results.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
{"task_id": "HumanEval/0", "completion": "from typing import List\n\ndef has_close_elements(numbers: List[float], threshold: float) -> bool:\n \"\"\"\n Check if in given list of numbers, are any two numbers closer to each other than\n given threshold.\n >>> has_close_elements([1.0, 2.0, 3.0], 0.5)\n False\n >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)\n True\n \"\"\"\n 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", "result": "passed", "passed": true}
{"task_id": "HumanEval/29", "completion": "from typing import List\n\n\ndef filter_by_prefix(strings: List[str], prefix: str) -> List[str]:\n \"\"\" Filter an input list of strings only for ones that start with a given prefix.\n \n Args:\n strings (List[str]): The list of strings to filter.\n prefix (str): The prefix to match against.\n\n Returns:\n List[str]: A new list containing only the strings that start with the given prefix.\n\n Examples:\n >>> filter_by_prefix([], 'a') \n []\n >>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a')\n ['abc', 'array']\n \"\"\"\n return [s for s in strings if s.startswith(prefix)]", "result": "passed", "passed": true}
{"task_id": "HumanEval/39", "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 fib_generator():\n a, b = 0, 1\n while True:\n yield b\n a, b = b, a + b\n\ndef prime_fib(n: int) -> int:\n \"\"\"\n prime_fib returns n-th number that is a Fibonacci number and it's also prime.\n >>> prime_fib(1)\n 2\n >>> prime_fib(2)\n 3\n >>> prime_fib(3)\n 5\n >>> prime_fib(4)\n 13\n >>> prime_fib(5)\n 89\n \"\"\"\n count = 0\n for fib in fib_generator():\n if is_prime(fib):\n count += 1\n if count == n:\n return fib", "result": "passed", "passed": true}
{"task_id": "HumanEval/68", "completion": "def pluck(arr: list) -> list:\n \"\"\"\n Finds and returns the node with the smallest even value from the array.\n If multiple nodes have the same smallest even value, returns the one with the smallest index.\n Returns an empty list if no even values are found, or the array is empty.\n\n >>> pluck([4,2,3])\n [2, 1]\n >>> pluck([1,2,3])\n [2, 1]\n >>> pluck([])\n []\n >>> pluck([5, 0, 3, 0, 4, 2])\n [0, 1]\n \"\"\"\n if not arr:\n return []\n \n min_even_val = float('inf')\n min_even_idx = -1\n \n for i, num in enumerate(arr):\n if num % 2 == 0 and num < min_even_val:\n min_even_val = num\n min_even_idx = i\n \n if min_even_idx == -1:\n return []\n else:\n return [min_even_val, min_even_idx]", "result": "passed", "passed": true}
{"task_id": "HumanEval/4", "completion": "from typing import List\n\ndef mean_absolute_deviation(numbers: List[float]) -> float:\n \"\"\"\n For a given list of input numbers, calculate Mean Absolute Deviation\n around the mean of this dataset.\n Mean Absolute Deviation is the average absolute difference between each\n element and a centerpoint (mean in this case):\n MAD = average | x - x_mean |\n >>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])\n 1.0\n \"\"\"\n if not numbers:\n return 0.0\n \n mean = sum(numbers) / len(numbers)\n absolute_deviations = [abs(x - mean) for x in numbers]\n return sum(absolute_deviations) / len(numbers)", "result": "passed", "passed": true}
{"task_id": "HumanEval/48", "completion": "def is_palindrome(text: str) -> bool:\n \"\"\"\n Checks if given string is a palindrome\n \n A palindrome is a string that reads the same forward and backward.\n This function compares the original string to its reverse and returns \n True if they are equal, False otherwise.\n\n Parameters:\n text (str): The input string to check \n\n Returns:\n bool: True if the string is a palindrome, False otherwise\n\n Examples:\n >>> is_palindrome('')\n True\n >>> is_palindrome('aba') \n True\n >>> is_palindrome('aaaaa')\n True\n >>> is_palindrome('zbcd')\n False\n \"\"\"\n # Compare the original string to its reverse \n return text == text[::-1]", "result": "passed", "passed": true}
{"task_id": "HumanEval/19", "completion": "from typing import List\n\n\ndef sort_numbers(numbers: str) -> str:\n \"\"\" Input is a space-delimited string of numerals from 'zero' to 'nine'.\n Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.\n Return the string with numbers sorted from smallest to largest\n >>> sort_numbers('three one five')\n 'one three five'\n \"\"\"\n num_dict = {'zero':0, 'one':1, 'two':2, 'three':3, 'four':4, 'five':5, 'six':6, 'seven':7, 'eight':8, 'nine':9}\n num_list = numbers.split()\n num_list.sort(key=lambda x: num_dict[x])\n return ' '.join(num_list)\n\n\nif __name__ == '__main__':\n import doctest\n doctest.testmod()", "result": "passed", "passed": true}
{"task_id": "HumanEval/58", "completion": "def common(l1: list, l2: list) -> list:\n \"\"\"Return sorted unique common elements for two lists.\n \n Args:\n l1 (list): First input list.\n l2 (list): Second input list.\n \n Returns:\n list: Sorted list of unique common elements.\n \n Examples:\n >>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])\n [1, 5, 653]\n >>> common([5, 3, 2, 8], [3, 2]) \n [2, 3]\n \"\"\"\n # Find the intersection of two lists using set intersection\n common_elements = list(set(l1) & set(l2))\n \n # Return the sorted list of common elements\n return sorted(common_elements)\n\n\nif __name__ == \"__main__\":\n # Run doctest\n import doctest\n doctest.testmod()", "result": "passed", "passed": true}
{"task_id": "HumanEval/5", "completion": "from typing import List\n\ndef intersperse(numbers: List[int], delimeter: int) -> List[int]:\n \"\"\"\n Insert a number 'delimeter' between every two consecutive elements of input list `numbers'\n >>> intersperse([], 4)\n []\n >>> intersperse([1, 2, 3], 4)\n [1, 4, 2, 4, 3]\n \"\"\"\n if not numbers:\n return []\n\n interspersed = [numbers[0]]\n for number in numbers[1:]:\n interspersed.append(delimeter)\n interspersed.append(number)\n return interspersed", "result": "passed", "passed": true}
{"task_id": "HumanEval/49", "completion": "def modp(n: int, p: int) -> int:\n \"\"\"Return 2^n modulo p (be aware of numerics).\n >>> modp(3, 5)\n 3\n >>> modp(1101, 101) \n 2\n >>> modp(0, 101)\n 1\n >>> modp(3, 11) \n 8\n >>> modp(100, 101)\n 1\n \"\"\"\n result = 1\n base = 2\n while n > 0:\n if n % 2 == 1:\n result = (result * base) % p\n base = (base * base) % p\n n //= 2\n return result", "result": "passed", "passed": true}
{"task_id": "HumanEval/18", "completion": "def how_many_times(string: str, substring: str) -> int:\n \"\"\" Find how many times a given substring can be found in the original string. Count overlapping cases.\n >>> how_many_times('', 'a')\n 0\n >>> how_many_times('aaa', 'a')\n 3\n >>> how_many_times('aaaa', 'aa')\n 3\n >>> how_many_times('abc', 'abc') \n 1\n >>> how_many_times('abaabaca', 'aba')\n 2\n \"\"\"\n count = 0\n start = 0\n while start < len(string):\n pos = string.find(substring, start) \n if pos != -1:\n count += 1\n start = pos + 1\n else:\n break\n return count", "result": "passed", "passed": true}
{"task_id": "HumanEval/59", "completion": "def largest_prime_factor(n: int) -> int:\n \"\"\"Return the largest prime factor of n. Assume n > 1 and is not a prime.\n >>> largest_prime_factor(13195)\n 29\n >>> largest_prime_factor(2048)\n 2\n \"\"\"\n def is_prime(num):\n if num < 2:\n return False\n for i in range(2, int(num**0.5) + 1):\n if num % i == 0:\n return False\n return True\n \n largest_prime = 1\n i = 2\n while i * i <= n:\n while n % i == 0:\n largest_prime = i\n n //= i\n i += 1\n \n if n > 1:\n largest_prime = n\n \n return largest_prime", "result": "passed", "passed": true}
{"task_id": "HumanEval/1", "completion": "from typing import List\n\ndef separate_paren_groups(paren_string: str) -> List[str]:\n \"\"\"\n Input to this function is a string containing multiple groups of nested parentheses. Your goal is to\n separate those group into separate strings and return the list of those.\n Separate groups are balanced (each open brace is properly closed) and not nested within each other\n Ignore any spaces in the input string.\n >>> separate_paren_groups('( ) (( )) (( )( ))')\n ['()', '(())', '(()())']\n \"\"\"\n stack = []\n result = []\n current_group = \"\"\n\n for char in paren_string.replace(\" \", \"\"):\n if char == '(':\n if current_group:\n stack.append(current_group)\n current_group = \"(\"\n elif char == ')':\n current_group += ')'\n if stack:\n prev_group = stack.pop()\n current_group = prev_group + current_group\n else:\n result.append(current_group)\n current_group = \"\"\n \n return result", "result": "passed", "passed": true}
{"task_id": "HumanEval/28", "completion": "from typing import List\n\n\ndef concatenate(strings: List[str]) -> str:\n \"\"\" Concatenate list of strings into a single string\n >>> concatenate([])\n ''\n >>> concatenate(['a', 'b', 'c'])\n 'abc'\n \"\"\"\n result = \"\"\n for s in strings:\n result += s\n return result", "result": "passed", "passed": true}
{"task_id": "HumanEval/38", "completion": "def encode_cyclic(s: str) -> 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) -> str:\n \"\"\"\n takes as input string encoded with encode_cyclic function. Returns decoded string.\n \"\"\"\n # This operation is the inverse of encoding, thus reverse the cycling process\n groups = [s[(3 * i):min((3 * i + 3), len(s))] for i in range((len(s) + 2) // 3)]\n groups = [(group[-1] + group[:-1]) if len(group) == 3 else group for group in groups]\n return \"\".join(groups)", "result": "passed", "passed": true}
{"task_id": "HumanEval/69", "completion": "def search(lst: list) -> int:\n '''\n Finds the greatest integer in the list whose frequency is greater than or equal to the value itself.\n\n Args:\n lst (list): A non-empty list of positive integers.\n\n Returns:\n int: The greatest integer meeting the criteria, or -1 if no such integer exists.\n\n Examples:\n >>> search([4, 1, 2, 2, 3, 1])\n 2\n >>> search([1, 2, 2, 3, 3, 3, 4, 4, 4])\n 3\n >>> search([5, 5, 4, 4, 4])\n -1\n '''\n counts = {}\n for num in lst:\n counts[num] = counts.get(num, 0) + 1\n \n candidates = [num for num, freq in counts.items() if freq >= num]\n \n if not candidates:\n return -1\n else:\n return max(candidates)", "result": "passed", "passed": true}
{"task_id": "HumanEval/17", "completion": "from typing import List\n\n\ndef parse_music(music_string: str) -> List[int]:\n \"\"\" Input to this function is a string representing musical notes in a special ASCII format.\n Your task is to parse this string and return list of integers corresponding to how many beats does each\n note last.\n\n Here is a legend:\n 'o' - whole note, lasts four beats\n 'o|' - half note, lasts two beats\n '.|' - quarter note, lasts one beat\n\n >>> parse_music('o o| .| o| o| .| .| .| .| o o')\n [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]\n \"\"\"\n notes_dict = {'o': 4, 'o|': 2, '.|': 1}\n notes = music_string.split()\n beats = [notes_dict[note] for note in notes if note in notes_dict]\n return beats", "result": "passed", "passed": true}
{"task_id": "HumanEval/46", "completion": "def fib4(n: int) -> int:\n \"\"\"The Fib4 number sequence is a sequence similar to the Fibonacci sequence that's defined as follows:\n fib4(0) -> 0\n fib4(1) -> 0 \n fib4(2) -> 2\n fib4(3) -> 0\n fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).\n \n This function efficiently computes the n-th element of the fib4 number sequence without using recursion.\n \n Examples:\n >>> fib4(5)\n 4\n >>> fib4(6) \n 8\n >>> fib4(7)\n 14\n \"\"\"\n if n < 0:\n raise ValueError(f'n must be >= 0, got {n}')\n \n # Handle base cases\n if n == 0 or n == 1 or n == 3:\n return 0\n elif n == 2:\n return 2\n \n # Use dynamic programming to compute fib4(n)\n # Store previously computed values to avoid recomputation\n dp = [0] * (n+1)\n dp[2] = 2\n \n for i in range(4, n+1):\n dp[i] = dp[i-1] + dp[i-2] + dp[i-3] + dp[i-4]\n \n return dp[n]", "result": "passed", "passed": true}
{"task_id": "HumanEval/72", "completion": "def will_it_fly(q: list, w: int) -> bool:\n \"\"\"\n Determine if the object q will fly.\n\n An object will fly if it is palindromic (reads the same forward and backward) \n and the sum of its elements does not exceed the maximum weight w.\n\n Args:\n q (list): The object represented as a list of integers.\n w (int): The maximum possible weight.\n\n Returns:\n bool: True if the object will fly, False otherwise.\n\n Examples:\n >>> will_it_fly([1, 2, 1], 5) \n True\n >>> will_it_fly([3, 2, 3], 1)\n False\n >>> will_it_fly([3, 2, 3], 9) \n True\n >>> will_it_fly([3], 5)\n True\n >>> will_it_fly([1, 2, 3], 6)\n False\n \"\"\"\n # Check if q is palindromic\n if q != q[::-1]:\n return False\n \n # Check if the sum of elements in q is within the weight limit w\n if sum(q) > w:\n return False\n\n # If both conditions are met, the object will fly\n return True", "result": "passed", "passed": true}
{"task_id": "HumanEval/23", "completion": "def strlen(string: str) -> int:\n \"\"\" Return length of given string\n >>> strlen('')\n 0\n >>> strlen('abc') \n 3\n \"\"\"\n length = 0\n for char in string:\n length += 1\n return length", "result": "passed", "passed": true}
{"task_id": "HumanEval/33", "completion": "def sort_third(l: list) -> list:\n \"\"\"This function takes a list l and returns a list l' such that\n l' is identical to l in the indices that are not divisible by three, while its values at the indices that are divisible by three are equal\n to the values of the corresponding indices of l, but sorted.\n >>> sort_third([1, 2, 3])\n [1, 2, 3]\n >>> sort_third([5, 6, 3, 4, 8, 9, 2])\n [2, 6, 3, 4, 8, 9, 5]\n \"\"\"\n # Create a new list to store the result\n result = l[:]\n \n # Extract elements at indices divisible by 3 into a separate list\n div_by_three = [l[i] for i in range(0, len(l), 3)]\n \n # Sort the list containing elements at indices divisible by 3\n div_by_three.sort()\n \n # Merge the sorted sublist back into the result list\n result[::3] = div_by_three\n \n return result", "result": "passed", "passed": true}
{"task_id": "HumanEval/62", "completion": "def derivative(xs: list) -> list:\n \"\"\" xs represent coefficients of a polynomial.\n xs[0] + xs[1] * x + xs[2] * x^2 + ....\n Return derivative of this polynomial in the same form.\n >>> derivative([3, 1, 2, 4, 5])\n [1, 4, 12, 20]\n >>> derivative([1, 2, 3])\n [2, 6]\n \"\"\"\n return [i*x for i, x in enumerate(xs[1:], start=1)]\n\nif __name__ == \"__main__\":\n print(derivative([3, 1, 2, 4, 5]))\n print(derivative([1, 2, 3]))", "result": "passed", "passed": true}
{"task_id": "HumanEval/56", "completion": "def correct_bracketing(brackets: str) -> bool:\n \"\"\" brackets is a string of \"<\" and \">\".\n return True if every opening bracket has a corresponding closing bracket.\n\n >>> correct_bracketing(\"<\")\n False\n >>> correct_bracketing(\"<>\")\n True\n >>> correct_bracketing(\"<<><>>\")\n True\n >>> correct_bracketing(\"><<>\")\n False\n \"\"\"\n count = 0\n for char in brackets:\n if char == '<':\n count += 1\n elif char == '>':\n if count == 0:\n return False\n count -= 1\n return count == 0\n\nif __name__ == '__main__':\n import doctest\n doctest.testmod()", "result": "passed", "passed": true}
{"task_id": "HumanEval/27", "completion": "def flip_case(string: str) -> str:\n \"\"\" For a given string, flip lowercase characters to uppercase and uppercase to lowercase.\n >>> flip_case('Hello') \n 'hELLO'\n >>> flip_case('wORLD')\n 'World'\n >>> flip_case('12345')\n '12345'\n >>> flip_case('')\n ''\n \"\"\"\n flipped = []\n for char in string:\n if char.islower():\n flipped.append(char.upper())\n elif char.isupper():\n flipped.append(char.lower())\n else:\n flipped.append(char)\n \n return ''.join(flipped)\n\nif __name__ == '__main__':\n import doctest\n doctest.testmod()", "result": "passed", "passed": true}
{"task_id": "HumanEval/42", "completion": "def incr_list(l: list) -> list:\n \"\"\"Return list with elements incremented by 1.\n \n >>> incr_list([1, 2, 3]) \n [2, 3, 4]\n >>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123])\n [6, 4, 6, 3, 4, 4, 10, 1, 124]\n \"\"\"\n return [x + 1 for x in l]", "result": "passed", "passed": true}
{"task_id": "HumanEval/13", "completion": "def greatest_common_divisor(a: int, b: int) -> int:\n \"\"\"\n Return a greatest common divisor of two integers a and b\n >>> greatest_common_divisor(3, 5)\n 1\n >>> greatest_common_divisor(25, 15)\n 5\n \"\"\"\n while b:\n a, b = b, a % b\n return a", "result": "passed", "passed": true}
{"task_id": "HumanEval/52", "completion": "def below_threshold(l: list, t: int) -> bool:\n \"\"\"Return True if all numbers in the list l are below threshold t.\n \n >>> below_threshold([1, 2, 4, 10], 100)\n True\n >>> below_threshold([1, 20, 4, 10], 5)\n False\n \"\"\"\n for x in l:\n if x >= t:\n return False\n return True", "result": "passed", "passed": true}
{"task_id": "HumanEval/66", "completion": "def digitSum(s: str) -> int:\n \"\"\"\n Computes the sum of the ASCII codes of uppercase characters in the given string.\n\n Args:\n s (str): The input string.\n\n Returns:\n int: The sum of ASCII codes of uppercase characters in s.\n \n Examples:\n digitSum(\"\") => 0\n digitSum(\"abAB\") => 131\n digitSum(\"abcCd\") => 67\n digitSum(\"helloE\") => 69\n digitSum(\"woArBld\") => 131\n digitSum(\"aAaaaXa\") => 153\n \"\"\"\n uppercase_sum = 0\n for char in s:\n if char.isupper():\n uppercase_sum += ord(char)\n return uppercase_sum", "result": "passed", "passed": true}
{"task_id": "HumanEval/37", "completion": "def sort_even(l: list) -> list:\n \"\"\"This function takes a list l and returns a list l' such that\n l' is identical to l in the odd indices, while its values at the even indices are equal \n to the values of the even indices of l, but sorted.\n >>> sort_even([1, 2, 3, 4, 5])\n [1, 2, 3, 4, 5]\n >>> sort_even([5, 6, 3, 4, 1, 2])\n [1, 6, 3, 4, 5, 2]\n \"\"\"\n even_elems = sorted(l[::2])\n odd_elems = l[1::2]\n \n result = [None]*(len(even_elems)+len(odd_elems))\n result[::2] = even_elems\n result[1::2] = odd_elems\n \n return result", "result": "passed", "passed": true}
{"task_id": "HumanEval/26", "completion": "from typing import List\n\n\ndef remove_duplicates(numbers: List[int]) -> List[int]:\n \"\"\" From a list of integers, remove all elements that occur more than once.\n Keep order of elements left the same as in the input.\n >>> remove_duplicates([1, 2, 3, 2, 4])\n [1, 3, 4]\n \"\"\"\n result = []\n seen = set()\n for i in numbers:\n if i not in seen:\n if numbers.count(i) == 1:\n result.append(i)\n seen.add(i)\n return result", "result": "passed", "passed": true}
{"task_id": "HumanEval/43", "completion": "def pairs_sum_to_zero(l: list) -> bool:\n \"\"\"\n pairs_sum_to_zero takes a list of integers as an input.\n it returns True if there are two distinct elements in the list that \n sum to zero, and False otherwise.\n >>> pairs_sum_to_zero([1, 3, 5, 0])\n False\n >>> pairs_sum_to_zero([1, 3, -2, 1])\n False\n >>> pairs_sum_to_zero([1, 2, 3, 7]) \n False\n >>> pairs_sum_to_zero([2, 4, -5, 3, 5, 7])\n True\n >>> pairs_sum_to_zero([1])\n False\n >>> pairs_sum_to_zero([2, 4, -2, 3, 5, 7])\n True\n \"\"\"\n s = set()\n for item in l:\n if -item in s:\n return True\n if item != 0:\n s.add(item)\n return False", "result": "passed", "passed": true}
{"task_id": "HumanEval/12", "completion": "from typing import List, Optional\n\ndef longest(strings: List[str]) -> Optional[str]:\n \"\"\"\n Out of list of strings, return the longest one. Return the first one in case of multiple\n strings of the same length. Return None in case the input list is empty.\n >>> longest([])\n None\n >>> longest(['a', 'b', 'c'])\n 'a'\n >>> longest(['a', 'bb', 'ccc'])\n 'ccc'\n \"\"\"\n if not strings:\n return None\n \n longest_string = strings[0]\n max_length = len(longest_string)\n \n for string in strings[1:]:\n if len(string) > max_length:\n longest_string = string\n max_length = len(string)\n \n return longest_string", "result": "passed", "passed": true}
{"task_id": "HumanEval/53", "completion": "def add(x: int, y: int) -> int:\n \"\"\"Add two numbers x and y\n >>> add(2, 3)\n 5\n >>> add(5, 7)\n 12\n \"\"\"\n return x + y", "result": "passed", "passed": true}
{"task_id": "HumanEval/67", "completion": "def fruit_distribution(fruits_string: str, total_fruits: int) -> int:\n \"\"\"\n Calculates the number of mango fruits in a basket given the total \n number of fruits and the number of apples and oranges.\n \n Args:\n fruits_string (str): A string expressing the number of apples and oranges, \n e.g. \"3 apples and 5 oranges\".\n total_fruits (int): The total number of fruits in the basket.\n \n Returns:\n int: The number of mango fruits in the basket.\n \n Example:\n >>> fruit_distribution(\"5 apples and 6 oranges\", 19)\n 8\n >>> fruit_distribution(\"0 apples and 1 orange\", 3)\n 2\n >>> fruit_distribution(\"2 apples and 3 oranges\", 100)\n 95\n \"\"\"\n # Extract the number of apples and oranges from the string\n fruit_counts = [int(s) for s in fruits_string.split() if s.isdigit()]\n \n # Sum up the number of apples and oranges\n apples_oranges_total = sum(fruit_counts)\n \n # Subtract from the total to get the number of mangoes\n mango_count = total_fruits - apples_oranges_total\n \n return mango_count", "result": "passed", "passed": true}
{"task_id": "HumanEval/36", "completion": "def fizz_buzz(n: int) -> int:\n \"\"\"Return the number of times the digit '7' appears in integers less than n which are divisible by 11 or 13.\n >>> fizz_buzz(50)\n 0\n >>> fizz_buzz(78)\n 2\n >>> fizz_buzz(79)\n 3\n \"\"\"\n 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", "result": "passed", "passed": true}
{"task_id": "HumanEval/16", "completion": "def count_distinct_characters(string: str) -> int:\n \"\"\" Given a string, find out how many distinct characters (regardless of case) does it consist of\n >>> count_distinct_characters('xyzXYZ')\n 3\n >>> count_distinct_characters('Jerry')\n 4\n \"\"\"\n # Using set to remove duplicates and lower() to ignore case\n return len(set(string.lower()))", "result": "passed", "passed": true}
{"task_id": "HumanEval/47", "completion": "def median(l: list) -> float:\n \"\"\"Return median of elements in the list l.\n >>> median([3, 1, 2, 4, 5])\n 3\n >>> median([-10, 4, 6, 1000, 10, 20])\n 8.0\n >>> median([1, 2, 3, 4])\n 2.5\n \"\"\"\n l_sorted = sorted(l)\n mid = len(l) // 2\n if len(l) % 2 == 0:\n return (l_sorted[mid - 1] + l_sorted[mid]) / 2\n else:\n return l_sorted[mid]", "result": "passed", "passed": true}
{"task_id": "HumanEval/73", "completion": "def smallest_change(arr):\n \"\"\"\n Given an array arr of integers, find the minimum number of elements that\n need to be changed to make the array palindromic. A palindromic array is an array that\n is read the same backwards and forwards. In one change, you can change one element to any other element.\n\n For example:\n smallest_change([1,2,3,5,4,7,9,6]) == 4\n smallest_change([1, 2, 3, 4, 3, 2, 2]) == 1\n smallest_change([1, 2, 3, 2, 1]) == 0\n \"\"\"\n\n left = 0\n right = len(arr) - 1\n changes = 0\n\n while left < right:\n if arr[left] != arr[right]:\n changes += 1\n left += 1\n right -= 1\n\n return changes\n\n# Doctests\nassert smallest_change([1,2,3,5,4,7,9,6]) == 4\nassert smallest_change([1, 2, 3, 4, 3, 2, 2]) == 1\nassert smallest_change([1, 2, 3, 2, 1]) == 0", "result": "passed", "passed": true}
{"task_id": "HumanEval/22", "completion": "from typing import List, Any\n\n\ndef filter_integers(values: List[Any]) -> List[int]:\n \"\"\" Filter given list of any python values only for integers\n >>> filter_integers(['a', 3.14, 5])\n [5]\n >>> filter_integers([1, 2, 3, 'abc', {}, []])\n [1, 2, 3]\n \"\"\"\n return [value for value in values if isinstance(value, int)]", "result": "passed", "passed": true}
{"task_id": "HumanEval/32", "completion": "import math\n\ndef poly(xs: list, x: float) -> float:\n \"\"\"\n Evaluates polynomial with coefficients xs at point x.\n return xs[0] + xs[1] * x + xs[2] * 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) -> float:\n \"\"\" \n xs are coefficients of a polynomial.\n find_zero finds x such that poly(xs, x) = 0.\n find_zero returns only one zero point, even if there are many.\n Moreover, find_zero only takes list xs having even number of coefficients\n and largest non-zero coefficient as it guarantees a solution.\n \n >>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x \n -0.5\n >>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3\n 1.0\n \"\"\"\n a, b = -1e9, 1e9\n fa, fb = poly(xs, a), poly(xs, b)\n \n while (b-a) > 1e-9:\n m = (a+b)/2\n fm = poly(xs, m)\n \n if fm == 0:\n return m\n if fa*fm < 0:\n b, fb = m, fm\n else:\n a, fa = m, fm\n \n return (a+b)/2", "result": "passed", "passed": true}
{"task_id": "HumanEval/63", "completion": "def fibfib(n: int) -> int:\n \"\"\"The FibFib number sequence is a sequence similar to the Fibonacci sequence that's defined as follows:\n fibfib(0) == 0\n fibfib(1) == 0 \n fibfib(2) == 1\n fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).\n Please write a function to efficiently compute the n-th element of the fibfib number sequence.\n >>> fibfib(0)\n 0\n >>> fibfib(1) \n 0\n >>> fibfib(2)\n 1\n >>> fibfib(5)\n 4\n >>> fibfib(8)\n 24\n \"\"\"\n if n < 0:\n raise ValueError(\"n must be a non-negative integer\")\n if n == 0 or n == 1: \n return 0\n if n == 2:\n return 1\n \n # Initialize first three FibFib numbers\n fibfib_nums = [0, 0, 1] \n \n # Compute remaining FibFib numbers up to n\n for i in range(3, n+1):\n next_fibfib = fibfib_nums[i-1] + fibfib_nums[i-2] + fibfib_nums[i-3]\n fibfib_nums.append(next_fibfib)\n\n return fibfib_nums[n]", "result": "passed", "passed": true}
{"task_id": "HumanEval/57", "completion": "def monotonic(l: list) -> bool:\n \"\"\"Return True if list elements are monotonically increasing or decreasing.\n >>> monotonic([1, 2, 4, 20])\n True\n >>> monotonic([1, 20, 4, 10]) \n False\n >>> monotonic([4, 1, 0, -10])\n True\n \"\"\"\n increasing = all(l[i] <= l[i+1] for i in range(len(l)-1)) \n decreasing = all(l[i] >= l[i+1] for i in range(len(l)-1))\n return increasing or decreasing", "result": "passed", "passed": true}
{"task_id": "HumanEval/74", "completion": "def total_match(lst1, lst2):\n '''\n Write a function that accepts two lists of strings and returns the list that has \n total number of chars in the all strings of the list less than the other list.\n\n if the two lists have the same number of chars, return the first list.\n\n Examples\n >>> total_match([], [])\n []\n >>> total_match(['hi', 'admin'], ['hI', 'Hi'])\n ['hI', 'Hi']\n >>> total_match(['hi', 'admin'], ['hi', 'hi', 'admin', 'project'])\n ['hi', 'admin']\n >>> total_match(['hi', 'admin'], ['hI', 'hi', 'hi'])\n ['hI', 'hi', 'hi']\n >>> total_match(['4'], ['1', '2', '3', '4', '5'])\n ['4']\n '''\n total1 = sum(len(s) for s in lst1)\n total2 = sum(len(s) for s in lst2)\n \n if total1 < total2:\n return lst1\n elif total2 < total1:\n return lst2\n else:\n return lst1\n", "result": "passed", "passed": true}
{"task_id": "HumanEval/25", "completion": "from typing import List\n\n\ndef factorize(n: int) -> List[int]:\n \"\"\" Return list of prime factors of given integer in the order from smallest to largest.\n Each of the factors should be listed number of times corresponding to how many times it appears in factorization.\n Input number should be equal to the product of all factors\n >>> factorize(8)\n [2, 2, 2]\n >>> factorize(25)\n [5, 5]\n >>> factorize(70)\n [2, 5, 7]\n \"\"\"\n factors = []\n divisor = 2\n while n > 1:\n while n % divisor == 0:\n factors.append(divisor)\n n //= divisor\n divisor += 1\n return factors", "result": "passed", "passed": true}
{"task_id": "HumanEval/11", "completion": "from typing import List\n\ndef string_xor(a: str, b: str) -> str:\n \"\"\"\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 \n a and b will be of the same length.\n\n >>> string_xor('010', '110')\n '100'\n >>> string_xor('1010101', '0101010')\n '1111111'\n >>> string_xor('1111111', '1111111')\n '0000000'\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", "result": "passed", "passed": true}
{"task_id": "HumanEval/40", "completion": "def triples_sum_to_zero(l: list) -> bool:\n \"\"\"\n triples_sum_to_zero takes a list of integers as an input.\n it returns True if there are three distinct elements in the list that \n sum to zero, and False otherwise.\n\n >>> triples_sum_to_zero([1, 3, 5, 0])\n False\n >>> triples_sum_to_zero([1, 3, -2, 1])\n True\n >>> triples_sum_to_zero([1, 2, 3, 7])\n False\n >>> triples_sum_to_zero([2, 4, -5, 3, 9, 7])\n True\n >>> triples_sum_to_zero([1])\n False\n \"\"\"\n l.sort()\n for i in range(len(l)-2):\n a = l[i]\n start = i+1\n end = len(l)-1\n while start < end:\n b = l[start]\n c = l[end]\n if a + b + c == 0:\n return True\n elif a + b + c < 0:\n start += 1\n else:\n end -= 1\n return False", "result": "passed", "passed": true}
{"task_id": "HumanEval/50", "completion": "def encode_shift(s: str) -> str:\n \"\"\"\n returns encoded string by shifting every character by 5 in the alphabet.\n \"\"\"\n encoded = \"\"\n for ch in s:\n if ch.isalpha():\n if ch.isupper():\n encoded += chr(((ord(ch) + 5 - ord('A')) % 26) + ord('A'))\n else:\n encoded += chr(((ord(ch) + 5 - ord('a')) % 26) + ord('a'))\n else:\n encoded += ch\n return encoded\n\n\ndef decode_shift(s: str) -> str:\n \"\"\"\n takes as input string encoded with encode_shift function. Returns decoded string.\n \"\"\"\n decoded = \"\"\n for ch in s:\n if ch.isalpha():\n if ch.isupper():\n decoded += chr(((ord(ch) - 5 - ord('A')) % 26) + ord('A'))\n else:\n decoded += chr(((ord(ch) - 5 - ord('a')) % 26) + ord('a'))\n else:\n decoded += ch\n return decoded", "result": "passed", "passed": true}
{"task_id": "HumanEval/35", "completion": "def max_element(l: list) -> int:\n \"\"\"Return maximum element in the list.\n \n Args:\n l (list): Input list\n \n Returns:\n int: Maximum element in the list\n \n Examples:\n >>> max_element([1, 2, 3]) \n 3\n >>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])\n 123\n \"\"\"\n if not l:\n raise ValueError(\"max_element() arg is an empty list\")\n \n max_val = l[0] # initialize max to first element\n for x in l:\n if x > max_val:\n max_val = x\n return max_val", "result": "passed", "passed": true}
{"task_id": "HumanEval/64", "completion": "def vowels_count(s: str) -> int:\n \"\"\"Write a function vowels_count which takes a string representing\n a word as input and returns the number of vowels in the string.\n Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a\n vowel, but only when it is at the end of the given word.\n\n Example:\n >>> vowels_count(\"abcde\")\n 2\n >>> vowels_count(\"ACEDY\")\n 3\n \"\"\"\n s = s.lower()\n vowels = 'aeiou'\n count = sum(char in vowels for char in s[:-1])\n if s and (s[-1] in vowels + 'y'):\n count += 1\n return count", "result": "passed", "passed": true}
{"task_id": "HumanEval/44", "completion": "def change_base(x: int, base: int) -> str:\n \"\"\"Change numerical base of input number x to base.\n return string representation after the conversion.\n base numbers are less than 10.\n >>> change_base(8, 3)\n '22'\n >>> change_base(8, 2)\n '1000'\n >>> change_base(7, 2)\n '111'\n >>> change_base(0, 2)\n '0'\n >>> change_base(0, 3)\n '0'\n \"\"\"\n if x == 0:\n return '0'\n \n if base < 2 or base >= 10:\n raise ValueError(f\"Invalid base: {base}. Base must be between 2 and 9.\")\n \n digits = []\n while x > 0:\n digits.append(str(x % base))\n x //= base\n \n return ''.join(reversed(digits))", "result": "passed", "passed": true}
{"task_id": "HumanEval/15", "completion": "def string_sequence(n: int) -> str:\n \"\"\"\n Return a string containing space-delimited numbers starting from 0 up to n inclusive.\n >>> string_sequence(0)\n '0'\n >>> string_sequence(5)\n '0 1 2 3 4 5'\n \"\"\"\n return ' '.join(str(i) for i in range(n + 1))", "result": "passed", "passed": true}
{"task_id": "HumanEval/8", "completion": "from typing import List, Tuple\n\ndef sum_product(numbers: List[int]) -> Tuple[int, int]:\n \"\"\"\n For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list.\n Empty sum should be equal to 0 and empty product should be equal to 1.\n >>> sum_product([])\n (0, 1)\n >>> sum_product([1, 2, 3, 4])\n (10, 24)\n \"\"\"\n if not numbers:\n return (0, 1)\n\n sum_numbers = sum(numbers)\n product_numbers = 1\n for number in numbers:\n product_numbers *= number\n\n return (sum_numbers, product_numbers)", "result": "passed", "passed": true}
{"task_id": "HumanEval/21", "completion": "from typing import List\n\n\ndef rescale_to_unit(numbers: List[float]) -> List[float]:\n \"\"\" Given list of numbers (of at least two elements), apply a linear transform to that list,\n such that the smallest number will become 0 and the largest will become 1\n >>> rescale_to_unit([1.0, 2.0, 3.0, 4.0, 5.0])\n [0.0, 0.25, 0.5, 0.75, 1.0]\n \"\"\"\n if len(numbers) < 2:\n raise ValueError('List must contain at least two numbers')\n \n a = min(numbers)\n b = max(numbers)\n \n return [(x - a) / (b - a) for x in numbers]", "result": "passed", "passed": true}
{"task_id": "HumanEval/70", "completion": "def strange_sort_list(lst: list) -> list:\n '''\n Given list of integers, return list in strange order.\n Strange sorting, is when you start with the minimum value,\n then maximum of the remaining integers, then minimum and so on.\n\n Examples:\n strange_sort_list([1, 2, 3, 4]) == [1, 4, 2, 3]\n strange_sort_list([5, 5, 5, 5]) == [5, 5, 5, 5]\n strange_sort_list([]) == []\n '''\n if not lst:\n return []\n \n sorted_lst = sorted(lst)\n result = []\n left = 0\n right = len(sorted_lst) - 1\n \n while left <= right:\n if left == right:\n result.append(sorted_lst[left])\n else:\n result.append(sorted_lst[left])\n result.append(sorted_lst[right])\n left += 1\n right -= 1\n \n return result", "result": "passed", "passed": true}
{"task_id": "HumanEval/60", "completion": "def sum_to_n(n: int) -> int:\n \"\"\"\n Computes the sum of numbers from 1 to n.\n \n Args:\n n (int): The number to sum up to.\n \n Returns:\n int: The sum of numbers from 1 to n.\n\n Examples:\n >>> sum_to_n(5) \n 15\n >>> sum_to_n(10)\n 55\n >>> sum_to_n(100)\n 5050\n \"\"\"\n return sum(range(1, n+1))\n\n\nif __name__ == '__main__':\n import doctest\n doctest.testmod()", "result": "passed", "passed": true}
{"task_id": "HumanEval/31", "completion": "def is_prime(n: int) -> bool:\n \"\"\"Return true if a given number is prime, and false otherwise.\n >>> is_prime(6)\n False\n >>> is_prime(101) \n True\n >>> is_prime(11)\n True\n >>> is_prime(13441)\n True\n >>> is_prime(61)\n True\n >>> is_prime(4)\n False\n >>> is_prime(1)\n False\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True", "result": "passed", "passed": true}
{"task_id": "HumanEval/54", "completion": "def same_chars(s0: str, s1: str) -> bool:\n \"\"\"\n Check if two strings contain the same set of unique characters.\n \n Args:\n s0 (str): The first string to compare.\n s1 (str): The second string to compare.\n \n Returns:\n bool: True if s0 and s1 contain the same set of characters, False otherwise.\n \n Examples:\n >>> same_chars('eabcdzzzz', 'dddzzzzzzzddeddabc')\n True\n >>> same_chars('abcd', 'dddddddabc') \n True\n >>> same_chars('dddddddabc', 'abcd')\n True\n >>> same_chars('eabcd', 'dddddddabc')\n False\n >>> same_chars('abcd', 'dddddddabce') \n False\n >>> same_chars('eabcdzzzz', 'dddzzzzzzzddddabc')\n False\n \"\"\"\n # Convert strings to sets to get unique characters \n set0 = set(s0)\n set1 = set(s1)\n \n # Check if the sets are equal\n return set0 == set1", "result": "passed", "passed": true}
{"task_id": "HumanEval/45", "completion": "def triangle_area(base: float, height: float) -> float:\n \"\"\"\n Calculates the area of a triangle given the length of the base and height.\n \n Args:\n base (float): The length of the base of the triangle\n height (float): The height of the triangle\n \n Returns:\n float: The area of the triangle\n \n Example:\n >>> triangle_area(5, 3) \n 7.5\n \"\"\"\n area = (base * height) / 2\n return area", "result": "passed", "passed": true}
{"task_id": "HumanEval/14", "completion": "from typing import List\n\ndef all_prefixes(string: str) -> List[str]:\n \"\"\" Return list of all prefixes from shortest to longest of the input string\n >>> all_prefixes('abc')\n ['a', 'ab', 'abc']\n \"\"\"\n prefixes = []\n for i in range(len(string)):\n prefixes.append(string[:i+1])\n return prefixes", "result": "passed", "passed": true}
{"task_id": "HumanEval/9", "completion": "from typing import List\n\ndef rolling_max(numbers: List[int]) -> List[int]:\n \"\"\"\n From a given list of integers, generate a list of rolling maximum element found until given moment\n in the sequence.\n >>> rolling_max([1, 2, 3, 2, 3, 4, 2])\n [1, 2, 3, 3, 3, 4, 4]\n \"\"\"\n if not numbers:\n return []\n\n rolling_maxes = [numbers[0]]\n current_max = numbers[0]\n for number in numbers[1:]:\n current_max = max(current_max, number)\n rolling_maxes.append(current_max)\n\n return rolling_maxes", "result": "passed", "passed": true}
{"task_id": "HumanEval/20", "completion": "from typing import List, Tuple\n\n\ndef find_closest_elements(numbers: List[float]) -> Tuple[float, float]:\n \"\"\" From a supplied list of numbers (of length at least two) select and return two that are the closest to each\n other and return them in order (smaller number, larger number).\n >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.2])\n (2.0, 2.2)\n >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.0])\n (2.0, 2.0)\n \"\"\"\n numbers.sort()\n closest_pair = (numbers[0], numbers[1])\n min_diff = abs(numbers[1] - numbers[0])\n for i in range(1, len(numbers) - 1):\n diff = abs(numbers[i + 1] - numbers[i])\n if diff < min_diff:\n min_diff = diff\n closest_pair = (numbers[i], numbers[i + 1])\n return closest_pair", "result": "passed", "passed": true}
{"task_id": "HumanEval/71", "completion": "import math\n\ndef triangle_area(a: float, b: float, c: float) -> float:\n '''\n Calculates the area of a triangle from side lengths using Heron's formula.\n\n Args:\n a (float): Length of side a.\n b (float): Length of side b. \n c (float): Length of side c.\n\n Returns:\n float: Area of the triangle rounded to 2 decimal points, or -1 if invalid.\n\n Examples:\n triangle_area(3, 4, 5) == 6.00\n triangle_area(1, 2, 10) == -1\n '''\n # Check if the sides form a valid triangle\n if (a + b > c) and (a + c > b) and (b + c > a):\n # Calculate semi-perimeter\n s = (a + b + c) / 2\n \n # Calculate area using Heron's formula \n area = math.sqrt(s * (s - a) * (s - b) * (s - c))\n \n return round(area, 2)\n else:\n return -1", "result": "passed", "passed": true}
{"task_id": "HumanEval/61", "completion": "def correct_bracketing(brackets: str) -> bool:\n \"\"\" brackets is a string of \"(\" and \")\".\n return True if every opening bracket has a corresponding closing bracket.\n\n >>> correct_bracketing(\"(\")\n False\n >>> correct_bracketing(\"()\")\n True\n >>> correct_bracketing(\"(()())\")\n True\n >>> correct_bracketing(\")(()\")\n False\n \"\"\"\n stack = []\n for char in brackets:\n if char == '(':\n stack.append(char)\n elif char == ')':\n if not stack:\n return False\n stack.pop()\n \n return len(stack) == 0", "result": "passed", "passed": true}
{"task_id": "HumanEval/30", "completion": "def get_positive(l: list) -> list:\n \"\"\"Return only positive numbers in the list.\n >>> get_positive([-1, 2, -4, 5, 6]) \n [2, 5, 6]\n >>> get_positive([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])\n [5, 3, 2, 3, 9, 123, 1]\n \"\"\"\n return [i for i in l if i > 0]", "result": "passed", "passed": true}
{"task_id": "HumanEval/55", "completion": "def fib(n: int) -> int:\n \"\"\"Return n-th Fibonacci number.\n \n Args:\n n (int): The index of the Fibonacci number to return.\n \n Returns:\n int: The n-th Fibonacci number.\n \n Examples:\n >>> fib(0) \n 0\n >>> fib(1)\n 1\n >>> fib(2)\n 1\n >>> fib(3)\n 2\n >>> fib(10) \n 55\n \"\"\"\n if n < 0:\n raise ValueError(\"n must be a non-negative integer\")\n elif n == 0:\n return 0\n elif n == 1:\n return 1\n else:\n a, b = 0, 1\n for _ in range(2, n+1):\n a, b = b, a + b\n return b", "result": "passed", "passed": true}
{"task_id": "HumanEval/24", "completion": "def largest_divisor(n: int) -> int:\n \"\"\" For a given number n, find the largest number that divides n evenly, smaller than n\n >>> largest_divisor(15)\n 5\n >>> largest_divisor(12) \n 6\n >>> largest_divisor(13)\n 1\n \"\"\"\n for i in range(n//2, 0, -1):\n if n % i == 0:\n return i\n return 1\n\nif __name__ == \"__main__\":\n import doctest\n doctest.testmod()", "result": "passed", "passed": true}
{"task_id": "HumanEval/10", "completion": "def is_palindrome(string: str) -> bool:\n \"\"\"\n Test if given string is a palindrome\n >>> is_palindrome('')\n True\n >>> is_palindrome('aba')\n True\n >>> is_palindrome('Abba')\n False\n \"\"\"\n return string == string[::-1]\n\ndef make_palindrome(string: str) -> str:\n \"\"\" \n Find the shortest palindrome that begins with a supplied string.\n Algorithm idea is simple:\n - Find the longest postfix of supplied string that is a palindrome.\n - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.\n >>> make_palindrome('')\n ''\n >>> make_palindrome('cat')\n 'catac'\n >>> make_palindrome('cata')\n 'catac'\n \"\"\"\n if not string:\n return ''\n \n if is_palindrome(string):\n return string\n else:\n index = 0\n while not is_palindrome(string[index:]):\n index += 1\n return string + string[:index][::-1]", "result": "passed", "passed": true}
{"task_id": "HumanEval/41", "completion": "def car_race_collision(n: int) -> int:\n \"\"\"\n Imagine a road that's a perfectly straight infinitely long line.\n n cars are driving left to right; simultaneously, a different set of n cars\n are driving right to left. The two sets of cars start out being very far from\n each other. All cars move in the same speed. Two cars are said to collide\n when a car that's moving left to right hits a car that's moving right to left.\n However, the cars are infinitely sturdy and strong; as a result, they continue moving\n in their trajectory as if they did not collide.\n\n This function outputs the number of such collisions.\n \"\"\"\n # Since each car from one direction will eventually collide with each car from the opposite direction,\n # the total number of collisions is simply the product of the number of cars in each direction.\n return n * n", "result": "passed", "passed": true}
{"task_id": "HumanEval/51", "completion": "def remove_vowels(s: str) -> str:\n \"\"\"\n Remove all vowels from the input string.\n\n Parameters:\n s (str): The input string from which vowels are to be removed.\n\n Returns:\n str: A string with all vowels removed.\n\n Examples:\n >>> remove_vowels('')\n ''\n >>> remove_vowels('abcdef\\\\nghijklm')\n 'bcdf\\\\nghjklm'\n >>> remove_vowels('abcdef')\n 'bcdf'\n >>> remove_vowels('aaaaa')\n ''\n >>> remove_vowels('aaBAA')\n 'B'\n >>> remove_vowels('zbcd')\n 'zbcd'\n \"\"\"\n vowels = 'aeiouAEIOU'\n return ''.join(c for c in s if c not in vowels)", "result": "passed", "passed": true}
{"task_id": "HumanEval/34", "completion": "def unique(l: list) -> list:\n \"\"\"Return sorted unique elements in a list\n \n Args:\n l (list): Input list\n \n Returns:\n list: Sorted list of unique elements\n \n Example:\n >>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123]) \n [0, 2, 3, 5, 9, 123]\n \"\"\"\n return sorted(list(set(l)))", "result": "passed", "passed": true}
{"task_id": "HumanEval/65", "completion": "def circular_shift(x: int, shift: int) -> str:\n \"\"\"Circular shift the digits of the integer x, shift the digits right by shift \n and return the result as a string.\n If shift > number of digits, return digits reversed.\n \n Args:\n x (int): The integer to circular shift\n shift (int): The number of positions to shift the digits right\n \n Returns:\n str: The circular shifted integer as a string\n \n Examples:\n >>> circular_shift(12345, 1) \n '51234'\n >>> circular_shift(12345, 2)\n '45123'\n >>> circular_shift(12345, 3)\n '34512'\n >>> circular_shift(12345, 4) \n '23451'\n >>> circular_shift(12345, 5)\n '12345'\n >>> circular_shift(12345, 6) \n '54321'\n \"\"\"\n x_str = str(x)\n n = len(x_str)\n \n if shift > n:\n return x_str[::-1]\n else:\n shift = shift % n\n return x_str[-shift:] + x_str[:-shift]\n\n\nif __name__ == '__main__':\n import doctest\n doctest.testmod()", "result": "passed", "passed": true}
{"task_id": "HumanEval/6", "completion": "from typing import List\n\ndef parse_nested_parens(paren_string: str) -> List[int]:\n \"\"\"\n Input to this function is a string represented multiple groups for nested parentheses separated by spaces.\n For each of the group, output the deepest level of nesting of parentheses.\n E.g. (()()) has maximum two levels of nesting while ((())) has three.\n\n >>> parse_nested_parens('(()()) ((())) () ((())()())')\n [2, 3, 1, 3]\n \"\"\"\n results = []\n for group in paren_string.split():\n depth = 0\n max_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 results.append(max_depth)\n return results", "result": "passed", "passed": true}
{"task_id": "HumanEval/2", "completion": "def truncate_number(number: float) -> float:\n \"\"\"\n Given a positive floating point number, it can be decomposed into\n an integer part (largest integer smaller than given number) and decimals\n (leftover part always smaller than 1).\n\n Return the decimal part of the number.\n >>> truncate_number(3.5)\n 0.5\n \"\"\"\n return number - int(number)", "result": "passed", "passed": true}
{"task_id": "HumanEval/3", "completion": "from typing import List\n\ndef below_zero(operations: List[int]) -> bool:\n \"\"\"\n You're given a list of deposit and withdrawal operations on a bank account that starts with\n zero balance. Your task is to detect if at any point the balance of account falls below zero, and\n at that point function should return True. Otherwise it should return False.\n >>> below_zero([1, 2, 3])\n False\n >>> below_zero([1, 2, -4, 5])\n True\n \"\"\"\n balance = 0\n for operation in operations:\n balance += operation\n if balance < 0:\n return True\n return False", "result": "passed", "passed": true}
{"task_id": "HumanEval/7", "completion": "from typing import List\n\ndef filter_by_substring(strings: List[str], substring: str) -> List[str]:\n \"\"\"\n Filter an input list of strings only for ones that contain given substring\n >>> filter_by_substring([], 'a')\n []\n >>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a')\n ['abc', 'bacd', 'array']\n \"\"\"\n return [string for string in strings if substring in string]", "result": "passed", "passed": true}