[代码大模型]MHPP: Exploring the Capabilities and Limitations of Language Models Beyond Basic Code Generat

Abstract (translated)

近年来,大型语言模型(LLMs)的进步在代码生成方面大大提高了性能,尤其是在功能级别。例如,GPT-4在HumanEval上的通过率为88.4%。然而,这引发了质疑现有基准在全面评估功能级别代码生成能力方面的充分性。我们的研究分析了两个常见的基准,HumanEval和MBPP,并发现,由于质量、难度和粒度等方面的限制,这些基准可能无法充分评估LLMs的代码生成能力。为解决这个问题,我们引入了主要由人类编写的M Mostly Hard Python Problems(MHPP)数据集,包括140个独特的由人类编写的独特问题。通过关注自然语言和代码推理的结合,MHPP衡量了LLMs理解规范和限制、进行多步推理以及有效应用编程知识的能力。使用MHPP评估22个LLM后,许多在HumanEval上表现优秀的模型在MHPP上未能取得类似的成功。此外,MHPP揭示了各种LLM中 previously未被发现的问题,使我们相信,它可能为更好地理解LLMs的能力和限制铺平道路。数据集和代码可在此链接下载:https://www.aclweb.org/anthology/H2022-10203176/

这篇论文名为“MHPP: Exploring the Capabilities and Limitations of Language Models Beyond Basic Code Generation”,主要探讨了大语言模型(LLMs)在基本代码生成之外的能力和局限性。

主要内容

  1. 研究背景

    • 近年来,LLMs在代码生成方面取得了显著进展,例如GPT-4在HumanEval基准测试中达到了88.4%的通过率
    • 现有的基准测试,如HumanEval和MBPP,可能无法充分评估LLMs在函数级别代码生成方面的能力,因为这些测试在质量、难度和细粒度上存在局限。
  2. 研究目的

    • 为了更全面地评估LLMs的代码生成能力,作者引入了Mostly Hard Python Problems (MHPP)数据集。该数据集包含140个独特的人工策划问题,专注于自然语言和代码推理的结合,以评估LLMs理解规范和限制、多步骤推理和应用编码知识的能力。
  3. 数据集分析

    • 对现有基准测试HumanEval和MBPP进行了深入的手动分析,发现这些基准测试在数据污染、质量、分布和难度级别方面存在问题,可能影响LLMs代码生成能力的可靠评估。
    • MBPP存在数据污染问题,65.4%的实例被发现是从开放访问网站上直接收集的,这使得模型能够通过记忆测试数据“作弊”。
    • HumanEval存在问题类型和难度分布不平衡的问题,导致难以全面评估LLMs的能力。
  4. MHPP数据集

    • MHPP数据集包含140个独特的Python编程问题,每个问题都附有单元测试,旨在全面评估LLMs在代码生成方面的各种挑战。
    • 这些挑战包括处理自然语言输入的变化、理解新定义的上下文、展示常识、应对边界情况、遵循复杂指令、使用数学和算法知识以及熟悉编码原则。
  5. 实验评估

    • 使用MHPP数据集对22个LLMs进行了广泛评估,揭示了许多之前未发现的局限性和模型在处理代码生成任务时的不同弱点。
    • 尤其是在需要高级算法推理的挑战中,模型表现出了较大的困难。
  6. 结论

    • MHPP数据集有效地测试了模型在多样化代码生成挑战中的表现,提供了更深入理解LLMs能力和局限性的途径。
    • 希望MHPP能够成为推进代码生成领域,尤其是在算法推理方面的基石。

结论

通过引入MHPP数据集,作者展示了现有基准测试在评估LLMs代码生成能力方面的不足,并提供了一个更全面的评估框架。MHPP数据集的建立和实验评估揭示了LLMs在多步骤推理和高级算法应用中的局限性,为未来的研究提供了重要的参考。

样题:

{"id": 1, "difficulty_types": 1, "question": "def table_tennis_results(marks: str) -> int:\n    \"\"\"Adham Sharara was elected as the sixth President of the International Table Tennis Federation(ITTF) in 1999.\n    Under his leadership, the ITTF underwent several reforms in the table tennis events to promote the sport globally.\n    For instance, they changed the scoring system from the 21-point format to an 11-point format. Since then, matches\n    have been played with an 11-point system, with a requirement of achieving a two-point lead upon reaching 11 points.\n\n\tRecently, Alice and Bob had a table tennis match. The match progress is represented by a string composed of 'A's \n\tfor Alice's points and 'B's for Bob's points. Please analyze the scores of each game and determine who is currently\n    leading overall. If Alice is leading, output 1; if Bob is leading, output -1; if they are tied, output 0.\n    >>> table_tennis_results(\"AAAAAAAAAAA\")\n    1\n    >>> table_tennis_results(\"BBBAAABABABABAAAAABBBBBB\")\n    1\n    >>> table_tennis_results(\"BBBAAABABABABAAAAABABABABAAAABBBABABABBAABBABB\")\n    0\n    >>> table_tennis_results(\"BBBAAABABABABAAAAABBBBBBBBBBBB\")\n    -1\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\ndef table_tennis_results(marks: str) -> int:\n    \"\"\"Adham Sharara was elected as the sixth President of the International Table Tennis Federation(ITTF) in 1999.\n    Under his leadership, the ITTF underwent several reforms in the table tennis events to promote the sport globally.\n    For instance, they changed the scoring system from the 21-point format to an 11-point format. Since then, matches\n    have been played with an 11-point system, with a requirement of achieving a two-point lead upon reaching 11 points.\n\n\tRecently, Alice and Bob had a table tennis match. The match progress is represented by a string composed of 'A's \n\tfor Alice's points and 'B's for Bob's points. Please analyze the scores of each game and determine who is currently\n    leading overall. If Alice is leading, output 1; if Bob is leading, output -1; if they are tied, output 0.\n    >>> table_tennis_results(\"AAAAAAAAAAA\")\n    1\n    >>> table_tennis_results(\"BBBAAABABABABAAAAABBBBBB\")\n    1\n    >>> table_tennis_results(\"BBBAAABABABABAAAAABABABABAAAABBBABABABBAABBABB\")\n    0\n    >>> table_tennis_results(\"BBBAAABABABABAAAAABBBBBBBBBBBB\")\n    -1\n    \"\"\"", "function_name": "table_tennis_results", "parameters": ["marks"], "assert_statements": ["assert table_tennis_results(\"AAAAABBAAA\") == 1", "assert table_tennis_results(\"ABABABBBAA\") ==  0", "assert table_tennis_results(\"AAAAAAAAAAABBBBBBBBBBB\") == 0"]}
{"id": 2, "difficulty_types": 1, "question": "from typing import List\n\ndef expectation_number(scores: List[int]) -> int:\n    \"\"\"The annual spring recruitment has begun at an internet company, and a total of n candidates have been selected.\n    Each candidate submits a resume, and the company generates an estimated ability value based on the provided resume\n    information, where a higher numerical value indicates a higher likelihood of passing the interview.\n\n    Alice and Bob are responsible for reviewing the candidates. They each have all the resumes and will review them in\n    descending order of the candidates' ability values. Since the resumes have been shuffled in advance, the order of\n    appearance of resumes with the same ability values is taken uniformly at random from their permutations.\n\n    Now, given the ability values of n candidates as scores, let X represent the number of resumes that appear at the\n    same position in the review order of both Alice and Bob. Calculate the expected value of X.\n\n    Hint: The formula for calculating the expected value of a discrete non-negative random variable is shown below:\n    E(X) = sum([k * probability_of_k for k in list])\n    >>> expectation_number([1, 2, 3, 4])\n    4\n    >>> expectation_number([1, 1, 2])\n    2\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef expectation_number(scores: List[int]) -> int:\n    \"\"\"The annual spring recruitment has begun at an internet company, and a total of n candidates have been selected.\n    Each candidate submits a resume, and the company generates an estimated ability value based on the provided resume\n    information, where a higher numerical value indicates a higher likelihood of passing the interview.\n\n    Alice and Bob are responsible for reviewing the candidates. They each have all the resumes and will review them in\n    descending order of the candidates' ability values. Since the resumes have been shuffled in advance, the order of\n    appearance of resumes with the same ability values is taken uniformly at random from their permutations.\n\n    Now, given the ability values of n candidates as scores, let X represent the number of resumes that appear at the\n    same position in the review order of both Alice and Bob. Calculate the expected value of X.\n\n    Hint: The formula for calculating the expected value of a discrete non-negative random variable is shown below:\n    E(X) = sum([k * probability_of_k for k in list])\n    >>> expectation_number([1, 2, 3, 4])\n    4\n    >>> expectation_number([1, 1, 2])\n    2\n    \"\"\"", "function_name": "expectation_number", "parameters": ["scores"], "assert_statements": ["assert expectation_number([1, 2, 3]) == 3", "assert expectation_number([37, 82, 19, 53, 65, 7, 91, 14, 46, 28]) == 10", "assert expectation_number([3, 2, 9, 3, 5, 7, 1, 4, 6, 8]) == 9"]}
{"id": 3, "difficulty_types": 1, "question": "from typing import List\n\ndef get_maximum_capital(n: int, c: int, profits: List[int], capital: List[int]) -> int:\n    \"\"\"As AI products like ChatGPT become popular worldwide, many artificial intelligence companies are eager\n    to try their luck. One company is about to start an IPO, and in order to sell its stocks to venture capital \n    firms at a higher price, the company wants to undertake some projects before the IPO to increase its capital.\n    Due to limited resources, it can only complete up to n different projects before the IPO. Help the company\n    design a way to complete at most n different projects after which it can obtain the maximum total capital.\n\n    You are given m projects. For each project i, it has a net profit profits[i] and the minimum capital capital[i]\n    required to start the project.\n\n    Initially, your capital is c. When you complete a project, you will gain the net profit, and the profit will \n    be added to your total capital.\n\n    In summary, choose a list of up to n different projects from the given projects to maximize the final capital,\n    and output the maximum capital that can be obtained in the end.\n    >>> get_maximum_capital(3, 0, [1,2,3], [0,1,2])\n    6\n    >>> get_maximum_capital(2, 0, [1,2,3], [0,1,1])\n    4\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef get_maximum_capital(n: int, c: int, profits: List[int], capital: List[int]) -> int:\n    \"\"\"As AI products like ChatGPT become popular worldwide, many artificial intelligence companies are eager\n    to try their luck. One company is about to start an IPO, and in order to sell its stocks to venture capital \n    firms at a higher price, the company wants to undertake some projects before the IPO to increase its capital.\n    Due to limited resources, it can only complete up to n different projects before the IPO. Help the company\n    design a way to complete at most n different projects after which it can obtain the maximum total capital.\n\n    You are given m projects. For each project i, it has a net profit profits[i] and the minimum capital capital[i]\n    required to start the project.\n\n    Initially, your capital is c. When you complete a project, you will gain the net profit, and the profit will \n    be added to your total capital.\n\n    In summary, choose a list of up to n different projects from the given projects to maximize the final capital,\n    and output the maximum capital that can be obtained in the end.\n    >>> get_maximum_capital(3, 0, [1,2,3], [0,1,2])\n    6\n    >>> get_maximum_capital(2, 0, [1,2,3], [0,1,1])\n    4\n    \"\"\"", "function_name": "get_maximum_capital", "parameters": ["n", "c", "profits", "capital"], "assert_statements": ["assert get_maximum_capital(5, 1, [1,2,3,4,5], [0,1,1,2,3]) == 16", "assert get_maximum_capital(7, 3, [1,2,3,4,2], [1,1,2,3,2]) == 15", "assert get_maximum_capital(10, 2, [10,4,2,4,1,2,3,4,2], [8,2,1,3,2,1,4,3,2]) == 34"]}
{"id": 4, "difficulty_types": 1, "question": "def least_goods_number(n: int) -> int:\n    \"\"\"Given a list of products where the first column represents the product name and the second column\n    represents the product price. You have n dollers, please calculate and return the minimum number of products\n    required to spend the total amount exactly. If no combination of products can add up to the total amount,\n    return -1. You can assume that the quantity of each product is unlimited.\n    +---------------+---------------+\n    |     Milk      |       2       |\n    |---------------|---------------|\n    |     Soap      |       3       |\n    |---------------|---------------|\n    |   Batteries   |       5       |\n    |---------------|---------------|\n    |     Eggs      |       1       |\n    +---------------+---------------+\n    >>> least_goods_number(11)\n    3\n    >>> least_goods_number(5)\n    1\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\ndef least_goods_number(n: int) -> int:\n    \"\"\"Given a list of products where the first column represents the product name and the second column\n    represents the product price. You have n dollers, please calculate and return the minimum number of products\n    required to spend the total amount exactly. If no combination of products can add up to the total amount,\n    return -1. You can assume that the quantity of each product is unlimited.\n    +---------------+---------------+\n    |     Milk      |       2       |\n    |---------------|---------------|\n    |     Soap      |       3       |\n    |---------------|---------------|\n    |   Batteries   |       5       |\n    |---------------|---------------|\n    |     Eggs      |       1       |\n    +---------------+---------------+\n    >>> least_goods_number(11)\n    3\n    >>> least_goods_number(5)\n    1\n    \"\"\"", "function_name": "least_goods_number", "parameters": ["n"], "assert_statements": ["assert least_goods_number(599) == 121", "assert least_goods_number(10000) == 2000", "assert least_goods_number(17) == 4"]}
{"id": 5, "difficulty_types": 1, "question": "from typing import List\n\ndef arrange_ark_pairs(ark_deck: List[int]) -> int:\n    \"\"\"Legend tells of a great Ark built by Noah to survive an immense flood that would cover the Earth.\n    To preserve the natural world, Noah invited animals to join him on the Ark, inviting them in pairs so\n    that each species could continue in the new world.\n\n    As the animals boarded the Ark, they were assigned places in a linear formation across the Ark's deck.\n    However, in the rush to board before the rain began, the animal pairs became separated across the 2n available spaces.\n    Each animal is known by a unique identifier, and the list of these identifiers as they are arranged on the Ark\n    is given by an integer array `arkDeck` where `arkDeck[i]` represents the animal occupying the ith space.\n    The pairs were meant to board in order, with the first pair being (0, 1), the second pair (2, 3), and so on,\n    up to the last pair being (2n - 2, 2n - 1).\n\n    Your task is to help Noah figure out the minimum number of exchanges necessary to reposition the animals so that\n    each pair is resting side by side. An exchange is the act of two animals, regardless of their species, standing\n    up from their places and switching spots on the deck.\n    >>> arrange_ark_pairs([0,1,3,2])\n    0\n    >>> arrange_ark_pairs([0,3,2,1])\n    1\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef arrange_ark_pairs(ark_deck: List[int]) -> int:\n    \"\"\"Legend tells of a great Ark built by Noah to survive an immense flood that would cover the Earth.\n    To preserve the natural world, Noah invited animals to join him on the Ark, inviting them in pairs so\n    that each species could continue in the new world.\n\n    As the animals boarded the Ark, they were assigned places in a linear formation across the Ark's deck.\n    However, in the rush to board before the rain began, the animal pairs became separated across the 2n available spaces.\n    Each animal is known by a unique identifier, and the list of these identifiers as they are arranged on the Ark\n    is given by an integer array `arkDeck` where `arkDeck[i]` represents the animal occupying the ith space.\n    The pairs were meant to board in order, with the first pair being (0, 1), the second pair (2, 3), and so on,\n    up to the last pair being (2n - 2, 2n - 1).\n\n    Your task is to help Noah figure out the minimum number of exchanges necessary to reposition the animals so that\n    each pair is resting side by side. An exchange is the act of two animals, regardless of their species, standing\n    up from their places and switching spots on the deck.\n    >>> arrange_ark_pairs([0,1,3,2])\n    0\n    >>> arrange_ark_pairs([0,3,2,1])\n    1\n    \"\"\"", "function_name": "arrange_ark_pairs", "parameters": ["ark_deck"], "assert_statements": ["assert arrange_ark_pairs([0,6,7,3,2,1,4,5]) == 2", "assert arrange_ark_pairs([0,6,7,3,2,8,9,10,11,1,4,5]) == 4", "assert arrange_ark_pairs([0,6,13,14,15,8,7,3,2,4,21,5,19,20,10,11,1,16,17,18,12,9]) == 8"]}
{"id": 6, "difficulty_types": 1, "question": "def artemis_game(beta: int, theta: int, upperBound: int) -> float:\n    \"\"\"\n    Artemis, engages in a strategic computational challenge.\n\n    Initiating with a tally of zero, Artemis partakes in sequential computational operations with the aim to accumulate a numerical aggregate less than a predefined threshold, denoted by the variable theta. Throughout each computational cycle, Artemis is awarded a quantified increment, discretely and uniformly distributed, within the confines of [1, upperBound], where upperBound defines the maximum achievable singular increment and is a fixed integer value. It is of importance to note that each operation occurs autonomously and the potential outcomes are equitably probable.\n\n    The process of numerical acquisition is suspended when Artemis' aggregate meets or exceeds the marker theta.\n\n    The objective is to assess the likelihood that Artemis concludes these operations possessing a tally not surpassing beta.\n\n    Estimations deviating from the true likelihood by no more than a margin of 10^-5 are deemed satisfactory.\n\n    >>> artemis_game(10, 1, 10)\n    1.00000\n    Rationale: Artemis completes a solitary computational operation and ceases further actions.\n    >>> artemis_game(6, 1, 10)\n    0.60000\n    Rationale: Artemis finalizes a solitary computational operation and refrains from continuing.\n    In 6 out of the 10 equitable scenarios, Artemis' score is confined to or less than 6 points.\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\ndef artemis_game(beta: int, theta: int, upperBound: int) -> float:\n    \"\"\"\n    Artemis, engages in a strategic computational challenge.\n\n    Initiating with a tally of zero, Artemis partakes in sequential computational operations with the aim to accumulate a numerical aggregate less than a predefined threshold, denoted by the variable theta. Throughout each computational cycle, Artemis is awarded a quantified increment, discretely and uniformly distributed, within the confines of [1, upperBound], where upperBound defines the maximum achievable singular increment and is a fixed integer value. It is of importance to note that each operation occurs autonomously and the potential outcomes are equitably probable.\n\n    The process of numerical acquisition is suspended when Artemis' aggregate meets or exceeds the marker theta.\n\n    The objective is to assess the likelihood that Artemis concludes these operations possessing a tally not surpassing beta.\n\n    Estimations deviating from the true likelihood by no more than a margin of 10^-5 are deemed satisfactory.\n\n    >>> artemis_game(10, 1, 10)\n    1.00000\n    Rationale: Artemis completes a solitary computational operation and ceases further actions.\n    >>> artemis_game(6, 1, 10)\n    0.60000\n    Rationale: Artemis finalizes a solitary computational operation and refrains from continuing.\n    In 6 out of the 10 equitable scenarios, Artemis' score is confined to or less than 6 points.\n    \"\"\"", "function_name": "artemis_game", "parameters": ["beta", "theta", "upperBound"], "assert_statements": ["assert abs((artemis_game(10, 1, 10) - 1.00000)) < 10 ** -5", "assert abs((artemis_game(6, 1, 10) - 0.60000)) < 10 ** -5", "assert abs((artemis_game(21, 17, 10) - 0.73278)) < 10 ** -5"]}
{"id": 7, "difficulty_types": 1, "question": "from typing import List\n\nclass UnionFind(object):\n    def __init__(self, names):\n        self.parent = {}\n        for name in names:\n            self.parent[name] = name\n\n    def union(self, a, b):\n        if a not in self.parent:\n            self.parent[a] = a\n        if b not in self.parent:\n            self.parent[b] = b\n        root_a = self.find_root(a)\n        root_b = self.find_root(b)\n        if root_a < root_b:\n            self.parent[root_b] = root_a\n        else:\n            self.parent[root_a] = root_b\n\n    def find_root(self, node):\n        while node != self.parent[node]:\n            self.parent[node] = self.parent[self.parent[node]]\n            node = self.parent[node]\n        return node\n\ndef popular_names(names: List[str], synonyms: List[str]) -> List[str]:\n    \"\"\"\n    Each year, the national statistics agency releases a list of the 10,000 most commonly chosen names for new babies, along with the frequency of each name's use. While variations in spelling can make certain names seem different, they may indeed refer to the same moniker. For instance, \"Aiden\" and \"Aidan\" are treated as separate entries in the statistics, even though they actually stem from the same name.\n\n    Given two datasets - one featuring names and their popularity, the other containing pairs of names deemed to be versions of the same underlying name - we wish to devise a method to effectively compute and present the cumulative frequency of each distinct name. This requires that we account for the fact that name equivalency is both transitive and symmetrical. This means that if \"Aiden\" is equivalent to \"Aidan\" and \"Aidan\" is deemed identical to \"Ayden\" then \"Aiden\" and \"Ayden\" must also be considered the same.\n\n    In the resulting list, choose the lexicographically smallest name as the representative for the true name.\n\n    In developing this procedure, we must ensure a systematic approach that can handle the numerous relations between equivalent names and their different spellings. By accounting for these equivalences, a name's total frequency could potentially be much different than what's indicated in the raw newborn name statistics. Thus, this method should more accurately reflect the true popularity of distinct names.\n\n    >>> popular_names([\"Aiden(10)\",\"Aidan(5)\",\"Alex(20)\",\"Lex(2)\",\"Alexander(30)\"], [\"(Aidan,Aiden)\",\"(Aiden,Ayden)\",\"(Alex,Lex)\",\"(Alex,Alexander)\"])\n    [\"Aiden(15)\",\"Alex(52)\"]\n    >>> popular_names([\"John(15)\",\"Jon(12)\",\"Chris(13)\",\"Kris(4)\",\"Christopher(19)\"], [\"(Jon,John)\",\"(John,Johnny)\",\"(Chris,Kris)\",\"(Chris,Christopher)\"])\n    [\"John(27)\",\"Chris(36)\"]\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\nclass UnionFind(object):\n    def __init__(self, names):\n        self.parent = {}\n        for name in names:\n            self.parent[name] = name\n\n    def union(self, a, b):\n        if a not in self.parent:\n            self.parent[a] = a\n        if b not in self.parent:\n            self.parent[b] = b\n        root_a = self.find_root(a)\n        root_b = self.find_root(b)\n        if root_a < root_b:\n            self.parent[root_b] = root_a\n        else:\n            self.parent[root_a] = root_b\n\n    def find_root(self, node):\n        while node != self.parent[node]:\n            self.parent[node] = self.parent[self.parent[node]]\n            node = self.parent[node]\n        return node\n\ndef popular_names(names: List[str], synonyms: List[str]) -> List[str]:\n    \"\"\"\n    Each year, the national statistics agency releases a list of the 10,000 most commonly chosen names for new babies, along with the frequency of each name's use. While variations in spelling can make certain names seem different, they may indeed refer to the same moniker. For instance, \"Aiden\" and \"Aidan\" are treated as separate entries in the statistics, even though they actually stem from the same name.\n\n    Given two datasets - one featuring names and their popularity, the other containing pairs of names deemed to be versions of the same underlying name - we wish to devise a method to effectively compute and present the cumulative frequency of each distinct name. This requires that we account for the fact that name equivalency is both transitive and symmetrical. This means that if \"Aiden\" is equivalent to \"Aidan\" and \"Aidan\" is deemed identical to \"Ayden\" then \"Aiden\" and \"Ayden\" must also be considered the same.\n\n    In the resulting list, choose the lexicographically smallest name as the representative for the true name.\n\n    In developing this procedure, we must ensure a systematic approach that can handle the numerous relations between equivalent names and their different spellings. By accounting for these equivalences, a name's total frequency could potentially be much different than what's indicated in the raw newborn name statistics. Thus, this method should more accurately reflect the true popularity of distinct names.\n\n    >>> popular_names([\"Aiden(10)\",\"Aidan(5)\",\"Alex(20)\",\"Lex(2)\",\"Alexander(30)\"], [\"(Aidan,Aiden)\",\"(Aiden,Ayden)\",\"(Alex,Lex)\",\"(Alex,Alexander)\"])\n    [\"Aiden(15)\",\"Alex(52)\"]\n    >>> popular_names([\"John(15)\",\"Jon(12)\",\"Chris(13)\",\"Kris(4)\",\"Christopher(19)\"], [\"(Jon,John)\",\"(John,Johnny)\",\"(Chris,Kris)\",\"(Chris,Christopher)\"])\n    [\"John(27)\",\"Chris(36)\"]\n    \"\"\"", "function_name": "popular_names", "parameters": ["names", "synonyms"], "assert_statements": ["assert set(popular_names([\"John(15)\",\"Jon(12)\",\"Chris(13)\",\"Kris(4)\",\"Christopher(19)\"],[\"(Jon,John)\",\"(John,Johnny)\",\"(Chris,Kris)\",\"(Chris,Christopher)\"])) == {\"John(27)\",\"Chris(36)\"}", "assert set(popular_names([\"John(15)\",\"Jon(12)\",\"Chris(13)\",\"Kris(4)\",\"Chuck(19)\"],[\"(Jon,John)\",\"(John,Johnny)\",\"(Chris,Kris)\"])) == {\"John(27)\",\"Chris(17)\",\"Chuck(19)\"}", "assert set(popular_names([\"Aiden(10)\",\"Aidan(5)\",\"Alex(20)\",\"Lex(2)\",\"Alexander(30)\"],[\"(Aidan,Aiden)\",\"(Aiden,Ayden)\",\"(Alex,Lex)\",\"(Alex,Alexander)\"])) == {\"Alex(52)\",\"Aidan(15)\"}"]}
{"id": 8, "difficulty_types": 1, "question": "from typing import List\n\ndef bridge_beams(shorter: int, longer: int, k: int) -> List[int]:\n    \"\"\"\n    The task at hand is both a practical and mathematical challenge, as constructing a bridge requires thorough understanding of engineering principles and creative problem-solving skills. The small stream represents a physical obstacle that needs to be overcome by establishing a steady connection from one side to the other. Metal beams are chosen for their durability and strength, essential for ensuring the longevity and safety of the bridge.\n\n    With two distinct types of beams, the \"shorter\" and the \"longer,\" your solution must accommodate a variety of circumstances. The shorter beams, while potentially more manageable due to their shorter length, might only be appropriate for narrow sections of the stream or for supporting lighter loads. On the other hand, the longer beams, offering a greater span, might be used to cover broader gaps or to bear more weight, but could also require additional support structures to maintain the necessary stability.\n\n    The project requires the precise integration of k beams. Your task is to develop a strategy to establish all potential bridge spans.\n\n    These spans should be organized from the shortest to the longest.\n\n    >>> bridge_beams(1,2,3)\n    [3, 4, 5, 6]\n    Explanation: By using the shorter beam three times, you create a span of 3; mixing two shorter beams with one longer beam results in a span of 4. Continue with this sequence to acquire the exhaustive list of spans.\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef bridge_beams(shorter: int, longer: int, k: int) -> List[int]:\n    \"\"\"\n    The task at hand is both a practical and mathematical challenge, as constructing a bridge requires thorough understanding of engineering principles and creative problem-solving skills. The small stream represents a physical obstacle that needs to be overcome by establishing a steady connection from one side to the other. Metal beams are chosen for their durability and strength, essential for ensuring the longevity and safety of the bridge.\n\n    With two distinct types of beams, the \"shorter\" and the \"longer,\" your solution must accommodate a variety of circumstances. The shorter beams, while potentially more manageable due to their shorter length, might only be appropriate for narrow sections of the stream or for supporting lighter loads. On the other hand, the longer beams, offering a greater span, might be used to cover broader gaps or to bear more weight, but could also require additional support structures to maintain the necessary stability.\n\n    The project requires the precise integration of k beams. Your task is to develop a strategy to establish all potential bridge spans.\n\n    These spans should be organized from the shortest to the longest.\n\n    >>> bridge_beams(1,2,3)\n    [3, 4, 5, 6]\n    Explanation: By using the shorter beam three times, you create a span of 3; mixing two shorter beams with one longer beam results in a span of 4. Continue with this sequence to acquire the exhaustive list of spans.\n    \"\"\"", "function_name": "bridge_beams", "parameters": ["shorter", "longer", "k"], "assert_statements": ["assert bridge_beams(1,2,3) == [3, 4, 5, 6]", "assert bridge_beams(1,1,0) == []", "assert bridge_beams(30,31,10) == [300,301,302,303,304,305,306,307,308,309,310]"]}
{"id": 9, "difficulty_types": 1, "question": "from typing import List\n\ndef pokemon(pokemons: List[List[int]], balls: List[List[int]], r: int)->int:\n    \"\"\"In the Pokémon world, Professor Oak invites Ash to participate in a Pokémon-catching drill. A vast field is dotted with many Pokémon, and each Pokémon's information is recorded as [xi, yi, ri], with (xi, yi) being their Global Positioning System (GPS) coordinates and ri as their catch radius. Ash has a set of Master Balls, each with a fixed catch radius R, and the coordinates of each Master Ball are recorded as [xj, yj] in the array balls[j]. The rules for catching Pokémon with Master Balls in this drill are as follows:\n        If any part of a Pokémon, including its edges, is inside or on the border of a Master Ball, then it is considered successfully caught.\n        If a Pokémon is simultaneously caught by multiple Master Balls, it only counts as one successful catch.\n        Please help Ash to calculate how many Pokémon he has successfully caught in total.\n    Note:\n        The input data guarantees that no two Pokémon have the same GPS coordinates; however, their catch radiuses may overlap.\n    >>> pokemon([[1,3,2],[4,3,1],[7,1,2]], [[1,0],[3,3]], 4)\n    2\n    >>> pokemon([[3,3,1],[3,2,1]], [[4,3]], 2)\n    1\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef pokemon(pokemons: List[List[int]], balls: List[List[int]], r: int)->int:\n    \"\"\"In the Pokémon world, Professor Oak invites Ash to participate in a Pokémon-catching drill. A vast field is dotted with many Pokémon, and each Pokémon's information is recorded as [xi, yi, ri], with (xi, yi) being their Global Positioning System (GPS) coordinates and ri as their catch radius. Ash has a set of Master Balls, each with a fixed catch radius R, and the coordinates of each Master Ball are recorded as [xj, yj] in the array balls[j]. The rules for catching Pokémon with Master Balls in this drill are as follows:\n        If any part of a Pokémon, including its edges, is inside or on the border of a Master Ball, then it is considered successfully caught.\n        If a Pokémon is simultaneously caught by multiple Master Balls, it only counts as one successful catch.\n        Please help Ash to calculate how many Pokémon he has successfully caught in total.\n    Note:\n        The input data guarantees that no two Pokémon have the same GPS coordinates; however, their catch radiuses may overlap.\n    >>> pokemon([[1,3,2],[4,3,1],[7,1,2]], [[1,0],[3,3]], 4)\n    2\n    >>> pokemon([[3,3,1],[3,2,1]], [[4,3]], 2)\n    1\n    \"\"\"", "function_name": "pokemon", "parameters": ["pokemons", "balls", "r"], "assert_statements": ["assert pokemon([[5,1,1],[3,1,2],[2,2,1]],[[1,1]],3) == 1", "assert pokemon([[1,3,1],[4,6,2],[7,6,1]],[[2,3],[6,7]],2) == 1", "assert pokemon([[11,2,2],[8,32,1],[7,1,3]],[[0,0],[3,3]], 2) == 0"]}
{"id": 10, "difficulty_types": 1, "question": "from typing import List\n\ndef shingen_impact_explore(nums: List[int]) -> int:\n    \"\"\"In a game called Shingen Impact, an explorer finds a series of ancient barriers in an undeveloped region\n    named Vateyt. These barriers are numbered from 0 to N-1. Each barrier conceals either a Healing Stele, \n    a Cursed Trap, or a neutral passage with nothing within:\n\n    - Healing Stele: Upon contact, it can restore vitality and elemental energy;\n    - Cursed Trap: Approaching it will incur a curse, consuming a certain amount of life;\n    - Neutral Passage: It will not impact the explorer in any way.\n\n    The effects of each barrier on the numeric value are recorded in the array 'nums'. The explorer must dispel the\n    influence of these barriers one by one to further explore new areas and uncover hidden secrets. Initially, the \n    explorer's life is at 1 (with no upper limit) and the plan was to explore each one according to the arrangement\n    order of the barriers. However, it was quickly discovered that heading directly into adventure might result in \n    life depletion. Thus, rearrangement of the exploration sequence is required, strategically placing those Cursed Traps\n    toward the end.\n\n    Therefore, the explorer needs to strategize. The explorer aims to minimally adjust the sequence order, ensuring his life\n    remains positive throughout the process. If there is no possible way to arrange the sequence of barriers to maintain \n    positive life, then the explorer must seek help from the deities and return a result of -1 (indicating the task is \n    unachievable).\n    >>> shingen_impact_explore([-300, 500, 0, -400, 0])\n    -1\n    >>> shingen_impact_explore([110,130,110,-250,-70,-110,-50,-50,90,150])\n    1\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef shingen_impact_explore(nums: List[int]) -> int:\n    \"\"\"In a game called Shingen Impact, an explorer finds a series of ancient barriers in an undeveloped region\n    named Vateyt. These barriers are numbered from 0 to N-1. Each barrier conceals either a Healing Stele, \n    a Cursed Trap, or a neutral passage with nothing within:\n\n    - Healing Stele: Upon contact, it can restore vitality and elemental energy;\n    - Cursed Trap: Approaching it will incur a curse, consuming a certain amount of life;\n    - Neutral Passage: It will not impact the explorer in any way.\n\n    The effects of each barrier on the numeric value are recorded in the array 'nums'. The explorer must dispel the\n    influence of these barriers one by one to further explore new areas and uncover hidden secrets. Initially, the \n    explorer's life is at 1 (with no upper limit) and the plan was to explore each one according to the arrangement\n    order of the barriers. However, it was quickly discovered that heading directly into adventure might result in \n    life depletion. Thus, rearrangement of the exploration sequence is required, strategically placing those Cursed Traps\n    toward the end.\n\n    Therefore, the explorer needs to strategize. The explorer aims to minimally adjust the sequence order, ensuring his life\n    remains positive throughout the process. If there is no possible way to arrange the sequence of barriers to maintain \n    positive life, then the explorer must seek help from the deities and return a result of -1 (indicating the task is \n    unachievable).\n    >>> shingen_impact_explore([-300, 500, 0, -400, 0])\n    -1\n    >>> shingen_impact_explore([110,130,110,-250,-70,-110,-50,-50,90,150])\n    1\n    \"\"\"", "function_name": "shingen_impact_explore", "parameters": ["nums"], "assert_statements": ["assert shingen_impact_explore([-60,-140,0,0,20,150]) == -1", "assert shingen_impact_explore([-60,-140,100,100,-250,-50,-50,200,150]) == 3", "assert shingen_impact_explore([-70,-50,90,0,160,-110,-50,-170,-300,350,0,120,40]) == 4"]}
{"id": 11, "difficulty_types": 1, "question": "from typing import List\n\ndef can_square(bucket_list: List[int]) -> str:\n    \"\"\" Given a bucket_list with each entry as the number of squares in the bucket, determin if we can build a square using all the given squares. Output \"YES\" if we can, otherwise \"No\".\n    >>> can_square([14, 2])\n    YES\n    >>> can_square([1, 2, 3, 4, 5, 6, 7])\n    NO\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef can_square(bucket_list: List[int]) -> str:\n    \"\"\" Given a bucket_list with each entry as the number of squares in the bucket, determin if we can build a square using all the given squares. Output \"YES\" if we can, otherwise \"No\".\n    >>> can_square([14, 2])\n    YES\n    >>> can_square([1, 2, 3, 4, 5, 6, 7])\n    NO\n    \"\"\"", "function_name": "can_square", "parameters": ["bucket_list"], "assert_statements": ["assert can_square([1,2]) == \"NO\"", "assert can_square([3,4,5]) == \"NO\"", "assert can_square([9]) == \"YES\""]}
{"id": 12, "difficulty_types": 1, "question": "from typing import List\n\ndef find_champion(grid: List[List[int]]) -> int:\n    \"\"\"\n    In a competition with 'n' teams numbered from 0 to n - 1, you have a 2D boolean matrix 'grid' of size n x n.\n    For all pairs of teams 'i' and 'j' where 0 <= i, j <= n - 1 and i != j: if grid[i][j] == 1, team 'i' is stronger than team 'j'; otherwise, team 'j' is stronger.\n    A team will be the champion if no other team is stronger than it.\n    Return the team that will be the champion.\n    >>>find_champion([[0,1],[0,0]])\n    0\n    >>>find_champion([[0,0,1],[1,0,1],[0,0,0]])\n    1\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef find_champion(grid: List[List[int]]) -> int:\n    \"\"\"\n    In a competition with 'n' teams numbered from 0 to n - 1, you have a 2D boolean matrix 'grid' of size n x n.\n    For all pairs of teams 'i' and 'j' where 0 <= i, j <= n - 1 and i != j: if grid[i][j] == 1, team 'i' is stronger than team 'j'; otherwise, team 'j' is stronger.\n    A team will be the champion if no other team is stronger than it.\n    Return the team that will be the champion.\n    >>>find_champion([[0,1],[0,0]])\n    0\n    >>>find_champion([[0,0,1],[1,0,1],[0,0,0]])\n    1\n    \"\"\"", "function_name": "find_champion", "parameters": ["grid"], "assert_statements": ["assert find_champion([[0,0,0],[1,0,0],[1,1,0]]) == 2", "assert find_champion([[0,0,0,0],[1,0,0,0],[1,1,0,1],[1,1,0,0]]) == 2", "assert find_champion([[0,0,1],[1,0,1],[0,0,0]]) ==1"]}
{"id": 13, "difficulty_types": 1, "question": "from typing import List\n\ndef get_highest_occurrence_count(number_list: List[int]) -> int:\n    \"\"\"\n    I was recently talking with my friend John who works as a data analyst.\n    He was telling me about some of the common tasks he has to do with the data sets he works with.\n    John mentioned he often needs to write little functions to calculate these frequencies. Last week, he was working with a data set of numbers and needed to find the total frequency of the number(s) that appear most often.\n    He asked if I could help him turn this task into a simple function. Here is a concise description of what it needs to do:\n\n    Given an array `nums` of positive integers, return the total frequency of the most frequent element(s) in the array `nums`.\n    The frequency of an element is the number of times it appears in the array.\n    >>>get_highest_occurrence_count([2,2,3,3])\n    4\n    >>>get_highest_occurrence_count([4,3,2,1])\n    4\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef get_highest_occurrence_count(number_list: List[int]) -> int:\n    \"\"\"\n    I was recently talking with my friend John who works as a data analyst.\n    He was telling me about some of the common tasks he has to do with the data sets he works with.\n    John mentioned he often needs to write little functions to calculate these frequencies. Last week, he was working with a data set of numbers and needed to find the total frequency of the number(s) that appear most often.\n    He asked if I could help him turn this task into a simple function. Here is a concise description of what it needs to do:\n\n    Given an array `nums` of positive integers, return the total frequency of the most frequent element(s) in the array `nums`.\n    The frequency of an element is the number of times it appears in the array.\n    >>>get_highest_occurrence_count([2,2,3,3])\n    4\n    >>>get_highest_occurrence_count([4,3,2,1])\n    4\n    \"\"\"", "function_name": "get_highest_occurrence_count", "parameters": ["number_list"], "assert_statements": ["assert get_highest_occurrence_count([1,2,2,3,1,4]) == 4", "assert get_highest_occurrence_count([6,13,15,15,11,6,7,12,4,11]) == 6", "assert get_highest_occurrence_count([5]) == 1"]}
{"id": 14, "difficulty_types": 1, "question": "from typing import List\n\ndef get_max_diagonal_area(dimensions: List[List[int]]) -> int:\n    \"\"\"\n    You were given a 2D array of integers called dimensions representing the lengths and widths of different rectangles. For each index i (where 0 <= i < dimensions.length), dimensions[i][0] is the length of rectangle i and dimensions[i][1] is the width.\n    You needed to find the area of the rectangle with the longest diagonal.\n    If there were multiple rectangles with the same longest diagonal length, he needed to return the area of the rectangle with the largest area.\n    So in summary, given a 2D array of rectangle dimensions, the problem is asking:\n\n    Return the area of the rectangle with the longest diagonal. If there are multiple rectangles with the same max diagonal length, return the one with the largest area.\n    >>>get_max_diagonal_area([[1,2],[3,4]])\n    12\n    >>>get_max_diagonal_area([[10,8],[7,6]])\n    80\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef get_max_diagonal_area(dimensions: List[List[int]]) -> int:\n    \"\"\"\n    You were given a 2D array of integers called dimensions representing the lengths and widths of different rectangles. For each index i (where 0 <= i < dimensions.length), dimensions[i][0] is the length of rectangle i and dimensions[i][1] is the width.\n    You needed to find the area of the rectangle with the longest diagonal.\n    If there were multiple rectangles with the same longest diagonal length, he needed to return the area of the rectangle with the largest area.\n    So in summary, given a 2D array of rectangle dimensions, the problem is asking:\n\n    Return the area of the rectangle with the longest diagonal. If there are multiple rectangles with the same max diagonal length, return the one with the largest area.\n    >>>get_max_diagonal_area([[1,2],[3,4]])\n    12\n    >>>get_max_diagonal_area([[10,8],[7,6]])\n    80\n    \"\"\"", "function_name": "get_max_diagonal_area", "parameters": ["dimensions"], "assert_statements": ["assert get_max_diagonal_area([[3,4],[4,3]]) == 12", "assert get_max_diagonal_area([[4,7],[10,10],[3,7],[9,1],[5,7],[3,9],[10,4],[4,8]]) == 100", "assert get_max_diagonal_area([[3,7],[2,10],[3,4],[9,9],[5,10]]) == 81"]}
{"id": 15, "difficulty_types": 1, "question": "from typing import List\n\ndef find_smallest_missing_integer(nums: List[int]) -> int:\n    \"\"\"\n    You are given an integer array nums indexed from 0.\n\n    A prefix nums[0..i] is called an ordered prefix if for every 1 <= j <= i, nums[j] equals nums[j - 1] + 1. Note that a prefix with only nums[0] is considered an ordered prefix.\n\n    Return the smallest integer x such that x is greater than or equal to the sum of the longest ordered prefix of nums.\n\n    Note that x cannot already exist in the array nums.\n    >>>find_smallest_missing_integer([1,2,3,4,5])\n    15\n    >>>find_smallest_missing_integer([6,1])\n    7\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef find_smallest_missing_integer(nums: List[int]) -> int:\n    \"\"\"\n    You are given an integer array nums indexed from 0.\n\n    A prefix nums[0..i] is called an ordered prefix if for every 1 <= j <= i, nums[j] equals nums[j - 1] + 1. Note that a prefix with only nums[0] is considered an ordered prefix.\n\n    Return the smallest integer x such that x is greater than or equal to the sum of the longest ordered prefix of nums.\n\n    Note that x cannot already exist in the array nums.\n    >>>find_smallest_missing_integer([1,2,3,4,5])\n    15\n    >>>find_smallest_missing_integer([6,1])\n    7\n    \"\"\"", "function_name": "find_smallest_missing_integer", "parameters": ["nums"], "assert_statements": ["assert find_smallest_missing_integer([1]) == 2", "assert find_smallest_missing_integer([38]) == 39", "assert find_smallest_missing_integer([19,20,21,22]) == 82"]}
{"id": 16, "difficulty_types": 1, "question": "def find_calling_steps(ring: str, key: str) -> int:\n    \"\"\"Baba is the only country on the planet Padamiya. This country has absolute political power, is rich and powerful. Their forward King Abanov is the best generation of leaders in history, and has promoted the Baba country to unprecedented prosperity. But something happened recently that made him very distressed, because fewer and fewer people can find their destiny in this life.\n\n    There is a romantic legend in this ancient and mysterious country: the local telephone route consists of an unfixed rotation of a string of characters. There is a button in the center of the route. Only by spelling out the specific keyword in the fewest possible steps can you navigate the route. This will allow you to successfully contact the person destined for you in this life.\n    Here's how the phone dial is used: Initially, the first character of the ring is aligned with the 12:00 direction. Rotate the ring clockwise or counterclockwise to align the key character key[i] with the 12:00 direction. Then, click the center button. In this way, the keyword key[i] is considered to be correctly inputted. Each rotation of the dial to a new position and each click of the center button are counted as one step.\n\n    Can you provide the key words in the smallest steps that spell out all the characters to help local residents find their loved ones?\n\n    Among them, the ring and key only contain lowercase English letters. At the same time, the key can definitely be written through the ring.\n\n    1 <= ring.length, key.length <= 100\n    ring and key consist of only lower case English letters.\n    It is guaranteed that key could always be spelled by rotating ring.\n\n    >>> find_calling_steps(\"godding\", \"gd\")\n    4\n    >>> find_calling_steps(\"godding\", \"godding\")\n    13\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\ndef find_calling_steps(ring: str, key: str) -> int:\n    \"\"\"Baba is the only country on the planet Padamiya. This country has absolute political power, is rich and powerful. Their forward King Abanov is the best generation of leaders in history, and has promoted the Baba country to unprecedented prosperity. But something happened recently that made him very distressed, because fewer and fewer people can find their destiny in this life.\n\n    There is a romantic legend in this ancient and mysterious country: the local telephone route consists of an unfixed rotation of a string of characters. There is a button in the center of the route. Only by spelling out the specific keyword in the fewest possible steps can you navigate the route. This will allow you to successfully contact the person destined for you in this life.\n    Here's how the phone dial is used: Initially, the first character of the ring is aligned with the 12:00 direction. Rotate the ring clockwise or counterclockwise to align the key character key[i] with the 12:00 direction. Then, click the center button. In this way, the keyword key[i] is considered to be correctly inputted. Each rotation of the dial to a new position and each click of the center button are counted as one step.\n\n    Can you provide the key words in the smallest steps that spell out all the characters to help local residents find their loved ones?\n\n    Among them, the ring and key only contain lowercase English letters. At the same time, the key can definitely be written through the ring.\n\n    1 <= ring.length, key.length <= 100\n    ring and key consist of only lower case English letters.\n    It is guaranteed that key could always be spelled by rotating ring.\n\n    >>> find_calling_steps(\"godding\", \"gd\")\n    4\n    >>> find_calling_steps(\"godding\", \"godding\")\n    13\n    \"\"\"", "function_name": "find_calling_steps", "parameters": ["ring", "key"], "assert_statements": ["assert find_calling_steps(\"Padamiya\", \"daad\") == 8", "assert find_calling_steps(\"nature\", \"art\") == 9", "assert find_calling_steps(\"yivnov\", \"vion\") == 11"]}
{"id": 17, "difficulty_types": 1, "question": "def get_palindromic_string(string1: str, string2: str) -> str:\n    \"\"\"If the reverse of a string is the same as the original string, the string is called a palindrome string.  \n    You are given two strings, please find a substring in the longer string that can be concatenated after the shorter string to form a palindrome string. \n    If it can be found, return the concatenated palindromic string. Otherwise, return None. \n    Note that if more than one substring matches, you need to return the longest one.\n    >>> get_palindromic_string(\"ab\", \"deba\")\n    \"abeba\"\n    >>> get_palindromic_string(\"uvw\", \"v\")\n    \"vv\"\n    >>> get_palindromic_string(\"abc\", \"abcd\")\n    \"\"\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\ndef get_palindromic_string(string1: str, string2: str) -> str:\n    \"\"\"If the reverse of a string is the same as the original string, the string is called a palindrome string.  \n    You are given two strings, please find a substring in the longer string that can be concatenated after the shorter string to form a palindrome string. \n    If it can be found, return the concatenated palindromic string. Otherwise, return None. \n    Note that if more than one substring matches, you need to return the longest one.\n    >>> get_palindromic_string(\"ab\", \"deba\")\n    \"abeba\"\n    >>> get_palindromic_string(\"uvw\", \"v\")\n    \"vv\"\n    >>> get_palindromic_string(\"abc\", \"abcd\")\n    \"\"\n    \"\"\"", "function_name": "get_palindromic_string", "parameters": ["string1", "string2"], "assert_statements": ["assert get_palindromic_string(\"abcde\", \"dcba1234\") == \"abcdedcba\"", "assert get_palindromic_string(\"ab\", \"1234ba5665ba78\") == \"ab5665ba\"", "assert get_palindromic_string(\"ddc\", \"123d456dd789\") == \"ddcdd\""]}
{"id": 18, "difficulty_types": 1, "question": "from typing import List\n\ndef mahjong_practice(tiles:List[int])->int:\n    \"\"\"The game of mahjong requires four players, 144 tiles and two dice to roll. The goal of mahjong is similar to poker, in that the aim is to make matching sets and pairs. A set is three or four identical tiles (e.g. 111, 1111) or three consecutive tiles (e.g. 123), and a pair is two of the same tiles (often called ‘eyes’). To win mahjong a player must form four sets and one pair. A complete mahjong set of 144 tiles includes three suits, each suit contains four sets of tiles numbered one to nine. As mentioned, the goal is to create four sets of three tiles and a pair. The three types of sets a player can make are:\n    Pong! – a set of three identical tiles\n    Gang! – a set of four identical tiles\n    Chi! – a sequence of three consecutive tiles of the same suit \n    Now, for practice, regardless of the suits, just look at the numbers. Given a list of tiles, calculate the maximum number of groups that can form \"Pong\" or \"Chi\".\n    >>> mahjong_practice([2,2,2,3,4])\n    1\n    >>> mahjong_practice([2,2,2,3,4,1,3])\n    2\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef mahjong_practice(tiles:List[int])->int:\n    \"\"\"The game of mahjong requires four players, 144 tiles and two dice to roll. The goal of mahjong is similar to poker, in that the aim is to make matching sets and pairs. A set is three or four identical tiles (e.g. 111, 1111) or three consecutive tiles (e.g. 123), and a pair is two of the same tiles (often called ‘eyes’). To win mahjong a player must form four sets and one pair. A complete mahjong set of 144 tiles includes three suits, each suit contains four sets of tiles numbered one to nine. As mentioned, the goal is to create four sets of three tiles and a pair. The three types of sets a player can make are:\n    Pong! – a set of three identical tiles\n    Gang! – a set of four identical tiles\n    Chi! – a sequence of three consecutive tiles of the same suit \n    Now, for practice, regardless of the suits, just look at the numbers. Given a list of tiles, calculate the maximum number of groups that can form \"Pong\" or \"Chi\".\n    >>> mahjong_practice([2,2,2,3,4])\n    1\n    >>> mahjong_practice([2,2,2,3,4,1,3])\n    2\n    \"\"\"", "function_name": "mahjong_practice", "parameters": ["tiles"], "assert_statements": ["assert mahjong_practice([9,9,8,8,7,7,6,6,6]) == 3", "assert mahjong_practice([1,2,2,4,5,5,8,8,9,1]) == 0", "assert mahjong_practice([1,2,3,3,4,5,5,6,7,7,8,9]) == 4"]}
{"id": 19, "difficulty_types": 1, "question": "from typing import List\n\n\ndef find_duplicate(nums: List[int]) -> int:\n    \"\"\"Floyd's cycle detection algorithm, also known as the \"tortoise and hare algorithm,\" is used to detect whether a linked list contains a cycle or loop.\n\n    In this algorithm, two pointers are used: the slow pointer (tortoise) and the fast pointer (hare). The slow pointer moves one step at a time, while the fast pointer moves two steps at a time. If there is a cycle in the linked list, eventually the fast pointer will catch up to the slow pointer and they will meet at a node in the cycle.\n\n    To detect the cycle, the algorithm starts by initializing both pointers to the head of the linked list. Then, the pointers move through the linked list as described above. If the fast pointer reaches the end of the list (i.e. it encounters a null pointer), then there is no cycle in the list. However, if the fast pointer catches up to the slow pointer, then there is a cycle in the list.\n\n    Once a cycle is detected, the algorithm can also find the starting point of the cycle. After the two pointers meet, the slow pointer is reset to the head of the list, and both pointers move one step at a time until they meet again. The node where they meet is the starting point of the cycle.\n\n    Floyd's cycle detection algorithm has a time complexity of O(n), where n is the length of the linked list. It is named after Robert W. Floyd, who described the algorithm in 1967.\n\n    Based on the above background, please find the repeated number in the array 'nums' of length n+1. The numbers in this array are all in the range [1, n].\n\n    1 <= n <= 10^5\n    nums.length == n + 1\n    1 <= nums[i] <= n\n    All the integers in nums appear only once except for precisely one integer which appears two or more times.\n\n    >>> find_duplicate([1,3,4,2,2])\n    2\n    >>> find_duplicate([3,1,3,4,2])\n    3\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\n\ndef find_duplicate(nums: List[int]) -> int:\n    \"\"\"Floyd's cycle detection algorithm, also known as the \"tortoise and hare algorithm,\" is used to detect whether a linked list contains a cycle or loop.\n\n    In this algorithm, two pointers are used: the slow pointer (tortoise) and the fast pointer (hare). The slow pointer moves one step at a time, while the fast pointer moves two steps at a time. If there is a cycle in the linked list, eventually the fast pointer will catch up to the slow pointer and they will meet at a node in the cycle.\n\n    To detect the cycle, the algorithm starts by initializing both pointers to the head of the linked list. Then, the pointers move through the linked list as described above. If the fast pointer reaches the end of the list (i.e. it encounters a null pointer), then there is no cycle in the list. However, if the fast pointer catches up to the slow pointer, then there is a cycle in the list.\n\n    Once a cycle is detected, the algorithm can also find the starting point of the cycle. After the two pointers meet, the slow pointer is reset to the head of the list, and both pointers move one step at a time until they meet again. The node where they meet is the starting point of the cycle.\n\n    Floyd's cycle detection algorithm has a time complexity of O(n), where n is the length of the linked list. It is named after Robert W. Floyd, who described the algorithm in 1967.\n\n    Based on the above background, please find the repeated number in the array 'nums' of length n+1. The numbers in this array are all in the range [1, n].\n\n    1 <= n <= 10^5\n    nums.length == n + 1\n    1 <= nums[i] <= n\n    All the integers in nums appear only once except for precisely one integer which appears two or more times.\n\n    >>> find_duplicate([1,3,4,2,2])\n    2\n    >>> find_duplicate([3,1,3,4,2])\n    3\n    \"\"\"", "function_name": "find_duplicate", "parameters": ["nums"], "assert_statements": ["assert find_duplicate([2, 2, 2, 2]) == 2", "assert find_duplicate([1, 1]) == 1", "assert find_duplicate([1, 2, 4, 4, 3]) == 4"]}
{"id": 20, "difficulty_types": 1, "question": "from typing import List\n\n\ndef majority_vote(nums: List[int]) -> List[int]:\n    \"\"\"The core idea of Majority voting method is consumption. First, we consider the basic Majority voting problem, such as finding a number that appears more than 1/2 of the total number of times in a set of number sequences (and assuming that this number always exists). We can directly use proof by contradiction to prove that there may be only one such number. The core idea of Majority voting algorithm is based on this fact:\n\n    Select two different numbers from the sequence and delete them every time. Finally, one number or several identical numbers are left, which is the element that appears more than half of the total. Assume that the elements that exist half of the maximum number of times in the current sequence are x, and the total length of the sequence is n. Then we can divide the array into two parts, one part is the same k elements x, and the other part is (n-k)/2 pairs of different elements. At this time, we assume that there is another element y with a frequency greater than half of the total, Then y should satisfy y>n/2 at this time, but according to our previous reasoning y should satisfy y<=(n-k)/2, which is contradictory.\n\n    Please follow the principle of Majority voting to find elements that appear more than n/3 times in a sequence of size n.\n\n    1 <= nums.length <= 5 * 10^4\n    -10^9 <= nums[i] <= 10^9\n\n    >>> majority_vote([3,2,3])\n    [3]\n    >>> majority_vote([1])\n    [1]\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\n\ndef majority_vote(nums: List[int]) -> List[int]:\n    \"\"\"The core idea of Majority voting method is consumption. First, we consider the basic Majority voting problem, such as finding a number that appears more than 1/2 of the total number of times in a set of number sequences (and assuming that this number always exists). We can directly use proof by contradiction to prove that there may be only one such number. The core idea of Majority voting algorithm is based on this fact:\n\n    Select two different numbers from the sequence and delete them every time. Finally, one number or several identical numbers are left, which is the element that appears more than half of the total. Assume that the elements that exist half of the maximum number of times in the current sequence are x, and the total length of the sequence is n. Then we can divide the array into two parts, one part is the same k elements x, and the other part is (n-k)/2 pairs of different elements. At this time, we assume that there is another element y with a frequency greater than half of the total, Then y should satisfy y>n/2 at this time, but according to our previous reasoning y should satisfy y<=(n-k)/2, which is contradictory.\n\n    Please follow the principle of Majority voting to find elements that appear more than n/3 times in a sequence of size n.\n\n    1 <= nums.length <= 5 * 10^4\n    -10^9 <= nums[i] <= 10^9\n\n    >>> majority_vote([3,2,3])\n    [3]\n    >>> majority_vote([1])\n    [1]\n    \"\"\"", "function_name": "majority_vote", "parameters": ["nums"], "assert_statements": ["assert majority_vote([0, 0, 0]) == [0]", "assert majority_vote([2, 3]) == [2, 3]", "assert majority_vote([]) == []"]}
{"id": 21, "difficulty_types": 2, "question": "from typing import List\n\n\ndef complete_combustion(numbers: List[int]) -> List[float]:\n    \"\"\"Input to this function is a list representing the number of elements C, H and O in a\n    compound CxHyOz (z is not equal to 0). When this compound undergoes complete combustion with O2,\n    it produces only CO2 and H2O. The chemical equation is as follows:\n    CxHyOz + aO2 → bCO2 + cH2O\n    Please calculate a, b and c to balance the equation and ensure that the quantities of the three\n    elements are equal on both sides. The input list represents the quantities of C, H, and O in order.\n    Please return a list where the elements represent the quantities of O2, CO2 and H2O respectively.\n    >>> complete_combustion([1,2,1])\n    [1, 1, 1]\n    >>> complete_combustion([2,6,1])\n    [3, 2, 3]\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\n\ndef complete_combustion(numbers: List[int]) -> List[float]:\n    \"\"\"Input to this function is a list representing the number of elements C, H and O in a\n    compound CxHyOz (z is not equal to 0). When this compound undergoes complete combustion with O2,\n    it produces only CO2 and H2O. The chemical equation is as follows:\n    CxHyOz + aO2 → bCO2 + cH2O\n    Please calculate a, b and c to balance the equation and ensure that the quantities of the three\n    elements are equal on both sides. The input list represents the quantities of C, H, and O in order.\n    Please return a list where the elements represent the quantities of O2, CO2 and H2O respectively.\n    >>> complete_combustion([1,2,1])\n    [1, 1, 1]\n    >>> complete_combustion([2,6,1])\n    [3, 2, 3]\n    \"\"\"", "function_name": "complete_combustion", "parameters": ["numbers"], "assert_statements": ["assert complete_combustion([1, 4, 1]) == [1.5, 1, 2.0]", "assert complete_combustion([2, 4, 2]) == [2.0, 2, 2.0]", "assert complete_combustion([6, 12, 6]) == [6.0, 6, 6.0]"]}
{"id": 22, "difficulty_types": 2, "question": "from typing import List\n\ndef max_balance_factor(weights: List[int]) -> int:\n    \"\"\"Write a function to find the maximum balance factor of the given list 'weights'.\n    The maximum balance factor is the sum of a subset of 'weights' that can be removed to split\n    the remaining elements into two parts with equal sums. If no such balance factor exists, return 0.\n\n    Write a function to find the maximum balance factor of object w.\n    The maximum balance factor refers to the size of the sum that results from extracting\n    some or all elements from w, dividing them into two parts, and ensuring that the sums\n    of these two parts are equal. If such a maximum balance factor does not exist. return 0\n    >>> max_balance_factor([4, 2, 3, 9])\n    9\n    >>> max_balance_factor([7, 1, 9])\n    0\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef max_balance_factor(weights: List[int]) -> int:\n    \"\"\"Write a function to find the maximum balance factor of the given list 'weights'.\n    The maximum balance factor is the sum of a subset of 'weights' that can be removed to split\n    the remaining elements into two parts with equal sums. If no such balance factor exists, return 0.\n\n    Write a function to find the maximum balance factor of object w.\n    The maximum balance factor refers to the size of the sum that results from extracting\n    some or all elements from w, dividing them into two parts, and ensuring that the sums\n    of these two parts are equal. If such a maximum balance factor does not exist. return 0\n    >>> max_balance_factor([4, 2, 3, 9])\n    9\n    >>> max_balance_factor([7, 1, 9])\n    0\n    \"\"\"", "function_name": "max_balance_factor", "parameters": ["weights"], "assert_statements": ["assert max_balance_factor([1, 2]) ==  0", "assert max_balance_factor([1, 2, 3, 4, 5, 6]) == 10", "assert max_balance_factor([1, 2, 3, 6]) == 6"]}
{"id": 23, "difficulty_types": 2, "question": "def laser_arrangement(m):\n    \"\"\"A military restricted area, represented by a square matrix with side length m,\n    requires the installation of laser defense systems. These lasers can be emitted horizontally,\n    vertically, or diagonally at a 45-degree angle to both ends. However, mutually intersecting\n    lasers will destroy each other. How many arrangements are there to reasonably arrange the\n    lasers to ensure complete coverage of the entire area without mutual destruction?\n    >>> laser_arrangement(4)\n    2\n    >>> laser_arrangement(2)\n    0\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\ndef laser_arrangement(m):\n    \"\"\"A military restricted area, represented by a square matrix with side length m,\n    requires the installation of laser defense systems. These lasers can be emitted horizontally,\n    vertically, or diagonally at a 45-degree angle to both ends. However, mutually intersecting\n    lasers will destroy each other. How many arrangements are there to reasonably arrange the\n    lasers to ensure complete coverage of the entire area without mutual destruction?\n    >>> laser_arrangement(4)\n    2\n    >>> laser_arrangement(2)\n    0\n    \"\"\"", "function_name": "laser_arrangement", "parameters": ["m"], "assert_statements": ["assert laser_arrangement(3) == 0", "assert laser_arrangement(9) == 352", "assert laser_arrangement(6) == 4"]}
{"id": 24, "difficulty_types": 2, "question": "from typing import List\n\ndef dice_probability(num: int) -> List[float]:\n    \"\"\"There is a regular tetrahedral dice with numbers 1, 2, 3, 4, and the mass distribution is uniform.\n    If you roll n of these dice, please return the probabilities of all possible sums in ascending order using a list.\n    >>> dice_probabitliy(1)\n    [0.25, 0.25, 0.25, 0.25]\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef dice_probability(num: int) -> List[float]:\n    \"\"\"There is a regular tetrahedral dice with numbers 1, 2, 3, 4, and the mass distribution is uniform.\n    If you roll n of these dice, please return the probabilities of all possible sums in ascending order using a list.\n    >>> dice_probabitliy(1)\n    [0.25, 0.25, 0.25, 0.25]\n    \"\"\"", "function_name": "dice_probability", "parameters": ["num"], "assert_statements": ["assert dice_probability(2) == [1/16, 2/16, 3/16, 4/16, 3/16, 2/16, 1/16]", "assert dice_probability(3) == [1/64, 3/64, 6/64, 10/64, 12/64, 12/64, 10/64, 6/64, 3/64, 1/64]", "assert dice_probability(4) == [0.00390625, 0.015625, 0.0390625, 0.078125, 0.12109375, 0.15625, 0.171875, 0.15625, 0.12109375, 0.078125, 0.0390625, 0.015625, 0.00390625]"]}
{"id": 25, "difficulty_types": 2, "question": "from typing import List\n\ndef extract_times(water_map:List[List[str]]) -> int:\n    \"\"\"Given a water map which is a 2-D array representing underground water(\"1\") and soil(\"0\"), you are using a water pump\n    to extract water. Please calculate how many times do you need to turn on the pump. Note that if underground water is\n    interconnected, you only need to turn on the pump once. Connected underground water is formed by connecting adjacent lands\n    horizontally or vertically. You can assume that outside the grid is all surrounded by soil.\n    >>> extract_times([[\"1\",\"0\",\"1\",\"0\",\"0\"],[\"1\",\"0\",\"1\",\"0\",\"0\"],[\"1\",\"0\",\"0\",\"0\",\"0\"],[\"1\",\"0\",\"0\",\"1\",\"0\"]])\n    3\n    >>> extract_times([[\"1\",\"1\",\"0\",\"0\"],[\"1\",\"1\",\"0\",\"0\"],[\"0\",\"1\",\"0\",\"0\"],[\"0\",\"0\",\"0\",\"1\"]])\n    2\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef extract_times(water_map:List[List[str]]) -> int:\n    \"\"\"Given a water map which is a 2-D array representing underground water(\"1\") and soil(\"0\"), you are using a water pump\n    to extract water. Please calculate how many times do you need to turn on the pump. Note that if underground water is\n    interconnected, you only need to turn on the pump once. Connected underground water is formed by connecting adjacent lands\n    horizontally or vertically. You can assume that outside the grid is all surrounded by soil.\n    >>> extract_times([[\"1\",\"0\",\"1\",\"0\",\"0\"],[\"1\",\"0\",\"1\",\"0\",\"0\"],[\"1\",\"0\",\"0\",\"0\",\"0\"],[\"1\",\"0\",\"0\",\"1\",\"0\"]])\n    3\n    >>> extract_times([[\"1\",\"1\",\"0\",\"0\"],[\"1\",\"1\",\"0\",\"0\"],[\"0\",\"1\",\"0\",\"0\"],[\"0\",\"0\",\"0\",\"1\"]])\n    2\n    \"\"\"", "function_name": "extract_times", "parameters": ["water_map"], "assert_statements": ["assert extract_times([[\"1\",\"1\",\"0\"],[\"1\",\"1\",\"0\"],[\"0\",\"1\",\"0\"]]) == 1", "assert extract_times([[\"1\",\"1\",\"1\",\"1\",\"0\"],[\"1\",\"1\",\"0\",\"1\",\"0\"],[\"1\",\"1\",\"0\",\"0\",\"0\"],[\"0\",\"0\",\"0\",\"0\",\"0\"]]) == 1", "assert extract_times([[\"1\",\"1\",\"0\",\"0\",\"1\"],[\"1\",\"1\",\"1\",\"0\",\"0\"],[\"0\",\"1\",\"0\",\"0\",\"0\"],[\"0\",\"0\",\"1\",\"0\",\"1\"],[\"0\",\"1\",\"0\",\"0\",\"1\"],[\"0\",\"1\",\"0\",\"0\",\"0\"]]) == 5"]}
{"id": 26, "difficulty_types": 2, "question": "def pod_probability(m: int) -> float:\n    \"\"\"\n    An interstellar transport vessel is equipped with precisely m individual passenger pods, each uniquely assigned to m traveling spacefarers based on their purchased tickets. As a result of a minor malfunction in the boarding protocol, the initial spacefarer misplaces their boarding pass upon entry and subsequently selects a pod through a randomized selection process. The subsequent spacefarers will:\n\n    - Proceed to their pre-designated pod if it remains unoccupied, and\n    - Resort to an arbitrary choice of any remaining available pods whenever they encounter their designated pod to be already taken.\n\n    Considering this scenario, devise a function capable of determining with what probability the final spacefarer will occupy their originally assigned pod.\n\n    >>> pod_probability(1)\n    1.00000\n    >>> pod_probability(2)\n    0.50000\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\ndef pod_probability(m: int) -> float:\n    \"\"\"\n    An interstellar transport vessel is equipped with precisely m individual passenger pods, each uniquely assigned to m traveling spacefarers based on their purchased tickets. As a result of a minor malfunction in the boarding protocol, the initial spacefarer misplaces their boarding pass upon entry and subsequently selects a pod through a randomized selection process. The subsequent spacefarers will:\n\n    - Proceed to their pre-designated pod if it remains unoccupied, and\n    - Resort to an arbitrary choice of any remaining available pods whenever they encounter their designated pod to be already taken.\n\n    Considering this scenario, devise a function capable of determining with what probability the final spacefarer will occupy their originally assigned pod.\n\n    >>> pod_probability(1)\n    1.00000\n    >>> pod_probability(2)\n    0.50000\n    \"\"\"", "function_name": "pod_probability", "parameters": ["m"], "assert_statements": ["assert pod_probability(1) == 1.0000", "assert pod_probability(2) == 0.50000", "assert pod_probability(5) == 0.50000"]}
{"id": 27, "difficulty_types": 2, "question": "def state_element(n: int) -> int:\n    \"\"\"\n    There is a sequence of x elements that are initially in a specific state. You first change the state of all the elements, then you change the state of every second element.\n\n    On the third iteration, you change the state of every third element (changing it from its current state to the opposite state). For the ith iteration, you change the state of every i-th element. For the nth iteration, you only change the state of the last element.\n\n    Return the number of elements that are in a specific state after x iterations.\n\n    >>> state_element(121)\n    11\n    >>> state_element(20)\n    4\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\ndef state_element(n: int) -> int:\n    \"\"\"\n    There is a sequence of x elements that are initially in a specific state. You first change the state of all the elements, then you change the state of every second element.\n\n    On the third iteration, you change the state of every third element (changing it from its current state to the opposite state). For the ith iteration, you change the state of every i-th element. For the nth iteration, you only change the state of the last element.\n\n    Return the number of elements that are in a specific state after x iterations.\n\n    >>> state_element(121)\n    11\n    >>> state_element(20)\n    4\n    \"\"\"", "function_name": "state_element", "parameters": ["n"], "assert_statements": ["assert state_element(3) == 1", "assert state_element(0) == 0", "assert state_element(1) == 1"]}
{"id": 28, "difficulty_types": 2, "question": "from typing import List\n\ndef arrange_conference(windowsA: List[List[int]], windowsB: List[List[int]], conferenceTime: int) -> List[int]:\n    \"\"\"\n    Consider the time windows of availability for two separate parties, labeled as windowsA and windowsB, and the time span needed for a conference. Your task is to coordinate the earliest overlap in their schedules that can accommodate the conference length.\n\n    Should there be no compatible overlap allowing for the conference, the function should result in an empty list.\n\n    Each time window is structured as [opening, closing], composed of an opening time opening and a closing time closing, reflecting the period from opening to closing.\n\n    The input assures the integrity of the data: each party's time windows do not intersect amongst themselves. So for any pair of time windows [opening1, closing1] and [opening2, closing2] for the same party, it will be true that either opening1 > closing2 or opening2 > closing1.\n\n    >>> arrange_conference(windowsA = [[10,50],[60,120],[140,210]], windowsB = [[0,15],[60,70]], conferenceTime = 8)\n    [60,68]\n    >>> arrange_conference(windowsA = [[10,50],[60,120],[140,210]], windowsB = [[0,15],[60,70]], conferenceTime = 12)\n    []\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef arrange_conference(windowsA: List[List[int]], windowsB: List[List[int]], conferenceTime: int) -> List[int]:\n    \"\"\"\n    Consider the time windows of availability for two separate parties, labeled as windowsA and windowsB, and the time span needed for a conference. Your task is to coordinate the earliest overlap in their schedules that can accommodate the conference length.\n\n    Should there be no compatible overlap allowing for the conference, the function should result in an empty list.\n\n    Each time window is structured as [opening, closing], composed of an opening time opening and a closing time closing, reflecting the period from opening to closing.\n\n    The input assures the integrity of the data: each party's time windows do not intersect amongst themselves. So for any pair of time windows [opening1, closing1] and [opening2, closing2] for the same party, it will be true that either opening1 > closing2 or opening2 > closing1.\n\n    >>> arrange_conference(windowsA = [[10,50],[60,120],[140,210]], windowsB = [[0,15],[60,70]], conferenceTime = 8)\n    [60,68]\n    >>> arrange_conference(windowsA = [[10,50],[60,120],[140,210]], windowsB = [[0,15],[60,70]], conferenceTime = 12)\n    []\n    \"\"\"", "function_name": "arrange_conference", "parameters": ["windowsA", "windowsB", "conferenceTime"], "assert_statements": ["assert arrange_conference([[10,50],[60,120],[140,210]], [[0,15],[60,70]], 8) == [60,68]", "assert arrange_conference([[10,50],[60,120],[140,210]], [[0,15],[60,70]], 12) == []", "assert arrange_conference([[10,11],[60,70],[140,141]], [[10,15],[68,70], [140,150]], 10) == []"]}
{"id": 29, "difficulty_types": 2, "question": "from typing import List\n\ndef top_records(entry: List[List[int]]) -> List[List[int]]:\n    \"\"\"\n    Imagine a dataset containing multiple records of athletes with different identification numbers, where each record is marked as entry, such that entry[i] = [IDi, pointsi] signifies the points earned by athlete IDi in a particular event. Your job is to determine the average of the highest five point totals for every athlete.\n\n    The response should be structured as a list of tuples, summary, where summary[j] = [IDj, topFiveAveragej] matches the IDj of the athlete and their average of the five highest point totals. This list, summary, must be ordered by the athlete's ID in ascending sequence.\n\n    To derive the average of the top five point totals for each athlete, add together the points of their five best performances and then apply integer division by 5.\n\n    >>> top_records(entry = [[1,91],[1,92],[2,93],[2,97],[1,60],[2,77],[1,65],[1,87],[1,100],[2,100],[2,76]])\n    [[1,87],[2,88]]\n    >>> top_records(entry = [[1,100],[7,100],[1,100],[7,100],[1,100],[7,100],[1,100],[7,100],[1,100],[7,100]])\n    [[1,100],[7,100]]\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef top_records(entry: List[List[int]]) -> List[List[int]]:\n    \"\"\"\n    Imagine a dataset containing multiple records of athletes with different identification numbers, where each record is marked as entry, such that entry[i] = [IDi, pointsi] signifies the points earned by athlete IDi in a particular event. Your job is to determine the average of the highest five point totals for every athlete.\n\n    The response should be structured as a list of tuples, summary, where summary[j] = [IDj, topFiveAveragej] matches the IDj of the athlete and their average of the five highest point totals. This list, summary, must be ordered by the athlete's ID in ascending sequence.\n\n    To derive the average of the top five point totals for each athlete, add together the points of their five best performances and then apply integer division by 5.\n\n    >>> top_records(entry = [[1,91],[1,92],[2,93],[2,97],[1,60],[2,77],[1,65],[1,87],[1,100],[2,100],[2,76]])\n    [[1,87],[2,88]]\n    >>> top_records(entry = [[1,100],[7,100],[1,100],[7,100],[1,100],[7,100],[1,100],[7,100],[1,100],[7,100]])\n    [[1,100],[7,100]]\n    \"\"\"", "function_name": "top_records", "parameters": ["entry"], "assert_statements": ["assert top_records([[1,91],[1,92],[2,93],[2,97],[1,60],[2,77],[1,65],[1,87],[1,100],[2,100],[2,76]]) == [[1,87],[2,88]]", "assert top_records([[1,100],[7,100],[1,100],[7,100],[1,100],[7,100],[1,100],[7,100],[1,100],[7,100]]) == [[1,100],[7,100]]", "assert top_records([[1,0],[2,0],[3,0],[4,0],[5,0],[1,0],[2,0],[3,0],[4,0],[5,0],[1,0],[2,0],[3,0],[4,0],[5,0],[1,0],[2,0],[3,0],[4,0],[5,0],[1,0],[2,0],[3,0],[4,0],[5,0]]) == [[1,0],[2,0],[3,0],[4,0],[5,0]]"]}
{"id": 30, "difficulty_types": 2, "question": "def sum_perfect_integer(lower_bound: int, higher_bound: int, n: int):\n    \"\"\"You are given positive integers lower_bound, higher_bound, and n.\n\n    A number is perfect if it meets both of the following conditions:\n\n    - The count of odd digits in the number is equal to the count of even digits.\n    - The number is divisible by n.\n    Return the number of perfect integers in the range [lower_bound, higher_bound].\n    >>> sum_perfect_integer(4, 4, 1)\n    0\n    >>> sum_perfect_integer(1, 10, 1)\n    1\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\ndef sum_perfect_integer(lower_bound: int, higher_bound: int, n: int):\n    \"\"\"You are given positive integers lower_bound, higher_bound, and n.\n\n    A number is perfect if it meets both of the following conditions:\n\n    - The count of odd digits in the number is equal to the count of even digits.\n    - The number is divisible by n.\n    Return the number of perfect integers in the range [lower_bound, higher_bound].\n    >>> sum_perfect_integer(4, 4, 1)\n    0\n    >>> sum_perfect_integer(1, 10, 1)\n    1\n    \"\"\"", "function_name": "sum_perfect_integer", "parameters": ["lower_bound", "higher_bound", "n"], "assert_statements": ["assert sum_perfect_integer(4, 4, 1) == 0", "assert sum_perfect_integer(11, 23, 3) == 3", "assert sum_perfect_integer(2000, 2024, 5) == 1"]}
{"id": 31, "difficulty_types": 2, "question": "from typing import List\n\ndef maximum_size_after_removal(nums1: List[int], nums2: List[int]):\n    \"\"\" You are given two memory quantities nums1 and nums2 whose subscripts start from 0, and their lengths are both even n.\n\nYou\t must delete n / 2 elements from nums1 and n / 2 elements from nums2. After deletion, you insert the remaining elements from nums1 and nums2 into the set s.\n\nReturns the maximum number of possible collections\n     >>>  maximum_size_after_removal([3,4], [1,2])\n     2\n     >>>  maximum_size_after_removal([1,2,1,2], [1,1,1,1])\n     2\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef maximum_size_after_removal(nums1: List[int], nums2: List[int]):\n    \"\"\" You are given two memory quantities nums1 and nums2 whose subscripts start from 0, and their lengths are both even n.\n\nYou\t must delete n / 2 elements from nums1 and n / 2 elements from nums2. After deletion, you insert the remaining elements from nums1 and nums2 into the set s.\n\nReturns the maximum number of possible collections\n     >>>  maximum_size_after_removal([3,4], [1,2])\n     2\n     >>>  maximum_size_after_removal([1,2,1,2], [1,1,1,1])\n     2\n    \"\"\"", "function_name": "maximum_size_after_removal", "parameters": ["nums1", "nums2"], "assert_statements": ["assert maximum_size_after_removal([7,1],[6,10]) == 2", "assert maximum_size_after_removal([3,6],[6,6]) == 2", "assert maximum_size_after_removal([10,3],[5,6]) == 2"]}
{"id": 32, "difficulty_types": 2, "question": "def get_maximum_special_substring(s: str) -> int:\n    \"\"\"Determine the length of the longest substring in a given string 's', which consists solely of a single lower English character and the entire substring appears at least three times in the string 's'.\nIf no such substring exists, return -1.\n    >>>get_maximum_special_substring(\"aaaa\")\n    2\n    >>>get_maximum_special_substring(\"aeebcccdd\")\n    1\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\ndef get_maximum_special_substring(s: str) -> int:\n    \"\"\"Determine the length of the longest substring in a given string 's', which consists solely of a single lower English character and the entire substring appears at least three times in the string 's'.\nIf no such substring exists, return -1.\n    >>>get_maximum_special_substring(\"aaaa\")\n    2\n    >>>get_maximum_special_substring(\"aeebcccdd\")\n    1\n    \"\"\"", "function_name": "get_maximum_special_substring", "parameters": ["s"], "assert_statements": ["assert get_maximum_special_substring(\"ccc\") == 1", "assert get_maximum_special_substring(\"abcaba\") == 1", "assert get_maximum_special_substring(\"kkk\") == 1"]}
{"id": 33, "difficulty_types": 2, "question": "from typing import List\n\ndef find_peak(mountain: List[int]) -> List[int]:\n    \"\"\"\n    You need to identify all the peaks in a given array named 'mountain'.\n    A peak is defined as any element that is strictly greater than its neighbors.\n    Keep in mind that the first and last elements of the array cannot be considered as peaks.\n    Return the indices (positions) of all the peaks in the array, in any order.\n    >>> find_peak([1,2,4])\n    []\n    >>> find_peak([9,2,4,7,3])\n    [3]\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef find_peak(mountain: List[int]) -> List[int]:\n    \"\"\"\n    You need to identify all the peaks in a given array named 'mountain'.\n    A peak is defined as any element that is strictly greater than its neighbors.\n    Keep in mind that the first and last elements of the array cannot be considered as peaks.\n    Return the indices (positions) of all the peaks in the array, in any order.\n    >>> find_peak([1,2,4])\n    []\n    >>> find_peak([9,2,4,7,3])\n    [3]\n    \"\"\"", "function_name": "find_peak", "parameters": ["mountain"], "assert_statements": ["assert find_peak([1,4,3,8,5]) == [1,3]", "assert find_peak([3,6,4,7]) == [1]", "assert find_peak([5,2,1]) == []"]}
{"id": 34, "difficulty_types": 2, "question": "from typing import List\n\ndef similar_matrix(mat: List[List[int]], k: int) -> bool:\n    \"\"\"\n    You have a matrix 'mat' sized m x n, starting with index 0.\n    Shift odd-numbered rows right and even-numbered rows left by 'k' positions.\n    Check if the final matrix is the same as the initial one.\n    Return True if they match, otherwise False.\n    >>>similar_matrix([[2,2]], 3)\n    True\n    >>>similar_matrix([[3,1,4,1],[1,4,3,1],[2,4,1,2]], 2)\n    False\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef similar_matrix(mat: List[List[int]], k: int) -> bool:\n    \"\"\"\n    You have a matrix 'mat' sized m x n, starting with index 0.\n    Shift odd-numbered rows right and even-numbered rows left by 'k' positions.\n    Check if the final matrix is the same as the initial one.\n    Return True if they match, otherwise False.\n    >>>similar_matrix([[2,2]], 3)\n    True\n    >>>similar_matrix([[3,1,4,1],[1,4,3,1],[2,4,1,2]], 2)\n    False\n    \"\"\"", "function_name": "similar_matrix", "parameters": ["mat", "k"], "assert_statements": ["assert similar_matrix([[2,2],[2,2]], 3) == True", "assert similar_matrix([[4,9,10,10],[9,3,8,4],[2,5,3,8],[6,1,10,4]], 5) == False", "assert similar_matrix([[1,2]], 1) == False"]}
{"id": 35, "difficulty_types": 2, "question": "from typing import List\n\ndef find_k_or(nums: List[int], k: int) -> int:\n    \"\"\"\n    You have an array of integers named 'nums' and an integer 'k'.\n    The 'K-or' of nums is a non-negative integer defined by the following condition:\n    The i-th bit of K-or is 1 if and only if there are at least 'k' elements in 'nums' with their i-th bit as 1.\n    Return the K-or value of nums.\n    Note: For an integer 'x', the i-th bit value is 1 if (2^i AND x) == 2^i, where AND is the bitwise AND operator.\n    >>>find_k_or([8,11,9,7],1)\n    15\n    >>>find_k_or([2,12,1,11,4,5],6)\n    0\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef find_k_or(nums: List[int], k: int) -> int:\n    \"\"\"\n    You have an array of integers named 'nums' and an integer 'k'.\n    The 'K-or' of nums is a non-negative integer defined by the following condition:\n    The i-th bit of K-or is 1 if and only if there are at least 'k' elements in 'nums' with their i-th bit as 1.\n    Return the K-or value of nums.\n    Note: For an integer 'x', the i-th bit value is 1 if (2^i AND x) == 2^i, where AND is the bitwise AND operator.\n    >>>find_k_or([8,11,9,7],1)\n    15\n    >>>find_k_or([2,12,1,11,4,5],6)\n    0\n    \"\"\"", "function_name": "find_k_or", "parameters": ["nums", "k"], "assert_statements": ["assert find_k_or([9],1) == 9", "assert find_k_or([7],1) == 7", "assert find_k_or([8],1) == 8"]}
{"id": 36, "difficulty_types": 2, "question": "from typing import List\n\ndef max_profit(prices: List[int]) -> int:\n    \"\"\"\n    Given an array, its i-th element represents the price per ton of water on the i-th day. You can store water in a reservoir, and your reservoir has a capacity of 5 tons. Design an algorithm to calculate the maximum profit you can achieve. You can perform up to 2 storage and release operations for buying and selling.\n    Note: You must release water before storing it.\n\n    >>> max_profit([3,3,5,0,0,3,1,4])\n    30\n    >>> max_profit([1,2,3,4,5])\n    20\n    >>> max_profit([7,6,4,3,1])\n    0\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef max_profit(prices: List[int]) -> int:\n    \"\"\"\n    Given an array, its i-th element represents the price per ton of water on the i-th day. You can store water in a reservoir, and your reservoir has a capacity of 5 tons. Design an algorithm to calculate the maximum profit you can achieve. You can perform up to 2 storage and release operations for buying and selling.\n    Note: You must release water before storing it.\n\n    >>> max_profit([3,3,5,0,0,3,1,4])\n    30\n    >>> max_profit([1,2,3,4,5])\n    20\n    >>> max_profit([7,6,4,3,1])\n    0\n    \"\"\"", "function_name": "max_profit", "parameters": ["prices"], "assert_statements": ["assert max_profit([3, 3, 5, 0, 0, 3, 1, 4]) == 30", "assert max_profit([1, 2, 3, 4, 5]) == 20", "assert max_profit([7, 6, 4, 3, 1]) == 0"]}
{"id": 37, "difficulty_types": 2, "question": "from typing import List\n\ndef winning_probability(numbers: List[int]) -> float:\n    \"\"\"In a raffle, lucky number is defined as containing only the factors 3, 5, 7, e.g. 15, 21. The system will generates a random set of numbers, \n    whoever picks the lucky number wins the prize. And no one knows the rules. Everyone picks numbers according to their preferences.\n    Everyone has their own lucky number. For Li, his lucky number is a number that contains 1, so in this raffle, Li will choose his lucky number first. \n    If there's no Li's lucky number in the set, he'll pick it at random.  \n    Can you help Li calculate the probability of winning the prize? \n    >>> winning_probability([1, 4, 12, 21, 33])\n    0.333\n    >>> winning_probability([35, 22, 11])\n    0\n    >>> winning_probability([2, 50, 24, 49])\n    0.25\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef winning_probability(numbers: List[int]) -> float:\n    \"\"\"In a raffle, lucky number is defined as containing only the factors 3, 5, 7, e.g. 15, 21. The system will generates a random set of numbers, \n    whoever picks the lucky number wins the prize. And no one knows the rules. Everyone picks numbers according to their preferences.\n    Everyone has their own lucky number. For Li, his lucky number is a number that contains 1, so in this raffle, Li will choose his lucky number first. \n    If there's no Li's lucky number in the set, he'll pick it at random.  \n    Can you help Li calculate the probability of winning the prize? \n    >>> winning_probability([1, 4, 12, 21, 33])\n    0.333\n    >>> winning_probability([35, 22, 11])\n    0\n    >>> winning_probability([2, 50, 24, 49])\n    0.25\n    \"\"\"", "function_name": "winning_probability", "parameters": ["numbers"], "assert_statements": ["assert abs(winning_probability([11, 42, 12, 21, 53])-0.33333) <= 1e-5", "assert abs(winning_probability([2, 50, 24, 49])-0.25) <= 1e-5", "assert abs(winning_probability([9, 27, 11, 31])-0) <= 1e-5"]}
{"id": 38, "difficulty_types": 2, "question": "from typing import List\n\ndef symmetry_number(n: int) -> List[int]:\n    \"\"\"If a number is equal to its inverse order, it is called a symmetric number, e.g., '121'. Noting that all single digits are symmetric numbers. If the binary of this symmetric number is also equal to the inverse order of its binary, it is called a binary symmetric number, e.g., '9', whose binary number is '1001'. Further, performing a 01 swap on the binary of the symmetric number to form a flipped binary. If the decimal number corresponding to the flipped binary is a symmetric number, it is called a flipped symmetric number, e.g., '9', whose binary is '1001' , the binary flip number is '0110' and the corresponding decimal number is '6'. Find the count of symmetric numbers, binary symmetric numbers, and flipped symmetric numbers for all natural numbers not greater than the given number.\n    >>> symmetry_number(10)\n    [9, 5, 6]\n    >>> symmetry_number(50)\n    [13, 6, 8]\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef symmetry_number(n: int) -> List[int]:\n    \"\"\"If a number is equal to its inverse order, it is called a symmetric number, e.g., '121'. Noting that all single digits are symmetric numbers. If the binary of this symmetric number is also equal to the inverse order of its binary, it is called a binary symmetric number, e.g., '9', whose binary number is '1001'. Further, performing a 01 swap on the binary of the symmetric number to form a flipped binary. If the decimal number corresponding to the flipped binary is a symmetric number, it is called a flipped symmetric number, e.g., '9', whose binary is '1001' , the binary flip number is '0110' and the corresponding decimal number is '6'. Find the count of symmetric numbers, binary symmetric numbers, and flipped symmetric numbers for all natural numbers not greater than the given number.\n    >>> symmetry_number(10)\n    [9, 5, 6]\n    >>> symmetry_number(50)\n    [13, 6, 8]\n    \"\"\"", "function_name": "symmetry_number", "parameters": ["n"], "assert_statements": ["assert symmetry_number(1000) == [108, 10, 15]", "assert symmetry_number(2000) == [118, 10, 17]", "assert symmetry_number(10000) == [198, 12, 19]"]}
{"id": 39, "difficulty_types": 2, "question": "from typing import List\n\n\ndef brew_capability(brew_counts: List[int]) -> int:\n    \"\"\"\n    You are given an integer array `brew_counts`, where `brew_counts[i]` represents the number of brews needed for different batches of a certain brand of tea leaves. Calculate and return the brewing capacity of this brand of tea leaves.\n\n    A brand's brewing capacity is defined as the maximum value of b such that the given brand has b batches of tea leaves that have each been brewed at least b times. If there are multiple possible values for the brewing capacity, the brewing capacity is the maximum among them.\n\n    **Constraints:**\n\n    - `n == brew_counts.length`\n    - `1 <= n <= 5000`\n    - `0 <= brew_counts[i] <= 1000`\n\n    >>> brew_capability([3, 0, 6, 1, 5])\n    3\n    >>> brew_capability([1, 3, 1])\n    1\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\n\ndef brew_capability(brew_counts: List[int]) -> int:\n    \"\"\"\n    You are given an integer array `brew_counts`, where `brew_counts[i]` represents the number of brews needed for different batches of a certain brand of tea leaves. Calculate and return the brewing capacity of this brand of tea leaves.\n\n    A brand's brewing capacity is defined as the maximum value of b such that the given brand has b batches of tea leaves that have each been brewed at least b times. If there are multiple possible values for the brewing capacity, the brewing capacity is the maximum among them.\n\n    **Constraints:**\n\n    - `n == brew_counts.length`\n    - `1 <= n <= 5000`\n    - `0 <= brew_counts[i] <= 1000`\n\n    >>> brew_capability([3, 0, 6, 1, 5])\n    3\n    >>> brew_capability([1, 3, 1])\n    1\n    \"\"\"", "function_name": "brew_capability", "parameters": ["brew_counts"], "assert_statements": ["assert brew_capability([3, 0, 6, 1, 5]) == 3", "assert brew_capability([1, 3, 1]) == 1", "assert brew_capability([3, 0, 6, 1, 5, 6, 7, 4, 7, 9]) == 5"]}
{"id": 40, "difficulty_types": 2, "question": "from typing import List\n\ndef triangular_pair_of_a_to_b(a:int,b:int)->int: \n    \"\"\"A triangular number is a term in a sequence formed by the sum of natural numbers, with the nth triangular number represented as T_n, defined as T_n=1+2+3+...+n. This creates a sequence of triangular numbers: 1,3,6,10,15. Given two integer a and b, the sum from the a-th triangular number to the b-th triangular number (including a and b) called the sequence sum of triangular numbers. If there exists two triangular numbers Ti and Tj whose sum is equal to the sequence sum, then the two triangular numbers are called a triangular pair of a_to_b. Note that the sequence ab possibly has more than one triangle pair. For example, the triangular pairs of 3_to_4 are (1,15) and (6,10), because the third and fourth triangular numbers are 6 and 10, respectively. Given a and b (where a>1 and b>a+1), return the number of triangular pairs.\n    >>> triangular_pair_of_a_to_b(3,4)\n    2\n    >>> triangular_pair_of_a_to_b(3,5)\n    0\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef triangular_pair_of_a_to_b(a:int,b:int)->int: \n    \"\"\"A triangular number is a term in a sequence formed by the sum of natural numbers, with the nth triangular number represented as T_n, defined as T_n=1+2+3+...+n. This creates a sequence of triangular numbers: 1,3,6,10,15. Given two integer a and b, the sum from the a-th triangular number to the b-th triangular number (including a and b) called the sequence sum of triangular numbers. If there exists two triangular numbers Ti and Tj whose sum is equal to the sequence sum, then the two triangular numbers are called a triangular pair of a_to_b. Note that the sequence ab possibly has more than one triangle pair. For example, the triangular pairs of 3_to_4 are (1,15) and (6,10), because the third and fourth triangular numbers are 6 and 10, respectively. Given a and b (where a>1 and b>a+1), return the number of triangular pairs.\n    >>> triangular_pair_of_a_to_b(3,4)\n    2\n    >>> triangular_pair_of_a_to_b(3,5)\n    0\n    \"\"\"", "function_name": "triangular_pair_of_a_to_b", "parameters": ["a", "b"], "assert_statements": ["assert triangular_pair_of_a_to_b(2,4) == 0", "assert triangular_pair_of_a_to_b(3,30) == 6", "assert triangular_pair_of_a_to_b(2,40) == 4"]}
{"id": 41, "difficulty_types": 3, "question": "from typing import List\n\ndef next_fibonacci(numbers: List[int]) -> List[int]:\n    \"\"\"Given a sequence, where each number is greater than 10000 and belongs to the Fibonacci sequence,\n    this function quickly calculates the next Fibonacci number for each individual number and returns\n    them in a list in the order they were given.\n    >>> next_fibonacci([196418, 121393, 10946])\n    [317811, 196418, 17711]\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef next_fibonacci(numbers: List[int]) -> List[int]:\n    \"\"\"Given a sequence, where each number is greater than 10000 and belongs to the Fibonacci sequence,\n    this function quickly calculates the next Fibonacci number for each individual number and returns\n    them in a list in the order they were given.\n    >>> next_fibonacci([196418, 121393, 10946])\n    [317811, 196418, 17711]\n    \"\"\"", "function_name": "next_fibonacci", "parameters": ["numbers"], "assert_statements": ["assert next_fibonacci([86267571272, 139583862445, 10946]) == [139583862445, 225851433717, 17711]", "assert next_fibonacci([46368, 10610209857723]) == [75025, 17167680177565]", "assert next_fibonacci([10946, 28657, 46368, 75025]) == [17711, 46368, 75025, 121393]"]}
{"id": 42, "difficulty_types": 3, "question": "from typing import List\n\ndef largest_multiple_of_three(digits: List[int]) -> str:\n    \"\"\"Given an array, concatenate any number of digits in any order to form the largest number that is divisible by 3,\n    and return it in string type. If such a number does not exist, return an empty string. Also, remember to remove\n    any unnecessary leading zeros.\n    >>> largest_multiple_of_three([1])\n    \"\"\n    >>> largest_multiple_of_three([1, 9, 9, 7])\n    \"99\"\n    \"\"\"", "prompt": "Write a Python function according to the function name and the problem description in the docstring below. \n\nfrom typing import List\n\ndef largest_multiple_of_three(digits: List[int]) -> str:\n    \"\"\"Given an array, concatenate any number of digits in any order to form the largest number that is divisible by 3,\n    and return it in string type. If such a number does not exist, return an empty string. Also, remember to remove\n    any unnecessary leading zeros.\n    >>> largest_multiple_of_three([1])\n    \"\"\n    >>> largest_multiple_of_three([1, 9, 9, 7])\n    \"99\"\n    \"\"\"", "function_name": "largest_multiple_of_three", "parameters": ["digits"], "assert_statements": ["assert largest_multiple_of_three([1,0,0,0,0,0,0,0,1,0]) == \"0\"", "assert largest_multiple_of_three([9,8,6,8,6]) == \"966\"", "assert largest_multiple_of_three([8,7,0,7,7]) == \"7770\""]}
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AI生成曾小健

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值