task_id
stringlengths
5
7
question
stringlengths
192
1.48k
test_list
listlengths
2
5
test_function
stringlengths
54
236
entry_point
stringclasses
1 value
test_matching
stringlengths
57
291
test_match_function
stringclasses
1 value
OOP/300
Question: Given an array **people**. people[i] represents the weight of the i-th person, the number of boats is unlimited, and each boat can carry a maximum weight of **limit**. Each boat can carry up to two people at the same time, but the condition is that the sum of these people's weights is at most **limit**. Retur...
[ "assert candidate([1,2],3)==1", "assert candidate([3,2,2,1],3)==3", "assert candidate([3,5,3,4],5)==4" ]
def test_run(content1,content2): return SN_MSS(content1,content2).Minimum_ships()
test_run
assert candidate([['class MSS', 'class SN_MSS(MSS)', 'super().__init__(people)', 'def Minimum_ships']]) == 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]...
OOP/301
Question: In an n x n **grid**, we place some 1 x 1 x 1 cubes aligned with the **x**, **y**, **z** axes. Each value v = grid[i][j] represents **v** cubes stacked on the cell (i, j). Now, we look at the projections of these cubes on the **xy**, **yz**, and **zx** planes. A projection is like a shadow, mapping a three-di...
[ "assert candidate([[1,2],[3,4]])==17", "assert candidate([[2]])==5", "assert candidate([[1,0],[0,2]])==8" ]
def test_run(content1): return SN_TPD(content1).Total_projected()
test_run
assert candidate([['class TPD', 'class SN_TPD(TPD)', 'super().__init__(grid)', 'def Total_projected']]) == 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]...
OOP/302
Question: On a grid of rows x cols, you start from the cell (rStart, cStart) facing east. The northwest corner of the grid is at the first row and the first column, and the southeast corner is at the last row and the last column. You need to walk in a clockwise spiral, visiting every position in this grid. Whenever you...
[ "assert candidate(1,4,0,0)==[[0,0],[0,1],[0,2],[0,3]]", "assert candidate(5,6,1,4)==[[1,4],[1,5],[2,5],[2,4],[2,3],[1,3],[0,3],[0,4],[0,5],[3,5],[3,4],[3,3],[3,2],[2,2],[1,2],[0,2],[4,5],[4,4],[4,3],[4,2],[4,1],[3,1],[2,1],[1,1],[0,1],[4,0],[3,0],[2,0],[1,0],[0,0]]" ]
def test_run(content1,content2,content3,content4): return SN_CLT(content1,content2,content3,content4).Coordinate_List()
test_run
assert candidate([['class CLT', 'class SN_CLT(CLT)', 'super().__init__(rows)', 'def Coordinate_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]...
OOP/303
Question: Given a set of **n** people (numbered 1,2,...,n), we want to divide each person into two groups of any size. Each person may not like others, so they should not belong to the same group. Given the integer **n** and the array **dislikes**, where dislikes[i]=[a_i,b_i], it is not allowed to put the people number...
[ "assert candidate(4,[[1,2],[1,3],[2,4]])==True", "assert candidate(3,[[1,2],[1,3],[2,3]])==False", "assert candidate(5,[[1,2],[2,3],[3,4],[4,5],[1,5]])==False" ]
def test_run(content1,content2): return SN_GPG(content1,content2).grouping()
test_run
assert candidate([['class GPG', 'class SN_GPG(GPG)', 'super().__init__(n)', 'def grouping']]) == 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]...
OOP/304
Question: You are given **k** identical eggs and you have access to a building with **n** floors from the 1st floor to the n-th floor. It is known that there exists a floor **f**, satisfying 0<=f<=n, any eggs dropped from a floor higher than **f** will break, and those dropped from the **f** floor or lower will not bre...
[ "assert candidate(1,2)==2", "assert candidate(2,6)==3", "assert candidate(3,14)==4" ]
def test_run(content1,content2): return SN_NOS(content1,content2).number_operations()
test_run
assert candidate([['class NOS', 'class SN_NOS(NOS)', 'super().__init__(k)', 'def number_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]...
OOP/305
Question: The width of a sequence is defined as the difference between the maximum and minimum elements in the sequence. Given an integer array **nums**, return the sum of the widths of all non-empty subsequences of **nums**. A subsequence is defined as an array obtained by deleting some (or not deleting) elements from...
[ "assert candidate([2,1,3])==6", "assert candidate([2])==0" ]
def test_run(content1): return SN_SWS(content1).Sum_widths()
test_run
assert candidate([['class SWS', 'class SN_SWS(SWS)', 'super().__init__(nums)', 'def Sum_widths']]) == 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]...
OOP/306
Question: We have a non-negative integer array **arr**. For each (continuous) subarray sub=[arr[i],arr[i+1],...,arr[j]] (i<=j), we perform a bitwise OR operation on each element in **sub**, obtaining the result arr[i]|arr[i+1]|...|arr[j]. Return the number of possible results. Multiple occurrences of the result are onl...
[ "assert candidate([0])==1", "assert candidate([1,1,2])==3", "assert candidate([1,2,4])==6" ]
def test_run(content1): return SN_FAR(content1).Final_Answer()
test_run
assert candidate([['class FAR', 'class SN_FAR(FAR)', 'super().__init__(arr)', 'def Final_Answer']]) == 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]...
OOP/307
Question: Given a string **s** and an integer **k**. You can choose one from the first **k** letters of **s** and add it to the end of the string. Return the lexicographically smallest string after any number of moves applying the above steps; Please create a class **SSG** with the attribute **s** in Python based on th...
[ "assert candidate(\"cba\",1)==\"acb\"", "assert candidate(\"baaca\",3)==\"aaabc\"" ]
def test_run(content1,content2): return SN_SSG(content1,content2).Smallest_string()
test_run
assert candidate([['class SSG', 'class SN_SSG(SSG)', 'super().__init__(s)', 'def Smallest_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]...
OOP/308
Question: Given a numerical array **digits** sorted in non-decreasing order. You can write numbers using digits[i] any number of times. For example, if digits = ['1','3','5'], we can write numbers like '13', '551', and '1351315'. Return the number of positive integers that can be generated that are less than or equal t...
[ "assert candidate([\"1\",\"3\",\"5\",\"7\"],100)==20", "assert candidate([\"1\",\"4\",\"9\"],1000000000)==29523", "assert candidate([\"7\"],8)==1" ]
def test_run(content1,content2): return SN_NDG(content1,content2).Non_decreasing()
test_run
assert candidate([['class NDG', 'class SN_NDG(NDG)', 'super().__init__(digits)', 'def Non_decreasing']]) == 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]...
OOP/309
Question: Given a string **s** of length **n**, where s[i] is: 1. **D** means decrease; 2. **I** means increase; A valid arrangement is a permutation **perm** of n+1 integers within the range [0, n], so that for all **i**: 1. If s[i] == 'D', then perm[i] > perm[i+1]; 2. If s[i] == 'I', then perm[i] < perm[i+1]. Return ...
[ "assert candidate(\"DID\")==5", "assert candidate(\"D\")==1" ]
def test_run(content1): return SN_EAT(content1).Effective_arrangement()
test_run
assert candidate([['class EAT', 'class SN_EAT(EAT)', 'super().__init__(s)', 'def Effective_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]...
OOP/310
Question: Given an integer array **arr**, find the sum of min(b), where **b** ranges over each (continuous) subarray of **arr**. Please create a class **IAY** in Python language based on the above question, with the attribute **arr**; then create a class **SN_IAY** that inherits from the **IAY** class, and add a public...
[ "assert candidate([3,1,2,4])==17", "assert candidate([11,81,94,43,3])==444" ]
def test_run(content1): return SN_IAY(content1).Integer_array()
test_run
assert candidate([['class IAY', 'class SN_IAY(IAY)', 'super().__init__(arr)', 'def Integer_array']]) == 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]...
OOP/311
Question: Given an integer array **nums** and an integer **k**. For each index **i** (0<=i<nums.length), change nums[i] to nums[i]+k or nums[i]-k. The score of **nums** is the difference between the maximum and minimum elements in **nums**. After changing the value corresponding to each index, return the minimum score ...
[ "assert candidate([1],0)==0", "assert candidate([0,10],2)==6", "assert candidate([1,3,6],3)==3" ]
def test_run(content1,content2): return SN_MSE(content1,content2).Minimum_score()
test_run
assert candidate([['class MSE', 'class SN_MSE(MSE)', 'super().__init__(nums)', 'def 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]...
OOP/312
Question: Given an integer array **nums**, please sort this array in ascending order; Based on the above question, please create a class **AOR** using Python language, with the attribute **nums**; then create another class **SN_AOR** that inherits from the **AOR** class, and add a public function **ascend_order** to so...
[ "assert candidate([5,2,3,1])==[1,2,3,5]", "assert candidate([5,1,1,2,0,0])==[0,0,1,1,2,5]" ]
def test_run(content1): return SN_AOR(content1).ascend_order()
test_run
assert candidate([['class AOR', 'class SN_AOR(AOR)', 'super().__init__(nums)', 'def ascend_order']]) == 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]...
OOP/313
Question: Two players play the roles of a cat and a mouse respectively, and they play a game on an undirected graph, taking turns to move. The form of the graph is: graph[a] is a list, consisting of all nodes **b** that satisfy that **ab** is an edge in the graph. The **mouse** starts from node 1 and moves first; the *...
[ "assert candidate([[2,5],[3],[0,4,5],[1,4,5],[2,3],[0,2,3]])==0", "assert candidate([[1,3],[0],[3],[0,2]])==1" ]
def test_run(content1): return SN_CGS(content1).Cat_games()
test_run
assert candidate([['class CGS', 'class SN_CGS(CGS)', 'super().__init__(graph)', 'def Cat_games']]) == 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]...
OOP/314
Question: Given a deck of cards, each card has an integer written on it. At this point, you need to select a number **X**, so that we can divide the deck into one or more groups according to the following rules: each group has **X** cards. All the cards in the group have the same integer written on them. Return True on...
[ "assert candidate([1,2,3,4,4,3,2,1])==True", "assert candidate([1,1,1,2,2,2,3,3])==False" ]
def test_run(content1): return SN_SIR(content1).Same_integer()
test_run
assert candidate([['class SIR', 'class SN_SIR(SIR)', 'super().__init__(deck)', 'def Same_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]...
OOP/315
Question: Given an array **nums**, divide it into two consecutive sub-arrays **left** and **right** so that: 1. Each element in **left** is less than or equal to each element in **right**. 2. Both **left** and **right** are non-empty. 3. The length of **left** should be as small as possible. After completing such group...
[ "assert candidate([5,0,3,8,6])==3", "assert candidate([1,1,1,0,6,12])==4" ]
def test_run(content1): return SN_PLH(content1).Packet_Length()
test_run
assert candidate([['class PLH', 'class SN_PLH(PLH)', 'super().__init__(nums)', 'def Packet_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]...
OOP/316
Question: Given two string arrays **words1** and **words2**. Now, if every letter in **b** appears in **a**, including the repeated letters, then we say that string **b** is a subset of string **a**. If for every word **b** in **words2**, **b** is a subset of **a**, then we say that the word **a** in **words1** is a un...
[ "assert candidate([\"amazon\",\"apple\",\"facebook\",\"google\",\"leetcode\"],[\"e\",\"o\"])==[\"facebook\",\"google\",\"leetcode\"]", "assert candidate([\"amazon\",\"apple\",\"facebook\",\"google\",\"leetcode\"],[\"l\",\"e\"])==[\"apple\",\"google\",\"leetcode\"]", "assert candidate([\"amazon\",\"apple\",\"fac...
def test_run(content1,content2): return SN_CWS(content1,content2).Common_Words()
test_run
assert candidate([['class CWS', 'class SN_CWS(CWS)', 'super().__init__(words1)', 'def Common_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]...
OOP/317
Question: Given a circular integer array **nums** of length **n**, return the maximum possible sum of non-empty subarrays in **nums**. Please create a class **CAY** in Python based on the above question, with the attribute **nums**. Then create another class **SN_CAY**, inheriting from the **CAY** class, and add a pub...
[ "assert candidate([1,-2,3,-2])==3", "assert candidate([5,-3,5])==10", "assert candidate([3,-2,2,-3])==3" ]
def test_run(content1): return SN_CAY(content1).Circular_array()
test_run
assert candidate([['class CAY', 'class SN_CAY(CAY)', 'super().__init__(nums)', 'def Circular_array']]) == 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]...
OOP/318
Question: You have **n** different songs in your music player. During your journey, you plan to listen to **goal** songs (not necessarily different, i.e., song repetition is allowed). You will create a playlist according to the following rules: 1. Each song is played at least once. 2. A song can only be played again af...
[ "assert candidate(3,3,1)==6", "assert candidate(2,3,0)==6", "assert candidate(2,3,1)==2" ]
def test_run(content1,content2,content3): return SN_PAL(content1,content2,content3).PlayList()
test_run
assert candidate([['class PAL', 'class SN_PAL(PAL)', 'super().__init__(n)', 'def PlayList']]) == 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]...
OOP/319
Question: A parenthesis string is valid only if one of the following conditions is met: 1. It is an empty string; 2. It can be written as AB (A connected with B), where both A and B are valid strings; 3. It can be written as (A), where A is a valid string. Given a parenthesis string **s**, in each operation, you can in...
[ "assert candidate(\"())\")==1", "assert candidate(\"(((\")==3" ]
def test_run(content1): return SN_MPS(content1).Minimum_parentheses()
test_run
assert candidate([['class MPS', 'class SN_MPS(MPS)', 'super().__init__(s)', 'def Minimum_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]...
OOP/320
Question: Given a non-negative integer array **nums**, half of the integers in **nums** are odd, and half are even. Sort the array so that when nums[i] is odd, **i** is also odd; when nums[i] is even, **i** is also even. You can return any array that meets the above conditions as the answer; Based on the above question...
[ "assert candidate([4,2,5,7])==[4,5,2,7]", "assert candidate([2,3])==[2,3]" ]
def test_run(content1): return SN_ASG(content1).Array_sorting()
test_run
assert candidate([['class ASG', 'class SN_ASG(ASG)', 'super().__init__(nums)', 'def Array_sorting']]) == 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]...
OOP/321
Question: Given an integer array **arr**, and an integer **target** as the target value, return the number of tuples **i**, **j**, **k** that satisfy i<j<k and arr[i]+arr[j]+arr[k]==target; Please create a class **NTS** in Python language based on the above question, with **arr** as an attribute; then create another cl...
[ "assert candidate([1,1,2,2,3,3,4,4,5,5],8)==20", "assert candidate([1,1,2,2,2,2],5)==12" ]
def test_run(content1,content2): return SN_NTS(content1,content2).Number_tuples()
test_run
assert candidate([['class NTS', 'class SN_NTS(NTS)', 'super().__init__(arr)', 'def Number_tuples']]) == 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]...
OOP/322
Question: Given a binary string **s**, you can flip any 0 to 1 or flip 1 to 0. Return the minimum number of flips to make **s** monotonically increasing; Please create a class **FTM** in Python based on the above question, with the attribute **s**. Then create another class **SN_FTM** that inherits from the **FTM** cla...
[ "assert candidate(\"00110\")==1", "assert candidate(\"010110\")==2", "assert candidate(\"00011000\")==2" ]
def test_run(content1): return SN_FTM(content1).Flip_Times()
test_run
assert candidate([['class FTM', 'class SN_FTM(FTM)', 'super().__init__(s)', 'def Flip_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]...
OOP/323
Question: Given an array **arr** composed of 0s and 1s, divide the array into three non-empty parts so that all these parts represent the same binary value. If it can be done, please return any [i, j], where i+1<j, so that: 1. arr[0], arr[1], ..., arr[i] is the first part; 2. arr[i+1], arr[i+2], ..., arr[j-1] is the se...
[ "assert candidate([1,0,1,0,1])==[0,3]", "assert candidate([1,1,0,1,1])==[-1,-1]", "assert candidate([1,1,0,0,1])==[0,2]" ]
def test_run(content1): return SN_BVE(content1).Binary_values()
test_run
assert candidate([['class BVE', 'class SN_BVE(BVE)', 'super().__init__(arr)', 'def Binary_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]...
OOP/324
Question: Given a binary array **nums** and an integer **goal**, please count and return how many non-empty subarrays have a sum equal to **goal**. Please create a class **NSY** in Python based on the above question, with the attribute **nums**. Then create another class **SN_NSY**, inheriting from the **NSY** class, ...
[ "assert candidate([1,0,1,0,1],2)==4", "assert candidate([0,0,0,0,0],0)==15" ]
def test_run(content1,content2): return SN_NSY(content1,content2).Non_subarray()
test_run
assert candidate([['class NSY', 'class SN_NSY(NSY)', 'super().__init__(nums)', 'def Non_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]...
OOP/325
Question: Given a square integer array **matrix** of size n x n, find and return the minimum sum of a descending path through the **matrix**; Based on the above question, create a class **DPH** in Python with the attribute **matrix**. Then create another class **SN_DPH** that inherits from the **DPH** class, and add a ...
[ "assert candidate([[2,1,3],[6,5,4],[7,8,9]])==13", "assert candidate([[-19,57],[-40,-5]])==-59" ]
def test_run(content1): return SN_DPH(content1).descent_path()
test_run
assert candidate([['class DPH', 'class SN_DPH(DPH)', 'super().__init__(matrix)', 'def descent_path']]) == 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]...
OOP/326
Question: An array **nums** of length **n** is considered a beautiful array if it meets the following conditions: 1. **nums** is a permutation of the integers in the range [1, n]. 2. For every 0 <= i < j < n, there is no index **k** (i < k < j) such that 2*nums[k] == nums[i] + nums[j]. Given an integer **n**, return ...
[ "assert candidate(4)==[2,1,4,3]", "assert candidate(5)==[3,1,2,5,4]" ]
def test_run(content1): return SN_BAR(content1).Beautiful_array()
test_run
assert candidate([['class BAR', 'class SN_BAR(BAR)', 'super().__init__(n)', 'def Beautiful_array']]) == 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]...
OOP/327
Question: Given a binary matrix **grid** of size n x n, where 1 represents land and 0 represents water. An island is a maximum group formed by 1s connected on all four sides, i.e., it will not be connected to any other 1s not in the group. There are exactly two islands in the grid. You can turn any number of 0s into 1s...
[ "assert candidate([[0,1],[1,0]])==1", "assert candidate([[0,1,0],[0,0,0],[0,0,1]])==2", "assert candidate([[1,1,1,1,1],[1,0,0,0,1],[1,0,1,0,1],[1,0,0,0,1],[1,1,1,1,1]])==1" ]
def test_run(content1): return SN_FNE(content1).Flip_Number()
test_run
assert candidate([['class FNE', 'class SN_FNE(FNE)', 'super().__init__(grid)', 'def Flip_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]...
OOP/328
Question: Given a log array **logs**. Each log is a string separated by spaces, with the first word being an identifier mixed with letters and numbers. There are two different types of logs: 1. Letter logs: Apart from the identifier, all words are composed of lowercase letters; 2. Number logs: Apart from the identifier...
[ "assert candidate([\"dig1 8 1 5 1\",\"let1 art can\",\"dig2 3 6\",\"let2 own kit dig\",\"let3 art zero\"])==[\"let1 art can\",\"let3 art zero\",\"let2 own kit dig\",\"dig1 8 1 5 1\",\"dig2 3 6\"]", "assert candidate([\"a1 9 2 3 1\",\"g1 act car\",\"zo4 4 7\",\"ab1 off key dog\",\"a8 act zoo\"])==[\"g1 act car\",\...
def test_run(content1): return SN_FOR(content1).Final_order()
test_run
assert candidate([['class FOR', 'class SN_FOR(FOR)', 'super().__init__(logs)', 'def Final_order']]) == 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]...
OOP/329
Question: Given a set of points **drop** on the xy-plane, determine the minimum area of the rectangle formed by these points, where the sides of the rectangle are parallel to the x-axis and y-axis. If no rectangle can be formed, return 0; Based on the above question, please create a class **MAR** in Python language wit...
[ "assert candidate([[1,1],[1,3],[3,1],[3,3],[2,2]])==4", "assert candidate([[1,1],[1,3],[3,1],[3,3],[4,1],[4,3]])==2" ]
def test_run(content1): return SN_MAR(content1).Minimum_Area()
test_run
assert candidate([['class MAR', 'class SN_MAR(MAR)', 'super().__init__(drop)', 'def Minimum_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]...
OOP/330
Question: Given a string **s**, calculate the number of different non-empty sub-sequences of **s**; Based on the above question, please create a class **ESU** in Python language with the attribute **s**. Then create another class **SN_ESU** that inherits from the **ESU** class, and add a public function **empty_subsequ...
[ "assert candidate(\"abc\")==7", "assert candidate(\"aba\")==6", "assert candidate(\"aaa\")==3" ]
def test_run(content1): return SN_ESU(content1).empty_subsequence()
test_run
assert candidate([['class ESU', 'class SN_ESU(ESU)', 'super().__init__(s)', 'def empty_subsequence']]) == 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]...
OOP/331
Question: Given an integer array **nums**. Each **move** operation will choose any index **i** that satisfies 0<=i<nums.length, and increase **nums[i]** by 1. Return the minimum number of operations required to make each value in **nums** unique; Please create a class **MOT** with the attribute **nums** in Python based...
[ "assert candidate([1,2,2])==1", "assert candidate([3,2,1,2,1,7])==6" ]
def test_run(content1): return SN_MOT(content1).Minimum_operations()
test_run
assert candidate([['class MOT', 'class SN_MOT(MOT)', 'super().__init__(nums)', 'def 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]...
OOP/332
Question: Given two sequences **pushed** and **popped**, each with unique values, return True if they could be the result of a sequence of **push** and **pop** operations on an initially empty stack; otherwise, return False. Based on the above question, create a class **ISK** in Python language with the attribute **pu...
[ "assert candidate([1,2,3,4,5],[4,5,3,2,1])==True", "assert candidate([1,2,3,4,5],[4,3,5,1,2])==False" ]
def test_run(content1,content2): return SN_ISK(content1,content2).Initial_stack()
test_run
assert candidate([['class ISK', 'class SN_ISK(ISK)', 'super().__init__(pushed)', 'def Initial_stack']]) == 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]...
OOP/333
Question: There are **n** stones placed on some integer coordinates in a two-dimensional plane. Each coordinate can have at most one stone. If a stone has other stones on the same row or column, it can be removed. Given an array of length **n**, **stones**, where stones[i] = [x_i, y_i] represents the position of the i-...
[ "assert candidate([[0,0],[0,1],[1,0],[1,2],[2,1],[2,2]])==5", "assert candidate([[0,0],[0,2],[1,1],[2,0],[2,2]])==3", "assert candidate([[0,0]])==0" ]
def test_run(content1): return SN_RSN(content1).Removed_stones()
test_run
assert candidate([['class RSN', 'class SN_RSN(RSN)', 'super().__init__(stones)', 'def Removed_stones']]) == 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]...
OOP/334
Question: Your initial energy is **power**, and your initial score is 0. You only have one pack of **tokens**. Where tokens[i] is the value of the i-th token (index starts from 0). There are two possible ways to use the tokens as follows: 1. If you have at least token[i] points of energy, you can flip the i-th token fa...
[ "assert candidate([100],50)==0", "assert candidate([100,200],150)==1", "assert candidate([100,200,300,400],200)==2" ]
def test_run(content1,content2): return SN_INY(content1,content2).Initial_energy()
test_run
assert candidate([['class INY', 'class SN_INY(INY)', 'super().__init__(tokens)', 'def Initial_energy']]) == 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]...
OOP/335
Question: Given an array composed of 4 digits, return the maximum time that can be set in accordance with the 24-hour system. The 24-hour format is **HH:MM**, where HH is between 00 and 23, and MM is between 00 and 59. The smallest 24-hour system time is 00:00, and the largest is 23:59. Starting from 00:00 (midnight), ...
[ "assert candidate([1,2,3,4])==\"23:41\"", "assert candidate([5,5,5,5])==\"\"", "assert candidate([0,0,0,0])==\"00:00\"", "assert candidate([0,0,1,0])==\"10:00\"" ]
def test_run(content1): return SN_ETM(content1).effective_time()
test_run
assert candidate([['class ETM', 'class SN_ETM(ETM)', 'super().__init__(arr)', 'def effective_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]...
OOP/336
Question: Given a non-empty array **nums** composed of different positive integers, consider the following graph: 1. There are nums.length nodes, marked from nums[0] to nums[nums.length-1]; 2. There is an edge between nums[i] and nums[j] only when nums[i] and nums[j] share a common factor greater than 1. Return the siz...
[ "assert candidate([4,6,15,35])==4", "assert candidate([20,50,9,63])==2", "assert candidate([2,3,6,7,4,12,21,39])==8" ]
def test_run(content1): return SN_CCN(content1).Connected_components()
test_run
assert candidate([['class CCN', 'class SN_CCN(CCN)', 'super().__init__(nums)', 'def Connected_components']]) == 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]...
OOP/337
Question: Given an integer array **arr** of even length, return True if **arr** can be rearranged to satisfy for each 0<=i<len(arr)/2, arr[2*i+1]=2*arr[2*i]; otherwise, return False. Please create a class **RSF** with the attribute **arr** in Python based on the above question. Then create another class **SN_RSF** tha...
[ "assert candidate([3,1,3,6])==False", "assert candidate([2,1,2,6])==False", "assert candidate([4,-2,2,-4])==True" ]
def test_run(content1): return SN_RSF(content1).Reorganization_satisfaction()
test_run
assert candidate([['class RSF', 'class SN_RSF(RSF)', 'super().__init__(arr)', 'def Reorganization_satisfaction']]) == 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]...
OOP/338
Question: Given an array **strs** composed of **n** strings, where each string is of equal length. Select a deletion index sequence, for each string in **strs**, delete the character at each corresponding index. Suppose, we have chosen a set of deletion indices **answer**, then after performing the deletion operation, ...
[ "assert candidate([\"ca\",\"bb\",\"ac\"])==1", "assert candidate([\"xc\",\"yb\",\"za\"])==0", "assert candidate([\"zyx\",\"wvu\",\"tsr\"])==3" ]
def test_run(content1): return SN_MPL(content1).Minimum_possible()
test_run
assert candidate([['class MPL', 'class SN_MPL(MPL)', 'super().__init__(strs)', 'def Minimum_possible']]) == 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]...
OOP/339
Question: You are installing a billboard and want it to be as high as possible. This billboard will have two steel brackets, one on each side. The height of each steel bracket must be equal. You have a pile of **rods** that can be welded together. For example, if the lengths of the rods are 1, 2, and 3, they can be wel...
[ "assert candidate([1,2,3,6])==6", "assert candidate([1,2,3,4,5,6])==10", "assert candidate([1,2])==0" ]
def test_run(content1): return SN_IBD(content1).Install_billboards()
test_run
assert candidate([['class IBD', 'class SN_IBD(IBD)', 'super().__init__(rods)', 'def Install_billboards']]) == 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]...
OOP/340
Question: In an nxn grid composed of 1x1 squares, each 1x1 square is made up of '/', '\' or a space. These characters divide the square into some regions with common edges. Given the grid represented as an array of strings, return the number of regions; Please create a class **NAS** in Python based on the above questio...
[ "assert candidate([\" /\",\"/ \"])==2", "assert candidate([\" /\",\" \"])==1", "assert candidate([\"/\\\",\"\\/\"])==5" ]
def test_run(content1): return SN_NAS(content1).Number_areas()
test_run
assert candidate([['class NAS', 'class SN_NAS(NAS)', 'super().__init__(grid)', 'def Number_areas']]) == 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]...
OOP/341
Question: Given an array of **strs** composed of **n** lowercase letter strings, where each string is of equal length. Select a deletion index sequence, and for each string in **strs**, delete the character at each corresponding index. For example, if strs = ["abcdef", "uvwxyz"], and the deletion index sequence is {0,2...
[ "assert candidate([\"babca\",\"bbazb\"])==3", "assert candidate([\"edcba\"])==4", "assert candidate([\"ghi\",\"def\",\"abc\"])==0" ]
def test_run(content1): return SN_MSI(content1).Minimum_spossible()
test_run
assert candidate([['class MSI', 'class SN_MSI(MSI)', 'super().__init__(strs)', 'def Minimum_spossible']]) == 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]...
OOP/342
Question: Given an integer array **A**, a slope is a tuple (i, j), where i < j and A[i] <= A[j]. The width of such a slope is j-i. Find the maximum width of the slope in **A**, if it does not exist, return 0. Please create a class **WSP** in Python language based on the above question, with the attribute **A**. Then cr...
[ "assert candidate([6,0,8,2,1,5])==4", "assert candidate([9,8,1,0,1,9,4,0,4,1])==7" ]
def test_run(content1): return SN_WSP(content1).Width_slope()
test_run
assert candidate([['class WSP', 'class SN_WSP(WSP)', 'super().__init__(A)', 'def Width_slope']]) == 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]...
OOP/343
Question: Given a set of points **drop** on the **xy** plane, determine the minimum area of any rectangle formed by these points, where the sides of the rectangle are not necessarily parallel to the x-axis and y-axis. If there are no rectangles, return 0; Based on the above question, please create a class **ARE** in Py...
[ "assert candidate([[1,2],[2,1],[1,0],[0,1]])==2.00000", "assert candidate([[0,1],[2,1],[1,1],[1,0],[2,0]])==1.00000", "assert candidate([[0,3],[1,2],[3,1],[1,3],[2,1]])==0", "assert candidate([[3,1],[1,1],[0,1],[2,1],[3,3],[3,2],[0,2],[2,3]])==2.00000" ]
def test_run(content1): return SN_ARE(content1).Any_rectangle()
test_run
assert candidate([['class ARE', 'class SN_ARE(ARE)', 'super().__init__(drop)', 'def Any_rectangle']]) == 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]...
OOP/344
Question: Given a positive integer **x**, we will write an expression of the form x(op1)x(op2)x(op3)x..., where each operator op1, op2, ... can be one of addition, subtraction, multiplication, or division (+, -, *, or /). For example, for x=3, we can write the expression 3*3/3+3-3, which equals 3. When writing such exp...
[ "assert candidate(3,19)==5", "assert candidate(5,501)==8", "assert candidate(100,100000000)==3" ]
def test_run(content1,content2): return SN_MNOOT(content1,content2).minimum_operators==5()
test_run
assert candidate([['class MNOOT', 'class SN_MNOOT(MNOOT)', 'super().__init__(x)', 'def minimum_operators']]) == 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]...
OOP/345
Question: Return all non-negative integers of length **n** such that the absolute difference between the digits in every two consecutive positions is **k**; Please create a class **NIG** in Python language based on the above question, with the attribute **n**. Then create a class **SN_NIG** that inherits from the **NIG...
[ "assert candidate(3,7)==[181,292,707,818,929]", "assert candidate(2,1)==[10,12,21,23,32,34,43,45,54,56,65,67,76,78,87,89,98]", "assert candidate(2,0)==[11,22,33,44,55,66,77,88,99]", "assert candidate(2,2)==[13,20,24,31,35,42,46,53,57,64,68,75,79,86,97]" ]
def test_run(content1,content2): return SN_NIG(content1,content2).nonnegative_integer()
test_run
assert candidate([['class NIG', 'class SN_NIG(NIG)', 'super().__init__(n)', 'def 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]...
OOP/346
Question: Given an integer array **arr**, please sort the array using pancake flipping. The execution process of a pancake flip is as follows: 1. Choose an integer **k**, where 1<=k<=arr.length; 2. Reverse the sub-array arr[0...k-1] (index starts from 0); Return the sequence of **k** values corresponding to the pancake...
[ "assert candidate([3,2,4,1])==[4,2,4,3]", "assert candidate([1,2,3])==[]" ]
def test_run(content1): return SN_PFG(content1).Pancake_flipping()
test_run
assert candidate([['class PFG', 'class SN_PFG(PFG)', 'super().__init__(arr)', 'def Pancake_flipping']]) == 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]...
OOP/347
Question: Given three integers **x**, **y**, and **bound**, return a list of all powerful integers that are less than or equal to **bound**; Based on the above question, please create a class **SIG** in Python with the attribute **x**; then create a class **SN_SIG** that inherits from the **SIG** class, and add two att...
[ "assert candidate(2,3,10)==[2,3,4,5,7,9,10]", "assert candidate(3,5,15)==[2,4,6,8,10,14]" ]
def test_run(content1,content2,content3): return SN_SIG(content1,content2,content3).Strong_integer()
test_run
assert candidate([['class SIG', 'class SN_SIG(SIG)', 'super().__init__(x)', 'def Strong_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]...
OOP/348
Question: Given two strings **s** and **t**, each string represents a non-negative rational number, return True only when they represent the same number; Based on the above question, please create a class **SNR** in Python with the attribute **s**; then create another class **SN_SNR** inheriting from the **SNR** class,...
[ "assert candidate(\"0.(52)\",\"0.5(25)\")==True", "assert candidate(\"0.1666(6)\",\"0.166(66)\")==True", "assert candidate(\"0.9(9)\",\"1.\")==True" ]
def test_run(content1,content2): return SN_SNR(content1,content2).()
test_run
assert candidate([['class SNR', 'class SN_SNR(SNR)', 'super().__init__(s)', 'def Same_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]...
OOP/349
Question: Given an array **points**, where points[i] = [x_i, y_i] represents a point on the X-Y plane, and an integer **k**, return the **k** points closest to the origin (0,0); Based on the above question, create a class **NOG** in Python, with the attribute **points**; then create a class **SN_NOG** that inherits fro...
[ "assert candidate([[1,3],[-2,2]],1)==[[-2,2]]", "assert candidate([[3,3],[5,-1],[-2,4]],2)==[[3,3],[-2,4]]" ]
def test_run(content1,content2): return SN_NOG(content1,content2).Nearest_origin()
test_run
assert candidate([['class NOG', 'class SN_NOG(NOG)', 'super().__init__(points)', 'def Nearest_origin']]) == 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]...
OOP/350
Question: Given an integer array **nums** and an integer **k**, return the number of (continuous, non-empty) sub-arrays whose sum of elements can be divided by **k**. Please create a class **SET** in Python language based on the above question, which has the attribute **nums**. Then create another class **SN_SET**, in...
[ "assert candidate([4,5,0,-2,-3,1],5)==7", "assert candidate([5],9)==0" ]
def test_run(content1,content2): return SN_SET(content1,content2).Sum_Elements()
test_run
assert candidate([['class SET', 'class SN_SET(SET)', 'super().__init__(nums)', 'def Sum_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]...
OOP/351
Question: Given an integer array **A**, you can start from a certain index and make a certain number of jumps. During your jumping process, the 1-th, 3-th, 5-th... jumps are called odd jumps, while the 2-th, 4-th, 6-th... jumps are called even jumps. You can jump from index **i** to index **j** (where **i < j**) in the...
[ "assert candidate([10,13,12,14,15])==2", "assert candidate([2,3,1,1,4])==3", "assert candidate([5,1,3,4,2])==3" ]
def test_run(content1): return SN_SID(content1).start_index()
test_run
assert candidate([['class SID', 'class SN_SID(SID)', 'super().__init__(A)', 'def start_index']]) == 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]...
OOP/352
Question: Given an integer array **arr**, return the length of the maximum **turbulence subarray** in **arr**. A subarray is a **turbulence subarray** if the comparison sign flips between each pair of adjacent elements in the subarray; Based on the above question, create a class **MTL** in Python, which has the attribu...
[ "assert candidate([9,4,2,10,7,8,8,1,9])==5", "assert candidate([4,8,12,16])==2", "assert candidate([100])==1" ]
def test_run(content1): return SN_MTL(content1).Maximum_turbulence()
test_run
assert candidate([['class MTL', 'class SN_MTL(MTL)', 'super().__init__(arr)', 'def Maximum_turbulence']]) == 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]...
OOP/353
Question: On a two-dimensional grid **grid**, there are 4 types of squares: **1** represents the starting square, and there is only one starting square; **2** represents the ending square, and there is only one ending square; **0** represents the empty square that we can walk through; **-1** represents the obstacle tha...
[ "assert candidate([[1,0,0,0],[0,0,0,0],[0,0,2,-1]])==2", "assert candidate([[1,0,0,0],[0,0,0,0],[0,0,0,2]])==4", "assert candidate([[0,1],[2,0]])==0" ]
def test_run(content1): return SN_DPS(content1).Different_paths()
test_run
assert candidate([['class DPS', 'class SN_DPS(DPS)', 'super().__init__(grid)', 'def Different_paths']]) == 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]...
OOP/354
Question: Given an integer array **nums**, return the number of bitwise AND triplets. A bitwise AND triplet is a triplet made up of indices (i, j, k) that satisfy all of the following conditions: 1. 0<=i<nums.length; 2. 0<=j<nums.length; 3. 0<=k<nums.length; 4. nums[i]&nums[j]&nums[k]==0, where & represents the bitwise...
[ "assert candidate([2,1,3])==12", "assert candidate([0,0,0])==27" ]
def test_run(content1): return SN_BTT(content1).Bitwise_triplet()
test_run
assert candidate([['class BTT', 'class SN_BTT(BTT)', 'super().__init__(nums)', 'def Bitwise_triplet']]) == 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]...
OOP/355
Question: Given two integers a and b, return any string s that satisfies the following conditions: 1. The length of s is a+b, and it contains exactly a occurrences of the letter 'a' and b occurrences of the letter 'b'. 2. The substring 'aaa' does not appear in s. 3. The substring 'bbb' does not appear in s. Please crea...
[ "assert candidate(1,2)==\"abb\"", "assert candidate(4,1)==\"aabaa\"" ]
def test_run(content1,content2): return SN_ASG(content1,content2).Any_string()
test_run
assert candidate([['class ASG', 'class SN_ASG(ASG)', 'super().__init__(a)', 'def Any_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]...
OOP/356
Question: Given two lists composed of some closed intervals, **firstList** and **secondList**, where firstList[i]=[start_i,end_i] and secondList[j]=[start_j,end_j]. Each interval list is pairwise disjoint and already sorted. Return the intersection of these two interval lists; Based on the above question, please create...
[ "assert candidate([[0,2],[5,10],[13,23],[24,25]],[[1,5],[8,12],[15,24],[25,26]])==[[1,2],[5,5],[8,10],[15,23],[24,24],[25,25]]", "assert candidate([[1,3],[5,9]],[])==[]", "assert candidate([],[[4,8],[10,12]])==[]", "assert candidate([[1,7]],[[3,10]])==[[3,7]]" ]
def test_run(content1,content2): return SN_ILT(content1,content2).Interval_List()
test_run
assert candidate([['class ILT', 'class SN_ILT(ILT)', 'super().__init__(firstList)', 'def Interval_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]...
OOP/357
Question: Given an array composed of string equations that represent the relationships between variables, each string equation equations[i] has a length of 4 and takes one of two different forms: **a==b** or **a!=b**. Here, a and b are lowercase letters (not necessarily different), representing single-letter variable n...
[ "assert candidate([\"a==b\",\"b!=a\"])==False", "assert candidate([\"b==a\",\"a==b\"])==True", "assert candidate([\"a==b\",\"b==c\",\"a==c\"])==True", "assert candidate([\"a==b\",\"b!=c\",\"c==a\"])==False", "assert candidate([\"c==c\",\"b==d\",\"x!=z\"])==True" ]
def test_run(content1): return SN_SVE(content1).Single_variable()
test_run
assert candidate([['class SVE', 'class SN_SVE(SVE)', 'super().__init__(equations)', 'def Single_variable']]) == 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]...
OOP/358
Question: On a broken calculator displaying the number **startValue**, we can perform the following two operations: 1. Double: Multiply the number on the display by 2; 2. Decrement: Subtract 1 from the number on the display. Given two integers, **startValue** and **target**, return the minimum number of operations requ...
[ "assert candidate(2,3)==2", "assert candidate(5,8)==2", "assert candidate(3,10)==3" ]
def test_run(content1,content2): return SN_MOS(content1,content2).Minimum_operands()
test_run
assert candidate([['class MOS', 'class SN_MOS(MOS)', 'super().__init__(startValue)', 'def Minimum_operands']]) == 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]...
OOP/359
Question: Given a positive integer array **nums** and an integer **k**, return the number of good sub-arrays in nums. If the number of different integers in a sub-array of nums is exactly **k**, then this continuous, not necessarily different sub-array of **nums** is called a good sub-array; Based on the above question...
[ "assert candidate([1,2,1,2,3],2)==7", "assert candidate([1,2,1,3,4],3)==3" ]
def test_run(content1,content2): return SN_GAR(content1,content2).Good_array()
test_run
assert candidate([['class GAR', 'class SN_GAR(GAR)', 'super().__init__(nums)', 'def Good_array']]) == 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]...
OOP/360
Question: In the given m x n grid **grid**, each cell can have one of the following three values: 1. Value 0 represents an empty cell. 2. Value 1 represents a fresh orange. 3. Value 2 represents a rotten orange. Every minute, a rotten orange will make any fresh orange in the four adjacent directions rot. Return the m...
[ "assert candidate([[2,1,1],[1,1,0],[0,1,1]])==4", "assert candidate([[2,1,1],[0,1,1],[1,0,1]])==-1", "assert candidate([[0,2]])==0" ]
def test_run(content1): return SN_MME(content1).Min_Minutes()
test_run
assert candidate([['class MME', 'class SN_MME(MME)', 'super().__init__(grid)', 'def Min_Minutes']]) == 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]...
OOP/361
Question: Given a binary array **nums** and an integer **k**, return the minimum number of k-bit flips required for the array to have no zeros. If it's not possible, return -1. A k-bit flip means choosing a subarray of length **k** from nums, and simultaneously changing every 0 in the subarray to 1, and every 1 in the ...
[ "assert candidate([0,1,0],1)==2", "assert candidate([1,1,0],2)==-1", "assert candidate([0,0,0,1,0,1,1,0],3)==3" ]
def test_run(content1,content2): return SN_MFI(content1,content2).Min_Flip()
test_run
assert candidate([['class MFI', 'class SN_MFI(MFI)', 'super().__init__(nums)', 'def Min_Flip']]) == 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]...
OOP/362
Question: Given a non-negative integer array **A**, if the sum of every pair of adjacent elements is a perfect square, then this array is called a square array. Return the number of square arrangements of **A**. Please create a **SAT** class based on the above question, with the attribute **A**; then create a **SN_SAT*...
[ "assert candidate([1,17,8])==2", "assert candidate([2,2,2])==1" ]
def test_run(content1): return SN_SAT(content1).Square_arrangement()
test_run
assert candidate([['class SAT', 'class SN_SAT(SAT)', 'super().__init__(A)', 'def Square_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]...
OOP/363
Question: There are **n** piles of stones arranged in a row, with stones[i] stones in the i-th pile. Each move requires merging **k** consecutive piles of stones into one pile, and the cost of this move is the total number of stones in these **k** piles. Return the lowest cost to merge all the stones into one pile. If ...
[ "assert candidate([3,2,4,1],2)==20", "assert candidate([3,2,4,1],3)==-1", "assert candidate([3,5,1,2,6],3)==25" ]
def test_run(content1,content2): return SN_SMG(content1,content2).Stone_Merge()
test_run
assert candidate([['class SMG', 'class SN_SMG(SMG)', 'super().__init__(stones)', 'def Stone_Merge']]) == 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]...
OOP/364
Question: In a row of dominoes, tops[i] and bottoms[i] represent the top and bottom halves of the i-th domino respectively. (A domino is formed by two numbers from 1 to 6 arranged in columns - each half of the tile has a number.) We can rotate the i-th domino so that the values of tops[i] and bottoms[i] are swapped. Re...
[ "assert candidate([2,1,2,4,2,2],[5,2,6,2,3,2])==2", "assert candidate([3,5,1,2,3],[3,6,3,3,4])==-1" ]
def test_run(content1,content2): return SN_DMS(content1,content2).Dominoes()
test_run
assert candidate([['class DMS', 'class SN_DMS(DMS)', 'super().__init__(tops)', 'def Dominoes']]) == 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]...
OOP/365
Question: In the song list, the duration of the i-th song is time[i] seconds. Return the number of song pairs whose total duration (in seconds) can be divided by 60; Based on the above question, please create a class **TDN** in Python, with the attribute **time**; then create another class **SN_TDN**, inheriting from t...
[ "assert candidate([30,20,150,100,40])==3", "assert candidate([60,60,60])==3" ]
def test_run(content1): return SN_TDN(content1).Total_duration()
test_run
assert candidate([['class TDN', 'class SN_TDN(TDN)', 'super().__init__(time)', 'def Total_duration']]) == 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]...
OOP/366
Question: The packages on the **conveyor belt** must be transported from one port to another within **days**. The weight of the i-th package on the conveyor belt is weights[i]. Every day, we load packages onto the conveyor belt in the order of the given weights. The weight we load will not exceed the maximum carrying w...
[ "assert candidate([1,2,3,4,5,6,7,8,9,10],5)==15", "assert candidate([3,2,2,4,1,4],3)==6", "assert candidate([1,2,3,1,1],4)==3" ]
def test_run(content1,content2): return SN_MCG(content1,content2).Minimum_carrying()
test_run
assert candidate([['class MCG', 'class SN_MCG(MCG)', 'super().__init__(weights)', 'def Minimum_carrying']]) == 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]...
OOP/367
Question: Given a positive integer **n**, return the number of positive integers within the range [1, n] that have at least one repeating digit; Based on the above question, please create a class called **RNS** in Python, with an attribute **n**. Then create another class **SN_RNS** that inherits from the **RNS** class...
[ "assert candidate(20)==1", "assert candidate(100)==10", "assert candidate(1000)==262" ]
def test_run(content1): return SN_RNS(content1).Repeating_numbers()
test_run
assert candidate([['class RNS', 'class SN_RNS(RNS)', 'super().__init__(n)', 'def Repeating_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]...
OOP/368
Question: Given a positive integer array **values**, where values[i] represents the rating of the i-th sightseeing spot, and the distance between two spots i and j is j-i. The score of a sightseeing combination of a pair of spots (i<j) is values[i]+values[j]+i-j, which is the sum of the ratings of the spots minus the d...
[ "assert candidate([8,1,5,2,6])==11", "assert candidate([1,2])==2" ]
def test_run(content1): return SN_SCT(content1).Sightseeing_combination()
test_run
assert candidate([['class SCT', 'class SN_SCT(SCT)', 'super().__init__(values)', 'def Sightseeing_combination']]) == 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]...
OOP/369
Question: Given a positive integer **k**, you need to find the length of the smallest positive integer **n** that can be divided by **k** and only contains the digit 1. Return the length of **n**. If there is no such **n**, return -1; Based on the above question, please create a class **MIR** in Python with the attribu...
[ "assert candidate(1)==1", "assert candidate(2)==-1", "assert candidate(3)==3" ]
def test_run(content1): return SN_MIR(content1).Minimum_integer()
test_run
assert candidate([['class MIR', 'class SN_MIR(MIR)', 'super().__init__(k)', 'def 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]...
OOP/370
Question: Given a binary string **s** and a positive integer **n**, return True if the binary representation of every integer in the range [1, n] is a substring of **s**, otherwise return False; Please create a class **ETG** in Python language based on the above question, with the attribute **s**. Then create a class *...
[ "assert candidate(\"0110\",3)==True", "assert candidate(\"0110\",4)==False" ]
def test_run(content1,content2): return SN_ETG(content1,content2).Each_integer()
test_run
assert candidate([['class ETG', 'class SN_ETG(ETG)', 'super().__init__(s)', 'def Each_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]...
OOP/371
Question: Given an integer **n**, return its negative binary (base-2) representation in the form of a binary string; Based on the above question, create a class **NGY** in Python language with the attribute **n**; then create a class **SN_NGY** that inherits from the **NGY** class, and add a public function **negabinar...
[ "assert candidate(2)==\"110\"", "assert candidate(3)==\"111\"", "assert candidate(4)==\"100\"" ]
def test_run(content1): return SN_NGY(content1).negabinary()
test_run
assert candidate([['class NGY', 'class SN_NGY(NGY)', 'super().__init__(n)', 'def negabinary']]) == 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]...
OOP/372
Question: Given a linked list of length **n**, **head**. For each node in the list, find the value of the next larger node. That is, for each node, find the value of the first node next to it, the value of this node is strictly greater than its value. Return an integer array **answer**, where answer[i] is the value of ...
[ "assert candidate([2,1,5])==[5,5,0]", "assert candidate([2,7,4,3,5])==[7,0,5,5,0]" ]
def test_run(content1): return SN_LNS(content1).Larger_nodes()
test_run
assert candidate([['class LNS', 'class SN_LNS(LNS)', 'super().__init__(head)', 'def Larger_nodes']]) == 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]...
OOP/373
Question: Given a binary matrix grid of size m x n, where 0 represents an ocean cell and 1 represents a land cell. A move is defined as moving from one land cell to another adjacent (up, down, left, right) land cell or crossing the border of the **grid**. Return the number of land cells in the grid that cannot leave th...
[ "assert candidate([[0,0,0,0],[1,0,1,0],[0,1,1,0],[0,0,0,0]])==3", "assert candidate([[0,1,1,0],[0,0,1,0],[0,0,1,0],[0,0,0,0]])==0" ]
def test_run(content1): return SN_LCL(content1).Land_Cell()
test_run
assert candidate([['class LCL', 'class SN_LCL(LCL)', 'super().__init__(grid)', 'def Land_Cell']]) == 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]...
OOP/374
Question: Given a string array **queries** and a string representing a **pattern**, return a boolean array **answer**. Only when the query item queries[i] matches the pattern string pattern, answer[i] is True, otherwise it is False; Based on the above question, please create a class **BAY** in Python with the property ...
[ "assert candidate([\"FooBar\",\"FooBarTest\",\"FootBall\",\"FrameBuffer\",\"ForceFeedBack\"],\"FB\")==[True,False,True,True,False]", "assert candidate([\"FooBar\",\"FooBarTest\",\"FootBall\",\"FrameBuffer\",\"ForceFeedBack\"],\"FoBa\")==[True,False,True,False,False]", "assert candidate([\"FooBar\",\"FooBarTest\...
def test_run(content1,content2): return SN_BAY(content1,content2).boolean_array()
test_run
assert candidate([['class BAY', 'class SN_BAY(BAY)', 'super().__init__(queries)', 'def boolean_array']]) == 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]...
OOP/375
Question: Given an integer array **nums**, return the length of the longest arithmetic subsequence in **nums**; Based on the above question, create a class **LSQ** using Python language, with the attribute **nums**. Then create another class **SN_LSQ**, inheriting from the **LSQ** class, and add a public function **Lon...
[ "assert candidate([3,6,9,12])==4", "assert candidate([9,4,7,2,10])==3", "assert candidate([20,1,15,3,10,5,8])==4" ]
def test_run(content1): return SN_LSQ(content1).Longest_subsequence()
test_run
assert candidate([['class LSQ', 'class SN_LSQ(LSQ)', 'super().__init__(nums)', 'def Longest_subsequence']]) == 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]...
OOP/376
Question: The company plans to interview 2n people. Given an array **costs**, where costs[i]=[aCosti,bCosti]. The cost for the i-th person to fly to city **a** is **aCost_i**, and the cost to fly to city **b** is **bCost_i**. Return the minimum cost to fly each person to either city **a** or **b**, with the requirement...
[ "assert candidate([[10,20],[30,200],[400,50],[30,20]])==110", "assert candidate([[259,770],[448,54],[926,667],[184,139],[840,118],[577,469]])==1859", "assert candidate([[515,563],[451,713],[537,709],[343,819],[855,779],[457,60],[650,359],[631,42]])==3086" ]
def test_run(content1): return SN_MCT(content1).Minimum_cost()
test_run
assert candidate([['class MCT', 'class SN_MCT(MCT)', 'super().__init__(costs)', 'def Minimum_cost']]) == 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]...
OOP/377
Question: Given an integer array **nums** and two integers **firstLen** and **secondLen**, you are to find and return the maximum sum of elements in two non-overlapping subarrays, with lengths respectively as **firstLen** and **secondLen**; Based on the above question, create a class **OSR** in Python with the attribut...
[ "assert candidate([0,6,5,2,2,5,1,9,4],1,2)==20", "assert candidate([3,8,1,3,2,1,8,9,0],3,2)==29", "assert candidate([2,1,5,6,0,9,5,0,3,8],4,3)==31" ]
def test_run(content1,content2,content3): return SN_OSR(content1,content2,content3).overlapping_subarray()
test_run
assert candidate([['class OSR', 'class SN_OSR(OSR)', 'super().__init__(nums)', 'def overlapping_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]...
OOP/378
Question: Three stones are placed on the number line at positions **a**, **b**, and **c**. In each round, you can pick up a stone from one of the ends (either the largest or smallest position) and place it in any free position between the two ends. Formally, suppose the three stones are currently at positions **x**, **...
[ "assert candidate(1,2,5)==[1, 2]", "assert candidate(4,3,2)==[0, 0]" ]
def test_run(content1,content2,content3): return SN_SMT(content1,content2,content3).Stone_movement()
test_run
assert candidate([['class SMT', 'class SN_SMT(SMT)', 'super().__init__(a)', 'def Stone_movement']]) == 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]...
OOP/379
Question: Write down the integers in **nums1** and **nums2** in the given order on two independent horizontal lines. Now, some lines can be drawn connecting the two numbers nums1[i] and nums2[j]. These lines need to satisfy the following conditions: 1. nums1[i] == nums2[j]; 2. The drawn line does not intersect with an...
[ "assert candidate([1,4,2],[1,2,4])==2", "assert candidate([2,5,1,2,5],[10,5,2,1,5,2])==3", "assert candidate([1,3,7,1,7,5],[1,9,2,5,1])==2" ]
def test_run(content1,content2): return SN_MCT(content1,content2).max_connections()
test_run
assert candidate([['class MCT', 'class SN_MCT(MCT)', 'super().__init__(nums1)', 'def max_connections']]) == 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]...
OOP/380
Question: In a 10^6x10^6 grid, the coordinates of each cell are (x,y). Now, starting from the source cell source=[sx,sy], the intention is to rush to the target cell target=[tx,ty]. The array blocked is a list of blocked cells, where each blocked[i]=[xi,yi] indicates that the cell with coordinates (xi,yi) is forbidden ...
[ "assert candidate([[0,1],[1,0]],[0,0],[0,2])==False", "assert candidate([],[0,0],[999999,999999])==True" ]
def test_run(content1,content2,content3): return SN_SGD(content1,content2,content3).Source_grid()
test_run
assert candidate([['class SGD', 'class SN_SGD(SGD)', 'super().__init__(blocked)', 'def Source_grid']]) == 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]...
OOP/381
Question: You have a convex n-polygon, each vertex of which has an integer value. Given an integer array **values**, where values[i] is the value of the i-th vertex (i.e., in clockwise order). Assume the polygon is divided into n-2 triangles. For each triangle, the value of the triangle is the product of the vertex lab...
[ "assert candidate([1,2,3])==6", "assert candidate([3,7,4,5])==144", "assert candidate([1,3,1,4,1,5])==13" ]
def test_run(content1): return SN_TGT(content1).triangulation()
test_run
assert candidate([['class TGT', 'class SN_TGT(TGT)', 'super().__init__(values)', 'def triangulation']]) == 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]...
OOP/382
Question: On an infinite plane, the robot initially stands at the point (0,0), facing north. Note: 1. North is the positive direction of the y-axis. 2. South is the negative direction of the y-axis. 3. East is the positive direction of the x-axis. 4. West is the negative direction of the x-axis. The robot can accept on...
[ "assert candidate(\"GGLLGG\")==True", "assert candidate(\"GG\")==False", "assert candidate(\"GL\")==True" ]
def test_run(content1): return SN_EIT(content1).Execute_instructions()
test_run
assert candidate([['class EIT', 'class SN_EIT(EIT)', 'super().__init__(instructions)', 'def Execute_instructions']]) == 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]...
OOP/383
Question: There are **n** gardens, labeled from 1 to **n**. There is also an array **paths**, where paths[i] = [x_i, y_i] describes the bidirectional path from garden **x_i** to garden **y_i**. In each garden, you plan to plant one of four types of flowers. Moreover, each garden can have at most three paths leading in ...
[ "assert candidate(3,[[1,2],[2,3],[3,1]])==[1,2,3]", "assert candidate(4,[[1,2],[3,4]])==[1,2,1,2]", "assert candidate(4,[[1,2],[2,3],[3,4],[4,1],[1,3],[2,4]])==[1,2,3,4]" ]
def test_run(content1,content2): return SN_PFS(content1,content2).Planted_flowers()
test_run
assert candidate([['class PFS', 'class SN_PFS(PFS)', 'super().__init__(n)', 'def Planted_flowers']]) == 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]...
OOP/384
Question: Given an integer array **arr**, please divide this array into some (continuous) sub-arrays with a maximum length of **k**. After the division, all values in each sub-array will become the maximum value in that sub-array. Return the maximum sum of elements that can be obtained after the array is divided and tr...
[ "assert candidate([1,15,7,9,2,5,10],3)==84", "assert candidate([1,4,1,5,7,3,6,1,9,9,3],4)==83", "assert candidate([1],1)==4" ]
def test_run(content1,content2): return SN_STF(content1,content2).Separation_transformation()
test_run
assert candidate([['class STF', 'class SN_STF(STF)', 'super().__init__(arr)', 'def Separation_transformation']]) == 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]...
OOP/385
Question: Given a string **s**, consider all its repeated substrings: that is, the (continuous) substrings of **s** that appear 2 or more times in **s**. These appearances may overlap. Return any one of the possible longest repeated substrings. If **s** does not contain repeated substrings, then the answer is ""; Pleas...
[ "assert candidate(\"banana\")==\"ana\"", "assert candidate(\"abcd\")==\"\"" ]
def test_run(content1): return SN_RST(content1).Repeated_substring()
test_run
assert candidate([['class RST', 'class SN_RST(RST)', 'super().__init__(s)', 'def Repeated_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]...
OOP/386
Question: Given a word array **words**, each word is composed of lowercase English letters. If we can add exactly one letter anywhere in **wordA** without changing the order of other characters to make it become **wordB**, then we consider **wordA** to be the predecessor of **wordB**. For example, **abc** is the predec...
[ "assert candidate([\"a\",\"b\",\"ba\",\"bca\",\"bda\",\"bdca\"])==4", "assert candidate([\"xbc\",\"pcxbcf\",\"xb\",\"cxbc\",\"pcxbc\"])==5", "assert candidate([\"abcd\",\"dbqca\"])==1" ]
def test_run(content1): return SN_FCA(content1).Form_chain()
test_run
assert candidate([['class FCA', 'class SN_FCA(FCA)', 'super().__init__(words)', 'def Form_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]...
OOP/387
Question: There is a pile of stones, represented by an integer array **stones**. Where stones[i] represents the weight of the i-th stone. Each round, select any two stones from it and crush them together. Suppose the weights of the stones are **x** and **y**, and x <= y. Then the possible results of crushing are as fol...
[ "assert candidate([2,7,4,1,8,1])==1", "assert candidate([31,26,33,21,40])==5" ]
def test_run(content1): return SN_MWG(content1).Minimum_weight()
test_run
assert candidate([['class MWG', 'class SN_MWG(MWG)', 'super().__init__(stones)', 'def Minimum_weight']]) == 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]...
OOP/388
Question: Given a positive integer array **arr** (which may contain duplicate elements), please return the maximum arrangement that is lexicographically smaller than **arr** and can be obtained by one swap (swapping the positions of two numbers arr[i] and arr[j]). If such operation is not possible, please return the or...
[ "assert candidate([3,2,1])==[3,1,2]", "assert candidate([1,1,5])==[1,1,5]", "assert candidate([1,9,4,6,7])==[1,7,4,6,9]" ]
def test_run(content1): return SN_OEH(content1).One_exchange()
test_run
assert candidate([['class OEH', 'class SN_OEH(OEH)', 'super().__init__(arr)', 'def One_exchange']]) == 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]...
OOP/389
Question: In a warehouse, there is a row of barcodes, where the i-th barcode is barcodes[i]. Please rearrange these barcodes so that no two adjacent barcodes are the same. You can return any answer that meets this requirement, and it is guaranteed that an answer exists; Please create a class **ABD** in Python based on ...
[ "assert candidate([1,1,1,2,2,2])==[2,1,2,1,2,1]", "assert candidate([1,1,1,1,2,2,3,3])==[1,3,1,3,2,1,2,1]" ]
def test_run(content1): return SN_ABD(content1).Adjacent_barcodes()
test_run
assert candidate([['class ABD', 'class SN_ABD(ABD)', 'super().__init__(barcodes)', 'def Adjacent_barcodes']]) == 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]...
OOP/390
Question: Given two strings of equal length, **s1** and **s2**, and another string, baseStr, where s1[i] and s2[i] are a pair of equivalent characters. For example, if s1 = **abc** and s2 = **cde**, then 'a' == 'c', 'b' == 'd', and 'c' == 'e'. Equivalent characters follow the general rules of any equivalence relation: ...
[ "assert candidate(\"parker\",\"morris\",\"parser\")==\"makkek\"", "assert candidate(\"hello\",\"world\",\"hold\")==\"hdld\"", "assert candidate(\"leetcode\",\"programs\",\"sourcecode\")==\"aauaaaaada\"" ]
def test_run(content1,content2,content3): return SN_EST(content1,content2,content3).Equivalent_String()
test_run
assert candidate([['class EST', 'class SN_EST(EST)', 'super().__init__(s1)', 'def Equivalent_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]...
OOP/391
Question: Given an m x n matrix **matrix**, you can select any number of columns from it and flip each cell on it. (That is, after flipping, the value of the cell changes from 0 to 1, or from 1 to 0.) Return the maximum number of rows where all values in the row are equal after some flips; Please create a class **MRW**...
[ "assert candidate([[0,1],[1,1]])==1", "assert candidate([[0,1],[1,0]])==2", "assert candidate([[0,0,0],[0,0,1],[1,1,0]])==2" ]
def test_run(content1): return SN_MRW(content1).Maximum_rows()
test_run
assert candidate([['class MRW', 'class SN_MRW(MRW)', 'super().__init__(matrix)', 'def Maximum_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]...
OOP/392
Question: Given two numbers **arr1** and **arr2** in base -2, return the result of their addition; Please create a class named **ANS** in Python based on the above question, with the attribute **arr1**. Then create another class named **SN_ANS**, which inherits from the **ANS** class, and adds the attribute **arr2**, a...
[ "assert candidate([1,1,1,1,1],[1,0,1])==[1,0,0,0,0]", "assert candidate([0],[0])==[0]", "assert candidate([0],[1])==[1]" ]
def test_run(content1,content2): return SN_ANS(content1,content2).Adding_Numbers()
test_run
assert candidate([['class ANS', 'class SN_ANS(ANS)', 'super().__init__(arr1)', 'def Adding_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]...
OOP/393
Question: Given a **matrix** and a **target** value, return the number of non-empty submatrices whose sum of elements equals the target value; Please create a class **ESI** in Python language based on the above question, with the attribute **matrix**; then create another class **SN_ESI**, inheriting from the **ESI** cl...
[ "assert candidate([[0,1,0],[1,1,1],[0,1,0]],0)==4", "assert candidate([[1,-1],[-1,1]],0)==5", "assert candidate([[904]],0)==0" ]
def test_run(content1,content2): return SN_ESI(content1,content2).empty_submatrix()
test_run
assert candidate([['class ESI', 'class SN_ESI(ESI)', 'super().__init__(matrix)', 'def empty_submatrix']]) == 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]...
OOP/394
Question: You have a set of movable type **tiles**, each of which is engraved with a letter tiles[i]. Return the number of non-empty letter sequences you can print; Please create a class **LSQ** based on the above question, with the attribute **tiles** using Python language; then create another class **SN_LSQ**, inheri...
[ "assert candidate(\"AAB\")==8", "assert candidate(\"AAABBC\")==188", "assert candidate(\"V\")==1" ]
def test_run(content1): return SN_LSQ(content1).letter_sequence()
test_run
assert candidate([['class LSQ', 'class SN_LSQ(LSQ)', 'super().__init__(tiles)', 'def letter_sequence']]) == 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]...
OOP/395
Question: Return the subsequence of **s** with the smallest lexicographical order, which contains all distinct characters of **s** and only contains them once; Based on the above question, create a class **SSU** in Python language with the attribute **s**. Then create another class **SN_SSU**, which inherits from the *...
[ "assert candidate(\"bcabc\")==\"abc\"", "assert candidate(\"cbacdcbc\")==\"acdb\"" ]
def test_run(content1): return SN_SSU(content1).smallest_subsequence()
test_run
assert candidate([['class SSU', 'class SN_SSU(SSU)', 'super().__init__(s)', 'def smallest_subsequence']]) == 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]...
OOP/396
Question: We have a set of **n** items. Two integer arrays, **values** and **labels**, are given, where the value and label of the i-th element are values[i] and labels[i] respectively. Two more integers, **numWanted** and **useLimit**, are also given. We are to select a subset **s** from the **n** elements such that: ...
[ "assert candidate([5,4,3,2,1],[1,1,2,2,3],3,1)==9", "assert candidate([5,4,3,2,1],[1,3,3,3,2],3,2)==12", "assert candidate([9,8,8,7,6],[0,0,0,1,1],3,1)==16" ]
def test_run(content1,content2,content3,content4): return SN_MSR(content1,content2,content3,content4).Maximum_score()
test_run
assert candidate([['class MSR', 'class SN_MSR(MSR)', 'super().__init__(values)', 'def Maximum_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]...
OOP/397
Question: Given an n x n binary matrix **grid**, return the length of the shortest unobstructed path in the matrix. If such a path does not exist, return -1; Based on the above question, please create a **UPT** class in Python with a **grid** attribute; then create a **SN_UPT** class that inherits the **UPT** class, an...
[ "assert candidate([[0,1],[1,0]])==2", "assert candidate([[0,0,0],[1,1,0],[1,1,0]])==4", "assert candidate([[1,0,0],[1,1,0],[1,1,0]])==-1" ]
def test_run(content1): return SN_UPT(content1).Unobstructed_path()
test_run
assert candidate([['class UPT', 'class SN_UPT(UPT)', 'super().__init__(grid)', 'def Unobstructed_path']]) == 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]...
OOP/398
Question: Given two strings **str1** and **str2**, return the shortest string that has both **str1** and **str2** as subsequences; Please create a class **SSI** in Python, which has the attribute **str1**. Then create another class **SN_SSI** that inherits from the **SSI** class, and add the attribute **str2**, as well...
[ "assert candidate(\"abac\",\"cab\")==\"cabac\"", "assert candidate(\"aaaaaaaa\",\"aaaaaaaa\")==\"aaaaaaaa\"" ]
def test_run(content1,content2): return SN_SSI(content1,content2).Shortest_string()
test_run
assert candidate([['class SSI', 'class SN_SSI(SSI)', 'super().__init__(str1)', 'def Shortest_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]...
OOP/399
Question: Initially, there are **capacity** empty seats on the bus. The bus can only travel in one direction (that is, it is not allowed to turn around or change direction). Given the integer **capacity** and an array **trips**, trip[i] = [numPassengers_i, from_i, to_i] indicates that there are **numPassengers_i** pass...
[ "assert candidate([[2,1,5],[3,3,7]],4)==False", "assert candidate([[2,1,5],[3,3,7]],5)==True" ]
def test_run(content1,content2): return SN_PPG(content1,content2).Pick_passengers()
test_run
assert candidate([['class PPG', 'class SN_PPG(PPG)', 'super().__init__(trips)', 'def Pick_passengers']]) == 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]...