task_id
stringlengths 11
13
| prompt
stringlengths 124
1.02k
| entry_point
stringlengths 1
30
| canonical_solution
stringlengths 16
864
| test
stringlengths 117
1.8k
| test_inputs
sequence | test_outputs
sequence | language
stringclasses 1
value |
---|---|---|---|---|---|---|---|
HumanEval/1 | <commit_before>from typing import List
def has_close_elements(numbers: List[float], threshold: float) -> bool:
for idx, elem in enumerate(numbers):
for idx2, elem2 in enumerate(numbers):
if idx != idx2:
distance = elem - elem2
if distance < threshold:
return True
return False
<commit_msg>Fix bugs in has_close_elements.<commit_after>
from typing import List
def has_close_elements(numbers: List[float], threshold: float) -> bool: | 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
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate('(()()) ((())) () ((())()())') == [
'(()())', '((()))', '()', '((())()())'
]
assert candidate('() (()) ((())) (((())))') == [
'()', '(())', '((()))', '(((())))'
]
assert candidate('(()(())((())))') == [
'(()(())((())))'
]
assert candidate('( ) (( )) (( )( ))') == ['()', '(())', '(()())']
| [
"('(()()) ((())) () ((())()())',)",
"('() (()) ((())) (((())))',)",
"('(()(())((())))',)",
"('( ) (( )) (( )( ))',)"
] | [
"['(()())', '((()))', '()', '((())()())']",
"['()', '(())', '((()))', '(((())))']",
"['(()(())((())))']",
"['()', '(())', '(()())']"
] | python |
HumanEval/0 | <commit_before>from typing import List
def separate_paren_groups(paren_string: str) -> List[str]:
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
<commit_msg>Fix bugs in separate_paren_groups.<commit_after>
from typing import List
def separate_paren_groups(paren_string: str) -> List[str]: | has_close_elements | 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
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate([1.0, 2.0, 3.9, 4.0, 5.0, 2.2], 0.3) == True
assert candidate([1.0, 2.0, 3.9, 4.0, 5.0, 2.2], 0.05) == False
assert candidate([1.0, 2.0, 5.9, 4.0, 5.0], 0.95) == True
assert candidate([1.0, 2.0, 5.9, 4.0, 5.0], 0.8) == False
assert candidate([1.0, 2.0, 3.0, 4.0, 5.0, 2.0], 0.1) == True
assert candidate([1.1, 2.2, 3.1, 4.1, 5.1], 1.0) == True
assert candidate([1.1, 2.2, 3.1, 4.1, 5.1], 0.5) == False
| [
"([1.0, 2.0, 3.9, 4.0, 5.0, 2.2], 0.3)",
"([1.0, 2.0, 3.9, 4.0, 5.0, 2.2], 0.05)",
"([1.0, 2.0, 5.9, 4.0, 5.0], 0.95)",
"([1.0, 2.0, 5.9, 4.0, 5.0], 0.8)",
"([1.0, 2.0, 3.0, 4.0, 5.0, 2.0], 0.1)",
"([1.1, 2.2, 3.1, 4.1, 5.1], 1.0)",
"([1.1, 2.2, 3.1, 4.1, 5.1], 0.5)"
] | [
"True",
"False",
"True",
"False",
"True",
"True",
"False"
] | python |
HumanEval/2 | <commit_before>def truncate_number(number: float) -> float:
return number % 1.0 + 1.0
<commit_msg>Fix bugs in truncate_number.<commit_after>
def truncate_number(number: float) -> float: | truncate_number | return number % 1.0
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate(3.5) == 0.5
assert abs(candidate(1.33) - 0.33) < 1e-6
assert abs(candidate(123.456) - 0.456) < 1e-6
| [
"(3.5,)",
"(1.33,)",
"(123.456,)"
] | [
"0.5",
"0.33000000000000007",
"0.45600000000000307"
] | python |
HumanEval/3 | <commit_before>from typing import List
def below_zero(operations: List[int]) -> bool:
balance = 0
for op in operations:
balance += op
if balance == 0:
return True
return False
<commit_msg>Fix bugs in below_zero.<commit_after>
from typing import List
def below_zero(operations: List[int]) -> bool: | below_zero | balance = 0
for op in operations:
balance += op
if balance < 0:
return True
return False
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate([]) == False
assert candidate([1, 2, -3, 1, 2, -3]) == False
assert candidate([1, 2, -4, 5, 6]) == True
assert candidate([1, -1, 2, -2, 5, -5, 4, -4]) == False
assert candidate([1, -1, 2, -2, 5, -5, 4, -5]) == True
assert candidate([1, -2, 2, -2, 5, -5, 4, -4]) == True
| [
"([],)",
"([1, 2, -3, 1, 2, -3],)",
"([1, 2, -4, 5, 6],)",
"([1, -1, 2, -2, 5, -5, 4, -4],)",
"([1, -1, 2, -2, 5, -5, 4, -5],)",
"([1, -2, 2, -2, 5, -5, 4, -4],)"
] | [
"False",
"False",
"True",
"False",
"True",
"True"
] | python |
HumanEval/4 | <commit_before>from typing import List
def mean_absolute_deviation(numbers: List[float]) -> float:
mean = sum(numbers) / len(numbers)
return sum(abs(x - mean) for x in numbers) / mean
<commit_msg>Fix bugs in mean_absolute_deviation.<commit_after>
from typing import List
def mean_absolute_deviation(numbers: List[float]) -> float: | mean_absolute_deviation | mean = sum(numbers) / len(numbers)
return sum(abs(x - mean) for x in numbers) / len(numbers)
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert abs(candidate([1.0, 2.0, 3.0]) - 2.0/3.0) < 1e-6
assert abs(candidate([1.0, 2.0, 3.0, 4.0]) - 1.0) < 1e-6
assert abs(candidate([1.0, 2.0, 3.0, 4.0, 5.0]) - 6.0/5.0) < 1e-6
| [
"([1.0, 2.0, 3.0],)",
"([1.0, 2.0, 3.0, 4.0],)",
"([1.0, 2.0, 3.0, 4.0, 5.0],)"
] | [
"0.6666666666666666",
"1.0",
"1.2"
] | python |
HumanEval/5 | <commit_before>from typing import List
def intersperse(numbers: List[int], delimeter: int) -> List[int]:
if not numbers:
return []
result = []
for n in numbers[:-1]:
result.append(n)
result.append(delimeter)
return result
<commit_msg>Fix bugs in intersperse.<commit_after>
from typing import List
def intersperse(numbers: List[int], delimeter: int) -> List[int]: | intersperse | if not numbers:
return []
result = []
for n in numbers[:-1]:
result.append(n)
result.append(delimeter)
result.append(numbers[-1])
return result
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate([], 7) == []
assert candidate([5, 6, 3, 2], 8) == [5, 8, 6, 8, 3, 8, 2]
assert candidate([2, 2, 2], 2) == [2, 2, 2, 2, 2]
| [
"([], 7)",
"([5, 6, 3, 2], 8)",
"([2, 2, 2], 2)"
] | [
"[]",
"[5, 8, 6, 8, 3, 8, 2]",
"[2, 2, 2, 2, 2]"
] | python |
HumanEval/6 | <commit_before>from typing import List
def parse_nested_parens(paren_string: str) -> List[int]:
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:
max_depth -= 1
return max_depth
return [parse_paren_group(x) for x in paren_string.split(' ') if x]
<commit_msg>Fix bugs in parse_nested_parens.<commit_after>
from typing import List
def parse_nested_parens(paren_string: str) -> List[int]: | parse_nested_parens | 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]
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate('(()()) ((())) () ((())()())') == [2, 3, 1, 3]
assert candidate('() (()) ((())) (((())))') == [1, 2, 3, 4]
assert candidate('(()(())((())))') == [4]
| [
"('(()()) ((())) () ((())()())',)",
"('() (()) ((())) (((())))',)",
"('(()(())((())))',)"
] | [
"[2, 3, 1, 3]",
"[1, 2, 3, 4]",
"[4]"
] | python |
HumanEval/7 | <commit_before>from typing import List
def filter_by_substring(strings: List[str], substring: str) -> List[str]:
return [x for x in strings if x in substring]
<commit_msg>Fix bugs in filter_by_substring.<commit_after>
from typing import List
def filter_by_substring(strings: List[str], substring: str) -> List[str]: | filter_by_substring | return [x for x in strings if substring in x]
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate([], 'john') == []
assert candidate(['xxx', 'asd', 'xxy', 'john doe', 'xxxAAA', 'xxx'], 'xxx') == ['xxx', 'xxxAAA', 'xxx']
assert candidate(['xxx', 'asd', 'aaaxxy', 'john doe', 'xxxAAA', 'xxx'], 'xx') == ['xxx', 'aaaxxy', 'xxxAAA', 'xxx']
assert candidate(['grunt', 'trumpet', 'prune', 'gruesome'], 'run') == ['grunt', 'prune']
| [
"([], 'john')",
"(['xxx', 'asd', 'xxy', 'john doe', 'xxxAAA', 'xxx'], 'xxx')",
"(['xxx', 'asd', 'aaaxxy', 'john doe', 'xxxAAA', 'xxx'], 'xx')",
"(['grunt', 'trumpet', 'prune', 'gruesome'], 'run')"
] | [
"[]",
"['xxx', 'xxxAAA', 'xxx']",
"['xxx', 'aaaxxy', 'xxxAAA', 'xxx']",
"['grunt', 'prune']"
] | python |
HumanEval/8 | <commit_before>from typing import List, Tuple
def sum_product(numbers: List[int]) -> Tuple[int, int]:
sum_value = 0
prod_value = 0
for n in numbers:
sum_value += n
prod_value *= n
return sum_value, prod_value
<commit_msg>Fix bugs in sum_product.<commit_after>
from typing import List, Tuple
def sum_product(numbers: List[int]) -> Tuple[int, int]: | sum_product | sum_value = 0
prod_value = 1
for n in numbers:
sum_value += n
prod_value *= n
return sum_value, prod_value
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate([]) == (0, 1)
assert candidate([1, 1, 1]) == (3, 1)
assert candidate([100, 0]) == (100, 0)
assert candidate([3, 5, 7]) == (3 + 5 + 7, 3 * 5 * 7)
assert candidate([10]) == (10, 10)
| [
"([],)",
"([1, 1, 1],)",
"([100, 0],)",
"([3, 5, 7],)",
"([10],)"
] | [
"(0, 1)",
"(3, 1)",
"(100, 0)",
"(15, 105)",
"(10, 10)"
] | python |
HumanEval/9 | <commit_before>from typing import List, Tuple
def rolling_max(numbers: List[int]) -> List[int]:
running_max = None
result = []
for n in numbers:
if running_max is None:
running_max = n
else:
running_max = max(numbers)
result.append(running_max)
return result
<commit_msg>Fix bugs in rolling_max.<commit_after>
from typing import List, Tuple
def rolling_max(numbers: List[int]) -> List[int]: | rolling_max | running_max = None
result = []
for n in numbers:
if running_max is None:
running_max = n
else:
running_max = max(running_max, n)
result.append(running_max)
return result
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate([]) == []
assert candidate([1, 2, 3, 4]) == [1, 2, 3, 4]
assert candidate([4, 3, 2, 1]) == [4, 4, 4, 4]
assert candidate([3, 2, 3, 100, 3]) == [3, 3, 3, 100, 100]
| [
"([],)",
"([1, 2, 3, 4],)",
"([4, 3, 2, 1],)",
"([3, 2, 3, 100, 3],)"
] | [
"[]",
"[1, 2, 3, 4]",
"[4, 4, 4, 4]",
"[3, 3, 3, 100, 100]"
] | python |
HumanEval/10 | <commit_before>def is_palindrome(string: str) -> bool:
""" Test if given string is a palindrome """
return string == string[::-1]
def make_palindrome(string: str) -> str:
if not string:
return ''
beginning_of_suffix = 0
while not is_palindrome(string):
beginning_of_suffix += 1
return string + string[:beginning_of_suffix][::-1]
<commit_msg>Fix bugs in make_palindrome.<commit_after>
def is_palindrome(string: str) -> bool:
""" Test if given string is a palindrome """
return string == string[::-1]
def make_palindrome(string: str) -> str: | make_palindrome | 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]
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate('') == ''
assert candidate('x') == 'x'
assert candidate('xyz') == 'xyzyx'
assert candidate('xyx') == 'xyx'
assert candidate('jerry') == 'jerryrrej'
| [
"('',)",
"('x',)",
"('xyz',)",
"('xyx',)",
"('jerry',)"
] | [
"",
"x",
"xyzyx",
"xyx",
"jerryrrej"
] | python |
HumanEval/11 | <commit_before>from typing import List
def string_xor(a: str, b: str) -> str:
def xor(i, j):
if i == j:
return '1'
else:
return '0'
return ''.join(xor(x, y) for x, y in zip(a, b))
<commit_msg>Fix bugs in string_xor.<commit_after>
from typing import List
def string_xor(a: str, b: str) -> str: | string_xor | def xor(i, j):
if i == j:
return '0'
else:
return '1'
return ''.join(xor(x, y) for x, y in zip(a, b))
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate('111000', '101010') == '010010'
assert candidate('1', '1') == '0'
assert candidate('0101', '0000') == '0101'
| [
"('111000', '101010')",
"('1', '1')",
"('0101', '0000')"
] | [
"010010",
"0",
"0101"
] | python |
HumanEval/12 | <commit_before>from typing import List, Optional
def longest(strings: List[str]) -> Optional[str]:
if not strings:
return None
maxlen = max(len(x) for x in strings)
for s in strings:
if len(s) > maxlen:
return s
<commit_msg>Fix bugs in longest.<commit_after>
from typing import List, Optional
def longest(strings: List[str]) -> Optional[str]: | longest | if not strings:
return None
maxlen = max(len(x) for x in strings)
for s in strings:
if len(s) == maxlen:
return s
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate([]) == None
assert candidate(['x', 'y', 'z']) == 'x'
assert candidate(['x', 'yyy', 'zzzz', 'www', 'kkkk', 'abc']) == 'zzzz'
| [
"([],)",
"(['x', 'y', 'z'],)",
"(['x', 'yyy', 'zzzz', 'www', 'kkkk', 'abc'],)"
] | [
"None",
"x",
"zzzz"
] | python |
HumanEval/13 | <commit_before>def greatest_common_divisor(a: int, b: int) -> int:
while b:
a, b = b, a % b
return b
<commit_msg>Fix bugs in greatest_common_divisor.<commit_after>
def greatest_common_divisor(a: int, b: int) -> int: | greatest_common_divisor | while b:
a, b = b, a % b
return a
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate(3, 7) == 1
assert candidate(10, 15) == 5
assert candidate(49, 14) == 7
assert candidate(144, 60) == 12
| [
"(3, 7)",
"(10, 15)",
"(49, 14)",
"(144, 60)"
] | [
"1",
"5",
"7",
"12"
] | python |
HumanEval/14 | <commit_before>from typing import List
def all_prefixes(string: str) -> List[str]:
result = []
for i in range(len(string)-1):
result.append(string[:i+1])
return result
<commit_msg>Fix bugs in all_prefixes.<commit_after>
from typing import List
def all_prefixes(string: str) -> List[str]: | all_prefixes | result = []
for i in range(len(string)):
result.append(string[:i+1])
return result
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate('') == []
assert candidate('asdfgh') == ['a', 'as', 'asd', 'asdf', 'asdfg', 'asdfgh']
assert candidate('WWW') == ['W', 'WW', 'WWW']
| [
"('',)",
"('asdfgh',)",
"('WWW',)"
] | [
"[]",
"['a', 'as', 'asd', 'asdf', 'asdfg', 'asdfgh']",
"['W', 'WW', 'WWW']"
] | python |
HumanEval/15 | <commit_before>def string_sequence(n: int) -> str:
return ' '.join([str(x) for x in range(n)])
<commit_msg>Fix bugs in string_sequence.<commit_after>
def string_sequence(n: int) -> str: | string_sequence | return ' '.join([str(x) for x in range(n + 1)])
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate(0) == '0'
assert candidate(3) == '0 1 2 3'
assert candidate(10) == '0 1 2 3 4 5 6 7 8 9 10'
| [
"(0,)",
"(3,)",
"(10,)"
] | [
"0",
"0 1 2 3",
"0 1 2 3 4 5 6 7 8 9 10"
] | python |
HumanEval/16 | <commit_before>def count_distinct_characters(string: str) -> int:
return len(set(string))
<commit_msg>Fix bugs in count_distinct_characters.<commit_after>
def count_distinct_characters(string: str) -> int: | count_distinct_characters | return len(set(string.lower()))
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate('') == 0
assert candidate('abcde') == 5
assert candidate('abcde' + 'cade' + 'CADE') == 5
assert candidate('aaaaAAAAaaaa') == 1
assert candidate('Jerry jERRY JeRRRY') == 5
| [
"('',)",
"('abcde',)",
"('abcdecadeCADE',)",
"('aaaaAAAAaaaa',)",
"('Jerry jERRY JeRRRY',)"
] | [
"0",
"5",
"5",
"1",
"5"
] | python |
HumanEval/17 | <commit_before>from typing import List
def parse_music(music_string: str) -> List[int]:
note_map = {'o': 3, 'o|': 2, '.|': 1}
return [note_map[x] for x in music_string.split(' ') if x]
<commit_msg>Fix bugs in parse_music.<commit_after>
from typing import List
def parse_music(music_string: str) -> List[int]: | parse_music | note_map = {'o': 4, 'o|': 2, '.|': 1}
return [note_map[x] for x in music_string.split(' ') if x]
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate('') == []
assert candidate('o o o o') == [4, 4, 4, 4]
assert candidate('.| .| .| .|') == [1, 1, 1, 1]
assert candidate('o| o| .| .| o o o o') == [2, 2, 1, 1, 4, 4, 4, 4]
assert candidate('o| .| o| .| o o| o o|') == [2, 1, 2, 1, 4, 2, 4, 2]
| [
"('',)",
"('o o o o',)",
"('.| .| .| .|',)",
"('o| o| .| .| o o o o',)",
"('o| .| o| .| o o| o o|',)"
] | [
"[]",
"[4, 4, 4, 4]",
"[1, 1, 1, 1]",
"[2, 2, 1, 1, 4, 4, 4, 4]",
"[2, 1, 2, 1, 4, 2, 4, 2]"
] | python |
HumanEval/18 | <commit_before>def how_many_times(string: str, substring: str) -> int:
times = 0
for i in range(len(string) - len(substring)):
if string[i:i+len(substring)] == substring:
times += 1
return times
<commit_msg>Fix bugs in how_many_times.<commit_after>
def how_many_times(string: str, substring: str) -> int: | how_many_times | times = 0
for i in range(len(string) - len(substring) + 1):
if string[i:i+len(substring)] == substring:
times += 1
return times
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate('', 'x') == 0
assert candidate('xyxyxyx', 'x') == 4
assert candidate('cacacacac', 'cac') == 4
assert candidate('john doe', 'john') == 1
| [
"('', 'x')",
"('xyxyxyx', 'x')",
"('cacacacac', 'cac')",
"('john doe', 'john')"
] | [
"0",
"4",
"4",
"1"
] | python |
HumanEval/19 | <commit_before>from typing import List
def sort_numbers(numbers: str) -> str:
value_map = {
'zero': 0,
'one': 1,
'two': 2,
'three': 3,
'four': 4,
'five': 5,
'six': 6,
'seven': 7,
'eight': 8,
'nine': 9
}
return ' '.join([x for x in numbers.split(' ') if x])
<commit_msg>Fix bugs in sort_numbers.<commit_after>
from typing import List
def sort_numbers(numbers: str) -> str: | sort_numbers | value_map = {
'zero': 0,
'one': 1,
'two': 2,
'three': 3,
'four': 4,
'five': 5,
'six': 6,
'seven': 7,
'eight': 8,
'nine': 9
}
return ' '.join(sorted([x for x in numbers.split(' ') if x], key=lambda x: value_map[x]))
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate('') == ''
assert candidate('three') == 'three'
assert candidate('three five nine') == 'three five nine'
assert candidate('five zero four seven nine eight') == 'zero four five seven eight nine'
assert candidate('six five four three two one zero') == 'zero one two three four five six'
| [
"('',)",
"('three',)",
"('three five nine',)",
"('five zero four seven nine eight',)",
"('six five four three two one zero',)"
] | [
"",
"three",
"three five nine",
"zero four five seven eight nine",
"zero one two three four five six"
] | python |
HumanEval/20 | <commit_before>from typing import List, Tuple
def find_closest_elements(numbers: List[float]) -> Tuple[float, float]:
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
<commit_msg>Fix bugs in find_closest_elements.<commit_after>
from typing import List, Tuple
def find_closest_elements(numbers: List[float]) -> Tuple[float, float]: | find_closest_elements | 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
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate([1.0, 2.0, 3.9, 4.0, 5.0, 2.2]) == (3.9, 4.0)
assert candidate([1.0, 2.0, 5.9, 4.0, 5.0]) == (5.0, 5.9)
assert candidate([1.0, 2.0, 3.0, 4.0, 5.0, 2.2]) == (2.0, 2.2)
assert candidate([1.0, 2.0, 3.0, 4.0, 5.0, 2.0]) == (2.0, 2.0)
assert candidate([1.1, 2.2, 3.1, 4.1, 5.1]) == (2.2, 3.1)
| [
"([1.0, 2.0, 3.9, 4.0, 5.0, 2.2],)",
"([1.0, 2.0, 5.9, 4.0, 5.0],)",
"([1.0, 2.0, 3.0, 4.0, 5.0, 2.2],)",
"([1.0, 2.0, 3.0, 4.0, 5.0, 2.0],)",
"([1.1, 2.2, 3.1, 4.1, 5.1],)"
] | [
"(3.9, 4.0)",
"(5.0, 5.9)",
"(2.0, 2.2)",
"(2.0, 2.0)",
"(2.2, 3.1)"
] | python |
HumanEval/21 | <commit_before>from typing import List
def rescale_to_unit(numbers: List[float]) -> List[float]:
min_number = min(numbers)
max_number = max(numbers)
return [(x - min_number) / (max_number + min_number) for x in numbers]
<commit_msg>Fix bugs in rescale_to_unit.<commit_after>
from typing import List
def rescale_to_unit(numbers: List[float]) -> List[float]: | rescale_to_unit | min_number = min(numbers)
max_number = max(numbers)
return [(x - min_number) / (max_number - min_number) for x in numbers]
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate([2.0, 49.9]) == [0.0, 1.0]
assert candidate([100.0, 49.9]) == [1.0, 0.0]
assert candidate([1.0, 2.0, 3.0, 4.0, 5.0]) == [0.0, 0.25, 0.5, 0.75, 1.0]
assert candidate([2.0, 1.0, 5.0, 3.0, 4.0]) == [0.25, 0.0, 1.0, 0.5, 0.75]
assert candidate([12.0, 11.0, 15.0, 13.0, 14.0]) == [0.25, 0.0, 1.0, 0.5, 0.75]
| [
"([2.0, 49.9],)",
"([100.0, 49.9],)",
"([1.0, 2.0, 3.0, 4.0, 5.0],)",
"([2.0, 1.0, 5.0, 3.0, 4.0],)",
"([12.0, 11.0, 15.0, 13.0, 14.0],)"
] | [
"[0.0, 1.0]",
"[1.0, 0.0]",
"[0.0, 0.25, 0.5, 0.75, 1.0]",
"[0.25, 0.0, 1.0, 0.5, 0.75]",
"[0.25, 0.0, 1.0, 0.5, 0.75]"
] | python |
HumanEval/22 | <commit_before>from typing import List, Any
def filter_integers(values: List[Any]) -> List[int]:
out = [x for x in values if isinstance(x, int)]
return values
<commit_msg>Fix bugs in filter_integers.<commit_after>
from typing import List, Any
def filter_integers(values: List[Any]) -> List[int]: | filter_integers | return [x for x in values if isinstance(x, int)]
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate([]) == []
assert candidate([4, {}, [], 23.2, 9, 'adasd']) == [4, 9]
assert candidate([3, 'c', 3, 3, 'a', 'b']) == [3, 3, 3]
| [
"([],)",
"([4, {}, [], 23.2, 9, 'adasd'],)",
"([3, 'c', 3, 3, 'a', 'b'],)"
] | [
"[]",
"[4, 9]",
"[3, 3, 3]"
] | python |
HumanEval/23 | <commit_before>def strlen(string: str) -> int:
return len(string) - 1
<commit_msg>Fix bugs in strlen.<commit_after>
def strlen(string: str) -> int: | strlen | return len(string)
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate('') == 0
assert candidate('x') == 1
assert candidate('asdasnakj') == 9
| [
"('',)",
"('x',)",
"('asdasnakj',)"
] | [
"0",
"1",
"9"
] | python |
HumanEval/24 | <commit_before>def largest_divisor(n: int) -> int:
for i in reversed(range(n)):
if n - i == 0:
return i
<commit_msg>Fix bugs in largest_divisor.<commit_after>
def largest_divisor(n: int) -> int: | largest_divisor | for i in reversed(range(n)):
if n % i == 0:
return i
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate(3) == 1
assert candidate(7) == 1
assert candidate(10) == 5
assert candidate(100) == 50
assert candidate(49) == 7
| [
"(3,)",
"(7,)",
"(10,)",
"(100,)",
"(49,)"
] | [
"1",
"1",
"5",
"50",
"7"
] | python |
HumanEval/25 | <commit_before>from typing import List
def factorize(n: int) -> List[int]:
import math
fact = []
i = 0
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
<commit_msg>Fix bugs in factorize.<commit_after>
from typing import List
def factorize(n: int) -> List[int]: | factorize | 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
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate(2) == [2]
assert candidate(4) == [2, 2]
assert candidate(8) == [2, 2, 2]
assert candidate(3 * 19) == [3, 19]
assert candidate(3 * 19 * 3 * 19) == [3, 3, 19, 19]
assert candidate(3 * 19 * 3 * 19 * 3 * 19) == [3, 3, 3, 19, 19, 19]
assert candidate(3 * 19 * 19 * 19) == [3, 19, 19, 19]
assert candidate(3 * 2 * 3) == [2, 3, 3]
| [
"(2,)",
"(4,)",
"(8,)",
"(57,)",
"(3249,)",
"(185193,)",
"(20577,)",
"(18,)"
] | [
"[2]",
"[2, 2]",
"[2, 2, 2]",
"[3, 19]",
"[3, 3, 19, 19]",
"[3, 3, 3, 19, 19, 19]",
"[3, 19, 19, 19]",
"[2, 3, 3]"
] | python |
HumanEval/26 | <commit_before>from typing import List
def remove_duplicates(numbers: List[int]) -> List[int]:
import collections
c = collections.Counter(numbers)
return [n for n in numbers if c[n] < 1]
<commit_msg>Fix bugs in remove_duplicates.<commit_after>
from typing import List
def remove_duplicates(numbers: List[int]) -> List[int]: | remove_duplicates | import collections
c = collections.Counter(numbers)
return [n for n in numbers if c[n] <= 1]
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate([]) == []
assert candidate([1, 2, 3, 4]) == [1, 2, 3, 4]
assert candidate([1, 2, 3, 2, 4, 3, 5]) == [1, 4, 5]
| [
"([],)",
"([1, 2, 3, 4],)",
"([1, 2, 3, 2, 4, 3, 5],)"
] | [
"[]",
"[1, 2, 3, 4]",
"[1, 4, 5]"
] | python |
HumanEval/27 | <commit_before>def flip_case(string: str) -> str:
return string.lower()
<commit_msg>Fix bugs in flip_case.<commit_after>
def flip_case(string: str) -> str: | flip_case | return string.swapcase()
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate('') == ''
assert candidate('Hello!') == 'hELLO!'
assert candidate('These violent delights have violent ends') == 'tHESE VIOLENT DELIGHTS HAVE VIOLENT ENDS'
| [
"('',)",
"('Hello!',)",
"('These violent delights have violent ends',)"
] | [
"",
"hELLO!",
"tHESE VIOLENT DELIGHTS HAVE VIOLENT ENDS"
] | python |
HumanEval/28 | <commit_before>from typing import List
def concatenate(strings: List[str]) -> str:
return ' '.join(strings)
<commit_msg>Fix bugs in concatenate.<commit_after>
from typing import List
def concatenate(strings: List[str]) -> str: | concatenate | return ''.join(strings)
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate([]) == ''
assert candidate(['x', 'y', 'z']) == 'xyz'
assert candidate(['x', 'y', 'z', 'w', 'k']) == 'xyzwk'
| [
"([],)",
"(['x', 'y', 'z'],)",
"(['x', 'y', 'z', 'w', 'k'],)"
] | [
"",
"xyz",
"xyzwk"
] | python |
HumanEval/29 | <commit_before>from typing import List
def filter_by_prefix(strings: List[str], prefix: str) -> List[str]:
return [x for x in strings if x.endswith(prefix)]
<commit_msg>Fix bugs in filter_by_prefix.<commit_after>
from typing import List
def filter_by_prefix(strings: List[str], prefix: str) -> List[str]: | filter_by_prefix | return [x for x in strings if x.startswith(prefix)]
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate([], 'john') == []
assert candidate(['xxx', 'asd', 'xxy', 'john doe', 'xxxAAA', 'xxx'], 'xxx') == ['xxx', 'xxxAAA', 'xxx']
| [
"([], 'john')",
"(['xxx', 'asd', 'xxy', 'john doe', 'xxxAAA', 'xxx'], 'xxx')"
] | [
"[]",
"['xxx', 'xxxAAA', 'xxx']"
] | python |
HumanEval/30 | <commit_before>def get_positive(l: list):
return [e for e in l if e < 0]
<commit_msg>Fix bugs in get_positive.<commit_after>
def get_positive(l: list): | get_positive | return [e for e in l if e > 0]
|
METADATA = {}
def check(candidate):
assert candidate([-1, -2, 4, 5, 6]) == [4, 5, 6]
assert candidate([5, 3, -5, 2, 3, 3, 9, 0, 123, 1, -10]) == [5, 3, 2, 3, 3, 9, 123, 1]
assert candidate([-1, -2]) == []
assert candidate([]) == []
| [
"([-1, -2, 4, 5, 6],)",
"([5, 3, -5, 2, 3, 3, 9, 0, 123, 1, -10],)",
"([-1, -2],)",
"([],)"
] | [
"[4, 5, 6]",
"[5, 3, 2, 3, 3, 9, 123, 1]",
"[]",
"[]"
] | python |
HumanEval/31 | <commit_before>def is_prime(n):
if n < 1:
return False
for k in range(1, n - 1):
if n % k == 0:
return False
return True
<commit_msg>Fix bugs in is_prime.<commit_after>
def is_prime(n): | is_prime | if n < 2:
return False
for k in range(2, n - 1):
if n % k == 0:
return False
return True
|
METADATA = {}
def check(candidate):
assert candidate(6) == False
assert candidate(101) == True
assert candidate(11) == True
assert candidate(13441) == True
assert candidate(61) == True
assert candidate(4) == False
assert candidate(1) == False
assert candidate(5) == True
assert candidate(11) == True
assert candidate(17) == True
assert candidate(5 * 17) == False
assert candidate(11 * 7) == False
assert candidate(13441 * 19) == False
| [
"(6,)",
"(101,)",
"(11,)",
"(13441,)",
"(61,)",
"(4,)",
"(1,)",
"(5,)",
"(11,)",
"(17,)",
"(85,)",
"(77,)",
"(255379,)"
] | [
"False",
"True",
"True",
"True",
"True",
"False",
"False",
"True",
"True",
"True",
"False",
"False",
"False"
] | python |
HumanEval/32 | <commit_before>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):
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while begin - end > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
<commit_msg>Fix bugs in find_zero.<commit_after>
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): | find_zero | begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
METADATA = {}
def check(candidate):
import math
import random
rng = random.Random(42)
import copy
for _ in range(100):
ncoeff = 2 * rng.randint(1, 4)
coeffs = []
for _ in range(ncoeff):
coeff = rng.randint(-10, 10)
if coeff == 0:
coeff = 1
coeffs.append(coeff)
solution = candidate(copy.deepcopy(coeffs))
assert math.fabs(poly(coeffs, solution)) < 1e-4
| [
"([-10, -2],)",
"([-3, -6, -7, 7],)",
"([8, 3],)",
"([-10, -8],)",
"([-3, 6, 9, -10],)",
"([10, 7, 3, -3],)",
"([8, -2, -10, -5, 3, 1, -2, -6],)",
"([1, -7, -8, 2],)",
"([1, 1],)",
"([-9, 4, 7, -7, 2, -8],)",
"([10, 9, 1, 8, -4, -8],)",
"([-3, -1],)",
"([-3, -7],)",
"([-2, 4, 10, 1, -5, 1, 1, -4],)",
"([10, -8, 9, 10, -5, 7],)",
"([-5, 4, 2, -2],)",
"([1, -9, -3, -9],)",
"([2, -2, -8, -4, 8, 1],)",
"([10, 5, 2, 10],)",
"([-6, -2, -6, -3, 7, 7, -2, 8],)",
"([8, 2, 1, -3, -6, 6, 5, -8],)",
"([-7, -6],)",
"([3, 9, -8, 2],)",
"([9, 4, 6, -2, 7, -10, -7, 7],)",
"([10, 1, -7, -1, 3, -5],)",
"([-10, -2, 6, -5, 6, -7, 10, -1],)",
"([-6, 1, -5, 7],)",
"([9, 1],)",
"([-10, -7, 1, -1, -3, -9, -3, 8],)",
"([-8, 5],)",
"([7, -6],)",
"([5, 7, -5, -2],)",
"([-4, 7, -4, -1, 2, 10, 1, 4],)",
"([-7, -3, -3, -8, 1, -10, 8, 7],)",
"([8, -3, -10, -8],)",
"([-3, -8],)",
"([1, -8],)",
"([-2, 5, -4, 7],)",
"([8, 8, 5, -3],)",
"([3, -4, -7, -7, 3, 1, 3, 3],)",
"([-9, 10, 10, -7, -9, 2, 1, -7],)",
"([-4, -4, 7, 4],)",
"([3, -5, -2, 4],)",
"([-8, 4, 7, -7],)",
"([10, 7],)",
"([-8, -3],)",
"([3, 5, 5, -4],)",
"([-9, -5, 2, -10, 2, -2, 4, -1],)",
"([7, 5, -6, -4, -1, -4, -9, 8],)",
"([1, -9],)",
"([8, 5],)",
"([-9, 6, -8, -5],)",
"([9, -8],)",
"([2, -7, 8, -3],)",
"([9, -8],)",
"([8, 8, 6, 1, -2, -4, 1, -3],)",
"([2, -6, 10, -1, 4, 1],)",
"([-10, 4],)",
"([-8, 7],)",
"([6, -2, -6, 1],)",
"([-3, 1],)",
"([-5, 4, 7, -1, 9, 10],)",
"([7, -1],)",
"([-6, -2],)",
"([-7, 7],)",
"([-2, -1, 9, -4],)",
"([-4, 10, -2, 6, 5, -2],)",
"([-8, 10],)",
"([-2, -9, -10, 1, -6, 10, -2, -5],)",
"([7, 3, 7, -10, -7, -8, -6, 7],)",
"([1, 8],)",
"([3, -6, -9, -1],)",
"([-9, 1, -4, -3, -7, 1],)",
"([9, -6, -3, -5, -5, 3, -10, -5],)",
"([3, -3, -2, -5, -7, 2],)",
"([5, -3],)",
"([4, 1, -1, -3],)",
"([-10, -4, 2, 1],)",
"([-8, -2, 1, 10, 6, 2],)",
"([-10, -7, -2, -5, 8, -2],)",
"([-7, 9],)",
"([1, 1, 3, 9, 6, -7, 2, 8],)",
"([-2, -9, 3, -10],)",
"([1, 3, -8, 1],)",
"([-7, -1, 6, -1, 3, 1],)",
"([-1, 7, -6, -4, 3, 2, -5, 9],)",
"([2, 7, -10, -1, -1, -4],)",
"([8, 9, 10, 1, 4, 4, 4, -4],)",
"([-5, -8, -1, 6, 10, 9, 1, -8],)",
"([-1, -3, -4, -6],)",
"([-9, -3],)",
"([9, -8, 4, 3, 10, 8, -4, 2],)",
"([2, -3, -6, 10, -10, -7, 3, -3],)",
"([6, 4, -9, 7],)",
"([-7, 4, -6, 4],)",
"([4, 9, 6, 3, 7, 4],)",
"([5, 4, -2, -3],)",
"([6, 5, 10, -3, -2, 4],)",
"([-1, -3],)",
"([1, 1, 7, -8, -6, -6],)"
] | [
"-5.000000000058208",
"1.6679422343731858",
"-2.666666666686069",
"-1.2500000000582077",
"-0.6685768984025344",
"2.4815587521297857",
"0.7057115506613627",
"-0.8446386614232324",
"-1.0",
"-0.8164280389901251",
"-0.8227368473890238",
"-3.0000000000582077",
"-0.42857142857974395",
"-0.86899654957233",
"-1.0731038876692764",
"-1.4836825707461685",
"0.10615823022089899",
"0.38501966872718185",
"-0.8933422100380994",
"0.9600705468910746",
"1.1312649988103658",
"-1.1666666666860692",
"-0.2661688190419227",
"-1.2858021691790782",
"1.0328693957999349",
"-0.7015198637964204",
"1.1949840254965238",
"-9.000000000058208",
"1.5114667361485772",
"1.599999999976717",
"1.1666666666278616",
"-0.547214484482538",
"0.6221468804869801",
"-0.7463565783691593",
"0.6355658151442185",
"-0.37500000005820766",
"0.12499999994179234",
"0.4360383356688544",
"2.9021427524276078",
"0.39456867933040485",
"-1.0938426014618017",
"-2.0",
"0.6513878188561648",
"-0.9312933354522102",
"-1.428571428579744",
"-2.666666666686069",
"2.0420076226000674",
"-0.6912827867781743",
"-0.7303538502892479",
"0.11111111106583849",
"-1.6000000000349246",
"-2.4085229280171916",
"1.1249999999417923",
"0.6666666666278616",
"1.1249999999417923",
"1.267006399051752",
"-4.72142661397811",
"2.4999999999417923",
"1.142857142840512",
"0.9066398076247424",
"2.9999999999417923",
"0.5266727519920096",
"6.999999999941792",
"-3.0000000000582077",
"0.9999999999417923",
"-0.3903882032027468",
"0.38592179998522624",
"0.7999999999883585",
"-1.9016489709028974",
"0.877888614195399",
"-0.12500000005820766",
"0.3303229847806506",
"7.4735223380848765",
"0.6800906549324282",
"-1.0",
"1.6666666666278616",
"1.091414260212332",
"2.1179422714048997",
"0.8199922735802829",
"-0.7751165542285889",
"0.7777777777519077",
"-1.0796475561219268",
"-0.20000000001164153",
"-0.2112208516919054",
"0.9578598753432743",
"0.17007400892907754",
"0.746446434292011",
"2.018535319773946",
"-0.7318775289459154",
"-0.42038060672348365",
"-3.0000000000582077",
"-1.2079210819210857",
"0.4243725821143016",
"-0.5456791458418593",
"1.5720202162628993",
"-1.4282608788926154",
"1.313795538211707",
"-1.3557373622315936",
"-0.33333333337213844",
"0.696112065052148"
] | python |
HumanEval/33 | <commit_before>def sort_third(l: list):
l = list(l)
return l
<commit_msg>Fix bugs in sort_third.<commit_after>
def sort_third(l: list): | sort_third | l = list(l)
l[::3] = sorted(l[::3])
return l
|
METADATA = {}
def check(candidate):
assert tuple(candidate([1, 2, 3])) == tuple(sort_third([1, 2, 3]))
assert tuple(candidate([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])) == tuple(sort_third([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]))
assert tuple(candidate([5, 8, -12, 4, 23, 2, 3, 11, 12, -10])) == tuple(sort_third([5, 8, -12, 4, 23, 2, 3, 11, 12, -10]))
assert tuple(candidate([5, 6, 3, 4, 8, 9, 2])) == tuple([2, 6, 3, 4, 8, 9, 5])
assert tuple(candidate([5, 8, 3, 4, 6, 9, 2])) == tuple([2, 8, 3, 4, 6, 9, 5])
assert tuple(candidate([5, 6, 9, 4, 8, 3, 2])) == tuple([2, 6, 9, 4, 8, 3, 5])
assert tuple(candidate([5, 6, 3, 4, 8, 9, 2, 1])) == tuple([2, 6, 3, 4, 8, 9, 5, 1])
| [
"([1, 2, 3],)",
"([1, 2, 3],)",
"([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10],)",
"([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10],)",
"([5, 8, -12, 4, 23, 2, 3, 11, 12, -10],)",
"([5, 8, -12, 4, 23, 2, 3, 11, 12, -10],)",
"([5, 6, 3, 4, 8, 9, 2],)",
"([5, 8, 3, 4, 6, 9, 2],)",
"([5, 6, 9, 4, 8, 3, 2],)",
"([5, 6, 3, 4, 8, 9, 2, 1],)"
] | [
"[1, 2, 3]",
"[1, 2, 3]",
"[1, 3, -5, 2, -3, 3, 5, 0, 123, 9, -10]",
"[1, 3, -5, 2, -3, 3, 5, 0, 123, 9, -10]",
"[-10, 8, -12, 3, 23, 2, 4, 11, 12, 5]",
"[-10, 8, -12, 3, 23, 2, 4, 11, 12, 5]",
"[2, 6, 3, 4, 8, 9, 5]",
"[2, 8, 3, 4, 6, 9, 5]",
"[2, 6, 9, 4, 8, 3, 5]",
"[2, 6, 3, 4, 8, 9, 5, 1]"
] | python |
HumanEval/34 | <commit_before>def unique(l: list):
return sorted(l)
<commit_msg>Fix bugs in unique.<commit_after>
def unique(l: list): | unique | return sorted(list(set(l)))
|
METADATA = {}
def check(candidate):
assert candidate([5, 3, 5, 2, 3, 3, 9, 0, 123]) == [0, 2, 3, 5, 9, 123]
| [
"([5, 3, 5, 2, 3, 3, 9, 0, 123],)"
] | [
"[0, 2, 3, 5, 9, 123]"
] | python |
HumanEval/35 | <commit_before>def max_element(l: list):
m = l[0]
for e in l:
if e < m:
m = e
return m
<commit_msg>Fix bugs in max_element.<commit_after>
def max_element(l: list): | max_element | m = l[0]
for e in l:
if e > m:
m = e
return m
|
METADATA = {}
def check(candidate):
assert candidate([1, 2, 3]) == 3
assert candidate([5, 3, -5, 2, -3, 3, 9, 0, 124, 1, -10]) == 124
| [
"([1, 2, 3],)",
"([5, 3, -5, 2, -3, 3, 9, 0, 124, 1, -10],)"
] | [
"3",
"124"
] | python |
HumanEval/36 | <commit_before>def fizz_buzz(n: int):
ns = []
for i in range(n):
if i % 11 == 0 and i % 13 == 0:
ns.append(i)
s = ''.join(list(map(str, ns)))
ans = 0
for c in s:
ans += (c == '7')
return ans
<commit_msg>Fix bugs in fizz_buzz.<commit_after>
def fizz_buzz(n: int): | fizz_buzz | 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
|
METADATA = {}
def check(candidate):
assert candidate(50) == 0
assert candidate(78) == 2
assert candidate(79) == 3
assert candidate(100) == 3
assert candidate(200) == 6
assert candidate(4000) == 192
assert candidate(10000) == 639
assert candidate(100000) == 8026
| [
"(50,)",
"(78,)",
"(79,)",
"(100,)",
"(200,)",
"(4000,)",
"(10000,)",
"(100000,)"
] | [
"0",
"2",
"3",
"3",
"6",
"192",
"639",
"8026"
] | python |
HumanEval/37 | <commit_before>def sort_even(l: list):
evens = l[::2]
odds = l[1::2]
odds.sort()
ans = []
for e, o in zip(evens, odds):
ans.extend([e, o])
if len(evens) > len(odds):
ans.append(evens[-1])
return ans
<commit_msg>Fix bugs in sort_even.<commit_after>
def sort_even(l: list): | sort_even | evens = l[::2]
odds = l[1::2]
evens.sort()
ans = []
for e, o in zip(evens, odds):
ans.extend([e, o])
if len(evens) > len(odds):
ans.append(evens[-1])
return ans
|
METADATA = {}
def check(candidate):
assert tuple(candidate([1, 2, 3])) == tuple([1, 2, 3])
assert tuple(candidate([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])) == tuple([-10, 3, -5, 2, -3, 3, 5, 0, 9, 1, 123])
assert tuple(candidate([5, 8, -12, 4, 23, 2, 3, 11, 12, -10])) == tuple([-12, 8, 3, 4, 5, 2, 12, 11, 23, -10])
| [
"([1, 2, 3],)",
"([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10],)",
"([5, 8, -12, 4, 23, 2, 3, 11, 12, -10],)"
] | [
"[1, 2, 3]",
"[-10, 3, -5, 2, -3, 3, 5, 0, 9, 1, 123]",
"[-12, 8, 3, 4, 5, 2, 12, 11, 23, -10]"
] | python |
HumanEval/38 | <commit_before>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):
return encode_cyclic(s)
<commit_msg>Fix bugs in decode_cyclic.<commit_after>
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): | decode_cyclic | return encode_cyclic(encode_cyclic(s))
|
METADATA = {}
def check(candidate):
from random import randint, choice
import string
letters = string.ascii_lowercase
for _ in range(100):
str = ''.join(choice(letters) for i in range(randint(10, 20)))
encoded_str = encode_cyclic(str)
assert candidate(encoded_str) == str
| [
"('wjqtgcubpkhida',)",
"('jfotyhnvwj',)",
"('hstcvelyynwffbnvux',)",
"('sztcdcighld',)",
"('ddbpsldorntnvjcw',)",
"('iycjjohprbzz',)",
"('hvdfodmmvmid',)",
"('waxeucbweqkq',)",
"('uxvusubjryrdsnmuwnt',)",
"('vhrqbsxwaspdparvsbg',)",
"('qvwgrghikmmlzvpfw',)",
"('ywapjelitnhre',)",
"('dkrimngzrrkcxq',)",
"('mqmmbimgsnpguhkddzzy',)",
"('lrorcioqqqfifr',)",
"('djosvnldztem',)",
"('yfovyrbpqod',)",
"('hdazyomcwfkx',)",
"('afdhlbaqexrra',)",
"('pccissxanbpaprk',)",
"('zbljehtakvqorzdc',)",
"('qexxqoixfslynui',)",
"('grzkvexemb',)",
"('uwhtoteqkczrdubigv',)",
"('lqhawdreavbnwa',)",
"('qlzjzjeqsia',)",
"('syarzginil',)",
"('wtyqitloqpeixiqwtykl',)",
"('gqavxsdludxqfregrwrc',)",
"('kcvmorpkhvkxs',)",
"('vhkfmqhhiraovsh',)",
"('prppfspdgsoitzvffv',)",
"('ukltdbwskzahznw',)",
"('wjlemsdglsmqljemtwp',)",
"('yciivsakpsnaxjgkx',)",
"('hqfkaptgwu',)",
"('ofdmliisbrplx',)",
"('srikbsiyhryc',)",
"('wwjztdicthzjzygmvm',)",
"('horewjchsfw',)",
"('bgvlpvndlgmmccfnebz',)",
"('nlqdzbkojvoeopkujp',)",
"('ubhmdgwgntskcsaedaq',)",
"('eoigeyjuxbias',)",
"('zmuzzrribpblwhz',)",
"('lcgiddrdzn',)",
"('rayyrxvptumzggrnnj',)",
"('ffvcikkvsmqsvydkmw',)",
"('khutwtkesgzzju',)",
"('hhgygiyasoablnox',)",
"('fiagrtxuezqsglvyy',)",
"('vctfmvfebvc',)",
"('uebqppwxbnudzdymmmn',)",
"('vhjriombdjglxtcflvyx',)",
"('leiohuyhakc',)",
"('mrfbhaegigkkekio',)",
"('mrajnhdsrmsmtnmfa',)",
"('ladxpkqqytq',)",
"('iwuzarcbnyqz',)",
"('mclytnuhyzz',)",
"('efmboiooezuvrvlcpeoy',)",
"('zhmzjrskrcog',)",
"('lgkparoges',)",
"('rtoknqeqhf',)",
"('pdoyofwlikgrcfel',)",
"('fcpfgfktopdettyhjp',)",
"('belvltrndxnas',)",
"('chsstceknzz',)",
"('odsouafensrjlnk',)",
"('vrlmqhpafma',)",
"('bjzjkpjeporp',)",
"('bynirhntqpoiglrto',)",
"('kcxuiuxuqrnyudkj',)",
"('ndxiezkqrgbiufsrg',)",
"('nnmtfvddaxlxnai',)",
"('pnsdkfusydfqncn',)",
"('eczhpzxgdptpdqdy',)",
"('gygdkhlqxipmqvpf',)",
"('kknaualrbebachuhxwv',)",
"('ecsqowiyzexyx',)",
"('obefnfovxnmbpw',)",
"('vjiopffffrdschfp',)",
"('upkyxidrfmcvqdzj',)",
"('jxateumaaigphcjxf',)",
"('pwupcalkxpomwqk',)",
"('flmphgqmpqwu',)",
"('cajslpvfxegdtd',)",
"('rdwodebuerypythnjui',)",
"('gpbumxafcrxypixizh',)",
"('necrhzoerqviojimx',)",
"('pfbgwzigoyoncyhtxl',)",
"('nosoeuadafofxtwxyzq',)",
"('epxywbsseggbyyidhco',)",
"('fdpvnrkvhhbnrlws',)",
"('yfmytnzibmamkwka',)",
"('uhtqzbxvgjoij',)",
"('hhnhpwvzfvuwbp',)",
"('tvmtjxchfuvyg',)",
"('pmbnbhcmeizsycb',)",
"('olynafvvebseujnauje',)"
] | [
"qwjctgpubikhda",
"ojfhtywnvj",
"thsecvylyfnwnfbxvu",
"tszccdhigld",
"bddlpsrdonntcvjw",
"ciyojjrhpzbz",
"dhvdfovmmdmi",
"xwaceuebwqqk",
"vuxuusrbjdyrmsnnuwt",
"rvhsqbaxwdsprpabvsg",
"wqvggrkhilmmpzvfw",
"aywepjtlirnhe",
"rdknimrgzcrkxq",
"mmqimbsmggnpkuhzddzy",
"olrircqoqiqffr",
"odjnsvzldmte",
"oyfrvyqbpod",
"ahdozywmcxfk",
"dafbhleaqrxra",
"cpcsisnxaabpkpr",
"lzbhjektaovqdrzc",
"xqeoxqfixyslinu",
"zgrekvmxeb",
"huwttokeqrczbduvig",
"hlqdawarenvbwa",
"zqljjzseqia",
"asygrziinl",
"ywttqiqloipeqxiywtkl",
"agqsvxudlqdxefrwgrrc",
"vkcrmohpkxvks",
"kvhqfmihhorahvs",
"pprspfgpdisovtzvff",
"lukbtdkwshzawzn",
"lwjsemldgqsmeljwmtp",
"iycsivpakasngxjkx",
"fhqpkawtgu",
"dofimlbislrpx",
"isrskbhiycry",
"jwwdztticjhzgzymmv",
"rhojewschfw",
"vbgvlplndmgmfccbnez",
"qnlbdzjkoevokoppuj",
"hubgmdnwgktsacsaedq",
"ieoygexjuabis",
"uzmrzzbrilpbzwh",
"glcdidzrdn",
"yraxyrtvpzumrggjnn",
"vffkciskvsmqdvywkm",
"ukhttwskezgzju",
"ghhiygsyaboaolnx",
"afitgrexuszqvglyy",
"tvcvfmbfevc",
"buepqpbwxdnuyzdmmmn",
"jvhoridmbljgcxtvflyx",
"ileuohayhkc",
"fmrabhiegkgkieko",
"amrhjnrdsmmsmtnfa",
"dlakxpyqqtq",
"uiwrzancbzyq",
"lmcnytyuhzz",
"mefiboeoovzulrvecpoy",
"mzhrzjrskgco",
"klgrpaeogs",
"ortqknheqf",
"opdfyoiwlrkgecfl",
"pfcffgoktepdyttphj",
"lbetvldrnaxns",
"schcstnekzz",
"sodaounfejsrkln",
"lvrhmqfpama",
"zbjpjkpjepor",
"nbyhirqntiporglto",
"xkcuuiqxuyrnkudj",
"xndzierkqigbsufrg",
"mnnvtfaddxxlina",
"spnfdkyusqdfnnc",
"zeczhpdxgpptddqy",
"ggyhdkxlqmippqvf",
"nkkaaublraebuchwhxv",
"secwqoziyyexx",
"eobffnxovbnmpw",
"ivjfopfffsrdfchp",
"kupiyxfdrvmczqdj",
"ajxuteamapigjhcxf",
"upwapcxlkmpokwq",
"mflgphpqmuqw",
"jcapslxvfdegtd",
"wrdeodebupryhytunji",
"bgpxumcafyrxxpihiz",
"cnezrhroeiqviojmx",
"bpfzgwoignyohcyltx",
"snouoeaadffowxtzxyq",
"xepbywessbggiyycdho",
"pfdrvnhkvnhbwrls",
"myfnytbzimmakkwa",
"tuhbqzgxvijoj",
"nhhwhpfvzwvubp",
"mtvxtjfchyuvg",
"bpmhnbecmsizbyc",
"yolfnaevvebsnujjaue"
] | python |
HumanEval/39 | <commit_before>def prime_fib(n: int):
import math
def is_prime(p):
if p < 2:
return False
for k in range(2, min(int(math.sqrt(p)), p)):
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]
<commit_msg>Fix bugs in prime_fib.<commit_after>
def prime_fib(n: int): | prime_fib | 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]
|
METADATA = {}
def check(candidate):
assert candidate(1) == 2
assert candidate(2) == 3
assert candidate(3) == 5
assert candidate(4) == 13
assert candidate(5) == 89
assert candidate(6) == 233
assert candidate(7) == 1597
assert candidate(8) == 28657
assert candidate(9) == 514229
assert candidate(10) == 433494437
| [
"(1,)",
"(2,)",
"(3,)",
"(4,)",
"(5,)",
"(6,)",
"(7,)",
"(8,)",
"(9,)",
"(10,)"
] | [
"2",
"3",
"5",
"13",
"89",
"233",
"1597",
"28657",
"514229",
"433494437"
] | python |
HumanEval/40 | <commit_before>def triples_sum_to_zero(l: list):
for i in range(1, 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
<commit_msg>Fix bugs in triples_sum_to_zero.<commit_after>
def triples_sum_to_zero(l: list): | triples_sum_to_zero | for i in range(len(l)):
for j in range(i + 1, len(l)):
for k in range(j + 1, len(l)):
if l[i] + l[j] + l[k] == 0:
return True
return False
|
METADATA = {}
def check(candidate):
assert candidate([1, 3, 5, 0]) == False
assert candidate([1, 3, 5, -1]) == False
assert candidate([1, 3, -2, 1]) == True
assert candidate([1, 2, 3, 7]) == False
assert candidate([1, 2, 5, 7]) == False
assert candidate([2, 4, -5, 3, 9, 7]) == True
assert candidate([1]) == False
assert candidate([1, 3, 5, -100]) == False
assert candidate([100, 3, 5, -100]) == False
| [
"([1, 3, 5, 0],)",
"([1, 3, 5, -1],)",
"([1, 3, -2, 1],)",
"([1, 2, 3, 7],)",
"([1, 2, 5, 7],)",
"([2, 4, -5, 3, 9, 7],)",
"([1],)",
"([1, 3, 5, -100],)",
"([100, 3, 5, -100],)"
] | [
"False",
"False",
"True",
"False",
"False",
"True",
"False",
"False",
"False"
] | python |
HumanEval/41 | <commit_before>def car_race_collision(n: int):
return n**3
<commit_msg>Fix bugs in car_race_collision.<commit_after>
def car_race_collision(n: int): | car_race_collision | return n**2
|
METADATA = {}
def check(candidate):
assert candidate(2) == 4
assert candidate(3) == 9
assert candidate(4) == 16
assert candidate(8) == 64
assert candidate(10) == 100
| [
"(2,)",
"(3,)",
"(4,)",
"(8,)",
"(10,)"
] | [
"4",
"9",
"16",
"64",
"100"
] | python |
HumanEval/42 | <commit_before>def incr_list(l: list):
return [(e + 2) for e in l]
<commit_msg>Fix bugs in incr_list.<commit_after>
def incr_list(l: list): | incr_list | return [(e + 1) for e in l]
|
METADATA = {}
def check(candidate):
assert candidate([]) == []
assert candidate([3, 2, 1]) == [4, 3, 2]
assert candidate([5, 2, 5, 2, 3, 3, 9, 0, 123]) == [6, 3, 6, 3, 4, 4, 10, 1, 124]
| [
"([],)",
"([3, 2, 1],)",
"([5, 2, 5, 2, 3, 3, 9, 0, 123],)"
] | [
"[]",
"[4, 3, 2]",
"[6, 3, 6, 3, 4, 4, 10, 1, 124]"
] | python |
HumanEval/43 | <commit_before>def pairs_sum_to_zero(l):
for i, l1 in enumerate(l):
for j in range(i, len(l)):
if l1 + l[j] == 0:
return True
return False
<commit_msg>Fix bugs in pairs_sum_to_zero.<commit_after>
def pairs_sum_to_zero(l): | pairs_sum_to_zero | for i, l1 in enumerate(l):
for j in range(i + 1, len(l)):
if l1 + l[j] == 0:
return True
return False
|
METADATA = {}
def check(candidate):
assert candidate([1, 3, 5, 0]) == False
assert candidate([1, 3, -2, 1]) == False
assert candidate([1, 2, 3, 7]) == False
assert candidate([2, 4, -5, 3, 5, 7]) == True
assert candidate([1]) == False
assert candidate([-3, 9, -1, 3, 2, 30]) == True
assert candidate([-3, 9, -1, 3, 2, 31]) == True
assert candidate([-3, 9, -1, 4, 2, 30]) == False
assert candidate([-3, 9, -1, 4, 2, 31]) == False
| [
"([1, 3, 5, 0],)",
"([1, 3, -2, 1],)",
"([1, 2, 3, 7],)",
"([2, 4, -5, 3, 5, 7],)",
"([1],)",
"([-3, 9, -1, 3, 2, 30],)",
"([-3, 9, -1, 3, 2, 31],)",
"([-3, 9, -1, 4, 2, 30],)",
"([-3, 9, -1, 4, 2, 31],)"
] | [
"False",
"False",
"False",
"True",
"False",
"True",
"True",
"False",
"False"
] | python |
HumanEval/44 | <commit_before>def change_base(x: int, base: int):
ret = ""
while x > 0:
ret = str(x % base) + ret
x -= base
return ret
<commit_msg>Fix bugs in change_base.<commit_after>
def change_base(x: int, base: int): | change_base | ret = ""
while x > 0:
ret = str(x % base) + ret
x //= base
return ret
|
METADATA = {}
def check(candidate):
assert candidate(8, 3) == "22"
assert candidate(9, 3) == "100"
assert candidate(234, 2) == "11101010"
assert candidate(16, 2) == "10000"
assert candidate(8, 2) == "1000"
assert candidate(7, 2) == "111"
for x in range(2, 8):
assert candidate(x, x + 1) == str(x)
| [
"(8, 3)",
"(9, 3)",
"(234, 2)",
"(16, 2)",
"(8, 2)",
"(7, 2)",
"(2, 3)",
"(3, 4)",
"(4, 5)",
"(5, 6)",
"(6, 7)",
"(7, 8)"
] | [
"22",
"100",
"11101010",
"10000",
"1000",
"111",
"2",
"3",
"4",
"5",
"6",
"7"
] | python |
HumanEval/45 | <commit_before>def triangle_area(a, h):
return a * h / 0.5
<commit_msg>Fix bugs in triangle_area.<commit_after>
def triangle_area(a, h): | triangle_area | return a * h / 2.0
|
METADATA = {}
def check(candidate):
assert candidate(5, 3) == 7.5
assert candidate(2, 2) == 2.0
assert candidate(10, 8) == 40.0
| [
"(5, 3)",
"(2, 2)",
"(10, 8)"
] | [
"7.5",
"2.0",
"40.0"
] | python |
HumanEval/46 | <commit_before>def fib4(n: int):
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[-2]
<commit_msg>Fix bugs in fib4.<commit_after>
def fib4(n: int): | fib4 | 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]
|
METADATA = {}
def check(candidate):
assert candidate(5) == 4
assert candidate(8) == 28
assert candidate(10) == 104
assert candidate(12) == 386
| [
"(5,)",
"(8,)",
"(10,)",
"(12,)"
] | [
"4",
"28",
"104",
"386"
] | python |
HumanEval/47 | <commit_before>def median(l: list):
l = sorted(l)
if len(l) % 2 == 1:
return l[len(l) // 2]
else:
return (l[len(l) - 1 // 2] + l[len(l) // 2]) / 2.0
<commit_msg>Fix bugs in median.<commit_after>
def median(l: list): | median | 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
|
METADATA = {}
def check(candidate):
assert candidate([3, 1, 2, 4, 5]) == 3
assert candidate([-10, 4, 6, 1000, 10, 20]) == 8.0
assert candidate([5]) == 5
assert candidate([6, 5]) == 5.5
assert candidate([8, 1, 3, 9, 9, 2, 7]) == 7
| [
"([3, 1, 2, 4, 5],)",
"([-10, 4, 6, 1000, 10, 20],)",
"([5],)",
"([6, 5],)",
"([8, 1, 3, 9, 9, 2, 7],)"
] | [
"3",
"8.0",
"5",
"5.5",
"7"
] | python |
HumanEval/48 | <commit_before>def is_palindrome(text: str):
for i in range(len(text)):
if text[i] != text[len(text) - i]:
return False
return True
<commit_msg>Fix bugs in is_palindrome.<commit_after>
def is_palindrome(text: str): | is_palindrome | for i in range(len(text)):
if text[i] != text[len(text) - 1 - i]:
return False
return True
|
METADATA = {}
def check(candidate):
assert candidate('') == True
assert candidate('aba') == True
assert candidate('aaaaa') == True
assert candidate('zbcd') == False
assert candidate('xywyx') == True
assert candidate('xywyz') == False
assert candidate('xywzx') == False
| [
"('',)",
"('aba',)",
"('aaaaa',)",
"('zbcd',)",
"('xywyx',)",
"('xywyz',)",
"('xywzx',)"
] | [
"True",
"True",
"True",
"False",
"True",
"False",
"False"
] | python |
HumanEval/49 | <commit_before>def modp(n: int, p: int):
ret = 0
for i in range(n):
ret = (2 * ret) % p
return ret
<commit_msg>Fix bugs in modp.<commit_after>
def modp(n: int, p: int): | modp | ret = 1
for i in range(n):
ret = (2 * ret) % p
return ret
|
METADATA = {}
def check(candidate):
assert candidate(3, 5) == 3
assert candidate(1101, 101) == 2
assert candidate(0, 101) == 1
assert candidate(3, 11) == 8
assert candidate(100, 101) == 1
assert candidate(30, 5) == 4
assert candidate(31, 5) == 3
| [
"(3, 5)",
"(1101, 101)",
"(0, 101)",
"(3, 11)",
"(100, 101)",
"(30, 5)",
"(31, 5)"
] | [
"3",
"2",
"1",
"8",
"1",
"4",
"3"
] | python |
HumanEval/50 | <commit_before>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):
return "".join([chr(((ord(ch) - 5 - ord("a")) % 26) + ord(ch)) for ch in s])
<commit_msg>Fix bugs in decode_shift.<commit_after>
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): | decode_shift | return "".join([chr(((ord(ch) - 5 - ord("a")) % 26) + ord("a")) for ch in s])
|
METADATA = {}
def check(candidate):
from random import randint, choice
import copy
import string
letters = string.ascii_lowercase
for _ in range(100):
str = ''.join(choice(letters) for i in range(randint(10, 20)))
encoded_str = encode_shift(str)
assert candidate(copy.deepcopy(encoded_str)) == str
| [
"('kxhciizsyxywezlczqhn',)",
"('tdyvbnygciwsboyro',)",
"('grlnjlrvrzraue',)",
"('sdzcycvjdweglwjud',)",
"('skvxqslynknnrlefm',)",
"('xpmnajwdzymwojkw',)",
"('wbkxupkaikh',)",
"('vyoamztnlnstv',)",
"('psompsjugchqqsh',)",
"('wyiafqmohvafvin',)",
"('wppgqeimekj',)",
"('bnayhkueemukn',)",
"('fltmepzvhmszbpyxtuq',)",
"('lgzcalxkavwipconcp',)",
"('brhcjvoydjxsgus',)",
"('ypkxfekqowjzgsfxfogq',)",
"('wlzgrnkoxuhh',)",
"('ismtkmczhivgj',)",
"('zimaiuhvywigjzvyhs',)",
"('leietgjcbon',)",
"('mpdgwbhssswxzib',)",
"('vexfngxtghdgoy',)",
"('jftvvakpsqoyrhydhp',)",
"('scgrlyijobsw',)",
"('ysinpbkbfzp',)",
"('kzpywdnyhr',)",
"('mblsbkldnb',)",
"('szhldncviurzl',)",
"('mzupmdtzlccxvmv',)",
"('kugfrxjwaqpedji',)",
"('gpvbzjmbyoewbmuqlh',)",
"('kxnmrowczleqgpyswa',)",
"('frqfbudaiohsrfhn',)",
"('nzfkotzaaiye',)",
"('lamrzgwwjthlhmxfej',)",
"('cdidqzkelg',)",
"('kvxfwfeikiljna',)",
"('ugewqbyefkd',)",
"('bqxdsaoeshyesv',)",
"('whqqzsldgxgk',)",
"('ebyidthghnwjrjmlgvpt',)",
"('ktadntfgarzebjmn',)",
"('hriftgahum',)",
"('xklgdzfhyclsraf',)",
"('sdbwlvvbqujkidwrjef',)",
"('eumduzwtrvmpolfihwmu',)",
"('vamknnhevcaeei',)",
"('plfwtyvvlwsuzgg',)",
"('dkirsiphbyuxfwqzuskn',)",
"('sjymevfwzhurbtzf',)",
"('onsrswmhyu',)",
"('msbvrevhxym',)",
"('tdzysbccylfjdxxdbij',)",
"('gwgdiwjasgvt',)",
"('gtuarakdiyknm',)",
"('xgdxffhvfxpkqn',)",
"('oyysrxnwlwnohulbzonc',)",
"('zyrgzrjulitjlqlqlds',)",
"('mdrlnmnwtunrdxacjdeh',)",
"('rxydgeoceeomruuphqx',)",
"('iydxhegpvp',)",
"('tqekmtuyjxoiab',)",
"('ymsuisnyghkcgenjizb',)",
"('sucenffajrmktwuhrp',)",
"('zofmseeoxiombapo',)",
"('nomkdzsqdrvdaqrgbq',)",
"('veagnaczcxjtaolzujhn',)",
"('efdtimkmsgwqva',)",
"('jivgqglggsmntpng',)",
"('kjqiuukinnvsn',)",
"('dowqlnuozx',)",
"('wjxxtfzdlkjxhf',)",
"('qlnrkebzdkpgtbzl',)",
"('fricmeygllqj',)",
"('ivljtlvradmkmiqhyfb',)",
"('inuhpgilkpjrcw',)",
"('nquzhtcdpnqsfouv',)",
"('sncknaqodzjikddp',)",
"('zwsyxsbuod',)",
"('jfzyqqapnstjgrhwzh',)",
"('ryxkdivksfwjnx',)",
"('wosxwpcacbdyzb',)",
"('vxipimwfbpjzgl',)",
"('mqgxfewhkuccxc',)",
"('dxnnmhkmnkyyexqqd',)",
"('cckltbcbrxuubkfqgyg',)",
"('mjchywincevymmlbgta',)",
"('hdejxarvmtwjuzry',)",
"('ypdevmxdrmtga',)",
"('zsxberzrvbslm',)",
"('bobzemfwoadafd',)",
"('quuxqesafnprozpxd',)",
"('gojanuqqtycyrgpwfhoh',)",
"('npfrfhokrdeesgkxy',)",
"('jbvhnrgzkzwblkvjbr',)",
"('ncawzgcepokilwmuj',)",
"('qofyfsnzqtvrgsbdpe',)",
"('vqjlnkxorbb',)",
"('zdmfhlkneahlhuruirqq',)",
"('fzbbqgjhjjowo',)"
] | [
"fscxdduntstrzugxulci",
"oytqwitbxdrnwjtmj",
"bmgiegmqmumvpz",
"nyuxtxqeyrzbgrepy",
"nfqslngtifiimgzah",
"skhiveryuthrjefr",
"rwfspkfvdfc",
"qtjvhuoiginoq",
"knjhknepbxcllnc",
"rtdvalhjcqvaqdi",
"rkkblzdhzfe",
"wivtcfpzzhpfi",
"agohzkuqchnuwktsopl",
"gbuxvgsfvqrdkxjixk",
"wmcxeqjtyesnbpn",
"tkfsazfljreubnasajbl",
"rgubmifjspcc",
"dnhofhxucdqbe",
"udhvdpcqtrdbeuqtcn",
"gzdzobexwji",
"hkybrwcnnnrsudw",
"qzsaibsobcybjt",
"eaoqqvfknljtmctyck",
"nxbmgtdejwnr",
"tndikwfwauk",
"fuktryitcm",
"hwgnwfgyiw",
"nucgyixqdpmug",
"hupkhyougxxsqhq",
"fpbamservlkzyed",
"bkqwuehwtjzrwhplgc",
"fsihmjrxugzlbktnrv",
"amlawpyvdjcnmaci",
"iuafjouvvdtz",
"gvhmubrreocgchsaze",
"xydylufzgb",
"fqsarazdfdgeiv",
"pbzrlwtzafy",
"wlsynvjznctznq",
"rcllungybsbf",
"zwtdyocbciremehgbqko",
"fovyioabvmuzwehi",
"cmdaobvcph",
"sfgbyuactxgnmva",
"nywrgqqwlpefdyrmeza",
"zphypuromqhkjgadcrhp",
"qvhfiiczqxvzzd",
"kgarotqqgrnpubb",
"yfdmndkcwtpsarlupnfi",
"nethzqarucpmwoua",
"jinmnrhctp",
"hnwqmzqcsth",
"oyutnwxxtgaeyssywde",
"brbydrevnbqo",
"bopvmvfydtfih",
"sbysaacqaskfli",
"jttnmsirgrijcpgwujix",
"utmbumepgdoeglglgyn",
"hymgihiropimysvxeyzc",
"mstybzjxzzjhmppkcls",
"dtysczbkqk",
"olzfhoptesjdvw",
"thnpdnitbcfxbzieduw",
"npxziaavemhforpcmk",
"ujahnzzjsdjhwvkj",
"ijhfyunlymqyvlmbwl",
"qzvbivxuxseovjgupeci",
"zayodhfhnbrlqv",
"edqblbgbbnhiokib",
"feldppfdiiqni",
"yjrlgipjus",
"ressoauygfesca",
"lgimfzwuyfkbowug",
"amdxhztbggle",
"dqgeogqmvyhfhdlctaw",
"dipckbdgfkemxr",
"ilpucoxykilnajpq",
"nixfivljyuedfyyk",
"urntsnwpjy",
"eautllvkinoebmcruc",
"mtsfydqfnareis",
"rjnsrkxvxwytuw",
"qsdkdhrawkeubg",
"hlbsazrcfpxxsx",
"ysiihcfhifttzslly",
"xxfgowxwmsppwfalbtb",
"hexctrdixzqthhgwbov",
"cyzesvmqhorepumt",
"tkyzqhsymhobv",
"unswzmumqwngh",
"wjwuzharjvyvay",
"lppslznvaikmjuksy",
"bjevipllotxtmbkracjc",
"ikamacjfmyzznbfst",
"ewqcimbufurwgfqewm",
"ixvrubxzkjfdgrhpe",
"ljataniuloqmbnwykz",
"qlegifsjmww",
"uyhacgfizvcgcpmpdmll",
"auwwlbeceejrj"
] | python |
HumanEval/51 | <commit_before>def remove_vowels(text):
return "".join([s for s in text if s.lower() not in ["a", "e", "i", "o", "u", "w", "y"]])
<commit_msg>Fix bugs in remove_vowels.<commit_after>
def remove_vowels(text): | remove_vowels | return "".join([s for s in text if s.lower() not in ["a", "e", "i", "o", "u"]])
|
METADATA = {}
def check(candidate):
assert candidate('') == ''
assert candidate("abcdef\nghijklm") == 'bcdf\nghjklm'
assert candidate('fedcba') == 'fdcb'
assert candidate('eeeee') == ''
assert candidate('acBAA') == 'cB'
assert candidate('EcBOO') == 'cB'
assert candidate('ybcd') == 'ybcd'
| [
"('',)",
"('abcdef\\nghijklm',)",
"('fedcba',)",
"('eeeee',)",
"('acBAA',)",
"('EcBOO',)",
"('ybcd',)"
] | [
"",
"bcdf\nghjklm",
"fdcb",
"",
"cB",
"cB",
"ybcd"
] | python |
HumanEval/52 | <commit_before>def below_threshold(l: list, t: int):
for e in l:
if e >= t:
return True
return False
<commit_msg>Fix bugs in below_threshold.<commit_after>
def below_threshold(l: list, t: int): | below_threshold | for e in l:
if e >= t:
return False
return True
|
METADATA = {}
def check(candidate):
assert candidate([1, 2, 4, 10], 100)
assert not candidate([1, 20, 4, 10], 5)
assert candidate([1, 20, 4, 10], 21)
assert candidate([1, 20, 4, 10], 22)
assert candidate([1, 8, 4, 10], 11)
assert not candidate([1, 8, 4, 10], 10)
| [
"([1, 2, 4, 10], 100)",
"([1, 20, 4, 10], 5)",
"([1, 20, 4, 10], 21)",
"([1, 20, 4, 10], 22)",
"([1, 8, 4, 10], 11)",
"([1, 8, 4, 10], 10)"
] | [
"True",
"False",
"True",
"True",
"True",
"False"
] | python |
HumanEval/53 | <commit_before>def add(x: int, y: int):
return x + y + y + x
<commit_msg>Fix bugs in add.<commit_after>
def add(x: int, y: int): | add | return x + y
|
METADATA = {}
def check(candidate):
import random
assert candidate(0, 1) == 1
assert candidate(1, 0) == 1
assert candidate(2, 3) == 5
assert candidate(5, 7) == 12
assert candidate(7, 5) == 12
for i in range(100):
x, y = random.randint(0, 1000), random.randint(0, 1000)
assert candidate(x, y) == x + y
| [
"(0, 1)",
"(1, 0)",
"(2, 3)",
"(5, 7)",
"(7, 5)",
"(728, 987)",
"(252, 746)",
"(6, 688)",
"(885, 821)",
"(872, 342)",
"(236, 745)",
"(393, 345)",
"(775, 670)",
"(233, 62)",
"(198, 874)",
"(976, 406)",
"(147, 247)",
"(498, 243)",
"(680, 8)",
"(823, 509)",
"(775, 781)",
"(402, 240)",
"(626, 157)",
"(948, 989)",
"(768, 76)",
"(348, 821)",
"(608, 22)",
"(702, 149)",
"(151, 396)",
"(540, 304)",
"(689, 405)",
"(599, 758)",
"(722, 192)",
"(295, 148)",
"(593, 695)",
"(651, 78)",
"(394, 608)",
"(743, 431)",
"(15, 977)",
"(797, 152)",
"(182, 631)",
"(975, 578)",
"(207, 526)",
"(245, 674)",
"(228, 155)",
"(448, 138)",
"(81, 429)",
"(576, 307)",
"(1, 598)",
"(459, 781)",
"(261, 438)",
"(553, 451)",
"(168, 307)",
"(531, 417)",
"(28, 151)",
"(625, 995)",
"(860, 627)",
"(211, 583)",
"(190, 37)",
"(274, 383)",
"(442, 359)",
"(263, 570)",
"(288, 990)",
"(468, 134)",
"(157, 85)",
"(552, 744)",
"(939, 156)",
"(842, 368)",
"(667, 809)",
"(948, 189)",
"(337, 62)",
"(405, 336)",
"(963, 722)",
"(568, 622)",
"(15, 396)",
"(586, 922)",
"(788, 648)",
"(915, 857)",
"(541, 822)",
"(541, 613)",
"(254, 972)",
"(849, 842)",
"(688, 375)",
"(632, 409)",
"(136, 314)",
"(190, 405)",
"(745, 555)",
"(121, 656)",
"(116, 132)",
"(596, 708)",
"(831, 720)",
"(89, 251)",
"(518, 535)",
"(229, 22)",
"(56, 547)",
"(632, 790)",
"(969, 913)",
"(291, 516)",
"(669, 292)",
"(59, 315)",
"(205, 29)",
"(365, 722)",
"(523, 662)",
"(655, 455)",
"(615, 378)"
] | [
"1",
"1",
"5",
"12",
"12",
"1715",
"998",
"694",
"1706",
"1214",
"981",
"738",
"1445",
"295",
"1072",
"1382",
"394",
"741",
"688",
"1332",
"1556",
"642",
"783",
"1937",
"844",
"1169",
"630",
"851",
"547",
"844",
"1094",
"1357",
"914",
"443",
"1288",
"729",
"1002",
"1174",
"992",
"949",
"813",
"1553",
"733",
"919",
"383",
"586",
"510",
"883",
"599",
"1240",
"699",
"1004",
"475",
"948",
"179",
"1620",
"1487",
"794",
"227",
"657",
"801",
"833",
"1278",
"602",
"242",
"1296",
"1095",
"1210",
"1476",
"1137",
"399",
"741",
"1685",
"1190",
"411",
"1508",
"1436",
"1772",
"1363",
"1154",
"1226",
"1691",
"1063",
"1041",
"450",
"595",
"1300",
"777",
"248",
"1304",
"1551",
"340",
"1053",
"251",
"603",
"1422",
"1882",
"807",
"961",
"374",
"234",
"1087",
"1185",
"1110",
"993"
] | python |
HumanEval/54 | <commit_before>def same_chars(s0: str, s1: str):
return s0 == s1
<commit_msg>Fix bugs in same_chars.<commit_after>
def same_chars(s0: str, s1: str): | same_chars | return set(s0) == set(s1)
|
METADATA = {}
def check(candidate):
assert candidate('eabcdzzzz', 'dddzzzzzzzddeddabc') == True
assert candidate('abcd', 'dddddddabc') == True
assert candidate('dddddddabc', 'abcd') == True
assert candidate('eabcd', 'dddddddabc') == False
assert candidate('abcd', 'dddddddabcf') == False
assert candidate('eabcdzzzz', 'dddzzzzzzzddddabc') == False
assert candidate('aabb', 'aaccc') == False
| [
"('eabcdzzzz', 'dddzzzzzzzddeddabc')",
"('abcd', 'dddddddabc')",
"('dddddddabc', 'abcd')",
"('eabcd', 'dddddddabc')",
"('abcd', 'dddddddabcf')",
"('eabcdzzzz', 'dddzzzzzzzddddabc')",
"('aabb', 'aaccc')"
] | [
"True",
"True",
"True",
"False",
"False",
"False",
"False"
] | python |
HumanEval/55 | <commit_before>def fib(n: int):
if n == 0:
return 0
if n == 1:
return 1
if n == 2:
return 2
return fib(n - 1) + fib(n - 2)
<commit_msg>Fix bugs in fib.<commit_after>
def fib(n: int): | fib | if n == 0:
return 0
if n == 1:
return 1
return fib(n - 1) + fib(n - 2)
|
METADATA = {}
def check(candidate):
assert candidate(10) == 55
assert candidate(1) == 1
assert candidate(8) == 21
assert candidate(11) == 89
assert candidate(12) == 144
| [
"(10,)",
"(1,)",
"(8,)",
"(11,)",
"(12,)"
] | [
"55",
"1",
"21",
"89",
"144"
] | python |
HumanEval/56 | <commit_before>def correct_bracketing(brackets: str):
depth = 0
for b in brackets:
if b == ">":
depth += 1
else:
depth -= 1
if depth < 0:
return False
return depth == 0
<commit_msg>Fix bugs in correct_bracketing.<commit_after>
def correct_bracketing(brackets: str): | correct_bracketing | depth = 0
for b in brackets:
if b == "<":
depth += 1
else:
depth -= 1
if depth < 0:
return False
return depth == 0
|
METADATA = {}
def check(candidate):
assert candidate("<>")
assert candidate("<<><>>")
assert candidate("<><><<><>><>")
assert candidate("<><><<<><><>><>><<><><<>>>")
assert not candidate("<<<><>>>>")
assert not candidate("><<>")
assert not candidate("<")
assert not candidate("<<<<")
assert not candidate(">")
assert not candidate("<<>")
assert not candidate("<><><<><>><>><<>")
assert not candidate("<><><<><>><>>><>")
| [
"('<>',)",
"('<<><>>',)",
"('<><><<><>><>',)",
"('<><><<<><><>><>><<><><<>>>',)",
"('<<<><>>>>',)",
"('><<>',)",
"('<',)",
"('<<<<',)",
"('>',)",
"('<<>',)",
"('<><><<><>><>><<>',)",
"('<><><<><>><>>><>',)"
] | [
"True",
"True",
"True",
"True",
"False",
"False",
"False",
"False",
"False",
"False",
"False",
"False"
] | python |
HumanEval/57 | <commit_before>def monotonic(l: list):
if l == sorted(l) or l == sorted(l, reverse=True):
return False
return True
<commit_msg>Fix bugs in monotonic.<commit_after>
def monotonic(l: list): | monotonic | if l == sorted(l) or l == sorted(l, reverse=True):
return True
return False
|
METADATA = {}
def check(candidate):
assert candidate([1, 2, 4, 10]) == True
assert candidate([1, 2, 4, 20]) == True
assert candidate([1, 20, 4, 10]) == False
assert candidate([4, 1, 0, -10]) == True
assert candidate([4, 1, 1, 0]) == True
assert candidate([1, 2, 3, 2, 5, 60]) == False
assert candidate([1, 2, 3, 4, 5, 60]) == True
assert candidate([9, 9, 9, 9]) == True
| [
"([1, 2, 4, 10],)",
"([1, 2, 4, 20],)",
"([1, 20, 4, 10],)",
"([4, 1, 0, -10],)",
"([4, 1, 1, 0],)",
"([1, 2, 3, 2, 5, 60],)",
"([1, 2, 3, 4, 5, 60],)",
"([9, 9, 9, 9],)"
] | [
"True",
"True",
"False",
"True",
"True",
"False",
"True",
"True"
] | python |
HumanEval/58 | <commit_before>def common(l1: list, l2: list):
ret = set()
for e1 in l1:
for e2 in l2:
ret.add(e1)
return sorted(list(ret))
<commit_msg>Fix bugs in common.<commit_after>
def common(l1: list, l2: list): | common | ret = set()
for e1 in l1:
for e2 in l2:
if e1 == e2:
ret.add(e1)
return sorted(list(ret))
|
METADATA = {}
def check(candidate):
assert candidate([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121]) == [1, 5, 653]
assert candidate([5, 3, 2, 8], [3, 2]) == [2, 3]
assert candidate([4, 3, 2, 8], [3, 2, 4]) == [2, 3, 4]
assert candidate([4, 3, 2, 8], []) == []
| [
"([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])",
"([5, 3, 2, 8], [3, 2])",
"([4, 3, 2, 8], [3, 2, 4])",
"([4, 3, 2, 8], [])"
] | [
"[1, 5, 653]",
"[2, 3]",
"[2, 3, 4]",
"[]"
] | python |
HumanEval/59 | <commit_before>def largest_prime_factor(n: int):
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(n):
largest = max(largest, j)
return largest
<commit_msg>Fix bugs in largest_prime_factor.<commit_after>
def largest_prime_factor(n: int): | largest_prime_factor | 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
|
METADATA = {}
def check(candidate):
assert candidate(15) == 5
assert candidate(27) == 3
assert candidate(63) == 7
assert candidate(330) == 11
assert candidate(13195) == 29
| [
"(15,)",
"(27,)",
"(63,)",
"(330,)",
"(13195,)"
] | [
"5",
"3",
"7",
"11",
"29"
] | python |
HumanEval/60 | <commit_before>def sum_to_n(n: int):
return sum(range(n))
<commit_msg>Fix bugs in sum_to_n.<commit_after>
def sum_to_n(n: int): | sum_to_n | return sum(range(n + 1))
|
METADATA = {}
def check(candidate):
assert candidate(1) == 1
assert candidate(6) == 21
assert candidate(11) == 66
assert candidate(30) == 465
assert candidate(100) == 5050
| [
"(1,)",
"(6,)",
"(11,)",
"(30,)",
"(100,)"
] | [
"1",
"21",
"66",
"465",
"5050"
] | python |
HumanEval/61 | <commit_before>def correct_bracketing(brackets: str):
depth = 0
for b in brackets:
if b == "(":
depth += 1
else:
depth -= 1
if depth < 0:
return True
return depth == 0
<commit_msg>Fix bugs in correct_bracketing.<commit_after>
def correct_bracketing(brackets: str): | correct_bracketing | depth = 0
for b in brackets:
if b == "(":
depth += 1
else:
depth -= 1
if depth < 0:
return False
return depth == 0
|
METADATA = {}
def check(candidate):
assert candidate("()")
assert candidate("(()())")
assert candidate("()()(()())()")
assert candidate("()()((()()())())(()()(()))")
assert not candidate("((()())))")
assert not candidate(")(()")
assert not candidate("(")
assert not candidate("((((")
assert not candidate(")")
assert not candidate("(()")
assert not candidate("()()(()())())(()")
assert not candidate("()()(()())()))()")
| [
"('()',)",
"('(()())',)",
"('()()(()())()',)",
"('()()((()()())())(()()(()))',)",
"('((()())))',)",
"(')(()',)",
"('(',)",
"('((((',)",
"(')',)",
"('(()',)",
"('()()(()())())(()',)",
"('()()(()())()))()',)"
] | [
"True",
"True",
"True",
"True",
"False",
"False",
"False",
"False",
"False",
"False",
"False",
"False"
] | python |
HumanEval/62 | <commit_before>def derivative(xs: list):
return [(i * x) for i, x in enumerate(xs)]
<commit_msg>Fix bugs in derivative.<commit_after>
def derivative(xs: list): | derivative | return [(i * x) for i, x in enumerate(xs)][1:]
|
METADATA = {}
def check(candidate):
assert candidate([3, 1, 2, 4, 5]) == [1, 4, 12, 20]
assert candidate([1, 2, 3]) == [2, 6]
assert candidate([3, 2, 1]) == [2, 2]
assert candidate([3, 2, 1, 0, 4]) == [2, 2, 0, 16]
assert candidate([1]) == []
| [
"([3, 1, 2, 4, 5],)",
"([1, 2, 3],)",
"([3, 2, 1],)",
"([3, 2, 1, 0, 4],)",
"([1],)"
] | [
"[1, 4, 12, 20]",
"[2, 6]",
"[2, 2]",
"[2, 2, 0, 16]",
"[]"
] | python |
HumanEval/63 | <commit_before>def fibfib(n: int):
if n == 0:
return 0
if n == 1:
return 1
if n == 2:
return 2
return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)
<commit_msg>Fix bugs in fibfib.<commit_after>
def fibfib(n: int): | fibfib | 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)
|
METADATA = {}
def check(candidate):
assert candidate(2) == 1
assert candidate(1) == 0
assert candidate(5) == 4
assert candidate(8) == 24
assert candidate(10) == 81
assert candidate(12) == 274
assert candidate(14) == 927
| [
"(2,)",
"(1,)",
"(5,)",
"(8,)",
"(10,)",
"(12,)",
"(14,)"
] | [
"1",
"0",
"4",
"24",
"81",
"274",
"927"
] | python |
HumanEval/64 | <commit_before>FIX = """
Add more test cases.
"""
def vowels_count(s):
vowels = "aeiouyAEIOUY"
n_vowels = sum(c in vowels for c in s)
return n_vowels
<commit_msg>Fix bugs in vowels_count.<commit_after>
FIX = """
Add more test cases.
"""
def vowels_count(s): | vowels_count | 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
| def check(candidate):
# Check some simple cases
assert candidate("abcde") == 2, "Test 1"
assert candidate("Alone") == 3, "Test 2"
assert candidate("key") == 2, "Test 3"
assert candidate("bye") == 1, "Test 4"
assert candidate("keY") == 2, "Test 5"
assert candidate("bYe") == 1, "Test 6"
assert candidate("ACEDY") == 3, "Test 7"
# Check some edge cases that are easy to work out by hand.
assert True, "This prints if this assert fails 2 (also good for debugging!)"
| [
"('abcde',)",
"('Alone',)",
"('key',)",
"('bye',)",
"('keY',)",
"('bYe',)",
"('ACEDY',)"
] | [
"2",
"3",
"2",
"1",
"2",
"1",
"3"
] | python |
HumanEval/65 | <commit_before>def circular_shift(x, shift):
s = str(x)
if shift > len(s):
return s[::-1]
else:
return s[:len(s) - shift] + s[len(s) - shift:]
<commit_msg>Fix bugs in circular_shift.<commit_after>
def circular_shift(x, shift): | circular_shift | s = str(x)
if shift > len(s):
return s[::-1]
else:
return s[len(s) - shift:] + s[:len(s) - shift]
| def check(candidate):
# Check some simple cases
assert candidate(100, 2) == "001"
assert candidate(12, 2) == "12"
assert candidate(97, 8) == "79"
assert candidate(12, 1) == "21", "This prints if this assert fails 1 (good for debugging!)"
# Check some edge cases that are easy to work out by hand.
assert candidate(11, 101) == "11", "This prints if this assert fails 2 (also good for debugging!)"
| [
"(100, 2)",
"(12, 2)",
"(97, 8)",
"(12, 1)",
"(11, 101)"
] | [
"001",
"12",
"79",
"21",
"11"
] | python |
HumanEval/66 | <commit_before>def digitSum(s):
if s == "": return 0
return sum(ord(char) if char.islower() else 0 for char in s)
<commit_msg>Fix bugs in digitSum.<commit_after>
def digitSum(s): | digitSum | if s == "": return 0
return sum(ord(char) if char.isupper() else 0 for char in s)
| def check(candidate):
# Check some simple cases
assert True, "This prints if this assert fails 1 (good for debugging!)"
assert candidate("") == 0, "Error"
assert candidate("abAB") == 131, "Error"
assert candidate("abcCd") == 67, "Error"
assert candidate("helloE") == 69, "Error"
assert candidate("woArBld") == 131, "Error"
assert candidate("aAaaaXa") == 153, "Error"
# Check some edge cases that are easy to work out by hand.
assert True, "This prints if this assert fails 2 (also good for debugging!)"
assert candidate(" How are yOu?") == 151, "Error"
assert candidate("You arE Very Smart") == 327, "Error"
| [
"('',)",
"('abAB',)",
"('abcCd',)",
"('helloE',)",
"('woArBld',)",
"('aAaaaXa',)",
"(' How are yOu?',)",
"('You arE Very Smart',)"
] | [
"0",
"131",
"67",
"69",
"131",
"153",
"151",
"327"
] | python |
HumanEval/67 | <commit_before>def fruit_distribution(s,n):
lis = list()
for i in s.split(' '):
if i.isdigit():
lis.append(int(i))
return n - sum(lis) - 1
<commit_msg>Fix bugs in fruit_distribution.<commit_after>
def fruit_distribution(s,n): | fruit_distribution | lis = list()
for i in s.split(' '):
if i.isdigit():
lis.append(int(i))
return n - sum(lis)
| def check(candidate):
# Check some simple cases
assert candidate("5 apples and 6 oranges",19) == 8
assert candidate("5 apples and 6 oranges",21) == 10
assert candidate("0 apples and 1 oranges",3) == 2
assert candidate("1 apples and 0 oranges",3) == 2
assert candidate("2 apples and 3 oranges",100) == 95
assert candidate("2 apples and 3 oranges",5) == 0
assert candidate("1 apples and 100 oranges",120) == 19
| [
"('5 apples and 6 oranges', 19)",
"('5 apples and 6 oranges', 21)",
"('0 apples and 1 oranges', 3)",
"('1 apples and 0 oranges', 3)",
"('2 apples and 3 oranges', 100)",
"('2 apples and 3 oranges', 5)",
"('1 apples and 100 oranges', 120)"
] | [
"8",
"10",
"2",
"2",
"95",
"0",
"19"
] | python |
HumanEval/68 | <commit_before>def pluck(arr):
if(len(arr) == 0): return []
evens = list(filter(lambda x: x%2 == 0, arr))
if(evens == []): return []
return [arr.index(min(evens)), min(evens)]
<commit_msg>Fix bugs in pluck.<commit_after>
def pluck(arr): | pluck | if(len(arr) == 0): return []
evens = list(filter(lambda x: x%2 == 0, arr))
if(evens == []): return []
return [min(evens), arr.index(min(evens))]
| def check(candidate):
# Check some simple cases
assert True, "This prints if this assert fails 1 (good for debugging!)"
assert candidate([4,2,3]) == [2, 1], "Error"
assert candidate([1,2,3]) == [2, 1], "Error"
assert candidate([]) == [], "Error"
assert candidate([5, 0, 3, 0, 4, 2]) == [0, 1], "Error"
# Check some edge cases that are easy to work out by hand.
assert True, "This prints if this assert fails 2 (also good for debugging!)"
assert candidate([1, 2, 3, 0, 5, 3]) == [0, 3], "Error"
assert candidate([5, 4, 8, 4 ,8]) == [4, 1], "Error"
assert candidate([7, 6, 7, 1]) == [6, 1], "Error"
assert candidate([7, 9, 7, 1]) == [], "Error"
| [
"([4, 2, 3],)",
"([1, 2, 3],)",
"([],)",
"([5, 0, 3, 0, 4, 2],)",
"([1, 2, 3, 0, 5, 3],)",
"([5, 4, 8, 4, 8],)",
"([7, 6, 7, 1],)",
"([7, 9, 7, 1],)"
] | [
"[2, 1]",
"[2, 1]",
"[]",
"[0, 1]",
"[0, 3]",
"[4, 1]",
"[6, 1]",
"[]"
] | python |
HumanEval/69 | <commit_before>def search(lst):
frq = [0] * (max(lst) + 1)
for i in lst:
frq[i] += 1;
ans = 0
for i in range(1, len(frq)):
if frq[i] >= i:
ans = i
return ans
<commit_msg>Fix bugs in search.<commit_after>
def search(lst): | search | 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
| def check(candidate):
# manually generated tests
assert candidate([5, 5, 5, 5, 1]) == 1
assert candidate([4, 1, 4, 1, 4, 4]) == 4
assert candidate([3, 3]) == -1
assert candidate([8, 8, 8, 8, 8, 8, 8, 8]) == 8
assert candidate([2, 3, 3, 2, 2]) == 2
# automatically generated tests
assert candidate([2, 7, 8, 8, 4, 8, 7, 3, 9, 6, 5, 10, 4, 3, 6, 7, 1, 7, 4, 10, 8, 1]) == 1
assert candidate([3, 2, 8, 2]) == 2
assert candidate([6, 7, 1, 8, 8, 10, 5, 8, 5, 3, 10]) == 1
assert candidate([8, 8, 3, 6, 5, 6, 4]) == -1
assert candidate([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]) == 1
assert candidate([1, 9, 10, 1, 3]) == 1
assert candidate([6, 9, 7, 5, 8, 7, 5, 3, 7, 5, 10, 10, 3, 6, 10, 2, 8, 6, 5, 4, 9, 5, 3, 10]) == 5
assert candidate([1]) == 1
assert candidate([8, 8, 10, 6, 4, 3, 5, 8, 2, 4, 2, 8, 4, 6, 10, 4, 2, 1, 10, 2, 1, 1, 5]) == 4
assert candidate([2, 10, 4, 8, 2, 10, 5, 1, 2, 9, 5, 5, 6, 3, 8, 6, 4, 10]) == 2
assert candidate([1, 6, 10, 1, 6, 9, 10, 8, 6, 8, 7, 3]) == 1
assert candidate([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]) == 4
assert candidate([2, 6, 4, 2, 8, 7, 5, 6, 4, 10, 4, 6, 3, 7, 8, 8, 3, 1, 4, 2, 2, 10, 7]) == 4
assert candidate([9, 8, 6, 10, 2, 6, 10, 2, 7, 8, 10, 3, 8, 2, 6, 2, 3, 1]) == 2
assert candidate([5, 5, 3, 9, 5, 6, 3, 2, 8, 5, 6, 10, 10, 6, 8, 4, 10, 7, 7, 10, 8]) == -1
assert candidate([10]) == -1
assert candidate([9, 7, 7, 2, 4, 7, 2, 10, 9, 7, 5, 7, 2]) == 2
assert candidate([5, 4, 10, 2, 1, 1, 10, 3, 6, 1, 8]) == 1
assert candidate([7, 9, 9, 9, 3, 4, 1, 5, 9, 1, 2, 1, 1, 10, 7, 5, 6, 7, 6, 7, 7, 6]) == 1
assert candidate([3, 10, 10, 9, 2]) == -1
| [
"([5, 5, 5, 5, 1],)",
"([4, 1, 4, 1, 4, 4],)",
"([3, 3],)",
"([8, 8, 8, 8, 8, 8, 8, 8],)",
"([2, 3, 3, 2, 2],)",
"([2, 7, 8, 8, 4, 8, 7, 3, 9, 6, 5, 10, 4, 3, 6, 7, 1, 7, 4, 10, 8, 1],)",
"([3, 2, 8, 2],)",
"([6, 7, 1, 8, 8, 10, 5, 8, 5, 3, 10],)",
"([8, 8, 3, 6, 5, 6, 4],)",
"([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],)",
"([1, 9, 10, 1, 3],)",
"([6, 9, 7, 5, 8, 7, 5, 3, 7, 5, 10, 10, 3, 6, 10, 2, 8, 6, 5, 4, 9, 5, 3, 10],)",
"([1],)",
"([8, 8, 10, 6, 4, 3, 5, 8, 2, 4, 2, 8, 4, 6, 10, 4, 2, 1, 10, 2, 1, 1, 5],)",
"([2, 10, 4, 8, 2, 10, 5, 1, 2, 9, 5, 5, 6, 3, 8, 6, 4, 10],)",
"([1, 6, 10, 1, 6, 9, 10, 8, 6, 8, 7, 3],)",
"([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],)",
"([2, 6, 4, 2, 8, 7, 5, 6, 4, 10, 4, 6, 3, 7, 8, 8, 3, 1, 4, 2, 2, 10, 7],)",
"([9, 8, 6, 10, 2, 6, 10, 2, 7, 8, 10, 3, 8, 2, 6, 2, 3, 1],)",
"([5, 5, 3, 9, 5, 6, 3, 2, 8, 5, 6, 10, 10, 6, 8, 4, 10, 7, 7, 10, 8],)",
"([10],)",
"([9, 7, 7, 2, 4, 7, 2, 10, 9, 7, 5, 7, 2],)",
"([5, 4, 10, 2, 1, 1, 10, 3, 6, 1, 8],)",
"([7, 9, 9, 9, 3, 4, 1, 5, 9, 1, 2, 1, 1, 10, 7, 5, 6, 7, 6, 7, 7, 6],)",
"([3, 10, 10, 9, 2],)"
] | [
"1",
"4",
"-1",
"8",
"2",
"1",
"2",
"1",
"-1",
"1",
"1",
"5",
"1",
"4",
"2",
"1",
"4",
"4",
"2",
"-1",
"-1",
"2",
"1",
"1",
"-1"
] | python |
HumanEval/70 | <commit_before>def strange_sort_list(lst):
res, switch = [], False
while lst:
res.append(min(lst) if switch else max(lst))
lst.remove(res[-1])
switch = not switch
return res
<commit_msg>Fix bugs in strange_sort_list.<commit_after>
def strange_sort_list(lst): | 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
| def check(candidate):
# Check some simple cases
assert candidate([1, 2, 3, 4]) == [1, 4, 2, 3]
assert candidate([5, 6, 7, 8, 9]) == [5, 9, 6, 8, 7]
assert candidate([1, 2, 3, 4, 5]) == [1, 5, 2, 4, 3]
assert candidate([5, 6, 7, 8, 9, 1]) == [1, 9, 5, 8, 6, 7]
assert candidate([5, 5, 5, 5]) == [5, 5, 5, 5]
assert candidate([]) == []
assert candidate([1,2,3,4,5,6,7,8]) == [1, 8, 2, 7, 3, 6, 4, 5]
assert candidate([0,2,2,2,5,5,-5,-5]) == [-5, 5, -5, 5, 0, 2, 2, 2]
assert candidate([111111]) == [111111]
# Check some edge cases that are easy to work out by hand.
assert True
| [
"([],)",
"([],)",
"([],)",
"([],)",
"([],)",
"([],)",
"([],)",
"([],)",
"([],)"
] | [
"[1, 4, 2, 3]",
"[5, 9, 6, 8, 7]",
"[1, 5, 2, 4, 3]",
"[1, 9, 5, 8, 6, 7]",
"[5, 5, 5, 5]",
"[]",
"[1, 8, 2, 7, 3, 6, 4, 5]",
"[-5, 5, -5, 5, 0, 2, 2, 2]",
"[111111]"
] | python |
HumanEval/71 | <commit_before>def triangle_area(a, b, c):
if a + b <= c or a + c <= b or b + c <= a:
return -1
s = (a + b + c)
area = (s * (s - a) * (s - b) * (s - c)) ** 0.5
area = round(area, 2)
return area
<commit_msg>Fix bugs in triangle_area.<commit_after>
def triangle_area(a, b, c): | triangle_area | 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
| def check(candidate):
# Check some simple cases
assert candidate(3, 4, 5) == 6.00, "This prints if this assert fails 1 (good for debugging!)"
assert candidate(1, 2, 10) == -1
assert candidate(4, 8, 5) == 8.18
assert candidate(2, 2, 2) == 1.73
assert candidate(1, 2, 3) == -1
assert candidate(10, 5, 7) == 16.25
assert candidate(2, 6, 3) == -1
# Check some edge cases that are easy to work out by hand.
assert candidate(1, 1, 1) == 0.43, "This prints if this assert fails 2 (also good for debugging!)"
assert candidate(2, 2, 10) == -1
| [
"(3, 4, 5)",
"(1, 2, 10)",
"(4, 8, 5)",
"(2, 2, 2)",
"(1, 2, 3)",
"(10, 5, 7)",
"(2, 6, 3)",
"(1, 1, 1)",
"(2, 2, 10)"
] | [
"6.0",
"-1",
"8.18",
"1.73",
"-1",
"16.25",
"-1",
"0.43",
"-1"
] | python |
HumanEval/72 | <commit_before>def will_it_fly(q,w):
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
<commit_msg>Fix bugs in will_it_fly.<commit_after>
def will_it_fly(q,w): | will_it_fly | 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
| def check(candidate):
# Check some simple cases
assert candidate([3, 2, 3], 9) is True
assert candidate([1, 2], 5) is False
assert candidate([3], 5) is True
assert candidate([3, 2, 3], 1) is False
# Check some edge cases that are easy to work out by hand.
assert candidate([1, 2, 3], 6) is False
assert candidate([5], 5) is True
| [
"([3, 2, 3], 9)",
"([1, 2], 5)",
"([3], 5)",
"([3, 2, 3], 1)",
"([1, 2, 3], 6)",
"([5], 5)"
] | [
"True",
"False",
"True",
"False",
"False",
"True"
] | python |
HumanEval/73 | <commit_before>def smallest_change(arr):
ans = 0
for i in range(len(arr) // 2):
if ans != arr[len(arr) - i - 1]:
ans += 1
return ans
<commit_msg>Fix bugs in smallest_change.<commit_after>
def smallest_change(arr): | smallest_change | ans = 0
for i in range(len(arr) // 2):
if arr[i] != arr[len(arr) - i - 1]:
ans += 1
return ans
| def check(candidate):
# Check some simple cases
assert candidate([1,2,3,5,4,7,9,6]) == 4
assert candidate([1, 2, 3, 4, 3, 2, 2]) == 1
assert candidate([1, 4, 2]) == 1
assert candidate([1, 4, 4, 2]) == 1
# Check some edge cases that are easy to work out by hand.
assert candidate([1, 2, 3, 2, 1]) == 0
assert candidate([3, 1, 1, 3]) == 0
assert candidate([1]) == 0
assert candidate([0, 1]) == 1
| [
"([1, 2, 3, 5, 4, 7, 9, 6],)",
"([1, 2, 3, 4, 3, 2, 2],)",
"([1, 4, 2],)",
"([1, 4, 4, 2],)",
"([1, 2, 3, 2, 1],)",
"([3, 1, 1, 3],)",
"([1],)",
"([0, 1],)"
] | [
"4",
"1",
"1",
"1",
"0",
"0",
"0",
"1"
] | python |
HumanEval/74 | <commit_before>def total_match(lst1, lst2):
l1 = 0
for st in lst1:
l1 += len(st)
l2 = 0
for st in lst2:
l2 += len(st)
if l1 <= l2:
return lst2
else:
return lst1
<commit_msg>Fix bugs in total_match.<commit_after>
def total_match(lst1, lst2): | total_match | 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
| def check(candidate):
# Check some simple cases
assert True, "This prints if this assert fails 1 (good for debugging!)"
assert candidate([], []) == []
assert candidate(['hi', 'admin'], ['hi', 'hi']) == ['hi', 'hi']
assert candidate(['hi', 'admin'], ['hi', 'hi', 'admin', 'project']) == ['hi', 'admin']
assert candidate(['4'], ['1', '2', '3', '4', '5']) == ['4']
assert candidate(['hi', 'admin'], ['hI', 'Hi']) == ['hI', 'Hi']
assert candidate(['hi', 'admin'], ['hI', 'hi', 'hi']) == ['hI', 'hi', 'hi']
assert candidate(['hi', 'admin'], ['hI', 'hi', 'hii']) == ['hi', 'admin']
# Check some edge cases that are easy to work out by hand.
assert True, "This prints if this assert fails 2 (also good for debugging!)"
assert candidate([], ['this']) == []
assert candidate(['this'], []) == []
| [
"([], [])",
"(['hi', 'admin'], ['hi', 'hi'])",
"(['hi', 'admin'], ['hi', 'hi', 'admin', 'project'])",
"(['4'], ['1', '2', '3', '4', '5'])",
"(['hi', 'admin'], ['hI', 'Hi'])",
"(['hi', 'admin'], ['hI', 'hi', 'hi'])",
"(['hi', 'admin'], ['hI', 'hi', 'hii'])",
"([], ['this'])",
"(['this'], [])"
] | [
"[]",
"['hi', 'hi']",
"['hi', 'admin']",
"['4']",
"['hI', 'Hi']",
"['hI', 'hi', 'hi']",
"['hi', 'admin']",
"[]",
"[]"
] | python |
HumanEval/75 | <commit_before>def is_multiply_prime(a):
def is_prime(n):
for j in range(0,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
<commit_msg>Fix bugs in is_multiply_prime.<commit_after>
def is_multiply_prime(a): | is_multiply_prime | 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
| def check(candidate):
assert candidate(5) == False
assert candidate(30) == True
assert candidate(8) == True
assert candidate(10) == False
assert candidate(125) == True
assert candidate(3 * 5 * 7) == True
assert candidate(3 * 6 * 7) == False
assert candidate(9 * 9 * 9) == False
assert candidate(11 * 9 * 9) == False
assert candidate(11 * 13 * 7) == True
| [
"(5,)",
"(30,)",
"(8,)",
"(10,)",
"(125,)",
"(105,)",
"(126,)",
"(729,)",
"(891,)",
"(1001,)"
] | [
"False",
"True",
"True",
"False",
"True",
"True",
"False",
"False",
"False",
"True"
] | python |
HumanEval/76 | <commit_before>def is_simple_power(x, n):
if (n == 1):
return (x == 1)
power = 1
while (n < x):
power = power * n
return (power == x)
<commit_msg>Fix bugs in is_simple_power.<commit_after>
def is_simple_power(x, n): | is_simple_power | if (n == 1):
return (x == 1)
power = 1
while (power < x):
power = power * n
return (power == x)
| def check(candidate):
# Check some simple cases
assert candidate(16, 2)== True, "This prints if this assert fails 1 (good for debugging!)"
assert candidate(143214, 16)== False, "This prints if this assert fails 1 (good for debugging!)"
assert candidate(4, 2)==True, "This prints if this assert fails 1 (good for debugging!)"
assert candidate(9, 3)==True, "This prints if this assert fails 1 (good for debugging!)"
assert candidate(16, 4)==True, "This prints if this assert fails 1 (good for debugging!)"
assert candidate(24, 2)==False, "This prints if this assert fails 1 (good for debugging!)"
assert candidate(128, 4)==False, "This prints if this assert fails 1 (good for debugging!)"
assert candidate(12, 6)==False, "This prints if this assert fails 1 (good for debugging!)"
# Check some edge cases that are easy to work out by hand.
assert candidate(1, 1)==True, "This prints if this assert fails 2 (also good for debugging!)"
assert candidate(1, 12)==True, "This prints if this assert fails 2 (also good for debugging!)"
| [
"(16, 2)",
"(143214, 16)",
"(4, 2)",
"(9, 3)",
"(16, 4)",
"(24, 2)",
"(128, 4)",
"(12, 6)",
"(1, 1)",
"(1, 12)"
] | [
"True",
"False",
"True",
"True",
"True",
"False",
"False",
"False",
"True",
"True"
] | python |
HumanEval/77 | <commit_before>def iscube(a):
a = abs(a)
return int(round(a ** (1. / 3))) == a
<commit_msg>Fix bugs in iscube.<commit_after>
def iscube(a): | iscube | a = abs(a)
return int(round(a ** (1. / 3))) ** 3 == a
| def check(candidate):
# Check some simple cases
assert candidate(1) == True, "First test error: " + str(candidate(1))
assert candidate(2) == False, "Second test error: " + str(candidate(2))
assert candidate(-1) == True, "Third test error: " + str(candidate(-1))
assert candidate(64) == True, "Fourth test error: " + str(candidate(64))
assert candidate(180) == False, "Fifth test error: " + str(candidate(180))
assert candidate(1000) == True, "Sixth test error: " + str(candidate(1000))
# Check some edge cases that are easy to work out by hand.
assert candidate(0) == True, "1st edge test error: " + str(candidate(0))
assert candidate(1729) == False, "2nd edge test error: " + str(candidate(1728))
| [
"(1,)",
"(2,)",
"(-1,)",
"(64,)",
"(180,)",
"(1000,)",
"(0,)",
"(1729,)"
] | [
"True",
"False",
"True",
"True",
"False",
"True",
"True",
"False"
] | python |
HumanEval/78 | <commit_before>def hex_key(num):
primes = ('2', '3', '5', '7', 'B', 'D')
total = 1
for i in range(0, len(num)):
if num[i] in primes:
total += 1
return total
<commit_msg>Fix bugs in hex_key.<commit_after>
def hex_key(num): | hex_key | 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
| def check(candidate):
# Check some simple cases
assert candidate("AB") == 1, "First test error: " + str(candidate("AB"))
assert candidate("1077E") == 2, "Second test error: " + str(candidate("1077E"))
assert candidate("ABED1A33") == 4, "Third test error: " + str(candidate("ABED1A33"))
assert candidate("2020") == 2, "Fourth test error: " + str(candidate("2020"))
assert candidate("123456789ABCDEF0") == 6, "Fifth test error: " + str(candidate("123456789ABCDEF0"))
assert candidate("112233445566778899AABBCCDDEEFF00") == 12, "Sixth test error: " + str(candidate("112233445566778899AABBCCDDEEFF00"))
# Check some edge cases that are easy to work out by hand.
assert candidate([]) == 0
| [
"('AB',)",
"('1077E',)",
"('ABED1A33',)",
"('2020',)",
"('123456789ABCDEF0',)",
"('112233445566778899AABBCCDDEEFF00',)",
"([],)"
] | [
"1",
"2",
"4",
"2",
"6",
"12",
"0"
] | python |
HumanEval/79 | <commit_before>def decimal_to_binary(decimal):
return "db" + bin(decimal)[2:] + "d"
<commit_msg>Fix bugs in decimal_to_binary.<commit_after>
def decimal_to_binary(decimal): | decimal_to_binary | return "db" + bin(decimal)[2:] + "db"
| def check(candidate):
# Check some simple cases
assert candidate(0) == "db0db"
assert candidate(32) == "db100000db"
assert candidate(103) == "db1100111db"
assert candidate(15) == "db1111db", "This prints if this assert fails 1 (good for debugging!)"
# Check some edge cases that are easy to work out by hand.
assert True, "This prints if this assert fails 2 (also good for debugging!)"
| [
"(0,)",
"(32,)",
"(103,)",
"(15,)"
] | [
"db0db",
"db100000db",
"db1100111db",
"db1111db"
] | python |
HumanEval/80 | <commit_before>def is_happy(s):
if len(s) < 3:
return False
for i in range(len(s) - 2):
if s[i] == s[i+1] and s[i+1] == s[i+2] and s[i] == s[i+2]:
return False
return True
<commit_msg>Fix bugs in is_happy.<commit_after>
def is_happy(s): | is_happy | 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
| def check(candidate):
# Check some simple cases
assert candidate("a") == False , "a"
assert candidate("aa") == False , "aa"
assert candidate("abcd") == True , "abcd"
assert candidate("aabb") == False , "aabb"
assert candidate("adb") == True , "adb"
assert candidate("xyy") == False , "xyy"
assert candidate("iopaxpoi") == True , "iopaxpoi"
assert candidate("iopaxioi") == False , "iopaxioi"
| [
"('a',)",
"('aa',)",
"('abcd',)",
"('aabb',)",
"('adb',)",
"('xyy',)",
"('iopaxpoi',)",
"('iopaxioi',)"
] | [
"False",
"False",
"True",
"False",
"True",
"False",
"True",
"False"
] | python |
HumanEval/81 | <commit_before>def numerical_letter_grade(grades):
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
<commit_msg>Fix bugs in numerical_letter_grade.<commit_after>
def numerical_letter_grade(grades): | numerical_letter_grade |
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
| def check(candidate):
# Check some simple cases
assert candidate([4.0, 3, 1.7, 2, 3.5]) == ['A+', 'B', 'C-', 'C', 'A-']
assert candidate([1.2]) == ['D+']
assert candidate([0.5]) == ['D-']
assert candidate([0.0]) == ['E']
assert candidate([1, 0.3, 1.5, 2.8, 3.3]) == ['D', 'D-', 'C-', 'B', 'B+']
assert candidate([0, 0.7]) == ['E', 'D-']
# Check some edge cases that are easy to work out by hand.
assert True
| [
"([4.0, 3, 1.7, 2, 3.5],)",
"([1.2],)",
"([0.5],)",
"([0.0],)",
"([1, 0.3, 1.5, 2.8, 3.3],)",
"([0, 0.7],)"
] | [
"['A+', 'B', 'C-', 'C', 'A-']",
"['D+']",
"['D-']",
"['E']",
"['D', 'D-', 'C-', 'B', 'B+']",
"['E', 'D-']"
] | python |
HumanEval/82 | <commit_before>def prime_length(string):
l = len(string)
if l == 0 or l == 1:
return False
for i in range(3, l):
if l % i == 0:
return False
return True
<commit_msg>Fix bugs in prime_length.<commit_after>
def prime_length(string): | prime_length | 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
| def check(candidate):
# Check some simple cases
assert candidate('Hello') == True
assert candidate('abcdcba') == True
assert candidate('kittens') == True
assert candidate('orange') == False
assert candidate('wow') == True
assert candidate('world') == True
assert candidate('MadaM') == True
assert candidate('Wow') == True
assert candidate('') == False
assert candidate('HI') == True
assert candidate('go') == True
assert candidate('gogo') == False
assert candidate('aaaaaaaaaaaaaaa') == False
# Check some edge cases that are easy to work out by hand.
assert candidate('Madam') == True
assert candidate('M') == False
assert candidate('0') == False
| [
"('Hello',)",
"('abcdcba',)",
"('kittens',)",
"('orange',)",
"('wow',)",
"('world',)",
"('MadaM',)",
"('Wow',)",
"('',)",
"('HI',)",
"('go',)",
"('gogo',)",
"('aaaaaaaaaaaaaaa',)",
"('Madam',)",
"('M',)",
"('0',)"
] | [
"True",
"True",
"True",
"False",
"True",
"True",
"True",
"True",
"False",
"True",
"True",
"False",
"False",
"True",
"False",
"False"
] | python |
HumanEval/83 | <commit_before>def starts_one_ends(n):
if n == 1: return 1
return 18 * n * (10 ** (n - 2))
<commit_msg>Fix bugs in starts_one_ends.<commit_after>
def starts_one_ends(n): | starts_one_ends | if n == 1: return 1
return 18 * (10 ** (n - 2))
| def check(candidate):
# Check some simple cases
assert True, "This prints if this assert fails 1 (good for debugging!)"
assert candidate(1) == 1
assert candidate(2) == 18
assert candidate(3) == 180
assert candidate(4) == 1800
assert candidate(5) == 18000
# Check some edge cases that are easy to work out by hand.
assert True, "This prints if this assert fails 2 (also good for debugging!)"
| [
"(1,)",
"(2,)",
"(3,)",
"(4,)",
"(5,)"
] | [
"1",
"18",
"180",
"1800",
"18000"
] | python |
HumanEval/84 | <commit_before>def solve(N):
return bin([int(i) for i in str(N)][-1])[2:]
<commit_msg>Fix bugs in solve.<commit_after>
def solve(N): | solve | return bin(sum(int(i) for i in str(N)))[2:]
| def check(candidate):
# Check some simple cases
assert True, "This prints if this assert fails 1 (good for debugging!)"
assert candidate(1000) == "1", "Error"
assert candidate(150) == "110", "Error"
assert candidate(147) == "1100", "Error"
# Check some edge cases that are easy to work out by hand.
assert True, "This prints if this assert fails 2 (also good for debugging!)"
assert candidate(333) == "1001", "Error"
assert candidate(963) == "10010", "Error"
| [
"(1000,)",
"(150,)",
"(147,)",
"(333,)",
"(963,)"
] | [
"1",
"110",
"1100",
"1001",
"10010"
] | python |
HumanEval/85 | <commit_before>def add(lst):
return sum([lst[i] for i in range(1, len(lst), 1) if lst[i]%2 == 0])
<commit_msg>Fix bugs in add.<commit_after>
def add(lst): | add | return sum([lst[i] for i in range(1, len(lst), 2) if lst[i]%2 == 0])
| def check(candidate):
# Check some simple cases
assert candidate([4, 88]) == 88
assert candidate([4, 5, 6, 7, 2, 122]) == 122
assert candidate([4, 0, 6, 7]) == 0
assert candidate([4, 4, 6, 8]) == 12
# Check some edge cases that are easy to work out by hand.
| [
"([4, 88],)",
"([4, 5, 6, 7, 2, 122],)",
"([4, 0, 6, 7],)",
"([4, 4, 6, 8],)"
] | [
"88",
"122",
"0",
"12"
] | python |
HumanEval/86 | <commit_before>def anti_shuffle(s):
return ''.join([''.join(sorted(list(i))) for i in s.split(' ')])
<commit_msg>Fix bugs in anti_shuffle.<commit_after>
def anti_shuffle(s): | anti_shuffle | return ' '.join([''.join(sorted(list(i))) for i in s.split(' ')])
| def check(candidate):
# Check some simple cases
assert candidate('Hi') == 'Hi'
assert candidate('hello') == 'ehllo'
assert candidate('number') == 'bemnru'
assert candidate('abcd') == 'abcd'
assert candidate('Hello World!!!') == 'Hello !!!Wdlor'
assert candidate('') == ''
assert candidate('Hi. My name is Mister Robot. How are you?') == '.Hi My aemn is Meirst .Rboot How aer ?ouy'
# Check some edge cases that are easy to work out by hand.
assert True
| [
"('Hi',)",
"('hello',)",
"('number',)",
"('abcd',)",
"('Hello World!!!',)",
"('',)",
"('Hi. My name is Mister Robot. How are you?',)"
] | [
"Hi",
"ehllo",
"bemnru",
"abcd",
"Hello !!!Wdlor",
"",
".Hi My aemn is Meirst .Rboot How aer ?ouy"
] | python |
HumanEval/87 | <commit_before>def get_row(lst, x):
coords = [(j, i) 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])
<commit_msg>Fix bugs in get_row.<commit_after>
def get_row(lst, x): | get_row | 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])
| def check(candidate):
# Check some simple cases
assert candidate([
[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)]
assert candidate([
[1,2,3,4,5,6],
[1,2,3,4,5,6],
[1,2,3,4,5,6],
[1,2,3,4,5,6],
[1,2,3,4,5,6],
[1,2,3,4,5,6]
], 2) == [(0, 1), (1, 1), (2, 1), (3, 1), (4, 1), (5, 1)]
assert candidate([
[1,2,3,4,5,6],
[1,2,3,4,5,6],
[1,1,3,4,5,6],
[1,2,1,4,5,6],
[1,2,3,1,5,6],
[1,2,3,4,1,6],
[1,2,3,4,5,1]
], 1) == [(0, 0), (1, 0), (2, 1), (2, 0), (3, 2), (3, 0), (4, 3), (4, 0), (5, 4), (5, 0), (6, 5), (6, 0)]
assert candidate([], 1) == []
assert candidate([[1]], 2) == []
assert candidate([[], [1], [1, 2, 3]], 3) == [(2, 2)]
# Check some edge cases that are easy to work out by hand.
assert True
| [
"([[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 1, 6], [1, 2, 3, 4, 5, 1]], 1)",
"([[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6]], 2)",
"([[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 1, 3, 4, 5, 6], [1, 2, 1, 4, 5, 6], [1, 2, 3, 1, 5, 6], [1, 2, 3, 4, 1, 6], [1, 2, 3, 4, 5, 1]], 1)",
"([], 1)",
"([[1]], 2)",
"([[], [1], [1, 2, 3]], 3)"
] | [
"[(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)]",
"[(0, 1), (1, 1), (2, 1), (3, 1), (4, 1), (5, 1)]",
"[(0, 0), (1, 0), (2, 1), (2, 0), (3, 2), (3, 0), (4, 3), (4, 0), (5, 4), (5, 0), (6, 5), (6, 0)]",
"[]",
"[]",
"[(2, 2)]"
] | python |
HumanEval/88 | <commit_before>def sort_array(array):
return [] if len(array) == 0 else sorted(array, reverse= (array[0]+array[-1]) % 2 != 0)
<commit_msg>Fix bugs in sort_array.<commit_after>
def sort_array(array): | sort_array | return [] if len(array) == 0 else sorted(array, reverse= (array[0]+array[-1]) % 2 == 0)
| def check(candidate):
# Check some simple cases
assert True, "This prints if this assert fails 1 (good for debugging!)"
assert candidate([]) == [], "Error"
assert candidate([5]) == [5], "Error"
assert candidate([2, 4, 3, 0, 1, 5]) == [0, 1, 2, 3, 4, 5], "Error"
assert candidate([2, 4, 3, 0, 1, 5, 6]) == [6, 5, 4, 3, 2, 1, 0], "Error"
# Check some edge cases that are easy to work out by hand.
assert True, "This prints if this assert fails 2 (also good for debugging!)"
assert candidate([2, 1]) == [1, 2], "Error"
assert candidate([15, 42, 87, 32 ,11, 0]) == [0, 11, 15, 32, 42, 87], "Error"
assert candidate([21, 14, 23, 11]) == [23, 21, 14, 11], "Error"
| [
"([],)",
"([5],)",
"([2, 4, 3, 0, 1, 5],)",
"([2, 4, 3, 0, 1, 5, 6],)",
"([2, 1],)",
"([15, 42, 87, 32, 11, 0],)",
"([21, 14, 23, 11],)"
] | [
"[]",
"[5]",
"[0, 1, 2, 3, 4, 5]",
"[6, 5, 4, 3, 2, 1, 0]",
"[1, 2]",
"[0, 11, 15, 32, 42, 87]",
"[23, 21, 14, 11]"
] | python |
HumanEval/89 | <commit_before>def encrypt(s):
d = 'abcdefghijklmnopqrstuvwxyz'
out = ''
for c in s:
if c in d:
out += d[(d.index(c)+2*2) % 24]
else:
out += c
return out
<commit_msg>Fix bugs in encrypt.<commit_after>
def encrypt(s): | encrypt | d = 'abcdefghijklmnopqrstuvwxyz'
out = ''
for c in s:
if c in d:
out += d[(d.index(c)+2*2) % 26]
else:
out += c
return out
| def check(candidate):
# Check some simple cases
assert candidate('hi') == 'lm', "This prints if this assert fails 1 (good for debugging!)"
assert candidate('asdfghjkl') == 'ewhjklnop', "This prints if this assert fails 1 (good for debugging!)"
assert candidate('gf') == 'kj', "This prints if this assert fails 1 (good for debugging!)"
assert candidate('et') == 'ix', "This prints if this assert fails 1 (good for debugging!)"
assert candidate('faewfawefaewg')=='jeiajeaijeiak', "This prints if this assert fails 1 (good for debugging!)"
assert candidate('hellomyfriend')=='lippsqcjvmirh', "This prints if this assert fails 2 (good for debugging!)"
assert candidate('dxzdlmnilfuhmilufhlihufnmlimnufhlimnufhfucufh')=='hbdhpqrmpjylqmpyjlpmlyjrqpmqryjlpmqryjljygyjl', "This prints if this assert fails 3 (good for debugging!)"
# Check some edge cases that are easy to work out by hand.
assert candidate('a')=='e', "This prints if this assert fails 2 (also good for debugging!)"
| [
"('hi',)",
"('asdfghjkl',)",
"('gf',)",
"('et',)",
"('faewfawefaewg',)",
"('hellomyfriend',)",
"('dxzdlmnilfuhmilufhlihufnmlimnufhlimnufhfucufh',)",
"('a',)"
] | [
"lm",
"ewhjklnop",
"kj",
"ix",
"jeiajeaijeiak",
"lippsqcjvmirh",
"hbdhpqrmpjylqmpyjlpmlyjrqpmqryjlpmqryjljygyjl",
"e"
] | python |
HumanEval/90 | <commit_before>def next_smallest(lst):
lst = sorted(set(lst))
return None if len(lst) < 3 else lst[1]
<commit_msg>Fix bugs in next_smallest.<commit_after>
def next_smallest(lst): | next_smallest | lst = sorted(set(lst))
return None if len(lst) < 2 else lst[1]
| def check(candidate):
# Check some simple cases
assert candidate([1, 2, 3, 4, 5]) == 2
assert candidate([5, 1, 4, 3, 2]) == 2
assert candidate([]) == None
assert candidate([1, 1]) == None
assert candidate([1,1,1,1,0]) == 1
assert candidate([1, 0**0]) == None
assert candidate([-35, 34, 12, -45]) == -35
# Check some edge cases that are easy to work out by hand.
assert True
| [
"([1, 2, 3, 4, 5],)",
"([5, 1, 4, 3, 2],)",
"([],)",
"([1, 1],)",
"([1, 1, 1, 1, 0],)",
"([1, 1],)",
"([-35, 34, 12, -45],)"
] | [
"2",
"2",
"None",
"None",
"1",
"None",
"-35"
] | python |
HumanEval/91 | <commit_before>def is_bored(S):
import re
sentences = re.split(r'[.?!]\s*', S)
return sum(sentence[0:2] == ' I' for sentence in sentences)
<commit_msg>Fix bugs in is_bored.<commit_after>
def is_bored(S): | is_bored | import re
sentences = re.split(r'[.?!]\s*', S)
return sum(sentence[0:2] == 'I ' for sentence in sentences)
| def check(candidate):
# Check some simple cases
assert candidate("Hello world") == 0, "Test 1"
assert candidate("Is the sky blue?") == 0, "Test 2"
assert candidate("I love It !") == 1, "Test 3"
assert candidate("bIt") == 0, "Test 4"
assert candidate("I feel good today. I will be productive. will kill It") == 2, "Test 5"
assert candidate("You and I are going for a walk") == 0, "Test 6"
# Check some edge cases that are easy to work out by hand.
assert True, "This prints if this assert fails 2 (also good for debugging!)"
| [
"('Hello world',)",
"('Is the sky blue?',)",
"('I love It !',)",
"('bIt',)",
"('I feel good today. I will be productive. will kill It',)",
"('You and I are going for a walk',)"
] | [
"0",
"0",
"1",
"0",
"2",
"0"
] | python |
HumanEval/92 | <commit_before>def any_int(x, y, z):
if isinstance(x,int) and isinstance(y,int) and isinstance(z,int):
if (x+y==z) or (y+z==x):
return True
return False
return False
<commit_msg>Fix bugs in any_int.<commit_after>
def any_int(x, y, z): | any_int |
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
| def check(candidate):
# Check some simple cases
assert candidate(2, 3, 1)==True, "This prints if this assert fails 1 (good for debugging!)"
assert candidate(2.5, 2, 3)==False, "This prints if this assert fails 2 (good for debugging!)"
assert candidate(1.5, 5, 3.5)==False, "This prints if this assert fails 3 (good for debugging!)"
assert candidate(2, 6, 2)==False, "This prints if this assert fails 4 (good for debugging!)"
assert candidate(4, 2, 2)==True, "This prints if this assert fails 5 (good for debugging!)"
assert candidate(2.2, 2.2, 2.2)==False, "This prints if this assert fails 6 (good for debugging!)"
assert candidate(-4, 6, 2)==True, "This prints if this assert fails 7 (good for debugging!)"
# Check some edge cases that are easy to work out by hand.
assert candidate(2,1,1)==True, "This prints if this assert fails 8 (also good for debugging!)"
assert candidate(3,4,7)==True, "This prints if this assert fails 9 (also good for debugging!)"
assert candidate(3.0,4,7)==False, "This prints if this assert fails 10 (also good for debugging!)"
| [
"(2, 3, 1)",
"(2.5, 2, 3)",
"(1.5, 5, 3.5)",
"(2, 6, 2)",
"(4, 2, 2)",
"(2.2, 2.2, 2.2)",
"(-4, 6, 2)",
"(2, 1, 1)",
"(3, 4, 7)",
"(3.0, 4, 7)"
] | [
"True",
"False",
"False",
"False",
"True",
"False",
"True",
"True",
"True",
"False"
] | python |
HumanEval/93 | <commit_before>def encode(message):
vowels = "aeiou"
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])
<commit_msg>Fix bugs in encode.<commit_after>
def encode(message): | encode | 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])
| def check(candidate):
# Check some simple cases
assert candidate('TEST') == 'tgst', "This prints if this assert fails 1 (good for debugging!)"
assert candidate('Mudasir') == 'mWDCSKR', "This prints if this assert fails 2 (good for debugging!)"
assert candidate('YES') == 'ygs', "This prints if this assert fails 3 (good for debugging!)"
# Check some edge cases that are easy to work out by hand.
assert candidate('This is a message') == 'tHKS KS C MGSSCGG', "This prints if this assert fails 2 (also good for debugging!)"
assert candidate("I DoNt KnOw WhAt tO WrItE") == 'k dQnT kNqW wHcT Tq wRkTg', "This prints if this assert fails 2 (also good for debugging!)"
| [
"('TEST',)",
"('Mudasir',)",
"('YES',)",
"('This is a message',)",
"('I DoNt KnOw WhAt tO WrItE',)"
] | [
"tgst",
"mWDCSKR",
"ygs",
"tHKS KS C MGSSCGG",
"k dQnT kNqW wHcT Tq wRkTg"
] | python |
HumanEval/94 | <commit_before>def skjkasdkd(lst):
def isPrime(n):
for i in range(2,int(n**0.5)+1):
if n%i==0:
return True
return False
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
<commit_msg>Fix bugs in skjkasdkd.<commit_after>
def skjkasdkd(lst): | skjkasdkd | 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
| def check(candidate):
# Check some simple cases
assert candidate([0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3]) == 10, "This prints if this assert fails 1 (good for debugging!)"
# Check some edge cases that are easy to work out by hand.
assert candidate([1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1]) == 25, "This prints if this assert fails 2 (also good for debugging!)"
# Check some edge cases that are easy to work out by hand.
assert candidate([1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3]) == 13, "This prints if this assert fails 3 (also good for debugging!)"
# Check some edge cases that are easy to work out by hand.
assert candidate([0,724,32,71,99,32,6,0,5,91,83,0,5,6]) == 11, "This prints if this assert fails 4 (also good for debugging!)"
# Check some edge cases that are easy to work out by hand.
assert candidate([0,81,12,3,1,21]) == 3, "This prints if this assert fails 5 (also good for debugging!)"
# Check some edge cases that are easy to work out by hand.
assert candidate([0,8,1,2,1,7]) == 7, "This prints if this assert fails 6 (also good for debugging!)"
assert candidate([8191]) == 19, "This prints if this assert fails 7 (also good for debugging!)"
assert candidate([8191, 123456, 127, 7]) == 19, "This prints if this assert fails 8 (also good for debugging!)"
assert candidate([127, 97, 8192]) == 10, "This prints if this assert fails 9 (also good for debugging!)"
| [
"([0, 3, 2, 1, 3, 5, 7, 4, 5, 5, 5, 2, 181, 32, 4, 32, 3, 2, 32, 324, 4, 3],)",
"([1, 0, 1, 8, 2, 4597, 2, 1, 3, 40, 1, 2, 1, 2, 4, 2, 5, 1],)",
"([1, 3, 1, 32, 5107, 34, 83278, 109, 163, 23, 2323, 32, 30, 1, 9, 3],)",
"([0, 724, 32, 71, 99, 32, 6, 0, 5, 91, 83, 0, 5, 6],)",
"([0, 81, 12, 3, 1, 21],)",
"([0, 8, 1, 2, 1, 7],)",
"([8191],)",
"([8191, 123456, 127, 7],)",
"([127, 97, 8192],)"
] | [
"10",
"25",
"13",
"11",
"3",
"7",
"19",
"19",
"10"
] | python |
HumanEval/95 | <commit_before>def check_dict_case(dict):
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()) and (state == "lower" and not key.islower()):
state = "mixed"
break
else:
break
return state == "upper" or state == "lower"
<commit_msg>Fix bugs in check_dict_case.<commit_after>
def check_dict_case(dict): | check_dict_case | 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"
| def check(candidate):
# Check some simple cases
assert candidate({"p":"pineapple", "b":"banana"}) == True, "First test error: " + str(candidate({"p":"pineapple", "b":"banana"}))
assert candidate({"p":"pineapple", "A":"banana", "B":"banana"}) == False, "Second test error: " + str(candidate({"p":"pineapple", "A":"banana", "B":"banana"}))
assert candidate({"p":"pineapple", 5:"banana", "a":"apple"}) == False, "Third test error: " + str(candidate({"p":"pineapple", 5:"banana", "a":"apple"}))
assert candidate({"Name":"John", "Age":"36", "City":"Houston"}) == False, "Fourth test error: " + str(candidate({"Name":"John", "Age":"36", "City":"Houston"}))
assert candidate({"STATE":"NC", "ZIP":"12345" }) == True, "Fifth test error: " + str(candidate({"STATE":"NC", "ZIP":"12345" }))
assert candidate({"fruit":"Orange", "taste":"Sweet" }) == True, "Fourth test error: " + str(candidate({"fruit":"Orange", "taste":"Sweet" }))
# Check some edge cases that are easy to work out by hand.
assert candidate({}) == False, "1st edge test error: " + str(candidate({}))
| [
"({'p': 'pineapple', 'b': 'banana'},)",
"({'p': 'pineapple', 'A': 'banana', 'B': 'banana'},)",
"({'p': 'pineapple', 5: 'banana', 'a': 'apple'},)",
"({'Name': 'John', 'Age': '36', 'City': 'Houston'},)",
"({'STATE': 'NC', 'ZIP': '12345'},)",
"({'fruit': 'Orange', 'taste': 'Sweet'},)",
"({},)"
] | [
"True",
"False",
"False",
"False",
"True",
"True",
"False"
] | python |
HumanEval/96 | <commit_before>def count_up_to(n):
primes = []
for i in range(2, n):
is_prime = True
for j in range(2, i):
if j % i == 0:
is_prime = False
break
if is_prime:
primes.append(i)
return primes
<commit_msg>Fix bugs in count_up_to.<commit_after>
def count_up_to(n): | count_up_to | 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
| def check(candidate):
assert candidate(5) == [2,3]
assert candidate(6) == [2,3,5]
assert candidate(7) == [2,3,5]
assert candidate(10) == [2,3,5,7]
assert candidate(0) == []
assert candidate(22) == [2,3,5,7,11,13,17,19]
assert candidate(1) == []
assert candidate(18) == [2,3,5,7,11,13,17]
assert candidate(47) == [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43]
assert candidate(101) == [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]
| [
"(5,)",
"(6,)",
"(7,)",
"(10,)",
"(0,)",
"(22,)",
"(1,)",
"(18,)",
"(47,)",
"(101,)"
] | [
"[2, 3]",
"[2, 3, 5]",
"[2, 3, 5]",
"[2, 3, 5, 7]",
"[]",
"[2, 3, 5, 7, 11, 13, 17, 19]",
"[]",
"[2, 3, 5, 7, 11, 13, 17]",
"[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43]",
"[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]"
] | python |
HumanEval/97 | <commit_before>def multiply(a, b):
return abs(a % 10) * abs(b % 10) * a * b
<commit_msg>Fix bugs in multiply.<commit_after>
def multiply(a, b): | multiply | return abs(a % 10) * abs(b % 10)
| def check(candidate):
# Check some simple cases
assert candidate(148, 412) == 16, "First test error: " + str(candidate(148, 412))
assert candidate(19, 28) == 72, "Second test error: " + str(candidate(19, 28))
assert candidate(2020, 1851) == 0, "Third test error: " + str(candidate(2020, 1851))
assert candidate(14,-15) == 20, "Fourth test error: " + str(candidate(14,-15))
assert candidate(76, 67) == 42, "Fifth test error: " + str(candidate(76, 67))
assert candidate(17, 27) == 49, "Sixth test error: " + str(candidate(17, 27))
# Check some edge cases that are easy to work out by hand.
assert candidate(0, 1) == 0, "1st edge test error: " + str(candidate(0, 1))
assert candidate(0, 0) == 0, "2nd edge test error: " + str(candidate(0, 0))
| [
"(148, 412)",
"(19, 28)",
"(2020, 1851)",
"(14, -15)",
"(76, 67)",
"(17, 27)",
"(0, 1)",
"(0, 0)"
] | [
"16",
"72",
"0",
"20",
"42",
"49",
"0",
"0"
] | python |
HumanEval/98 | <commit_before>def count_upper(s):
count = 0
for i in range(0,len(s),2):
if s[i] in "AEIOU":
count += 2
return count
<commit_msg>Fix bugs in count_upper.<commit_after>
def count_upper(s): | count_upper | count = 0
for i in range(0,len(s),2):
if s[i] in "AEIOU":
count += 1
return count
| def check(candidate):
# Check some simple cases
assert candidate('aBCdEf') == 1
assert candidate('abcdefg') == 0
assert candidate('dBBE') == 0
assert candidate('B') == 0
assert candidate('U') == 1
assert candidate('') == 0
assert candidate('EEEE') == 2
# Check some edge cases that are easy to work out by hand.
assert True
| [
"('aBCdEf',)",
"('abcdefg',)",
"('dBBE',)",
"('B',)",
"('U',)",
"('',)",
"('EEEE',)"
] | [
"1",
"0",
"0",
"0",
"1",
"0",
"2"
] | python |
HumanEval/99 | <commit_before>def closest_integer(value):
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 = floor(num)
else:
res = ceil(num)
elif len(value) > 0:
res = int(round(num))
else:
res = 0
return res
<commit_msg>Fix bugs in closest_integer.<commit_after>
def closest_integer(value): | closest_integer | 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
| def check(candidate):
# Check some simple cases
assert candidate("10") == 10, "Test 1"
assert candidate("14.5") == 15, "Test 2"
assert candidate("-15.5") == -16, "Test 3"
assert candidate("15.3") == 15, "Test 3"
# Check some edge cases that are easy to work out by hand.
assert candidate("0") == 0, "Test 0"
| [
"('10',)",
"('14.5',)",
"('-15.5',)",
"('15.3',)",
"('0',)"
] | [
"10",
"15",
"-16",
"15",
"0"
] | python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.