src_lang null | solution stringlengths 132 1.99k | compare_func stringclasses 1 value | demos sequencelengths 0 8 | entry_func stringlengths 1 30 | suffix stringclasses 1 value | import_str sequencelengths 0 1 | doc_string stringlengths 0 1.07k | task_name stringclasses 1 value | dataset_name stringclasses 1 value | tgt_lang stringclasses 1 value | test_cases sequencelengths 12 1.1k ⌀ | data_id stringlengths 11 13 | prefix stringlengths 115 1.36k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
null | from typing import List
def has_close_elements(numbers: List[float], threshold: float) -> bool:
""" Check if in given list of numbers, are any two numbers closer to each other than
given threshold.
>>> has_close_elements([1.0, 2.0, 3.0], 0.5)
False
>>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)
True
"""
for idx, elem in enumerate(numbers):
for idx2, elem2 in enumerate(numbers):
if idx != idx2:
distance = abs(elem - elem2)
if distance < threshold:
return True
return False
|
import numpy as np
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == np.float64 or x.dtype == np.float32
return False
def assertion(out, exp, atol):
exact_match = out == exp
if atol == 0 and is_floats(exp):
atol = 1e-6
if not exact_match and atol != 0:
assert np.allclose(out, exp, rtol=1e-07, atol=atol)
else:
assert exact_match
| [
[
"[1.0, 2.0, 3.0], 0.5",
"False"
],
[
"[1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3",
"True"
]
] | has_close_elements | [
"from typing import List"
] | Check if in given list of numbers, are any two numbers closer to each other than given threshold. | code_generation | HumanEval_plus | python | [
[
"[1.0, 2.0, 3.9, 4.0, 5.0, 2.2], 0.3",
"True"
],
[
"[1.0, 2.0, 3.9, 4.0, 5.0, 2.2], 0.05",
"False"
],
[
"[1.0, 2.0, 5.9, 4.0, 5.0], 0.95",
"True"
],
[
"[1.0, 2.0, 5.9, 4.0, 5.0], 0.8",
"False"
],
[
"[1.0, 2.0, 3.0, 4.0, 5.0, 2.0], 0.1",
"True"
],
[
"... | HumanEval/0 | from typing import List
def has_close_elements(numbers: List[float], threshold: float) -> bool:
""" Check if in given list of numbers, are any two numbers closer to each other than
given threshold.
>>> has_close_elements([1.0, 2.0, 3.0], 0.5)
False
>>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)
True
"""
| |
null | from typing import List
def separate_paren_groups(paren_string: str) -> List[str]:
""" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
separate those group into separate strings and return the list of those.
Separate groups are balanced (each open brace is properly closed) and not nested within each other
Ignore any spaces in the input string.
>>> separate_paren_groups('( ) (( )) (( )( ))')
['()', '(())', '(()())']
"""
result = []
current_string = []
current_depth = 0
for c in paren_string:
if c == '(':
current_depth += 1
current_string.append(c)
elif c == ')':
current_depth -= 1
current_string.append(c)
if current_depth == 0:
result.append(''.join(current_string))
current_string.clear()
return result
|
import numpy as np
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == np.float64 or x.dtype == np.float32
return False
def assertion(out, exp, atol):
exact_match = out == exp
if atol == 0 and is_floats(exp):
atol = 1e-6
if not exact_match and atol != 0:
assert np.allclose(out, exp, rtol=1e-07, atol=atol)
else:
assert exact_match
| [
[
"'( ) (( )) (( )( ))'",
"['()', '(())', '(()())']"
]
] | separate_paren_groups | [
"from typing import List"
] | Input to this function is a string containing multiple groups of nested parentheses. Your goal is to separate those group into separate strings and return the list of those. Separate groups are balanced (each open brace is properly closed) and not nested within each other Ignore any spaces in the input string. | code_generation | HumanEval_plus | python | [
[
"(()()) ((())) () ((())()())",
"['(()())', '((()))', '()', '((())()())']"
],
[
"() (()) ((())) (((())))",
"['()', '(())', '((()))', '(((())))']"
],
[
"(()(())((())))",
"['(()(())((())))']"
],
[
"( ) (( )) (( )( ))",
"['()', '(())', '(()())']"
],
[
"()",
"['(... | HumanEval/1 | from typing import List
def separate_paren_groups(paren_string: str) -> List[str]:
""" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
separate those group into separate strings and return the list of those.
Separate groups are balanced (each open brace is properly closed) and not nested within each other
Ignore any spaces in the input string.
>>> separate_paren_groups('( ) (( )) (( )( ))')
['()', '(())', '(()())']
"""
| |
null |
def truncate_number(number: float) -> float:
""" Given a positive floating point number, it can be decomposed into
and integer part (largest integer smaller than given number) and decimals
(leftover part always smaller than 1).
Return the decimal part of the number.
>>> truncate_number(3.5)
0.5
"""
return number % 1.0
|
import numpy as np
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == np.float64 or x.dtype == np.float32
return False
def assertion(out, exp, atol):
exact_match = out == exp
if atol == 0 and is_floats(exp):
atol = 1e-6
if not exact_match and atol != 0:
assert np.allclose(out, exp, rtol=1e-07, atol=atol)
else:
assert exact_match
| [
[
"3.5",
"0.5"
]
] | truncate_number | [] | Given a positive floating point number, it can be decomposed into and integer part (largest integer smaller than given number) and decimals (leftover part always smaller than 1). Return the decimal part of the number. | code_generation | HumanEval_plus | python | [
[
"3.5",
"0.5"
],
[
"1.33",
"0.33000000000000007"
],
[
"123.456",
"0.45600000000000307"
],
[
"999.99999",
"0.9999900000000252"
],
[
"0.3333333",
"0.3333333"
],
[
"1.0",
"0.0"
],
[
"1.5",
"0.5"
],
[
"0.5",
"0.5"
],
[
... | HumanEval/2 |
def truncate_number(number: float) -> float:
""" Given a positive floating point number, it can be decomposed into
and integer part (largest integer smaller than given number) and decimals
(leftover part always smaller than 1).
Return the decimal part of the number.
>>> truncate_number(3.5)
0.5
"""
| |
null | "from typing import List\n\n\ndef below_zero(operations: List[int]) -> bool:\n \"\"\" You're give(...TRUNCATED) | "\nimport numpy as np\n\ndef is_floats(x) -> bool:\n # check if it is float; List[float]; Tuple[f(...TRUNCATED) | [
[
"[1, 2, 3]",
"False"
],
[
"[1, 2, -4, 5]",
"True"
]
] | below_zero | [
"from typing import List"
] | " You're given a list of deposit and withdrawal operations on a bank account that starts with zero b(...TRUNCATED) | code_generation | HumanEval_plus | python | [["[]","False"],["[1, 2, -3, 1, 2, -3]","False"],["[1, 2, -4, 5, 6]","True"],["[1, -1, 2, -2, 5, -5,(...TRUNCATED) | HumanEval/3 | "from typing import List\n\n\ndef below_zero(operations: List[int]) -> bool:\n \"\"\" You're give(...TRUNCATED) | |
null | "from typing import List\n\n\ndef mean_absolute_deviation(numbers: List[float]) -> float:\n \"\"\(...TRUNCATED) | "\nimport numpy as np\n\ndef is_floats(x) -> bool:\n # check if it is float; List[float]; Tuple[f(...TRUNCATED) | [
[
"[1.0, 2.0, 3.0, 4.0]",
"1.0"
]
] | mean_absolute_deviation | [
"from typing import List"
] | " For a given list of input numbers, calculate Mean Absolute Deviation around the mean of this datas(...TRUNCATED) | code_generation | HumanEval_plus | python | [["[1.0, 2.0, 3.0]","0.6666666666666666"],["[1.0, 2.0, 3.0, 4.0]","1.0"],["[1.0, 2.0, 3.0, 4.0, 5.0](...TRUNCATED) | HumanEval/4 | "from typing import List\n\n\ndef mean_absolute_deviation(numbers: List[float]) -> float:\n \"\"\(...TRUNCATED) | |
null | "from typing import List\n\n\ndef intersperse(numbers: List[int], delimeter: int) -> List[int]:\n (...TRUNCATED) | "\nimport numpy as np\n\ndef is_floats(x) -> bool:\n # check if it is float; List[float]; Tuple[f(...TRUNCATED) | [
[
"[], 4",
"[]"
],
[
"[1, 2, 3], 4",
"[1, 4, 2, 4, 3]"
]
] | intersperse | [
"from typing import List"
] | Insert a number 'delimeter' between every two consecutive elements of input list `numbers' | code_generation | HumanEval_plus | python | [["[], 7","[]"],["[5, 6, 3, 2], 8","[5, 8, 6, 8, 3, 8, 2]"],["[2, 2, 2], 2","[2, 2, 2, 2, 2]"],["[1,(...TRUNCATED) | HumanEval/5 | "from typing import List\n\n\ndef intersperse(numbers: List[int], delimeter: int) -> List[int]:\n (...TRUNCATED) | |
null | "from typing import List\n\n\ndef parse_nested_parens(paren_string: str) -> List[int]:\n \"\"\" I(...TRUNCATED) | "\nimport numpy as np\n\ndef is_floats(x) -> bool:\n # check if it is float; List[float]; Tuple[f(...TRUNCATED) | [
[
"'(()()) ((())) () ((())()())'",
"[2, 3, 1, 3]"
]
] | parse_nested_parens | [
"from typing import List"
] | " Input to this function is a string represented multiple groups for nested parentheses separated by(...TRUNCATED) | code_generation | HumanEval_plus | python | [["(()()) ((())) () ((())()())","[2, 3, 1, 3]"],["() (()) ((())) (((())))","[1, 2, 3, 4]"],["(()(())(...TRUNCATED) | HumanEval/6 | "from typing import List\n\n\ndef parse_nested_parens(paren_string: str) -> List[int]:\n \"\"\" I(...TRUNCATED) | |
null | "from typing import List\n\n\ndef filter_by_substring(strings: List[str], substring: str) -> List[st(...TRUNCATED) | "\nimport numpy as np\n\ndef is_floats(x) -> bool:\n # check if it is float; List[float]; Tuple[f(...TRUNCATED) | [
[
"[], 'a'",
"[]"
],
[
"['abc', 'bacd', 'cde', 'array'], 'a'",
"['abc', 'bacd', 'array']"
]
] | filter_by_substring | [
"from typing import List"
] | Filter an input list of strings only for ones that contain given substring | code_generation | HumanEval_plus | python | [["[], john","[]"],["['xxx', 'asd', 'xxy', 'john doe', 'xxxAAA', 'xxx'], xxx","['xxx', 'xxxAAA', 'xx(...TRUNCATED) | HumanEval/7 | "from typing import List\n\n\ndef filter_by_substring(strings: List[str], substring: str) -> List[st(...TRUNCATED) | |
null | "from typing import List, Tuple\n\n\ndef sum_product(numbers: List[int]) -> Tuple[int, int]:\n \"(...TRUNCATED) | "\nimport numpy as np\n\ndef is_floats(x) -> bool:\n # check if it is float; List[float]; Tuple[f(...TRUNCATED) | [
[
"[]",
"(0, 1)"
],
[
"[1, 2, 3, 4]",
"(10, 24)"
]
] | sum_product | [
"from typing import List, Tuple"
] | " For a given list of integers, return a tuple consisting of a sum and a product of all the integers(...TRUNCATED) | code_generation | HumanEval_plus | python | [["[]","(0, 1)"],["[1, 1, 1]","(3, 1)"],["[100, 0]","(100, 0)"],["[3, 5, 7]","(15, 105)"],["[10]","((...TRUNCATED) | HumanEval/8 | "from typing import List, Tuple\n\n\ndef sum_product(numbers: List[int]) -> Tuple[int, int]:\n \"(...TRUNCATED) | |
null | "from typing import List, Tuple\n\n\ndef rolling_max(numbers: List[int]) -> List[int]:\n \"\"\" F(...TRUNCATED) | "\nimport numpy as np\n\ndef is_floats(x) -> bool:\n # check if it is float; List[float]; Tuple[f(...TRUNCATED) | [
[
"[1, 2, 3, 2, 3, 4, 2]",
"[1, 2, 3, 3, 3, 4, 4]"
]
] | rolling_max | [
"from typing import List, Tuple"
] | " From a given list of integers, generate a list of rolling maximum element found until given moment(...TRUNCATED) | code_generation | HumanEval_plus | python | [["[]","[]"],["[1, 2, 3, 4]","[1, 2, 3, 4]"],["[4, 3, 2, 1]","[4, 4, 4, 4]"],["[3, 2, 3, 100, 3]","[(...TRUNCATED) | HumanEval/9 | "from typing import List, Tuple\n\n\ndef rolling_max(numbers: List[int]) -> List[int]:\n \"\"\" F(...TRUNCATED) |
End of preview. Expand
in Data Studio
README.md exists but content is empty.
- Downloads last month
- 4