Datasets:
entry_point
stringlengths 1
30
| name
stringlengths 11
13
| prompt
stringlengths 115
1.36k
| prompt1a
stringlengths 143
1.34k
| prompt1c
stringlengths 114
1.36k
β | prompt1p
stringlengths 62
695
| prompt2ac
stringlengths 142
1.34k
β | prompt2ap
stringlengths 67
629
β | prompt2cp
stringlengths 82
525
β | prompt3acp
stringclasses 12
values | solution
stringlengths 132
1.99k
| test_case
stringlengths 96
19.6k
|
---|---|---|---|---|---|---|---|---|---|---|---|
has_close_elements | HumanEval/0 | from typing import List
def has_close_elements(numbers: List[float], threshold: float) -> bool:
""" Check if in given list of numbers, are any two numbers closer to each other than
given threshold.
>>> has_close_elements([1.0, 2.0, 3.0], 0.5)
False
>>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)
True
"""
| from typing import List
def candidate(numbers: List[float], threshold: float) -> bool:
""" Check if in given list of numbers, are any two numbers meeting a certain condition (e.g. closer to or larger than each other than
given threshold).
>>> candidate([1.0, 2.0, 3.0], 0.5)
False
>>> candidate([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)
True
"""
| from typing import List
def has_close_elements(numbers: List[float], threshold: float) -> bool:
""" Check if in given list of numbers, are any two numbers larger than each other than
given threshold.
>>> has_close_elements([1.0, 2.0, 3.0], 0.5)
False
>>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)
True
"""
| from typing import List
def candidate(...) -> bool:
""" Check given a list of number."""
| from typing import List
def candidate(numbers: List[float], threshold: float) -> bool:
""" Check if in given list of numbers, are any two numbers meeting a certain condition (e.g. closer to or larger than each other than
given threshold).
>>> candidate([1.0, 2.0, 3.0], 0.5)
True
>>> candidate([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)
False
"""
| from typing import List
def candidate(numbers: List[float], x: float) -> bool:
""" given a list of number."""
| null | null | from typing import List
def has_close_elements(numbers: List[float], threshold: float) -> bool:
""" Check if in given list of numbers, are any two numbers closer to each other than
given threshold.
>>> has_close_elements([1.0, 2.0, 3.0], 0.5)
False
>>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)
True
"""
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
| [{'input': '[1.0, 2.0, 3.9, 4.0, 5.0, 2.2], 0.3', 'output': 'True', 'relation': '=='}, {'input': '[1.0, 2.0, 3.9, 4.0, 5.0, 2.2], 0.05', 'output': 'False', 'relation': '=='}, {'input': '[1.0, 2.0, 5.9, 4.0, 5.0], 0.95', 'output': 'True', 'relation': '=='}, {'input': '[1.0, 2.0, 5.9, 4.0, 5.0], 0.8', 'output': 'False', 'relation': '=='}, {'input': '[1.0, 2.0, 3.0, 4.0, 5.0, 2.0], 0.1', 'output': 'True', 'relation': '=='}, {'input': '[1.1, 2.2, 3.1, 4.1, 5.1], 1.0', 'output': 'True', 'relation': '=='}, {'input': '[1.1, 2.2, 3.1, 4.1, 5.1], 0.5', 'output': 'False', 'relation': '=='}] |
separate_paren_groups | HumanEval/1 | from typing import List
def separate_paren_groups(paren_string: str) -> List[str]:
""" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
separate those group into separate strings and return the list of those.
Separate groups are balanced (each open brace is properly closed) and not nested within each other
Ignore any spaces in the input string.
>>> separate_paren_groups('( ) (( )) (( )( ))')
['()', '(())', '(()())']
"""
| from typing import List
def candidate(paren_string: str) -> List[str]:
""" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
separate those group into separate strings and return the list of those.
Separate groups are balanced (each open brace has a certain requirement to meet) and not nested within each other
Keep or ignore any spaces in the input string.
>>> candidate('( ) (( )) (( )( ))')
['()', '(())', '(()())']
"""
| from typing import List
def separate_paren_groups(paren_string: str) -> List[str]:
""" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
separate those group into separate strings and return the list of those.
Separate groups are balanced (each open brace is properly closed) and not nested within each other
Ignore any spaces in the input string.
>>> separate_paren_groups('( ) (( )) (( )( ))')
['(', '(', '(']
"""
| from typing import List
def separate_paren_groups(paren_string: str) -> List[str]:
""" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
"""
| from typing import List
def candidate(paren_string: str) -> List[str]:
""" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
separate those group into separate strings and return the list of those.
Separate groups are balanced (each open brace has a certain requirement to meet) and not nested within each other
Keep or ignore any spaces in the input string.
>>> candidate('( ) (( )) (( )( ))')
['(', '(', '(']
"""
| from typing import List
def candidate(paren_string: str) -> List[str]:
""" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
separate those group into separate strings and return the list of those.
Separate groups are balanced (each open brace has a certain requirement to meet) and not nested within each other
"""
| null | null | from typing import List
def separate_paren_groups(paren_string: str) -> List[str]:
""" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
separate those group into separate strings and return the list of those.
Separate groups are balanced (each open brace is properly closed) and not nested within each other
Ignore any spaces in the input string.
>>> separate_paren_groups('( ) (( )) (( )( ))')
['()', '(())', '(()())']
"""
result = []
current_string = []
current_depth = 0
for c in paren_string:
if c == '(':
current_depth += 1
current_string.append(c)
elif c == ')':
current_depth -= 1
current_string.append(c)
if current_depth == 0:
result.append(''.join(current_string))
current_string.clear()
return result
| [{'input': "'(()()) ((())) () ((())()())'", 'output': "['(()())', '((()))', '()', '((())()())']", 'relation': '=='}, {'input': "'() (()) ((())) (((())))'", 'output': "['()', '(())', '((()))', '(((())))']", 'relation': '=='}, {'input': "'(()(())((())))'", 'output': "['(()(())((())))']", 'relation': '=='}, {'input': "'( ) (( )) (( )( ))'", 'output': "['()', '(())', '(()())']", 'relation': '=='}] |
truncate_number | 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.
>>> truncate_number(3.5)
0.5
"""
|
def candidate(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 a certain part of the number (e.g. integer or decimal or another).
>>> candidate(3.5)
0.5
"""
|
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.
>>> truncate_number(3.5)
3
"""
|
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).
"""
|
def candidate(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 a certain part of the number (e.g. integer or decimal or another)
>>> candidate(3.5)
3
"""
|
def candidate(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).
"""
| null | null |
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.
>>> truncate_number(3.5)
0.5
"""
return number % 1.0
| [{'input': '3.5', 'output': '0.5', 'relation': '=='}, {'input': '1.33', 'output': '1e-6', 'relation': 'abs(candidate(1.33) - 0.33) < 1e-6'}, {'input': '123.456', 'output': '1e-6', 'relation': 'abs(candidate(123.456) - 0.456) < 1e-6'}] |
below_zero | 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 fallls below zero, and
at that point function should return True. Otherwise it should return False.
>>> below_zero([1, 2, 3])
False
>>> below_zero([1, 2, -4, 5])
True
"""
| 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
a given balance (e.g. positive or zero). Your task is to detect if at any point the balance of account fallls below zero, and
at that point function should return True. Otherwise it should return False.
>>> below_zero([1, 2, 3])
False
>>> below_zero([1, 2, -4, 5])
False
"""
| 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 fallls below zero, and
at that point function should return True. Otherwise it should return False.
>>> below_zero([1, 2, 3])
True
>>> below_zero([1, 2, -4, 5])
False
"""
| 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 fallls below zero. """
| 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
a given balance (e.g. positive or zero). Your task is to detect if at any point the balance of account fallls below zero, and
at that point function should return True. Otherwise it should return False.
>>> below_zero([1, 2, 3])
True
>>> below_zero([1, 2, -4, 5])
False
"""
| 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
a given balance (e.g. positive or zero). Your task is to detect if at any point the balance of account fallls below zero. """
| null | null | 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 fallls below zero, and
at that point function should return True. Otherwise it should return False.
>>> below_zero([1, 2, 3])
False
>>> below_zero([1, 2, -4, 5])
True
"""
balance = 0
for op in operations:
balance += op
if balance < 0:
return True
return False
| [{'input': '[]', 'output': 'False', 'relation': '=='}, {'input': '[1, 2, -3, 1, 2, -3]', 'output': 'False', 'relation': '=='}, {'input': '[1, 2, -4, 5, 6]', 'output': 'True', 'relation': '=='}, {'input': '[1, -1, 2, -2, 5, -5, 4, -4]', 'output': 'False', 'relation': '=='}, {'input': '[1, -1, 2, -2, 5, -5, 4, -5]', 'output': 'True', 'relation': '=='}, {'input': '[1, -2, 2, -2, 5, -5, 4, -4]', 'output': 'True', 'relation': '=='}] |
mean_absolute_deviation | 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 this case):
MAD = average | x - x_mean |
>>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])
1.0
"""
| from typing import List
def candidate(numbers: List[float]) -> float:
""" For a given list of input numbers, calculate Mean Absolute Deviation
around a certain attribute (e.g. max or mean or other) of this dataset.
Mean Absolute Deviation is the average absolute difference between each
element and a centerpoint (e.g. max or mean in this case):
MAD = average | x - (e.g. max or mean or other) |
>>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])
1.0
"""
| 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 this case):
MAD = average | x - x_mean |
>>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])
1.5
"""
| from typing import List
def mean_absolute_deviation(numbers: List[float]) -> float:
""" For a given list of input numbers, calculate Mean Absolute Deviation.
"""
| from typing import List
def candidate(numbers: List[float]) -> float:
""" For a given list of input numbers, calculate Mean Absolute Deviation
around a certain attribute (e.g. max or mean or other) of this dataset.
Mean Absolute Deviation is the average absolute difference between each
element and a centerpoint (e.g. max or mean in this case):
MAD = average | x - (e.g. max or mean or other) |
>>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])
1.5
"""
| from typing import List
def candidate(numbers: List[float]) -> float:
""" For a given list of input numbers, calculate Mean Absolute Deviation
MAD = average | x - (e.g. max or mean or other) |
"""
| from typing import List
def mean_absolute_deviation(numbers: List[float]) -> float:
""" For a given list of input numbers, calculate Mean Absolute Deviation.
>>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])
1.5
"""
| from typing import List
def candidate(numbers: List[float]) -> float:
""" For a given list of input numbers, calculate Mean Absolute Deviation. >>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])
1.5
"""
| 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 this case):
MAD = average | x - x_mean |
>>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])
1.0
"""
mean = sum(numbers) / len(numbers)
return sum(abs(x - mean) for x in numbers) / len(numbers)
| [{'input': '[1.0, 2.0, 3.0]', 'output': '1e-6', 'relation': 'abs(candidate([1.0, 2.0, 3.0]) - 2.0/3.0) < 1e-6'}, {'input': '[1.0, 2.0, 3.0, 4.0]', 'output': '1e-6', 'relation': 'abs(candidate([1.0, 2.0, 3.0, 4.0]) - 1.0) < 1e-6'}, {'input': '[1.0, 2.0, 3.0, 4.0, 5.0]', 'output': '1e-6', 'relation': 'abs(candidate([1.0, 2.0, 3.0, 4.0, 5.0]) - 6.0/5.0) < 1e-6'}] |
intersperse | 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'
>>> intersperse([], 4)
[]
>>> intersperse([1, 2, 3], 4)
[1, 4, 2, 4, 3]
"""
| from typing import List
def candidate(numbers: List[int], x: int) -> List[int]:
""" Insert a number 'x' for a certain number of times in the input list `numbers'
>>> candidate([], 4)
[]
>>> candidate([1, 2, 3], 4)
[1, 4, 2, 4, 3]
"""
| 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'
>>> intersperse([], 4)
[4]
>>> intersperse([1, 2, 3], 4)
[1, 2, 3, 4]
"""
| from typing import List
def candidate(numbers: List[int], delimeter: int) -> List[int]:
""" Insert a number 'delimeter'
"""
| from typing import List
def candidate(numbers: List[int], x: int) -> List[int]:
""" Insert a number 'x' for a certain number of times in the input list `numbers'
>>> candidate([], 4)
[4]
>>> candidate([1, 2, 3], 4)
[1, 2, 3, 4]
"""
| null | null | null | 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'
>>> intersperse([], 4)
[]
>>> intersperse([1, 2, 3], 4)
[1, 4, 2, 4, 3]
"""
if not numbers:
return []
result = []
for n in numbers[:-1]:
result.append(n)
result.append(delimeter)
result.append(numbers[-1])
return result
| [{'input': '[], 7', 'output': '[]', 'relation': '=='}, {'input': '[5, 6, 3, 2], 8', 'output': '[5, 8, 6, 8, 3, 8, 2]', 'relation': '=='}, {'input': '[2, 2, 2], 2', 'output': '[2, 2, 2, 2, 2]', 'relation': '=='}] |
parse_nested_parens | HumanEval/6 | from typing import List
def parse_nested_parens(paren_string: str) -> List[int]:
""" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
For each of the group, output the deepest level of nesting of parentheses.
E.g. (()()) has maximum two levels of nesting while ((())) has three.
>>> parse_nested_parens('(()()) ((())) () ((())()())')
[2, 3, 1, 3]
"""
| from typing import List
def candidate(paren_string: str) -> List[int]:
""" Input to this function is a string represented multiple groups for nested parentheses separated by certain characters.
For each of the group, output the deepest level of nesting of parentheses.
E.g. (()()) has maximum two levels of nesting while ((())) has three.
>>> candidate('(()()) ((())) () ((())()())')
[2, 3, 1, 3]
"""
| from typing import List
def parse_nested_parens(paren_string: str) -> List[int]:
""" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
For each of the group, output the deepest level of nesting of parentheses.
E.g. (() ()) has maximum two levels of nesting while ((( ))) has three.
>>> parse_nested_parens('(()())((()))()((())()())')
[2, 3, 1, 3]
"""
| from typing import List
def parse_nested_parens(paren_string: str) -> List[int]:
""" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
For each of the group, output an integer
"""
| from typing import List
def candidate(paren_string: str) -> List[int]:
""" Input to this function is a string represented multiple groups for nested parentheses separated by certain characters.
For each of the group, output the deepest level of nesting of parentheses.
E.g. (() ()) has maximum two levels of nesting while ((( ))) has three.
>>> candidate('(()())((()))()((())()())')
[2, 3, 1, 3]
"""
| from typing import List
def candidate(paren_string: str) -> List[int]:
""" Input to this function is a string represented multiple groups for nested parentheses separated by certain characters.
For each of the group, output an integer
"""
| null | null | from typing import List
def parse_nested_parens(paren_string: str) -> List[int]:
""" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
For each of the group, output the deepest level of nesting of parentheses.
E.g. (()()) has maximum two levels of nesting while ((())) has three.
>>> parse_nested_parens('(()()) ((())) () ((())()())')
[2, 3, 1, 3]
"""
def parse_paren_group(s):
depth = 0
max_depth = 0
for c in s:
if c == '(':
depth += 1
max_depth = max(depth, max_depth)
else:
depth -= 1
return max_depth
return [parse_paren_group(x) for x in paren_string.split(' ') if x]
| [{'input': "'(()()) ((())) () ((())()())'", 'output': '[2, 3, 1, 3]', 'relation': '=='}, {'input': "'() (()) ((())) (((())))'", 'output': '[1, 2, 3, 4]', 'relation': '=='}, {'input': "'(()(())((())))'", 'output': '[4]', 'relation': '=='}] |
filter_by_substring | 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
>>> filter_by_substring([], 'a')
[]
>>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a')
['abc', 'bacd', 'array']
"""
| from typing import List
def candidate(strings: List[str], x: str) -> List[str]:
""" Process an input list of strings given string x
>>> candidate([], 'a')
[]
>>> candidate(['abc', 'bacd', 'cde', 'array'], 'a')
['abc', 'bacd', 'array']
"""
| 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
>>> filter_by_substring([], 'a')
['a']
>>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a')
['cde']
"""
| from typing import List
def filter_by_substring(strings: List[str], substring: str) -> List[str]:
""" Filter an input list of strings
"""
| from typing import List
def candidate(strings: List[str], x: str) -> List[str]:
""" Process an input list of strings given string x
>>> candidate([], 'a')
['a']
>>> candidate(['abc', 'bacd', 'cde', 'array'], 'a')
['cde']
"""
| from typing import List
def candidate(strings: List[str], x: str) -> List[str]:
""" Process an input list of strings
"""
| null | null | 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
>>> filter_by_substring([], 'a')
[]
>>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a')
['abc', 'bacd', 'array']
"""
return [x for x in strings if substring in x]
| [{'input': "[], 'john'", 'output': '[]', 'relation': '=='}, {'input': "['xxx', 'asd', 'xxy', 'john doe', 'xxxAAA', 'xxx'], 'xxx'", 'output': "['xxx', 'xxxAAA', 'xxx']", 'relation': '=='}, {'input': "['xxx', 'asd', 'aaaxxy', 'john doe', 'xxxAAA', 'xxx'], 'xx'", 'output': "['xxx', 'aaaxxy', 'xxxAAA', 'xxx']", 'relation': '=='}, {'input': "['grunt', 'trumpet', 'prune', 'gruesome'], 'run'", 'output': "['grunt', 'prune']", 'relation': '=='}] |
sum_product | 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.
>>> sum_product([])
(0, 1)
>>> sum_product([1, 2, 3, 4])
(10, 24)
"""
| from typing import List, Tuple
def candidate(numbers: List[int]) -> Tuple[int, int]:
""" For a given list of integers, return a tuple consisting of a sum and a product of a certain given subset of the integers in a list.
Empty sum or product should be equal to either 0 or 1.
>>> sum_product([])
(0, 1)
>>> sum_product([1, 2, 3, 4])
(10, 24)
"""
| 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.
>>> sum_product([])
(1, 0)
>>> sum_product([1, 2, 3, 4])
(24, 10)
"""
| from typing import List, Tuple
def candidate(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.
"""
| from typing import List, Tuple
def candidate(numbers: List[int]) -> Tuple[int, int]:
""" For a given list of integers, return a tuple consisting of a sum and a product of a certain given subset of the integers in a list.
Empty sum or product should be equal to either 0 or 1.
>>> candidate([])
(1, 0)
>>> candidate([1, 2, 3, 4])
(24, 10)
"""
| from typing import List, Tuple
def candidate(numbers: List[int]) -> Tuple[int, int]:
""" For a given list of integers, return a tuple consisting of a sum and a product of a certain given subset of the integers in a list.
"""
| null | null | 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.
>>> sum_product([])
(0, 1)
>>> sum_product([1, 2, 3, 4])
(10, 24)
"""
sum_value = 0
prod_value = 1
for n in numbers:
sum_value += n
prod_value *= n
return sum_value, prod_value
| [{'input': '[]', 'output': '(0, 1)', 'relation': '=='}, {'input': '[1, 1, 1]', 'output': '(3, 1)', 'relation': '=='}, {'input': '[100, 0]', 'output': '(100, 0)', 'relation': '=='}, {'input': '[3, 5, 7]', 'output': '(15, 105)', 'relation': '=='}, {'input': '[10]', 'output': '(10, 10)', 'relation': '=='}] |
rolling_max | HumanEval/9 | from typing import List, Tuple
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.
>>> rolling_max([1, 2, 3, 2, 3, 4, 2])
[1, 2, 3, 3, 3, 4, 4]
"""
| from typing import List, Tuple
def candidate(numbers: List[int]) -> List[int]:
""" From a given list of integers, generate a list of rolling certain type of element (minimal or maximum or other) found until given moment
in the sequence.
>>> candidate([1, 2, 3, 2, 3, 4, 2])
[1, 2, 3, 3, 3, 4, 4]
"""
| from typing import List, Tuple
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.
>>> rolling_max([1, 2, 3, 2, 3, 4, 2])
[1, 1, 1, 1, 1, 1, 1]
"""
| from typing import List, Tuple
def rolling_max(numbers: List[int]) -> List[int]:
""" From a given list of integers, generate a list of rolling element.
"""
| from typing import List, Tuple
def candidate(numbers: List[int]) -> List[int]:
""" From a given list of integers, generate a list of rolling certain type of element (minimal or maximum or other) found until given moment
in the sequence.
>>> candidate([1, 2, 3, 2, 3, 4, 2])
[1, 1, 1, 1, 1, 1, 1]
"""
| from typing import List, Tuple
def candidate(numbers: List[int]) -> List[int]:
""" From a given list of integers, generate a list of rolling element.
"""
| null | null | from typing import List, Tuple
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.
>>> rolling_max([1, 2, 3, 2, 3, 4, 2])
[1, 2, 3, 3, 3, 4, 4]
"""
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
| [{'input': '[]', 'output': '[]', 'relation': '=='}, {'input': '[1, 2, 3, 4]', 'output': '[1, 2, 3, 4]', 'relation': '=='}, {'input': '[4, 3, 2, 1]', 'output': '[4, 4, 4, 4]', 'relation': '=='}, {'input': '[3, 2, 3, 100, 3]', 'output': '[3, 3, 3, 100, 100]', 'relation': '=='}] |
make_palindrome | HumanEval/10 |
def is_palindrome(string: str) -> bool:
""" Test if given string is a palindrome """
return string == string[::-1]
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 suffix.
>>> make_palindrome('')
''
>>> make_palindrome('cat')
'catac'
>>> make_palindrome('cata')
'catac'
"""
|
def is_palindrome(string: str) -> bool:
""" Test if given string is a palindrome """
return string == string[::-1]
def candidate(string: str) -> str:
""" Find the longest or shortest palindrome that begins with a supplied string.
Algorithm idea is simple:
- Find the shortest or 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 suffix.
>>> candidate('')
''
>>> candidate('cat')
'catac'
>>> candidate('cata')
'catac'
"""
|
def is_palindrome(string: str) -> bool:
""" Test if given string is a palindrome """
return string == string[::-1]
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 suffix.
>>> make_palindrome('')
''
>>> make_palindrome('cat')
'ata'
>>> make_palindrome('cata')
'ata'
"""
|
def is_palindrome(string: str) -> bool:
""" Test if given string is a palindrome """
return string == string[::-1]
def make_palindrome(string: str) -> str:
""" Find the shortest palindrome.
"""
|
def is_palindrome(string: str) -> bool:
""" Test if given string is a palindrome """
return string == string[::-1]
def candidate(string: str) -> str:
""" Find the longest or shortest palindrome that begins with a supplied string.
Algorithm idea is simple:
- Find the shortest or 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 suffix.
>>> candidate('')
''
>>> candidate('cat')
'ata'
>>> candidate('cata')
'ata'
"""
|
def is_palindrome(string: str) -> bool:
""" Test if given string is a palindrome """
return string == string[::-1]
def candidate(string: str) -> str:
""" Find the longest or shortest palindrome.
"""
| null | null |
def is_palindrome(string: str) -> bool:
""" Test if given string is a palindrome """
return string == string[::-1]
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 suffix.
>>> make_palindrome('')
''
>>> make_palindrome('cat')
'catac'
>>> make_palindrome('cata')
'catac'
"""
if not string:
return ''
beginning_of_suffix = 0
while not is_palindrome(string[beginning_of_suffix:]):
beginning_of_suffix += 1
return string + string[:beginning_of_suffix][::-1]
| [{'input': "''", 'output': '', 'relation': '=='}, {'input': "'x'", 'output': 'x', 'relation': '=='}, {'input': "'xyz'", 'output': 'xyzyx', 'relation': '=='}, {'input': "'xyx'", 'output': 'xyx', 'relation': '=='}, {'input': "'jerry'", 'output': 'jerryrrej', 'relation': '=='}] |
string_xor | 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.
>>> string_xor('010', '110')
'100'
"""
| from typing import List
def candidate(a: str, b: str) -> str:
""" Input are two strings a and b consisting only of 1s and 0s.
Perform certain bitwise operation on these inputs and return result also as a string.
>>> candidate('010', '110')
'100'
"""
| 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.
>>> string_xor('010', '110')
'011'
"""
| from typing import List
def candidate(a: str, b: str) -> str:
""" Input are two strings a and b consisting only of 1s and 0s.
"""
| from typing import List
def candidate(a: str, b: str) -> str:
""" Input are two strings a and b consisting only of 1s and 0s.
Perform certain bitwise operation on these inputs and return result also as a string.
>>> candidate('010', '110')
'011'
"""
| null | null | null | 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.
>>> string_xor('010', '110')
'100'
"""
def xor(i, j):
if i == j:
return '0'
else:
return '1'
return ''.join(xor(x, y) for x, y in zip(a, b))
| [{'input': "'111000', '101010'", 'output': '010010', 'relation': '=='}, {'input': "'1', '1'", 'output': '0', 'relation': '=='}, {'input': "'0101', '0000'", 'output': '0101', 'relation': '=='}] |
longest | HumanEval/12 | from typing import List, Optional
def longest(strings: List[str]) -> Optional[str]:
""" Out of list of strings, return the longest one. Return the first one in case of multiple
strings of the same length. Return None in case the input list is empty.
>>> longest([])
>>> longest(['a', 'b', 'c'])
'a'
>>> longest(['a', 'bb', 'ccc'])
'ccc'
"""
| from typing import List, Optional
def candidate(strings: List[str]) -> Optional[str]:
""" Out of list of strings, return a certain one (the shortest or longest or another). Return the first one in case of multiple
strings of the same length. Return None in case the input list is empty.
>>> candidate([])
>>> candidate(['a', 'b', 'c'])
'a'
>>> candidate(['a', 'bb', 'ccc'])
'ccc'
"""
| from typing import List, Optional
def longest(strings: List[str]) -> Optional[str]:
""" Out of list of strings, return the longest one. Return the first one in case of multiple
strings of the same length. Return None in case the input list is empty.
>>> longest([])
>>> longest(['a', 'b', 'c'])
'c'
>>> longest(['a', 'bb', 'ccc'])
'a'
"""
| from typing import List, Optional
def candidate(strings: List[str]) -> Optional[str]:
""" Out of list of strings, return one of them. Return the first one in case of multiple
strings of the same length. Return None in case the input list is empty.
"""
| from typing import List, Optional
def candidate(strings: List[str]) -> Optional[str]:
""" Out of list of strings, return a certain one (the shortest or longest or another). Return the first one in case of multiple
strings of the same length. Return None in case the input list is empty.
>>> candidate([])
>>> candidate(['a', 'b', 'c'])
'c'
>>> candidate(['a', 'bb', 'ccc'])
'a'
"""
| null | null | null | from typing import List, Optional
def longest(strings: List[str]) -> Optional[str]:
""" Out of list of strings, return the longest one. Return the first one in case of multiple
strings of the same length. Return None in case the input list is empty.
>>> longest([])
>>> longest(['a', 'b', 'c'])
'a'
>>> longest(['a', 'bb', 'ccc'])
'ccc'
"""
if not strings:
return None
maxlen = max(len(x) for x in strings)
for s in strings:
if len(s) == maxlen:
return s
| [{'input': '[]', 'output': 'None', 'relation': '=='}, {'input': "['x', 'y', 'z']", 'output': 'x', 'relation': '=='}, {'input': "['x', 'yyy', 'zzzz', 'www', 'kkkk', 'abc']", 'output': 'zzzz', 'relation': '=='}] |
greatest_common_divisor | HumanEval/13 |
def greatest_common_divisor(a: int, b: int) -> int:
""" Return a greatest common divisor of two integers a and b
>>> greatest_common_divisor(3, 5)
1
>>> greatest_common_divisor(25, 15)
5
"""
|
def candidate(a: int, b: int) -> int:
""" Return a common divisor of two integers a and b
>>> candidate(3, 5)
1
>>> candidate(25, 15)
5
"""
|
def greatest_common_divisor(a: int, b: int) -> int:
""" Return a greatest common divisor of two integers a and b
>>> greatest_common_divisor(3, 5)
3
>>> greatest_common_divisor(25, 15)
15
"""
|
def candidate(...) -> int:
""" Return a greatest common divisor
"""
|
def candidate(a: int, b: int) -> int:
""" Return a common divisor of two integers a and b
>>> candidate(3, 5)
3
>>> candidate(25, 15)
15
"""
|
def candidate(...) -> int:
""" Return a common divisor
"""
| null | null |
def greatest_common_divisor(a: int, b: int) -> int:
""" Return a greatest common divisor of two integers a and b
>>> greatest_common_divisor(3, 5)
1
>>> greatest_common_divisor(25, 15)
5
"""
while b:
a, b = b, a % b
return a
| [{'input': '3, 7', 'output': '1', 'relation': '=='}, {'input': '10, 15', 'output': '5', 'relation': '=='}, {'input': '49, 14', 'output': '7', 'relation': '=='}, {'input': '144, 60', 'output': '12', 'relation': '=='}] |
all_prefixes | 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
>>> all_prefixes('abc')
['a', 'ab', 'abc']
"""
| from typing import List
def candidate(string: str) -> List[str]:
""" Return list of a certain pattern (suffixes or prefixes or other types of substring) from shortest to longest of the input string
>>> candidate('abc')
['a', 'ab', 'abc']
"""
| from typing import List
def all_prefixes(string: str) -> List[str]:
""" Return list of all prefixes from shortest to longest of the input string
>>> all_prefixes('abc')
['abc', 'ab', 'a']
"""
| from typing import List
def all_prefixes(string: str) -> List[str]:
""" Return list of all prefixes
"""
| from typing import List
def candidate(string: str) -> List[str]:
""" Return list of a certain pattern (suffixes or prefixes or other types of substring) from shortest to longest of the input string
>>> candidate('abc')
['abc', 'ab', 'a']
"""
| from typing import List
def candidate(string: str) -> List[str]:
""" Return list of a certain patter
"""
| null | null | from typing import List
def all_prefixes(string: str) -> List[str]:
""" Return list of all prefixes from shortest to longest of the input string
>>> all_prefixes('abc')
['a', 'ab', 'abc']
"""
result = []
for i in range(len(string)):
result.append(string[:i+1])
return result
| [{'input': "''", 'output': '[]', 'relation': '=='}, {'input': "'asdfgh'", 'output': "['a', 'as', 'asd', 'asdf', 'asdfg', 'asdfgh']", 'relation': '=='}, {'input': "'WWW'", 'output': "['W', 'WW', 'WWW']", 'relation': '=='}] |
string_sequence | HumanEval/15 |
def string_sequence(n: int) -> str:
""" Return a string containing space-delimited numbers starting from 0 upto n inclusive.
>>> string_sequence(0)
'0'
>>> string_sequence(5)
'0 1 2 3 4 5'
"""
|
def string_sequence(n: int) -> str:
""" Return a string containing dot or space-delimited numbers starting from 0 upto a certain number inclusive.
>>> string_sequence(0)
'0'
>>> string_sequence(5)
'0 1 2 3 4 5'
"""
|
def string_sequence(n: int) -> str:
""" Return a string containing space-delimited numbers starting from 0 upto n inclusive.
>>> string_sequence(0)
'0'
>>> string_sequence(5)
'0.1.2.3.4.5'
"""
|
def string_sequence(n: int) -> str:
""" Return a string containing space-delimited numbers.
|
def string_sequence(n: int) -> str:
""" Return a string containing dot or space-delimited numbers starting from 0 upto a certain number inclusive.
>>> string_sequence(0)
'0'
>>> string_sequence(5)
'0.1.2.3.4.5'
"""
|
def string_sequence(n: int) -> str:
""" Return a string containing dot or space-delimited numbers.
| null | null |
def string_sequence(n: int) -> str:
""" Return a string containing space-delimited numbers starting from 0 upto n inclusive.
>>> string_sequence(0)
'0'
>>> string_sequence(5)
'0 1 2 3 4 5'
"""
return ' '.join([str(x) for x in range(n + 1)])
| [{'input': '0', 'output': '0', 'relation': '=='}, {'input': '3', 'output': '0 1 2 3', 'relation': '=='}, {'input': '10', 'output': '0 1 2 3 4 5 6 7 8 9 10', 'relation': '=='}] |
count_distinct_characters | HumanEval/16 |
def count_distinct_characters(string: str) -> int:
""" Given a string, find out how many distinct characters (regardless of case) does it consist of
>>> count_distinct_characters('xyzXYZ')
3
>>> count_distinct_characters('Jerry')
4
"""
|
def candidate(string: str) -> int:
""" Given a string, find out how many characters (regardless of case) does it consist of
>>> candidate('xyzXYZ')
3
>>> candidate('Jerry')
4
"""
|
def count_distinct_characters(string: str) -> int:
""" Given a string, find out how many distinct characters (regardless of case) does it consist of
>>> count_distinct_characters('xyzXYZ')
6
>>> count_distinct_characters('Jerry')
5
"""
|
def candidate(string: str) -> int:
""" Given a string, find out how many distinct characters does it consist of
"""
|
def candidate(string: str) -> int:
""" Given a string, find out how many characters (regardless of case) does it consist of
>>> candidate('xyzXYZ')
6
>>> candidate('Jerry')
5
"""
|
def candidate(string: str) -> int:
""" Given a string, find out how many characters (regardless of case) does it consist of
"""
| null | null |
def count_distinct_characters(string: str) -> int:
""" Given a string, find out how many distinct characters (regardless of case) does it consist of
>>> count_distinct_characters('xyzXYZ')
3
>>> count_distinct_characters('Jerry')
4
"""
return len(set(string.lower()))
| [{'input': "''", 'output': '0', 'relation': '=='}, {'input': "'abcde'", 'output': '5', 'relation': '=='}, {'input': "'abcde' + 'cade' + 'CADE'", 'output': '5', 'relation': '=='}, {'input': "'aaaaAAAAaaaa'", 'output': '1', 'relation': '=='}, {'input': "'Jerry jERRY JeRRRY'", 'output': '5', 'relation': '=='}] |
parse_music | 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
not last.
Here is a legend:
'o' - whole note, lasts four beats
'o|' - half note, lasts two beats
'.|' - quater note, lasts one beat
>>> parse_music('o o| .| o| o| .| .| .| .| o o')
[4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]
"""
| 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
not last.
Here is a legend:
'o' - whole note, lasts A beats
'o|' - half note, lasts B beats
'.|' - quater note, lasts C beat
>>> parse_music('o o| .| o| o| .| .| .| .| o o')
[4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]
"""
| 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
not last.
Here is a legend:
'o' - whole note, lasts four beats
'o|' - half note, lasts two beats
'.|' - quater note, lasts one beat
>>> parse_music('o o| .| o| o| .| .| .| .| o o')
[1, 4, 2, 4, 4, 2, 2, 2, 2, 1, 1]
"""
| 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
not last.
"""
| 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
not last.
Here is a legend:
'o' - whole note, lasts A beats
'o|' - half note, lasts B beats
'.|' - quater note, lasts C beat
>>> parse_music('o o| .| o| o| .| .| .| .| o o')
[1, 4, 2, 4, 4, 2, 2, 2, 2, 1, 1]
"""
| null | null | null | 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
not last.
Here is a legend:
'o' - whole note, lasts four beats
'o|' - half note, lasts two beats
'.|' - quater note, lasts one beat
>>> parse_music('o o| .| o| o| .| .| .| .| o o')
[4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]
"""
note_map = {'o': 4, 'o|': 2, '.|': 1}
return [note_map[x] for x in music_string.split(' ') if x]
| [{'input': "''", 'output': '[]', 'relation': '=='}, {'input': "'o o o o'", 'output': '[4, 4, 4, 4]', 'relation': '=='}, {'input': "'.| .| .| .|'", 'output': '[1, 1, 1, 1]', 'relation': '=='}, {'input': "'o| o| .| .| o o o o'", 'output': '[2, 2, 1, 1, 4, 4, 4, 4]', 'relation': '=='}, {'input': "'o| .| o| .| o o| o o|'", 'output': '[2, 1, 2, 1, 4, 2, 4, 2]', 'relation': '=='}] |
how_many_times | 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 overlaping cases.
>>> how_many_times('', 'a')
0
>>> how_many_times('aaa', 'a')
3
>>> how_many_times('aaaa', 'aa')
3
"""
|
def candidate(a: str, b: str) -> int:
""" Find how many times a given substring can be found in the original string. Count overlaping cases.
>>> how_many_times('', 'a')
0
>>> how_many_times('aaa', 'a')
3
>>> how_many_times('aaaa', 'aa')
3
"""
|
def how_many_times(string: str, substring: str) -> int:
""" Find how many times a given substring can be found in the original string. Count overlaping cases.
>>> how_many_times('', 'a')
0
>>> how_many_times('aaa', 'a')
3
>>> how_many_times('aaaa', 'aa')
2
"""
|
def how_many_times(string: str, substring: str) -> int:
""" Find how many times a given substring can be found in the original string.
"""
|
def candidate(a: str, b: str) -> int:
""" Find how many times a given substring can be found in the original string. Count overlaping cases.
>>> canidate('', 'a')
0
>>> candidate('aaa', 'a')
3
>>> candidate('aaaa', 'aa')
2
"""
|
def candidate(a: str, b: str) -> int:
""" Find how many times a given substring can be found in the original string.
"""
| null | null |
def how_many_times(string: str, substring: str) -> int:
""" Find how many times a given substring can be found in the original string. Count overlaping cases.
>>> how_many_times('', 'a')
0
>>> how_many_times('aaa', 'a')
3
>>> how_many_times('aaaa', 'aa')
3
"""
times = 0
for i in range(len(string) - len(substring) + 1):
if string[i:i+len(substring)] == substring:
times += 1
return times
| [{'input': "'', 'x'", 'output': '0', 'relation': '=='}, {'input': "'xyxyxyx', 'x'", 'output': '4', 'relation': '=='}, {'input': "'cacacacac', 'cac'", 'output': '4', 'relation': '=='}, {'input': "'john doe', 'john'", 'output': '1', 'relation': '=='}] |
sort_numbers | HumanEval/19 | from typing import List
def sort_numbers(numbers: str) -> str:
""" Input is a space-delimited string of numberals 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
>>> sort_numbers('three one five')
'one three five'
"""
| from typing import List
def candidate(numbers: str) -> str:
""" Input is a space-delimited string of numberals from 'zero' to 'nine'.
Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
Return the string with numbers in a certain order (sorted descendingly or ascendingly or another order)
>>> candidate('three one five')
'one three five'
"""
| from typing import List
def sort_numbers(numbers: str) -> str:
""" Input is a space-delimited string of numberals 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
>>> sort_numbers('three one five')
'five three one'
"""
| from typing import List
def sort_numbers(numbers: str) -> str:
""" Input is a space-delimited string of numberals.
"""
| from typing import List
def candidate(numbers: str) -> str:
""" Input is a space-delimited string of numberals from 'zero' to 'nine'.
Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
Return the string with numbers in a certain order (sorted descendingly or ascendingly or another order)
>>> candidate('three one five')
'five three one'
"""
| from typing import List
def candidate(numbers: str) -> str:
""" Input is a space-delimited string of numberals.
"""
| null | null | from typing import List
def sort_numbers(numbers: str) -> str:
""" Input is a space-delimited string of numberals 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
>>> sort_numbers('three one five')
'one three five'
"""
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], key=lambda x: value_map[x]))
| [{'input': "''", 'output': '', 'relation': '=='}, {'input': "'three'", 'output': 'three', 'relation': '=='}, {'input': "'three five nine'", 'output': 'three five nine', 'relation': '=='}, {'input': "'five zero four seven nine eight'", 'output': 'zero four five seven eight nine', 'relation': '=='}, {'input': "'six five four three two one zero'", 'output': 'zero one two three four five six', 'relation': '=='}] |
find_closest_elements | 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 two that are the closest to each
other and return them in order (smaller number, larger number).
>>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.2])
(2.0, 2.2)
>>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.0])
(2.0, 2.0)
"""
| from typing import List, Tuple
def candidate(numbers: List[float]) -> Tuple[float, float]:
""" From a supplied list of numbers (of length at least two) select and return two that are the farthest or closest to each
other and return them in order (smaller number, larger number).
>>> candidate([1.0, 2.0, 3.0, 4.0, 5.0, 2.2])
(2.0, 2.2)
>>> candidate([1.0, 2.0, 3.0, 4.0, 5.0, 2.0])
(2.0, 2.0)
"""
| 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 two that are the closest to each
other and return them in order (smaller number, larger number).
>>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.2])
(1.0, 5.0)
>>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.0])
(1.0, 5.0)
"""
| 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 two that are the closest to each
other and return them in order.
"""
| from typing import List, Tuple
def candidate(numbers: List[float]) -> Tuple[float, float]:
""" From a supplied list of numbers (of length at least two) select and return two that are the farthest or closest to each
other and return them in order (smaller number, larger number).
>>> candidate([1.0, 2.0, 3.0, 4.0, 5.0, 2.2])
(1.0, 5.0)
>>> candidate([1.0, 2.0, 3.0, 4.0, 5.0, 2.0])
(1.0, 5.0)
"""
| from typing import List, Tuple
def candidate(numbers: List[float]) -> Tuple[float, float]:
""" From a supplied list of numbers (of length at least two) select and return two that are the farthest or closest to each
other and return them in order.
"""
| null | null | 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 two that are the closest to each
other and return them in order (smaller number, larger number).
>>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.2])
(2.0, 2.2)
>>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.0])
(2.0, 2.0)
"""
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(sorted([elem, elem2]))
else:
new_distance = abs(elem - elem2)
if new_distance < distance:
distance = new_distance
closest_pair = tuple(sorted([elem, elem2]))
return closest_pair
| [{'input': '[1.0, 2.0, 3.9, 4.0, 5.0, 2.2]', 'output': '(3.9, 4.0)', 'relation': '=='}, {'input': '[1.0, 2.0, 5.9, 4.0, 5.0]', 'output': '(5.0, 5.9)', 'relation': '=='}, {'input': '[1.0, 2.0, 3.0, 4.0, 5.0, 2.2]', 'output': '(2.0, 2.2)', 'relation': '=='}, {'input': '[1.0, 2.0, 3.0, 4.0, 5.0, 2.0]', 'output': '(2.0, 2.0)', 'relation': '=='}, {'input': '[1.1, 2.2, 3.1, 4.1, 5.1]', 'output': '(2.2, 3.1)', 'relation': '=='}] |
rescale_to_unit | HumanEval/21 | from typing import List
def rescale_to_unit(numbers: List[float]) -> List[float]:
""" Given 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
>>> rescale_to_unit([1.0, 2.0, 3.0, 4.0, 5.0])
[0.0, 0.25, 0.5, 0.75, 1.0]
"""
| from typing import List
def rescale(numbers: List[float]) -> List[float]:
""" Given list of numbers (of at least two elements), apply a linear transform to that list,
such that the one number will become 0 and another will become 1
>>> rescale([1.0, 2.0, 3.0, 4.0, 5.0])
[0.0, 0.25, 0.5, 0.75, 1.0]
"""
| from typing import List
def rescale_to_unit(numbers: List[float]) -> List[float]:
""" Given 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
>>> rescale_to_unit([1.0, 2.0, 3.0, 4.0, 5.0])
[1.0, 0.75, 0.5, 0.25, 0.0]
"""
| from typing import List
def rescale(numbers: List[float]) -> List[float]:
""" Given list of numbers (of at least two elements), apply a linear transform to that list
"""
| from typing import List
def rescale(numbers: List[float]) -> List[float]:
""" Given list of numbers (of at least two elements), apply a linear transform to that list,
such that the one number will become 0 and another will become 1
>>> rescale([1.0, 2.0, 3.0, 4.0, 5.0])
[1.0, 0.75, 0.5, 0.25, 0.0]
"""
| null | null | null | from typing import List
def rescale_to_unit(numbers: List[float]) -> List[float]:
""" Given 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
>>> rescale_to_unit([1.0, 2.0, 3.0, 4.0, 5.0])
[0.0, 0.25, 0.5, 0.75, 1.0]
"""
min_number = min(numbers)
max_number = max(numbers)
return [(x - min_number) / (max_number - min_number) for x in numbers]
| [{'input': '[2.0, 49.9]', 'output': '[0.0, 1.0]', 'relation': '=='}, {'input': '[100.0, 49.9]', 'output': '[1.0, 0.0]', 'relation': '=='}, {'input': '[1.0, 2.0, 3.0, 4.0, 5.0]', 'output': '[0.0, 0.25, 0.5, 0.75, 1.0]', 'relation': '=='}, {'input': '[2.0, 1.0, 5.0, 3.0, 4.0]', 'output': '[0.25, 0.0, 1.0, 0.5, 0.75]', 'relation': '=='}, {'input': '[12.0, 11.0, 15.0, 13.0, 14.0]', 'output': '[0.25, 0.0, 1.0, 0.5, 0.75]', 'relation': '=='}] |
filter_integers | HumanEval/22 | from typing import List, Any
def filter_integers(values: List[Any]) -> List[int]:
""" Filter given list of any python values only for integers
>>> filter_integers(['a', 3.14, 5])
[5]
>>> filter_integers([1, 2, 3, 'abc', {}, []])
[1, 2, 3]
"""
| from typing import List, Any
def candidate(values: List[Any]) -> List[int]:
""" Filter given list of any python values only for certain types
>>> candidate(['a', 3.14, 5])
[5]
>>> candidate([1, 2, 3, 'abc', {}, []])
[1, 2, 3]
"""
| from typing import List, Any
def filter_integers(values: List[Any]) -> List[int]:
""" Filter given list of any python values only for integers
>>> filter_integers(['a', 3.14, 5])
['a']
>>> filter_integers([1, 2, 3, 'abc', {}, []])
['abc']
"""
| from typing import List, Any
def candidate(values: List[Any]) -> List[int]:
""" Filter given list of any python values
"""
| from typing import List, Any
def candidate(values: List[Any]) -> List[int]:
""" Filter given list of any python values only for certain types
>>> candidate(['a', 3.14, 5])
['a']
>>> candidate([1, 2, 3, 'abc', {}, []])
['abc']
"""
| null | null | null | from typing import List, Any
def filter_integers(values: List[Any]) -> List[int]:
""" Filter given list of any python values only for integers
>>> filter_integers(['a', 3.14, 5])
[5]
>>> filter_integers([1, 2, 3, 'abc', {}, []])
[1, 2, 3]
"""
return [x for x in values if isinstance(x, int)]
| [{'input': '[]', 'output': '[]', 'relation': '=='}, {'input': "[4, {}, [], 23.2, 9, 'adasd']", 'output': '[4, 9]', 'relation': '=='}, {'input': "[3, 'c', 3, 3, 'a', 'b']", 'output': '[3, 3, 3]', 'relation': '=='}] |
strlen | HumanEval/23 |
def strlen(string: str) -> int:
""" Return length of given string
>>> strlen('')
0
>>> strlen('abc')
3
"""
|
def candidate(string: str) -> int:
""" Return length or length of Longest Palindrome Substring of the given string
>>> candidate('')
0
>>> candidate('abc')
3
"""
|
def strlen(string: str) -> int:
""" Return length of given string
>>> strlen('')
0
>>> strlen('abc')
1
"""
|
def candidate(string: str) -> int:
""" Return length
"""
|
def candidate(string: str) -> int:
""" Return length or length of Longest Palindrome Substring of the given string
>>> candidate('')
0
>>> candidate('abc')
1
"""
|
def candidate(string: str) -> int:
""" Return length or length of Longest Palindrome Substring
"""
| null | null |
def strlen(string: str) -> int:
""" Return length of given string
>>> strlen('')
0
>>> strlen('abc')
3
"""
return len(string)
| [{'input': "''", 'output': '0', 'relation': '=='}, {'input': "'x'", 'output': '1', 'relation': '=='}, {'input': "'asdasnakj'", 'output': '9', 'relation': '=='}] |
largest_divisor | HumanEval/24 |
def largest_divisor(n: int) -> int:
""" For a given number n, find the largest number that divides n evenly, smaller than n
>>> largest_divisor(15)
5
"""
|
def candidate(n: int) -> int:
""" For a given number n, find the smallest or largest number that divides n evenly, smaller than n
>>> candidate(15)
5
"""
|
def largest_divisor(n: int) -> int:
""" For a given number n, find the largest number that divides n evenly, smaller than n
>>> largest_divisor(15)
1
"""
|
def candidate(n: int) -> int:
""" For a given number n, find the largest number that divides n evenly
"""
|
def candidate(n: int) -> int:
""" For a given number n, find the smallest or largest number that divides n evenly, smaller than n
>>> candidate(15)
1
"""
|
def candidate(n: int) -> int:
""" For a given number n, find the smallest or largest number that divides n evenly
"""
| null | null |
def largest_divisor(n: int) -> int:
""" For a given number n, find the largest number that divides n evenly, smaller than n
>>> largest_divisor(15)
5
"""
for i in reversed(range(n)):
if n % i == 0:
return i
| [{'input': '3', 'output': '1', 'relation': '=='}, {'input': '7', 'output': '1', 'relation': '=='}, {'input': '10', 'output': '5', 'relation': '=='}, {'input': '100', 'output': '50', 'relation': '=='}, {'input': '49', 'output': '7', 'relation': '=='}] |
factorize | HumanEval/25 | from typing import List
def factorize(n: int) -> List[int]:
""" Return list of prime factors of given integer in the order from smallest to largest.
Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.
Input number should be equal to the product of all factors
>>> factorize(8)
[2, 2, 2]
>>> factorize(25)
[5, 5]
>>> factorize(70)
[2, 5, 7]
"""
| from typing import List
def candidate(n: int) -> List[int]:
""" Return list of factors of given integer in the descending or ascending order.
Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.
Input number should be equal to the product of all factors
>>> candidate(8)
[2, 2, 2]
>>> candidate(25)
[5, 5]
>>> candidate(70)
[2, 5, 7]
"""
| from typing import List
def factorize(n: int) -> List[int]:
""" Return list of prime factors of given integer in the order from smallest to largest.
Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.
Input number should be equal to the product of all factors
>>> factorize(8)
[2, 4, 8]
>>> factorize(25)
[5, 25]
>>> factorize(70)
[2, 10, 70]
"""
| from typing import List
def candidate(n: int) -> List[int]:
""" Return list of prime factors of given integer.
"""
| from typing import List
def candidate(n: int) -> List[int]:
""" Return list of factors of given integer in the descending or ascending order.
Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.
Input number should be equal to the product of all factors
>>> candidate(8)
[2, 4, 8]
>>> candidate(25)
[5, 25]
>>> candidate(70)
[2, 10, 70]
"""
| from typing import List
def candidate(n: int) -> List[int]:
""" Return list of factors of given integer.
"""
| null | null | from typing import List
def factorize(n: int) -> List[int]:
""" Return list of prime factors of given integer in the order from smallest to largest.
Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.
Input number should be equal to the product of all factors
>>> factorize(8)
[2, 2, 2]
>>> factorize(25)
[5, 5]
>>> factorize(70)
[2, 5, 7]
"""
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
| [{'input': '2', 'output': '[2]', 'relation': '=='}, {'input': '4', 'output': '[2, 2]', 'relation': '=='}, {'input': '8', 'output': '[2, 2, 2]', 'relation': '=='}, {'input': '3 * 19', 'output': '[3, 19]', 'relation': '=='}, {'input': '3 * 19 * 3 * 19', 'output': '[3, 3, 19, 19]', 'relation': '=='}, {'input': '3 * 19 * 3 * 19 * 3 * 19', 'output': '[3, 3, 3, 19, 19, 19]', 'relation': '=='}, {'input': '3 * 19 * 19 * 19', 'output': '[3, 19, 19, 19]', 'relation': '=='}, {'input': '3 * 2 * 3', 'output': '[2, 3, 3]', 'relation': '=='}] |
remove_duplicates | HumanEval/26 | from typing import List
def remove_duplicates(numbers: List[int]) -> List[int]:
""" From a list of integers, remove all elements that occur more than once.
Keep order of elements left the same as in the input.
>>> remove_duplicates([1, 2, 3, 2, 4])
[1, 3, 4]
"""
| from typing import List
def candidate(numbers: List[int]) -> List[int]:
""" From a list of integers, remove all elements that occur K time(s).
Keep order of elements left the same as in the input.
>>> candidate([1, 2, 3, 2, 4])
[1, 3, 4]
"""
| from typing import List
def remove_duplicates(numbers: List[int]) -> List[int]:
""" From a list of integers, remove all elements that occur more than once.
Keep order of elements left the same as in the input.
>>> remove_duplicates([1, 2, 3, 2, 4])
[1, 2, 3, 4]
"""
| from typing import List
def candidate(numbers: List[int]) -> List[int]:
""" From a list of integers, remove all elements that occur.
"""
| from typing import List
def candidate(numbers: List[int]) -> List[int]:
""" From a list of integers, remove all elements that occur K time(s).
Keep order of elements left the same as in the input.
>>> candidate([1, 2, 3, 2, 4])
[1, 2, 3, 4]
"""
| from typing import List
def candidate(numbers: List[int]) -> List[int]:
""" From a list of integers, remove all elements that occur K time(s).
"""
| null | null | from typing import List
def remove_duplicates(numbers: List[int]) -> List[int]:
""" From a list of integers, remove all elements that occur more than once.
Keep order of elements left the same as in the input.
>>> remove_duplicates([1, 2, 3, 2, 4])
[1, 3, 4]
"""
import collections
c = collections.Counter(numbers)
return [n for n in numbers if c[n] <= 1]
| [{'input': '[]', 'output': '[]', 'relation': '=='}, {'input': '[1, 2, 3, 4]', 'output': '[1, 2, 3, 4]', 'relation': '=='}, {'input': '[1, 2, 3, 2, 4, 3, 5]', 'output': '[1, 4, 5]', 'relation': '=='}] |
flip_case | HumanEval/27 |
def flip_case(string: str) -> str:
""" For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
>>> flip_case('Hello')
'hELLO'
"""
|
def candidate(string: str) -> str:
""" For a given string, flip lowercase or uppercase characters to either uppercase or lowercase.
>>> candidate('Hello')
'hELLO'
"""
|
def flip_case(string: str) -> str:
""" For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
>>> flip_case('Hello')
'hello'
"""
|
def candidate(string: str) -> str:
""" For a given string, flip lowercase characters to uppercase.
"""
|
def candidate(string: str) -> str:
""" For a given string, flip lowercase or uppercase characters to either uppercase or lowercase.
>>> candidate('Hello')
'hello'
"""
|
def candidate(string: str) -> str:
""" For a given string, flip lowercase or uppercase characters to either uppercase or lowercase.
"""
| null | null |
def flip_case(string: str) -> str:
""" For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
>>> flip_case('Hello')
'hELLO'
"""
return string.swapcase()
| [{'input': "''", 'output': '', 'relation': '=='}, {'input': "'Hello!'", 'output': 'hELLO!', 'relation': '=='}, {'input': "'These violent delights have violent ends'", 'output': 'tHESE VIOLENT DELIGHTS HAVE VIOLENT ENDS', 'relation': '=='}] |
concatenate | HumanEval/28 | from typing import List
def concatenate(strings: List[str]) -> str:
""" Concatenate list of strings into a single string
>>> concatenate([])
''
>>> concatenate(['a', 'b', 'c'])
'abc'
"""
| from typing import List
def candidate(strings: List[str]) -> str:
""" Concatenate list of strings into a single string with space or without space
>>> candidate([])
''
>>> candidate(['a', 'b', 'c'])
'abc'
"""
| from typing import List
def concatenate(strings: List[str]) -> str:
""" Concatenate list of strings into a single string
>>> concatenate([])
''
>>> concatenate(['a', 'b', 'c'])
'c b a'
"""
| from typing import List
def candidate(strings: List[str]) -> str:
""" Concatenate
"""
| from typing import List
def candidate(strings: List[str]) -> str:
""" Concatenate list of strings into a single string with space or without space
>>> candidate([])
''
>>> candidate(['a', 'b', 'c'])
'c b a'
"""
| null | null | null | from typing import List
def concatenate(strings: List[str]) -> str:
""" Concatenate list of strings into a single string
>>> concatenate([])
''
>>> concatenate(['a', 'b', 'c'])
'abc'
"""
return ''.join(strings)
| [{'input': '[]', 'output': '', 'relation': '=='}, {'input': "['x', 'y', 'z']", 'output': 'xyz', 'relation': '=='}, {'input': "['x', 'y', 'z', 'w', 'k']", 'output': 'xyzwk', 'relation': '=='}] |
filter_by_prefix | 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.
>>> filter_by_prefix([], 'a')
[]
>>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a')
['abc', 'array']
"""
| from typing import List
def candidate(strings: List[str], prefix: str) -> List[str]:
""" Filter an input list of strings only for ones that satisfy certain condition with a given prefix.
>>> candidate([], 'a')
[]
>>> candidate(['abc', 'bcd', 'cde', 'array'], 'a')
['abc', 'array']
"""
| 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.
>>> filter_by_prefix([], 'a')
[]
>>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a')
['bcd', 'cde']
"""
| from typing import List
def candidate(strings: List[str], x: str) -> List[str]:
""" Filter an input list of strings only for ones.
"""
| from typing import List
def candidate(strings: List[str], prefix: str) -> List[str]:
""" Filter an input list of strings only for ones that satisfy certain condition with a given prefix.
>>> candidate([], 'a')
[]
>>> candidate(['abc', 'bcd', 'cde', 'array'], 'a')
['bcd', 'cde']
"""
| null | null | null | 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.
>>> filter_by_prefix([], 'a')
[]
>>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a')
['abc', 'array']
"""
return [x for x in strings if x.startswith(prefix)]
| [{'input': "[], 'john'", 'output': '[]', 'relation': '=='}, {'input': "['xxx', 'asd', 'xxy', 'john doe', 'xxxAAA', 'xxx'], 'xxx'", 'output': "['xxx', 'xxxAAA', 'xxx']", 'relation': '=='}] |
get_positive | HumanEval/30 |
def get_positive(l: list):
"""Return only positive numbers in the list.
>>> get_positive([-1, 2, -4, 5, 6])
[2, 5, 6]
>>> get_positive([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
[5, 3, 2, 3, 9, 123, 1]
"""
|
def candidate(l: list):
"""Return only negative or positive numbers in the list.
>>> candidate([-1, 2, -4, 5, 6])
[2, 5, 6]
>>> candidate([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
[5, 3, 2, 3, 9, 123, 1]
"""
|
def get_positive(l: list):
"""Return only positive numbers in the list.
>>> get_positive([-1, 2, -4, 5, 6])
[-1, -4]
>>> get_positive([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
[-5, -3, -10]
"""
|
def candidate(l: list):
"""
>>> candidate([-1, 2, -4, 5, 6])
[2, 5, 6]
>>> candidate([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
[5, 3, 2, 3, 9, 123, 1]
"""
|
def candidate(l: list):
"""Return only negative or positive numbers in the list.
>>> candidate([-1, 2, -4, 5, 6])
[-1, -4]
>>> candidate([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
[-5, -3, -10]
"""
| null |
def candidate(l: list):
"""
>>> candidate([-1, 2, -4, 5, 6])
[-1, -4]
>>> candidate([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
[-5, -3, -10]
"""
| null |
def get_positive(l: list):
"""Return only positive numbers in the list.
>>> get_positive([-1, 2, -4, 5, 6])
[2, 5, 6]
>>> get_positive([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
[5, 3, 2, 3, 9, 123, 1]
"""
return [e for e in l if e > 0]
| [{'input': '[-1, -2, 4, 5, 6]', 'output': '[4, 5, 6]', 'relation': '=='}, {'input': '[5, 3, -5, 2, 3, 3, 9, 0, 123, 1, -10]', 'output': '[5, 3, 2, 3, 3, 9, 123, 1]', 'relation': '=='}, {'input': '[-1, -2]', 'output': '[]', 'relation': '=='}, {'input': '[]', 'output': '[]', 'relation': '=='}] |
is_prime | HumanEval/31 |
def is_prime(n):
"""Return true if a given number is prime, and false otherwise.
>>> is_prime(6)
False
>>> is_prime(101)
True
>>> is_prime(11)
True
>>> is_prime(13441)
True
>>> is_prime(61)
True
>>> is_prime(4)
False
>>> is_prime(1)
False
"""
|
def candidate(n):
"""Return true if a given number is composite or prime, and false otherwise.
>>> candidate(6)
False
>>> candidate(101)
True
>>> candidate(11)
True
>>> candidate(13441)
True
>>> candidate(61)
True
>>> candidate(4)
False
>>> candidate(1)
False
"""
|
def is_prime(n):
"""Return true if a given number is prime, and false otherwise.
>>> is_prime(6)
True
>>> is_prime(101)
False
>>> is_prime(11)
False
>>> is_prime(13441)
False
>>> is_prime(61)
False
>>> is_prime(4)
True
>>> is_prime(1)
True
"""
|
def candidate(n):
"""Return true, and false otherwise.
"""
|
def candidate(n):
"""Return true if a given number is composite or prime, and false otherwise.
>>> candidate(6)
True
>>> candidate(101)
False
>>> candidate(11)
False
>>> candidate(13441)
False
>>> candidate(61)
False
>>> candidate(4)
True
>>> candidate(1)
True
"""
| null | null | null |
def is_prime(n):
"""Return true if a given number is prime, and false otherwise.
>>> is_prime(6)
False
>>> is_prime(101)
True
>>> is_prime(11)
True
>>> is_prime(13441)
True
>>> is_prime(61)
True
>>> is_prime(4)
False
>>> is_prime(1)
False
"""
if n < 2:
return False
for k in range(2, n - 1):
if n % k == 0:
return False
return True
| [{'input': '6', 'output': 'False', 'relation': '=='}, {'input': '101', 'output': 'True', 'relation': '=='}, {'input': '11', 'output': 'True', 'relation': '=='}, {'input': '13441', 'output': 'True', 'relation': '=='}, {'input': '61', 'output': 'True', 'relation': '=='}, {'input': '4', 'output': 'False', 'relation': '=='}, {'input': '1', 'output': 'False', 'relation': '=='}, {'input': '5', 'output': 'True', 'relation': '=='}, {'input': '11', 'output': 'True', 'relation': '=='}, {'input': '17', 'output': 'True', 'relation': '=='}, {'input': '5 * 17', 'output': 'False', 'relation': '=='}, {'input': '11 * 7', 'output': 'False', 'relation': '=='}, {'input': '13441 * 19', 'output': 'False', 'relation': '=='}] |
find_zero | HumanEval/32 | import math
def poly(xs: list, x: 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):
""" xs are coefficients of a polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
| import math
def poly(xs: list, x: 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 candidate(xs: list):
""" xs are coefficients of a polynomial.
candidate find x such that poly(x) is positive or negative or 0.
candidate returns only only zero point, even if there are many.
Moreover, candidate only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(candidate([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(candidate([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
| import math
def poly(xs: list, x: 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):
""" xs are coefficients of a polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-3.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
0.0
"""
| import math
def poly(xs: list, x: 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):
""" xs are coefficients of a polynomial.
find_zero find x.
"""
| import math
def poly(xs: list, x: 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 candidate(xs: list):
""" xs are coefficients of a polynomial.
candidate find x such that poly(x) is positive or negative or 0.
candidate returns only only zero point, even if there are many.
Moreover, candidate only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(candidate([1, 2]), 2) # f(x) = 1 + 2x
-3.5
>>> round(candidate([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
0.0
"""
| null | null | null | import math
def poly(xs: list, x: 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):
""" xs are coefficients of a polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
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
| [{'input': [-10, -2], 'output': 1.1641532182693481e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-3, -6, -7, 7], 'output': 9.76619674020185e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [8, 3], 'output': 5.820766091346741e-11, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-10, -8], 'output': 4.656612873077393e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-3, 6, 9, -10], 'output': 1.337379096355562e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [10, 7, 3, -3], 'output': 1.3840022461408807e-09, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [8, -2, -10, -5, 3, 1, -2, -6], 'output': 6.92455426332117e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [1, -7, -8, 2], 'output': 2.1342083655895294e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [1, 1], 'output': 0.0, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-9, 4, 7, -7, 2, -8], 'output': 1.1405965061328516e-09, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [10, 9, 1, 8, -4, -8], 'output': 4.0877967677488414e-11, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-3, -1], 'output': 5.820766091346741e-11, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-3, -7], 'output': 5.820766091346741e-11, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-2, 4, 10, 1, -5, 1, 1, -4], 'output': 4.5996983999430086e-11, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [10, -8, 9, 10, -5, 7], 'output': 4.412106235918145e-09, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-5, 4, 2, -2], 'output': 7.292131343206165e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [1, -9, -3, -9], 'output': 1.7145054993783493e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [2, -2, -8, -4, 8, 1], 'output': 3.6866111552402714e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [10, 5, 2, 10], 'output': 1.015466821741029e-09, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-6, -2, -6, -3, 7, 7, -2, 8], 'output': 2.469873194854699e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [8, 2, 1, -3, -6, 6, 5, -8], 'output': 4.654125973502232e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-7, -6], 'output': 1.1641532182693481e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [3, 9, -8, 2], 'output': 4.748736473492166e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [9, 4, 6, -2, 7, -10, -7, 7], 'output': 1.0656506788109255e-09, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [10, 1, -7, -1, 3, -5], 'output': 6.19443163429878e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-10, -2, 6, -5, 6, -7, 10, -1], 'output': 1.039987151951749e-09, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-6, 1, -5, 7], 'output': 8.558842523598287e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [9, 1], 'output': 5.820766091346741e-11, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-10, -7, 1, -1, -3, -9, -3, 8], 'output': 9.059419880941277e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-8, 5], 'output': 1.1641532182693481e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [7, -6], 'output': 2.3283064365386963e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [5, 7, -5, -2], 'output': 3.864730757641155e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-4, 7, -4, -1, 2, 10, 1, 4], 'output': 1.152398176884617e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-7, -3, -3, -8, 1, -10, 8, 7], 'output': 1.1465629556894896e-09, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [8, -3, -10, -8], 'output': 8.052962741089686e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-3, -8], 'output': 4.656612873077393e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [1, -8], 'output': 4.656612873077393e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-2, 5, -4, 7], 'output': 2.8748137204104296e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [8, 8, 5, -3], 'output': 7.751452812954085e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [3, -4, -7, -7, 3, 1, 3, 3], 'output': 3.0882091502093534e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-9, 10, 10, -7, -9, 2, 1, -7], 'output': 2.323840675444444e-09, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-4, -4, 7, 4], 'output': 0.0, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [3, -5, -2, 4], 'output': 2.471778337564956e-11, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-8, 4, 7, -7], 'output': 5.787530454881562e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [10, 7], 'output': 5.820766091346741e-11, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-8, -3], 'output': 5.820766091346741e-11, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [3, 5, 5, -4], 'output': 4.028066769024008e-11, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-9, -5, 2, -10, 2, -2, 4, -1], 'output': 1.2186199688235533e-09, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [7, 5, -6, -4, -1, -4, -9, 8], 'output': 7.55201901014857e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [1, -9], 'output': 4.0745362639427185e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [8, 5], 'output': 1.7462298274040222e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-9, 6, -8, -5], 'output': 7.17989223630866e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [9, -8], 'output': 4.656612873077393e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [2, -7, 8, -3], 'output': 1.2934986415302774e-11, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [9, -8], 'output': 4.656612873077393e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [8, 8, 6, 1, -2, -4, 1, -3], 'output': 8.968825682131865e-11, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [2, -6, 10, -1, 4, 1], 'output': 1.2246800906723365e-08, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-10, 4], 'output': 2.3283064365386963e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-8, 7], 'output': 1.1641532182693481e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [6, -2, -6, 1], 'output': 4.1145209461745935e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-3, 1], 'output': 5.820766091346741e-11, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-5, 4, 7, -1, 9, 10], 'output': 2.8451518918615193e-11, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [7, -1], 'output': 5.820766091346741e-11, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-6, -2], 'output': 1.1641532182693481e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-7, 7], 'output': 4.0745362639427185e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-2, -1, 9, -4], 'output': 5.314582107729393e-12, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-4, 10, -2, 6, 5, -2], 'output': 5.341000801351026e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-8, 10], 'output': 1.1641532182693481e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-2, -9, -10, 1, -6, 10, -2, -5], 'output': 1.4370016288012266e-08, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [7, 3, 7, -10, -7, -8, -6, 7], 'output': 1.0816925133383393e-09, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [1, 8], 'output': 4.656612873077393e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [3, -6, -9, -1], 'output': 4.090063773776187e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-9, 1, -4, -3, -7, 1], 'output': 6.964910426177084e-08, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [9, -6, -3, -5, -5, 3, -10, -5], 'output': 1.3005894139439533e-09, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [3, -3, -2, -5, -7, 2], 'output': 0.0, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [5, -3], 'output': 1.1641532182693481e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [4, 1, -1, -3], 'output': 1.2522427539352066e-11, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-10, -4, 2, 1], 'output': 7.0775918459276e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-8, -2, 1, 10, 6, 2], 'output': 1.0347153134304676e-09, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-10, -7, -2, -5, 8, -2], 'output': 4.458877711499554e-12, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-7, 9], 'output': 2.3283064365386963e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [1, 1, 3, 9, 6, -7, 2, 8], 'output': 6.708447131131834e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-2, -9, 3, -10], 'output': 1.3271347909515896e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [1, 3, -8, 1], 'output': 9.151792171313566e-11, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-7, -1, 6, -1, 3, 1], 'output': 9.165997960636219e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-1, 7, -6, -4, 3, 2, -5, 9], 'output': 1.2270528522298832e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [2, 7, -10, -1, -1, -4], 'output': 8.104050763790838e-11, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [8, 9, 10, 1, 4, 4, 4, -4], 'output': 2.9445686777762603e-08, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-5, -8, -1, 6, 10, 9, 1, -8], 'output': 2.796114451086851e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-1, -3, -4, -6], 'output': 8.562428543967826e-11, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-9, -3], 'output': 1.7462298274040222e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [9, -8, 4, 3, 10, 8, -4, 2], 'output': 4.614358672938579e-09, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [2, -3, -6, 10, -10, -7, 3, -3], 'output': 2.5733340805467186e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [6, 4, -9, 7], 'output': 4.689382215872229e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-7, 4, -6, 4], 'output': 9.2210683533267e-12, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [4, 9, 6, 3, 7, 4], 'output': 2.5149304860860866e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [5, 4, -2, -3], 'output': 1.9339907453286287e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [6, 5, 10, -3, -2, 4], 'output': 1.9849579757647007e-09, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [-1, -3], 'output': 1.1641532182693481e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}, {'input': [1, 1, 7, -8, -6, -6], 'output': 4.970059919173764e-10, 'relation': 'from $demo$ import poly\nimport math\nsolution = find_zero($input$)\nprint(math.fabs(poly($input$, solution)) < 1e-4)'}] |
sort_third | HumanEval/33 |
def sort_third(l: list):
"""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 corresponding indicies of l, but sorted.
>>> sort_third([1, 2, 3])
[1, 2, 3]
>>> sort_third([5, 6, 3, 4, 8, 9, 2])
[2, 6, 3, 4, 8, 9, 5]
"""
|
def candidate(l: list):
"""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 corresponding indicies of l, but sorted descendingly or ascendingly.
>>> candidate([1, 2, 3])
[1, 2, 3]
>>> candidate([5, 6, 3, 4, 8, 9, 2])
[2, 6, 3, 4, 8, 9, 5]
"""
|
def sort_third(l: list):
"""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 corresponding indicies of l, but sorted.
>>> sort_third([1, 2, 3])
[3, 2, 1]
>>> sort_third([5, 6, 3, 4, 8, 9, 2])
[9, 8, 6, 5, 4, 3, 2]
"""
|
def candidate(l: list):
"""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 corresponding indicies of l.
"""
|
def candidate(l: list):
"""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 corresponding indicies of l, but sorted descendingly or ascendingly.
>>> candidate([1, 2, 3])
[3, 2, 1]
>>> candidate([5, 6, 3, 4, 8, 9, 2])
[9, 8, 6, 5, 4, 3, 2]
"""
| null | null | null |
def sort_third(l: list):
"""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 corresponding indicies of l, but sorted.
>>> sort_third([1, 2, 3])
[1, 2, 3]
>>> sort_third([5, 6, 3, 4, 8, 9, 2])
[2, 6, 3, 4, 8, 9, 5]
"""
l = list(l)
l[::3] = sorted(l[::3])
return l
| [{'input': '[5, 6, 3, 4, 8, 9, 2]', 'output': '[2, 6, 3, 4, 8, 9, 5]', 'relation': '=='}, {'input': '[5, 8, 3, 4, 6, 9, 2]', 'output': '[2, 8, 3, 4, 6, 9, 5]', 'relation': '=='}, {'input': '[5, 6, 9, 4, 8, 3, 2]', 'output': '[2, 6, 9, 4, 8, 3, 5]', 'relation': '=='}, {'input': '[5, 6, 3, 4, 8, 9, 2, 1]', 'output': '[2, 6, 3, 4, 8, 9, 5, 1]', 'relation': '=='}] |
unique | HumanEval/34 |
def unique(l: list):
"""Return sorted unique elements in a list
>>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123])
[0, 2, 3, 5, 9, 123]
"""
|
def candidate(l: list):
"""Return descending or ascending sorted unique elements in a list
>>> candidate([5, 3, 5, 2, 3, 3, 9, 0, 123])
[0, 2, 3, 5, 9, 123]
"""
|
def unique(l: list):
"""Return sorted unique elements in a list
>>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123])
[3, 5, 9, 123]
"""
|
def candidate(l: list):
"""Return elements in a list
"""
|
def candidate(l: list):
"""Return descending or ascending sorted unique elements in a list
>>> candidate([5, 3, 5, 2, 3, 3, 9, 0, 123])
[3, 5, 9, 123]
"""
| null | null | null |
def unique(l: list):
"""Return sorted unique elements in a list
>>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123])
[0, 2, 3, 5, 9, 123]
"""
return sorted(list(set(l)))
| [{'input': '[5, 3, 5, 2, 3, 3, 9, 0, 123]', 'output': '[0, 2, 3, 5, 9, 123]', 'relation': '=='}] |
max_element | HumanEval/35 |
def max_element(l: list):
"""Return maximum element in the list.
>>> max_element([1, 2, 3])
3
>>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
123
"""
|
def candidate(l: list):
"""Return a certain element in the list.
>>> candidate([1, 2, 3])
3
>>> candidate([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
123
"""
|
def max_element(l: list):
"""Return maximum element in the list.
>>> max_element([1, 2, 3])
1
>>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
-10
"""
|
def candidate(l: list):
"""Return element in the list.
"""
|
def candidate(l: list):
"""Return a certain element in the list.
>>> candidate([1, 2, 3])
1
>>> candidate([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
-10
"""
| null | null | null |
def max_element(l: list):
"""Return maximum element in the list.
>>> max_element([1, 2, 3])
3
>>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
123
"""
m = l[0]
for e in l:
if e > m:
m = e
return m
| [{'input': '[1, 2, 3]', 'output': '3', 'relation': '=='}, {'input': '[5, 3, -5, 2, -3, 3, 9, 0, 124, 1, -10]', 'output': '124', 'relation': '=='}] |
fizz_buzz | HumanEval/36 |
def fizz_buzz(n: int):
"""Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
>>> fizz_buzz(50)
0
>>> fizz_buzz(78)
2
>>> fizz_buzz(79)
3
"""
|
def candidate(n: int):
"""Return the number of times the digit 7 appears in integers less than k or n*n or n which are divisible by 11 or 13.
>>> candidate(50)
0
>>> candidate(78)
2
>>> candidate(79)
3
"""
|
def fizz_buzz(n: int):
"""Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
>>> fizz_buzz(50)
2
>>> fizz_buzz(78)
4
>>> fizz_buzz(79)
4
"""
|
def fizz_buzz(n: int):
"""Return the number of times the digit 7 appears in integers less than n which are divisible.
"""
|
def candidate(n: int):
"""Return the number of times the digit 7 appears in integers less than k or n*n or n which are divisible by 11 or 13.
>>> candidate(50)
2
>>> candidate(78)
4
>>> candidate(79)
4
"""
| null | null | null |
def fizz_buzz(n: int):
"""Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
>>> fizz_buzz(50)
0
>>> fizz_buzz(78)
2
>>> fizz_buzz(79)
3
"""
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
| [{'input': '50', 'output': '0', 'relation': '=='}, {'input': '78', 'output': '2', 'relation': '=='}, {'input': '79', 'output': '3', 'relation': '=='}, {'input': '100', 'output': '3', 'relation': '=='}, {'input': '200', 'output': '6', 'relation': '=='}, {'input': '4000', 'output': '192', 'relation': '=='}, {'input': '10000', 'output': '639', 'relation': '=='}, {'input': '100000', 'output': '8026', 'relation': '=='}] |
sort_even | HumanEval/37 |
def sort_even(l: list):
"""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.
>>> sort_even([1, 2, 3])
[1, 2, 3]
>>> sort_even([5, 6, 3, 4])
[3, 6, 5, 4]
"""
|
def candidate(l: list):
"""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 descendingly or ascendingly.
>>> candidate([1, 2, 3])
[1, 2, 3]
>>> candidate([5, 6, 3, 4])
[3, 6, 5, 4]
"""
|
def sort_even(l: list):
"""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.
>>> sort_even([1, 2, 3])
[3, 2, 1]
>>> sort_even([5, 6, 3, 4])
[6, 5, 4, 3]
"""
|
def candidate(l: list):
"""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.
"""
|
def candidate(l: list):
"""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 descendingly or ascendingly.
>>> candidate([1, 2, 3])
[3, 2, 1]
>>> candidate([5, 6, 3, 4])
[6, 5, 4, 3]
"""
| null | null | null |
def sort_even(l: list):
"""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.
>>> sort_even([1, 2, 3])
[1, 2, 3]
>>> sort_even([5, 6, 3, 4])
[3, 6, 5, 4]
"""
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
| [{'input': '[1, 2, 3]', 'output': '[1, 2, 3]', 'relation': '=='}, {'input': '[5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]', 'output': '[-10, 3, -5, 2, -3, 3, 5, 0, 9, 1, 123]', 'relation': '=='}, {'input': '[5, 8, -12, 4, 23, 2, 3, 11, 12, -10]', 'output': '[-12, 8, 3, 4, 5, 2, 12, 11, 23, -10]', 'relation': '=='}] |
decode_cyclic | HumanEval/38 |
def encode_cyclic(s: 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 fewer elements than 3.
groups = [(group[1:] + group[0]) if len(group) == 3 else group for group in groups]
return "".join(groups)
def decode_cyclic(s: str):
"""
takes as input string encoded with encode_cyclic function. Returns decoded string.
"""
|
def encode_cyclic(s: 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 fewer elements than 3.
groups = [(group[1:] + group[0]) if len(group) == 3 else group for group in groups]
return "".join(groups)
def candidate(s: str):
"""
takes as input string encoded with encode_cyclic function. Returns encoded or decoded string.
"""
|
def encode_cyclic(s: 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 fewer elements than 3.
groups = [(group[1:] + group[0]) if len(group) == 3 else group for group in groups]
return "".join(groups)
def decode_cyclic(s: str):
"""
takes as input string decoded with encode_cyclic function. Returns encoded string.
"""
|
def encode_cyclic(s: 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 fewer elements than 3.
groups = [(group[1:] + group[0]) if len(group) == 3 else group for group in groups]
return "".join(groups)
def candidate(s: str):
"""
takes as input string encoded with encode_cyclic function.
"""
|
def encode_cyclic(s: 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 fewer elements than 3.
groups = [(group[1:] + group[0]) if len(group) == 3 else group for group in groups]
return "".join(groups)
def candidate(s: str):
"""
takes as input string decoded with encode_cyclic function. Returns encoded or decoded string.
"""
| null | null | null |
def encode_cyclic(s: 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 fewer elements than 3.
groups = [(group[1:] + group[0]) if len(group) == 3 else group for group in groups]
return "".join(groups)
def decode_cyclic(s: str):
"""
takes as input string encoded with encode_cyclic function. Returns decoded string.
"""
return encode_cyclic(encode_cyclic(s))
| [{'input': "'axdhhixdexrvsncacbgh'", 'output': 'daxihhexdvxrcsnbacgh', 'relation': '=='}, {'input': "'artwugrnwoshzaizfy'", 'output': 'targwuwrnhosizayzf', 'relation': '=='}, {'input': "'iekykgcmdlldiztb'", 'output': 'kiegykdcmdlltizb', 'relation': '=='}, {'input': "'dmrrjctlugwsbvchy'", 'output': 'rdmcrjutlsgwcbvhy', 'relation': '=='}, {'input': "'hdciomlfulglvi'", 'output': 'chdmioulfllgvi', 'relation': '=='}, {'input': "'ctufruhfxmiowruvkhyy'", 'output': 'uctufrxhfomiuwrhvkyy', 'relation': '=='}, {'input': "'bzhmikgscw'", 'output': 'hbzkmicgsw', 'relation': '=='}, {'input': "'upguomieexrhixr'", 'output': 'gupmuoeiehxrrix', 'relation': '=='}, {'input': "'smnhelpcqbdyufevnzt'", 'output': 'nsmlheqpcybdeufzvnt', 'relation': '=='}, {'input': "'mtmqioavrxd'", 'output': 'mmtoqiravxd', 'relation': '=='}, {'input': "'yirukyjndoafxixyfqqd'", 'output': 'ryiyukdjnfoaxxiqyfqd', 'relation': '=='}, {'input': "'uqjgetyflyqrtkaadplz'", 'output': 'juqtgelyfryqatkpadlz', 'relation': '=='}, {'input': "'bhhccspcxryyee'", 'output': 'hbhsccxpcyryee', 'relation': '=='}, {'input': "'rfpqtigrnxwywjgvumlo'", 'output': 'prfiqtngryxwgwjmvulo', 'relation': '=='}, {'input': "'dhockhsrashhcwabhu'", 'output': 'odhhckasrhshacwubh', 'relation': '=='}, {'input': "'kcbhiqpgvre'", 'output': 'bkcqhivpgre', 'relation': '=='}, {'input': "'phspzzgdnvndnnlxbov'", 'output': 'sphzpzngddvnlnnoxbv', 'relation': '=='}, {'input': "'dbuxkmdhzgrgenoiofhc'", 'output': 'udbmxkzdhggroenfiohc', 'relation': '=='}, {'input': "'rdzurbcyafnhpgpmb'", 'output': 'zrdburacyhfnppgmb', 'relation': '=='}, {'input': "'ammzzijnoxzw'", 'output': 'mamizzojnwxz', 'relation': '=='}, {'input': "'wpvgjebsgrbxkbxspb'", 'output': 'vwpegjgbsxrbxkbbsp', 'relation': '=='}, {'input': "'fbqcfqtcchmvshdtbs'", 'output': 'qfbqcfctcvhmdshstb', 'relation': '=='}, {'input': "'nvcsqsigkwkvimhvuej'", 'output': 'cnvssqkigvwkhimevuj', 'relation': '=='}, {'input': "'yckotadcsgqrelich'", 'output': 'kycaotsdcrgqielch', 'relation': '=='}, {'input': "'fojwjrzutavqjvr'", 'output': 'jforwjtzuqavrjv', 'relation': '=='}, {'input': "'idexrdijetg'", 'output': 'eiddxreijtg', 'relation': '=='}, {'input': "'vugqpibciniuakb'", 'output': 'gvuiqpibcunibak', 'relation': '=='}, {'input': "'ifuorxnrwdca'", 'output': 'uifxorwnradc', 'relation': '=='}, {'input': "'blrresebnlzj'", 'output': 'rblsrenebjlz', 'relation': '=='}, {'input': "'gvlvdhyrln'", 'output': 'lgvhvdlyrn', 'relation': '=='}, {'input': "'ehxzzfnafxkfnzzxzvh'", 'output': 'xehfzzfnafxkznzvxzh', 'relation': '=='}, {'input': "'zwfmbdhgpljozh'", 'output': 'fzwdmbphgoljzh', 'relation': '=='}, {'input': "'vgakimyicuqlm'", 'output': 'avgmkicyiluqm', 'relation': '=='}, {'input': "'karifdibstndxzlntkqd'", 'output': 'rkadifsibdtnlxzkntqd', 'relation': '=='}, {'input': "'giswnbqzavxrxvxg'", 'output': 'sgibwnaqzrvxxxvg', 'relation': '=='}, {'input': "'cvntkkdxvqjjnkv'", 'output': 'ncvktkvdxjqjvnk', 'relation': '=='}, {'input': "'jrwgnemvvftxjmsr'", 'output': 'wjregnvmvxftsjmr', 'relation': '=='}, {'input': "'jgjzsnukto'", 'output': 'jjgnzstuko', 'relation': '=='}, {'input': "'vgopzqxfzcjvvuqtk'", 'output': 'ovgqpzzxfvcjqvutk', 'relation': '=='}, {'input': "'hvyhzjeagbh'", 'output': 'yhvjhzgeabh', 'relation': '=='}, {'input': "'yctnuogwsmpwhemuw'", 'output': 'tyconusgwwmpmheuw', 'relation': '=='}, {'input': "'ydynhyzwfq'", 'output': 'yydynhfzwq', 'relation': '=='}, {'input': "'rhboedovzrtqyoktx'", 'output': 'brhdoezovqrtkyotx', 'relation': '=='}, {'input': "'ronxpfiyouihyqyuhp'", 'output': 'nrofxpoiyhuiyyqpuh', 'relation': '=='}, {'input': "'cwohijkrkeechm'", 'output': 'ocwjhikkrceehm', 'relation': '=='}, {'input': "'gcwnknonrgnb'", 'output': 'wgcnnkronbgn', 'relation': '=='}, {'input': "'swyysapamjylnrmx'", 'output': 'yswaysmpaljymnrx', 'relation': '=='}, {'input': "'thzhippankvmzmvfox'", 'output': 'zthphinpamkvvzmxfo', 'relation': '=='}, {'input': "'ratssmacvneu'", 'output': 'tramssvacune', 'relation': '=='}, {'input': "'bifkgmkkomiyniycp'", 'output': 'fbimkgokkymiynicp', 'relation': '=='}, {'input': "'rbxhulyucb'", 'output': 'xrblhucyub', 'relation': '=='}, {'input': "'gahehtpved'", 'output': 'hgatehepvd', 'relation': '=='}, {'input': "'owgylittfwdxfjysadj'", 'output': 'gowiylfttxwdyfjdsaj', 'relation': '=='}, {'input': "'mmvgcwwusdwhjvyzdtz'", 'output': 'vmmwgcswuhdwyjvtzdz', 'relation': '=='}, {'input': "'blznvrcqlkaupdnluno'", 'output': 'zblrnvlcqukanpdnluo', 'relation': '=='}, {'input': "'fxnuiqzrtpoy'", 'output': 'nfxquitzrypo', 'relation': '=='}, {'input': "'sixhckohiosyvmtk'", 'output': 'xsikhciohyostvmk', 'relation': '=='}, {'input': "'kfpglpikzi'", 'output': 'pkfpglziki', 'relation': '=='}, {'input': "'irwqgahxcprnhwyuwpp'", 'output': 'wiraqgchxnpryhwpuwp', 'relation': '=='}, {'input': "'aczhmjhjwslvrqpln'", 'output': 'zacjhmwhjvslprqln', 'relation': '=='}, {'input': "'lwkijohdigkxxrdwfy'", 'output': 'klwoijihdxgkdxrywf', 'relation': '=='}, {'input': "'xpgxsiqtydgjj'", 'output': 'gxpixsyqtjdgj', 'relation': '=='}, {'input': "'fjlwraiberjbw'", 'output': 'lfjawreibbrjw', 'relation': '=='}, {'input': "'ypuasdppjkfo'", 'output': 'uypdasjppokf', 'relation': '=='}, {'input': "'pdimpcsucv'", 'output': 'ipdcmpcsuv', 'relation': '=='}, {'input': "'ezejcsdrhy'", 'output': 'eezsjchdry', 'relation': '=='}, {'input': "'tzthytmoqjsojsnt'", 'output': 'ttzthyqmoojsnjst', 'relation': '=='}, {'input': "'xdtguyivgc'", 'output': 'txdygugivc', 'relation': '=='}, {'input': "'frhfacownpjt'", 'output': 'hfrcfanowtpj', 'relation': '=='}, {'input': "'jwhwojvhci'", 'output': 'hjwjwocvhi', 'relation': '=='}, {'input': "'vzsndghurieebfcjtzxs'", 'output': 'svzgndrhueiecbfzjtxs', 'relation': '=='}, {'input': "'doojwwiqmporct'", 'output': 'odowjwmiqrpoct', 'relation': '=='}, {'input': "'xkniathvcs'", 'output': 'nxktiachvs', 'relation': '=='}, {'input': "'yvasbiyfyqupifonusp'", 'output': 'ayvisbyyfpquoifsnup', 'relation': '=='}, {'input': "'lnpkvkfkdnw'", 'output': 'plnkkvdfknw', 'relation': '=='}, {'input': "'vmjrbyckokdimqyav'", 'output': 'jvmyrbockikdymqav', 'relation': '=='}, {'input': "'nboqlgyptoyugibejr'", 'output': 'onbgqltypuoybgirej', 'relation': '=='}, {'input': "'pdwutahwzjrfrnach'", 'output': 'wpdautzhwfjrarnch', 'relation': '=='}, {'input': "'duopweqwjin'", 'output': 'oduepwjqwin', 'relation': '=='}, {'input': "'hopemrtqgecxyzink'", 'output': 'phoremgtqxeciyznk', 'relation': '=='}, {'input': "'ajijsxvpsorelkpyrr'", 'output': 'iajxjssvpeorplkryr', 'relation': '=='}, {'input': "'kgohswhymbknpwxz'", 'output': 'okgwhsmhynbkxpwz', 'relation': '=='}, {'input': "'vzmepueqbkdsdqoo'", 'output': 'mvzuepbeqskdodqo', 'relation': '=='}, {'input': "'enxecuzipk'", 'output': 'xenuecpzik', 'relation': '=='}, {'input': "'muwkvcmkrwyurbpchtu'", 'output': 'wmuckvrmkuwyprbtchu', 'relation': '=='}, {'input': "'hxjndcuwyofdjawkzbbj'", 'output': 'jhxcndyuwdofwjabkzbj', 'relation': '=='}, {'input': "'nelqnhvzsffftmc'", 'output': 'lnehqnsvzfffctm', 'relation': '=='}, {'input': "'hpvehsuioivozoavrjf'", 'output': 'vhpsehouioivazojvrf', 'relation': '=='}, {'input': "'lsounjiowjg'", 'output': 'olsjunwiojg', 'relation': '=='}, {'input': "'dhpslmjwsavjiams'", 'output': 'pdhmslsjwjavmias', 'relation': '=='}, {'input': "'xbyxptyzjtzhhultigvy'", 'output': 'yxbtxpjyzhtzlhugtivy', 'relation': '=='}, {'input': "'euvuudjzbbsoxeljkcxn'", 'output': 'veuduubjzobslxecjkxn', 'relation': '=='}, {'input': "'ezglqrifqpzi'", 'output': 'gezrlqqifipz', 'relation': '=='}, {'input': "'kzxocdyhexvvmz'", 'output': 'xkzdoceyhvxvmz', 'relation': '=='}, {'input': "'czlaimdorvxlisvulm'", 'output': 'lczmairdolvxvismul', 'relation': '=='}, {'input': "'hpvtrathkuc'", 'output': 'vhpatrkthuc', 'relation': '=='}, {'input': "'wjondubbepdjhrdmoelv'", 'output': 'owjundebbjpddhremolv', 'relation': '=='}, {'input': "'sxnenxdpunitwlboog'", 'output': 'nsxxenudptnibwlgoo', 'relation': '=='}, {'input': "'dvlrulbmlgdio'", 'output': 'ldvlrulbmigdo', 'relation': '=='}, {'input': "'guvtauzkbhe'", 'output': 'vguutabzkhe', 'relation': '=='}] |
prime_fib | HumanEval/39 |
def prime_fib(n: int):
"""
prime_fib returns n-th number that is a Fibonacci number and it's also prime.
>>> prime_fib(1)
2
>>> prime_fib(2)
3
>>> prime_fib(3)
5
>>> prime_fib(4)
13
>>> prime_fib(5)
89
"""
|
def candidate(n: int):
"""
candidate returns n-th number that is a Fibonacci number and it's also prime or composite.
>>> candidate(1)
2
>>> candidate(2)
3
>>> candidate(3)
5
>>> candidate(4)
13
>>> candidate(5)
89
"""
|
def prime_fib(n: int):
"""
prime_fib returns n-th number that is a Fibonacci number and it's also prime.
>>> prime_fib(1)
20
>>> prime_fib(2)
30
>>> prime_fib(3)
50
>>> prime_fib(4)
130
>>> prime_fib(5)
890
"""
|
def candidate(n: int):
"""
candidate returns n-th number that is a Fibonacci number.
"""
|
def candidate(n: int):
"""
candidate returns n-th number that is a Fibonacci number and it's also prime or composite.
>>> candidate(1)
20
>>> candidate(2)
30
>>> candidate(3)
50
>>> candidate(4)
130
>>> candidate(5)
890
"""
| null | null | null |
def prime_fib(n: int):
"""
prime_fib returns n-th number that is a Fibonacci number and it's also prime.
>>> prime_fib(1)
2
>>> prime_fib(2)
3
>>> prime_fib(3)
5
>>> prime_fib(4)
13
>>> prime_fib(5)
89
"""
import math
def is_prime(p):
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])
if is_prime(f[-1]):
n -= 1
if n == 0:
return f[-1]
| [{'input': '1', 'output': '2', 'relation': '=='}, {'input': '2', 'output': '3', 'relation': '=='}, {'input': '3', 'output': '5', 'relation': '=='}, {'input': '4', 'output': '13', 'relation': '=='}, {'input': '5', 'output': '89', 'relation': '=='}, {'input': '6', 'output': '233', 'relation': '=='}, {'input': '7', 'output': '1597', 'relation': '=='}, {'input': '8', 'output': '28657', 'relation': '=='}, {'input': '9', 'output': '514229', 'relation': '=='}, {'input': '10', 'output': '433494437', 'relation': '=='}] |
triples_sum_to_zero | HumanEval/40 |
def triples_sum_to_zero(l: list):
"""
triples_sum_to_zero takes a list of integers as an input.
it returns True if there are three distinct elements in the list that
sum to zero, and False otherwise.
>>> triples_sum_to_zero([1, 3, 5, 0])
False
>>> triples_sum_to_zero([1, 3, -2, 1])
True
>>> triples_sum_to_zero([1, 2, 3, 7])
False
>>> triples_sum_to_zero([2, 4, -5, 3, 9, 7])
True
>>> triples_sum_to_zero([1])
False
"""
|
def candidate(l: list):
"""
candidate takes a list of integers as an input.
it returns True if there are three elements in a list that
sum to zero and meet a certain condition (such as they are distinct, they are odd, they are prime, or another condition), and False otherwise.
>>> candidate([1, 3, 5, 0])
False
>>> candidate([1, 3, -2, 1])
True
>>> candidate([1, 2, 3, 7])
False
>>> candidate([2, 4, -5, 3, 9, 7])
True
>>> candidate([1])
False
"""
|
def triples_sum_to_zero(l: list):
"""
triples_sum_to_zero takes a list of integers as an input.
it returns True if there are three distinct elements in the list that
sum to zero, and False otherwise.
>>> triples_sum_to_zero([1, 3, 5, 0])
False
>>> triples_sum_to_zero([1, 3, -2, 1])
False
>>> triples_sum_to_zero([1, 2, 3, 7])
True
>>> triples_sum_to_zero([2, 4, -5, 3, 9, 7])
False
>>> triples_sum_to_zero([1])
True
"""
|
def candidate(l: list):
"""
candidate takes a list of integers as an input.
it returns True if there are three distinct elements in the list,
and False otherwise.
"""
|
def candidate(l: list):
"""
candidate takes a list of integers as an input.
it returns True if there are three elements in a list that
sum to zero and meet a certain condition (such as they are distinct, they are odd, they are prime, or another condition), and False otherwise.
>>> candidate([1, 3, 5, 0])
True
>>> candidate([1, 3, -2, 1])
False
>>> candidate([1, 2, 3, 7])
True
>>> candidate([2, 4, -5, 3, 9, 7])
False
>>> candidate([1])
True
"""
| null | null | null |
def triples_sum_to_zero(l: list):
"""
triples_sum_to_zero takes a list of integers as an input.
it returns True if there are three distinct elements in the list that
sum to zero, and False otherwise.
>>> triples_sum_to_zero([1, 3, 5, 0])
False
>>> triples_sum_to_zero([1, 3, -2, 1])
True
>>> triples_sum_to_zero([1, 2, 3, 7])
False
>>> triples_sum_to_zero([2, 4, -5, 3, 9, 7])
True
>>> triples_sum_to_zero([1])
False
"""
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
| [{'input': '[1, 3, 5, 0]', 'output': 'False', 'relation': '=='}, {'input': '[1, 3, 5, -1]', 'output': 'False', 'relation': '=='}, {'input': '[1, 3, -2, 1]', 'output': 'True', 'relation': '=='}, {'input': '[1, 2, 3, 7]', 'output': 'False', 'relation': '=='}, {'input': '[1, 2, 5, 7]', 'output': 'False', 'relation': '=='}, {'input': '[2, 4, -5, 3, 9, 7]', 'output': 'True', 'relation': '=='}, {'input': '[1]', 'output': 'False', 'relation': '=='}, {'input': '[1, 3, 5, -100]', 'output': 'False', 'relation': '=='}, {'input': '[100, 3, 5, -100]', 'output': 'False', 'relation': '=='}] |
car_race_collision | HumanEval/41 |
def car_race_collision(n: 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. The two sets of cars start out being very far from
each other. All cars move in the same speed. Two cars are said to collide
when a car that's moving left to right hits a car that's moving right to left.
However, the cars are infinitely sturdy and strong; as a result, they continue moving
in their trajectory as if they did not collide.
This function outputs the number of such collisions.
"""
|
def car_race_collision(n: int):
"""
Imagine a road that's a perfectly straight infinitely long line.
2*n or n cars are driving left to right; simultaneously, a different set of 2*n or n cars
are driving right to left. The two sets of cars start out being very far from
each other. All cars move in the same speed. Two cars are said to collide
when a car that's moving left to right hits a car that's moving right to left.
However, the cars are infinitely sturdy and strong; as a result, they continue moving
in their trajectory as if they did not collide.
This function outputs the number of such collisions.
"""
|
def is_prime(n: 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. The two sets of cars start out being very far from
each other. All cars move in the same speed. Two cars are said to collide
when a car that's moving left to right hits a car that's moving right to left.
However, the cars are infinitely sturdy and strong; as a result, they continue moving
in their trajectory as if they did not collide.
This function outputs the number of such collisions.
"""
|
def candidate(n: 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. The two sets of cars start out being very far from
each other. All cars move in the same speed. Two cars are said to collide
"""
|
def is_prime(n: int):
"""
Imagine a road that's a perfectly straight infinitely long line.
2*n or n cars are driving left to right; simultaneously, a different set of 2*n or n cars
are driving right to left. The two sets of cars start out being very far from
each other. All cars move in the same speed. Two cars are said to collide
when a car that's moving left to right hits a car that's moving right to left.
However, the cars are infinitely sturdy and strong; as a result, they continue moving
in their trajectory as if they did not collide.
This function outputs the number of such collisions.
"""
|
def candidate(n: int):
"""
Imagine a road that's a perfectly straight infinitely long line.
2*n or n cars are driving left to right; simultaneously, a different set of 2*n or n cars
are driving right to left. The two sets of cars start out being very far from
each other. All cars move in the same speed. Two cars are said to collide
"""
|
def is_prime(n: 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. The two sets of cars start out being very far from
each other. All cars move in the same speed. Two cars are said to collide
"""
|
def is_prime(n: int):
"""
Imagine a road that's a perfectly straight infinitely long line.
2*n or n cars are driving left to right; simultaneously, a different set of 2*n or n cars
are driving right to left. The two sets of cars start out being very far from
each other. All cars move in the same speed. Two cars are said to collide
"""
|
def car_race_collision(n: 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. The two sets of cars start out being very far from
each other. All cars move in the same speed. Two cars are said to collide
when a car that's moving left to right hits a car that's moving right to left.
However, the cars are infinitely sturdy and strong; as a result, they continue moving
in their trajectory as if they did not collide.
This function outputs the number of such collisions.
"""
return n**2
| [{'input': '2', 'output': '4', 'relation': '=='}, {'input': '3', 'output': '9', 'relation': '=='}, {'input': '4', 'output': '16', 'relation': '=='}, {'input': '8', 'output': '64', 'relation': '=='}, {'input': '10', 'output': '100', 'relation': '=='}] |
incr_list | HumanEval/42 |
def incr_list(l: list):
"""Return list with elements incremented by 1.
>>> incr_list([1, 2, 3])
[2, 3, 4]
>>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123])
[6, 4, 6, 3, 4, 4, 10, 1, 124]
"""
|
def incr_list(l: list):
"""Return list with elements incremented by a number.
>>> incr_list([1, 2, 3])
[2, 3, 4]
>>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123])
[6, 4, 6, 3, 4, 4, 10, 1, 124]
"""
|
def incr_list(l: list):
"""Return list with elements incremented by 1.
>>> incr_list([1, 2, 3])
[3, 4, 5]
>>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123])
[7, 5, 7, 4, 5, 5, 11, 2, 125]
"""
|
def incr_list(l: list):
"""Return list with elements incremented.
"""
|
def incr_list(l: list):
"""Return list with elements incremented by a number.
>>> incr_list([1, 2, 3])
[3, 4, 5]
>>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123])
[7, 5, 7, 4, 5, 5, 11, 2, 125]
"""
| null | null | null |
def incr_list(l: list):
"""Return list with elements incremented by 1.
>>> incr_list([1, 2, 3])
[2, 3, 4]
>>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123])
[6, 4, 6, 3, 4, 4, 10, 1, 124]
"""
return [(e + 1) for e in l]
| [{'input': '[]', 'output': '[]', 'relation': '=='}, {'input': '[3, 2, 1]', 'output': '[4, 3, 2]', 'relation': '=='}, {'input': '[5, 2, 5, 2, 3, 3, 9, 0, 123]', 'output': '[6, 3, 6, 3, 4, 4, 10, 1, 124]', 'relation': '=='}] |
pairs_sum_to_zero | HumanEval/43 |
def pairs_sum_to_zero(l):
"""
pairs_sum_to_zero takes a list of integers as an input.
it returns True if there are two distinct elements in the list that
sum to zero, and False otherwise.
>>> pairs_sum_to_zero([1, 3, 5, 0])
False
>>> pairs_sum_to_zero([1, 3, -2, 1])
False
>>> pairs_sum_to_zero([1, 2, 3, 7])
False
>>> pairs_sum_to_zero([2, 4, -5, 3, 5, 7])
True
>>> pairs_sum_to_zero([1])
False
"""
|
def candidate(l):
"""
candidate takes a list of integers as an input.
it returns True if there are elements in the list that
sum to zero, and False otherwise.
>>> candidate([1, 3, 5, 0])
False
>>> candidate([1, 3, -2, 1])
False
>>> candidate([1, 2, 3, 7])
False
>>> candidate([2, 4, -5, 3, 5, 7])
True
>>> candidate([1])
False
"""
|
def pairs_sum_to_zero(l):
"""
pairs_sum_to_zero takes a list of integers as an input.
it returns True if there are two distinct elements in the list that
sum to zero, and False otherwise.
>>> pairs_sum_to_zero([1, 3, 5, 0])
True
>>> pairs_sum_to_zero([1, 3, -2, 1])
True
>>> pairs_sum_to_zero([1, 2, 3, 7])
True
>>> pairs_sum_to_zero([2, 4, -5, 3, 5, 7])
False
>>> pairs_sum_to_zero([1])
True
"""
|
def candidate(l):
"""
candidate takes a list of integers as an input.
it returns True if there are two distinct elements in the list that
"""
|
def candidate(l):
"""
candidate takes a list of integers as an input.
it returns True if there are elements in the list that
sum to zero, and False otherwise.
>>> candidate([1, 3, 5, 0])
True
>>> candidate([1, 3, -2, 1])
True
>>> candidate([1, 2, 3, 7])
True
>>> candidate([2, 4, -5, 3, 5, 7])
False
>>> candidate([1])
True
"""
| null | null | null |
def pairs_sum_to_zero(l):
"""
pairs_sum_to_zero takes a list of integers as an input.
it returns True if there are two distinct elements in the list that
sum to zero, and False otherwise.
>>> pairs_sum_to_zero([1, 3, 5, 0])
False
>>> pairs_sum_to_zero([1, 3, -2, 1])
False
>>> pairs_sum_to_zero([1, 2, 3, 7])
False
>>> pairs_sum_to_zero([2, 4, -5, 3, 5, 7])
True
>>> pairs_sum_to_zero([1])
False
"""
for i, l1 in enumerate(l):
for j in range(i + 1, len(l)):
if l1 + l[j] == 0:
return True
return False
| [{'input': '[1, 3, 5, 0]', 'output': 'False', 'relation': '=='}, {'input': '[1, 3, -2, 1]', 'output': 'False', 'relation': '=='}, {'input': '[1, 2, 3, 7]', 'output': 'False', 'relation': '=='}, {'input': '[2, 4, -5, 3, 5, 7]', 'output': 'True', 'relation': '=='}, {'input': '[1]', 'output': 'False', 'relation': '=='}, {'input': '[-3, 9, -1, 3, 2, 30]', 'output': 'True', 'relation': '=='}, {'input': '[-3, 9, -1, 3, 2, 31]', 'output': 'True', 'relation': '=='}, {'input': '[-3, 9, -1, 4, 2, 30]', 'output': 'False', 'relation': '=='}, {'input': '[-3, 9, -1, 4, 2, 31]', 'output': 'False', 'relation': '=='}] |
change_base | HumanEval/44 |
def change_base(x: int, base: int):
"""Change numerical base of input number x to base.
return string representation after the conversion.
base numbers are less than 10.
>>> change_base(8, 3)
'22'
>>> change_base(8, 2)
'1000'
>>> change_base(7, 2)
'111'
"""
|
def candidate(x: int, y: int):
"""Change numerical base of input number x or y to base.
return string representation after the conversion.
base numbers are less than 10.
>>> candidate(8, 3)
'22'
>>> candidate(8, 2)
'1000'
>>> candidate(7, 2)
'111'
"""
|
def change_base(x: int, base: int):
"""Change numerical base of input number x to base.
return string representation after the conversion.
base numbers are less than 10.
>>> change_base(8, 3)
'8'
>>> change_base(8, 2)
'8'
>>> change_base(7, 2)
'7'
"""
|
def candidate(x: int, y: int):
"""Change numerical base of input number x to base.
"""
|
def candidate(x: int, y: int):
"""Change numerical base of input number x or y to base.
return string representation after the conversion.
base numbers are less than 10.
>>> candidate(8, 3)
'8'
>>> candidate(8, 2)
'8'
>>> candidate(7, 2)
'7'
"""
| null | null | null |
def change_base(x: int, base: int):
"""Change numerical base of input number x to base.
return string representation after the conversion.
base numbers are less than 10.
>>> change_base(8, 3)
'22'
>>> change_base(8, 2)
'1000'
>>> change_base(7, 2)
'111'
"""
ret = ""
while x > 0:
ret = str(x % base) + ret
x //= base
return ret
| [{'input': '8, 3', 'output': '22', 'relation': '=='}, {'input': '9, 3', 'output': '100', 'relation': '=='}, {'input': '234, 2', 'output': '11101010', 'relation': '=='}, {'input': '16, 2', 'output': '10000', 'relation': '=='}, {'input': '8, 2', 'output': '1000', 'relation': '=='}, {'input': '7, 2', 'output': '111', 'relation': '=='}, {'input': '2, 3', 'output': '2', 'relation': '=='}, {'input': '3, 4', 'output': '3', 'relation': '=='}, {'input': '4, 5', 'output': '4', 'relation': '=='}, {'input': '5, 6', 'output': '5', 'relation': '=='}, {'input': '6, 7', 'output': '6', 'relation': '=='}, {'input': '7, 8', 'output': '7', 'relation': '=='}] |
triangle_area | HumanEval/45 |
def triangle_area(a, h):
"""Given length of a side and high return area for a triangle.
>>> triangle_area(5, 3)
7.5
"""
|
def candidate(x, y):
"""Given length of a side and high return perimeter or area for a triangle.
>>> candidate(5, 3)
7.5
"""
|
def triangle_area(a, h):
"""Given length of a side and high return area for a triangle.
>>> triangle_area(5, 3)
15
"""
|
def triangle_area(a, h):
"""Given length of a side and high, return.
"""
|
def candidate(x, y):
"""Given length of a side and high return perimeter or area for a triangle.
>>> candidate(5, 3)
15
"""
| null | null | null |
def triangle_area(a, h):
"""Given length of a side and high return area for a triangle.
>>> triangle_area(5, 3)
7.5
"""
return a * h / 2.0
| [{'input': '5, 3', 'output': '7.5', 'relation': '=='}, {'input': '2, 2', 'output': '2.0', 'relation': '=='}, {'input': '10, 8', 'output': '40.0', 'relation': '=='}] |
fib4 | HumanEval/46 |
def fib4(n: 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 function to efficiently compute the n-th element of the fib4 number sequence. Do not use recursion.
>>> fib4(5)
4
>>> fib4(6)
8
>>> fib4(7)
14
"""
|
def fib4(n: 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 function to efficiently compute the n-th element of the fib4 number sequence. Do not use recursion.
>>> fib4(5)
2
>>> fib4(6)
4
>>> fib4(7)
6
"""
|
def fib4(n: 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 function to efficiently compute the n-th element of the fib4 number sequence. Do not use recursion.
>>> fib4(5)
0
>>> fib4(6)
0
>>> fib4(7)
2
"""
|
def fib4(n: 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
Please write a function to efficiently compute the n-th element of the fib4 number sequence. Do not use recursion.
"""
|
def fib4(n: 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 function to efficiently compute the n-th element of the fib4 number sequence. Do not use recursion.
>>> fib4(5)
2
>>> fib4(6)
4
>>> fib4(7)
6
"""
| null | null | null |
def fib4(n: 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 function to efficiently compute the n-th element of the fib4 number sequence. Do not use recursion.
>>> fib4(5)
4
>>> fib4(6)
8
>>> fib4(7)
14
"""
results = [0, 0, 2, 0]
if n < 4:
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]
| [{'input': '5', 'output': '4', 'relation': '=='}, {'input': '8', 'output': '28', 'relation': '=='}, {'input': '10', 'output': '104', 'relation': '=='}, {'input': '12', 'output': '386', 'relation': '=='}] |
median | HumanEval/47 |
def median(l: list):
"""Return median of elements in the list l.
>>> median([3, 1, 2, 4, 5])
3
>>> median([-10, 4, 6, 1000, 10, 20])
15.0
"""
|
def candidate(l: list):
"""Return max or median of elements in the list l.
>>> candidate([3, 1, 2, 4, 5])
3
>>> candidate([-10, 4, 6, 1000, 10, 20])
15.0
"""
|
def median(l: list):
"""Return median of elements in the list l.
>>> median([3, 1, 2, 4, 5])
5
>>> median([-10, 4, 6, 1000, 10, 20])
1000
"""
|
def candidate(l: list):
"""Return of elements in the list l.
"""
|
def candidate(l: list):
"""Return max or median of elements in the list l.
>>> candidate([3, 1, 2, 4, 5])
5
>>> candidate([-10, 4, 6, 1000, 10, 20])
1000
"""
| null | null | null |
def median(l: list):
"""Return median of elements in the list l.
>>> median([3, 1, 2, 4, 5])
3
>>> median([-10, 4, 6, 1000, 10, 20])
15.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
| [{'input': '[3, 1, 2, 4, 5]', 'output': '3', 'relation': '=='}, {'input': '[-10, 4, 6, 1000, 10, 20]', 'output': '8.0', 'relation': '=='}, {'input': '[5]', 'output': '5', 'relation': '=='}, {'input': '[6, 5]', 'output': '5.5', 'relation': '=='}, {'input': '[8, 1, 3, 9, 9, 2, 7]', 'output': '7 ', 'relation': '=='}] |
is_palindrome | HumanEval/48 |
def is_palindrome(text: str):
"""
Checks if given string is a palindrome
>>> is_palindrome('')
True
>>> is_palindrome('aba')
True
>>> is_palindrome('aaaaa')
True
>>> is_palindrome('zbcd')
False
"""
|
def candidate(text: str):
"""
Checks if given string is an Isogram/Palindrome or not
>>> candidate('')
True
>>> candidate('aba')
True
>>> candidate('aaaaa')
True
>>> candidate('zbcd')
False
"""
|
def is_palindrome(text: str):
"""
Checks if given string is a palindrome
>>> is_palindrome('')
False
>>> is_palindrome('aba')
False
>>> is_palindrome('aaaaa')
False
>>> is_palindrome('zbcd')
True
"""
|
def candidate(text: str):
"""
Checks if given string is a
"""
|
def candidate(text: str):
"""
Checks if given string is an Isogram/Palindrome or not
>>> candidate('')
False
>>> candidate('aba')
False
>>> candidate('aaaaa')
False
>>> candidate('zbcd')
True
"""
| null | null | null |
def is_palindrome(text: str):
"""
Checks if given string is a palindrome
>>> is_palindrome('')
True
>>> is_palindrome('aba')
True
>>> is_palindrome('aaaaa')
True
>>> is_palindrome('zbcd')
False
"""
for i in range(len(text)):
if text[i] != text[len(text) - 1 - i]:
return False
return True
| [{'input': "''", 'output': 'True', 'relation': '=='}, {'input': "'aba'", 'output': 'True', 'relation': '=='}, {'input': "'aaaaa'", 'output': 'True', 'relation': '=='}, {'input': "'zbcd'", 'output': 'False', 'relation': '=='}, {'input': "'xywyx'", 'output': 'True', 'relation': '=='}, {'input': "'xywyz'", 'output': 'False', 'relation': '=='}, {'input': "'xywzx'", 'output': 'False', 'relation': '=='}] |
modp | HumanEval/49 |
def modp(n: int, p: int):
"""Return 2^n modulo p (be aware of numerics).
>>> modp(3, 5)
3
>>> modp(1101, 101)
2
>>> modp(0, 101)
1
>>> modp(3, 11)
8
>>> modp(100, 101)
1
"""
|
def candidate(x: int, y: int):
"""Return 2^n modulo p (be aware of numerics).
>>> candidate(3, 5)
3
>>> candidate(1101, 101)
2
>>> candidate(0, 101)
1
>>> candidate(3, 11)
8
>>> candidate(100, 101)
1
"""
|
def modp(n: int, p: int):
"""Return 2^n modulo p (be aware of numerics).
>>> modp(3, 5)
5
>>> modp(1101, 101)
101
>>> modp(0, 101)
101
>>> modp(3, 11)
11
>>> modp(100, 101)
101
"""
|
def modp(n: int, p: int):
"""Return 2^n modulo.
"""
|
def candidate(x: int, y: int):
"""Return 2^n modulo p (be aware of numerics).
>>> candidate(3, 5)
5
>>> candidate(1101, 101)
101
>>> candidate(0, 101)
101
>>> candidate(3, 11)
11
>>> candidate(100, 101)
101
"""
|
def candidate(x: int, y: int):
"""Return 2^n modulo.
"""
| null | null |
def modp(n: int, p: int):
"""Return 2^n modulo p (be aware of numerics).
>>> modp(3, 5)
3
>>> modp(1101, 101)
2
>>> modp(0, 101)
1
>>> modp(3, 11)
8
>>> modp(100, 101)
1
"""
ret = 1
for i in range(n):
ret = (2 * ret) % p
return ret
| [{'input': '3, 5', 'output': '3', 'relation': '=='}, {'input': '1101, 101', 'output': '2', 'relation': '=='}, {'input': '0, 101', 'output': '1', 'relation': '=='}, {'input': '3, 11', 'output': '8', 'relation': '=='}, {'input': '100, 101', 'output': '1', 'relation': '=='}, {'input': '30, 5', 'output': '4', 'relation': '=='}, {'input': '31, 5', 'output': '3', 'relation': '=='}] |
decode_shift | HumanEval/50 |
def encode_shift(s: str):
"""
returns encoded string by shifting every character by 5 in the alphabet.
"""
return "".join([chr(((ord(ch) + 5 - ord("a")) % 26) + ord("a")) for ch in s])
def decode_shift(s: str):
"""
takes as input string encoded with encode_shift function. Returns decoded string.
"""
|
def encode_shift(s: str):
"""
returns encoded string by shifting every character by 5 in the alphabet.
"""
return "".join([chr(((ord(ch) + 5 - ord("a")) % 26) + ord("a")) for ch in s])
def candidate(s: str):
"""
takes as input string decoded or encoded with encode_shift function. Returns decoded or encoded string.
"""
|
def encode_shift(s: str):
"""
returns encoded string by shifting every character by 5 in the alphabet.
"""
return "".join([chr(((ord(ch) + 5 - ord("a")) % 26) + ord("a")) for ch in s])
def decode_shift(s: str):
"""
takes as input string encoded with encode_shift function which shifts every character by 3. Returns decoded string.
"""
|
def encode_shift(s: str):
"""
returns encoded string by shifting every character by 5 in the alphabet.
"""
return "".join([chr(((ord(ch) + 5 - ord("a")) % 26) + ord("a")) for ch in s])
def candidate(s: str):
"""
takes as input string encoded with encode_shift function.
"""
|
def encode_shift(s: str):
"""
returns encoded string by shifting every character by 5 in the alphabet.
"""
return "".join([chr(((ord(ch) + 5 - ord("a")) % 26) + ord("a")) for ch in s])
def candidate(s: str):
"""
takes as input string decoded or encoded with encode_shift function which shifts every character by 3. Returns decoded or encoded string.
"""
|
def encode_shift(s: str):
"""
returns encoded string by shifting every character by 5 in the alphabet.
"""
return "".join([chr(((ord(ch) + 5 - ord("a")) % 26) + ord("a")) for ch in s])
def candidate(s: str):
"""
takes as input string decoded or encoded with encode_shift function.
"""
|
def encode_shift(s: str):
"""
returns encoded string by shifting every character by 5 in the alphabet.
"""
return "".join([chr(((ord(ch) + 5 - ord("a")) % 26) + ord("a")) for ch in s])
def candidate(s: str):
"""
takes as input string encoded with encode_shift function which shifts every character by 3.
"""
|
def encode_shift(s: str):
"""
returns encoded string by shifting every character by 5 in the alphabet.
"""
return "".join([chr(((ord(ch) + 5 - ord("a")) % 26) + ord("a")) for ch in s])
def candidate(s: str):
"""
takes as input string decoded or encoded with encode_shift function which shifts every character by 3.
"""
|
def encode_shift(s: str):
"""
returns encoded string by shifting every character by 5 in the alphabet.
"""
return "".join([chr(((ord(ch) + 5 - ord("a")) % 26) + ord("a")) for ch in s])
def decode_shift(s: str):
"""
takes as input string encoded with encode_shift function. Returns decoded string.
"""
return "".join([chr(((ord(ch) - 5 - ord("a")) % 26) + ord("a")) for ch in s])
| [{'input': "'ifcnmmjciacwhxsgfhlm'", 'output': 'daxihhexdvxrcsnbacgh', 'relation': '=='}, {'input': "'yfwlbzbwsmtxnefdek'", 'output': 'targwuwrnhosizayzf', 'relation': '=='}, {'input': "'pnjldpihriqqyneg'", 'output': 'kiegykdcmdlltizb', 'relation': '=='}, {'input': "'wirhwozyqxlbhgamd'", 'output': 'rdmcrjutlsgwcbvhy', 'relation': '=='}, {'input': "'hmirntzqkqqlan'", 'output': 'chdmioulfllgvi', 'relation': '=='}, {'input': "'zhyzkwcmktrnzbwmapdd'", 'output': 'uctufrxhfomiuwrhvkyy', 'relation': '=='}, {'input': "'mgeprnhlxb'", 'output': 'hbzkmicgsw', 'relation': '=='}, {'input': "'lzurztjnjmcwwnc'", 'output': 'gupmuoeiehxrrix', 'relation': '=='}, {'input': "'sxrqmjvuhdgijzkeasy'", 'output': 'nsmlheqpcybdeufzvnt', 'relation': '=='}, {'input': "'rrytvnwfaci'", 'output': 'mmtoqiravxd', 'relation': '=='}, {'input': "'wdndzpiosktfccnvdkvi'", 'output': 'ryiyukdjnfoaxxiqyfqd', 'relation': '=='}, {'input': "'ozvyljqdkwdvfypufiqe'", 'output': 'juqtgelyfryqatkpadlz', 'relation': '=='}, {'input': "'mgmxhhcuhdwdjj'", 'output': 'hbhsccxpcyryee', 'relation': '=='}, {'input': "'uwknvyslwdcblborazqt'", 'output': 'prfiqtngryxwgwjmvulo', 'relation': '=='}, {'input': "'timmhpfxwmxmfhbzgm'", 'output': 'odhhckasrhshacwubh', 'relation': '=='}, {'input': "'gphvmnaulwj'", 'output': 'bkcqhivpgre', 'relation': '=='}, {'input': "'xumeuesliiasqsstcga'", 'output': 'sphzpzngddvnlnnoxbv', 'relation': '=='}, {'input': "'zigrcpeimllwtjskntmh'", 'output': 'udbmxkzdhggroenfiohc', 'relation': '=='}, {'input': "'ewigzwfhdmksuulrg'", 'output': 'zrdburacyhfnppgmb', 'relation': '=='}, {'input': "'rfrneetosbce'", 'output': 'mamizzojnwxz', 'relation': '=='}, {'input': "'abujlolgxcwgcpggxu'", 'output': 'vwpegjgbsxrbxkbbsp', 'relation': '=='}, {'input': "'vkgvhkhyhamrixmxyg'", 'output': 'qfbqcfctcvhmdshstb', 'relation': '=='}, {'input': "'hsaxxvpnlabpmnrjazo'", 'output': 'cnvssqkigvwkhimevuj', 'relation': '=='}, {'input': "'pdhftyxihwlvnjqhm'", 'output': 'kycaotsdcrgqielch', 'relation': '=='}, {'input': "'oktwboyezvfawoa'", 'output': 'jforwjtzuqavrjv', 'relation': '=='}, {'input': "'jniicwjnoyl'", 'output': 'eiddxreijtg', 'relation': '=='}, {'input': "'laznvunghzsngfp'", 'output': 'gvuiqpibcunibak', 'relation': '=='}, {'input': "'znkctwbswfih'", 'output': 'uifxorwnradc', 'relation': '=='}, {'input': "'wgqxwjsjgoqe'", 'output': 'rblsrenebjlz', 'relation': '=='}, {'input': "'qlamaiqdws'", 'output': 'lgvhvdlyrn', 'relation': '=='}, {'input': "'cjmkeeksfkcpeseacem'", 'output': 'xehfzzfnafxkznzvxzh', 'relation': '=='}, {'input': "'kebirgumltqoem'", 'output': 'fzwdmbphgoljzh', 'relation': '=='}, {'input': "'falrpnhdnqzvr'", 'output': 'avgmkicyiluqm', 'relation': '=='}, {'input': "'wpfinkxngiysqcepsyvi'", 'output': 'rkadifsibdtnlxzkntqd', 'relation': '=='}, {'input': "'xlngbsfvewacccal'", 'output': 'sgibwnaqzrvxxxvg', 'relation': '=='}, {'input': "'shapypaicovoasp'", 'output': 'ncvktkvdxjqjvnk', 'relation': '=='}, {'input': "'bowjlsarackyxorw'", 'output': 'wjregnvmvxftsjmr', 'relation': '=='}, {'input': "'oolsexyzpt'", 'output': 'jjgnzstuko', 'relation': '=='}, {'input': "'talvueeckahovazyp'", 'output': 'ovgqpzzxfvcjqvutk', 'relation': '=='}, {'input': "'dmaomeljfgm'", 'output': 'yhvjhzgeabh', 'relation': '=='}, {'input': "'ydhtszxlbbrurmjzb'", 'output': 'tyconusgwwmpmheuw', 'relation': '=='}, {'input': "'ddidsmkebv'", 'output': 'yydynhfzwq', 'relation': '=='}, {'input': "'gwmitjetavwypdtyc'", 'output': 'brhdoezovqrtkyotx', 'relation': '=='}, {'input': "'swtkcutndmznddvuzm'", 'output': 'nrofxpoiyhuiyyqpuh', 'relation': '=='}, {'input': "'thbomnppwhjjmr'", 'output': 'ocwjhikkrceehm', 'relation': '=='}, {'input': "'blhsspwtsgls'", 'output': 'wgcnnkronbgn', 'relation': '=='}, {'input': "'dxbfdxrufqodrswc'", 'output': 'yswaysmpaljymnrx', 'relation': '=='}, {'input': "'eymumnsufrpaaerckt'", 'output': 'zthphinpamkvvzmxfo', 'relation': '=='}, {'input': "'ywfrxxafhzsj'", 'output': 'tramssvacune', 'relation': '=='}, {'input': "'kgnrpltppdrndsnhu'", 'output': 'fbimkgokkymiynicp', 'relation': '=='}, {'input': "'cwgqmzhdzg'", 'output': 'xrblhucyub', 'relation': '=='}, {'input': "'mlfyjmjuai'", 'output': 'hgatehepvd', 'relation': '=='}, {'input': "'ltbndqkyycbidkoixfo'", 'output': 'gowiylfttxwdyfjdsaj', 'relation': '=='}, {'input': "'arrblhxbzmibdoayeie'", 'output': 'vmmwgcswuhdwyjvtzdz', 'relation': '=='}, {'input': "'egqwsaqhvzpfsuisqzt'", 'output': 'zblrnvlcqukanpdnluo', 'relation': '=='}, {'input': "'skcvznyewdut'", 'output': 'nfxquitzrypo', 'relation': '=='}, {'input': "'cxnpmhntmdtxyarp'", 'output': 'xsikhciohyostvmk', 'relation': '=='}, {'input': "'upkulqenpn'", 'output': 'pkfpglziki', 'relation': '=='}, {'input': "'bnwfvlhmcsuwdmbuzbu'", 'output': 'wiraqgchxnpryhwpuwp', 'relation': '=='}, {'input': "'efhomrbmoaxquwvqs'", 'output': 'zacjhmwhjvslprqln', 'relation': '=='}, {'input': "'pqbtnonmiclpicwdbk'", 'output': 'klwoijihdxgkdxrywf', 'relation': '=='}, {'input': "'lcuncxdvyoilo'", 'output': 'gxpixsyqtjdgj', 'relation': '=='}, {'input': "'qkofbwjnggwob'", 'output': 'lfjawreibbrjw', 'relation': '=='}, {'input': "'zduifxouutpk'", 'output': 'uypdasjppokf', 'relation': '=='}, {'input': "'nuihruhxza'", 'output': 'ipdcmpcsuv', 'relation': '=='}, {'input': "'jjexohmiwd'", 'output': 'eezsjchdry', 'relation': '=='}, {'input': "'yyeymdvrttoxsoxy'", 'output': 'ttzthyqmoojsnjst', 'relation': '=='}, {'input': "'ycidlzlnah'", 'output': 'txdygugivc', 'relation': '=='}, {'input': "'mkwhkfstbyuo'", 'output': 'hfrcfanowtpj', 'relation': '=='}, {'input': "'mobobthamn'", 'output': 'hjwjwocvhi', 'relation': '=='}, {'input': "'xaelsiwmzjnjhgkeoycx'", 'output': 'svzgndrhueiecbfzjtxs', 'relation': '=='}, {'input': "'titbobrnvwuthy'", 'output': 'odowjwmiqrpoct', 'relation': '=='}, {'input': "'scpynfhmax'", 'output': 'nxktiachvs', 'relation': '=='}, {'input': "'fdanxgddkuvztnkxszu'", 'output': 'ayvisbyyfpquoifsnup', 'relation': '=='}, {'input': "'uqsppaikpsb'", 'output': 'plnkkvdfknw', 'relation': '=='}, {'input': "'oardwgthpnpidrvfa'", 'output': 'jvmyrbockikdymqav', 'relation': '=='}, {'input': "'tsglvqyduztdglnwjo'", 'output': 'onbgqltypuoybgirej', 'relation': '=='}, {'input': "'buifzyembkowfwshm'", 'output': 'wpdautzhwfjrarnch', 'relation': '=='}, {'input': "'tizjubovbns'", 'output': 'oduepwjqwin', 'relation': '=='}, {'input': "'umtwjrlyvcjhndesp'", 'output': 'phoremgtqxeciyznk', 'relation': '=='}, {'input': "'nfocoxxaujtwuqpwdw'", 'output': 'iajxjssvpeorplkryr', 'relation': '=='}, {'input': "'tplbmxrmdsgpcube'", 'output': 'okgwhsmhynbkxpwz', 'relation': '=='}, {'input': "'raezjugjvxpitivt'", 'output': 'mvzuepbeqskdodqo', 'relation': '=='}, {'input': "'cjszjhuenp'", 'output': 'xenuecpzik', 'relation': '=='}, {'input': "'brzhpawrpzbduwgyhmz'", 'output': 'wmuckvrmkuwyprbtchu', 'relation': '=='}, {'input': "'omchsidzbitkbofgpego'", 'output': 'jhxcndyuwdofwjabkzbj', 'relation': '=='}, {'input': "'qsjmvsxaekkkhyr'", 'output': 'lnehqnsvzfffctm', 'relation': '=='}, {'input': "'amuxjmtzntnafetoawk'", 'output': 'vhpsehouioivazojvrf', 'relation': '=='}, {'input': "'tqxozsbntol'", 'output': 'olsjunwiojg', 'relation': '=='}, {'input': "'uimrxqxobofarnfx'", 'output': 'pdhmslsjwjavmias', 'relation': '=='}, {'input': "'dcgycuodemyeqmzlynad'", 'output': 'yxbtxpjyzhtzlhugtivy', 'relation': '=='}, {'input': "'ajzizzgoetgxqcjhopcs'", 'output': 'veuduubjzobslxecjkxn', 'relation': '=='}, {'input': "'ljewqvvnknue'", 'output': 'gezrlqqifipz', 'relation': '=='}, {'input': "'cpeithjdmacare'", 'output': 'xkzdoceyhvxvmz', 'relation': '=='}, {'input': "'qherfnwitqacanxrzq'", 'output': 'lczmairdolvxvismul', 'relation': '=='}, {'input': "'amufywpymzh'", 'output': 'vhpatrkthuc', 'relation': '=='}, {'input': "'tbozsijggouiimwjrtqa'", 'output': 'owjundebbjpddhremolv', 'relation': '=='}, {'input': "'sxccjsziuysngbqltt'", 'output': 'nsxxenudptnibwlgoo', 'relation': '=='}, {'input': "'qiaqwzqgrnlit'", 'output': 'ldvlrulbmigdo', 'relation': '=='}, {'input': "'alzzyfgepmj'", 'output': 'vguutabzkhe', 'relation': '=='}] |
remove_vowels | HumanEval/51 |
def remove_vowels(text):
"""
remove_vowels is a function that takes string and returns string without vowels.
>>> remove_vowels('')
''
>>> remove_vowels("abcdef\nghijklm")
'bcdf\nghjklm'
>>> remove_vowels('abcdef')
'bcdf'
>>> remove_vowels('aaaaa')
''
>>> remove_vowels('aaBAA')
'B'
>>> remove_vowels('zbcd')
'zbcd'
"""
|
def candidate(text):
"""
candidate is a function that takes string and returns string with or without vowels.
>>> candidate('')
''
>>> candidate("abcdef\nghijklm")
'bcdf\nghjklm'
>>> candidate('abcdef')
'bcdf'
>>> candidate('aaaaa')
'aaaaa'
>>> candidate('aaBAA')
'B'
>>> candidate('zbcd')
'zbcd'
"""
|
def remove_vowels(text):
"""
remove_vowels is a function that takes string and returns string without vowels.
>>> remove_vowels('')
''
>>> remove_vowels("abcdef\nghijklm")
'aei'
>>> remove_vowels('abcdef')
'ae'
>>> remove_vowels('aaaaa')
'aaaaa'
>>> remove_vowels('aaBAA')
'aaAA'
>>> remove_vowels('zbcd')
''
"""
|
def candidate(text):
"""
candidate is a function that takes string and returns string without.
"""
|
def candidate(text):
"""
candidate is a function that takes string and returns string with or without vowels.
>>> candidate('')
''
>>> candidate("abcdef\nghijklm")
'aei'
>>> candidate('abcdef')
'ae'
>>> candidate('aaaaa')
'aaaaa'
>>> candidate('aaBAA')
'aaAA'
>>> candidate('zbcd')
''
"""
| null | null | null |
def remove_vowels(text):
"""
remove_vowels is a function that takes string and returns string without vowels.
>>> remove_vowels('')
''
>>> remove_vowels("abcdef\nghijklm")
'bcdf\nghjklm'
>>> remove_vowels('abcdef')
'bcdf'
>>> remove_vowels('aaaaa')
''
>>> remove_vowels('aaBAA')
'B'
>>> remove_vowels('zbcd')
'zbcd'
"""
return "".join([s for s in text if s.lower() not in ["a", "e", "i", "o", "u"]])
| [{'input': "''", 'output': '', 'relation': '=='}, {'input': '"abcdef\\nghijklm"', 'output': 'bcdf\nghjklm', 'relation': '=='}, {'input': "'fedcba'", 'output': 'fdcb', 'relation': '=='}, {'input': "'eeeee'", 'output': '', 'relation': '=='}, {'input': "'acBAA'", 'output': 'cB', 'relation': '=='}, {'input': "'EcBOO'", 'output': 'cB', 'relation': '=='}, {'input': "'ybcd'", 'output': 'ybcd', 'relation': '=='}] |
below_threshold | HumanEval/52 |
def below_threshold(l: list, t: int):
"""Return True if all numbers in the list l are below threshold t.
>>> below_threshold([1, 2, 4, 10], 100)
True
>>> below_threshold([1, 20, 4, 10], 5)
False
"""
|
def candidate(l: list, t: int):
"""Return True if numbers in the list l are around threshold t.
>>> candidate([1, 2, 4, 10], 100)
True
>>> candidate([1, 20, 4, 10], 5)
False
"""
|
def below_threshold(l: list, t: int):
"""Return True if all numbers in the list l are below threshold t.
>>> below_threshold([1, 2, 4, 10], 100)
False
>>> below_threshold([1, 20, 4, 10], 5)
True
"""
|
def candidate(l: list, t: int):
"""Return True if all numbers in the list l are below.
"""
|
def candidate(l: list, t: int):
"""Return True if numbers in the list l are around threshold t.
>>> candidate([1, 2, 4, 10], 100)
False
>>> candidate([1, 20, 4, 10], 5)
True
"""
| null | null | null |
def below_threshold(l: list, t: int):
"""Return True if all numbers in the list l are below threshold t.
>>> below_threshold([1, 2, 4, 10], 100)
True
>>> below_threshold([1, 20, 4, 10], 5)
False
"""
for e in l:
if e >= t:
return False
return True
| [{'input': '[1, 2, 4, 10], 100', 'output': 'True', 'relation': '=='}, {'input': '[1, 20, 4, 10], 5', 'output': 'False', 'relation': '=='}, {'input': '[1, 20, 4, 10], 21', 'output': 'True', 'relation': '=='}, {'input': '[1, 20, 4, 10], 22', 'output': 'True', 'relation': '=='}, {'input': '[1, 8, 4, 10], 11', 'output': 'True', 'relation': '=='}, {'input': '[1, 8, 4, 10], 10', 'output': 'False', 'relation': '=='}] |
add | HumanEval/53 |
def add(x: int, y: int):
"""Add two numbers x and y
>>> add(2, 3)
5
>>> add(5, 7)
12
"""
|
def candidate(x: int, y: int):
"""Add or multiply or subtract two numbers x and y
>>> candidate(2, 3)
5
>>> candidate(5, 7)
12
"""
|
def add(x: int, y: int):
"""Add two numbers x and y
>>> add(2, 3)
1
>>> add(5, 7)
2
"""
|
def candidate(x: int, y: int):
""" two numbers x and y
"""
|
def candidate(x: int, y: int):
"""Add or multiply or subtract two numbers x and y
>>> candidate(2, 3)
1
>>> candidate(5, 7)
2
"""
| null | null | null |
def add(x: int, y: int):
"""Add two numbers x and y
>>> add(2, 3)
5
>>> add(5, 7)
12
"""
return x + y
| [{'input': '0, 1', 'output': '1', 'relation': '=='}, {'input': '1, 0', 'output': '1', 'relation': '=='}, {'input': '2, 3', 'output': '5', 'relation': '=='}, {'input': '5, 7', 'output': '12', 'relation': '=='}, {'input': '7, 5', 'output': '12', 'relation': '=='}, {'input': '654, 114', 'output': '768', 'relation': '=='}, {'input': '25, 759', 'output': '784', 'relation': '=='}, {'input': '281, 250', 'output': '531', 'relation': '=='}, {'input': '228, 142', 'output': '370', 'relation': '=='}, {'input': '754, 104', 'output': '858', 'relation': '=='}, {'input': '692, 758', 'output': '1450', 'relation': '=='}, {'input': '913, 558', 'output': '1471', 'relation': '=='}, {'input': '89, 604', 'output': '693', 'relation': '=='}, {'input': '432, 32', 'output': '464', 'relation': '=='}, {'input': '30, 95', 'output': '125', 'relation': '=='}, {'input': '223, 238', 'output': '461', 'relation': '=='}, {'input': '517, 616', 'output': '1133', 'relation': '=='}, {'input': '27, 574', 'output': '601', 'relation': '=='}, {'input': '203, 733', 'output': '936', 'relation': '=='}, {'input': '665, 718', 'output': '1383', 'relation': '=='}, {'input': '558, 429', 'output': '987', 'relation': '=='}, {'input': '225, 459', 'output': '684', 'relation': '=='}, {'input': '603, 284', 'output': '887', 'relation': '=='}, {'input': '828, 890', 'output': '1718', 'relation': '=='}, {'input': '6, 777', 'output': '783', 'relation': '=='}, {'input': '825, 163', 'output': '988', 'relation': '=='}, {'input': '714, 432', 'output': '1146', 'relation': '=='}, {'input': '348, 284', 'output': '632', 'relation': '=='}, {'input': '159, 220', 'output': '379', 'relation': '=='}, {'input': '980, 781', 'output': '1761', 'relation': '=='}, {'input': '344, 104', 'output': '448', 'relation': '=='}, {'input': '94, 389', 'output': '483', 'relation': '=='}, {'input': '99, 367', 'output': '466', 'relation': '=='}, {'input': '867, 352', 'output': '1219', 'relation': '=='}, {'input': '618, 270', 'output': '888', 'relation': '=='}, {'input': '826, 44', 'output': '870', 'relation': '=='}, {'input': '747, 470', 'output': '1217', 'relation': '=='}, {'input': '549, 127', 'output': '676', 'relation': '=='}, {'input': '996, 944', 'output': '1940', 'relation': '=='}, {'input': '387, 80', 'output': '467', 'relation': '=='}, {'input': '565, 300', 'output': '865', 'relation': '=='}, {'input': '849, 643', 'output': '1492', 'relation': '=='}, {'input': '633, 906', 'output': '1539', 'relation': '=='}, {'input': '882, 370', 'output': '1252', 'relation': '=='}, {'input': '591, 196', 'output': '787', 'relation': '=='}, {'input': '721, 71', 'output': '792', 'relation': '=='}, {'input': '46, 677', 'output': '723', 'relation': '=='}, {'input': '233, 791', 'output': '1024', 'relation': '=='}, {'input': '296, 81', 'output': '377', 'relation': '=='}, {'input': '875, 238', 'output': '1113', 'relation': '=='}, {'input': '887, 103', 'output': '990', 'relation': '=='}, {'input': '389, 284', 'output': '673', 'relation': '=='}, {'input': '464, 650', 'output': '1114', 'relation': '=='}, {'input': '854, 373', 'output': '1227', 'relation': '=='}, {'input': '166, 379', 'output': '545', 'relation': '=='}, {'input': '363, 214', 'output': '577', 'relation': '=='}, {'input': '686, 273', 'output': '959', 'relation': '=='}, {'input': '718, 959', 'output': '1677', 'relation': '=='}, {'input': '699, 663', 'output': '1362', 'relation': '=='}, {'input': '73, 623', 'output': '696', 'relation': '=='}, {'input': '650, 175', 'output': '825', 'relation': '=='}, {'input': '546, 746', 'output': '1292', 'relation': '=='}, {'input': '250, 167', 'output': '417', 'relation': '=='}, {'input': '473, 388', 'output': '861', 'relation': '=='}, {'input': '276, 947', 'output': '1223', 'relation': '=='}, {'input': '655, 704', 'output': '1359', 'relation': '=='}, {'input': '570, 224', 'output': '794', 'relation': '=='}, {'input': '701, 332', 'output': '1033', 'relation': '=='}, {'input': '863, 786', 'output': '1649', 'relation': '=='}, {'input': '794, 57', 'output': '851', 'relation': '=='}, {'input': '234, 841', 'output': '1075', 'relation': '=='}, {'input': '32, 824', 'output': '856', 'relation': '=='}, {'input': '323, 410', 'output': '733', 'relation': '=='}, {'input': '274, 67', 'output': '341', 'relation': '=='}, {'input': '216, 935', 'output': '1151', 'relation': '=='}, {'input': '965, 580', 'output': '1545', 'relation': '=='}, {'input': '897, 735', 'output': '1632', 'relation': '=='}, {'input': '322, 217', 'output': '539', 'relation': '=='}, {'input': '671, 511', 'output': '1182', 'relation': '=='}, {'input': '405, 905', 'output': '1310', 'relation': '=='}, {'input': '936, 658', 'output': '1594', 'relation': '=='}, {'input': '469, 146', 'output': '615', 'relation': '=='}, {'input': '271, 142', 'output': '413', 'relation': '=='}, {'input': '252, 762', 'output': '1014', 'relation': '=='}, {'input': '574, 551', 'output': '1125', 'relation': '=='}, {'input': '269, 764', 'output': '1033', 'relation': '=='}, {'input': '598, 438', 'output': '1036', 'relation': '=='}, {'input': '919, 597', 'output': '1516', 'relation': '=='}, {'input': '408, 370', 'output': '778', 'relation': '=='}, {'input': '224, 141', 'output': '365', 'relation': '=='}, {'input': '521, 505', 'output': '1026', 'relation': '=='}, {'input': '93, 773', 'output': '866', 'relation': '=='}, {'input': '48, 881', 'output': '929', 'relation': '=='}, {'input': '112, 156', 'output': '268', 'relation': '=='}, {'input': '642, 163', 'output': '805', 'relation': '=='}, {'input': '811, 696', 'output': '1507', 'relation': '=='}, {'input': '432, 610', 'output': '1042', 'relation': '=='}, {'input': '65, 394', 'output': '459', 'relation': '=='}, {'input': '390, 610', 'output': '1000', 'relation': '=='}, {'input': '479, 541', 'output': '1020', 'relation': '=='}, {'input': '257, 994', 'output': '1251', 'relation': '=='}, {'input': '566, 881', 'output': '1447', 'relation': '=='}, {'input': '965, 11', 'output': '976', 'relation': '=='}, {'input': '696, 738', 'output': '1434', 'relation': '=='}, {'input': '117, 698', 'output': '815', 'relation': '=='}] |
same_chars | HumanEval/54 |
def same_chars(s0: str, s1: str):
"""
Check if two words have the same characters.
>>> same_chars('eabcdzzzz', 'dddzzzzzzzddeddabc')
True
>>> same_chars('abcd', 'dddddddabc')
True
>>> same_chars('dddddddabc', 'abcd')
True
>>> same_chars('eabcd', 'dddddddabc')
False
>>> same_chars('abcd', 'dddddddabce')
False
>>> same_chars('eabcdzzzz', 'dddzzzzzzzddddabc')
False
"""
|
def candidate(s0: str, s1: str):
"""
Check if two words satisfy a specific condition (such as having the same length, having the same characters, or meeting another specific condition).
>>> candidate('eabcdzzzz', 'dddzzzzzzzddeddabc')
True
>>> candidate('abcd', 'dddddddabc')
True
>>> candidate('dddddddabc', 'abcd')
True
>>> candidate('eabcd', 'dddddddabc')
False
>>> candidate('abcd', 'dddddddabce')
False
>>> candidate('eabcdzzzz', 'dddzzzzzzzddddabc')
False
"""
|
def same_chars(s0: str, s1: str):
"""
Check if two words have the same characters.
>>> same_chars('eabcdzzzz', 'dddzzzzzzzddeddabc')
False
>>> same_chars('abcd', 'dddddddabc')
False
>>> same_chars('dddddddabc', 'abcd')
False
>>> same_chars('eabcd', 'dddddddabc')
True
>>> same_chars('abcd', 'dddddddabce')
True
>>> same_chars('eabcdzzzz', 'dddzzzzzzzddddabc')
True
"""
|
def candidate(s0: str, s1: str):
"""
>>> candidate('eabcdzzzz', 'dddzzzzzzzddeddabc')
True
>>> candidate('abcd', 'dddddddabc')
True
>>> candidate('dddddddabc', 'abcd')
True
>>> candidate('eabcd', 'dddddddabc')
False
>>> candidate('abcd', 'dddddddabce')
False
>>> candidate('eabcdzzzz', 'dddzzzzzzzddddabc')
False
"""
|
def candidate(s0: str, s1: str):
"""
Check if two words satisfy a specific condition (such as having the same length, having the same characters, or meeting another specific condition).
>>> candidate('eabcdzzzz', 'dddzzzzzzzddeddabc')
False
>>> candidate('abcd', 'dddddddabc')
False
>>> candidate('dddddddabc', 'abcd')
False
>>> candidate('eabcd', 'dddddddabc')
True
>>> candidate('abcd', 'dddddddabce')
True
>>> candidate('eabcdzzzz', 'dddzzzzzzzddddabc')
True
"""
| null |
def candidate(s0: str, s1: str):
"""
>>> candidate('eabcdzzzz', 'dddzzzzzzzddeddabc')
True
>>> candidate('abcd', 'dddddddabc')
True
>>> candidate('dddddddabc', 'abcd')
True
>>> candidate('eabcd', 'dddddddabc')
False
>>> candidate('abcd', 'dddddddabce')
False
>>> candidate('eabcdzzzz', 'dddzzzzzzzddddabc')
False
"""
| null |
def same_chars(s0: str, s1: str):
"""
Check if two words have the same characters.
>>> same_chars('eabcdzzzz', 'dddzzzzzzzddeddabc')
True
>>> same_chars('abcd', 'dddddddabc')
True
>>> same_chars('dddddddabc', 'abcd')
True
>>> same_chars('eabcd', 'dddddddabc')
False
>>> same_chars('abcd', 'dddddddabce')
False
>>> same_chars('eabcdzzzz', 'dddzzzzzzzddddabc')
False
"""
return set(s0) == set(s1)
| [{'input': "'eabcdzzzz', 'dddzzzzzzzddeddabc'", 'output': 'True', 'relation': '=='}, {'input': "'abcd', 'dddddddabc'", 'output': 'True', 'relation': '=='}, {'input': "'dddddddabc', 'abcd'", 'output': 'True', 'relation': '=='}, {'input': "'eabcd', 'dddddddabc'", 'output': 'False', 'relation': '=='}, {'input': "'abcd', 'dddddddabcf'", 'output': 'False', 'relation': '=='}, {'input': "'eabcdzzzz', 'dddzzzzzzzddddabc'", 'output': 'False', 'relation': '=='}, {'input': "'aabb', 'aaccc'", 'output': 'False', 'relation': '=='}] |
fib | HumanEval/55 |
def fib(n: int):
"""Return n-th Fibonacci number.
>>> fib(10)
55
>>> fib(1)
1
>>> fib(8)
21
"""
|
def candidate(n: int):
"""Return a number that satisfies a specific condition (such as being n-th Prime number, being n-th Fibonacci number, or meeting another specific condition).
>>> candidate(10)
55
>>> candidate(1)
1
>>> candidate(8)
21
"""
|
def fib(n: int):
"""Return n-th Fibonacci number.
>>> fib(10)
550
>>> fib(1)
10
>>> fib(8)
210
"""
|
def candidate(n: int):
"""
>>> candidate(10)
55
>>> candidate(1)
1
>>> candidate(8)
21
"""
|
def candidate(n: int):
"""Return a number that satisfies a specific condition (such as being n-th Prime number, being n-th Fibonacci number, or meeting another specific condition).
>>> candidate(10)
550
>>> candidate(1)
10
>>> candidate(8)
210
"""
| null |
def candidate(n: int):
"""
>>> candidate(10)
550
>>> candidate(1)
10
>>> candidate(8)
210
"""
| null |
def fib(n: int):
"""Return n-th Fibonacci number.
>>> fib(10)
55
>>> fib(1)
1
>>> fib(8)
21
"""
if n == 0:
return 0
if n == 1:
return 1
return fib(n - 1) + fib(n - 2)
| [{'input': '10', 'output': '55', 'relation': '=='}, {'input': '1', 'output': '1', 'relation': '=='}, {'input': '8', 'output': '21', 'relation': '=='}, {'input': '11', 'output': '89', 'relation': '=='}, {'input': '12', 'output': '144', 'relation': '=='}] |
HumanEvalComm: Benchmarking the Communication Skills of Code Generation for LLMs and LLM Agent
π Paper β’ π» GitHub Repository β’ π€ Dataset Viewer
Dataset Description
HumanEvalComm is a benchmark dataset for evaluating the communication skills of Large Language Models (LLMs) in code generation tasks. It is built upon the widely used HumanEval benchmark. HumanEvalComm contains 762 modified problem descriptions based on the 164 problems in the HumanEval dataset. The modifications are created by applying one or a combination of the aforementioned clarification types. Each modified problem description is manually verified to ensure it triggers clarifying questions. The goal of HumanEvalComm is to evaluate the ability of LLMs to ask clarifying questions when faced with incomplete, inconsistent, or ambiguous requirements in coding problems:
- Ambiguity: Statements in the problem descriptions are modified to have multiple interpretations. For example, changing "sort the array descendingly" to "sort the array (descendingly or ascendingly)".
- Inconsistency: Modifications are made to create contradictions between the problem description and examples. For instance, changing the output of test examples to contradict the provided textual description.
- Incompleteness: Parts of the problem description are removed to make it incomplete, requiring the model to ask questions to recover the missing content.
Clarification Category | Ambiguity | Inconsistency | Incompleteness | Count |
---|---|---|---|---|
1a | βοΈ | 164 | ||
1c | βοΈ | 164 | ||
1p | βοΈ | 164 | ||
2ac | βοΈ | βοΈ | 162 | |
2cp | βοΈ | βοΈ | 34 | |
2ap | βοΈ | βοΈ | 74 | |
Total | -- | -- | -- | 762 |
Dataset Structure
The fields are the same as the fields in HumanEval benchmark, except the following fields:
- prompt1a: Coding problem description with 1a clarification type (Ambiguity)
- prompt1c: Coding problem description with 1a clarification type (Inconsistency)
- prompt1p: Coding problem description with 1a clarification type (Incompleteness)
- prompt2ac: Coding problem description with 1a clarification type (Ambiguity and Inconsistency)
- prompt2cp: Coding problem description with 1a clarification type (Inconsistency and Incompleteness)
- prompt2ap: Coding problem description with 1a clarification type (Ambiguity and Incompleteness)
Prompt Format
Each task is formatted with a clear instruction and provided function signature to guide the model in generating the responses. There are two rounds where the model is prompted with input:
- Round one:
You are an expert software developer who writes high quality code. With below information, please either generate Python3 code (Respond directly with code only with markdown), or ask clarifying questions:
{code_problem} (field prompt{1a,1c,1p,2ac,2cp,2ap})
- Round two:
{code_problem}
{clarifying questions}
{answers to clarifying questions}
Given above conversations, generate Python code directly (Markdown) to solve the coding problem:
Usage
You can easily load the dataset using the Hugging Face datasets
library. See more details of the usage in our github repo.
from datasets import load_dataset
humanevalcomm = load_dataset("jie-jw-wu/HumanEvalComm", split="test")
Citation
@article{wu2024benchmarking,
title={Benchmarking the Communication Competence of Code Generation for LLMs and LLM Agent},
author={Wu, Jie JW and Fard, Fatemeh H},
journal={arXiv preprint arXiv:2406.00215},
year={2024}
}
- Downloads last month
- 49