{"input":[{"id":"dcff8346","content":"Read the following function signature and docstring, and fully implement the function described. Your response should only contain the code for this function.\nfrom typing import List\n\n\ndef has_close_elements(numbers: List[float], threshold: f ... [TRUNCATED] ... Check if in given list of numbers, are any two numbers closer to each other than\n given threshold.\n >>> has_close_elements([1.0, 2.0, 3.0], 0.5)\n False\n >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)\n True\n \"\"\"\n"}],"target":"\n\n sorted_numbers = sorted(numbers)\n for i in range(len(sorted_numbers) - 1):\n if sorted_numbers[i + 1] - sorted_numbers[i] < threshold:\n return True\n return False\n\n","id":0,"group_id":0,"metadata":{"task_id":"HumanEval/0","entry_point":"has_close_elements","prompt":"from typing import List\n\n\ndef has_close_elements(numbers: List[float], threshold: float) -> bool:\n \"\"\" Check if in given list of numbers, are any two numbers closer to each other than\n given threshold.\n >>> has_close_elements([1.0, 2.0, 3.0], 0.5)\n False\n >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)\n True\n \"\"\"\n","test":"\n\nimport numpy as np\n\ndef is_floats(x) -> bool:\n # check if it is float; List[float]; Tuple[float]\n if isinstance(x, float):\n return True\n if isinstance(x, (list, tuple)):\n return all(isinstance(i, float) for i in x)\n ... [TRUNCATED] ... True, True, True, True, True, True, True, True, True, False, True, True, True, True, True, True, True, True, True, True, False, True, True]\n for i, (inp, exp) in enumerate(zip(inputs, results)):\n assertion(candidate(*inp), exp, 0)\n"}}
注:部分内容因展示需要已被截断。
提示模板
提示模板:
Read the following function signature and docstring, and fully implement the function described. Your response should only contain the code for this function.
{question}