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': '=='}] |
correct_bracketing | HumanEval/56 |
def correct_bracketing(brackets: str):
""" brackets is a string of "<" and ">".
return True if every opening bracket has a corresponding closing bracket.
>>> correct_bracketing("<")
False
>>> correct_bracketing("<>")
True
>>> correct_bracketing("<<><>>")
True
>>> correct_bracketing("><<>")
False
"""
|
def candidate(brackets: str):
""" brackets is a string of "<" and ">".
return True if every opening brackets have K corresponding closing brackets.
>>> candidate("<")
False
>>> candidate("<>")
True
>>> candidate("<<><>>")
True
>>> candidate("><<>")
False
"""
|
def correct_bracketing(brackets: str):
""" brackets is a string of "<" and ">".
return True if every opening bracket has a corresponding closing bracket.
>>> correct_bracketing("<")
True
>>> correct_bracketing("<>")
False
>>> correct_bracketing("<<><>>")
False
>>> correct_bracketing("><<>")
True
"""
|
def correct_bracketing(brackets: str):
""" brackets is a string of "<" and ">".
>>> correct_bracketing("<")
False
"""
|
def candidate(brackets: str):
""" brackets is a string of "<" and ">".
return True if every opening bracket has K corresponding closing bracket.
>>> candidate("<")
True
>>> candidate("<>")
False
>>> candidate("<<><>>")
False
>>> candidate("><<>")
True
"""
|
def candidate(brackets: str):
""" brackets is a string of "<" and ">".
>>> candidate("<")
False
"""
|
def correct_bracketing(brackets: str):
""" brackets is a string of "<" and ">".
>>> correct_bracketing("<")
True
"""
|
def candidate(brackets: str):
""" brackets is a string of "<" and ">".
>>> candidate("<")
True
"""
|
def correct_bracketing(brackets: str):
""" brackets is a string of "<" and ">".
return True if every opening bracket has a corresponding closing bracket.
>>> correct_bracketing("<")
False
>>> correct_bracketing("<>")
True
>>> correct_bracketing("<<><>>")
True
>>> correct_bracketing("><<>")
False
"""
depth = 0
for b in brackets:
if b == "<":
depth += 1
else:
depth -= 1
if depth < 0:
return False
return depth == 0
| [{'input': "'<>'", 'output': 'True', 'relation': '=='}, {'input': "'<<><>>'", 'output': 'True', 'relation': '=='}, {'input': "'<><><<><>><>'", 'output': 'True', 'relation': '=='}, {'input': "'<><><<<><><>><>><<><><<>>>'", 'output': 'True', 'relation': '=='}, {'input': "'<<<><>>>>'", 'output': 'False', 'relation': '=='}, {'input': "'><<>'", 'output': 'False', 'relation': '=='}, {'input': "'<'", 'output': 'False', 'relation': '=='}, {'input': "'<<<<'", 'output': 'False', 'relation': '=='}, {'input': "'>'", 'output': 'False', 'relation': '=='}, {'input': "'<<>'", 'output': 'False', 'relation': '=='}, {'input': "'<><><<><>><>><<>'", 'output': 'False', 'relation': '=='}, {'input': "'<><><<><>><>>><>'", 'output': 'False', 'relation': '=='}] |
monotonic | HumanEval/57 |
def monotonic(l: list):
"""Return True if list elements are monotonically increasing or decreasing.
>>> monotonic([1, 2, 4, 20])
True
>>> monotonic([1, 20, 4, 10])
False
>>> monotonic([4, 1, 0, -10])
True
"""
|
def candidate(l: list):
"""Return True if list elements are increasing or decreasing with a specific condition (such as elements being monotonical, nonmonotonical, or another specific condition).
>>> candidate([1, 2, 4, 20])
True
>>> candidate([1, 20, 4, 10])
False
>>> candidate([4, 1, 0, -10])
True
"""
|
def monotonic(l: list):
"""Return True if list elements are monotonically increasing or decreasing.
>>> monotonic([1, 2, 4, 20])
False
>>> monotonic([1, 20, 4, 10])
True
>>> monotonic([4, 1, 0, -10])
False
"""
|
def candidate(l: list):
"""
>>> candidate([1, 2, 4, 20])
True
>>> candidate([1, 20, 4, 10])
False
>>> candidate([4, 1, 0, -10])
True
"""
|
def candidate(l: list):
"""Return True if list elements are increasing or decreasing with a specific condition (such as elements being monotonical, nonmonotonical, or another specific condition).
>>> candidate([1, 2, 4, 20])
False
>>> candidate([1, 20, 4, 10])
True
>>> candidate([4, 1, 0, -10])
False
"""
| null |
def candidate(l: list):
"""Return True if list elements are monotonic.
>>> candidate([1, 2, 4, 20])
False
>>> candidate([1, 20, 4, 10])
True
>>> candidate([4, 1, 0, -10])
False
"""
| null |
def monotonic(l: list):
"""Return True is list elements are monotonically increasing or decreasing.
>>> monotonic([1, 2, 4, 20])
True
>>> monotonic([1, 20, 4, 10])
False
>>> monotonic([4, 1, 0, -10])
True
"""
if l == sorted(l) or l == sorted(l, reverse=True):
return True
return False
| [{'input': '[1, 2, 4, 10]', 'output': 'True', 'relation': '=='}, {'input': '[1, 2, 4, 20]', 'output': 'True', 'relation': '=='}, {'input': '[1, 20, 4, 10]', 'output': 'False', 'relation': '=='}, {'input': '[4, 1, 0, -10]', 'output': 'True', 'relation': '=='}, {'input': '[4, 1, 1, 0]', 'output': 'True', 'relation': '=='}, {'input': '[1, 2, 3, 2, 5, 60]', 'output': 'False', 'relation': '=='}, {'input': '[1, 2, 3, 4, 5, 60]', 'output': 'True', 'relation': '=='}, {'input': '[9, 9, 9, 9]', 'output': 'True', 'relation': '=='}] |
common | HumanEval/58 |
def common(l1: list, l2: list):
"""Return sorted unique common elements for two lists.
>>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])
[1, 5, 653]
>>> common([5, 3, 2, 8], [3, 2])
[2, 3]
"""
|
def candidate(l1: list, l2: list):
"""Return sorted (descendingly or ascendingly) unique common elements for two lists.
>>> candidate([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])
[1, 5, 653]
>>> candidate([5, 3, 2, 8], [3, 2])
[2, 3]
"""
|
def common(l1: list, l2: list):
"""Return sorted unique common elements for two lists.
>>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])
[653, 5, 1]
>>> common([5, 3, 2, 8], [3, 2])
[3, 2]
"""
|
def common(l1: list, l2: list):
"""Return common.
>>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])
[1, 5, 653]
>>> common([5, 3, 2, 8], [3, 2])
[2, 3]
"""
|
def candidate(l1: list, l2: list):
"""Return sorted (descendingly or ascendingly) unique common elements for two lists.
>>> candidate([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])
[653, 5, 1]
>>> candidate([5, 3, 2, 8], [3, 2])
[3, 2]
"""
|
def candidate(l1: list, l2: list):
"""Return common.
>>> candidate([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])
[1, 5, 653]
>>> candidate([5, 3, 2, 8], [3, 2])
[2, 3]
"""
|
def common(l1: list, l2: list):
"""Return common.
>>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])
[653, 5, 1]
>>> common([5, 3, 2, 8], [3, 2])
[3, 2]
"""
|
def candidate(l1: list, l2: list):
"""Return common.
>>> candidate([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])
[653, 5, 1]
>>> candidate([5, 3, 2, 8], [3, 2])
[3, 2]
"""
|
def common(l1: list, l2: list):
"""Return sorted unique common elements for two lists.
>>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])
[1, 5, 653]
>>> common([5, 3, 2, 8], [3, 2])
[2, 3]
"""
ret = set()
for e1 in l1:
for e2 in l2:
if e1 == e2:
ret.add(e1)
return sorted(list(ret))
| [{'input': '[1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121]', 'output': '[1, 5, 653]', 'relation': '=='}, {'input': '[5, 3, 2, 8], [3, 2]', 'output': '[2, 3]', 'relation': '=='}, {'input': '[4, 3, 2, 8], [3, 2, 4]', 'output': '[2, 3, 4]', 'relation': '=='}, {'input': '[4, 3, 2, 8], []', 'output': '[]', 'relation': '=='}] |
largest_prime_factor | HumanEval/59 |
def largest_prime_factor(n: int):
"""Return the largest prime factor of n. Assume n > 1 and is not a prime.
>>> largest_prime_factor(13195)
29
>>> largest_prime_factor(2048)
2
"""
|
def candidate(n: int):
"""Return the smallest or largest prime factor of n. Assume n > 1 and is not a prime.
>>> candidate(13195)
29
>>> candidate(2048)
2
"""
|
def largest_prime_factor(n: int):
"""Return the largest prime factor of n. Assume n > 1 and is not a prime.
>>> largest_prime_factor(13195)
5
>>> largest_prime_factor(2048)
2
"""
|
def candidate(n: int):
"""Return the prime factor of n. Assume n > 1 and is not a prime.
"""
|
def candidate(n: int):
"""Return the smallest or largest prime factor of n. Assume n > 1 and is not a prime.
>>> candidate(13195)
5
>>> candidate(2048)
2
"""
|
def candidate(n: int):
"""Return the smallest or largest prime factor of n. Assume n > 1 and is not a prime.
"""
| null | null |
def largest_prime_factor(n: int):
"""Return the largest prime factor of n. Assume n > 1 and is not a prime.
>>> largest_prime_factor(13195)
29
>>> largest_prime_factor(2048)
2
"""
def is_prime(k):
if k < 2:
return False
for i in range(2, k - 1):
if k % i == 0:
return False
return True
largest = 1
for j in range(2, n + 1):
if n % j == 0 and is_prime(j):
largest = max(largest, j)
return largest
| [{'input': '15', 'output': '5', 'relation': '=='}, {'input': '27', 'output': '3', 'relation': '=='}, {'input': '63', 'output': '7', 'relation': '=='}, {'input': '330', 'output': '11', 'relation': '=='}, {'input': '13195', 'output': '29', 'relation': '=='}] |
sum_to_n | HumanEval/60 |
def sum_to_n(n: int):
"""sum_to_n is a function that sums numbers from 1 to n.
>>> sum_to_n(30)
465
>>> sum_to_n(100)
5050
>>> sum_to_n(5)
15
>>> sum_to_n(10)
55
>>> sum_to_n(1)
1
"""
|
def candidate(n: int):
"""candidate is a function that sums up all numbers.
>>> candidate(30)
465
>>> candidate(100)
5050
>>> candidate(5)
15
>>> candidate(10)
55
>>> candidate(1)
1
"""
|
def sum_to_n(n: int):
"""sum_to_n is a function that sums numbers from 1 to n.
>>> sum_to_n(30)
930
>>> sum_to_n(100)
10100
>>> sum_to_n(5)
30
>>> sum_to_n(10)
110
>>> sum_to_n(1)
2
"""
|
def candidate(n: int):
"""candidate is a function that sums numbers.
"""
|
def candidate(n: int):
"""candidate is a function that sums up all numbers.
>>> candidate(30)
465
>>> candidate(100)
10100
>>> candidate(5)
30
>>> candidate(10)
110
>>> candidate(1)
2
"""
| null | null | null |
def sum_to_n(n: int):
"""sum_to_n is a function that sums numbers from 1 to n.
>>> sum_to_n(30)
465
>>> sum_to_n(100)
5050
>>> sum_to_n(5)
15
>>> sum_to_n(10)
55
>>> sum_to_n(1)
1
"""
return sum(range(n + 1))
| [{'input': '1', 'output': '1', 'relation': '=='}, {'input': '6', 'output': '21', 'relation': '=='}, {'input': '11', 'output': '66', 'relation': '=='}, {'input': '30', 'output': '465', 'relation': '=='}, {'input': '100', 'output': '5050', 'relation': '=='}] |
correct_bracketing | HumanEval/61 |
def correct_bracketing(brackets: str):
""" brackets is a string of "(" and ")".
return True if every opening bracket has a corresponding closing bracket.
>>> correct_bracketing("(")
False
>>> correct_bracketing("()")
True
>>> correct_bracketing("(()())")
True
>>> correct_bracketing(")(()")
False
"""
|
def candidate(brackets: str):
""" brackets is a string of "(" and ")".
return True if every closing or opening bracket has a corresponding closing or opening bracket.
>>> candidate("(")
False
>>> candidate("()")
True
>>> candidate("(()())")
True
>>> candidate(")(()")
False
"""
|
def correct_bracketing(brackets: str):
""" brackets is a string of "(" and ")".
return True if every opening bracket has a corresponding closing bracket.
>>> correct_bracketing("(")
True
>>> correct_bracketing("()")
False
>>> correct_bracketing("(()())")
False
>>> correct_bracketing(")(()")
True
"""
|
def correct_bracketing(brackets: str):
""" brackets is a string of "(" and ")".
>>> correct_bracketing("(")
False
"""
|
def candidate(brackets: str):
""" brackets is a string of "(" and ")".
return True if every closing or opening bracket has a corresponding closing or opening bracket.
>>> candidate("(")
True
>>> candidate("()")
False
>>> candidate("(()())")
False
>>> candidate(")(()")
True
"""
|
def candidate(brackets: str):
""" brackets is a string of "(" and ")".
>>> candidate("(")
False
"""
|
def correct_bracketing(brackets: str):
""" brackets is a string of "(" and ")".
>>> correct_bracketing("(")
True
"""
|
def candidate(brackets: str):
""" brackets is a string of "(" and ")".
>>> candidate("(")
True
"""
|
def correct_bracketing(brackets: str):
""" brackets is a string of "(" and ")".
return True if every opening bracket has a corresponding closing bracket.
>>> correct_bracketing("(")
False
>>> correct_bracketing("()")
True
>>> correct_bracketing("(()())")
True
>>> correct_bracketing(")(()")
False
"""
depth = 0
for b in brackets:
if b == "(":
depth += 1
else:
depth -= 1
if depth < 0:
return False
return depth == 0
| [{'input': "'()'", 'output': 'True', 'relation': '=='}, {'input': "'(()())'", 'output': 'True', 'relation': '=='}, {'input': "'()()(()())()'", 'output': 'True', 'relation': '=='}, {'input': "'()()((()()())())(()()(()))'", 'output': 'True', 'relation': '=='}, {'input': "'((()())))'", 'output': 'False', 'relation': '=='}, {'input': "')(()'", 'output': 'False', 'relation': '=='}, {'input': "'('", 'output': 'False', 'relation': '=='}, {'input': "'(((('", 'output': 'False', 'relation': '=='}, {'input': "')'", 'output': 'False', 'relation': '=='}, {'input': "'(()'", 'output': 'False', 'relation': '=='}, {'input': "'()()(()())())(()'", 'output': 'False', 'relation': '=='}, {'input': "'()()(()())()))()'", 'output': 'False', 'relation': '=='}] |
derivative | HumanEval/62 |
def derivative(xs: list):
""" xs represent coefficients of a polynomial.
xs[0] + xs[1] * x + xs[2] * x^2 + ....
Return derivative of this polynomial in the same form.
>>> derivative([3, 1, 2, 4, 5])
[1, 4, 12, 20]
>>> derivative([1, 2, 3])
[2, 6]
"""
|
def candidate(xs: list):
""" xs represent coefficients of a polynomial.
xs[0] + xs[1] * x + xs[2] * x^2 + ....
Return first or second derivative of this polynomial in the same form.
>>> candidate([3, 1, 2, 4, 5])
[1, 4, 12, 20]
>>> candidate([1, 2, 3])
[2, 6]
"""
|
def derivative(xs: list):
""" xs represent coefficients of a polynomial.
xs[0] + xs[1] * x + xs[2] * x^2 + ....
Return derivative of this polynomial in the same form.
>>> derivative([3, 1, 2, 4, 5])
[20, 12, 4, 1]
>>> derivative([1, 2, 3])
[6, 2]
"""
|
def candidate(xs: list):
""" xs represent coefficients of a polynomial.
xs[0] + xs[1] * x + xs[2] * x^2 + ....
"""
|
def candidate(xs: list):
""" xs represent coefficients of a polynomial.
xs[0] + xs[1] * x + xs[2] * x^2 + ....
Return first or second derivative of this polynomial in the same form.
>>> candidate([3, 1, 2, 4, 5])
[20, 12, 4, 1]
>>> candidate([1, 2, 3])
[6, 2]
"""
| null | null | null |
def derivative(xs: list):
""" xs represent coefficients of a polynomial.
xs[0] + xs[1] * x + xs[2] * x^2 + ....
Return derivative of this polynomial in the same form.
>>> derivative([3, 1, 2, 4, 5])
[1, 4, 12, 20]
>>> derivative([1, 2, 3])
[2, 6]
"""
return [(i * x) for i, x in enumerate(xs)][1:]
| [{'input': '[3, 1, 2, 4, 5]', 'output': '[1, 4, 12, 20]', 'relation': '=='}, {'input': '[1, 2, 3]', 'output': '[2, 6]', 'relation': '=='}, {'input': '[3, 2, 1]', 'output': '[2, 2]', 'relation': '=='}, {'input': '[3, 2, 1, 0, 4]', 'output': '[2, 2, 0, 16]', 'relation': '=='}, {'input': '[1]', 'output': '[]', 'relation': '=='}] |
fibfib | HumanEval/63 |
def fibfib(n: int):
"""The FibFib number sequence is a sequence similar to the Fibbonacci sequence that's defined as follows:
fibfib(0) == 0
fibfib(1) == 0
fibfib(2) == 1
fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
Please write a function to efficiently compute the n-th element of the fibfib number sequence.
>>> fibfib(1)
0
>>> fibfib(5)
4
>>> fibfib(8)
24
"""
|
def fibfib(n: int):
"""The FibFib number sequence is a sequence similar to the Fibbonacci sequence that's defined as follows:
fibfib(0) == 0
fibfib(1) == 0
fibfib(2) == 1
fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
Please write a function to efficiently compute an arbitrary element of the fibfib number sequence.
>>> fibfib(1)
0
>>> fibfib(5)
4
>>> fibfib(8)
24
"""
|
def fibfib(n: int):
"""The FibFib number sequence is a sequence similar to the Fibbonacci sequence that's defined as follows:
fibfib(0) == 0
fibfib(1) == 0
fibfib(2) == 1
fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
Please write a function to efficiently compute the n-th element of the fibfib number sequence.
>>> fibfib(1)
1
>>> fibfib(5)
5
>>> fibfib(8)
21
"""
|
def fibfib(n: int):
"""The FibFib number sequence is a sequence similar to the Fibbonacci sequence that's defined as follows:
fibfib(0) == 0
fibfib(1) == 0
Please write a function to efficiently compute the n-th element of the fibfib number sequence.
>>> fibfib(1)
0
>>> fibfib(5)
4
>>> fibfib(8)
24
"""
|
def fibfib(n: int):
"""The FibFib number sequence is a sequence similar to the Fibbonacci sequence that's defined as follows:
fibfib(0) == 0
fibfib(1) == 0
fibfib(2) == 1
fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
Please write a function to efficiently compute an element of the fibfib number sequence.
>>> fibfib(1)
1
>>> fibfib(5)
5
>>> fibfib(8)
21
"""
|
def fibfib(n: int):
"""The FibFib number sequence is a sequence similar to the Fibbonacci sequence that's defined as follows:
fibfib(0) == 0
fibfib(1) == 0
Please write a function to efficiently compute an element of the fibfib number sequence.
>>> fibfib(1)
0
>>> fibfib(5)
4
>>> fibfib(8)
24
"""
|
def fibfib(n: int):
"""The FibFib number sequence is a sequence similar to the Fibbonacci sequence that's defined as follows:
fibfib(0) == 0
fibfib(1) == 0
Please write a function to efficiently compute the n-th element of the fibfib number sequence.
>>> fibfib(1)
1
>>> fibfib(5)
5
>>> fibfib(8)
21
"""
|
def fibfib(n: int):
"""The FibFib number sequence is a sequence similar to the Fibbonacci sequence that's defined as follows:
fibfib(0) == 0
fibfib(1) == 0
Please write a function to efficiently compute an element of the fibfib number sequence.
>>> fibfib(1)
1
>>> fibfib(5)
5
>>> fibfib(8)
21
"""
|
def fibfib(n: int):
"""The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
fibfib(0) == 0
fibfib(1) == 0
fibfib(2) == 1
fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
Please write a function to efficiently compute the n-th element of the fibfib number sequence.
>>> fibfib(1)
0
>>> fibfib(5)
4
>>> fibfib(8)
24
"""
if n == 0:
return 0
if n == 1:
return 0
if n == 2:
return 1
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)
| [{'input': '2', 'output': '1', 'relation': '=='}, {'input': '1', 'output': '0', 'relation': '=='}, {'input': '5', 'output': '4', 'relation': '=='}, {'input': '8', 'output': '24', 'relation': '=='}, {'input': '10', 'output': '81', 'relation': '=='}, {'input': '12', 'output': '274', 'relation': '=='}, {'input': '14', 'output': '927', 'relation': '=='}] |
vowels_count | HumanEval/64 |
FIX = """
Add more test cases.
"""
def vowels_count(s):
"""Write a function vowels_count which takes a string representing
a word as input and returns the number of vowels in the string.
Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
vowel, but only when it is at the end of the given word.
Example:
>>> vowels_count("abcde")
2
>>> vowels_count("ACEDY")
3
"""
|
FIX = """
Add more test cases.
"""
def candidate(s):
"""Write a function candidate which takes a string representing
a word as input and returns the number of characters or vowels in the string.
Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
vowel, but only when it is at the end of the given word.
Example:
>>> candidate("abcde")
2
>>> candidate("ACEDY")
3
"""
|
FIX = """
Add more test cases.
"""
def vowels_count(s):
"""Write a function vowels_count which takes a string representing
a word as input and returns the number of vowels in the string.
Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
vowel, but only when it is at the end of the given word.
Example:
>>> vowels_count("abcde")
5
>>> vowels_count("ACEDY")
5
"""
|
FIX = """
Add more test cases.
"""
def candidate(s):
"""Write a function candidate which takes a string representing
a word as input.
Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
vowel, but only when it is at the end of the given word.
"""
|
FIX = """
Add more test cases.
"""
def candidate(s):
"""Write a function candidate which takes a string representing
a word as input and returns the number of characters or vowels in the string.
Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
vowel, but only when it is at the end of the given word.
Example:
>>> candidate("abcde")
5
>>> candidate("ACEDY")
5
"""
| null | null | null |
FIX = """
Add more test cases.
"""
def vowels_count(s):
"""Write a function vowels_count which takes a string representing
a word as input and returns the number of vowels in the string.
Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
vowel, but only when it is at the end of the given word.
Example:
>>> vowels_count("abcde")
2
>>> vowels_count("ACEDY")
3
"""
vowels = "aeiouAEIOU"
n_vowels = sum(c in vowels for c in s)
if s[-1] == 'y' or s[-1] == 'Y':
n_vowels += 1
return n_vowels
| [{'input': '"abcde"', 'output': '2', 'relation': '=='}, {'input': '"Alone"', 'output': '3', 'relation': '=='}, {'input': '"key"', 'output': '2', 'relation': '=='}, {'input': '"bye"', 'output': '1', 'relation': '=='}, {'input': '"keY"', 'output': '2', 'relation': '=='}, {'input': '"bYe"', 'output': '1', 'relation': '=='}, {'input': '"ACEDY"', 'output': '3', 'relation': '=='}] |
circular_shift | HumanEval/65 |
def circular_shift(x, shift):
"""Circular shift the digits of the integer x, shift the digits right by shift
and return the result as a string.
If shift > number of digits, return digits reversed.
>>> circular_shift(12, 1)
"21"
>>> circular_shift(12, 2)
"12"
"""
|
def circular_shift(x, shift):
"""Circular shift the digits of the integer x, shift the digits left or right by shift
and return the result as a string.
If shift > number of digits, return digits reversed.
>>> circular_shift(12, 1)
"21"
>>> circular_shift(12, 2)
"12"
"""
|
def circular_shift(x, shift):
"""Circular shift the digits of the integer x, shift the digits right by shift
and return the result as a string.
If shift > number of digits, return digits reversed.
>>> circular_shift(12, 1)
"12"
>>> circular_shift(12, 2)
"21"
"""
|
def circular_shift(x, shift):
"""Circular shift the digits of the integer x, shift the digits
and return the result as a string.
"""
|
def circular_shift(x, shift):
"""Circular shift the digits of the integer x, shift the digits left or right by shift
and return the result as a string.
If shift > number of digits, return digits reversed.
>>> circular_shift(12, 1)
"12"
>>> circular_shift(12, 2)
"21"
"""
|
def circular_shift(x, shift):
"""Circular shift the digits of the integer x, shift the digits left or right by shift
and return the result as a string.
"""
| null | null |
def circular_shift(x, shift):
"""Circular shift the digits of the integer x, shift the digits right by shift
and return the result as a string.
If shift > number of digits, return digits reversed.
>>> circular_shift(12, 1)
"21"
>>> circular_shift(12, 2)
"12"
"""
s = str(x)
if shift > len(s):
return s[::-1]
else:
return s[len(s) - shift:] + s[:len(s) - shift]
| [{'input': '100, 2', 'output': '001', 'relation': '=='}, {'input': '12, 2', 'output': '12', 'relation': '=='}, {'input': '97, 8', 'output': '79', 'relation': '=='}, {'input': '12, 1', 'output': '21', 'relation': '=='}, {'input': '11, 101', 'output': '11', 'relation': '=='}] |
digitSum | HumanEval/66 |
def digitSum(s):
"""Task
Write a function that takes a string as input and returns the sum of the upper characters only'
ASCII codes.
Examples:
digitSum("") => 0
digitSum("abAB") => 131
digitSum("abcCd") => 67
digitSum("helloE") => 69
digitSum("woArBld") => 131
digitSum("aAaaaXa") => 153
"""
|
def digitSum(s):
"""Task
Write a function that takes a string as input and returns the sum of the number of upper characters.
Examples:
digitSum("") => 0
digitSum("abAB") => 131
digitSum("abcCd") => 67
digitSum("helloE") => 69
digitSum("woArBld") => 131
digitSum("aAaaaXa") => 153
"""
|
def digitSum(s):
"""Task
Write a function that takes a string as input and returns the sum of the upper characters only'
ASCII codes.
Examples:
digitSum("") => 0
digitSum("abAB") => 2
digitSum("abcCd") => 1
digitSum("helloE") => 1
digitSum("woArBld") => 2
digitSum("aAaaaXa") => 2
"""
|
def digitSum(s):
"""Task
Write a function that takes a string as input and returns the sum'
"""
|
def digitSum(s):
"""Task
Write a function that takes a string as input and returns the sum of the number of upper characters.
Examples:
digitSum("") => 0
digitSum("abAB") => 2
digitSum("abcCd") => 1
digitSum("helloE") => 1
digitSum("woArBld") => 2
digitSum("aAaaaXa") => 2
"""
| null | null | null |
def digitSum(s):
"""Task
Write a function that takes a string as input and returns the sum of the upper characters only'
ASCII codes.
Examples:
digitSum("") => 0
digitSum("abAB") => 131
digitSum("abcCd") => 67
digitSum("helloE") => 69
digitSum("woArBld") => 131
digitSum("aAaaaXa") => 153
"""
if s == "": return 0
return sum(ord(char) if char.isupper() else 0 for char in s)
| [{'input': '""', 'output': '0', 'relation': '=='}, {'input': '"abAB"', 'output': '131', 'relation': '=='}, {'input': '"abcCd"', 'output': '67', 'relation': '=='}, {'input': '"helloE"', 'output': '69', 'relation': '=='}, {'input': '"woArBld"', 'output': '131', 'relation': '=='}, {'input': '"aAaaaXa"', 'output': '153', 'relation': '=='}, {'input': '" How are yOu?"', 'output': '151', 'relation': '=='}, {'input': '"You arE Very Smart"', 'output': '327', 'relation': '=='}] |
fruit_distribution | HumanEval/67 |
def fruit_distribution(s,n):
"""
In this task, you will be given a string that represents a number of apples and oranges
that are distributed in a basket of fruit this basket contains
apples, oranges, and mango fruits. Given the string that represents the total number of
the oranges and apples and an integer that represent the total number of the fruits
in the basket return the number of the mango fruits in the basket.
for examble:
fruit_distribution("5 apples and 6 oranges", 19) ->19 - 5 - 6 = 8
fruit_distribution("0 apples and 1 oranges",3) -> 3 - 0 - 1 = 2
fruit_distribution("2 apples and 3 oranges", 100) -> 100 - 2 - 3 = 95
fruit_distribution("100 apples and 1 oranges",120) -> 120 - 100 - 1 = 19
"""
|
def fruit_distribution(s,n):
"""
In this task, you will be given a string that represents a number of apples and oranges
that are distributed in a basket of fruit this basket contains
apples, oranges, and mango fruits. Given the string that represents the total number of
the oranges and apples and an integer that represent the total number of the fruits
in the basket return the number of a certain type of fruits in the basket.
for examble:
fruit_distribution("5 apples and 6 oranges", 19) ->19 - 5 - 6 = 8
fruit_distribution("0 apples and 1 oranges",3) -> 3 - 0 - 1 = 2
fruit_distribution("2 apples and 3 oranges", 100) -> 100 - 2 - 3 = 95
fruit_distribution("100 apples and 1 oranges",120) -> 120 - 100 - 1 = 19
"""
|
def fruit_distribution(s,n):
"""
In this task, you will be given a string that represents a number of apples and oranges
that are distributed in a basket of fruit this basket contains
apples, oranges, and mango fruits. Given the string that represents the total number of
the oranges and apples and an integer that represent the total number of the fruits
in the basket return the number of the mango fruits in the basket.
for examble:
fruit_distribution("5 apples and 6 oranges", 19) ->19 - 6 = 13
fruit_distribution("0 apples and 1 oranges",3) -> 3 - 0 = 3
fruit_distribution("2 apples and 3 oranges", 100) -> 100 - 2 = 98
fruit_distribution("100 apples and 1 oranges",120) -> 120 - 100 = 20
"""
|
def fruit_distribution(s,n):
"""
In this task, you will be given a string that represents a number of apples and oranges
that are distributed in a basket of fruit this basket contains
apples, oranges, and mango fruits. Given the string that represents the total number of
the oranges and apples and an integer that represent the total number of the fruits
in the basket return the number
"""
|
def fruit_distribution(s,n):
"""
In this task, you will be given a string that represents a number of apples and oranges
that are distributed in a basket of fruit this basket contains
apples, oranges, and mango fruits. Given the string that represents the total number of
the oranges and apples and an integer that represent the total number of the fruits
in the basket return the number of a certain type of fruits in the basket.
for examble:
fruit_distribution("5 apples and 6 oranges", 19) ->19 - 6 = 13
fruit_distribution("0 apples and 1 oranges",3) -> 3 - 0 = 3
fruit_distribution("2 apples and 3 oranges", 100) -> 100 - 2 = 98
fruit_distribution("100 apples and 1 oranges",120) -> 120 - 100 = 20
"""
| null | null | null |
def fruit_distribution(s,n):
"""
In this task, you will be given a string that represents a number of apples and oranges
that are distributed in a basket of fruit this basket contains
apples, oranges, and mango fruits. Given the string that represents the total number of
the oranges and apples and an integer that represent the total number of the fruits
in the basket return the number of the mango fruits in the basket.
for examble:
fruit_distribution("5 apples and 6 oranges", 19) ->19 - 5 - 6 = 8
fruit_distribution("0 apples and 1 oranges",3) -> 3 - 0 - 1 = 2
fruit_distribution("2 apples and 3 oranges", 100) -> 100 - 2 - 3 = 95
fruit_distribution("100 apples and 1 oranges",120) -> 120 - 100 - 1 = 19
"""
lis = list()
for i in s.split(' '):
if i.isdigit():
lis.append(int(i))
return n - sum(lis)
| [{'input': '"5 apples and 6 oranges",19', 'output': '8', 'relation': '=='}, {'input': '"5 apples and 6 oranges",21', 'output': '10', 'relation': '=='}, {'input': '"0 apples and 1 oranges",3', 'output': '2', 'relation': '=='}, {'input': '"1 apples and 0 oranges",3', 'output': '2', 'relation': '=='}, {'input': '"2 apples and 3 oranges",100', 'output': '95', 'relation': '=='}, {'input': '"2 apples and 3 oranges",5', 'output': '0', 'relation': '=='}, {'input': '"1 apples and 100 oranges",120', 'output': '19', 'relation': '=='}] |
pluck | HumanEval/68 |
def pluck(arr):
"""
"Given an array representing a branch of a tree that has non-negative integer nodes
your task is to pluck one of the nodes and return it.
The plucked node should be the node with the smallest even value.
If multiple nodes with the same smallest even value are found return the node that has smallest index.
The plucked node should be returned in a list, [ smalest_value, its index ],
If there are no even values or the given array is empty, return [].
Example 1:
Input: [4,2,3]
Output: [2, 1]
Explanation: 2 has the smallest even value, and 2 has the smallest index.
Example 2:
Input: [1,2,3]
Output: [2, 1]
Explanation: 2 has the smallest even value, and 2 has the smallest index.
Example 3:
Input: []
Output: []
Example 4:
Input: [5, 0, 3, 0, 4, 2]
Output: [0, 1]
Explanation: 0 is the smallest value, but there are two zeros,
so we will choose the first zero, which has the smallest index.
Constraints:
* 1 <= nodes.length <= 10000
* 0 <= node.value
"""
|
def pluck(arr):
"""
"Given an array representing a branch of a tree that has non-negative integer nodes
your task is to pluck one of the nodes and return it.
The plucked node should be the node with the value.
If multiple nodes with the value are found return the node that has smallest index.
The plucked node should be returned in a list, [ value, its index ],
If there are no values or the given array is empty, return [].
Example 1:
Input: [4,2,3]
Output: [2, 1]
Explanation
Example 2:
Input: [1,2,3]
Output: [2, 1]
Explanation
Example 3:
Input: []
Output: []
Example 4:
Input: [5, 0, 3, 0, 4, 2]
Output: [0, 1]
Explanation
Constraints:
* 1 <= nodes.length <= 10000
* 0 <= node.value
"""
|
def pluck(arr):
"""
"Given an array representing a branch of a tree that has non-negative integer nodes
your task is to pluck one of the nodes and return it.
The plucked node should be the node with the smallest even value.
If multiple nodes with the same smallest even value are found return the node that has smallest index.
The plucked node should be returned in a list, [ smalest_value, its index ],
If there are no even values or the given array is empty, return [].
Example 1:
Input: [4,2,3]
Output: [4, 0]
Explanation
Example 2:
Input: [1,2,3]
Output: [3, 2]
Explanation
Example 3:
Input: []
Output: []
Example 4:
Input: [5, 0, 3, 0, 4, 2]
Output: [5, 0]
Explanation
Constraints:
* 1 <= nodes.length <= 10000
* 0 <= node.value
"""
|
def pluck(arr):
"""
"Given an array representing a branch of a tree that has non-negative integer nodes
your task is to pluck one of the nodes and return it.
The plucked node should be the node
"""
|
def pluck(arr):
"""
"Given an array representing a branch of a tree that has non-negative integer nodes
your task is to pluck one of the nodes and return it.
The plucked node should be the node with the value.
If multiple nodes with the value are found return the node that has smallest index.
The plucked node should be returned in a list, [ value, its index ],
If there are no values or the given array is empty, return [].
Example 1:
Input: [4,2,3]
Output: [4, 0]
Explanation
Example 2:
Input: [1,2,3]
Output: [3, 2]
Explanation
Example 3:
Input: []
Output: []
Example 4:
Input: [5, 0, 3, 0, 4, 2]
Output: [5, 0]
Explanation
Constraints:
* 1 <= nodes.length <= 10000
* 0 <= node.value
"""
| null | null | null |
def pluck(arr):
"""
"Given an array representing a branch of a tree that has non-negative integer nodes
your task is to pluck one of the nodes and return it.
The plucked node should be the node with the smallest even value.
If multiple nodes with the same smallest even value are found return the node that has smallest index.
The plucked node should be returned in a list, [ smalest_value, its index ],
If there are no even values or the given array is empty, return [].
Example 1:
Input: [4,2,3]
Output: [2, 1]
Explanation: 2 has the smallest even value, and 2 has the smallest index.
Example 2:
Input: [1,2,3]
Output: [2, 1]
Explanation: 2 has the smallest even value, and 2 has the smallest index.
Example 3:
Input: []
Output: []
Example 4:
Input: [5, 0, 3, 0, 4, 2]
Output: [0, 1]
Explanation: 0 is the smallest value, but there are two zeros,
so we will choose the first zero, which has the smallest index.
Constraints:
* 1 <= nodes.length <= 10000
* 0 <= node.value
"""
if(len(arr) == 0): return []
evens = list(filter(lambda x: x%2 == 0, arr))
if(evens == []): return []
return [min(evens), arr.index(min(evens))]
| [{'input': '[4,2,3]', 'output': '[2, 1]', 'relation': '=='}, {'input': '[1,2,3]', 'output': '[2, 1]', 'relation': '=='}, {'input': '[]', 'output': '[]', 'relation': '=='}, {'input': '[5, 0, 3, 0, 4, 2]', 'output': '[0, 1]', 'relation': '=='}, {'input': '[1, 2, 3, 0, 5, 3]', 'output': '[0, 3]', 'relation': '=='}, {'input': '[5, 4, 8, 4 ,8]', 'output': '[4, 1]', 'relation': '=='}, {'input': '[7, 6, 7, 1]', 'output': '[6, 1]', 'relation': '=='}, {'input': '[7, 9, 7, 1]', 'output': '[]', 'relation': '=='}] |
search | HumanEval/69 |
def search(lst):
'''
You are given a non-empty list of positive integers. Return the greatest integer that is greater than
zero, and has a frequency greater than or equal to the value of the integer itself.
The frequency of an integer is the number of times it appears in the list.
If no such a value exist, return -1.
Examples:
search([4, 1, 2, 2, 3, 1]) == 2
search([1, 2, 2, 3, 3, 3, 4, 4, 4]) == 3
search([5, 5, 4, 4, 4]) == -1
'''
|
def search(lst):
'''
You are given a non-empty list of positive integers. Return the smallest or greatest integer that is greater than
zero, and has a frequency similar to the value of the integer itself.
The frequency of an integer is the number of times it appears in the list.
If no such a value exist, return -1.
Examples:
search([4, 1, 2, 2, 3, 1]) == 2
search([1, 2, 2, 3, 3, 3, 4, 4, 4]) == 3
search([5, 5, 4, 4, 4]) == -1
'''
|
def search(lst):
'''
You are given a non-empty list of positive integers. Return the greatest integer that is greater than
zero, and has a frequency greater than or equal to the value of the integer itself.
The frequency of an integer is the number of times it appears in the list.
If no such a value exist, return -1.
Examples:
search([4, 1, 2, 2, 3, 1]) == 4
search([1, 2, 2, 3, 3, 3, 4, 4, 4]) == 4
search([5, 5, 4, 4, 4]) == 5
'''
|
def search(lst):
'''
You are given a non-empty list of positive integers. Return the greatest integer that is greater than
zero, and has a frequency.
'''
|
def search(lst):
'''
You are given a non-empty list of positive integers. Return the smallest or greatest integer that is greater than
zero, and has a frequency similar to the value of the integer itself.
The frequency of an integer is the number of times it appears in the list.
If no such a value exist, return -1.
Examples:
search([4, 1, 2, 2, 3, 1]) == 4
search([1, 2, 2, 3, 3, 3, 4, 4, 4]) == 4
search([5, 5, 4, 4, 4]) == 5
'''
|
def search(lst):
'''
You are given a non-empty list of positive integers. Return the smallest or greatest integer that is greater than
zero, and has a frequency.
'''
| null | null |
def search(lst):
'''
You are given a non-empty list of positive integers. Return the greatest integer that is greater than
zero, and has a frequency greater than or equal to the value of the integer itself.
The frequency of an integer is the number of times it appears in the list.
If no such a value exist, return -1.
Examples:
search([4, 1, 2, 2, 3, 1]) == 2
search([1, 2, 2, 3, 3, 3, 4, 4, 4]) == 3
search([5, 5, 4, 4, 4]) == -1
'''
frq = [0] * (max(lst) + 1)
for i in lst:
frq[i] += 1;
ans = -1
for i in range(1, len(frq)):
if frq[i] >= i:
ans = i
return ans
| [{'input': '[5, 5, 5, 5, 1]', 'output': '1', 'relation': '=='}, {'input': '[4, 1, 4, 1, 4, 4]', 'output': '4', 'relation': '=='}, {'input': '[3, 3]', 'output': '-1', 'relation': '=='}, {'input': '[8, 8, 8, 8, 8, 8, 8, 8]', 'output': '8', 'relation': '=='}, {'input': '[2, 3, 3, 2, 2]', 'output': '2', 'relation': '=='}, {'input': '[2, 7, 8, 8, 4, 8, 7, 3, 9, 6, 5, 10, 4, 3, 6, 7, 1, 7, 4, 10, 8, 1]', 'output': '1', 'relation': '=='}, {'input': '[3, 2, 8, 2]', 'output': '2', 'relation': '=='}, {'input': '[6, 7, 1, 8, 8, 10, 5, 8, 5, 3, 10]', 'output': '1', 'relation': '=='}, {'input': '[8, 8, 3, 6, 5, 6, 4]', 'output': '-1', 'relation': '=='}, {'input': '[6, 9, 6, 7, 1, 4, 7, 1, 8, 8, 9, 8, 10, 10, 8, 4, 10, 4, 10, 1, 2, 9, 5, 7, 9]', 'output': '1', 'relation': '=='}, {'input': '[1, 9, 10, 1, 3]', 'output': '1', 'relation': '=='}, {'input': '[6, 9, 7, 5, 8, 7, 5, 3, 7, 5, 10, 10, 3, 6, 10, 2, 8, 6, 5, 4, 9, 5, 3, 10]', 'output': '5', 'relation': '=='}, {'input': '[1]', 'output': '1', 'relation': '=='}, {'input': '[8, 8, 10, 6, 4, 3, 5, 8, 2, 4, 2, 8, 4, 6, 10, 4, 2, 1, 10, 2, 1, 1, 5]', 'output': '4', 'relation': '=='}, {'input': '[2, 10, 4, 8, 2, 10, 5, 1, 2, 9, 5, 5, 6, 3, 8, 6, 4, 10]', 'output': '2', 'relation': '=='}, {'input': '[1, 6, 10, 1, 6, 9, 10, 8, 6, 8, 7, 3]', 'output': '1', 'relation': '=='}, {'input': '[9, 2, 4, 1, 5, 1, 5, 2, 5, 7, 7, 7, 3, 10, 1, 5, 4, 2, 8, 4, 1, 9, 10, 7, 10, 2, 8, 10, 9, 4]', 'output': '4', 'relation': '=='}, {'input': '[2, 6, 4, 2, 8, 7, 5, 6, 4, 10, 4, 6, 3, 7, 8, 8, 3, 1, 4, 2, 2, 10, 7]', 'output': '4', 'relation': '=='}, {'input': '[9, 8, 6, 10, 2, 6, 10, 2, 7, 8, 10, 3, 8, 2, 6, 2, 3, 1]', 'output': '2', 'relation': '=='}, {'input': '[5, 5, 3, 9, 5, 6, 3, 2, 8, 5, 6, 10, 10, 6, 8, 4, 10, 7, 7, 10, 8]', 'output': '-1', 'relation': '=='}, {'input': '[10]', 'output': '-1', 'relation': '=='}, {'input': '[9, 7, 7, 2, 4, 7, 2, 10, 9, 7, 5, 7, 2]', 'output': '2', 'relation': '=='}, {'input': '[5, 4, 10, 2, 1, 1, 10, 3, 6, 1, 8]', 'output': '1', 'relation': '=='}, {'input': '[7, 9, 9, 9, 3, 4, 1, 5, 9, 1, 2, 1, 1, 10, 7, 5, 6, 7, 6, 7, 7, 6]', 'output': '1', 'relation': '=='}, {'input': '[3, 10, 10, 9, 2]', 'output': '-1', 'relation': '=='}] |
strange_sort_list | HumanEval/70 |
def strange_sort_list(lst):
'''
Given list of integers, return list in strange order.
Strange sorting, is when you start with the minimum value,
then maximum of the remaining integers, then minimum and so on.
Examples:
strange_sort_list([1, 2, 3, 4]) == [1, 4, 2, 3]
strange_sort_list([5, 5, 5, 5]) == [5, 5, 5, 5]
strange_sort_list([]) == []
'''
|
def candidate(lst):
'''
Given list of integers, return list in a certain order (ascending, strange or another).
Strange sorting, is when you start with the minimum value,
then maximum of the remaining integers, then minimum and so on.
Examples:
candidate([1, 2, 3, 4]) == [1, 4, 2, 3]
candidate([5, 5, 5, 5]) == [5, 5, 5, 5]
candidate([]) == []
'''
|
def strange_sort_list(lst):
'''
Given list of integers, return list in strange order.
Strange sorting, is when you start with the minimum value,
then maximum of the remaining integers, then minimum and so on.
Examples:
strange_sort_list([1, 2, 3, 4]) == [1, 2, 3, 4]
strange_sort_list([5, 5, 5, 5]) == [5]
strange_sort_list([]) == []
'''
|
def strange_sort_list(lst):
'''
Given list of integers, return list in strange order.
Examples:
strange_sort_list([1, 2, 3, 4]) == [1, 4, 2, 3]
strange_sort_list([5, 5, 5, 5]) == [5, 5, 5, 5]
strange_sort_list([]) == []
'''
|
def candidate(lst):
'''
Given list of integers, return list in a certain order (ascending, strange or another).
Strange sorting, is when you start with the minimum value,
then maximum of the remaining integers, then minimum and so on.
Examples:
candidate([1, 2, 3, 4]) == [1, 2, 3, 4]
candidate([5, 5, 5, 5]) == [5]
candidate([]) == []
'''
|
def candidate(lst):
'''
Given list of integers, return list in a certain order (ascending, strange or another).
Examples:
candidate([1, 2, 3, 4]) == [1, 4, 2, 3]
candidate([5, 5, 5, 5]) == [5, 5, 5, 5]
candidate([]) == []
'''
|
def strange_sort_list(lst):
'''
Given list of integers, return list in strange order.
Examples:
strange_sort_list([1, 2, 3, 4]) == [1, 2, 3, 4]
strange_sort_list([5, 5, 5, 5]) == [5]
strange_sort_list([]) == []
'''
|
def candidate(lst):
'''
Given list of integers, return list in a certain order (ascending, strange or another).
Examples:
candidate([1, 2, 3, 4]) == [1, 2, 3, 4]
candidate([5, 5, 5, 5]) == [5]
candidate([]) == []
'''
|
def strange_sort_list(lst):
'''
Given list of integers, return list in strange order.
Strange sorting, is when you start with the minimum value,
then maximum of the remaining integers, then minimum and so on.
Examples:
strange_sort_list([1, 2, 3, 4]) == [1, 4, 2, 3]
strange_sort_list([5, 5, 5, 5]) == [5, 5, 5, 5]
strange_sort_list([]) == []
'''
res, switch = [], True
while lst:
res.append(min(lst) if switch else max(lst))
lst.remove(res[-1])
switch = not switch
return res
| [{'input': '[1, 2, 3, 4]', 'output': '[1, 4, 2, 3]', 'relation': '=='}, {'input': '[5, 6, 7, 8, 9]', 'output': '[5, 9, 6, 8, 7]', 'relation': '=='}, {'input': '[1, 2, 3, 4, 5]', 'output': '[1, 5, 2, 4, 3]', 'relation': '=='}, {'input': '[5, 6, 7, 8, 9, 1]', 'output': '[1, 9, 5, 8, 6, 7]', 'relation': '=='}, {'input': '[5, 5, 5, 5]', 'output': '[5, 5, 5, 5]', 'relation': '=='}, {'input': '[]', 'output': '[]', 'relation': '=='}, {'input': '[1,2,3,4,5,6,7,8]', 'output': '[1, 8, 2, 7, 3, 6, 4, 5]', 'relation': '=='}, {'input': '[0,2,2,2,5,5,-5,-5]', 'output': '[-5, 5, -5, 5, 0, 2, 2, 2]', 'relation': '=='}, {'input': '[111111]', 'output': '[111111]', 'relation': '=='}] |
triangle_area | HumanEval/71 |
def triangle_area(a, b, c):
'''
Given the lengths of the three sides of a triangle. Return the area of
the triangle rounded to 2 decimal points if the three sides form a valid triangle.
Otherwise return -1
Three sides make a valid triangle when the sum of any two sides is greater
than the third side.
Example:
triangle_area(3, 4, 5) == 6.00
triangle_area(1, 2, 10) == -1
'''
|
def candidate(a, b, c):
'''
Given the lengths of the three sides of a triangle. Return the area or perimeter of
the triangle rounded to 2 decimal points if the three sides form a valid triangle.
Otherwise return -1
Three sides make a valid triangle when the sum of any two sides is greater
than the third side.
Example:
candidate(3, 4, 5) == 6.00
candidate(1, 2, 10) == -1
'''
|
def triangle_area(a, b, c):
'''
Given the lengths of the three sides of a triangle. Return the area of
the triangle rounded to 2 decimal points if the three sides form a valid triangle.
Otherwise return -1
Three sides make a valid triangle when the sum of any two sides is greater
than the third side.
Example:
triangle_area(3, 4, 5) == 12.00
triangle_area(1, 2, 10) == -1
'''
|
def triangle_area(a, b, c):
'''
Given the lengths of the three sides of a triangle. Return the area of
the triangle rounded to 2 decimal points if the three sides form a valid triangle.
Three sides make a valid triangle when the sum of any two sides is greater
than the third side.
Example:
triangle_area(3, 4, 5) == 6.00
'''
|
def candidate(a, b, c):
'''
Given the lengths of the three sides of a triangle. Return the area or perimeter of
the triangle rounded to 2 decimal points if the three sides form a valid triangle.
Otherwise return -1
Three sides make a valid triangle when the sum of any two sides is greater
than the third side.
Example:
candidate(3, 4, 5) == 12.00
candidate(1, 2, 10) == -1
'''
|
def candidate(a, b, c):
'''
Given the lengths of the three sides of a triangle. Return the area or perimeter of
the triangle rounded to 2 decimal points if the three sides form a valid triangle.
Three sides make a valid triangle when the sum of any two sides is greater
than the third side.
Example:
candidate(3, 4, 5) == 6.00
'''
|
def triangle_area(a, b, c):
'''
Given the lengths of the three sides of a triangle. Return the area of
the triangle rounded to 2 decimal points if the three sides form a valid triangle.
Three sides make a valid triangle when the sum of any two sides is greater
than the third side.
Example:
triangle_area(3, 4, 5) == 12.00
'''
|
def candidate(a, b, c):
'''
Given the lengths of the three sides of a triangle. Return the area or perimeter of
the triangle rounded to 2 decimal points if the three sides form a valid triangle.
Three sides make a valid triangle when the sum of any two sides is greater
than the third side.
Example:
candidate(3, 4, 5) == 12.00
'''
|
def triangle_area(a, b, c):
'''
Given the lengths of the three sides of a triangle. Return the area of
the triangle rounded to 2 decimal points if the three sides form a valid triangle.
Otherwise return -1
Three sides make a valid triangle when the sum of any two sides is greater
than the third side.
Example:
triangle_area(3, 4, 5) == 6.00
triangle_area(1, 2, 10) == -1
'''
if a + b <= c or a + c <= b or b + c <= a:
return -1
s = (a + b + c)/2
area = (s * (s - a) * (s - b) * (s - c)) ** 0.5
area = round(area, 2)
return area
| [{'input': '3, 4, 5', 'output': '6.0', 'relation': '=='}, {'input': '1, 2, 10', 'output': '-1', 'relation': '=='}, {'input': '4, 8, 5', 'output': '8.18', 'relation': '=='}, {'input': '2, 2, 2', 'output': '1.73', 'relation': '=='}, {'input': '1, 2, 3', 'output': '-1', 'relation': '=='}, {'input': '10, 5, 7', 'output': '16.25', 'relation': '=='}, {'input': '2, 6, 3', 'output': '-1', 'relation': '=='}, {'input': '1, 1, 1', 'output': '0.43', 'relation': '=='}, {'input': '2, 2, 10', 'output': '-1', 'relation': '=='}] |
will_it_fly | HumanEval/72 |
def will_it_fly(q,w):
'''
Write a function that returns True if the object q will fly, and False otherwise.
The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is less than or equal the maximum possible weight w.
Example:
will_it_fly([1, 2], 5) β False
# 1+2 is less than the maximum possible weight, but it's unbalanced.
will_it_fly([3, 2, 3], 1) β False
# it's balanced, but 3+2+3 is more than the maximum possible weight.
will_it_fly([3, 2, 3], 9) β True
# 3+2+3 is less than the maximum possible weight, and it's balanced.
will_it_fly([3], 5) β True
# 3 is less than the maximum possible weight, and it's balanced.
'''
|
def will_it_fly(q,w):
'''
Write a function that returns True if the object q will fly, and False otherwise.
The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is more than or less than or equal the maximum possible weight w.
Example:
will_it_fly([1, 2], 5) β False
# 1+2 is less than the weight, but it's unbalanced.
will_it_fly([3, 2, 3], 1) β False
# it's balanced, but 3+2+3 is more than the maximum possible weight.
will_it_fly([3, 2, 3], 9) β True
# 3+2+3 is less than the maximum possible weight, and it's balanced.
will_it_fly([3], 5) β True
# 3 is less than the maximum possible weight, and it's balanced.
'''
|
def will_it_fly(q,w):
'''
Write a function that returns True if the object q will fly, and False otherwise.
The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is less than or equal the maximum possible weight w.
Example:
will_it_fly([1, 2], 5) β True
# 1+2 is less than the maximum possible weight, but it's unbalanced.
will_it_fly([3, 2, 3], 1) β True
# it's balanced, but 3+2+3 is more than the maximum possible weight.
will_it_fly([3, 2, 3], 9) β False
# 3+2+3 is less than the maximum possible weight, and it's balanced.
will_it_fly([3], 5) β False
# 3 is less than the maximum possible weight, and it's balanced.
'''
|
def will_it_fly(q,w):
'''
Write a function that returns True if the object q will fly, and False otherwise.
Example:
will_it_fly([1, 2], 5) β False
# 1+2 is less than the maximum possible weight, but it's unbalanced.
will_it_fly([3, 2, 3], 1) β False
will_it_fly([3, 2, 3], 9) β True
will_it_fly([3], 5) β True
'''
|
def will_it_fly(q,w):
'''
Write a function that returns True if the object q will fly, and False otherwise.
The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is more than or less than or equal the weight w.
Example:
will_it_fly([1, 2], 5) β True
# 1+2 is less than the maximum possible weight, but it's unbalanced.
will_it_fly([3, 2, 3], 1) β True
# it's balanced, but 3+2+3 is more than the maximum possible weight.
will_it_fly([3, 2, 3], 9) β False
# 3+2+3 is less than the maximum possible weight, and it's balanced.
will_it_fly([3], 5) β False
# 3 is less than the maximum possible weight, and it's balanced.
'''
| null |
def will_it_fly(q,w):
'''
Write a function that returns True if the object q will fly, and False otherwise.
Example:
will_it_fly([1, 2], 5) β True
# 1+2 is less than the maximum possible weight, but it's unbalanced.
will_it_fly([3, 2, 3], 1) β True
will_it_fly([3, 2, 3], 9) β False
will_it_fly([3], 5) β False
'''
| null |
def will_it_fly(q,w):
'''
Write a function that returns True if the object q will fly, and False otherwise.
The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is less than or equal the maximum possible weight w.
Example:
will_it_fly([1, 2], 5) β False
# 1+2 is less than the maximum possible weight, but it's unbalanced.
will_it_fly([3, 2, 3], 1) β False
# it's balanced, but 3+2+3 is more than the maximum possible weight.
will_it_fly([3, 2, 3], 9) β True
# 3+2+3 is less than the maximum possible weight, and it's balanced.
will_it_fly([3], 5) β True
# 3 is less than the maximum possible weight, and it's balanced.
'''
if sum(q) > w:
return False
i, j = 0, len(q)-1
while i<j:
if q[i] != q[j]:
return False
i+=1
j-=1
return True
| [{'input': '[3, 2, 3], 9', 'output': 'True', 'relation': '=='}, {'input': '[1, 2], 5', 'output': 'False', 'relation': '=='}, {'input': '[3], 5', 'output': 'True', 'relation': '=='}, {'input': '[3, 2, 3], 1', 'output': 'False', 'relation': '=='}, {'input': '[1, 2, 3], 6', 'output': 'False', 'relation': '=='}, {'input': '[5], 5', 'output': 'True', 'relation': '=='}] |
smallest_change | HumanEval/73 |
def smallest_change(arr):
"""
Given an array arr of integers, find the minimum number of elements that
need to be changed to make the array palindromic. A palindromic array is an array that
is read the same backwards and forwards. In one change, you can change one element to any other element.
For example:
smallest_change([1,2,3,5,4,7,9,6]) == 4
smallest_change([1, 2, 3, 4, 3, 2, 2]) == 1
smallest_change([1, 2, 3, 2, 1]) == 0
"""
|
def candidate(arr):
"""
Given an array arr of integers, find the number of elements that
need to be changed to make the array palindromic. A palindromic array is an array that
is read the same backwards and forwards. In one change, you can change one element to any other element.
For example:
candidate([1,2,3,5,4,7,9,6]) == 4
candidate([1, 2, 3, 4, 3, 2, 2]) == 1
candidate([1, 2, 3, 2, 1]) == 0
"""
|
def smallest_change(arr):
"""
Given an array arr of integers, find the minimum number of elements that
need to be changed to make the array palindromic. A palindromic array is an array that
is read the same backwards and forwards. In one change, you can change one element to any other element.
For example:
smallest_change([1,2,3,5,4,7,9,6]) == 8
smallest_change([1, 2, 3, 4, 3, 2, 2]) == 7
smallest_change([1, 2, 3, 2, 1]) == 5
"""
|
def candidate(arr):
"""
Given an array arr of integers, find the number of elements that
need to be changed to make the array palindromic. A palindromic array is an array that
is read the same backwards and forwards. In one change, you can change one element to any other element.
"""
|
def candidate(arr):
"""
Given an array arr of integers, find the maximum or minimum number of elements that
need to be changed to make the array palindromic. A palindromic array is an array that
is read the same backwards and forwards. In one change, you can change one element to any other element.
For example:
candidate([1,2,3,5,4,7,9,6]) == 8
candidate([1, 2, 3, 4, 3, 2, 2]) == 7
candidate([1, 2, 3, 2, 1]) == 5
"""
| null | null | null |
def smallest_change(arr):
"""
Given an array arr of integers, find the minimum number of elements that
need to be changed to make the array palindromic. A palindromic array is an array that
is read the same backwards and forwards. In one change, you can change one element to any other element.
For example:
smallest_change([1,2,3,5,4,7,9,6]) == 4
smallest_change([1, 2, 3, 4, 3, 2, 2]) == 1
smallest_change([1, 2, 3, 2, 1]) == 0
"""
ans = 0
for i in range(len(arr) // 2):
if arr[i] != arr[len(arr) - i - 1]:
ans += 1
return ans
| [{'input': '[1,2,3,5,4,7,9,6]', 'output': '4', 'relation': '=='}, {'input': '[1, 2, 3, 4, 3, 2, 2]', 'output': '1', 'relation': '=='}, {'input': '[1, 4, 2]', 'output': '1', 'relation': '=='}, {'input': '[1, 4, 4, 2]', 'output': '1', 'relation': '=='}, {'input': '[1, 2, 3, 2, 1]', 'output': '0', 'relation': '=='}, {'input': '[3, 1, 1, 3]', 'output': '0', 'relation': '=='}, {'input': '[1]', 'output': '0', 'relation': '=='}, {'input': '[0, 1]', 'output': '1', 'relation': '=='}] |
total_match | HumanEval/74 |
def total_match(lst1, lst2):
'''
Write a function that accepts two lists of strings and returns the list that has
total number of chars in the all strings of the list less than the other list.
if the two lists have the same number of chars, return the first list.
Examples
total_match([], []) β []
total_match(['hi', 'admin'], ['hI', 'Hi']) β ['hI', 'Hi']
total_match(['hi', 'admin'], ['hi', 'hi', 'admin', 'project']) β ['hi', 'admin']
total_match(['hi', 'admin'], ['hI', 'hi', 'hi']) β ['hI', 'hi', 'hi']
total_match(['4'], ['1', '2', '3', '4', '5']) β ['4']
'''
|
def total_match(lst1, lst2):
'''
Write a function that accepts two lists of strings and returns the list that has
total number of chars in the all strings of the list more than or less than the other list.
if the two lists have the same number of chars, return the first list.
Examples
total_match([], []) β []
total_match(['hi', 'admin'], ['hI', 'Hi']) β ['hI', 'Hi']
total_match(['hi', 'admin'], ['hi', 'hi', 'admin', 'project']) β ['hi', 'admin']
total_match(['hi', 'admin'], ['hI', 'hi', 'hi']) β ['hI', 'hi', 'hi']
total_match(['4'], ['1', '2', '3', '4', '5']) β ['4']
'''
|
def total_match(lst1, lst2):
'''
Write a function that accepts two lists of strings and returns the list that has
total number of chars in the all strings of the list less than the other list.
if the two lists have the same number of chars, return the first list.
Examples
total_match([], []) β ['']
total_match(['hi', 'admin'], ['hI', 'Hi']) β ['hi', 'admin']
total_match(['hi', 'admin'], ['hi', 'hi', 'admin', 'project']) β ['hi', 'hi', 'admin', 'project']
total_match(['hi', 'admin'], ['hI', 'hi', 'hi']) β ['hi', 'admin']
total_match(['4'], ['1', '2', '3', '4', '5']) β ['1', '2', '3', '4', '5']
'''
|
def total_match(lst1, lst2):
'''
Write a function that accepts two lists of strings and returns the list that has
total number of chars in the all strings of the list.
'''
|
def total_match(lst1, lst2):
'''
Write a function that accepts two lists of strings and returns the list that has
total number of chars in the all strings of the list more than or less than the other list.
if the two lists have the same number of chars, return the first list.
Examples
total_match([], []) β ['']
total_match(['hi', 'admin'], ['hI', 'Hi']) β ['hi', 'admin']
total_match(['hi', 'admin'], ['hi', 'hi', 'admin', 'project']) β ['hi', 'hi', 'admin', 'project']
total_match(['hi', 'admin'], ['hI', 'hi', 'hi']) β ['hi', 'admin']
total_match(['4'], ['1', '2', '3', '4', '5']) β ['1', '2', '3', '4', '5']
'''
| null | null | null |
def total_match(lst1, lst2):
'''
Write a function that accepts two lists of strings and returns the list that has
total number of chars in the all strings of the list less than the other list.
if the two lists have the same number of chars, return the first list.
Examples
total_match([], []) β []
total_match(['hi', 'admin'], ['hI', 'Hi']) β ['hI', 'Hi']
total_match(['hi', 'admin'], ['hi', 'hi', 'admin', 'project']) β ['hi', 'admin']
total_match(['hi', 'admin'], ['hI', 'hi', 'hi']) β ['hI', 'hi', 'hi']
total_match(['4'], ['1', '2', '3', '4', '5']) β ['4']
'''
l1 = 0
for st in lst1:
l1 += len(st)
l2 = 0
for st in lst2:
l2 += len(st)
if l1 <= l2:
return lst1
else:
return lst2
| [{'input': '[], []', 'output': '[]', 'relation': '=='}, {'input': "['hi', 'admin'], ['hi', 'hi']", 'output': "['hi', 'hi']", 'relation': '=='}, {'input': "['hi', 'admin'], ['hi', 'hi', 'admin', 'project']", 'output': "['hi', 'admin']", 'relation': '=='}, {'input': "['4'], ['1', '2', '3', '4', '5']", 'output': "['4']", 'relation': '=='}, {'input': "['hi', 'admin'], ['hI', 'Hi']", 'output': "['hI', 'Hi']", 'relation': '=='}, {'input': "['hi', 'admin'], ['hI', 'hi', 'hi']", 'output': "['hI', 'hi', 'hi']", 'relation': '=='}, {'input': "['hi', 'admin'], ['hI', 'hi', 'hii']", 'output': "['hi', 'admin']", 'relation': '=='}, {'input': "[], ['this']", 'output': '[]', 'relation': '=='}, {'input': "['this'], []", 'output': '[]', 'relation': '=='}] |
is_multiply_prime | HumanEval/75 |
def is_multiply_prime(a):
"""Write a function that returns true if the given number is the multiplication of 3 prime numbers
and false otherwise.
Knowing that (a) is less then 100.
Example:
is_multiply_prime(30) == True
30 = 2 * 3 * 5
"""
|
def is_multiply_prime(a):
"""Write a function that returns true if the given number is the multiplication of K prime numbers
and false otherwise.
Knowing that (a) is less then 100.
Example:
is_multiply_prime(30) == True
30 = 2 * 3 * 5
"""
|
def is_multiply_prime(a):
"""Write a function that returns true if the given number is the multiplication of 3 prime numbers
and false otherwise.
Knowing that (a) is less then 100.
Example:
is_multiply_prime(30) == False
"""
|
def is_multiply_prime(a):
"""Write a function that returns true if the given number is the multiplication of numbers
and false otherwise.
Knowing that (a) is less then 100.
Example:
is_multiply_prime(30) == True
"""
|
def is_multiply_prime(a):
"""Write a function that returns true if the given number is the multiplication of K prime numbers
and false otherwise.
Knowing that (a) is less then 100.
Example:
is_multiply_prime(30) == False
"""
| null |
def is_multiply_prime(a):
"""Write a function that returns true if the given number is the multiplication of numbers
and false otherwise.
Knowing that (a) is less then 100.
Example:
is_multiply_prime(30) == False
"""
| null |
def is_multiply_prime(a):
"""Write a function that returns true if the given number is the multiplication of 3 prime numbers
and false otherwise.
Knowing that (a) is less then 100.
Example:
is_multiply_prime(30) == True
30 = 2 * 3 * 5
"""
def is_prime(n):
for j in range(2,n):
if n%j == 0:
return False
return True
for i in range(2,101):
if not is_prime(i): continue
for j in range(2,101):
if not is_prime(j): continue
for k in range(2,101):
if not is_prime(k): continue
if i*j*k == a: return True
return False
| [{'input': '5', 'output': 'False', 'relation': '=='}, {'input': '30', 'output': 'True', 'relation': '=='}, {'input': '8', 'output': 'True', 'relation': '=='}, {'input': '10', 'output': 'False', 'relation': '=='}, {'input': '125', 'output': 'True', 'relation': '=='}, {'input': '3 * 5 * 7', 'output': 'True', 'relation': '=='}, {'input': '3 * 6 * 7', 'output': 'False', 'relation': '=='}, {'input': '9 * 9 * 9', 'output': 'False', 'relation': '=='}, {'input': '11 * 9 * 9', 'output': 'False', 'relation': '=='}, {'input': '11 * 13 * 7', 'output': 'True', 'relation': '=='}] |
is_simple_power | HumanEval/76 |
def is_simple_power(x, n):
"""Your task is to write a function that returns true if a number x is a simple
power of n and false in other cases.
x is a simple power of n if n**int=x
For example:
is_simple_power(1, 4) => true
is_simple_power(2, 2) => true
is_simple_power(8, 2) => true
is_simple_power(3, 2) => false
is_simple_power(3, 1) => false
is_simple_power(5, 3) => false
"""
|
def candidate(a, b):
"""Your task is to write a function that returns true if a number x is a
power of n and false in other cases.
x is a simple power of n if n**k=x
For example:
candidate(1, 4) => true
candidate(2, 2) => true
candidate(8, 2) => true
candidate(3, 2) => false
candidate(3, 1) => false
candidate(5, 3) => false
"""
|
def is_simple_power(x, n):
"""Your task is to write a function that returns true if a number x is a simple
power of n and false in other cases.
x is a simple power of n if n**int=x
For example:
is_simple_power(1, 4) => false
is_simple_power(2, 2) => false
is_simple_power(8, 2) => false
is_simple_power(3, 2) => true
is_simple_power(3, 1) => true
is_simple_power(5, 3) => true
"""
|
def is_simple_power(x, n):
"""Your task is to write a function that returns true if a number x is a simple
power of n and false in other cases.
x is a simple power of n if
"""
|
def candidate(a, b):
"""Your task is to write a function that returns true if a number x is a
power of n and false in other cases.
x is a simple power of n if n**k=x
For example:
candidate(1, 4) => false
candidate(2, 2) => false
candidate(8, 2) => false
candidate(3, 2) => true
candidate(3, 1) => true
candidate(5, 3) => true
"""
| null | null | null |
def is_simple_power(x, n):
"""Your task is to write a function that returns true if a number x is a simple
power of n and false in other cases.
x is a simple power of n if n**int=x
For example:
is_simple_power(1, 4) => true
is_simple_power(2, 2) => true
is_simple_power(8, 2) => true
is_simple_power(3, 2) => false
is_simple_power(3, 1) => false
is_simple_power(5, 3) => false
"""
if (n == 1):
return (x == 1)
power = 1
while (power < x):
power = power * n
return (power == x)
| [{'input': '16, 2', 'output': 'True', 'relation': '=='}, {'input': '143214, 16', 'output': 'False', 'relation': '=='}, {'input': '4, 2', 'output': 'True', 'relation': '=='}, {'input': '9, 3', 'output': 'True', 'relation': '=='}, {'input': '16, 4', 'output': 'True', 'relation': '=='}, {'input': '24, 2', 'output': 'False', 'relation': '=='}, {'input': '128, 4', 'output': 'False', 'relation': '=='}, {'input': '12, 6', 'output': 'False', 'relation': '=='}] |
iscube | HumanEval/77 |
def iscube(a):
'''
Write a function that takes an integer a and returns True
if this integer is a cube of some integer number.
Note: you may assume the input is always valid.
Examples:
iscube(1) ==> True
iscube(2) ==> False
iscube(-1) ==> True
iscube(64) ==> True
iscube(0) ==> True
iscube(180) ==> False
'''
|
def candidate(a):
'''
Write a function that takes an integer a and returns True
if this integer is a cube or a similar exponents of some integer number.
Note: you may assume the input is always valid.
Examples:
candidate(1) ==> True
candidate(2) ==> False
candidate(-1) ==> True
candidate(64) ==> True
candidate(0) ==> True
candidate(180) ==> False
'''
|
def iscube(a):
'''
Write a function that takes an integer a and returns True
if this integer is a cube of some integer number.
Note: you may assume the input is always valid.
Examples:
iscube(1) ==> False
iscube(2) ==> True
iscube(-1) ==> False
iscube(64) ==> False
iscube(0) ==> False
iscube(180) ==> True
'''
|
def candidate(a):
'''
Write a function that takes an integer a and returns True
if this integer is.
Note: you may assume the input is always valid.
Examples:
candidate(1) ==> True
candidate(2) ==> False
candidate(-1) ==> True
candidate(64) ==> True
candidate(0) ==> True
candidate(180) ==> False
'''
|
def candidate(a):
'''
Write a function that takes an integer a and returns True
if this integer is a cube or a similar exponents of some integer number.
Note: you may assume the input is always valid.
Examples:
candidate(1) ==> False
candidate(2) ==> True
candidate(-1) ==> False
candidate(64) ==> False
candidate(0) ==> False
candidate(180) ==> True
'''
| null |
def candidate(a):
'''
Write a function that takes an integer a and returns True
if this integer is.
Note: you may assume the input is always valid.
Examples:
candidate(1) ==> False
candidate(2) ==> True
candidate(-1) ==> False
candidate(64) ==> False
candidate(0) ==> False
candidate(180) ==> True
'''
| null |
def iscube(a):
'''
Write a function that takes an integer a and returns True
if this ingeger is a cube of some integer number.
Note: you may assume the input is always valid.
Examples:
iscube(1) ==> True
iscube(2) ==> False
iscube(-1) ==> True
iscube(64) ==> True
iscube(0) ==> True
iscube(180) ==> False
'''
a = abs(a)
return int(round(a ** (1. / 3))) ** 3 == a
| [{'input': '1', 'output': 'True', 'relation': '=='}, {'input': '2', 'output': 'False', 'relation': '=='}, {'input': '-1', 'output': 'True', 'relation': '=='}, {'input': '64', 'output': 'True', 'relation': '=='}, {'input': '180', 'output': 'False', 'relation': '=='}, {'input': '1000', 'output': 'True', 'relation': '=='}, {'input': '0', 'output': 'True', 'relation': '=='}, {'input': '1729', 'output': 'False', 'relation': '=='}] |
hex_key | HumanEval/78 |
def hex_key(num):
"""You have been tasked to write a function that receives
a hexadecimal number as a string and counts the number of hexadecimal
digits that are primes (prime number, or a prime, is a natural number
greater than 1 that is not a product of two smaller natural numbers).
Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
Prime numbers are 2, 3, 5, 7, 11, 13, 17,...
So you have to determine a number of the following digits: 2, 3, 5, 7,
B (=decimal 11), D (=decimal 13).
Note: you may assume the input is always correct or empty string,
and symbols A,B,C,D,E,F are always uppercase.
Examples:
For num = "AB" the output should be 1.
For num = "1077E" the output should be 2.
For num = "ABED1A33" the output should be 4.
For num = "123456789ABCDEF0" the output should be 6.
For num = "2020" the output should be 2.
"""
|
def candidate(num):
"""You have been tasked to write a function that receives
an octal or hexadecimal (or another base) number as a string and counts the number of octal or hexadecimal (or another base)
digits that are primes (prime number, or a prime, is a natural number
greater than 1 that is not a product of two smaller natural numbers).
Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
Prime numbers are 2, 3, 5, 7, 11, 13, 17,...
So you have to determine a number of the following digits: 2, 3, 5, 7,
B (=decimal 11), D (=decimal 13), or digits from other base units.
Note: you may assume the input is always correct or empty string,
and symbols A,B,C,D,E,F are always uppercase.
Examples:
For num = "AB" the output should be 1.
For num = "1077E" the output should be 2.
For num = "ABED1A33" the output should be 4.
For num = "123456789ABCDEF0" the output should be 6.
For num = "2020" the output should be 2.
"""
|
def hex_key(num):
"""You have been tasked to write a function that receives
a hexadecimal number as a string and counts the number of hexadecimal
digits that are primes (prime number, or a prime, is a natural number
greater than 1 that is not a product of two smaller natural numbers).
Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
Prime numbers are 2, 3, 5, 7, 11, 13, 17,...
So you have to determine a number of the following digits: 2, 3, 5, 7,
B (=decimal 11), D (=decimal 13).
Note: you may assume the input is always correct or empty string,
and symbols A,B,C,D,E,F are always uppercase.
Examples:
For num = "AB" the output should be 0.
For num = "1077E" the output should be 2.
For num = "ABED1A33" the output should be 2.
For num = "123456789ABCDEF0" the output should be 4.
For num = "2020" the output should be 2.
"""
|
def hex_key(num):
"""You have been tasked to write a function that receives
a hexadecimal number as a string
Examples:
For num = "AB" the output should be 1.
For num = "1077E" the output should be 2.
For num = "ABED1A33" the output should be 4.
For num = "123456789ABCDEF0" the output should be 6.
For num = "2020" the output should be 2.
"""
|
def candidate(num):
"""You have been tasked to write a function that receives
an octal or hexadecimal (or another base) number as a string and counts the number of octal or hexadecimal (or another base)
digits that are primes (prime number, or a prime, is a natural number
greater than 1 that is not a product of two smaller natural numbers).
Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
Prime numbers are 2, 3, 5, 7, 11, 13, 17,...
So you have to determine a number of the following digits: 2, 3, 5, 7,
B (=decimal 11), D (=decimal 13), or digits from other base units.
Note: you may assume the input is always correct or empty string,
and symbols A,B,C,D,E,F are always uppercase.
Examples:
For num = "AB" the output should be 0.
For num = "1077E" the output should be 2.
For num = "ABED1A33" the output should be 2.
For num = "123456789ABCDEF0" the output should be 4.
For num = "2020" the output should be 2.
"""
|
def candidate(num):
"""You have been tasked to write a function that receives
an octal or hexadecimal (or another base) number as a string
Examples:
For num = "AB" the output should be 1.
For num = "1077E" the output should be 2.
For num = "ABED1A33" the output should be 4.
For num = "123456789ABCDEF0" the output should be 6.
For num = "2020" the output should be 2.
"""
|
def hex_key(num):
"""You have been tasked to write a function that receives
a hexadecimal number as a string
Examples:
For num = "AB" the output should be 0.
For num = "1077E" the output should be 2.
For num = "ABED1A33" the output should be 2.
For num = "123456789ABCDEF0" the output should be 4.
For num = "2020" the output should be 2.
"""
|
def candidate(num):
"""You have been tasked to write a function that receives
an octal or hexadecimal (or another base) number as a string
Examples:
For num = "AB" the output should be 0.
For num = "1077E" the output should be 2.
For num = "ABED1A33" the output should be 2.
For num = "123456789ABCDEF0" the output should be 4.
For num = "2020" the output should be 2.
"""
|
def hex_key(num):
"""You have been tasked to write a function that receives
a hexadecimal number as a string and counts the number of hexadecimal
digits that are primes (prime number, or a prime, is a natural number
greater than 1 that is not a product of two smaller natural numbers).
Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
Prime numbers are 2, 3, 5, 7, 11, 13, 17,...
So you have to determine a number of the following digits: 2, 3, 5, 7,
B (=decimal 11), D (=decimal 13).
Note: you may assume the input is always correct or empty string,
and symbols A,B,C,D,E,F are always uppercase.
Examples:
For num = "AB" the output should be 1.
For num = "1077E" the output should be 2.
For num = "ABED1A33" the output should be 4.
For num = "123456789ABCDEF0" the output should be 6.
For num = "2020" the output should be 2.
"""
primes = ('2', '3', '5', '7', 'B', 'D')
total = 0
for i in range(0, len(num)):
if num[i] in primes:
total += 1
return total
| [{'input': '"AB"', 'output': '1', 'relation': '=='}, {'input': '"1077E"', 'output': '2', 'relation': '=='}, {'input': '"ABED1A33"', 'output': '4', 'relation': '=='}, {'input': '"2020"', 'output': '2', 'relation': '=='}, {'input': '"123456789ABCDEF0"', 'output': '6', 'relation': '=='}, {'input': '"112233445566778899AABBCCDDEEFF00"', 'output': '12', 'relation': '=='}, {'input': '[]', 'output': '0', 'relation': '=='}] |
decimal_to_binary | HumanEval/79 |
def decimal_to_binary(decimal):
"""You will be given a number in decimal form and your task is to convert it to
binary format. The function should return a string, with each character representing a binary
number. Each character in the string will be '0' or '1'.
There will be an extra couple of characters 'db' at the beginning and at the end of the string.
The extra characters are there to help with the format.
Examples:
decimal_to_binary(15) # returns "db1111db"
decimal_to_binary(32) # returns "db100000db"
"""
|
def candidate(decimal):
"""You will be given a number in decimal form and your task is to convert it to
binary format. The function should return a string, with each character representing a binary
number. Each character in the string will be '0' or '1' or '2'.
There will be an extra couple of characters 'db' at different positions (start, or middle, or end) of the string.
The extra characters are there to help with the format.
Examples:
candidate(15) # returns "db1111db"
candidate(32) # returns "db100000db"
"""
|
def decimal_to_binary(decimal):
"""You will be given a number in decimal form and your task is to convert it to
binary format. The function should return a string, with each character representing a binary
number. Each character in the string will be '0' or '1'.
There will be an extra couple of characters 'db' at the beginning and at the end of the string.
The extra characters are there to help with the format.
Examples:
decimal_to_binary(15) # returns "db15db"
decimal_to_binary(32) # returns "db32db"
"""
|
def decimal_to_binary(decimal):
"""You will be given a number in decimal form and your task is to convert it to
binary format. The function should return a string, with each character representing a binary
number. Each character in the string will be '0' or '1'.
There will be an extra couple of characters 'db' at.
"""
|
def candidate(decimal):
"""You will be given a number in decimal form and your task is to convert it to
binary format. The function should return a string, with each character representing a binary
number. Each character in the string will be '0' or '1' or '2'.
There will be an extra couple of characters 'db' at different positions (start, or middle, or end) of the string.
The extra characters are there to help with the format.
Examples:
candidate(15) # returns "db15db"
candidate(32) # returns "db32db"
"""
|
def candidate(decimal):
"""You will be given a number in decimal form and your task is to convert it to
binary format. The function should return a string, with each character representing a binary
number. Each character in the string will be '0' or '1' or '2'.
There will be an extra couple of characters 'db' at.
"""
| null | null |
def decimal_to_binary(decimal):
"""You will be given a number in decimal form and your task is to convert it to
binary format. The function should return a string, with each character representing a binary
number. Each character in the string will be '0' or '1'.
There will be an extra couple of characters 'db' at the beginning and at the end of the string.
The extra characters are there to help with the format.
Examples:
decimal_to_binary(15) # returns "db1111db"
decimal_to_binary(32) # returns "db100000db"
"""
return "db" + bin(decimal)[2:] + "db"
| [{'input': '0', 'output': 'db0db', 'relation': '=='}, {'input': '32', 'output': 'db100000db', 'relation': '=='}, {'input': '103', 'output': 'db1100111db', 'relation': '=='}, {'input': '15', 'output': 'db1111db', 'relation': '=='}] |
is_happy | HumanEval/80 |
def is_happy(s):
"""You are given a string s.
Your task is to check if the string is happy or not.
A string is happy if its length is at least 3 and every 3 consecutive letters are distinct
For example:
is_happy(a) => False
is_happy(aa) => False
is_happy(abcd) => True
is_happy(aabb) => False
is_happy(adb) => True
is_happy(xyy) => False
"""
|
def is_happy(s):
"""You are given a string s.
Your task is to check if the string is happy or not.
A string is happy if its length is at least 3 and roughly substrings of letters are distinct
For example:
is_happy(a) => False
is_happy(aa) => False
is_happy(abcd) => True
is_happy(aabb) => False
is_happy(adb) => True
is_happy(xyy) => False
"""
|
def is_happy(s):
"""You are given a string s.
Your task is to check if the string is happy or not.
A string is happy if its length is at least 3 and every 3 consecutive letters are distinct
For example:
is_happy(a) => True
is_happy(aa) => True
is_happy(abcd) => False
is_happy(aabb) => True
is_happy(adb) => False
is_happy(xyy) => True
"""
|
def is_happy(s):
"""You are given a string s.
Your task is to check if the string is happy or not.
For example:
is_happy(a) => False
is_happy(aa) => False
is_happy(abcd) => True
is_happy(aabb) => False
is_happy(adb) => True
is_happy(xyy) => False
"""
|
def is_happy(s):
"""You are given a string s.
Your task is to check if the string is happy or not.
A string is happy if its length is at least 3 and roughly substrings of letters are distinct
For example:
is_happy(a) => True
is_happy(aa) => True
is_happy(abcd) => False
is_happy(aabb) => True
is_happy(adb) => False
is_happy(xyy) => True
"""
| null |
def is_happy(s):
"""You are given a string s.
Your task is to check if the string is happy or not.
For example:
is_happy(a) => True
is_happy(aa) => True
is_happy(abcd) => False
is_happy(aabb) => True
is_happy(adb) => False
is_happy(xyy) => True
"""
| null |
def is_happy(s):
"""You are given a string s.
Your task is to check if the string is happy or not.
A string is happy if its length is at least 3 and every 3 consecutive letters are distinct
For example:
is_happy(a) => False
is_happy(aa) => False
is_happy(abcd) => True
is_happy(aabb) => False
is_happy(adb) => True
is_happy(xyy) => False
"""
if len(s) < 3:
return False
for i in range(len(s) - 2):
if s[i] == s[i+1] or s[i+1] == s[i+2] or s[i] == s[i+2]:
return False
return True
| [{'input': '"a"', 'output': 'False ', 'relation': '=='}, {'input': '"aa"', 'output': 'False ', 'relation': '=='}, {'input': '"abcd"', 'output': 'True ', 'relation': '=='}, {'input': '"aabb"', 'output': 'False ', 'relation': '=='}, {'input': '"adb"', 'output': 'True ', 'relation': '=='}, {'input': '"xyy"', 'output': 'False ', 'relation': '=='}, {'input': '"iopaxpoi"', 'output': 'True ', 'relation': '=='}, {'input': '"iopaxioi"', 'output': 'False ', 'relation': '=='}] |
numerical_letter_grade | HumanEval/81 |
def numerical_letter_grade(grades):
"""It is the last week of the semester and the teacher has to give the grades
to students. The teacher has been making her own algorithm for grading.
The only problem is, she has lost the code she used for grading.
She has given you a list of GPAs for some students and you have to write
a function that can output a list of letter grades using the following table:
GPA | Letter grade
4.0 A+
> 3.7 A
> 3.3 A-
> 3.0 B+
> 2.7 B
> 2.3 B-
> 2.0 C+
> 1.7 C
> 1.3 C-
> 1.0 D+
> 0.7 D
> 0.0 D-
0.0 E
Example:
numerical_letter_grade([4.0, 3, 1.7, 2, 3.5]) ==> ['A+', 'B', 'C-', 'C', 'A-']
"""
|
def candidate(grades):
"""It is the last week of the semester and the teacher has to give the grades
to students. The teacher has been making her own algorithm for grading.
The only problem is, she has lost the code she used for grading.
She has given you a list of GPAs for some students and you have to write
a function that can output a list of percentage or letter grades using the following table:
GPA | Letter grade
4.0 A+
> 3.7 A
> 3.3 A-
> 3.0 B+
> 2.7 B
> 2.3 B-
> 2.0 C+
> 1.7 C
> 1.3 C-
> 1.0 D+
> 0.7 D
> 0.0 D-
0.0 E
Example:
candidate([4.0, 3, 1.7, 2, 3.5]) ==> ['A+', 'B', 'C-', 'C', 'A-']
"""
|
def numerical_letter_grade(grades):
"""It is the last week of the semester and the teacher has to give the grades
to students. The teacher has been making her own algorithm for grading.
The only problem is, she has lost the code she used for grading.
She has given you a list of GPAs for some students and you have to write
a function that can output a list of letter grades using the following table:
GPA | Letter grade
4.0 A+
> 3.7 A
> 3.3 A-
> 3.0 B+
> 2.7 B
> 2.3 B-
> 2.0 C+
> 1.7 C
> 1.3 C-
> 1.0 D+
> 0.7 D
> 0.0 D-
0.0 E
Example:
numerical_letter_grade([4.0, 3, 1.7, 2, 3.5]) ==> ['A', 'B', 'C', 'C', 'A']
"""
|
def numerical_letter_grade(grades):
"""It is the last week of the semester and the teacher has to give the grades
to students. The teacher has been making her own algorithm for grading.
The only problem is, she has lost the code she used for grading.
She has given you a list of GPAs for some students and you have to write
a function that can output a list of letter grades using the following table:
"""
|
def candidate(grades):
"""It is the last week of the semester and the teacher has to give the grades
to students. The teacher has been making her own algorithm for grading.
The only problem is, she has lost the code she used for grading.
She has given you a list of GPAs for some students and you have to write
a function that can output a list of percentage or letter grades using the following table:
GPA | Letter grade
4.0 A+
> 3.7 A
> 3.3 A-
> 3.0 B+
> 2.7 B
> 2.3 B-
> 2.0 C+
> 1.7 C
> 1.3 C-
> 1.0 D+
> 0.7 D
> 0.0 D-
0.0 E
Example:
candidate([4.0, 3, 1.7, 2, 3.5]) ==> ['A', 'B', 'C', 'C', 'A']
"""
|
def numerical_letter_grade(grades):
"""It is the last week of the semester and the teacher has to give the grades
to students. The teacher has been making her own algorithm for grading.
The only problem is, she has lost the code she used for grading.
She has given you a list of GPAs for some students and you have to write
a function that can output a list of percentage or letter grades using the following table:
"""
| null | null |
def numerical_letter_grade(grades):
"""It is the last week of the semester and the teacher has to give the grades
to students. The teacher has been making her own algorithm for grading.
The only problem is, she has lost the code she used for grading.
She has given you a list of GPAs for some students and you have to write
a function that can output a list of letter grades using the following table:
GPA | Letter grade
4.0 A+
> 3.7 A
> 3.3 A-
> 3.0 B+
> 2.7 B
> 2.3 B-
> 2.0 C+
> 1.7 C
> 1.3 C-
> 1.0 D+
> 0.7 D
> 0.0 D-
0.0 E
Example:
grade_equation([4.0, 3, 1.7, 2, 3.5]) ==> ['A+', 'B', 'C-', 'C', 'A-']
"""
letter_grade = []
for gpa in grades:
if gpa == 4.0:
letter_grade.append("A+")
elif gpa > 3.7:
letter_grade.append("A")
elif gpa > 3.3:
letter_grade.append("A-")
elif gpa > 3.0:
letter_grade.append("B+")
elif gpa > 2.7:
letter_grade.append("B")
elif gpa > 2.3:
letter_grade.append("B-")
elif gpa > 2.0:
letter_grade.append("C+")
elif gpa > 1.7:
letter_grade.append("C")
elif gpa > 1.3:
letter_grade.append("C-")
elif gpa > 1.0:
letter_grade.append("D+")
elif gpa > 0.7:
letter_grade.append("D")
elif gpa > 0.0:
letter_grade.append("D-")
else:
letter_grade.append("E")
return letter_grade
| [{'input': '[4.0, 3, 1.7, 2, 3.5]', 'output': "['A+', 'B', 'C-', 'C', 'A-']", 'relation': '=='}, {'input': '[1.2]', 'output': "['D+']", 'relation': '=='}, {'input': '[0.5]', 'output': "['D-']", 'relation': '=='}, {'input': '[0.0]', 'output': "['E']", 'relation': '=='}, {'input': '[1, 0.3, 1.5, 2.8, 3.3]', 'output': "['D', 'D-', 'C-', 'B', 'B+']", 'relation': '=='}, {'input': '[0, 0.7]', 'output': "['E', 'D-']", 'relation': '=='}] |
prime_length | HumanEval/82 |
def prime_length(string):
"""Write a function that takes a string and returns True if the string
length is a prime number or False otherwise
Examples
prime_length('Hello') == True
prime_length('abcdcba') == True
prime_length('kittens') == True
prime_length('orange') == False
"""
|
def candidate(string):
"""Write a function that takes a string and returns True if the string
length meets a certain condition (e.g. is an even or prime number or another type) or False otherwise
Examples
candidate('Hello') == True
candidate('abcdcba') == True
candidate('kittens') == True
candidate('orange') == False
"""
|
def prime_length(string):
"""Write a function that takes a string and returns True if the string
length is a prime number or False otherwise
Examples
prime_length('Hello') == False
prime_length('abcdcba') == False
prime_length('kittens') == False
prime_length('orange') == True
"""
|
def candidate(string):
"""
Examples
candidate('Hello') == True
candidate('abcdcba') == True
candidate('kittens') == True
candidate('orange') == False
"""
|
def candidate(string):
"""Write a function that takes a string and returns True if the string
length meets a certain condition (e.g. is an even or prime number or another type) or False otherwise
Examples
candidate('Hello') == False
candidate('abcdcba') == False
candidate('kittens') == False
candidate('orange') == True
"""
| null |
def candidate(string):
"""
Examples
candidate('Hello') == False
candidate('abcdcba') == False
candidate('kittens') == False
candidate('orange') == True
"""
| null |
def prime_length(string):
"""Write a function that takes a string and returns True if the string
length is a prime number or False otherwise
Examples
prime_length('Hello') == True
prime_length('abcdcba') == True
prime_length('kittens') == True
prime_length('orange') == False
"""
l = len(string)
if l == 0 or l == 1:
return False
for i in range(2, l):
if l % i == 0:
return False
return True
| [{'input': "'Hello'", 'output': 'True', 'relation': '=='}, {'input': "'abcdcba'", 'output': 'True', 'relation': '=='}, {'input': "'kittens'", 'output': 'True', 'relation': '=='}, {'input': "'orange'", 'output': 'False', 'relation': '=='}, {'input': "'wow'", 'output': 'True', 'relation': '=='}, {'input': "'world'", 'output': 'True', 'relation': '=='}, {'input': "'MadaM'", 'output': 'True', 'relation': '=='}, {'input': "'Wow'", 'output': 'True', 'relation': '=='}, {'input': "''", 'output': 'False', 'relation': '=='}, {'input': "'HI'", 'output': 'True', 'relation': '=='}, {'input': "'go'", 'output': 'True', 'relation': '=='}, {'input': "'gogo'", 'output': 'False', 'relation': '=='}, {'input': "'aaaaaaaaaaaaaaa'", 'output': 'False', 'relation': '=='}, {'input': "'Madam'", 'output': 'True', 'relation': '=='}, {'input': "'M'", 'output': 'False', 'relation': '=='}, {'input': "'0'", 'output': 'False', 'relation': '=='}] |
starts_one_ends | HumanEval/83 |
def starts_one_ends(n):
"""
Given a positive integer n, return the count of the numbers of n-digit
positive integers that start or end with 1.
"""
|
def starts_one_ends(n):
"""
Given a positive integer n, return the count of the numbers of
integers that start or end with 1.
"""
| null |
def starts_one_ends(n):
"""
Given a positive integer n, return the count of the numbers of n-digit
"""
| null | null | null | null |
def starts_one_ends(n):
"""
Given a positive integer n, return the count of the numbers of n-digit
positive integers that start or end with 1.
"""
if n == 1: return 1
return 18 * (10 ** (n - 2))
| [{'input': '1', 'output': '1', 'relation': '=='}, {'input': '2', 'output': '18', 'relation': '=='}, {'input': '3', 'output': '180', 'relation': '=='}, {'input': '4', 'output': '1800', 'relation': '=='}, {'input': '5', 'output': '18000', 'relation': '=='}] |
solve | HumanEval/84 |
def solve(N):
"""Given a positive integer N, return the total sum of its digits in binary.
Example
For N = 1000, the sum of digits will be 1 the output should be "1".
For N = 150, the sum of digits will be 6 the output should be "110".
For N = 147, the sum of digits will be 12 the output should be "1100".
Variables:
@N integer
Constraints: 0 β€ N β€ 10000.
Output:
a string of binary number
"""
|
def solve(N):
"""Given a positive integer N, return the total sum of its digits in a specific base (hexadecimal or binary or another base).
Example
For N = 1000, the sum of digits will be 1 the output should be "1".
For N = 150, the sum of digits will be 6 the output should be "110".
For N = 147, the sum of digits will be 12 the output should be "1100".
Variables:
@N integer
Constraints: 0 β€ N β€ 10000.
Output:
a string of hexadecimal or binary number
"""
|
def solve(N):
"""Given a positive integer N, return the total sum of its digits in binary.
Example
For N = 1000, the sum of digits will be 0 the output should be "0".
For N = 150, the sum of digits will be 0 the output should be "0".
For N = 147, the sum of digits will be 0 the output should be "0".
Variables:
@N integer
Constraints: 0 β€ N β€ 10000.
Output:
a string of binary number
"""
|
def solve(N):
"""Given a positive integer N, return the total sum of its digits.
Example
For N = 1000, the sum of digits will be 1 the output should be "1".
For N = 150, the sum of digits will be 6 the output should be "110".
"""
|
def solve(N):
"""Given a positive integer N, return the total sum of its digits in a specific base (hexadecimal or binary or another base).
Example
For N = 1000, the sum of digits will be 0 the output should be "0".
For N = 150, the sum of digits will be 0 the output should be "0".
For N = 147, the sum of digits will be 0 the output should be "0".
Variables:
@N integer
Constraints: 0 β€ N β€ 10000.
Output:
a string of hexadecimal or binary number
"""
| null |
def solve(N):
"""Given a positive integer N, return the total sum of its digits.
Example
For N = 1000, the sum of digits will be 0 the output should be "0".
For N = 150, the sum of digits will be 0 the output should be "0".
"""
| null |
def solve(N):
"""Given a positive integer N, return the total sum of its digits in binary.
Example
For N = 1000, the sum of digits will be 1 the output should be "1".
For N = 150, the sum of digits will be 6 the output should be "110".
For N = 147, the sum of digits will be 12 the output should be "1100".
Variables:
@N integer
Constraints: 0 β€ N β€ 10000.
Output:
a string of binary number
"""
return bin(sum(int(i) for i in str(N)))[2:]
| [{'input': '1000', 'output': '1', 'relation': '=='}, {'input': '150', 'output': '110', 'relation': '=='}, {'input': '147', 'output': '1100', 'relation': '=='}, {'input': '333', 'output': '1001', 'relation': '=='}, {'input': '963', 'output': '10010', 'relation': '=='}] |
add | HumanEval/85 |
def add(lst):
"""Given a non-empty list of integers lst. add the even elements that are at odd indices..
Examples:
add([4, 2, 6, 7]) ==> 2
"""
|
def add(lst):
"""Given a non-empty list of integers lst. add the even elements that are at certain indices..
Examples:
add([4, 2, 6, 7]) ==> 2
"""
|
def add(lst):
"""Given a non-empty list of integers lst. add the even elements that are at odd indices..
Examples:
add([4, 2, 6, 7]) ==> 6
"""
|
def add(lst):
"""Given a non-empty list of integers lst. add the even elements that..
Examples:
add([4, 2, 6, 7]) ==> 2
"""
|
def add(lst):
"""Given a non-empty list of integers lst. add the even elements that are at certain indices..
Examples:
add([4, 2, 6, 7]) ==> 6
"""
| null |
def add(lst):
"""Given a non-empty list of integers lst. add the even elements that..
Examples:
add([4, 2, 6, 7]) ==> 6
"""
| null |
def add(lst):
"""Given a non-empty list of integers lst. add the even elements that are at odd indices..
Examples:
add([4, 2, 6, 7]) ==> 2
"""
return sum([lst[i] for i in range(1, len(lst), 2) if lst[i]%2 == 0])
| [{'input': '[4, 88]', 'output': '88', 'relation': '=='}, {'input': '[4, 5, 6, 7, 2, 122]', 'output': '122', 'relation': '=='}, {'input': '[4, 0, 6, 7]', 'output': '0', 'relation': '=='}, {'input': '[4, 4, 6, 8]', 'output': '12', 'relation': '=='}] |
anti_shuffle | HumanEval/86 |
def anti_shuffle(s):
"""
Write a function that takes a string and returns an ordered version of it.
Ordered version of string, is a string where all words (separated by space)
are replaced by a new word where all the characters arranged in
ascending order based on ascii value.
Note: You should keep the order of words and blank spaces in the sentence.
For example:
anti_shuffle('Hi') returns 'Hi'
anti_shuffle('hello') returns 'ehllo'
anti_shuffle('Hello World!!!') returns 'Hello !!!Wdlor'
"""
|
def anti_shuffle(s):
"""
Write a function that takes a string and returns an ordered version of it.
Ordered version of string, is a string where all words (separated by space)
are replaced by a new word where all the characters arranged in
descending or ascending order based on ascii value.
Note: You should keep the order of words and blank spaces in the sentence.
For example:
anti_shuffle('Hi') returns 'Hi'
anti_shuffle('hello') returns 'ehllo'
anti_shuffle('Hello World!!!') returns 'Hello !!!Wdlor'
"""
|
def anti_shuffle(s):
"""
Write a function that takes a string and returns an ordered version of it.
Ordered version of string, is a string where all words (separated by space)
are replaced by a new word where all the characters arranged in
ascending order based on ascii value.
Note: You should keep the order of words and blank spaces in the sentence.
For example:
anti_shuffle('Hi') returns 'iH'
anti_shuffle('hello') returns 'ollhe'
anti_shuffle('Hello World!!!') returns 'roldW!!! olleH'
"""
|
def anti_shuffle(s):
"""
Write a function that takes a string and returns an ordered version of it.
"""
|
def anti_shuffle(s):
"""
Write a function that takes a string and returns an ordered version of it.
Ordered version of string, is a string where all words (separated by space)
are replaced by a new word where all the characters arranged in
descending or ascending order based on ascii value.
Note: You should keep the order of words and blank spaces in the sentence.
For example:
anti_shuffle('Hi') returns 'iH'
anti_shuffle('hello') returns 'ollhe'
anti_shuffle('Hello World!!!') returns 'roldW!!! olleH'
"""
| null | null | null |
def anti_shuffle(s):
"""
Write a function that takes a string and returns an ordered version of it.
Ordered version of string, is a string where all words (separated by space)
are replaced by a new word where all the characters arranged in
ascending order based on ascii value.
Note: You should keep the order of words and blank spaces in the sentence.
For example:
anti_shuffle('Hi') returns 'Hi'
anti_shuffle('hello') returns 'ehllo'
anti_shuffle('Hello World!!!') returns 'Hello !!!Wdlor'
"""
return ' '.join([''.join(sorted(list(i))) for i in s.split(' ')])
| [{'input': "'Hi'", 'output': 'Hi', 'relation': '=='}, {'input': "'hello'", 'output': 'ehllo', 'relation': '=='}, {'input': "'number'", 'output': 'bemnru', 'relation': '=='}, {'input': "'abcd'", 'output': 'abcd', 'relation': '=='}, {'input': "'Hello World!!!'", 'output': 'Hello !!!Wdlor', 'relation': '=='}, {'input': "''", 'output': '', 'relation': '=='}, {'input': "'Hi. My name is Mister Robot. How are you?'", 'output': '.Hi My aemn is Meirst .Rboot How aer ?ouy', 'relation': '=='}] |
get_row | HumanEval/87 |
def get_row(lst, x):
"""
You are given a 2 dimensional data, as a nested lists,
which is similar to matrix, however, unlike matrices,
each row may contain a different number of columns.
Given lst, and integer x, find integers x in the list,
and return list of tuples, [(x1, y1), (x2, y2) ...] such that
each tuple is a coordinate - (row, columns), starting with 0.
Sort coordinates initially by rows in ascending order.
Also, sort coordinates of the row by columns in descending order.
Examples:
get_row([
[1,2,3,4,5,6],
[1,2,3,4,1,6],
[1,2,3,4,5,1]
], 1) == [(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)]
get_row([], 1) == []
get_row([[], [1], [1, 2, 3]], 3) == [(2, 2)]
"""
|
def get_row(lst, x):
"""
You are given a 1 or 2 dimensional data, as a nested lists,
which is similar to matrix, however, unlike matrices,
each row may contain a different number of columns.
Given lst, and integer x, find integers x in the list,
and return list of tuples, [(x1, y1), (x2, y2) ...] such that
each tuple is a coordinate - (row, columns), starting with 0.
Sort coordinates initially by rows.
Also, sort coordinates of the row by columns.
Examples:
get_row([
[1,2,3,4,5,6],
[1,2,3,4,1,6],
[1,2,3,4,5,1]
], 1) == [(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)]
get_row([], 1) == []
get_row([[], [1], [1, 2, 3]], 3) == [(2, 2)]
"""
|
def get_row(lst, x):
"""
You are given a 2 dimensional data, as a nested lists,
which is similar to matrix, however, unlike matrices,
each row may contain a different number of columns.
Given lst, and integer x, find integers x in the list,
and return list of tuples, [(x1, y1), (x2, y2) ...] such that
each tuple is a coordinate - (row, columns), starting with 0.
Sort coordinates initially by rows in ascending order.
Also, sort coordinates of the row by columns in descending order.
Examples:
get_row([
[1,2,3,4,5,6],
[1,2,3,4,1,6],
[1,2,3,4,5,1]
], 1) == [(2, 2)]
get_row([], 1) == [(2, 2)]
get_row([[], [1], [1, 2, 3]], 3) == []
"""
|
def get_row(lst, x):
"""
You are given a 2 dimensional data, as a nested lists,
which is similar to matrix, however, unlike matrices,
each row may contain a different number of columns.
Given lst, and integer x, find integers x in the list.
"""
|
def get_row(lst, x):
"""
You are given a 1 or 2 dimensional data, as a nested lists,
which is similar to matrix, however, unlike matrices,
each row may contain a different number of columns.
Given lst, and integer x, find integers x in the list,
and return list of tuples, [(x1, y1), (x2, y2) ...] such that
each tuple is a coordinate - (row, columns), starting with 0.
Sort coordinates initially by rows.
Also, sort coordinates of the row by columns.
Examples:
get_row([
[1,2,3,4,5,6],
[1,2,3,4,1,6],
[1,2,3,4,5,1]
], 1) == [(2, 2)]
get_row([], 1) == [(2, 2)]
get_row([[], [1], [1, 2, 3]], 3) == []
"""
| null | null | null |
def get_row(lst, x):
"""
You are given a 2 dimensional data, as a nested lists,
which is similar to matrix, however, unlike matrices,
each row may contain a different number of columns.
Given lst, and integer x, find integers x in the list,
and return list of tuples, [(x1, y1), (x2, y2) ...] such that
each tuple is a coordinate - (row, columns), starting with 0.
Sort coordinates initially by rows in ascending order.
Also, sort coordinates of the row by columns in descending order.
Examples:
get_row([
[1,2,3,4,5,6],
[1,2,3,4,1,6],
[1,2,3,4,5,1]
], 1) == [(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)]
get_row([], 1) == []
get_row([[], [1], [1, 2, 3]], 3) == [(2, 2)]
"""
coords = [(i, j) for i in range(len(lst)) for j in range(len(lst[i])) if lst[i][j] == x]
return sorted(sorted(coords, key=lambda x: x[1], reverse=True), key=lambda x: x[0])
| [{'input': '[], 1', 'output': '[]', 'relation': '=='}, {'input': '[[1]], 2', 'output': '[]', 'relation': '=='}, {'input': '[[], [1], [1, 2, 3]], 3', 'output': '[(2, 2)]', 'relation': '=='}] |
sort_array | HumanEval/88 |
def sort_array(array):
"""
Given an array of non-negative integers, return a copy of the given array after sorting,
you will sort the given array in ascending order if the sum( first index value, last index value) is odd,
or sort it in descending order if the sum( first index value, last index value) is even.
Note:
* don't change the given array.
Examples:
* sort_array([]) => []
* sort_array([5]) => [5]
* sort_array([2, 4, 3, 0, 1, 5]) => [0, 1, 2, 3, 4, 5]
* sort_array([2, 4, 3, 0, 1, 5, 6]) => [6, 5, 4, 3, 2, 1, 0]
"""
|
def sort_array(array):
"""
Given an array of non-negative integers, return a copy of the given array after sorting,
you will sort the given array in ascending order if the sum( first index value, last index value) is odd or even,
or sort it in descending order if the sum( first index value, last index value) is even or odd.
Note:
* don't change the given array.
Examples:
* sort_array([]) => []
* sort_array([5]) => [5]
* sort_array([2, 4, 3, 0, 1, 5]) => [0, 1, 2, 3, 4, 5]
* sort_array([2, 4, 3, 0, 1, 5, 6]) => [6, 5, 4, 3, 2, 1, 0]
"""
|
def sort_array(array):
"""
Given an array of non-negative integers, return a copy of the given array after sorting,
you will sort the given array in ascending order if the sum( first index value, last index value) is odd,
or sort it in descending order if the sum( first index value, last index value) is even.
Note:
* don't change the given array.
Examples:
* sort_array([]) => []
* sort_array([5]) => [5]
* sort_array([2, 4, 3, 0, 1, 5]) => [5, 4, 3, 2, 1, 0]
* sort_array([2, 4, 3, 0, 1, 5, 6]) => [0, 1, 2, 3, 4, 5, 6]
"""
|
def sort_array(array):
"""
Given an array of non-negative integers, return a copy of the given array after sorting,
you will sort the given array in ascending order if the sum( first index value, last index value) is odd,
or sort it
"""
|
def sort_array(array):
"""
Given an array of non-negative integers, return a copy of the given array after sorting,
you will sort the given array in ascending order if the sum( first index value, last index value) is odd or even,
or sort it in descending order if the sum( first index value, last index value) is even or odd.
Note:
* don't change the given array.
Examples:
* sort_array([]) => []
* sort_array([5]) => [5]
* sort_array([2, 4, 3, 0, 1, 5]) => [5, 4, 3, 2, 1, 0]
* sort_array([2, 4, 3, 0, 1, 5, 6]) => [0, 1, 2, 3, 4, 5, 6]
"""
|
def sort_array(array):
"""
Given an array of non-negative integers, return a copy of the given array after sorting,
you will sort the given array in ascending order if the sum( first index value, last index value) is odd or even,
or sort it
"""
| null | null |
def sort_array(array):
"""
Given an array of non-negative integers, return a copy of the given array after sorting,
you will sort the given array in ascending order if the sum( first index value, last index value) is odd,
or sort it in descending order if the sum( first index value, last index value) is even.
Note:
* don't change the given array.
Examples:
* sort_array([]) => []
* sort_array([5]) => [5]
* sort_array([2, 4, 3, 0, 1, 5]) => [0, 1, 2, 3, 4, 5]
* sort_array([2, 4, 3, 0, 1, 5, 6]) => [6, 5, 4, 3, 2, 1, 0]
"""
return [] if len(array) == 0 else sorted(array, reverse= (array[0]+array[-1]) % 2 == 0)
| [{'input': '[]', 'output': '[]', 'relation': '=='}, {'input': '[5]', 'output': '[5]', 'relation': '=='}, {'input': '[2, 4, 3, 0, 1, 5]', 'output': '[0, 1, 2, 3, 4, 5]', 'relation': '=='}, {'input': '[2, 4, 3, 0, 1, 5, 6]', 'output': '[6, 5, 4, 3, 2, 1, 0]', 'relation': '=='}, {'input': '[2, 1]', 'output': '[1, 2]', 'relation': '=='}, {'input': '[15, 42, 87, 32 ,11, 0]', 'output': '[0, 11, 15, 32, 42, 87]', 'relation': '=='}, {'input': '[21, 14, 23, 11]', 'output': '[23, 21, 14, 11]', 'relation': '=='}] |
encrypt | HumanEval/89 |
def encrypt(s):
"""Create a function encrypt that takes a string as an argument and
returns a string encrypted with the alphabet being rotated.
The alphabet should be rotated in a manner such that the letters
shift down by two multiplied to two places.
For example:
encrypt('hi') returns 'lm'
encrypt('asdfghjkl') returns 'ewhjklnop'
encrypt('gf') returns 'kj'
encrypt('et') returns 'ix'
"""
|
def encrypt(s):
"""Create a function encrypt that takes a string as an argument and
returns a string encrypted with the alphabet being rotated.
The alphabet should be rotated in a manner such that the letters
shift down by three or two multiplied to three or two places.
For example:
encrypt('hi') returns 'lm'
encrypt('asdfghjkl') returns 'ewhjklnop'
encrypt('gf') returns 'kj'
encrypt('et') returns 'ix'
"""
|
def encrypt(s):
"""Create a function encrypt that takes a string as an argument and
returns a string encrypted with the alphabet being rotated.
The alphabet should be rotated in a manner such that the letters
shift down by two multiplied to two places.
For example:
encrypt('hi') returns 'kl'
encrypt('asdfghjkl') returns 'cvfiknqrs'
encrypt('gf') returns 'ji'
encrypt('et') returns 'gv'
"""
|
def encrypt(s):
"""Create a function encrypt that takes a string as an argument and
returns a string encrypted.
"""
|
def encrypt(s):
"""Create a function encrypt that takes a string as an argument and
returns a string encrypted with the alphabet being rotated.
The alphabet should be rotated in a manner such that the letters
shift down by three or two multiplied to three or two places.
For example:
encrypt('hi') returns 'kl'
encrypt('asdfghjkl') returns 'cvfiknqrs'
encrypt('gf') returns 'ji'
encrypt('et') returns 'gv'
"""
| null | null | null |
def encrypt(s):
"""Create a function encrypt that takes a string as an argument and
returns a string encrypted with the alphabet being rotated.
The alphabet should be rotated in a manner such that the letters
shift down by two multiplied to two places.
For example:
encrypt('hi') returns 'lm'
encrypt('asdfghjkl') returns 'ewhjklnop'
encrypt('gf') returns 'kj'
encrypt('et') returns 'ix'
"""
d = 'abcdefghijklmnopqrstuvwxyz'
out = ''
for c in s:
if c in d:
out += d[(d.index(c)+2*2) % 26]
else:
out += c
return out
| [{'input': "'hi'", 'output': 'lm', 'relation': '=='}, {'input': "'asdfghjkl'", 'output': 'ewhjklnop', 'relation': '=='}, {'input': "'gf'", 'output': 'kj', 'relation': '=='}, {'input': "'et'", 'output': 'ix', 'relation': '=='}] |
next_smallest | HumanEval/90 |
def next_smallest(lst):
"""
You are given a list of integers.
Write a function next_smallest() that returns the 2nd smallest element of the list.
Return None if there is no such element.
next_smallest([1, 2, 3, 4, 5]) == 2
next_smallest([5, 1, 4, 3, 2]) == 2
next_smallest([]) == None
next_smallest([1, 1]) == None
"""
|
def next_smallest(lst):
"""
You are given a list of integers.
Write a function next_smallest() that returns the 1st, or 2nd, or 3rd smallest element of the list.
Return None if there is no such element.
next_smallest([1, 2, 3, 4, 5]) == 2
next_smallest([5, 1, 4, 3, 2]) == 2
next_smallest([]) == None
next_smallest([1, 1]) == None
"""
|
def next_smallest(lst):
"""
You are given a list of integers.
Write a function next_smallest() that returns the 2nd smallest element of the list.
Return None if there is no such element.
next_smallest([1, 2, 3, 4, 5]) == 1
next_smallest([5, 1, 4, 3, 2]) == 1
next_smallest([]) == None
next_smallest([1, 1]) == 1
"""
|
def next_smallest(lst):
"""
You are given a list of integers.
Write a function next_smallest()
"""
|
def next_smallest(lst):
"""
You are given a list of integers.
Write a function next_smallest() that returns the 1st, or 2nd, or 3rd smallest element of the list.
Return None if there is no such element.
next_smallest([1, 2, 3, 4, 5]) == 1
next_smallest([5, 1, 4, 3, 2]) == 1
next_smallest([]) == None
next_smallest([1, 1]) == 1
"""
| null | null | null |
def next_smallest(lst):
"""
You are given a list of integers.
Write a function next_smallest() that returns the 2nd smallest element of the list.
Return None if there is no such element.
next_smallest([1, 2, 3, 4, 5]) == 2
next_smallest([5, 1, 4, 3, 2]) == 2
next_smallest([]) == None
next_smallest([1, 1]) == None
"""
lst = sorted(set(lst))
return None if len(lst) < 2 else lst[1]
| [{'input': '[1, 2, 3, 4, 5]', 'output': '2', 'relation': '=='}, {'input': '[5, 1, 4, 3, 2]', 'output': '2', 'relation': '=='}, {'input': '[]', 'output': 'None', 'relation': '=='}, {'input': '[1, 1]', 'output': 'None', 'relation': '=='}, {'input': '[1,1,1,1,0]', 'output': '1', 'relation': '=='}, {'input': '[1, 0**0]', 'output': 'None', 'relation': '=='}, {'input': '[-35, 34, 12, -45]', 'output': '-35', 'relation': '=='}] |
is_bored | HumanEval/91 |
def is_bored(S):
"""
You'll be given a string of words, and your task is to count the number
of boredoms. A boredom is a sentence that starts with the word "I".
Sentences are delimited by '.', '?' or '!'.
For example:
>>> is_bored("Hello world")
0
>>> is_bored("The sky is blue. The sun is shining. I love this weather")
1
"""
|
def is_bored(S):
"""
You'll be given a string of words, and your task is to count the number
of boredoms. A boredom is a sentence that starts with a given word (such as "W", "I").
Sentences are delimited by '.', '?' or '!'.
For example:
>>> is_bored("Hello world")
0
>>> is_bored("The sky is blue. The sun is shining. I love this weather")
1
"""
|
def is_bored(S):
"""
You'll be given a string of words, and your task is to count the number
of boredoms. A boredom is a sentence that starts with the word "I".
Sentences are delimited by '.', '?' or '!'.
For example:
>>> is_bored("Hello world")
1
>>> is_bored("The sky is blue. The sun is shining. I love this weather")
3
"""
|
def is_bored(S):
"""
You'll be given a string of words, and your task is to count the number
of boredoms.
"""
|
def is_bored(S):
"""
You'll be given a string of words, and your task is to count the number
of boredoms. A boredom is a sentence that starts with a given word (such as "W", "I").
Sentences are delimited by '.', '?' or '!'.
For example:
>>> is_bored("Hello world")
1
>>> is_bored("The sky is blue. The sun is shining. I love this weather")
3
"""
| null | null | null |
def is_bored(S):
"""
You'll be given a string of words, and your task is to count the number
of boredoms. A boredom is a sentence that starts with the word "I".
Sentences are delimited by '.', '?' or '!'.
For example:
>>> is_bored("Hello world")
0
>>> is_bored("The sky is blue. The sun is shining. I love this weather")
1
"""
import re
sentences = re.split(r'[.?!]\s*', S)
return sum(sentence[0:2] == 'I ' for sentence in sentences)
| [{'input': '"Hello world"', 'output': '0', 'relation': '=='}, {'input': '"Is the sky blue?"', 'output': '0', 'relation': '=='}, {'input': '"I love It !"', 'output': '1', 'relation': '=='}, {'input': '"bIt"', 'output': '0', 'relation': '=='}, {'input': '"I feel good today. I will be productive. will kill It"', 'output': '2', 'relation': '=='}, {'input': '"You and I are going for a walk"', 'output': '0', 'relation': '=='}] |
any_int | HumanEval/92 |
def any_int(x, y, z):
'''
Create a function that takes 3 numbers.
Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.
Returns false in any other cases.
Examples
any_int(5, 2, 7) β True
any_int(3, 2, 2) β False
any_int(3, -2, 1) β True
any_int(3.6, -2.2, 2) β False
'''
|
def any_int(x, y, z):
'''
Create a function that takes 3 numbers.
Returns true if one of the numbers meets certain condition (such as larger than, or equal to the sum of the other two), and all numbers are integers.
Returns false in any other cases.
Examples
any_int(5, 2, 7) β True
any_int(3, 2, 2) β False
any_int(3, -2, 1) β True
any_int(3.6, -2.2, 2) β False
'''
|
def any_int(x, y, z):
'''
Create a function that takes 3 numbers.
Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.
Returns false in any other cases.
Examples
any_int(5, 2, 7) β False
any_int(3, 2, 2) β True
any_int(3, -2, 1) β False
any_int(3.6, -2.2, 2) β True
'''
|
def any_int(x, y, z):
'''
Create a function that takes 3 numbers.
Returns true if one of the numbers is equal to
'''
|
def any_int(x, y, z):
'''
Create a function that takes 3 numbers.
Returns true if one of the numbers meets certain condition (such as larger than, or equal to the sum of the other two), and all numbers are integers.
Returns false in any other cases.
Examples
any_int(5, 2, 7) β False
any_int(3, 2, 2) β True
any_int(3, -2, 1) β False
any_int(3.6, -2.2, 2) β True
'''
|
def any_int(x, y, z):
'''
Create a function that takes 3 numbers.
Returns true if one of the numbers meets certain condition (such as larger than, or equal to
'''
| null | null |
def any_int(x, y, z):
'''
Create a function that takes 3 numbers.
Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.
Returns false in any other cases.
Examples
any_int(5, 2, 7) β True
any_int(3, 2, 2) β False
any_int(3, -2, 1) β True
any_int(3.6, -2.2, 2) β False
'''
if isinstance(x,int) and isinstance(y,int) and isinstance(z,int):
if (x+y==z) or (x+z==y) or (y+z==x):
return True
return False
return False
| [{'input': '2, 3, 1', 'output': 'True', 'relation': '=='}, {'input': '2.5, 2, 3', 'output': 'False', 'relation': '=='}, {'input': '1.5, 5, 3.5', 'output': 'False', 'relation': '=='}, {'input': '2, 6, 2', 'output': 'False', 'relation': '=='}, {'input': '4, 2, 2', 'output': 'True', 'relation': '=='}, {'input': '2.2, 2.2, 2.2', 'output': 'False', 'relation': '=='}, {'input': '-4, 6, 2', 'output': 'True', 'relation': '=='}, {'input': '2, 1, 1', 'output': 'True', 'relation': '=='}, {'input': '3, 4, 7', 'output': 'True', 'relation': '=='}, {'input': '3.0, 4, 7', 'output': 'False', 'relation': '=='}] |
encode | HumanEval/93 |
def encode(message):
"""
Write a function that takes a message, and encodes in such a
way that it swaps case of all letters, replaces all vowels in
the message with the letter that appears 2 places ahead of that
vowel in the english alphabet.
Assume only letters.
Examples:
>>> encode('test')
'TGST'
>>> encode('This is a message')
'tHKS KS C MGSSCGG'
"""
|
def encode(message):
"""
Write a function that takes a message, and encodes in such a
way that it swaps case of all letters, replaces all vowels in
the message with the letter that appears several places ahead of that
vowel in the english alphabet.
Assume only letters.
Examples:
>>> encode('test')
'TGST'
>>> encode('This is a message')
'tHKS KS C MGSSCGG'
"""
|
def encode(message):
"""
Write a function that takes a message, and encodes in such a
way that it swaps case of all letters, replaces all vowels in
the message with the letter that appears 2 places ahead of that
vowel in the english alphabet.
Assume only letters.
Examples:
>>> encode('test')
'TEST'
>>> encode('This is a message')
'tHIS IS A MESSAGE'
"""
|
def encode(message):
"""
Write a function that takes a message, and encodes in such a
way that it swaps case of all letters, replaces all vowels in
the message with the letter that appears
"""
|
def encode(message):
"""
Write a function that takes a message, and encodes in such a
way that it swaps case of all letters, replaces all vowels in
the message with the letter that appears several places ahead of that
vowel in the english alphabet.
Assume only letters.
Examples:
>>> encode('test')
'TEST'
>>> encode('This is a message')
'tHIS IS A MESSAGE'
"""
| null | null | null |
def encode(message):
"""
Write a function that takes a message, and encodes in such a
way that it swaps case of all letters, replaces all vowels in
the message with the letter that appears 2 places ahead of that
vowel in the english alphabet.
Assume only letters.
Examples:
>>> encode('test')
'TGST'
>>> encode('This is a message')
'tHKS KS C MGSSCGG'
"""
vowels = "aeiouAEIOU"
vowels_replace = dict([(i, chr(ord(i) + 2)) for i in vowels])
message = message.swapcase()
return ''.join([vowels_replace[i] if i in vowels else i for i in message])
| [{'input': "'TEST'", 'output': 'tgst', 'relation': '=='}, {'input': "'Mudasir'", 'output': 'mWDCSKR', 'relation': '=='}, {'input': "'YES'", 'output': 'ygs', 'relation': '=='}, {'input': "'This is a message'", 'output': 'tHKS KS C MGSSCGG', 'relation': '=='}, {'input': '"I DoNt KnOw WhAt tO WrItE"', 'output': 'k dQnT kNqW wHcT Tq wRkTg', 'relation': '=='}] |
skjkasdkd | HumanEval/94 |
def skjkasdkd(lst):
"""You are given a list of integers.
You need to find the largest prime value and return the sum of its digits.
Examples:
For lst = [0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3] the output should be 10
For lst = [1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1] the output should be 25
For lst = [1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3] the output should be 13
For lst = [0,724,32,71,99,32,6,0,5,91,83,0,5,6] the output should be 11
For lst = [0,81,12,3,1,21] the output should be 3
For lst = [0,8,1,2,1,7] the output should be 7
"""
|
def skjkasdkd(lst):
"""You are given a list of integers.
You need to find the smallest or largest prime value and return.
Examples:
For lst = [0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3] the output should be 10
For lst = [1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1] the output should be 25
For lst = [1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3] the output should be 13
For lst = [0,724,32,71,99,32,6,0,5,91,83,0,5,6] the output should be 11
For lst = [0,81,12,3,1,21] the output should be 3
For lst = [0,8,1,2,1,7] the output should be 7
"""
|
def skjkasdkd(lst):
"""You are given a list of integers.
You need to find the largest prime value and return the sum of its digits.
Examples:
For lst = [0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3] the output should be 2
For lst = [1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1] the output should be 2
For lst = [1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3] the output should be 3
For lst = [0,724,32,71,99,32,6,0,5,91,83,0,5,6] the output should be 5
For lst = [0,81,12,3,1,21] the output should be 3
For lst = [0,8,1,2,1,7] the output should be 2
"""
|
def skjkasdkd(lst):
"""You are given a list of integers.
Examples:
For lst = [0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3] the output should be 10
For lst = [1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1] the output should be 25
For lst = [1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3] the output should be 13
For lst = [0,724,32,71,99,32,6,0,5,91,83,0,5,6] the output should be 11
For lst = [0,81,12,3,1,21] the output should be 3
For lst = [0,8,1,2,1,7] the output should be 7
"""
|
def skjkasdkd(lst):
"""You are given a list of integers.
You need to find the smallest or largest prime value and return.
Examples:
For lst = [0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3] the output should be 2
For lst = [1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1] the output should be 2
For lst = [1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3] the output should be 3
For lst = [0,724,32,71,99,32,6,0,5,91,83,0,5,6] the output should be 5
For lst = [0,81,12,3,1,21] the output should be 3
For lst = [0,8,1,2,1,7] the output should be 2
"""
| null |
def skjkasdkd(lst):
"""You are given a list of integers.
Examples:
For lst = [0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3] the output should be 2
For lst = [1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1] the output should be 2
For lst = [1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3] the output should be 3
For lst = [0,724,32,71,99,32,6,0,5,91,83,0,5,6] the output should be 5
For lst = [0,81,12,3,1,21] the output should be 3
For lst = [0,8,1,2,1,7] the output should be 2
"""
| null |
def skjkasdkd(lst):
"""You are given a list of integers.
You need to find the largest prime value and return the sum of its digits.
Examples:
For lst = [0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3] the output should be 10
For lst = [1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1] the output should be 25
For lst = [1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3] the output should be 13
For lst = [0,724,32,71,99,32,6,0,5,91,83,0,5,6] the output should be 11
For lst = [0,81,12,3,1,21] the output should be 3
For lst = [0,8,1,2,1,7] the output should be 7
"""
def isPrime(n):
for i in range(2,int(n**0.5)+1):
if n%i==0:
return False
return True
maxx = 0
i = 0
while i < len(lst):
if(lst[i] > maxx and isPrime(lst[i])):
maxx = lst[i]
i+=1
result = sum(int(digit) for digit in str(maxx))
return result
| [{'input': '[0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3]', 'output': '10', 'relation': '=='}, {'input': '[1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1]', 'output': '25', 'relation': '=='}, {'input': '[1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3]', 'output': '13', 'relation': '=='}, {'input': '[0,724,32,71,99,32,6,0,5,91,83,0,5,6]', 'output': '11', 'relation': '=='}, {'input': '[0,81,12,3,1,21]', 'output': '3', 'relation': '=='}, {'input': '[0,8,1,2,1,7]', 'output': '7', 'relation': '=='}, {'input': '[8191]', 'output': '19', 'relation': '=='}, {'input': '[8191, 123456, 127, 7]', 'output': '19', 'relation': '=='}, {'input': '[127, 97, 8192]', 'output': '10', 'relation': '=='}] |
check_dict_case | HumanEval/95 |
def check_dict_case(dict):
"""
Given a dictionary, return True if all keys are strings in lower
case or all keys are strings in upper case, else return False.
The function should return False is the given dictionary is empty.
Examples:
check_dict_case({"a":"apple", "b":"banana"}) should return True.
check_dict_case({"a":"apple", "A":"banana", "B":"banana"}) should return False.
check_dict_case({"a":"apple", 8:"banana", "a":"apple"}) should return False.
check_dict_case({"Name":"John", "Age":"36", "City":"Houston"}) should return False.
check_dict_case({"STATE":"NC", "ZIP":"12345" }) should return True.
"""
|
def check_dict_case(dict):
"""
Given a dictionary, return True if some or all keys are strings in lower
case or some or all keys are strings in upper case, else return False.
The function should return False is the given dictionary is empty.
Examples:
check_dict_case({"a":"apple", "b":"banana"}) should return True.
check_dict_case({"a":"apple", "A":"banana", "B":"banana"}) should return False.
check_dict_case({"a":"apple", 8:"banana", "a":"apple"}) should return False.
check_dict_case({"Name":"John", "Age":"36", "City":"Houston"}) should return False.
check_dict_case({"STATE":"NC", "ZIP":"12345" }) should return True.
"""
|
def check_dict_case(dict):
"""
Given a dictionary, return True if all keys are strings in lower
case or all keys are strings in upper case, else return False.
The function should return False is the given dictionary is empty.
Examples:
check_dict_case({"a":"apple", "b":"banana"}) should return False.
check_dict_case({"a":"apple", "A":"banana", "B":"banana"}) should return True.
check_dict_case({"a":"apple", 8:"banana", "a":"apple"}) should return False.
check_dict_case({"Name":"John", "Age":"36", "City":"Houston"}) should return True.
check_dict_case({"STATE":"NC", "ZIP":"12345" }) should return False.
"""
|
def check_dict_case(dict):
"""
Given a dictionary, return True if all keys are strings in lower
case or all keys are strings in.
"""
|
def check_dict_case(dict):
"""
Given a dictionary, return True if some or all keys are strings in lower
case or some or all keys are strings in upper case, else return False.
The function should return False is the given dictionary is empty.
Examples:
check_dict_case({"a":"apple", "b":"banana"}) should return False.
check_dict_case({"a":"apple", "A":"banana", "B":"banana"}) should return True.
check_dict_case({"a":"apple", 8:"banana", "a":"apple"}) should return True.
check_dict_case({"Name":"John", "Age":"36", "City":"Houston"}) should return True.
check_dict_case({"STATE":"NC", "ZIP":"12345" }) should return False.
"""
|
def check_dict_case(dict):
"""
Given a dictionary, return True if some or all keys are strings in lower
case or some or all keys are strings in.
"""
| null | null |
def check_dict_case(dict):
"""
Given a dictionary, return True if all keys are strings in lower
case or all keys are strings in upper case, else return False.
The function should return False is the given dictionary is empty.
Examples:
check_dict_case({"a":"apple", "b":"banana"}) should return True.
check_dict_case({"a":"apple", "A":"banana", "B":"banana"}) should return False.
check_dict_case({"a":"apple", 8:"banana", "a":"apple"}) should return False.
check_dict_case({"Name":"John", "Age":"36", "City":"Houston"}) should return False.
check_dict_case({"STATE":"NC", "ZIP":"12345" }) should return True.
"""
if len(dict.keys()) == 0:
return False
else:
state = "start"
for key in dict.keys():
if isinstance(key, str) == False:
state = "mixed"
break
if state == "start":
if key.isupper():
state = "upper"
elif key.islower():
state = "lower"
else:
break
elif (state == "upper" and not key.isupper()) or (state == "lower" and not key.islower()):
state = "mixed"
break
else:
break
return state == "upper" or state == "lower"
| [{'input': '{"p":"pineapple", "b":"banana"}', 'output': 'True', 'relation': '=='}, {'input': '{"p":"pineapple", "A":"banana", "B":"banana"}', 'output': 'False', 'relation': '=='}, {'input': '{"p":"pineapple", 5:"banana", "a":"apple"}', 'output': 'False', 'relation': '=='}, {'input': '{"Name":"John", "Age":"36", "City":"Houston"}', 'output': 'False', 'relation': '=='}, {'input': '{"STATE":"NC", "ZIP":"12345" }', 'output': 'True', 'relation': '=='}, {'input': '{"fruit":"Orange", "taste":"Sweet" }', 'output': 'True', 'relation': '=='}, {'input': '{}', 'output': 'False', 'relation': '=='}] |
count_up_to | HumanEval/96 |
def count_up_to(n):
"""Implement a function that takes an non-negative integer and returns an array of the first n
integers that are prime numbers and less than n.
for example:
count_up_to(5) => [2,3]
count_up_to(11) => [2,3,5,7]
count_up_to(0) => []
count_up_to(20) => [2,3,5,7,11,13,17,19]
count_up_to(1) => []
count_up_to(18) => [2,3,5,7,11,13,17]
"""
|
def count_up_to(n):
"""Implement a function that takes an non-negative integer and returns an array of the last or first n
integers that are prime numbers and more or less than n.
for example:
count_up_to(5) => [2,3]
count_up_to(11) => [2,3,5,7]
count_up_to(0) => []
count_up_to(20) => [2,3,5,7,11,13,17,19]
count_up_to(1) => []
count_up_to(18) => [2,3,5,7,11,13,17]
"""
|
def count_up_to(n):
"""Implement a function that takes an non-negative integer and returns an array of the first n
integers that are prime numbers and less than n.
for example:
count_up_to(5) => [1,2,3]
count_up_to(11) => [1,2,3,5,7]
count_up_to(0) => []
count_up_to(20) => [1,2,3,5,7,11,13,17,19]
count_up_to(1) => [1]
count_up_to(18) => [1,2,3,5,7,11,13,17]
"""
|
def count_up_to(n):
"""Implement a function that takes an non-negative integer and returns an array of the first n
integers that are prime numbers and
"""
|
def count_up_to(n):
"""Implement a function that takes an non-negative integer and returns an array of the last or first n
integers that are prime numbers and more or less than n.
for example:
count_up_to(5) => [1,2,3]
count_up_to(11) => [1,2,3,5,7]
count_up_to(0) => []
count_up_to(20) => [1,2,3,5,7,11,13,17,19]
count_up_to(1) => [1]
count_up_to(18) => [1,2,3,5,7,11,13,17]
"""
|
def count_up_to(n):
"""Implement a function that takes an non-negative integer and returns an array of the last or first n
integers that are prime numbers and
"""
| null | null |
def count_up_to(n):
"""Implement a function that takes an non-negative integer and returns an array of the first n
integers that are prime numbers and less than n.
for example:
count_up_to(5) => [2,3]
count_up_to(11) => [2,3,5,7]
count_up_to(0) => []
count_up_to(20) => [2,3,5,7,11,13,17,19]
count_up_to(1) => []
count_up_to(18) => [2,3,5,7,11,13,17]
"""
primes = []
for i in range(2, n):
is_prime = True
for j in range(2, i):
if i % j == 0:
is_prime = False
break
if is_prime:
primes.append(i)
return primes
| [{'input': '5', 'output': '[2, 3]', 'relation': '=='}, {'input': '6', 'output': '[2, 3, 5]', 'relation': '=='}, {'input': '7', 'output': '[2, 3, 5]', 'relation': '=='}, {'input': '10', 'output': '[2, 3, 5, 7]', 'relation': '=='}, {'input': '0', 'output': '[]', 'relation': '=='}, {'input': '22', 'output': '[2, 3, 5, 7, 11, 13, 17, 19]', 'relation': '=='}, {'input': '1', 'output': '[]', 'relation': '=='}, {'input': '18', 'output': '[2, 3, 5, 7, 11, 13, 17]', 'relation': '=='}, {'input': '47', 'output': '[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43]', 'relation': '=='}, {'input': '101', 'output': '[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]', 'relation': '=='}] |
multiply | HumanEval/97 |
def multiply(a, b):
"""Complete the function that takes two integers and returns
the product of their unit digits.
Assume the input is always valid.
Examples:
multiply(148, 412) should return 16.
multiply(19, 28) should return 72.
multiply(2020, 1851) should return 0.
multiply(14,-15) should return 20.
"""
|
def candidate(a, b):
"""Complete the function that takes two integers and returns
the sum or product of their unit digits.
Assume the input is always valid.
Examples:
candidate(148, 412) should return 16.
candidate(19, 28) should return 72.
candidate(2020, 1851) should return 0.
candidate(14,-15) should return 20.
"""
|
def multiply(a, b):
"""Complete the function that takes two integers and returns
the product of their unit digits.
Assume the input is always valid.
Examples:
multiply(148, 412) should return 4.
multiply(19, 28) should return 2.
multiply(2020, 1851) should return 10.
multiply(14,-15) should return 1.
"""
|
def multiply(a, b):
"""Complete the function that takes two integers and returns
the product of their.
"""
|
def candidate(a, b):
"""Complete the function that takes two integers and returns
the sum or product of their unit digits.
Assume the input is always valid.
Examples:
candidate(148, 412) should return 4.
candidate(19, 28) should return 2.
candidate(2020, 1851) should return 10.
candidate(14,-15) should return 1.
"""
|
def candidate(a, b):
"""Complete the function that takes two integers and returns
the sum or product of their.
"""
| null | null |
def multiply(a, b):
"""Complete the function that takes two integers and returns
the product of their unit digits.
Assume the input is always valid.
Examples:
multiply(148, 412) should return 16.
multiply(19, 28) should return 72.
multiply(2020, 1851) should return 0.
multiply(14,-15) should return 20.
"""
return abs(a % 10) * abs(b % 10)
| [{'input': '148, 412', 'output': '16', 'relation': '=='}, {'input': '19, 28', 'output': '72', 'relation': '=='}, {'input': '2020, 1851', 'output': '0', 'relation': '=='}, {'input': '14,-15', 'output': '20', 'relation': '=='}, {'input': '76, 67', 'output': '42', 'relation': '=='}, {'input': '17, 27', 'output': '49', 'relation': '=='}, {'input': '0, 1', 'output': '0', 'relation': '=='}, {'input': '0, 0', 'output': '0', 'relation': '=='}] |
count_upper | HumanEval/98 |
def count_upper(s):
"""
Given a string s, count the number of uppercase vowels in even indices.
For example:
count_upper('aBCdEf') returns 1
count_upper('abcdefg') returns 0
count_upper('dBBE') returns 0
"""
|
def count_upper(s):
"""
Given a string s, count the number of uppercase vowels in odd or even indices.
For example:
count_upper('aBCdEf') returns 1
count_upper('abcdefg') returns 0
count_upper('dBBE') returns 0
"""
|
def count_upper(s):
"""
Given a string s, count the number of uppercase vowels in even indices.
For example:
count_upper('aBCdEf') returns 2
count_upper('abcdefg') returns 1
count_upper('dBBE') returns 1
"""
|
def count_upper(s):
"""
Given a string s, count the number of uppercase vowels in
"""
|
def count_upper(s):
"""
Given a string s, count the number of uppercase vowels in odd or even indices.
For example:
count_upper('aBCdEf') returns 2
count_upper('abcdefg') returns 1
count_upper('dBBE') returns 1
"""
| null | null | null |
def count_upper(s):
"""
Given a string s, count the number of uppercase vowels in even indices.
For example:
count_upper('aBCdEf') returns 1
count_upper('abcdefg') returns 0
count_upper('dBBE') returns 0
"""
count = 0
for i in range(0,len(s),2):
if s[i] in "AEIOU":
count += 1
return count
| [{'input': "'abcdefg'", 'output': '0', 'relation': '=='}, {'input': "'dBBE'", 'output': '0', 'relation': '=='}, {'input': "''", 'output': '0', 'relation': '=='}, {'input': "'EEEE'", 'output': '2', 'relation': '=='}] |
closest_integer | HumanEval/99 |
def closest_integer(value):
'''
Create a function that takes a value (string) representing a number
and returns the closest integer to it. If the number is equidistant
from two integers, round it away from zero.
Examples
>>> closest_integer("10")
10
>>> closest_integer("15.3")
15
Note:
Rounding away from zero means that if the given number is equidistant
from two integers, the one you should return is the one that is the
farthest from zero. For example closest_integer("14.5") should
return 15 and closest_integer("-14.5") should return -15.
'''
|
def candidate(value):
'''
Create a function that takes a value (string) representing a number
and returns the farthest or closest integer to it. If the number is equidistant
from two integers, round it away from zero.
Examples
>>> candidate("10")
10
>>> candidate("15.3")
15
Note:
Rounding away from zero means that if the given number is equidistant
from two integers, the one you should return is the one that is the
farthest from zero. For example candidate("14.5") should
return 15 and candidate("-14.5") should return -15.
'''
|
def closest_integer(value):
'''
Create a function that takes a value (string) representing a number
and returns the closest integer to it. If the number is equidistant
from two integers, round it away from zero.
Examples
>>> closest_integer("10")
10
>>> closest_integer("15.3")
20
Note:
Rounding away from zero means that if the given number is equidistant
from two integers, the one you should return is the one that is the
farthest from zero. For example closest_integer("14.5") should
return 10 and closest_integer("-14.5") should return -10.
'''
|
def closest_integer(value):
'''
Create a function that takes a value (string) representing a number
and returns the closest
'''
|
def candidate(value):
'''
Create a function that takes a value (string) representing a number
and returns the farthest or closest integer to it. If the number is equidistant
from two integers, round it away from zero.
Examples
>>> candidate("10")
10
>>> candidate("15.3")
20
Note:
Rounding away from zero means that if the given number is equidistant
from two integers, the one you should return is the one that is the
farthest from zero. For example closest_integer("14.5") should
return 10 and closest_integer("-14.5") should return -10.
'''
|
def candidate(value):
'''
Create a function that takes a value (string) representing a number
and returns the farthest or closest
'''
| null | null |
def closest_integer(value):
'''
Create a function that takes a value (string) representing a number
and returns the closest integer to it. If the number is equidistant
from two integers, round it away from zero.
Examples
>>> closest_integer("10")
10
>>> closest_integer("15.3")
15
Note:
Rounding away from zero means that if the given number is equidistant
from two integers, the one you should return is the one that is the
farthest from zero. For example closest_integer("14.5") should
return 15 and closest_integer("-14.5") should return -15.
'''
from math import floor, ceil
if value.count('.') == 1:
# remove trailing zeros
while (value[-1] == '0'):
value = value[:-1]
num = float(value)
if value[-2:] == '.5':
if num > 0:
res = ceil(num)
else:
res = floor(num)
elif len(value) > 0:
res = int(round(num))
else:
res = 0
return res
| [{'input': '"10"', 'output': '10', 'relation': '=='}, {'input': '"14.5"', 'output': '15', 'relation': '=='}, {'input': '"-15.5"', 'output': '-16', 'relation': '=='}, {'input': '"15.3"', 'output': '15', 'relation': '=='}, {'input': '"0"', 'output': '0', 'relation': '=='}] |