task_id
stringlengths
5
7
question
stringlengths
192
1.48k
test_list
sequencelengths
2
5
test_function
stringlengths
54
236
entry_point
stringclasses
1 value
test_matching
stringlengths
57
291
test_match_function
stringclasses
1 value
OOP/94
First, design an **LS** class using the Python language, which has instance attributes **s** and **dictionary**, a private function **private_Longest_string**, and a public function **public_Longest_string**. Then, in the private function **private_Longest_string**, return the longest string in the **dictionary**, which can be obtained by deleting some characters in **s**. If there is more than one answer, return the string with the longest length and the smallest lexicographical order. If there is no answer, return an empty string. Finally, in the public function **public_Longest_string**, call the private function **private_Longest_string** to return the result.
[ "assert candidate(\"abpcplea\",[\"ale\",\"apple\",\"monkey\",\"plea\"])==\"apple\"", "assert candidate(\"abpcplea\",[\"a\",\"b\",\"c\"])==\"a\"" ]
def test_run(content1,content2): return LS(content1,content2).public_Longest_string()
test_run
assert candidate([["class LS", "def __init__(self, s, dictionary)", "def _private_Longest_string","def public_Longest_string"], ["class LS", "def __init__(self, s, dictionary)", "def __private_Longest_string","def public_Longest_string"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/95
Firstly, design an **AL** class using Python language, which has an instance attribute **nums**, a private function **private_Array_length**, and a public function **public_Array_length**. Then, find the longest consecutive subarray with the same number of 0 and 1 in the private function **private_Array_length**, and return the length of this subarray. Finally, call the private function **private_Array_length** in the public function **public_Array_length** to return the result.
[ "assert candidate([0,1])==2", "assert candidate([0,1,0])==2" ]
def test_run(content1): return AL(content1).public_Array_length()
test_run
assert candidate([["class AL", "def __init__(self, nums)", "def _private_Array_length","def public_Array_length"], ["class AL", "def __init__(self, nums)", "def __private_Array_length","def public_Array_length"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/96
Firstly, design a class **CQ** using the Python language, which has an instance attribute **n**, a private function **private_Construction_quantity**, and a public function **public_Construction_quantity**. Then, in the private function **private_Construction_quantity**, return the number of beautiful arrangements that can be constructed. Finally, in the public function **public_Construction_quantity**, call the private function **private_Construction_quantity** to return the result. The condition for a beautiful arrangement is: suppose there are **n** integers from 1 to **n**. Construct an array **perm** (index starts from 1) with these integers. As long as one of the following conditions is met, the array is a beautiful arrangement: 1. perm[i] can be divided by **i**; 2. **i** can be divided by perm[i].
[ "assert candidate(2)==2", "assert candidate(1)==1" ]
def test_run(content1): return CQ(content1).public_Construction_quantity()
test_run
assert candidate([["class CQ", "def __init__(self, n)", "def _private_Construction_quantity","def public_Construction_quantity"], ["class CQ", "def __init__(self, n)", "def __private_Construction_quantity","def public_Construction_quantity"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/97
Firstly, design an **RS** class using the Python language, which has an instance attribute **w**, a private function **private_Return_Subscript**, and a public function **public_Return_Subscript**. Then, in the private function **private_Return_Subscript**, randomly select and return a subscript from the range [0, w.length-1] (including 0 and w.length-1), with the probability of selecting subscript **i** being w[i]/sum(w). Finally, in the public function **public_Return_Subscript**, call the private function **private_Return_Subscript** to return the result.
[ "assert candidate([\"Solution\",\"pickIndex\"],[[[1]],[]])==[null,0]", "assert candidate([\"Solution\",\"pickIndex\",\"pickIndex\",\"pickIndex\",\"pickIndex\",\"pickIndex\"],[[[1,3]],[],[],[],[],[]])==[null,1,1,1,1,0]" ]
def test_run(content1,content2): return RS(content1,content2).public_Return_Subscript()
test_run
assert candidate([["class RS", "def __init__(self, w)", "def _private_Return_Subscript","def public_Return_Subscript"], ["class RS", "def __init__(self, w)", "def __private_Return_Subscript","def public_Return_Subscript"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/98
Firstly, design a class named **MG** using Python language, which has instance attributes **board** and **click**, a private function **private_Minesweeping_game**, and a public function **public_Minesweeping_game**. Then, implement the following problem in the private function **private_Minesweeping_game**. Finally, call the private function **private_Minesweeping_game** in the public function **public_Minesweeping_game** to return the result. Problem: Please design a minesweeper game represented by an m x n two-dimensional character matrix **board**. 'M', 'E', 'B', and 'X' respectively represent unexcavated mines, empty blocks, excavated blank blocks, and excavated mines. The specific rules are as follows: If a mine ('M') is excavated, the game ends, and it is changed to 'X'. If an empty block ('E') with no adjacent mines is excavated, change it to 'B', and all its adjacent unexcavated blocks should be recursively revealed. If an empty block ('E') adjacent to at least one mine is excavated, change it to a number ('1' to '8'), representing the number of adjacent mines. The requirement is to return the corresponding game board after the corresponding position is clicked.
[ "assert candidate([[\"E\",\"E\",\"E\",\"E\",\"E\"],[\"E\",\"E\",\"M\",\"E\",\"E\"],[\"E\",\"E\",\"E\",\"E\",\"E\"],[\"E\",\"E\",\"E\",\"E\",\"E\"]],[3,0])==[[\"B\",\"1\",\"E\",\"1\",\"B\"],[\"B\",\"1\",\"M\",\"1\",\"B\"],[\"B\",\"1\",\"1\",\"1\",\"B\"],[\"B\",\"B\",\"B\",\"B\",\"B\"]]", "assert candidate([[\"B\",\"1\",\"E\",\"1\",\"B\"],[\"B\",\"1\",\"M\",\"1\",\"B\"],[\"B\",\"1\",\"1\",\"1\",\"B\"],[\"B\",\"B\",\"B\",\"B\",\"B\"]],[1,2])==[[\"B\",\"1\",\"E\",\"1\",\"B\"],[\"B\",\"1\",\"X\",\"1\",\"B\"],[\"B\",\"1\",\"1\",\"1\",\"B\"],[\"B\",\"B\",\"B\",\"B\",\"B\"]]" ]
def test_run(content1,content2): return MG(content1,content2).public_Minesweeping_game()
test_run
assert candidate([["class MG", "def __init__(self, board, click)", "def _private_Minesweeping_game","def public_Minesweeping_game"], ["class MG", "def __init__(self, board, click)", "def __private_Minesweeping_game","def public_Minesweeping_game"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/99
Firstly, design a class **NP** using the Python language, which has instance attributes **nums** and **k**, a private function **private_Number_Pairs**, and a public function **public_Number_Pairs**. Then, return the number of different **k-diff** number pairs in the private function **private_Number_Pairs**. Finally, call the private function **private_Number_Pairs** in the public function **public_Number_Pairs** to return the result.
[ "assert candidate([3, 1, 4, 1, 5],2)==2", "assert candidate([1, 2, 3, 4, 5],1)==4", "assert candidate([1, 3, 1, 5, 4],0)==1" ]
def test_run(content1,content2): return NP(content1,content2).public_Number_Pairs()
test_run
assert candidate([["class NP", "def __init__(self, nums, k)", "def _private_Number_Pairs","def public_Number_Pairs"], ["class NP", "def __init__(self, nums, k)", "def __private_Number_Pairs","def public_Number_Pairs"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/100
Firstly, design a **SOP** class using the Python language, which has instance attributes **num1** and **num2**, a private function **String_product**, and a public function **public_String_product**. Then, in the private function **String_product**, follow the complex number representation format, and return a string representing the product of complex numbers **num1** and **num2**. Finally, in the public function **public_String_product**, call the private function **String_product** to return the result.
[ "assert candidate(\"1+1i\",\"1+1i\")==\"0+2i\"", "assert candidate(\"1+-1i\",\"1+-1i\")==\"0+-2i\"" ]
def test_run(content1,content2): return SOP(content1,content2).public_String_product()
test_run
assert candidate([["class SOP", "def __init__(self, num1, num2)", "def _String_product","def public_String_product"], ["class SOP", "def __init__(self, num1, num2)", "def __String_product","def public_String_product"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/101
Firstly, design an **MTD** class using the Python language, which has an instance attribute **timePoints**, a private function **Minimum_difference**, and a public function **public_Minimum_difference**. Then, in the private function **Minimum_difference**, return the minimum time difference between any two times in the list, represented in minutes. Finally, in the public function **public_Minimum_difference**, call the private function **Minimum_difference** to return the result.
[ "assert candidate([\"23:59\",\"00:00\"])==1", "assert candidate([\"00:00\",\"23:59\",\"00:00\"])==0" ]
def test_run(content1): return MTD(content1).public_Number_occurrences()
test_run
assert candidate([["class MTD", "def __init__(self, timePoints)", "def _Minimum_difference","def public_Minimum_difference"], ["class MTD", "def __init__(self, timePoints)", "def __Minimum_difference","def public_Minimum_difference"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/102
Firstly, design a class named **NOO** using Python language, which has an instance attribute **nums**, a private function **Number_occurrences**, and a public function **public_Number_occurrences**. Then, implement the following problem in the private function **Number_occurrences**. Finally, call the private function **Number_occurrences** in the public function **public_Number_occurrences** to return the result. Problem: Given a sorted array composed only of integers, where each element appears twice except for one that appears only once. Please find and return that single number.
[ "assert candidate([1,1,2,3,3,4,4,8,8])==2", "assert candidate([3,3,7,7,10,11,11])==10" ]
def test_run(content1): return NOO(content1).public_Number_of_occurrences()
test_run
assert candidate([["class NOO", "def __init__(self, nums)", "def _Number_occurrences","def public_Number_occurrences"], ["class NOO", "def __init__(self, nums)", "def __Number_occurrences","def public_Number_occurrences"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/103
Firstly, design a class named **MS** using Python language, which has an instance attribute **mat**, a private function **private_Matrices_size**, and a public function **public_Matrices_size**. Then, implement the following problem in the private function **private_Matrices_size**. Finally, call the private function **private_Matrices_size** in the public function **public_Matrices_size** to return the result. Problem: Given a matrix **mat** composed of 0 and 1, output a matrix of the same size, where each cell is the distance from the corresponding element in **mat** to the nearest 0. The distance between two adjacent elements is 1.
[ "assert candidate([[0,0,0],[0,1,0],[0,0,0]])==[[0,0,0],[0,1,0],[0,0,0]]", "assert candidate([[0,0,0],[0,1,0],[1,1,1]])==[[0,0,0],[0,1,0],[1,2,1]]" ]
def test_run(content1): return MS(content1).public_Matrices_size()
test_run
assert candidate([["class MS", "def __init__(self, mat)", "def _private_Matrices_size","def public_Matrices_size"], ["class MS", "def __init__(self, mat)", "def __private_Matrices_size","def public_Matrices_size"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/104
Firstly, design an **RB** class using Python language, which has an instance attribute **boxes**, a private function **private_Remove_Box**, and a public function **public_Remove_Box**. Then, implement the following problem in the private function **private_Remove_Box**. Finally, call the private function **private_Remove_Box** in the public function **public_Remove_Box** to return the result. Problem: Given some **boxes** of different colors, the color of the box is represented by different positive numbers. After several rounds of operations to remove the boxes until all the boxes are removed. In each round, you can remove **k** consecutive boxes of the same color (k >= 1), and you will get **k * k** points after such a round. Return the maximum sum of points that can be obtained.
[ "assert candidate([1,3,2,2,2,3,4,3,1])==23", "assert candidate([1,1,1])==9", "assert candidate([1])==1" ]
def test_run(content1): return RB(content1).public_Remove_Box()
test_run
assert candidate([["class RB", "def __init__(self, boxes)", "def _private_Remove_Box","def public_Remove_Box"], ["class RB", "def __init__(self, boxes)", "def __private_Remove_Box","def public_Remove_Box"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/105
Firstly, design an **AP** class using the Python language, which has an instance attribute **nums**, a private function **private_Add_parentheses**, and a public function **public_Add_parentheses**. Then, implement the following problem in the private function **private_Add_parentheses**. Finally, call the private function **private_Add_parentheses** in the public function **public_Add_parentheses** to return the result. Problem: Please perform floating-point division on a positive integer array **nums**. You can add any number of parentheses at any position to change the priority of arithmetic. Return the corresponding expression in string format with the maximum value.
[ "assert candidate([1000,100,10,2])==\"1000/(100/10/2)\"", "assert candidate([2,3,4])==\"2/(3/4)\"" ]
def test_run(content1): return AP(content1).public_Add_parentheses()
test_run
assert candidate([["class AP", "def __init__(self, nums)", "def _private_Add_parentheses","def public_Add_parentheses"], ["class AP", "def __init__(self, nums)", "def __private_Add_parentheses","def public_Add_parentheses"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/106
Firstly, design an **MI** class using Python language, which has an instance attribute **n**, a private function **private_Minimum_integer**, and a public function **public_Minimum_integer**. Then, implement the following problem in the private function **private_Minimum_integer**. Finally, call the private function **private_Minimum_integer** in the public function **public_Minimum_integer** to return the result. Problem: Given a positive integer **n**, find the smallest integer that meets the conditions, which is composed of each digit existing in **n** rearranged, and its value is greater than **n**. If there is no such positive integer, return -1.
[ "assert candidate(12)==21", "assert candidate(21)==-1" ]
def test_run(content1): return MI(content1).public_Minimum_integer()
test_run
assert candidate([["class MI", "def __init__(self, n)", "def _private_Minimum_integer","def public_Minimum_integer"], ["class MI", "def __init__(self, n)", "def __private_Minimum_integer","def public_Minimum_integer"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/107
Firstly, design an **IS** class using the Python language, which has an instance attribute **s**, a private function **private_Invert_String**, and a public function **public_Invert_String**. Then, in the private function **private_Invert_String**, output the string after reversing the character order of each word in the string, while still retaining the spaces and the initial order of the words. Finally, call the private function **private_Invert_String** in the public function **public_Invert_String** to return the result.
[ "assert candidate(\"Let's take LeetCode contest\")==\"s'teL ekat edoCteeL tsetnoc\"", "assert candidate(\"God Ding\")==\"doG gniD\"" ]
def test_run(content1): return IS(content1).public_Invert_String()
test_run
assert candidate([["class IS", "def __init__(self, s)", "def _private_Invert_String","def public_Invert_String"], ["class IS", "def __init__(self, s)", "def __private_Invert_String","def public_Invert_String"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/108
Firstly, design a **CS** class using Python language, which has instance attributes **nums** and **k**, a private function **private_Continuous_subarray**, and a public function **public_Continuous_subarray**. Then, in the private function **private_Continuous_subarray**, count and return the number of continuous subarrays in the array whose sum is **k**. Finally, call the private function **private_Continuous_subarray** in the public function **public_Continuous_subarray** to return the result.
[ "assert candidate([1,1,1],2)==2", "assert candidate([1,2,3],3)==2" ]
def test_run(content1,content2): return CS(content1,content2).public_Continuous_subarray()
test_run
assert candidate([["class IS", "def __init__(self, s)", "def _private_Invert_String","def public_Invert_String"], ["class IS", "def __init__(self, s)", "def __private_Invert_String","def public_Invert_String"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/109
Firstly, design a class **PI** using the Python language, which has an instance attribute **n**, a private function **private_Palindrome_integer**, and a public function **public_Palindrome_integer**. Then, in the private function **private_Palindrome_integer**, return the palindrome integer closest to the string **n** (excluding itself). If there is more than one, return the smaller one. **Closest** is defined as the smallest absolute difference between two integers. Finally, in the public function **public_Palindrome_integer**, call the private function **private_Palindrome_integer** to return the result.
[ "assert candidate(\"123\")==\"121\"", "assert candidate(\"1\")==\"0\"" ]
def test_run(content1): return PI(content1).public_Palindrome_integer()
test_run
assert candidate([["class PI", "def __init__(self, n)", "def _private_Palindrome_integer","def public_Palindrome_integer"], ["class PI", "def __init__(self, n)", "def __private_Palindrome_integer","def public_Palindrome_integer"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/110
Firstly, design a class **JA** using the Python language, which has instance attributes **s1** and **s2**, a private function **private_Judgment_arrangement**, and a public function **public_Judgment_arrangement**. Then, in the private function **private_Judgment_arrangement**, determine whether **s2** contains the arrangement of **s1**. If it does, return **True**; otherwise, return **False**. Finally, call the private function **private_Judgment_arrangement** in the public function **public_Judgment_arrangement** to return the result.
[ "assert candidate(\"ab\",\"eidbaooo\")==True", "assert candidate(\"ab\",\"eidboaoo\")==False" ]
def test_run(content1,content2): return JA(content1,content2).public_Judgment_arrangement()
test_run
assert candidate([["class JA", "def __init__(self, s1, s2)", "def _private_Judgment_arrangement","def public_Judgment_arrangement"], ["class JA", "def __init__(self, s1, s2)", "def __private_Judgment_arrangement","def public_Judgment_arrangement"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/111
Firstly, design a class named **SS** using the Python language, which includes an instance attribute **nums**, a private function **private_Shortest_subarray**, and a public function **public_Shortest_subarray**. Then, implement the following problem in the private function **private_Shortest_subarray**. Finally, call the private function **private_Shortest_subarray** in the public function **public_Shortest_subarray** to return the result. Problem: Given an integer array **nums**, you need to find a continuous subarray. If this subarray is sorted in ascending order, then the entire array will become sorted in ascending order. Please find the shortest subarray that meets this requirement and output its length.
[ "assert candidate([2,6,4,8,10,9,15])==5", "assert candidate([1,2,3,4])==0", "assert candidate([1])==0" ]
def test_run(content1): return SS(content1).public_Shortest_subarray()
test_run
assert candidate([["class SS", "def __init__(self, nums)", "def _private_Shortest_subarray","def public_Shortest_subarray"], ["class SS", "def __init__(self, nums)", "def __private_Shortest_subarray","def public_Shortest_subarray"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/112
Firstly, design a class named **MS** using the Python language, which has instance attributes **word1** and **word2**, a private function **private_Minimum_Steps**, and a public function **public_Minimum_Steps**. Then, in the private function **private_Minimum_Steps**, return the minimum number of steps required to make **word1** and **word2** identical. Finally, in the public function **public_Minimum_Steps**, call the private function **private_Minimum_Steps** to return the result.
[ "assert candidate(\"sea\",\"eat\")==2", "assert candidate(\"leetcode\",\"etco\")==4" ]
def test_run(content1,content2): return MS(content1,content2).public_Minimum_Steps()
test_run
assert candidate([["class MS", "def __init__(self, word1, word2)", "def _private_Minimum_Steps","def public_Minimum_Steps"], ["class MS", "def __init__(self, word1, word2)", "def __private_Minimum_Steps","def public_Minimum_Steps"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/113
Firstly, design an **RC** class using the Python language, which has an instance attribute **trees**, a private function **private_Return_Coordinates**, and a public function **public_Return_Coordinates**. Then, implement the following problem in the private function **private_Return_Coordinates**. Finally, call the private function **private_Return_Coordinates** in the public function **public_Return_Coordinates** to return the result. Problem: Given an array **trees**, where trees[i]=[x_i, y_i] represents the location of the tree in the garden. You are required to enclose the entire garden with the shortest length of rope because the rope is expensive. The garden is well enclosed only when all the trees are enclosed. Return the coordinates of the trees that are exactly on the perimeter of the fence.
[ "assert candidate([[1,1],[2,2],[2,0],[2,4],[3,3],[4,2]])==[[1,1],[2,0],[3,3],[2,4],[4,2]]", "assert candidate([[1,2],[2,2],[4,2]])==[[4,2],[2,2],[1,2]]" ]
def test_run(content1): return RC(content1).public_Return_Coordinates()
test_run
assert candidate([["class RC", "def __init__(self, trees)", "def _private_Return_Coordinates","def public_Return_Coordinates"], ["class RC", "def __init__(self, trees)", "def __private_Return_Coordinates","def public_Return_Coordinates"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/114
First, design a class named **MS** using Python language, which has an instance attribute **expression**, a private function **private_Minimal_Score**, and a public function **public_Minimal_Score**. Then, implement the following problem in the private function **private_Minimal_Score**. Finally, call the private function **private_Minimal_Score** in the public function **public_Minimal_Score** to return the result. Problem: Given a string **expression** representing addition and subtraction of scores, you need to return a string form of the calculated result. This result should be an irreducible fraction, that is, the simplest fraction. If the final result is an integer, for example, an integer 2, you need to convert it into a fraction form with a denominator of 1. So in the above example, 2 should be converted to 2/1.
[ "assert candidate(\"-1/2+1/2\")==\"0/1\"", "assert candidate(\"-1/2+1/2\")==\"0/1\"", "assert candidate(\"1/3-1/2\")==\"-1/6\"" ]
def test_run(content1): return MS(content1).public_Minimal_Score()
test_run
assert candidate([["class MS", "def __init__(self, expression)", "def _private_Minimal_Score","def public_Minimal_Score"], ["class MS", "def __init__(self, expression)", "def __private_Minimal_Score","def public_Minimal_Score"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/115
Firstly, design a **FAS** class using the Python language, which has instance attributes **p1**, **p2**, **p3**, and **p4**, a private function **Form_square**, and a public function **public_Form_square**. Then, in the private function **Form_square**, determine whether the four points form a square. If they do, return True; otherwise, return False. Finally, in the public function **public_Form_square**, call the private function **Form_square** to return the result.
[ "assert candidate([0,0],[1,1],[1,0],[0,1])==True", "assert candidate([0,0],[1,1],[1,0],[0,12])==False", "assert candidate([1,0],[-1,0],[0,1],[0,-1])==False" ]
def test_run(content1,content2,content3,content4): return FAS(content1,content2,content3,content4).public_Form_square()
test_run
assert candidate([["class FAS", "def __init__(self, p1, p2, p3, p4)", "def _Form_square","def public_Form_a_square"], ["class FAS", "def __init__(self, p1, p2, p3, p4)", "def __Form_square","def public_Form_a_square"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/116
Firstly, design a **TC** class using Python language, which has an instance attribute **n**, a private function **private_There_continuity**, and a public function **public_There_continuity**. Then, in the private function **private_There_continuity**, count how many non-negative integers in the range of [0, n] do not have consecutive 1 in their binary representation. Finally, call the private function **private_There_continuity** in the public function **public_There_continuity** to return the result.
[ "assert candidate(5)==5", "assert candidate(1)==2", "assert candidate(2)==3" ]
def test_run(content1): return TC(content1).public_There_continuity()
test_run
assert candidate([["class TC", "def __init__(self, n)", "def _private_There_continuity","def public_There_continuity"], ["class TC", "def __init__(self, n)", "def __private_There_continuity","def public_There_continuity"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/117
Firstly, design a **NOT** class using Python language, which has an instance attribute **nums**, a private function **private_Number_of_triples**, and a public function **public_Number_of_triples**. Then, in the private function **private_Number_of_triples**, return the number of triples that **nums** can form the three sides of a triangle. Finally, in the public function **public_Number_of_triples**, call the private function **private_Number_of_triples** to return the result.
[ "assert candidate([2,2,3,4])==3", "assert candidate([4,2,3,4])==4" ]
def test_run(content1): return NOT(content1).public_Number_of_triples()
test_run
assert candidate([["class NOT", "def __init__(self, nums)", "def _private_Number_of_triples","def public_Number_of_triples"], ["class NOT", "def __init__(self, nums)", "def __private_Number_of_triples","def public_Number_of_triples"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/118
Firstly, design an **MT** class using Python language, which has instance attributes **tasks** and **n**, a private function **private_Minimum_time**, and a public function **public_Minimum_time**. Then, implement the following problem in the private function **private_Minimum_time**. Finally, call the private function **private_Minimum_time** in the public function **public_Minimum_time** to return the result. Problem: Given a list of tasks that the CPU needs to execute, represented by a character array **tasks**. Each letter represents a different type of task. Tasks can be executed in any order, and each task can be completed within 1 unit of time. In any unit of time, the CPU can complete a task or be in standby mode. However, there must be a cooling time of integer **n** between two tasks of the same type, so the CPU must be executing different tasks or in standby mode for at least continuous **n** units of time. Calculate the shortest time required to complete all tasks.
[ "assert candidate([\"A\",\"A\",\"A\",\"B\",\"B\",\"B\"],2)==8", "assert candidate([\"A\",\"A\",\"A\",\"B\",\"B\",\"B\"],0)==6", "assert candidate([\"A\",\"A\",\"A\",\"A\",\"A\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\"],2)==16" ]
def test_run(content1,content2): return MT(content1,content2).public_Minimum_time()
test_run
assert candidate([["class MT", "def __init__(self, tasks, n)", "def _private_Minimum_time","def public_Minimum_time"], ["class MT", "def __init__(self, tasks, n)", "def __private_Minimum_time","def public_Minimum_time"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/119
Firstly, design a class named **ROP** using the Python language, which has instance attributes **n** and **k**, a private function **private_Reverse_order_pair**, and a public function **public_Reverse_order_pair**. Then, implement the following problem in the private function **private_Reverse_order_pair**. Finally, call the private function **private_Reverse_order_pair** in the public function **public_Reverse_order_pair** to return the result. Problem: Please find out the number of different arrays that contain numbers from 1 to **n** and exactly have **k** reverse order pairs. Definition of reverse order pair: For the i-th and j-th elements of the array **nums**, if it satisfies 0<=i<j<nums.length and nums[i]>nums[j], it is a reverse order pair; otherwise, it is not.
[ "assert candidate(3,0)==1", "assert candidate(3,1)==2" ]
def test_run(content1,content2): return ROP(content1,content2).public_Reverse_order_pair()
test_run
assert candidate([["class ROP", "def __init__(self, n, k)", "def _private_Reverse_order_pair","def public_Reverse_order_pair"], ["class ROP", "def __init__(self, n, k)", "def __private_Reverse_order_pair","def public_Reverse_order_pair"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/120
Firstly, design an **NCT** class using Python language, which has an instance attribute **courses**, a private function **private_Number_courses_taken**, and a public function **public_Number_courses_taken**. Then, implement the following problem in the private function **private_Number_courses_taken**. Finally, call the private function **private_Number_courses_taken** in the public function **public_Number_courses_taken** to return the result. Problem: Here are **n** different online courses, numbered from 1 to **n**. Given an array **courses**, where courses[i] = [duration_i, lastDay_i] indicates that the i-th course will last for **duration_i** days, and must be completed no later than **lastDay_i**. Your semester starts from the first day and you cannot take two or more courses at the same time. Return the maximum number of courses you can take.
[ "assert candidate([[100,200],[200,1300],[1000,1250],[2000,3200]])==3", "assert candidate([[1,2]])==1", "assert candidate([[3,2],[4,3]])==0" ]
def test_run(content1): return NCT(content1).public_Number_courses_taken()
test_run
assert candidate([["class NCT", "def __init__(self, courses)", "def _private_Number_courses_taken","def public_Number_courses_taken"], ["class NCT", "def __init__(self, courses)", "def __private_Number_courses_taken","def public_Number_courses_taken"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/121
Firstly, design a class **JI** using the Python language, which has an instance attribute **c**, a private function **private_Judging_integers**, and a public function **public_Judging_integers**. Then, in the private function **private_Judging_integers**, determine whether there exist two integers **a** and **b** such that a^2 + b^2 = c. If they exist, return True, otherwise, return False. Finally, call the private function **private_Judging_integers** in the public function **public_Judging_integers** to return the result.
[ "assert candidate(5)==True", "assert candidate(3)==False" ]
def test_run(content1): return JI(content1).public_Judging_integers()
test_run
assert candidate([["class JI", "def __init__(self, c)", "def _private_Judging_integers","def public_Judging_integers"], ["class JI", "def __init__(self, c)", "def __private_Judging_integers","def public_Judging_integers"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/122
First, design a class **SE** using the Python language, which has an instance attribute **equation**, a private function **private_solve_equation**, and a public function **public_solve_equation**. Then, implement the following problem in the private function **private_solve_equation**. Finally, call the private function **private_solve_equation** in the public function **public_solve_equation** to return the result. Problem: Solve a given equation and return **x** in the form of a string **x=#value**. The equation only contains '+' and '-' operations, the variable **x** and its corresponding coefficient. If the equation has no solution or the existing solution is not an integer, please return **No solution**. If the equation has infinite solutions, return **Infinite solutions**.
[ "assert candidate(\"x+5-3+x=6+x-2\")==\"x=2\"", "assert candidate(\"x=x\")==\"Infinite solutions\"", "assert candidate(\"2x=x\")==\"x=0\"" ]
def test_run(content1): return SE(content1).public_solve_equation()
test_run
assert candidate([["class SE", "def __init__(self, equation)", "def _private_solve_equation","def public_solve_equation"], ["class SE", "def __init__(self, equation)", "def __private_solve_equation","def public_solve_equation"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/123
Firstly, design an **LPC** class using Python language, which has an instance attribute **pairs**, a private function **private_Longest_pair_chain**, and a public function **public_Longest_pair_chain**. Then, implement the following problem in the private function **private_Longest_pair_chain**. Finally, call the private function **private_Longest_pair_chain** in the public function **public_Longest_pair_chain** to return the result. Problem: Given an array of pairs **pairs** composed of n pairs, where pairs[i] = [left_i, right_i] and left_i < right_i. Now, define a following relationship, where pair p2 = [c, d] can only follow p1 = [a, b] if and only if b < c. Use this form to construct a pair chain, find and return the length of the longest pair chain that can be formed.
[ "assert candidate([[1,2], [2,3], [3,4]])==2", "assert candidate([[1,2],[7,8],[4,5]])==3" ]
def test_run(content1): return LPC(content1).public_Longest_pair_chain()
test_run
assert candidate([["class LPC", "def __init__(self, pairs)", "def _private_Longest_pair_chain","def public_Longest_pair_chain"], ["class LPC", "def __init__(self, pairs)", "def __private_Longest_pair_chain","def public_Longest_pair_chain"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/124
Firstly, design a **PS** class using Python language, which has an instance attribute **s**, a private function **private_Palindrome_substring**, and a public function **public_Palindrome_substring**. Then, return the number of palindrome substrings in the string **s** within the private function **private_Palindrome_substring**. Finally, call the private function **private_Palindrome_substring** to return the result within the public function **public_Palindrome_substring**.
[ "assert candidate(\"abc\")==3", "assert candidate(\"aaa\")==6" ]
def test_run(content1): return PS(content1).public_Palindrome_substring()
test_run
assert candidate([["class PS", "def __init__(self, s)", "def _private_Palindrome_substring","def public_Palindrome_substring"], ["class PS", "def __init__(self, s)", "def __private_Palindrome_substring","def public_Palindrome_substring"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/125
Firstly, design an **RS** class using the Python language, which has instance attributes **dictionary** and **sentence**, a private function **private_Root_substitution**, and a public function **public_Root_substitution**. Then, implement the following problem in the private function **private_Root_substitution**. Finally, call the private function **private_Root_substitution** in the public function **public_Root_substitution** to return the result. Problem: In English, there is a concept called **root**, where you can add other words after the root to form a longer word, which is called a **successor** word. For example, the root **an**, followed by the word **other**, can form a new word **another**. Now, given a **dictionary** composed of many roots and a **sentence** formed by words separated by spaces. You need to replace all the successor words in the sentence with the root. If there are many roots that can form the successor word, replace it with the shortest root. You need to output the sentence after the replacement.
[ "assert candidate([\"cat\",\"bat\",\"rat\"],\"the cattle was rattled by the battery\")==\"the cat was rat by the bat\"", "assert candidate([\"a\",\"b\",\"c\"],\"aadsfasf absbs bbab cadsfafs\")==\"a a b c\"" ]
def test_run(content1,content2): return RS(content1,content2).public_Root_substitution()
test_run
assert candidate([["class RS", "def __init__(self, dictionary, sentence)", "def _private_Root_substitution","def public_Root_substitution"], ["class RS", "def __init__(self, dictionary, sentence)", "def __private_Root_substitution","def public_Root_substitution"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/126
Firstly, design an **MNO** class using Python language, which has an instance attribute **n**, a private function **Minimum_operations**, and a public function **public_Minimum_operations**. Then, implement the following problem in the private function **Minimum_operations**. Finally, call the private function **Minimum_operations** in the public function **public_Minimum_operations** to return the result. Problem: Initially, there is only one character 'A' on the notepad. You can perform two types of operations on this notepad each time: 1. Copy All: Copy all characters in this notepad (partial copying is not allowed); 2. Paste: Paste the characters copied last time. Given a number **n**, you need to use the minimum number of operations to output exactly **n** 'A's on the notepad. Return the minimum number of operations that can print out **n** 'A's.
[ "assert candidate(3)==3", "assert candidate(1)==0" ]
def test_run(content1): return MNO(content1).public_Minimum_operations()
test_run
assert candidate([["class MNO", "def __init__(self, n)", "def _Minimum_operations","def public_Minimum_operations"], ["class MNO", "def __init__(self, n)", "def __Minimum_operations","def public_Minimum_operations"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/127
Firstly, design an **FPV** class using Python language, which has instance attributes **arr**, **k**, and **x**, a private function **private_Find_Proximity_Values**, and a public function **public_Find_Proximity_Values**. Then, implement the following problem in the private function **private_Find_Proximity_Values**. Finally, call the private function **private_Find_Proximity_Values** in the public function **public_Find_Proximity_Values** to return the result. Problem: Given a sorted array **arr**, two integers **k** and **x**, find the **k** numbers closest to **x** (the difference between the two numbers is the smallest) from the array. The returned result must be sorted in ascending order. An integer **a** is closer to **x** than an integer **b** if: |a-x| < |b-x| or |a-x| == |b-x| and a < b.
[ "assert candidate([1,2,3,4,5],4,3)==[1,2,3,4]", "assert candidate([1,2,3,4,5],4,-1)==[1,2,3,4]" ]
def test_run(content1,content2,content3): return FPV(content1,content2,content3).public_Find_Proximity_Values()
test_run
assert candidate([["class FPV", "def __init__(self, arr, k, x)", "def _private_Find_Proximity_Values","def public_Find_Proximity_Values"], ["class FPV", "def __init__(self, arr, k, x)", "def __private_Find_Proximity_Values","def public_Find_Proximity_Values"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/128
Firstly, design a **JS** class using the Python language, which has an instance attribute **nums**, a private function **private_Judgment_segmentation**, and a public function **public_Judgment_segmentation**. Then, implement the following problem in the private function **private_Judgment_segmentation**. Finally, call the private function **private_Judgment_segmentation** in the public function **public_Judgment_segmentation** to return the result. Problem: Given an integer array **nums** sorted in non-decreasing order. Please judge whether it is possible to satisfy the following two conditions while dividing **nums** into one or more sub-sequences: each sub-sequence is a continuous increasing sequence (that is, each integer is exactly one larger than the previous one); the length of all sub-sequences is at least 3. If **nums** can be divided and meet the above conditions, return True; otherwise, return False.
[ "assert candidate([1,2,3,3,4,5])==True", "assert candidate([1,2,3,3,4,4,5,5])==True", "assert candidate([1,2,3,4,4,5])==False" ]
def test_run(content1): return JS(content1).public_Judgment_segmentation()
test_run
assert candidate([["class JS", "def __init__(self, nums)", "def _private_Judgment_segmentation","def public_Judgment_segmentation"], ["class JS", "def __init__(self, nums)", "def _private_Judgment_segmentation","def public_Judgment_segmentation"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/129
Firstly, design an **MPT** class using Python language, which has an instance attribute **s**, a private function **Minimum_Times**, and a public function **public_Minimum_Times**. Then, implement the following problem in the private function **Minimum_Times**. Finally, call the private function **Minimum_Times** in the public function **public_Minimum_Times** to return the result. Problem: There is a strange printer with the following two special requirements: 1. The printer can only print a sequence composed of the same character each time; 2. It can print a new character at any position from the beginning to the end each time, and it will overwrite the original characters. Given a string **s**, your task is to calculate the minimum number of times this printer needs to print it.
[ "assert candidate(\"aaabbb\")==2", "assert candidate(\"aba\")==2" ]
def test_run(content1): return MPT(content1).public_Minimum_Times()
test_run
assert candidate([["class MPT", "def __init__(self, s)", "def _Minimum_Times","def public_Minimum_Times"], ["class MPT", "def __init__(self, s)", "def __Minimum_Times","def public_Minimum_Times"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/130
Firstly, design an **NDC** class using Python language, which has an instance attribute **nums**, a private function **private_Non_decreasing_column**, and a public function **public_Non_decreasing_column**. Then, implement the following problem in the private function **private_Non_decreasing_column**. Finally, call the private function **private_Non_decreasing_column** in the public function **public_Non_decreasing_column** to return the result. Problem: Given an integer array **nums** of length **n**, please determine whether this array can become a non-decreasing sequence by changing at most one element. Definition of non-decreasing sequence: For any **i** (0 <= i <= n-2) in the array, it always satisfies that nums[i]<= nums[i + 1].
[ "assert candidate([4,2,3])==True", "assert candidate([4,2,1])==False" ]
def test_run(content1): return NDC(content1).public_Non_decreasing_column()
test_run
assert candidate([["class NDC", "def __init__(self, nums)", "def _private_Non_decreasing_column","def public_Non_decreasing_column"], ["class NDC", "def __init__(self, nums)", "def __private_Non_decreasing_column","def public_Non_decreasing_column"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/131
Firstly, design an **AL** class using Python language, which has instance attributes **n** and **k**, a private function **private_Answer_List**, and a public function **public_Answer_List**. Then, return the constructed answer list **answer** in the private function **private_Answer_List**. Finally, call the private function **private_Answer_List** in the public function **public_Answer_List** to return the result. Problem: Given two integers **n** and **k**, please construct an answer list **answer**. This list should contain **n** different positive integers from 1 to **n**, and at the same time meet the following condition: Assuming the list is answer=[a1, a2, a3, ... , an], then the list [|a1 - a2|,|a2 - a3|,|a3 - a4|,...,|an-1 - an|] should have exactly **k** different integers. Return the list **answer**.
[ "assert candidate(3,1)==[1, 2, 3]", "assert candidate(3,2)==[1, 3, 2]" ]
def test_run(content1,content2): return AL(content1,content2).public_Answer_List()
test_run
assert candidate([["class AL", "def __init__(self, n, k)", "def _private_Answer_List","def public_Answer_List"], ["class AL", "def __init__(self, n, k)", "def _private_Answer_List","def public_Answer_List"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/132
Firstly, design a class named **LIS** using Python language, which has instance attribute **nums**, a private function **lo_in_sub**, and a public function **public_lo_in_sub**. Then, in the private function **lo_in_sub**, return the count of the longest increasing subsequence from the unsorted integer array **nums**. Finally, in the public function **public_lo_in_sub**, call the private function **lo_in_sub** to return the result.
[ "assert candidate([1,3,5,4,7])==2", "assert candidate([2,2,2,2,2])==5" ]
def test_run(content1): return LIS(content1).public_lo_in_sub()
test_run
assert candidate([["class LIS", "def __init__(self, nums)", "def _lo_in_sub","def public_lo_in_sub"], ["class LIS", "def __init__(self, nums)", "def __lo_in_sub","def public_lo_in_sub"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/133
Firstly, design a **CDT** class using Python language, which has an instance attribute **forest**, a private function **private_Chop_down_trees**, and a public function **public_Chop_down_trees**. Then, implement the following problem in the private function **private_Chop_down_trees**. Finally, call the private function **private_Chop_down_trees** in the public function **public_Chop_down_trees** to return the result. Problem: The forest is represented by an m x n matrix. In this matrix, 0 represents an obstacle that cannot be touched; 1 represents the ground where you can walk. Numbers larger than 1 represent cells with trees, which can be walked on, and the number represents the height of the tree. At each step, you can move one unit in one of the four directions: up, down, left, or right. If there is a tree where you stand, you can decide whether to cut it down. You need to cut down all the trees from low to high according to the height of the trees. After cutting down a tree, the value of the cell becomes **1** (i.e., it becomes the ground). You will start working from the point (0, 0), and return the minimum number of steps you need to take to cut down all the trees. If you cannot cut down all the trees, return -1.
[ "assert candidate([[1,2,3],[0,0,4],[7,6,5]])==6", "assert candidate([[1,2,3],[0,0,0],[7,6,5]])==-1", "assert candidate([[2,3,4],[0,0,5],[8,7,6]])==6" ]
def test_run(content1): return CDT(content1).public_Chop_down_trees()
test_run
assert candidate([["class CDT", "def __init__(self, forest)", "def _private_Chop_down_trees","def public_Chop_down_trees"], ["class CDT", "def __init__(self, forest)", "def __private_Chop_down_trees","def public_Chop_down_trees"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/134
Firstly, design a **VS** class using Python language, which has an instance attribute **s**, a private function **private_Valid_String**, and a public function **public_Valid_String**. Then, implement the following problem in the private function **private_Valid_String**. Finally, call the private function **private_Valid_String** in the public function **public_Valid_String** and return the result. Problem: Given a string that only contains three types of characters, the supported character types are '(', ')', and '*'. Please check whether this string is a valid string. If it is a valid string, return True; otherwise, return False.
[ "assert candidate(\"()\")==True", "assert candidate(\"(*)\")==True", "assert candidate(\"(*))\")==True" ]
def test_run(content1): return VS(content1).public_Valid_String()
test_run
assert candidate([["class VS", "def __init__(self, s)", "def _private_Valid_String","def public_Valid_String"], ["class VS", "def __init__(self, s)", "def __private_Valid_String","def public_Valid_String"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/135
Firstly, design a class **ME** using the Python language, which has an instance attribute **cards**, a private function **private_mathematical_expression**, and a public function **public_mathematical_expression**. Then, implement the following problem in the private function **private_mathematical_expression**. Finally, call the private function **private_mathematical_expression** in the public function **public_mathematical_expression** to return the result. Problem: Given an integer array **cards** of length 4. Assume there are 4 cards, each containing a number ranging from [1,9]. You should arrange the numbers on these cards into a mathematical expression using the operators ['+', '-', '*', '/'] and parentheses '(' and ')' to achieve the value 24. You must follow these rules: 1. The division operator '/' represents real number division, not integer division; 2. Each operation is between two numbers. Specifically, you cannot use "-" as a unary operator. For example, if cards = [1,1,1,1], the expression "-1 -1 -1 -1" is not allowed; 3. You cannot string numbers together. If cards = [1,2,1,2], the expression "12 + 12" is invalid. If such an expression can be obtained and its calculation result is 24, return True, otherwise return False.
[ "assert candidate([4, 1, 8, 7])==True", "assert candidate([1, 2, 1, 2])==False" ]
def test_run(content1): return ME(content1).public_mathematical_expression()
test_run
assert candidate([["class ME", "def __init__(self, cards)", "def _private_mathematical_expression","def public_mathematical_expression"], ["class ME", "def __init__(self, cards)", "def __private_mathematical_expression","def public_mathematical_expression"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/136
Firstly, design an **OS** class using Python language, which has instance attributes **a** and **b**, a private function **private_Overlay_substring**, and a public function **public_Overlay_substring**. Then, implement the following problem in the private function **private_Overlay_substring**. Finally, call the private function **private_Overlay_substring** in the public function **public_Overlay_substring** to return the result. Problem: Given two strings **a** and **b**, find the minimum number of times string **a** needs to be repeatedly overlaid so that string **b** becomes a substring of the overlaid string **a**. If it does not exist, return -1.
[ "assert candidate(\"abcd\",\"cdabcdab\")==3", "assert candidate(\"a\",\"aa\")==2", "assert candidate(\"a\",\"a\")==1", "assert candidate(\"abc\",\"wxyz\")==-1" ]
def test_run(content1,content2): return OS(content1,content2).public_Overlay_substring()
test_run
assert candidate([["class OS", "def __init__(self, a, b)", "def _private_Overlay_substring","def public_Overlay_substring"], ["class OS", "def __init__(self, a, b)", "def __private_Overlay_substring","def public_Overlay_substring"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/137
Firstly, design a **KC** class using Python language, which has instance attributes **n**, **k**, **row**, and **column**, a private function **private_Knight_Chessboard**, and a public function **public_Knight_Chessboard**. Then, implement the following problem in the private function **private_Knight_Chessboard**. Finally, call the private function **private_Knight_Chessboard** in the public function **public_Knight_Chessboard** to return the result. Problem: On an n x n international chessboard, a knight starts from the cell (row, column) and tries to make **k** moves. Rows and columns start from 0, so the top-left cell is (0,0), and the bottom-right cell is (n - 1, n - 1). The chess knight has 8 possible moves, each move is two cells in the basic direction, then one cell in the orthogonal direction. Each time the knight is to move, it randomly selects one from the 8 possible moves (even if the piece will leave the board), and then moves there. The knight continues to move until it has taken **k** steps or has left the board. Return the probability that the knight still remains on the board after it stops moving.
[ "assert candidate(3,2,0,0)==0.0625", "assert candidate(1,0,0,0)==1.00000" ]
def test_run(content1,content2,content3,content4): return KC(content1,content2,content3,content4).public_Knight_Chessboard()
test_run
assert candidate([["class KC", "def __init__(self, n, k, row, column)", "def _private_Knight_Chessboard","def public_Knight_Chessboard"], ["class KC", "def __init__(self, n, k, row, column)", "def __private_Knight_Chessboard","def public_Knight_Chessboard"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/138
Firstly, design an **MS** class using Python language, which has instance attributes **nums** and **k**, a private function **private_Maximum_subarray**, and a public function **public_Maximum_subarray**. Then, implement the following problem in the private function **private_Maximum_subarray**. Finally, call the private function **private_Maximum_subarray** in the public function **public_Maximum_subarray** to return the result. Problem: Given an integer array **nums** and an integer **k**, find three non-overlapping subarrays of length **k** with the maximum sum of all numbers (3*k items) and return these three subarrays.
[ "assert candidate([1,2,1,2,6,7,5,1],2)==[0,3,5]", "assert candidate([1,2,1,2,1,2,1,2,1],2)==[0,2,4]" ]
def test_run(content1,content2): return MS(content1,content2).public_Maximum_subarray()
test_run
assert candidate([["class MS", "def __init__(self, nums, k)", "def _private_Maximum_subarray","def public_Maximum_subarray"], ["class MS", "def __init__(self, nums, k)", "def __private_Maximum_subarray","def public_Maximum_subarray"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/139
Firstly, design a class named **SW** using Python language, which has instance attributes **stickers** and **target**, a private function **private_Sticker_Words**, and a public function **public_Sticker_Words**. Then, implement the following problem in the private function **private_Sticker_Words**. Finally, call the private function **private_Sticker_Words** in the public function **public_Sticker_Words** to return the result. Problem: There are **n** different types of stickers, each with a lowercase English word on it. You want to spell out a given string **target** by cutting individual letters from the collected stickers and rearranging them. If you wish, you can use each sticker multiple times, and the quantity of each sticker is unlimited. Return the minimum number of stickers required to spell out the **target**. If the task is impossible, return -1.
[ "assert candidate([\"with\",\"example\",\"science\"],\"thehat\")==3", "assert candidate([\"notice\",\"possible\"],\"basicbasic\")==-1" ]
def test_run(content1,content2): return SW(content1,content2).public_Sticker_Words()
test_run
assert candidate([["class SW", "def __init__(self, stickers, target)", "def _private_Sticker_Words","def public_Sticker_Words"], ["class SW", "def __init__(self, stickers, target)", "def __private_Sticker_Words","def public_Sticker_Words"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/140
Firstly, design an **MT** class using the Python language, which has instance attributes **words** and **k**, a private function **private_Most_times**, and a public function **public_Most_times**. Then, in the private function **private_Most_times**, return the top **k** most frequently occurring words from a given word list **words** and an integer **k**. Finally, call the private function **private_Most_times** in the public function **public_Most_times** to return the result.
[ "assert candidate([\"i\", \"love\", \"leetcode\", \"i\", \"love\", \"coding\"],2)==[\"i\", \"love\"]", "assert candidate([\"the\", \"day\", \"is\", \"sunny\", \"the\", \"the\", \"the\", \"sunny\", \"is\", \"is\"],4)==[\"the\", \"is\", \"sunny\", \"day\"]" ]
def test_run(content1,content2): return MT(content1,content2).public_Most_times()
test_run
assert candidate([["class MT", "def __init__(self, words, k)", "def _private_Most_times","def public_Most_times"], ["class MT", "def __init__(self, words, k)", "def __private_Most_times","def public_Most_times"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/141
Firstly, design an **AA** class using the Python language, which has an instance attribute **n**, a private function **private_Alternating_appearance**, and a public function **public_Alternating_appearance**. Then, implement the following problem in the private function **private_Alternating_appearance**. Finally, call the private function **private_Alternating_appearance** in the public function **public_Alternating_appearance** to return the result. Problem: Given a positive integer, check whether its binary representation always alternates between 0 and 1. In other words, the adjacent digits in the binary representation are never the same. If 0 and 1 alternate, return True; otherwise, return False.
[ "assert candidate(5)==True", "assert candidate(7)==False", "assert candidate(11)==False" ]
def test_run(content1): return AA(content1).public_Alternating_appearance()
test_run
assert candidate([["class AA", "def __init__(self, n)", "def _private_Alternating_appearance","def public_Alternating_appearance"], ["class AA", "def __init__(self, n)", "def __private_Alternating_appearance","def public_Alternating_appearance"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/142
Firstly, design an **IA** class using Python language, which has an instance attribute **grid**, a private function **private_Island_area**, and a public function **public_Island_area**. Then, implement the following problem in the private function **private_Island_area**. Finally, call the private function **private_Island_area** in the public function **public_Island_area** to return the result. Problem: Given a binary matrix **grid** of size m x n. An island is a combination of some adjacent 1s (representing land), where adjacency requires that two 1s must be adjacent in the horizontal or vertical four directions. It can be assumed that the four edges of the **grid** are surrounded by 0s (representing water). The area of the island is the number of cells on the island with a value of 1. Calculate and return the largest island area in the **grid**. If there is no island, return an area of 0.
[ "assert candidate([[0,0,1,0,0,0,0,1,0,0,0,0,0],[0,0,0,0,0,0,0,1,1,1,0,0,0],[0,1,1,0,1,0,0,0,0,0,0,0,0],[0,1,0,0,1,1,0,0,1,0,1,0,0],[0,1,0,0,1,1,0,0,1,1,1,0,0],[0,0,0,0,0,0,0,0,0,0,1,0,0],[0,0,0,0,0,0,0,1,1,1,0,0,0],[0,0,0,0,0,0,0,1,1,0,0,0,0]])==6", "assert candidate([[0,0,0,0,0,0,0,0]])==0" ]
def test_run(content1): return IA(content1).public_Island_area()
test_run
assert candidate([["class IA", "def __init__(self, grid)", "def _private_Island_area","def public_Island_area"], ["class IA", "def __init__(self, grid)", "def __private_Island_area","def public_Island_area"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/143
Firstly, design an **ES** class using Python language, which has instance attributes **nums** and **k**, a private function **private_Equal_sum**, and a public function **public_Equal_sum**. Then, in the private function **private_Equal_sum**, determine whether it is possible to divide this array into **k** non-empty subsets with equal sums, based on a given integer array **nums** and a positive integer **k**. Finally, call the private function **private_Equal_sum** in the public function **public_Equal_sum** to return the result.
[ "assert candidate([4, 3, 2, 3, 5, 2, 1],4)==True", "assert candidate([1,2,3,4],3)==False" ]
def test_run(content1,content2): return ES(content1,content2).public_Equal_sum()
test_run
assert candidate([["class ES", "def __init__(self, nums, k)", "def _private_Equal_sum","def public_Equal_sum"], ["class ES", "def __init__(self, nums, k)", "def __private_Equal_sum","def public_Equal_sum"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/144
Firstly, design a **BS** class using Python language, which has an instance attribute **positions**, a private function **private_Block_stacking**, and a public function **public_Block_stacking**. Then, implement the following problem in the private function **private_Block_stacking**. Finally, call the private function **private_Block_stacking** in the public function **public_Block_stacking** to return the result. Problem: Given a two-dimensional integer array **positions**, where positions[i] = [left_i, sideLength_i] indicates: the side length of the i-th block is **sideLength_i**, and its left side aligns with the coordinate point **left_i** on the x-axis. Each block falls from a height higher than all the currently landed blocks. The block falls in the negative direction of the y-axis until it lands on the top edge of another square or on the x-axis. A block merely brushing past the left or right side of another block does not count as landing. Once landed, it will be fixed in place and cannot move. After each block falls, you must record the highest height of the currently stable stacked blocks.
[ "assert candidate([[1,2],[2,3],[6,1]])==[2,5,5]", "assert candidate([[100,100],[200,100]])==[100,100]" ]
def test_run(content1): return BS(content1).public_Block_stacking()
test_run
assert candidate([["class BS", "def __init__(self, positions)", "def _private_Block_stacking","def public_Block_stacking"], ["class BS", "def __init__(self, positions)", "def __private_Block_stacking","def public_Block_stacking"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/145
Firstly, design a **DC** class using the Python language, which has instance attributes **s1** and **s2**, a private function **private_Delete_Characters**, and a public function **public_Delete_Characters**. Then, in the private function **private_Delete_Characters**, return the minimum sum of the ASCII values of the characters that need to be deleted to make the two given strings **s1** and **s2** equal. Finally, call the private function **private_Delete_Characters** in the public function **public_Delete_Characters** to return the result.
[ "assert candidate(\"sea\",\"eat\")==231", "assert candidate(\"delete\",\"leet\")==403" ]
def test_run(content1,content2): return DC(content1,content2).public_Delete_Characters()
test_run
assert candidate([["class DC", "def __init__(self, s1, s2)", "def _private_Delete_Characters","def public_Delete_Characters"], ["class DC", "def __init__(self, s1, s2)", "def __private_Delete_Characters","def public_Delete_Characters"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/146
Firstly, design a **POE** class using Python language, which has instance attributes **nums** and **k**, a private function **private_Product_of_elements**, and a public function **public_Product_of_elements**. Then, in the private function **private_Product_of_elements**, return the number of continuous subarrays where the product of all elements in the subarray is strictly less than **k**, given an integer array **nums** and an integer **k**. Finally, in the public function **public_Product_of_elements**, call the private function **private_Product_of_elements** to return the result.
[ "assert candidate([10,5,2,6],100)==8", "assert candidate([1,2,3],0)==0" ]
def test_run(content1,content2): return POE(content1,content2).public_Product_of_elements()
test_run
assert candidate([["class POE", "def __init__(self, nums, k)", "def _private_Product_of_elements","def public_Product_of_elements"], ["class POE", "def __init__(self, nums, k)", "def __private_Product_of_elements","def public_Product_of_elements"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/147
Firstly, design a **BS** class using Python language, which has instance attributes **prices** and **fee**, a private function **private_buy_share**, and a public function **public_buy_share**. Then, implement the following problem in the private function **private_buy_share**. Finally, call the private function **private_buy_share** in the public function **public_buy_share** to return the result. Problem: Given an integer array **prices**, where prices[i] represents the stock price on the i-th day; the integer **fee** represents the transaction fee for trading stocks. You can complete transactions unlimited times, but you need to pay a fee for each transaction. If you have already purchased a stock, you cannot continue to buy stocks before selling it. Return the maximum profit that can be obtained.
[ "assert candidate([1, 3, 2, 8, 4, 9],2)==8", "assert candidate([1,3,7,5,10,3],3)==6" ]
def test_run(content1,content2): return BS(content1,content2).public_buy_share()
test_run
assert candidate([["class BS", "def __init__(self, prices, fee)", "def _private_buy_share","def public_buy_share"], ["class BS", "def __init__(self, prices, fee)", "def __private_buy_share","def public_buy_share"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/148
Firstly, design a **BC** class using the Python language, which has an instance attribute **bits**, a private function **private_Bit_character**, and a public function **public_Bit_character**. Then, implement the following problem in the private function **private_Bit_character**. Finally, call the private function **private_Bit_character** in the public function **public_Bit_character** to return the result. Problem: There are two special characters: the first type of character can be represented by a one-bit 0; the second type of character can be represented by two bits (10 or 11). Given a binary array **bits** ending with 0, if the last character must be a one-bit character, return True; otherwise, return False.
[ "assert candidate([1, 0, 0])==True", "assert candidate([1,1,1,0])==False" ]
def test_run(content1): return BC(content1).public_Bit_character()
test_run
assert candidate([["class BC", "def __init__(self, bits)", "def _private_Bit_character","def public_Bit_character"], ["class BC", "def __init__(self, bits)", "def __private_Bit_character","def public_Bit_character"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/149
Firstly, design a **BL** class using Python language, which has instance attributes **nums1** and **nums2**, a private function **private_BLongest_length**, and a public function **public_BLongest_length**. Then, in the private function **private_BLongest_length**, return the length of the longest common subarray from the two given integer arrays **nums1** and **nums2**. Finally, call the private function **private_BLongest_length** in the public function **public_BLongest_length** to return the result.
[ "assert candidate([1,2,3,2,1],[3,2,1,4,7])==3", "assert candidate([0,0,0,0,0],[0,0,0,0,0])==5" ]
def test_run(content1,content2): return BL(content1,content2).public_BLongest_length()
test_run
assert candidate([["class BL", "def __init__(self, nums1, nums2)", "def _private_BLongest_length","def public_BLongest_length"], ["class BL", "def __init__(self, nums1, nums2)", "def __private_BLongest_length","def public_BLongest_length"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/150
Firstly, design an **AD** class using Python language, which has instance attributes **nums** and **k**, a private function **private_absolute_difference**, and a public function **public_absolute_difference**. Then, implement the following problem in the private function **private_absolute_difference**. Finally, call the private function **private_absolute_difference** in the public function **public_absolute_difference** to return the result. Problem: A pair of numbers (a, b) is composed of integers **a** and **b**, and the distance of the pair is defined as the absolute difference between **a** and **b**. Given an integer array **nums** and an integer **k**, the pair is composed of nums[i] and nums[j] and satisfies 0<= i<j<nums.length. Return the k-th smallest pair distance among all pair distances.
[ "assert candidate([1,3,1],1)==0", "assert candidate([1,1,1],2)==0", "assert candidate([1,6,1],3)==5" ]
def test_run(content1,content2): return AD(content1,content2).public_absolute_difference()
test_run
assert candidate([["class AD", "def __init__(self, nums, k)", "def _private_absolute_difference","def public_absolute_difference"], ["class AD", "def __init__(self, nums, k)", "def __private_absolute_difference","def public_absolute_difference"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/151
Firstly, design an **ED** class using the Python language, which has an instance attribute **words**, a private function **private_English_Dictionary**, and a public function **public_English_Dictionary**. Then, implement the following problem in the private function **private_English_Dictionary**. Finally, call the private function **private_English_Dictionary** in the public function **public_English_Dictionary** to return the result. Problem: Given a string array **words** that forms an English dictionary, return the longest word in **words**. This word is formed by gradually adding one letter from other words in the **words** dictionary. If there are multiple feasible answers, return the word with the smallest lexicographical order among the answers. If there is no answer, return an empty string.
[ "assert candidate([\"w\",\"wo\",\"wor\",\"worl\", \"world\"])==\"world\"", "assert candidate([\"a\", \"banana\", \"app\", \"appl\", \"ap\", \"apply\", \"apple\"])==\"apple\"" ]
def test_run(content1): return ED(content1).public_English_Dictionary()
test_run
assert candidate([["class ED", "def __init__(self, words)", "def _private_English_Dictionary","def public_English_Dictionary"], ["class ED", "def __init__(self, words)", "def __private_English_Dictionary","def public_English_Dictionary"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/152
Firstly, design an **LS** class using Python language, which has instance attributes **head** and **k**, a private function **private_List_separation**, and a public function **public_List_separation**. Then, implement the following problem in the private function **private_List_separation**. Finally, call the private function **private_List_separation** in the public function **public_List_separation** to return the result. Problem: Given a singly linked list with a head node **head** and an integer **k**, please design an algorithm to divide the linked list into **k** consecutive parts. The length of each part should be as equal as possible: the difference in length between any two parts cannot exceed 1. This may cause some parts to be null. These **k** parts should be arranged in the order they appear in the linked list, and the length of the parts in the front should be greater than or equal to the length of the parts in the back. Return an array composed of the above **k** parts.
[ "assert candidate([1,2,3],5)==[[1],[2],[3],[],[]]", "assert candidate([1,2,3,4,5,6,7,8,9,10],3)==[[1,2,3,4],[5,6,7],[8,9,10]]" ]
def test_run(content1,content2): return LS(content1,content2).public_public_List_separation()
test_run
assert candidate([["class LS", "def __init__(self, head, k)", "def _private_List_separation","def public_List_separation"], ["class LS", "def __init__(self, head, k)", "def __private_List_separation","def public_List_separation"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/153
Firstly, design a **NOS** class using the Python language, which has an instance attribute **s**, a private function **private_Number_of_sequences**, and a public function **public_Number_of_sequences**. Then, in the private function **private_Number_of_sequences**, return the number of different non-empty palindrome sub-sequences in a given string **s**. Finally, in the public function **public_Number_of_sequences**, call the private function **private_Number_of_sequences** to return the result.
[ "assert candidate('bccb')==6", "assert candidate('abcdabcdabcdabcdabcdabcdabcdabcddcbadcbadcbadcbadcbadcbadcbadcba')==104860361" ]
def test_run(content1): return NOS(content1).public_Number_of_sequences()
test_run
assert candidate([["class NOS", "def __init__(self, s)", "def _private_Number_of_sequences","def public_Number_of_sequences"], ["class NOS", "def __init__(self, s)", "def __private_Number_of_sequences","def public_Number_of_sequences"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/154
Firstly, design an **MI** class using Python language, which has an instance attribute **n**, a private function **private_monotonic_increase**, and a public function **public_monotonic_increase**. Then, implement the following problem in the private function **private_monotonic_increase**. Finally, call the private function **private_monotonic_increase** in the public function **public_monotonic_increase** to return the result. Problem: An integer is said to be monotonically increasing if and only if each pair of adjacent digits **x** and **y** satisfy x <= y. Given an integer **n**, return the largest number less than or equal to **n** that is monotonically increasing.
[ "assert candidate(10)==9", "assert candidate(1234)==1234", "assert candidate(332)==299" ]
def test_run(content1): return MI(content1).public_monotonic_increase()
test_run
assert candidate([["class MI", "def __init__(self, n)", "def _private_monotonic_increase","def public_monotonic_increase"], ["class MI", "def __init__(self, n)", "def __private_monotonic_increase","def public_monotonic_increase"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/155
Firstly, design a class **TR** using the Python language, which has an instance attribute **temperatures**, a private function **private_Temperature_rise**, and a public function **public_Temperature_rise**. Then, implement the following problem in the private function **private_Temperature_rise**. Finally, call the private function **private_Temperature_rise** in the public function **public_Temperature_rise** to return the result. Problem: Given an integer array **temperatures** representing the temperature of each day, return an array **answer**, where answer[i] refers to the number of days until the next higher temperature for the i-th day. If the temperature will not rise after this, please replace it with 0 at this position.
[ "assert candidate([73,74,75,71,69,72,76,73])==[1,1,4,2,1,1,0,0]", "assert candidate([30,40,50,60])==[1,1,1,0]", "assert candidate([30,60,90])==[1,1,0]" ]
def test_run(content1): return TR(content1).public_Temperature_rise()
test_run
assert candidate([["class TR", "def __init__(self, temperatures)", "def _private_Temperature_rise","def public_Temperature_rise"], ["class TR", "def __init__(self, temperatures)", "def __private_Temperature_rise","def public_Temperature_rise"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/156
Firstly, design a class **MN** using the Python language, which has an instance attribute **nums**, a private function **private_Maximum_number**, and a public function **public_Maximum_number**. Then, implement the following problem in the private function **private_Maximum_number**. Finally, call the private function **private_Maximum_number** in the public function **public_Maximum_number** to return the result. Problem: Given an integer array **nums**, you can perform some operations on it. In each operation, choose any nums[i], delete it and get the points of nums[i]. After that, you must delete all elements equal to nums[i]-1 and nums[i]+1. Initially, you have 0 points. Return the maximum points that can be obtained through these operations.
[ "assert candidate([3,4,2])==6", "assert candidate([2,2,3,3,3,4])==9" ]
def test_run(content1): return MN(content1).public_Maximum_number()
test_run
assert candidate([["class MN", "def __init__(self, nums)", "def _private_Maximum_number","def public_Maximum_number"], ["class MN", "def __init__(self, nums)", "def __private_Maximum_number","def public_Maximum_number"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/157
Firstly, design a class **NN** using the Python language, which has instance attributes **times**, **n** and **k**, a private function **private_network_node**, and a public function **public_network_node**. Then, implement the following problem in the private function **private_network_node**. Finally, call the private function **private_network_node** in the public function **public_network_node** to return the result. Problem: There are **n** network nodes, labeled from 1 to n. Given a list **times**, which represents the transmission time of signals passing through directed edges. times[i] = (u_i, v_i, w_i), where **u_i** is the source node, **v_i** is the target node, and **w_i** is the time it takes for a signal to pass from the source node to the target node. Now, a signal is sent from a certain node **K**, how long will it take for all nodes to receive the signal? If not all nodes can receive the signal, return -1.
[ "assert candidate([[2,1,1],[2,3,1],[3,4,1]],4,2)==2", "assert candidate([[1,2,1]],2,1)==1", "assert candidate([[1,2,1]],2,2)==-1" ]
def test_run(content1,content2,content3): return NN(content1,content2,content3).public_network_node()
test_run
assert candidate([["class NN", "def __init__(self, times, n, k)", "def _private_network_node","def public_network_node"], ["class NN", "def __init__(self, times, n, k)", "def __private_network_node","def public_network_node"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/158
Firstly, design an **INA** class using Python language, which has an instance attribute **target**, a private function **private_Infinite_number_axis**, and a public function **public_Infinite_number_axis**. Then, implement the following problem in the private function **private_Infinite_number_axis**. Finally, call the private function **private_Infinite_number_axis** in the public function **public_Infinite_number_axis** to return the result. Problem: On an infinitely long number axis, you stand at position 0, and the endpoint is at the **target** position. You can make a certain number of moves **numMoves**: each time you can choose to move left or right, and for the i-th move (from i==1 to i==numMoves), you walk **i** steps in the chosen direction. Given an integer **target**, return the minimum number of moves required to reach the target (i.e., the minimum **numMoves**).
[ "assert candidate(2)==3", "assert candidate(3)==2" ]
def test_run(content1): return INA(content1).public_Infinite_number_axis()
test_run
assert candidate([["class INA", "def __init__(self, target)", "def _private_Infinite_number_axis","def public_Infinite_number_axis"], ["class INA", "def __init__(self, target)", "def __private_Infinite_number_axis","def public_Infinite_number_axis"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/159
Firstly, design an **IC** class using Python language, which has an instance attribute **intervals**, a private function **private_Include_Collection**, and a public function **public_Include_Collection**. Then, implement the following problem in the private function **private_Include_Collection**. Finally, call the private function **private_Include_Collection** in the public function **public_Include_Collection** to return the result. Problem: Given a two-dimensional integer array **intervals**, where intervals[i] = [start_i, end_i] represents all integers from **start_i** to **end_i**, including **start_i** and **end_i**. The inclusion set is an array named **nums**, and it satisfies that each interval in **intervals** has at least two integers in **nums**. Return the possible minimum size of the inclusion set.
[ "assert candidate([[1,3],[3,7],[8,9]])==5", "assert candidate([[1,3],[1,4],[2,5],[3,5]])==3", "assert candidate([[1,2],[2,3],[2,4],[4,5]])==5" ]
def test_run(content1): return IC(content1).public_Include_Collection()
test_run
assert candidate([["class IC", "def __init__(self, intervals)", "def _private_Include_Collection","def public_Include_Collection"], ["class IC", "def __init__(self, intervals)", "def __private_Include_Collection","def public_Include_Collection"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/160
Firstly, design a class **SP** using Python language, which has an instance attribute **s**, a private function **private_String_partitioning**, and a public function **public_String_partitioning**. Then, implement the following problem in the private function **private_String_partitioning**. Finally, call the private function **private_String_partitioning** in the public function **public_String_partitioning** to return the result. Problem: Given a string **s**, partition this string into as many segments as possible, with the same letter appearing at most once in a segment, and return a list representing the length of each string segment. The partition result needs to satisfy: concatenating all partition results in order, the string obtained is still **s**.
[ "assert candidate(\"ababcbacadefegdehijhklij\")==[9,7,8]", "assert candidate(\"eccbbbbdec\")==[10]" ]
def test_run(content1): return SP(content1).public_String_partitioning()
test_run
assert candidate([["class SP", "def __init__(self, s)", "def _private_String_partitioning","def public_String_partitioning"], ["class SP", "def __init__(self, s)", "def __private_String_partitioning","def public_String_partitioning"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/161
Firstly, design a **PS** class using Python language, which has instance attributes **n** and **mines**, a private function **private_Plus_sign**, and a public function **public_Plus_sign**. Then, implement the following problem in the private function **private_Plus_sign**. Finally, call the private function **private_Plus_sign** in the public function **public_Plus_sign** to return the result. Problem: In an n x n matrix **grid**, every element is 1 except for the elements given as 0 in the array **mines**. mines[i]=[x_i,y_i] indicates grid[x_i][y_i]==0. Return the order of the largest axis-aligned plus sign of 1s in **grid**. If no plus sign is found, return 0.
[ "assert candidate(5,[[4, 2]])==2", "assert candidate(1,[[0, 0]])==0" ]
def test_run(content1,content2): return PS(content1,content2).public_Plus_sign()
test_run
assert candidate([["class PS", "def __init__(self, n, mines)", "def _private_Plus_sign","def public_Plus_sign"], ["class PS", "def __init__(self, n, mines)", "def __private_Plus_sign","def public_Plus_sign"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/162
Firstly, design an **ES** class using Python language, which has an instance attribute **row**, a private function **private_Exchange_seats**, and a public function **public_Exchange_seats**. Then, implement the following problem in the private function **private_Exchange_seats**. Finally, call the private function **private_Exchange_seats** in the public function **public_Exchange_seats** to return the result. Problem: There are **n** pairs of couples sitting on **2n** seats arranged in a row, and they want to hold each other's hands. People and seats are represented by an integer array **row**, where row[i] is the ID of the person sitting in the i-th seat. The couples are numbered in order, the first pair is (0, 1), the second pair is (2, 3), and so on, the last pair is (2n-2, 2n-1). Return the minimum number of seat swaps so that each couple can sit together side by side. You can choose any two people for each swap, and have them stand up and exchange seats.
[ "assert candidate([0,2,1,3])==1", "assert candidate([3,2,0,1])==0" ]
def test_run(content1): return ES(content1).public_Exchange_seats()
test_run
assert candidate([["class ES", "def __init__(self, row)", "def _private_Exchange_seats","def public_Exchange_seats"], ["class ES", "def __init__(self, row)", "def __private_Exchange_seats","def public_Exchange_seats"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/163
Firstly, design a **JM** class using Python language, which has an instance attribute **matrix**, a private function **private_judgment_matrix**, and a public function **public_judgment_matrix**. Then, in the private function **private_judgment_matrix**, determine whether a given m x n **matrix** is a Toeplitz matrix. If it is, return True; otherwise, return False. Finally, call the private function **private_judgment_matrix** in the public function **public_judgment_matrix** to return the result.
[ "assert candidate([[1,2,3,4],[5,1,2,3],[9,5,1,2]])==True", "assert candidate([[1,2],[2,2]])==False" ]
def test_run(content1): return JM(content1).public_judgment_matrix()
test_run
assert candidate([["class JM", "def __init__(self, matrix)", "def _private_judgment_matrix","def public_judgment_matrix"], ["class JM", "def __init__(self, matrix)", "def _private_judgment_matrix","def public_judgment_matrix"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/164
First, design an **RL** class using the Python language, which has an instance attribute **s**, a private function **private_Rearrange_letters**, and a public function **public_Rearrange_letters**. Then, implement the following problem in the private function **private_Rearrange_letters**. Finally, call the private function **private_Rearrange_letters** in the public function **public_Rearrange_letters** to return the result. Problem: Given a string **s**, check if it is possible to rearrange its letters so that no two adjacent characters are the same. Return any possible rearrangement of **s**. If it is not feasible, return an empty string "".
[ "assert candidate(\"aab\")==\"aba\"", "assert candidate(\"aaab\")==\"\"" ]
def test_run(content1): return RL(content1).public_Rearrange_letters()
test_run
assert candidate([["class RL", "def __init__(self, s)", "def _private_Rearrange_letters","def public_Rearrange_letters"], ["class RL", "def __init__(self, s)", "def _private_Rearrange_letters","def public_Rearrange_letters"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/165
Firstly, design an **MNB** class using the Python language, which has an instance attribute **arr**, a private function **private_Maximum_number_blocks**, and a public function **public_Maximum_number_blocks**. Then, implement the following problem in the private function **private_Maximum_number_blocks**. Finally, call the private function **private_Maximum_number_blocks** in the public function **public_Maximum_number_blocks** to return the result. Problem: Given an integer array **arr**, split **arr** into several chunks, and sort these chunks separately. Then connect them together so that the result of the connection is the same as the original array sorted in ascending order. Return the maximum number of chunks that the array can be divided into.
[ "assert candidate([5,4,3,2,1])==1", "assert candidate([2,1,3,4,4])==4" ]
def test_run(content1): return MNB(content1).public_Maximum_number_blocks()
test_run
assert candidate([["class MNB", "def __init__(self, arr)", "def _private_Maximum_number_blocks","def public_Maximum_number_blocks"], ["class MNB", "def __init__(self, arr)", "def __private_Maximum_number_blocks","def public_Maximum_number_blocks"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/166
Firstly, design a class named **SS** using Python language, which includes an instance attribute **arr**, a private function **private_Sort_separately**, and a public function **public_Sort_separately**. Then, implement the following problem in the private function **private_Sort_separately**. Finally, call the private function **private_Sort_separately** in the public function **public_Sort_separately** and return the result. Problem: Given an integer array **arr** of length **n**, which represents the permutation of integers in the range [0, n - 1], divide **arr** into several blocks (i.e., partitions) and sort each block separately. After connecting them, make the result of the connection the same as the original array sorted in ascending order, and return the maximum number of blocks that the array can be divided into.
[ "assert candidate([4,3,2,1,0])==1", "assert candidate([1,0,2,3,4])==4" ]
def test_run(content1): return SS(content1).public_Sort_separately()
test_run
assert candidate([["class SS", "def __init__(self, arr)", "def _private_Sort_separately","def public_Sort_separately"], ["class SS", "def __init__(self, arr)", "def __private_Sort_separately","def public_Sort_separately"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/167
Firstly, design a class **SPB** using Python language, which has an instance attribute **board**, a private function **private_Solving_puzzle_board**, and a public function **public_Solving_puzzle_board**. Then, implement the following problem in the private function **private_Solving_puzzle_board**. Finally, call the private function **private_Solving_puzzle_board** in the public function **public_Solving_puzzle_board** to return the result. Problem: On a 2 x 3 **board**, there are 5 tiles represented by numbers 1~5, and an empty space represented by 0. A move is defined as swapping 0 with an adjacent number (up, down, left, or right). The puzzle is solved when the **board** result is [[1,2,3],[4,5,0]]. Given an initial state of the puzzle **board**, return the minimum number of moves to solve the puzzle. If the puzzle cannot be solved, return -1.
[ "assert candidate([[1,2,3],[4,0,5]])==1", "assert candidate([[1,2,3],[5,4,0]])==-1", "assert candidate([[4,1,2],[5,0,3]])==5" ]
def test_run(content1): return SPB(content1).public_Solving_puzzle_board()
test_run
assert candidate([["class SPB", "def __init__(self, board)", "def _private_Solving_puzzle_board","def public_Solving_puzzle_board"], ["class SPB", "def __init__(self, board)", "def __private_Solving_puzzle_board","def public_Solving_puzzle_board"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/168
Firstly, design a class **LI** using Python language, which has an instance attribute **nums**, a private function **private_Local_inversion**, and a public function **public_Local_inversion**. Then, implement the following problem in the private function **private_Local_inversion**. Finally, call the private function **private_Local_inversion** in the public function **public_Local_inversion** and return the result. Problem: Given an integer array **nums** of length **n**, representing a permutation composed of all integers within the range [0, n - 1]. The number of global inversions is equal to the number of different index pairs (i, j) that satisfy the following conditions: 1. 0 <= i < j < n; 2. nums[i] > nums[j]; The number of local inversions is equal to the number of indexes **i** that satisfy the following conditions: 1. 0 <= i < n - 1; 2. nums[i] > nums[i + 1]; When the number of global inversions in the array **nums** equals the number of local inversions, return True; otherwise, return False.
[ "assert candidate([1,0,2])==True", "assert candidate([1,2,0])==False" ]
def test_run(content1): return LI(content1).public_Local_inversion()
test_run
assert candidate([["class LI", "def __init__(self, nums)", "def _private_Local_inversion","def public_Local_inversion"], ["class LI", "def __init__(self, nums)", "def __private_Local_inversion","def public_Local_inversion"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/169
Firstly, design a class **GS** using the Python language, which has an instance attribute **grid**, a private function **private_Grid_swimming**, and a public function **public_Grid_swimming**. Then, implement the following problem in the private function **private_Grid_swimming**. Finally, call the private function **private_Grid_swimming** in the public function **public_Grid_swimming** to return the result. Problem: In an n x n integer matrix **grid**, each cell's value grid[i][j] represents the platform height at position (i, j). When it starts to rain, the water level in the pool is **t** at time **t**. You can swim to any adjacent platform, but the prerequisite is that the water level must submerge these two platforms at the same time. Assuming you can move an infinite distance instantly, that is, it is assumed that swimming within the grid does not consume time. Of course, you must stay within the coordinate grid while swimming. You start from the top-left platform (0,0) of the coordinate grid, and return the minimum time required to reach the bottom-right platform (n-1, n-1) of the coordinate grid.
[ "assert candidate([[0,2],[1,3]])==3", "assert candidate([[0,1,2,3,4],[24,23,22,21,5],[12,13,14,15,16],[11,17,18,19,20],[10,9,8,7,6]])==16" ]
def test_run(content1): return GS(content1).public_Grid_swimming()
test_run
assert candidate([["class GS", "def __init__(self, grid)", "def _private_Grid_swimming","def public_Grid_swimming"], ["class GS", "def __init__(self, grid)", "def __private_Grid_swimming","def public_Grid_swimming"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/170
Firstly, design a **GNR** class using Python language, which has instance attributes **n** and **k**, a private function **private_Given_number_rows**, and a public function **public_Given_number_rows**. Then, implement the following problem in the private function **private_Given_number_rows**. Finally, call the private function **private_Given_number_rows** in the public function **public_Given_number_rows** to return the result. Problem: We have constructed a table with **n** rows (indexed from 1). Initially, we write a 0 on the first row. For each subsequent row, we replace 0 with 01 and 1 with 10 in the previous row. Given the row number **n** and the ordinal **k**, return the k-th character (k indexed from 1) in the n-th row.
[ "assert candidate(1,1)==0", "assert candidate(2,1)==0", "assert candidate(2,2)==1" ]
def test_run(content1,content2): return GNR(content1,content2).public_Given_number_rows()
test_run
assert candidate([["class GNR", "def __init__(self, n, k)", "def _private_Given_number_rows","def public_Given_number_rows"], ["class GNR", "def __init__(self, n, k)", "def __private_Given_number_rows","def public_Given_number_rows"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/171
Firstly, design a **CN** class using Python language, which has instance attributes **sx**, **sy**, **tx**, and **ty**, a private function **private_Convert_numbers**, and a public function **public_Convert_numbers**. Then, implement the following problem in the private function **private_Convert_numbers**. Finally, call the private function **private_Convert_numbers** in the public function **public_Convert_numbers** to return the result. Problem: Given four integers **sx**, **sy**, **tx**, and **ty**. If it is possible to reach the endpoint (tx, ty) from the starting point (sx, sy) through a series of transformations, return True, otherwise return False. From point (x, y), it can be transformed to either (x, x+y) or (x+y, y).
[ "assert candidate(1,1,3,5)==True", "assert candidate(1,1,2,2)==False", "assert candidate(1,1,1,1)==True" ]
def test_run(content1,content2,content3,content4): return CN(content1,content2,content3,content4).public_Convert_numbers()
test_run
assert candidate([["class CN", "def __init__(self, sx, sy, tx, ty)", "def _private_Convert_numbers","def public_Convert_numbers"], ["class CN", "def __init__(self, sx, sy, tx, ty)", "def __private_Convert_numbers","def public_Convert_numbers"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/172
First, design a class **FR** using the Python language, which has an instance attribute **answers**, a private function **private_Forest_Rabbit**, and a public function **public_Forest_Rabbit**. Then, implement the following problem in the private function **private_Forest_Rabbit**. Finally, call the private function **private_Forest_Rabbit** in the public function **public_Forest_Rabbit** to return the result. Problem: There is an unknown number of rabbits in the forest. Ask some of the rabbits **how many other rabbits have the same color as you (referring to the rabbit being asked)**, and collect the answers into an integer array **answers**, where answers[i] is the answer of the i-th rabbit. Given the array **answers**, return the minimum number of rabbits in the forest.
[ "assert candidate([1,1,2])==5", "assert candidate([10,10,10])==11" ]
def test_run(content1): return FR(content1).public_Forest_Rabbit()
test_run
assert candidate([["class FR", "def __init__(self, answers)", "def _private_Forest_Rabbit","def public_Forest_Rabbit"], ["class FR", "def __init__(self, answers)", "def __private_Forest_Rabbit","def public_Forest_Rabbit"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/173
Firstly, design a class **NM** using the Python language, which has an instance attribute **board**, a private function **private_Network_Matrix**, and a public function **public_Network_Matrix**. Then, implement the following problem in the private function **private_Network_Matrix**. Finally, call the private function **private_Network_Matrix** in the public function **public_Network_Matrix** to return the result. Problem: A n x n two-dimensional network **board** is composed only of 0 and 1. In each move, you can freely swap the positions of two columns or two rows. Return the minimum number of moves required to transform this matrix into a **chessboard**. If there is no feasible transformation, output -1.
[ "assert candidate([[0,1,1,0],[0,1,1,0],[1,0,0,1],[1,0,0,1]])==2", "assert candidate([[0,1],[1,0]])==0", "assert candidate([[1,0],[1,0]])==-1" ]
def test_run(content1): return NM(content1).public_Network_Matrix()
test_run
assert candidate([["class NM", "def __init__(self, board)", "def _private_Network_Matrix","def public_Network_Matrix"], ["class NM", "def __init__(self, board)", "def __private_Network_Matrix","def public_Network_Matrix"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/174
Firstly, design a class **CC** using Python language, which has an instance attribute **s**, a private function **private_Change_Case**, and a public function **public_Change_Case**. Then, implement the following problem in the private function **private_Change_Case**. Finally, call the private function **private_Change_Case** in the public function **public_Change_Case** to return the result. Problem: Given a string **s**, by changing the case of each letter in the string **s**, we can obtain a new string. Return the set of all possible strings that can be obtained.
[ "assert candidate(\"a1b2\")==[\"a1b2\", \"a1B2\", \"A1b2\", \"A1B2\"]", "assert candidate(\"3z4\")==[\"3z4\",\"3Z4\"]" ]
def test_run(content1): return CC(content1).public_Change_Case()
test_run
assert candidate([["class CC", "def __init__(self, s)", "def _private_Change_Case","def public_Change_Case"], ["class CC", "def __init__(self, s)", "def __private_Change_Case","def public_Change_Case"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/175
Firstly, design a class **MS** using the Python language, which has instance attributes **arr** and **k**, a private function **private_Minimum_score**, and a public function **public_Minimum_score**. Then, implement the following problem in the private function **private_Minimum_score**. Finally, call the private function **private_Minimum_score** in the public function **public_Minimum_score** to return the result. Problem: Given an array **arr** sorted in ascending order and an integer **k**. The array **arr** is composed of 1 and several prime numbers, and all integers in it are different from each other. For each pair of **i** and **j** satisfying 0 <= i < j < arr.length, a score can be obtained as arr[i]/arr[j]. So, what is the k-th smallest score?
[ "assert candidate([1,2,3,5],3)==[2,5]", "assert candidate([1,7],1)==[1,7]" ]
def test_run(content1,content2): return MS(content1,content2).public_Minimum_score()
test_run
assert candidate([["class MS", "def __init__(self, arr, k)", "def _private_Minimum_score","def public_Minimum_score"], ["class MS", "def __init__(self, arr, k)", "def __private_Minimum_score","def public_Minimum_score"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/176
Firstly, design a **PM** class using Python language, which has instance attributes **order** and **s**, a private function **private_Permutation_matching**, and a public function **public_Permutation_matching**. Then, implement the following problem in the private function **private_Permutation_matching**. Finally, call the private function **private_Permutation_matching** in the public function **public_Permutation_matching** to return the result. Problem: Given two strings, **order** and **s**, all the letters in **order** are unique and have been sorted in some custom order. Permute the characters of **s** to match the sorted **order**. More specifically, if character **x** appears before character **y** in **order**, then in the permuted string, **x** should also appear before **y**. Return any permutation of **s** that satisfies this property.
[ "assert candidate(\"cba\",\"abcd\")==\"cbad\"", "assert candidate(\"cbafg\",\"abcd\")==\"cbad\"" ]
def test_run(content1,content2): return PM(content1,content2).public_Permutation_matching()
test_run
assert candidate([["class PM", "def __init__(self, order, s)", "def _private_Permutation_matching","def public_Permutation_matching"], ["class PM", "def __init__(self, order, s)", "def _private_Permutation_matching","def public_Permutation_matching"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/177
Firstly, design a class **NW** using the Python language, which has instance attributes **s** and **words**, a private function **private_Number_words**, and a public function **public_Number_words**. Then, in the private function **private_Number_words**, return the number of words in words[i] that are subsequences of the given string **s** based on the given string **s** and the number of strings **words**. Finally, in the public function **public_Number_words**, call the private function **private_Number_words** to return the result.
[ "assert candidate(\"abcde\",[\"a\",\"bb\",\"acd\",\"ace\"])==3", "assert candidate(\"dsahjpjauf\",[\"ahjpjau\",\"ja\",\"ahbwzgqnuk\",\"tnmlanowax\"])==2" ]
def test_run(content1,content2): return NW(content1,content2).public_Number_words()
test_run
assert candidate([["class NW", "def __init__(self, s, words)", "def _private_Number_words","def public_Number_words"], ["class NW", "def __init__(self, s, words)", "def __private_Number_words","def public_Number_words"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/178
Firstly, design a class **NI** using Python language, which has an instance attribute **k**, a private function **private_nonnegative_integer**, and a public function **public_nonnegative_integer**. Then, implement the following problem in the private function **private_nonnegative_integer**. Finally, call the private function **private_nonnegative_integer** in the public function **public_nonnegative_integer** to return the result. Problem: f(x) is the number of zeros at the end of x!, recall that x! = 1*2*3*...*x, and 0! = 1. Given **k**, find the number of non-negative integers **x** that can satisfy f(x) = k.
[ "assert candidate(0)==5", "assert candidate(5)==0", "assert candidate(3)==5" ]
def test_run(content1): return NI(content1).public_nonnegative_integer()
test_run
assert candidate([["class NI", "def __init__(self, k)", "def _private_nonnegative_integer","def public_nonnegative_integer"], ["class NI", "def __init__(self, k)", "def __private_nonnegative_integer","def public_nonnegative_integer"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/0
First, write a **WDS** class using the Python language. Then, within the WDS class, create a public function called **without_duplicates** to implement finding the length of the longest substring in a given string **s** that does not contain any duplicate characters.
[ "assert candidate(\"abcabcbb\")==3", "assert candidate(\"bbbbb\")==1", "assert candidate(\"pwwkew\")==3" ]
def test_run(content1): return WDS().without_duplicates(content1)
test_run
assert candidate([["class WDS", "def without_duplicates"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/1
First, design a class called **MNS** in Python, which has an instance attribute called **machines**, a private function called **private_Ministeps**, and a public function called **public_Ministeps**. Then, implement the following problem in the private function **private_Ministeps**. Finally, call the private function private_Ministeps in the public function **public_Ministeps** and return the result. Problem: There are **n** super washing machines placed in a row, and it is unknown whether there are clothes inside each machine. You can choose any **m** machines and move one piece of clothing from each selected machine to an adjacent machine. Return the minimum number of steps required to make the number of clothes remaining in each machine equal.
[ "assert candidate([1,0,5])==3", "assert candidate([0,3,0])==2", "assert candidate([0,2,0])==-1" ]
def test_run(content1): return MNS(content1).public_Minimum_number_steps()
test_run
assert candidate([["class MNS", "def public_Ministeps", "def __private_Ministeps"],["class MNS", "def public_Ministeps", "def _private_Ministeps"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/2
First, write a class called **FTM** using the Python language. Then, within the **FTM** class, create a public function called **find_the_median** that returns the median of two sorted arrays, **nums1** and **nums2**.
[ "assert candidate([1,3], [2])==2.00000", "assert candidate([1,2], [3,4])==2.50000" ]
def test_run(content1,content2): return FTM().find_the_median(content1,content2)
test_run
assert candidate([["class FTM", "def find_the_median"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/3
First, write a **PDSB** class using the Python language. Then, within the **PDSB** class, implement a public **pa_substring** function to find the longest palindrome substring in string **s**.
[ "assert candidate(\"babad\")==\"bab\"", "assert candidate(\"cbbd\")==\"bb\"" ]
def test_run(content1): return PDSB().pa_substring(content1)
test_run
assert candidate([["class PDSB", "def pa_substring"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/4
First, write a **ZZPTN** class using the Python language, then write a public **Zigzag_pattern** function in the **ZZPTN** class to solve the following problem. Problem: Given a string **s** and an integer **numRows**, arrange the string **s** from top to bottom and from left to right in a Z shape according to the given **numRows**.
[ "assert candidate(\"PAYPALISHIRING\", 3)==\"PAHNAPLSIIGYIR\"", "assert candidate(\"PAYPALISHIRING\", 4)==\"PINALSIGYAHRPI\"", "assert candidate(\"A\", 1)==\"A\"" ]
def test_run(content1,content2): return ZZPTN().Zigzag_pattern(content1,content2)
test_run
assert candidate([["class ZZPTN", "def Zigzag_pattern"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/5
First, write an **ITOC** class using the Python language. Then, within the **ITOC** class, create a public function called **Invert_outcome** that takes a 32-bit signed integer **x** as input and returns the result of reversing the numerical part of **x**.
[ "assert candidate(123)==321", "assert candidate(-123)==-321", "assert candidate(120)==21", "assert candidate(0)==0" ]
def test_run(content1): return ITOC().Invert_outcome(content1)
test_run
assert candidate([["class ITOC", "def Invert_outcome"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/6
First, write a **PDIT** class using Python language. Then, within the **PDIT** class, write a public function named **Palindromic_integer**. This function should determine whether a given integer **x** is a palindromic integer. If it is, the function should return True; otherwise, it should return False.
[ "assert candidate(121)==True", "assert candidate(-121)==False", "assert candidate(10)==False" ]
def test_run(content1): return PDIT().Palindromic_integer(content1)
test_run
assert candidate([["class PDIT", "def Palindromic_integer"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/7
First, write a **RLMH** class using the Python language. Then, within the **RLMH** class, create a public **rule_matching** function that implements a regular expression matching for a given string **s** and a character pattern **p**, using the following rules: 1. '.' matches any single character; 2. '*' matches zero or more occurrences of the preceding element.
[ "assert candidate(\"aa\", \"a\")==False", "assert candidate(\"aa\", \"a*\")==True", "assert candidate(\"ab\", \".*\")==True" ]
def test_run(content1,content2): return RLMH().rule_matching(content1,content2)
test_run
assert candidate([["class RLMH", "def rule_matching"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/8
First, write a **LCMP** class using the Python language. Then, within the **LCMP** class, create a public function called **longest_common_prefix** to find the longest common prefix among an array of strings. If no common prefix exists, return an empty string "".
[ "assert candidate([\"flower\",\"flow\",\"flight\"])==\"fl\"", "assert candidate([\"dog\",\"racecar\",\"car\"])==\"\"" ]
def test_run(content1,content2,content3): return LCMP().longest_common_prefix(content1,content2,content3)
test_run
assert candidate([["class LCMP", "def longest_common_prefix"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/9
First, write a **TSOTN** class using the Python language. Then, within the **TSOTN** class, create a public function called **sum_three_numbers**. This function takes in an integer array called **nums** with a length of **n**, and a target value called **target**. The function selects three integers from **nums** in such a way that their sum is closest to the target value. Finally, the function returns the sum of these three numbers.
[ "assert candidate([-1,2,1,-4], 1)==2", "assert candidate([0,0,0], 1)==0" ]
def test_run(content1,content2): return TSOTN().sum_three_numbers(content1,content2)
test_run
assert candidate([["class TSOTN", "def sum_three_numbers"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/10
Firstly, write a class **VLD_ST** using the Python language, then write a public function **valid_string** within the **VLD_ST** class to judge whether a given string **s**, which only includes '(',')','{','}','[',']', is valid or not. A valid string must meet the following conditions: 1. The left bracket must be closed by the right bracket of the same type; 2. The left brackets must be closed in the correct order; 3. Each right bracket has a corresponding left bracket of the same type.
[ "assert candidate(\"()\")==True", "assert candidate(\"()[]{}\")==True", "assert candidate(\"(]\")==False" ]
def test_run(content1): return VLD_ST().valid_string(content1)
test_run
assert candidate([["class VLD_ST", "def valid_string"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/11
First, write a **VDPT** class using the Python language. Then, within the **VDPT** class, create a public **valid_parentheses** function. This function should take an integer **n** as input, representing the number of pairs of parentheses to generate. The function should then print out all possible and valid combinations of parentheses.
[ "assert candidate(3)==[\"((()))\",\"(()())\",\"(())()\",\"()(())\",\"()()()==[\"((()))\",\"(()())\",\"(())()\",\"()(())\",\"()()()\"]", "assert candidate(1)==[\"()==[\"()\"]", "assert candidate(\"(]\")==False" ]
def test_run(content1): return VDPT().valid_parentheses(content1)
test_run
assert candidate([["class VDPT", "def valid_parentheses"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/12
First, write a **NLAR** class using the Python language. Then, within the **NLAR** class, create a public function called **new_length_removal**. This function should take an array called **nums** and a value called **val** as input. The function should remove all elements in the array that are equal to **val**, and return the new length of the array after removal.
[ "assert candidate([3,2,2,3], 3)==2", "assert candidate([0,1,2,2,3,0,4,2], 2)==5" ]
def test_run(content1,content2): return NLAR().new_length_removal(content1,content2)
test_run
assert candidate([["class VDPT", "def new_length_removal"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/13
First, write a class **FMIS** using the Python language. Then, within the **FMIS** class, write a public function **find_matching_items** that, given two strings **haystack** and **needle**, finds the index of the first matching item of the **needle** string in the **haystack** string (index starts from 0). If the **needle** is not part of the **haystack**, return -1.
[ "assert candidate(\"sadbutsad\", \"sad\")==0", "assert candidate(\"leetcode\", \"leeto\")==-1" ]
def test_run(content1,content2): return FMIS().find_matching_items(content1,content2)
test_run
assert candidate([["class FMIS", "def find_matching_items"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False
OOP/14
First, write an **LVPSS** class using the Python language. Then, within the **LVPSS** class, write a public function named **long_valid_substring**. This function should find the length of the longest valid (correctly formatted and continuous) parenthesis substring in a given string that only contains '(' and ')'.
[ "assert candidate(\"(()\")==2", "assert candidate(\"\")==0", "assert candidate(\")()())\")==4" ]
def test_run(content1): return LVPSS().long_valid_substring(content1)
test_run
assert candidate([["class LVPSS", "def long_valid_substring"]]) == True
def matching_function(content): def run_match(text): for task in text: if task not in str_content: return False return True len_cont = len(content) if len_cont==1 and run_match(content[0]) == True: return True elif (len_cont==2 and run_match(content[0]) == True) or (len_cont==2 and run_match(content[1]) == True): return True else: return False