Datasets:

Modalities:
Text
Formats:
parquet
Size:
< 1K
ArXiv:
Libraries:
Datasets
pandas
Dataset Viewer
Auto-converted to Parquet Duplicate
task_id
stringlengths
11
12
prompt
stringlengths
145
1.35k
entry_point
stringlengths
3
25
canonical_solution
stringlengths
17
1.88k
test
stringlengths
253
113k
HumanEval/0
from typing import List def has_close_elements(numbers: List[float], threshold: float) -> bool: """ Check if in a given list of numbers, there are any two numbers closer to each other than the given threshold. Examples: >>> has_close_elements([1.0, 2.0, 3.0], 0.5) False >>> ha...
has_close_elements
if len(numbers) < 2: return False for idx, elem in enumerate(numbers): for idx2, elem2 in enumerate(numbers): if idx != idx2: distance = abs(elem - elem2) if distance < threshold: return True return False
def check(candidate): assert candidate([1.0, 2.0, 3.9, 4.0, 5.0, 2.2], 0.3) == True assert candidate([1.0, 2.0, 3.9, 4.0, 5.0, 2.2], 0.05) == False assert candidate([1.0, 2.0, 5.9, 4.0, 5.0], 0.95) == True assert candidate([1.0, 2.0, 5.9, 4.0, 5.0], 0.8) == False assert candidate([1.0, 2.0, 3.0, 4.0...
HumanEval/1
from typing import List def separate_paren_groups(paren_string: str) -> List[str]: """ Input to this function is a string possibly containing multiple groups of nested parentheses. Your goal is to separate those groups into separate strings and return the list of those. Ignore anything other than "(" ...
separate_paren_groups
input = "".join([x for x in paren_string if x in '()']) breakpoints = input.split('()') groups = [] for i in range(len(breakpoints) - 1): group = '()' while breakpoints[i] != "" and breakpoints[i].endswith('(') and breakpoints[i + 1] != "" and breakpoints[i + 1].startswith(')'): ...
def check(candidate): assert candidate('()') == ['()'] assert candidate('()()') == ['()', '()'] assert candidate('(())') == ['(())'] assert candidate('') == [] assert candidate('True') == [] assert candidate('{}') == [] assert candidate('((') == [] assert candidate('))') == [] assert...
HumanEval/2
def truncate_number(number: float) -> float: """ Given a positive floating point number, it can be decomposed into and integer part (largest integer smaller than given number) and decimals (leftover part always smaller than 1). Return the decimal part of the number. Example: >>> truncat...
truncate_number
assert number > 0 return number % 1.0
def check(candidate): assert candidate(3.5) == 0.5 assert candidate(1.33) < 0.330001 assert candidate(1.33) > 0.329999 assert candidate(123.456) < 0.456001 assert candidate(123.456) > 0.455999 assert candidate(9.99999) < 0.99999001 assert candidate(9.99999) > 0.99998999 assert candidate(...
HumanEval/3
from typing import List def below_zero(operations: List[int]) -> bool: """ You're given a list of deposit and withdrawal operations on a bank account that starts with zero balance. Your task is to detect if at any point the balance of account falls below zero, and at that point function should return ...
below_zero
balance = 0 for op in operations: balance += op if balance < 0: return True return False
def check(candidate): assert candidate([]) == False assert candidate([-1]) == True assert candidate([1]) == False assert candidate([10000000, -10000000]) == False assert candidate([1, 2, -3, 1, 2, -3]) == False assert candidate([1, 2, -4, 5, 6]) == True assert candidate([2, 2, 2, 2, 2, -10, ...
HumanEval/4
from typing import List def mean_absolute_deviation(numbers: List[float]) -> float: """ For a given list of input numbers, calculate Mean Absolute Deviation around the mean of this dataset. Mean Absolute Deviation is the average absolute difference between each element and a centerpoint (mean in t...
mean_absolute_deviation
assert len(numbers) > 0 mean = sum(numbers) / len(numbers) return sum(abs(x - mean) for x in numbers) / len(numbers)
def check(candidate): assert abs(candidate([1.0, 2.0, 3.0]) - 2.0 / 3.0) < 1e-6 assert abs(candidate([1.0, 2.0, 3.0, 4.0]) - 1.0) < 1e-6 assert abs(candidate([1.0, 2.0, 3.0, 4.0, 5.0]) - 6.0 / 5.0) < 1e-6 assert abs(candidate([0.0, 0.0, 0.0]) - 0.0) < 1e-6 assert abs(candidate([-1.0, 1.0]) - 1.0) < ...
HumanEval/5
from typing import List def intersperse(numbers: List[int], delimeter: int) -> List[int]: """ Insert a number 'delimeter' between every two consecutive elements of input list `numbers' Example: >>> intersperse([1, 2, 3], 4) [1, 4, 2, 4, 3] """
intersperse
if not numbers: return [] result = [] for n in numbers[:-1]: result.append(n) result.append(delimeter) result.append(numbers[-1]) return result
def check(candidate): assert candidate([], 7) == [] assert candidate([1], 1) == [1] assert candidate([1, 3], 2) == [1, 2, 3] assert candidate([5, 6, 3, 2], 8) == [5, 8, 6, 8, 3, 8, 2] assert candidate([2, 2, 2], 2) == [2, 2, 2, 2, 2] assert candidate([0, 0, 0, 0, 0], 0) == [0, 0, 0, 0, 0, 0, 0, ...
HumanEval/6
from typing import List def parse_nested_parens(paren_string: str) -> List[int]: """ Input to this function is a string containing "(" and ")"s (not exclusively), possibly including multiple groups for nested parentheses. For each of these groups, output the deepest level of nesting of parentheses. ...
parse_nested_parens
input = "".join([x for x in paren_string if x in '()']) breakpoints = input.split('()') groups = [] for i in range(len(breakpoints) - 1): group = '()' while breakpoints[i] != "" and breakpoints[i].endswith('(') and breakpoints[i + 1] != "" and breakpoints[i + 1].startswith(')'): ...
def check(candidate): assert candidate('') == [] assert candidate('(())') == [2] assert candidate(')(') == [] assert candidate('((') == [] assert candidate('))') == [] assert candidate('((())') == [2] assert candidate('(()))') == [2] assert candidate('()') == [1] assert candidate('((...
HumanEval/7
from typing import List def filter_by_substring(strings: List[str], substring: str) -> List[str]: """ Filter an input list of strings only for ones that contain given substring. Example: >>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a') ['abc', 'bacd', 'array'] """
filter_by_substring
return [x for x in strings if substring in x]
def check(candidate): assert candidate([], 'john') == [] assert candidate([], '') == [] assert candidate(['', ' ', ' '], ' ') == [' ', ' '] assert candidate(['jo'], 'john') == [] assert candidate(['john'], 'john') == ['john'] assert candidate(['JOHN'], 'john') == [] assert candidate(['jo...
HumanEval/8
from typing import List, Tuple def sum_product(numbers: List[int]) -> Tuple[int, int]: """ For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list. Empty sum should be equal to 0 and empty product should be equal to 1. Example: >>> sum_prod...
sum_product
sum_value = 0 prod_value = 1 for n in numbers: sum_value += n prod_value *= n return sum_value, prod_value
def check(candidate): assert candidate([]) == (0, 1) assert candidate([1, 1, 1]) == (3, 1) assert candidate([100, 0]) == (100, 0) assert candidate([3, 5, 7]) == (15, 105) assert candidate([10]) == (10, 10) assert candidate([-1, -2, -3]) == (-6, -6) assert candidate([0, 0, 0]) == (0, 0) a...
HumanEval/9
from typing import List def rolling_max(numbers: List[int]) -> List[int]: """ From a given list of integers, generate a list of rolling maximum element found until given moment in the sequence. Example: >>> rolling_max([1, 2, 3, 2, 3, 4, 2]) [1, 2, 3, 3, 3, 4, 4] """
rolling_max
running_max = None result = [] for n in numbers: if running_max is None: running_max = n else: running_max = max(running_max, n) result.append(running_max) return result
def check(candidate): assert candidate([]) == [] assert candidate([-1]) == [-1] assert candidate([0, 1, 2, 3, 4]) == [0, 1, 2, 3, 4] assert candidate([4, 3, 2, 1]) == [4, 4, 4, 4] assert candidate([3, 2, 3, 100, 3]) == [3, 3, 3, 100, 100] assert candidate([5, 5, 5, 5, 5]) == [5, 5, 5, 5, 5] ...
HumanEval/10
def make_palindrome(string: str) -> str: """ Find the shortest palindrome that begins with a supplied string. Algorithm idea is simple: - Find the longest postfix of supplied string that is a palindrome. - Append to the end of the string reverse of a string prefix that comes before the palindromic s...
make_palindrome
if not string: return "" def is_palindrome(string: str) -> bool: """ Test if given string is a palindrome """ return string == string[::-1] beginning_of_suffix = 0 while not is_palindrome(string[beginning_of_suffix:]): beginning_of_suffix += 1 return string + s...
def check(candidate): assert candidate("") == "" assert candidate("x") == "x" assert candidate("xyz") == "xyzyx" assert candidate("xyx") == "xyx" assert candidate("noon") == "noon" assert candidate("race") == "racecar" assert candidate("jerry") == "jerryrrej" assert candidate("1234543") ...
HumanEval/11
from typing import List def string_xor(a: str, b: str) -> str: """ Input are two strings a and b consisting only of 1s and 0s. Perform binary XOR on these inputs and return result also as a string. Example: >>> string_xor('10', '110') '100' """
string_xor
if len(a) < len(b): a = '0' * (len(b) - len(a)) + a elif len(b) < len(a): b = '0' * (len(a) - len(b)) + b def xor(i, j): if i == j: return '0' else: return '1' return ''.join(xor(x, y) for x, y in zip(a, b))
def check(candidate): assert candidate('111000', '101010') == '010010' assert candidate('1', '1') == '0' assert candidate('0', '0') == '0' assert candidate('1', '0') == '1' assert candidate('0', '1') == '1' assert candidate('0101', '0000') == '0101' assert candidate('', '101') == '101' a...
HumanEval/12
from typing import List def longest(strings: List[str]) -> str: """ Out of a list of strings, return the longest one. Return the first one in case of multiple strings of the same length. Return an empty string for edge cases. Examples: >>> longest(['a', 'b', 'c']) 'a' >>> ...
longest
if not strings: return '' maxlen = max(len(x) for x in strings) for s in strings: if len(s) == maxlen: return s
def check(candidate): assert candidate([]) == '' assert candidate(['x', 'y', 'z']) == 'x' assert candidate(['x', 'yyy', 'zzzz', 'www', 'kkkk', 'abc']) == 'zzzz' assert candidate(['bb', 'aa']) == 'bb' assert candidate(['\n\n\n', 'n']) == '\n\n\n' assert candidate(['', ' n ', 'nnn']) == ' n ' ...
HumanEval/13
def greatest_common_divisor(a: int, b: int) -> int: """ Return the greatest common divisor of two integers a and b Examples: >>> greatest_common_divisor(3, 5) 1 >>> greatest_common_divisor(25, 15) 5 """
greatest_common_divisor
while b: a, b = b, a % b return abs(a)
def check(candidate): assert candidate(3, 7) == 1 assert candidate(10, 15) == 5 assert candidate(49, 14) == 7 assert candidate(144, 60) == 12 assert candidate(8, 0) == 8 assert candidate(0, -4) == 4 assert candidate(-5, -10) == 5 assert candidate(-2, 9) == 1 def test_check(): check...
HumanEval/14
from typing import List def all_prefixes(string: str) -> List[str]: """ Return list of all prefixes from shortest to longest of the input string. Example: >>> all_prefixes('abc') ['a', 'ab', 'abc'] """
all_prefixes
result = [] for i in range(len(string)): result.append(string[:i+1]) return result
def check(candidate): assert candidate('') == [] assert candidate(' a ') == [' ', ' a', ' a '] assert candidate('abc\nde\tf') == ['a', 'ab', 'abc', 'abc\n', 'abc\nd', 'abc\nde', 'abc\nde\t', 'abc\nde\tf'] assert candidate('asdfgh') == ['a', 'as', 'asd', 'asdf', 'asdfg', 'asdfgh'] assert candidate('W...
HumanEval/15
def string_sequence(n: int) -> str: """ Return a string containing space-delimited numbers starting from 0 upto n inclusive. If n is negative, return an empty string. Examples: >>> string_sequence(0) '0' >>> string_sequence(5) '0 1 2 3 4 5' """
string_sequence
if n < 0: return '' return ' '.join([str(x) for x in range(n + 1)])
def check(candidate): assert candidate(0) == '0' assert candidate(1) == '0 1' assert candidate(3) == '0 1 2 3' assert candidate(10) == '0 1 2 3 4 5 6 7 8 9 10' assert candidate(100) == '0 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 4...
HumanEval/16
def count_distinct_characters(string: str) -> int: """ Find out how many distinct characters (regardless of case) are in the string. Examples: >>> count_distinct_characters("xyzXYZ") 3 >>> count_distinct_characters("Jerry") 4 """
count_distinct_characters
return len(set(string.lower()))
def check(candidate): assert candidate("") == 0 assert candidate("abcde") == 5 assert candidate("abcdecadeCADE") == 5 assert candidate("aaaaAAAAaaaa") == 1 assert candidate("Jerry jERRY JeRRRY") == 5 assert candidate(' ...
HumanEval/17
from typing import List def parse_music(music_string: str) -> List[int]: """ Input to this function is a string representing musical notes in a special ASCII format. Your task is to parse this string and return list of integers corresponding to how many beats does each note last. Here is a legend...
parse_music
note_map = {'o': 4, 'o|': 2, '.|': 1} return [note_map[x] for x in music_string.split(' ') if x]
def check(candidate): assert candidate('') == [] assert candidate('o o o o') == [4, 4, 4, 4] assert candidate('.| .| .| .|') == [1, 1, 1, 1] assert candidate('o| o| .| .| o o o o') == [2, 2, 1, 1, 4, 4, 4, 4] assert candidate('o| .| o| .| o o| o o|') == [2, 1, 2, 1, 4, 2, 4, 2] assert candidate(...
HumanEval/18
def how_many_times(string: str, substring: str) -> int: """ Find how many times a given substring can be found in the original string. Count overlapping cases. Example: >>> how_many_times('aaaa', 'aa') 3 """
how_many_times
times = 0 if not substring: return len(string) + 1 for i in range(len(string) - len(substring) + 1): if string[i:i + len(substring)] == substring: times += 1 return times
def check(candidate): assert candidate('', 'x') == 0 assert candidate('xyxyxyx', 'x') == 4 assert candidate('cacacacac', 'cac') == 4 assert candidate('john doe', 'john') == 1 assert candidate('1 2 324 5', ' 2') == 1 assert candidate('xy', 'xyz') == 0 assert candidate('abc', '') == 4 ass...
HumanEval/19
def sort_numbers(numbers: str) -> str: """ Input is a space-delimited string of numerals from 'zero' to 'nine'. Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'. Return the string with numbers sorted from smallest to largest Example: >>> so...
sort_numbers
value_map = { 'zero': 0, 'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5, 'six': 6, 'seven': 7, 'eight': 8, 'nine': 9 } return ' '.join(sorted([x for x in numbers.split(' ') if x and x in value_map], key=lambda x: value_map...
def check(candidate): assert candidate('') == '' assert candidate('three') == 'three' assert candidate('two two') == 'two two' assert candidate('three five nine') == 'three five nine' assert candidate(' two one three ') == 'one two three' assert candidate('five zero four seven nine eight'...
HumanEval/20
from typing import List, Tuple def find_closest_elements(numbers: List[float]) -> Tuple[float, float]: """ From a supplied list of numbers (of length at least two) select and return the last two elements that are the closest to each other and return them in order (smaller number, larger number). ...
find_closest_elements
assert len(numbers) >= 2 closest_pair = None distance = None for idx, elem in enumerate(numbers): for idx2, elem2 in enumerate(numbers): if idx != idx2: if distance is None: distance = abs(elem - elem2) closest_pair = tuple(so...
def check(candidate): assert candidate([1.0, 2.0, 3.9, 4.0, 5.0, 2.2]) == (3.9, 4.0) assert candidate([1.0, 2.0, 5.9, 4.0, 5.0]) == (5.0, 5.9) assert candidate([1.0, 2.0, 3.0, 4.0, 5.0, 2.2]) == (2.0, 2.2) assert candidate([1.0, 2.0, 3.0, 4.0, 5.0, 2.0]) == (2.0, 2.0) assert candidate([1.1, 2.2, 3.1...
HumanEval/21
from typing import List def rescale_to_unit(numbers: List[float]) -> List[float]: """ Given a list of numbers (of at least two elements), apply a linear transform to that list, such that the smallest number will become 0 and the largest will become 1. Return an empty list for any undefined edge cases....
rescale_to_unit
if len(set(numbers)) < 2: return [] min_number = min(numbers) max_number = max(numbers) return [(x - min_number) / (max_number - min_number) for x in numbers]
def check(candidate): assert candidate([]) == [] assert candidate([1.0]) == [] assert candidate([1.0, 2.0]) == [0.0, 1.0] assert candidate([-4.0, -4.0, -4.0]) == [] assert candidate([0.0, 0.0]) == [] assert candidate([2.0, 49.9]) == [0.0, 1.0] assert candidate([100.0, 49.9]) == [1.0, 0.0] ...
HumanEval/22
from typing import List def filter_integers(values: List[str]) -> List[int]: """ Filter given list of string values only for integers. Example: >>> filter_integers(['10', ' 123 ', '5.0', three', 'abc', '{}']) [10] """
filter_integers
return [int(x) for x in values if x.isdigit()]
def check(candidate): assert candidate([]) == [] assert candidate(['4', '{}', '[1]', '23.2', '9', 'adasd']) == [4, 9] assert candidate(['3', 'c', '3', '3', 'a', 'b']) == [3, 3, 3] assert candidate(['0', '1', 'O', 'o', 'False', '1e5']) == [0, 1] assert candidate(['10-8', '10 - 8', '4*2', '4 / 2', '4+...
HumanEval/23
def strlen(string: str) -> int: """ Return the length of the given string. Example: >>> strlen('abc') 3 """
strlen
return len(string)
def check(candidate): assert candidate('') == 0 assert candidate(' ') == 1 assert candidate('x') == 1 assert candidate('asdasnakj') == 9 assert candidate(' s p a c e s ') == 23 assert candidate('a\nb\tc') == 5 assert candidate('False') == 5 assert candidate('10') == 2 asser...
HumanEval/24
def largest_divisor(n: int) -> int: """ Find the largest number that divides n evenly, smaller than n. Return -1 if such a number does not exist. Example: >>> largest_divisor(15) 5 """
largest_divisor
if n <= 0: return -1 for i in reversed(range(n)): if n % i == 0: return i
def check(candidate): assert candidate(3) == 1 assert candidate(7) == 1 assert candidate(10) == 5 assert candidate(100) == 50 assert candidate(49) == 7 assert candidate(-4) == -1 assert candidate(0) == -1 def test_check(): check(largest_divisor)
HumanEval/25
from typing import List def factorize(n: int) -> List[int]: """ Return a list of prime factors of the given integer in the order of smallest to largest. Each of the factors should be listed as often as it appears in the factorization. The input number should be equal to the product of all factors. ...
factorize
assert n > 1 import math fact = [] i = 2 while i <= int(math.sqrt(n) + 1): if n % i == 0: fact.append(i) n //= i else: i += 1 if n > 1: fact.append(n) return fact
def check(candidate): assert candidate(2) == [2] assert candidate(4) == [2, 2] assert candidate(8) == [2, 2, 2] assert candidate(57) == [3, 19] assert candidate(3249) == [3, 3, 19, 19] assert candidate(185193) == [3, 3, 3, 19, 19, 19] assert candidate(20577) == [3, 19, 19, 19] assert can...
HumanEval/26
from typing import List def remove_duplicates(numbers: List[int]) -> List[int]: """ From a list of integers, remove all the elements that occur more than once. Keep the order of the elements the same as in the input. Example: >>> remove_duplicates([1, 2, 3, 2, 4]) [1, 3, 4] """
remove_duplicates
import collections c = collections.Counter(numbers) return [n for n in numbers if c[n] <= 1]
def check(candidate): assert candidate([]) == [] assert candidate([1, 1, 1]) == [] assert candidate([1, 2, 3, 4]) == [1, 2, 3, 4] assert candidate([1, 2, 3, 2, 4, 3, 5]) == [1, 4, 5] assert candidate([-1, -2, -3, -2, -4, -3, -5]) == [-1, -4, -5] assert candidate([1, -1]) == [1, -1] def test_ch...
HumanEval/27
def flip_case(string: str) -> str: """ For a given string, flip lowercase characters to uppercase and uppercase to lowercase. Example: >>> flip_case('Hello') 'hELLO' """
flip_case
return string.swapcase()
def check(candidate): assert candidate('') == '' assert candidate('Hello!') == 'hELLO!' assert candidate('These violent delights have violent ends') == 'tHESE VIOLENT DELIGHTS HAVE VIOLENT ENDS' assert candidate('n\nN') == 'N\nn' assert candidate(' spa\tces ') == ' SPA\tCES ' assert ...
HumanEval/28
from typing import List def concatenate(strings: List[str]) -> str: """ Concatenate list of strings into a single string. Example: >>> concatenate(['a', 'b', 'c']) 'abc' """
concatenate
return ''.join(strings)
def check(candidate): assert candidate([]) == '' assert candidate(['', '', '']) == '' assert candidate(['x', 'yy', 'zzz']) == 'xyyzzz' assert candidate(['x', 'y', 'z,', 'w', 'k!']) == 'xyz,wk!' assert candidate(['\n', '\t', ' ']) == '\n\t ' assert candidate(['\"', 'string', '\"']) == '\"string\"...
HumanEval/29
from typing import List def filter_by_prefix(strings: List[str], prefix: str) -> List[str]: """ Filter an input list of strings only for ones that start with a given prefix. Examples: >>> filter_by_prefix([], 'a') [] >>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a') ...
filter_by_prefix
return [x for x in strings if x.startswith(prefix)]
def check(candidate): assert candidate([], 'john') == [] assert candidate(['john', 'jo', 'johnny'], 'john') == ['john', 'johnny'] assert candidate(['a', '', ' ', 'bbb', '!C@'], '') == ['a', '', ' ', 'bbb', '!C@'] assert candidate(['caps', 'CAPS', 'CaPs', 'cApS'], 'CAPS') == ['CAPS'] assert candidate...
HumanEval/30
from typing import List def get_positive(l: List[int]) -> List[int]: """ Return only the positive numbers in the list. Example: >>> get_positive([-1, 2, -4, 5, 6]) [2, 5, 6] """
get_positive
return [e for e in l if e > 0]
def check(candidate): assert candidate([-1, -2, 4, 5, 6]) == [4, 5, 6] assert candidate([5, 3, -5, 2, 3, 3, 9, 0, 123, 1, -10]) == [5, 3, 2, 3, 3, 9, 123, 1] assert candidate([-1, -2]) == [] assert candidate([0]) == [] assert candidate([]) == [] assert candidate([2, 2, 2]) == [2, 2, 2] def tes...
HumanEval/31
def is_prime(n: int) -> bool: """ Check if given number is considered to be prime. Examples: >>> is_prime(6) False >>> is_prime(100) False >>> is_prime(11) True """
is_prime
if n < 2: return False for k in range(2, n - 1): if n % k == 0: return False return True
def check(candidate): assert candidate(-5) == False assert candidate(-1) == False assert candidate(0) == False assert candidate(1) == False assert candidate(2) == True assert candidate(3) == True assert candidate(4) == False assert candidate(5) == True assert candidate(6) == False ...
HumanEval/32
import math from typing import List def poly(xs: list, x: float) -> float: """ Evaluates polynomial with coefficients xs at point x. return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n """ return sum([coeff * math.pow(x, i) for i, coeff in enumerate(xs)]) def find_zero(xs: List[int]) -> fl...
find_zero
begin, end = -1., 1. while poly(xs, begin) * poly(xs, end) > 0: begin *= 2.0 end *= 2.0 while end - begin > 1e-10: center = (begin + end) / 2.0 if poly(xs, center) * poly(xs, begin) > 0: begin = center else: end = center return begin
def check(candidate): assert abs(candidate([-10, -2]) - (-5.000000000058208)) < 1e-6 assert abs(candidate([-3, -6, -7, 7]) - (1.6679422343731858)) < 1e-6 assert abs(candidate([8, 3]) - (-2.666666666686069)) < 1e-6 assert abs(candidate([-10, -8]) - (-1.2500000000582077)) < 1e-6 assert abs(candidate([...
HumanEval/33
from typing import List def sort_third(l: List[int]) -> List[int]: """ This function takes a list l and returns a list l' such that l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal to the values of the correspo...
sort_third
l = list(l) l[::3] = sorted(l[::3]) return l
def check(candidate): assert candidate([]) == [] assert candidate([1, 2, 3]) == [1, 2, 3] assert candidate([4, 2, 3, 1]) == [1, 2, 3, 4] assert candidate([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == [1, 3, -5, 2, -3, 3, 5, 0, 123, 9, -10] assert candidate([5, 8, -12, 4, 23, 2, 3, 11, 12, -10]) == [-1...
HumanEval/34
from typing import List def unique(l: List[int]) -> List[int]: """ Return sorted unique elements in a list. Example: >>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123]) [0, 2, 3, 5, 9, 123] """
unique
return sorted(list(set(l)))
def check(candidate): assert candidate([]) == [] assert candidate([2, 1, 2, 1, 2]) == [1, 2] assert candidate([-3, -2, -4, -2, -2, -3, -4]) == [-4, -3, -2] assert candidate([1, 2, 3]) == [1, 2, 3] assert candidate([0, 0, -1, 0, 1, 0, 1]) == [-1, 0, 1] assert candidate([5, 3, 5, 2, 3, 3, 9, 0, 12...
HumanEval/35
from typing import List def max_element(l: List[int]) -> int: """ Return the maximum element in the list. Assume that the list is not empty. Example: >>> max_element([1, 2, 3]) 3 """
max_element
assert len(l) > 0 m = l[0] for e in l: if e > m: m = e return m
def check(candidate): assert candidate([0]) == 0 assert candidate([-3, -8, -21]) == -3 assert candidate([1, 2, 3, 4, 0, 1, 2, 3]) == 4 assert candidate([5, 3, -5, 2, -3, 3, 9, 0, 124, 1, -10]) == 124 assert candidate([4, 4, 4, 3, 3, 3, 5, 0, 2, 2]) == 5 def test_check(): check(max_element)
HumanEval/36
def fizz_buzz(n: int) -> int: """ Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13. Examples: >>> fizz_buzz(50) 0 >>> fizz_buzz(78) 2 >>> fizz_buzz(79) 3 """
fizz_buzz
assert n >= 0 ns = [] for i in range(n): if i % 11 == 0 or i % 13 == 0: ns.append(i) s = ''.join(list(map(str, ns))) ans = 0 for c in s: ans += (c == '7') return ans
def check(candidate): assert candidate(0) == 0 assert candidate(1) == 0 assert candidate(50) == 0 assert candidate(78) == 2 assert candidate(79) == 3 assert candidate(100) == 3 assert candidate(200) == 6 assert candidate(4000) == 192 assert candidate(10000) == 639 assert candidat...
HumanEval/37
from typing import List def sort_even(l: List[int]) -> List[int]: """ This function takes a list l and returns a list l' such that l' is identical to l in the odd indicies, while its values at the even indicies are equal to the values of the even indicies of l, but sorted. Examples: >>> s...
sort_even
evens = l[::2] odds = l[1::2] evens.sort() ans = [] for e, o in zip(evens, odds): ans.extend([e, o]) if len(evens) > len(odds): ans.append(evens[-1]) return ans
def check(candidate): assert candidate([]) == [] assert candidate([1, 2, 3]) == [1, 2, 3] assert candidate([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) == [-10, 3, -5, 2, -3, 3, 5, 0, 9, 1, 123] assert candidate([5, 8, -12, 4, 23, 2, 3, 11, 12, -10]) == [-12, 8, 3, 4, 5, 2, 12, 11, 23, -10] def test_check...
HumanEval/38
def encode_cyclic(s: str) -> str: """ Returns encoded string by cycling groups of three characters. """ # split string to groups. Each of length 3. groups = [s[(3 * i):min((3 * i + 3), len(s))] for i in range((len(s) + 2) // 3)] # cycle elements in each group. Unless group has fewe...
decode_cyclic
return encode_cyclic(encode_cyclic(s))
def check(candidate): assert candidate("[Z*uqK1`_ZGX<: C*[8vFn)-SpO") == "*[ZKuq_1`XZG <:[C*F8v-n)OSp" assert candidate("bo(") == "(bo" assert candidate("fH:*B=]1a@A*W2C~7i95~!(.1") == ":fH=*Ba]1*@ACW2i~7~95.!(1" assert candidate("uWiFq6U+hJ|f") == "iuW6FqhU+fJ|" assert candidate("NT)OBVt; yxb") == ...
HumanEval/39
def prime_fib(n: int) -> int: """ prime_fib returns n-th number that is a Fibonacci number and also prime. Examples: >>> prime_fib(1) 2 >>> prime_fib(2) 3 >>> prime_fib(3) 5 >>> prime_fib(4) 13 >>> prime_fib(5) 89 """
prime_fib
import math assert n > 0 def is_prime(p: int) -> bool: if p < 2: return False for k in range(2, min(int(math.sqrt(p)) + 1, p - 1)): if p % k == 0: return False return True f = [0, 1] while True: f.append(f[-1] + f[-2]) ...
def check(candidate): assert candidate(1) == 2 assert candidate(2) == 3 assert candidate(3) == 5 assert candidate(4) == 13 assert candidate(5) == 89 assert candidate(6) == 233 assert candidate(7) == 1597 assert candidate(8) == 28657 assert candidate(9) == 514229 assert candidate(...
HumanEval/40
from typing import List def triples_sum_to_zero(l: List[int]) -> bool: """ Check if there are three distinct elements in the list that sum to zero. Examples: >>> triples_sum_to_zero([1, 3, 5, 0]) False >>> triples_sum_to_zero([1, 3, -2, 1]) True """
triples_sum_to_zero
for i in range(len(l)): for j in range(i + 1, len(l)): for k in range(j + 1, len(l)): if l[i] + l[j] + l[k] == 0: return True return False
def check(candidate): assert candidate([1, 3, 5, 0]) == False assert candidate([1, 3, 5, -1]) == False assert candidate([1, 3, -2, 1]) == True assert candidate([1, 2, 3, 7]) == False assert candidate([1, 2, 5, 7]) == False assert candidate([2, 4, -5, 3, 9, 7]) == True assert candidate([-5, 0...
HumanEval/41
def car_race_collision(n: int) -> int: """ Imagine a road that's a perfectly straight infinitely long line. n cars are driving left to right; simultaneously, a different set of n cars are driving right to left. n cars -> ..... <- n other cars The two sets of cars start out being very far f...
car_race_collision
assert n >= 0 return n**2
def check(candidate): assert candidate(0) == 0 assert candidate(1) == 1 assert candidate(2) == 4 assert candidate(3) == 9 assert candidate(4) == 16 assert candidate(8) == 64 assert candidate(10) == 100 def test_check(): check(car_race_collision)
HumanEval/42
from typing import List def incr_list(l: List[int]) -> List[int]: """ Increment all elements of the list by 1. Example: >>> incr_list([1, 2, 3]) [2, 3, 4] """
incr_list
return [(e + 1) for e in l]
def check(candidate): assert candidate([]) == [] assert candidate([3, 2, 1]) == [4, 3, 2] assert candidate([5, 2, 5, 2, 3, 3, 9, 0, 123]) == [6, 3, 6, 3, 4, 4, 10, 1, 124] assert candidate([1, 0, -1, -2, -3]) == [2, 1, 0, -1, -2] def test_check(): check(incr_list)
HumanEval/43
from typing import List def pairs_sum_to_zero(l: List[int]) -> bool: """ Check if there are two distinct elements in the list that sum to zero. Examples: >>> pairs_sum_to_zero([1, 3, 5, 0]) False >>> pairs_sum_to_zero([2, 4, -5, 3, 5, 7]) True """
pairs_sum_to_zero
for i, l1 in enumerate(l): for j in range(i + 1, len(l)): if l1 + l[j] == 0: return True return False
def check(candidate): assert candidate([1, 3, 5, 0]) == False assert candidate([1, 3, -2, 1]) == False assert candidate([1, 2, 3, 7]) == False assert candidate([2, 4, -5, 3, 5, 7]) == True assert candidate([1]) == False assert candidate([]) == False assert candidate([0, 0]) == True asse...
HumanEval/44
def change_base(x: int, base: int) -> str: """ Change numerical base of input number x to base. return string representation after the conversion. base numbers are less than 10. Examples: >>> change_base(8, 3) '22' >>> change_base(8, 2) '1000' >>> change_base...
change_base
ret = "" while x > 0: ret = str(x % base) + ret x //= base return ret
def check(candidate): assert candidate(8, 3) == "22" assert candidate(9, 3) == "100" assert candidate(234, 2) == "11101010" assert candidate(16, 2) == "10000" assert candidate(8, 2) == "1000" assert candidate(7, 2) == "111" assert candidate(2, 3) == "2" assert candidate(3, 4) == "3" ...
HumanEval/45
def triangle_area(a: float, h: float) -> float: """ Given length of a side and height, return area for a triangle. Examples: >>> triangle_area(5, 3) 7.5 """
triangle_area
return abs(a) * abs(h) / 2.0
def check(candidate): assert candidate(3, 5) == 7.5 assert candidate(2, 2) == 2.0 assert candidate(10, 8) == 40.0 assert candidate(0, 0) == 0.0 assert candidate(2, -8) == 8.0 assert candidate(-8, 2) == 8.0 def test_check(): check(triangle_area)
HumanEval/46
def fib4(n: int) -> int: """ The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows: fib4(0) -> 0 fib4(1) -> 0 fib4(2) -> 2 fib4(3) -> 0 fib4(n) -> fib4(n - 1) + fib4(n - 2) + fib4(n - 3) + fib4(n - 4) Please write a functi...
fib4
assert n >= 0 results = [0, 0, 2, 0] if n < 4: assert n >= 0 return results[n] for _ in range(4, n + 1): results.append(results[-1] + results[-2] + results[-3] + results[-4]) results.pop(0) return results[-1]
def check(candidate): assert candidate(0) == 0 assert candidate(5) == 4 assert candidate(8) == 28 assert candidate(10) == 104 assert candidate(12) == 386 assert candidate(49) == 13546793363542 def test_check(): check(fib4)
HumanEval/47
from typing import List def median(l: List[float]) -> float: """ Return median of elements in the list l. Examples: >>> median([3, 1, 2, 4, 5]) 3 >>> median([-10, 4, 6, 1000, 10, 20]) 8.0 """
median
assert len(l) > 0 l = sorted(l) if len(l) % 2 == 1: return l[len(l) // 2] else: return (l[len(l) // 2 - 1] + l[len(l) // 2]) / 2.0
def check(candidate): assert candidate([3, 1, 2, 4, 5]) == 3 assert candidate([-10, 4, 6, 1000, 10, 20]) == 8.0 assert candidate([5]) == 5 assert candidate([6, 5]) == 5.5 assert candidate([8, 1, 3, 9, 9, 2, 7]) == 7 def test_check(): check(median)
HumanEval/48
def is_palindrome(text: str) -> bool: """ Checks if given string is a palindrome. Examples: >>> is_palindrome('racecar') True >>> is_palindrome('car') False """
is_palindrome
for i in range(len(text)): if text[i] != text[len(text) - 1 - i]: return False return True
def check(candidate): assert candidate('') == True assert candidate('aba') == True assert candidate('aaaaa') == True assert candidate('zbcd') == False assert candidate('xywyx') == True assert candidate('xywyz') == False assert candidate('xywzx') == False assert candidate('palindrome') ==...
HumanEval/49
def modp(n: int, p: int) -> int: """ Solve 2^n modulo p (be aware of numerics). Return the least non-negative residue. Examples: >>> modp(3, 5) 3 >>> modp(100, 101) 1 """
modp
assert n >= 0 ret = 1 for _ in range(n): ret = (2 * ret) % p while ret < 0: ret += abs(p) return ret
def check(candidate): assert candidate(3, 5) == 3 assert candidate(1101, 101) == 2 assert candidate(0, 101) == 1 assert candidate(3, 11) == 8 assert candidate(3, -11) == 8 assert candidate(100, 101) == 1 assert candidate(30, 5) == 4 assert candidate(31, 5) == 3 assert candidate(31, -...
HumanEval/50
def decode_shift(s: str) -> str: """ Takes as input a lowercase string encoded as follows: - Shift every letter by 5 in the alphabet. This function should return the decoded string. Examples: >>> decode_shift("cryim") "xmtdh" >>> decode_shift("zlsebmzxbqrvxkrwlqvrvg...
decode_shift
return "".join([chr(((ord(ch) - 5 - ord("a")) % 26) + ord("a")) for ch in s])
def check(candidate): assert candidate("cryim") == "xmtdh" assert candidate("zlsebmzxbqrvxkrwlqvrvgpmbrgerh") == "ugnzwhuswlmqsfmrglqmqbkhwmbzmc" assert candidate("cfxchfesawcaybmbq") == "xasxcaznvrxvtwhwl" assert candidate("qenusc") == "lzipnx" assert candidate("awxsembugkohodgmfgukoe") == "vrsnzhw...
HumanEval/51
def remove_vowels(text: str) -> str: """ Return the text without vowels (a, e, i, o, u). Examples: >>> remove_vowels('abcdef') 'bcdf' >>> remove_vowels('aaaaa') '' >>> remove_vowels('aaBAA') 'B' >>> remove_vowels('zbcd') 'zbcd' """
remove_vowels
return "".join([s for s in text if s.lower() not in ["a", "e", "i", "o", "u"]])
def check(candidate): assert candidate('') == '' assert candidate("abcdef\nghijklm") == 'bcdf\nghjklm' assert candidate('abc\tdef') == 'bc\tdf' assert candidate('fedcba') == 'fdcb' assert candidate('eeeee') == '' assert candidate('acBAA') == 'cB' assert candidate('EcBOO') == 'cB' assert ...
HumanEval/52
from typing import List def below_threshold(l: List[int], t: int) -> bool: """ Check if all numbers in the list l are below threshold t. Examples: >>> below_threshold([1, 2, 4, 10], 100) True >>> below_threshold([1, 20, 4, 10], 5) False """
below_threshold
for e in l: if e >= t: return False return True
def check(candidate): assert candidate([1, 2, 4, 10], 100) == True assert candidate([1, 20, 4, 10], 5) == False assert candidate([1, 20, 4, 10], 21) == True assert candidate([1, 20, 4, 10], 22) == True assert candidate([1, 8, 4, 10], 11) == True assert candidate([1, 8, 4, 10], 10) == False a...
End of preview. Expand in Data Studio

This is the dataset for the paper https://arxiv.org/abs/2503.05860

HumanEvalNext

HumanEvalNext is an improved version of the HumanEval code generation benchmark. The improvements made are based on the framework EvalPro. This framework is aimed at enhancing benchmark quality through a rigorous improvement process along with peer reviews. An overview of the approach along with the specific applicability to HumanEval has been illustrated below.

HumanEvalNext Improvement Process Figure 1. The Process of improving HumanEval through the BenchFrame framework

The evaluation results of benchmark can be found here. A more detailed description of HumanEvalNext can be found here. We find the following results results when benchmarking 10 SOTA open-weight models.

HumanEvalNext Comparative Results Figure 2. Comparison of HumanEval with two enhanced versions. (HumanEvalNext and EvalPlus)

Downloads last month
130

Paper for AISE-TUDelft/HumanEvalNext