Dataset Viewer
Auto-converted to Parquet Duplicate
content
stringlengths
250
2.36k
labels
dict
test
stringlengths
42
359
id
int64
1
140
Write a Python function according to the function name and the problem description in the docstring below. def table_tennis_results(marks: str) -> int: """Adham Sharara was elected as the sixth President of the International Table Tennis Federation(ITTF) in 1999. Under his leadership, the ITTF underwent sever...
{ "difficulty_type": "Distraction" }
assert table_tennis_results("AAAAAAAAAAA") == 1 assert table_tennis_results("BBBAAABABABABAAAAABBBBBB") == 1 assert table_tennis_results("BBBAAABABABABAAAAABABABABAAAABBBABABABBAABBABB") == 0 assert table_tennis_results("BBBAAABABABABAAAAABBBBBBBBBBBB") == -1
1
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def expectation_number(scores: List[int]) -> int: """The annual spring recruitment has begun at an internet company, and a total of n candidates have been selected. Each candidat...
{ "difficulty_type": "Distraction" }
assert expectation_number([1, 2, 3, 4]) == 4 assert expectation_number([1, 1, 2]) == 2
2
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def get_maximum_capital(n: int, c: int, profits: List[int], capital: List[int]) -> int: """As AI products like ChatGPT become popular worldwide, many artificial intelligence companie...
{ "difficulty_type": "Distraction" }
assert get_maximum_capital(3, 0, [1,2,3], [0,1,2]) == 6 assert get_maximum_capital(2, 0, [1,2,3], [0,1,1]) == 4
3
Write a Python function according to the function name and the problem description in the docstring below. def least_goods_number(n: int) -> int: """Given a list of products where the first column represents the product name and the second column represents the product price. You have n dollers, please calcul...
{ "difficulty_type": "Distraction" }
assert least_goods_number(11) == 3 assert least_goods_number(5) == 1
4
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def arrange_ark_pairs(ark_deck: List[int]) -> int: """Legend tells of a great Ark built by Noah to survive an immense flood that would cover the Earth. To preserve the natural wo...
{ "difficulty_type": "Distraction" }
assert arrange_ark_pairs([0,1,3,2]) == 0 assert arrange_ark_pairs([0,3,2,1]) == 1
5
Write a Python function according to the function name and the problem description in the docstring below. def artemis_game(beta: int, theta: int, upperBound: int) -> float: """ Artemis, engages in a strategic computational challenge. Initiating with a tally of zero, Artemis partakes in sequential comput...
{ "difficulty_type": "Distraction" }
assert artemis_game(10, 1, 10) == 1.00000 assert artemis_game(6, 1, 10) == 0.60000
6
Write a Python function according to the function name and the problem description in the docstring below. from typing import List class UnionFind(object): def __init__(self, names): self.parent = {} for name in names: self.parent[name] = name def union(self, a, b): if a ...
{ "difficulty_type": "Distraction" }
assert popular_names(["Aiden(10)","Aidan(5)","Alex(20)","Lex(2)","Alexander(30)"], ["(Aidan,Aiden)","(Aiden,Ayden)","(Alex,Lex)","(Alex,Alexander)"]) == ["Aiden(15)","Alex(52)"] assert popular_names(["John(15)","Jon(12)","Chris(13)","Kris(4)","Christopher(19)"], ["(Jon,John)","(John,Johnny)","(Chris,Kris)","(Chris,Chri...
7
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def bridge_beams(shorter: int, longer: int, k: int) -> List[int]: """ The task at hand is both a practical and mathematical challenge, as constructing a bridge requires thorough ...
{ "difficulty_type": "Distraction" }
assert bridge_beams(1,2,3) == [3, 4, 5, 6]
8
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def pokemon(pokemons: List[List[int]], balls: List[List[int]], r: int)->int: """In the Pokémon world, Professor Oak invites Ash to participate in a Pokémon-catching drill. A vast fie...
{ "difficulty_type": "Distraction" }
assert pokemon([[1,3,2],[4,3,1],[7,1,2]], [[1,0],[3,3]], 4) == 2 assert pokemon([[3,3,1],[3,2,1]], [[4,3]], 2) == 1
9
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def shingen_impact_explore(nums: List[int]) -> int: """In a game called Shingen Impact, an explorer finds a series of ancient barriers in an undeveloped region named Vateyt. Thes...
{ "difficulty_type": "Distraction" }
assert shingen_impact_explore([-300, 500, 0, -400, 0]) == -1 assert shingen_impact_explore([110,130,110,-250,-70,-110,-50,-50,90,150]) == 1
10
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def can_square(bucket_list: List[int]) -> str: """ Given a bucket_list with each entry as the number of squares in the bucket, determin if we can build a square using all the given s...
{ "difficulty_type": "Distraction" }
assert can_square([14, 2]) == "YES" assert can_square([1, 2, 3, 4, 5, 6, 7]) == "NO"
11
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def find_champion(grid: List[List[int]]) -> int: """ In a competition with 'n' teams numbered from 0 to n - 1, you have a 2D boolean matrix 'grid' of size n x n. For all pair...
{ "difficulty_type": "Distraction" }
assert find_champion([[0,1],[0,0]]) == 0 assert find_champion([[0,0,1],[1,0,1],[0,0,0]]) == 1
12
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def get_highest_occurrence_count(number_list: List[int]) -> int: """ I was recently talking with my friend John who works as a data analyst. He was telling me about some of t...
{ "difficulty_type": "Distraction" }
assert get_highest_occurrence_count([2,2,3,3]) == 4 assert get_highest_occurrence_count([4,3,2,1]) == 4
13
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def get_max_diagonal_area(dimensions: List[List[int]]) -> int: """ You were given a 2D array of integers called dimensions representing the lengths and widths of different rectan...
{ "difficulty_type": "Distraction" }
assert get_max_diagonal_area([[1,2],[3,4]]) == 12 assert get_max_diagonal_area([[10,8],[7,6]]) == 80
14
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def find_smallest_missing_integer(nums: List[int]) -> int: """ You are given an integer array nums indexed from 0. A prefix nums[0..i] is called an ordered prefix if for eve...
{ "difficulty_type": "Distraction" }
assert find_smallest_missing_integer([1,2,3,4,5]) == 15 assert find_smallest_missing_integer([6,1]) == 7
15
Write a Python function according to the function name and the problem description in the docstring below. def find_calling_steps(ring: str, key: str) -> int: """Baba is the only country on the planet Padamiya. This country has absolute political power, is rich and powerful. Their forward King Abanov is the best ...
{ "difficulty_type": "Distraction" }
assert find_calling_steps("godding", "gd") == 4 assert find_calling_steps("godding", "godding") == 13
16
Write a Python function according to the function name and the problem description in the docstring below. def get_palindromic_string(string1: str, string2: str) -> str: """If the reverse of a string is the same as the original string, the string is called a palindrome string. You are given two strings, ple...
{ "difficulty_type": "Distraction" }
assert get_palindromic_string("ab", "deba") == "abeba" assert get_palindromic_string("uvw", "v") == "vv" assert get_palindromic_string("abc", "abcd") == ""
17
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def mahjong_practice(tiles:List[int])->int: """The game of mahjong requires four players, 144 tiles and two dice to roll. The goal of mahjong is similar to poker, in that the aim is ...
{ "difficulty_type": "Distraction" }
assert mahjong_practice([2,2,2,3,4]) == 1 assert mahjong_practice([2,2,2,3,4,1,3]) == 2
18
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def find_duplicate(nums: List[int]) -> int: """Floyd's cycle detection algorithm, also known as the "tortoise and hare algorithm," is used to detect whether a linked list contains a...
{ "difficulty_type": "Distraction" }
assert find_duplicate([1,3,4,2,2]) == 2 assert find_duplicate([3,1,3,4,2]) == 3
19
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def majority_vote(nums: List[int]) -> List[int]: """The core idea of Majority voting method is consumption. First, we consider the basic Majority voting problem, such as finding a n...
{ "difficulty_type": "Distraction" }
assert majority_vote([3,2,3]) == [3] assert majority_vote([1]) == [1]
20
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def complete_combustion(numbers: List[int]) -> List[float]: """Input to this function is a list representing the number of elements C, H and O in a compound CxHyOz (z is not equ...
{ "difficulty_type": "Redefinition" }
assert complete_combustion([1,2,1]) == [1, 1, 1] assert complete_combustion([2,6,1]) == [3, 2, 3]
21
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def max_balance_factor(weights: List[int]) -> int: """Write a function to find the maximum balance factor of the given list 'weights'. The maximum balance factor is the sum of a ...
{ "difficulty_type": "Redefinition" }
assert max_balance_factor([4, 2, 3, 9]) == 9 assert max_balance_factor([7, 1, 9]) == 0
22
Write a Python function according to the function name and the problem description in the docstring below. def laser_arrangement(m): """A military restricted area, represented by a square matrix with side length m, requires the installation of laser defense systems. These lasers can be emitted horizontally, ...
{ "difficulty_type": "Redefinition" }
assert laser_arrangement(4) == 2 assert laser_arrangement(2) == 0
23
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def dice_probability(num: int) -> List[float]: """There is a regular tetrahedral dice with numbers 1, 2, 3, 4, and the mass distribution is uniform. If you roll n of these dice, ...
{ "difficulty_type": "Redefinition" }
assert dice_probabitliy(1) == [0.25, 0.25, 0.25, 0.25]
24
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def extract_times(water_map:List[List[str]]) -> int: """Given a water map which is a 2-D array representing underground water("1") and soil("0"), you are using a water pump to ex...
{ "difficulty_type": "Redefinition" }
assert extract_times([["1","0","1","0","0"],["1","0","1","0","0"],["1","0","0","0","0"],["1","0","0","1","0"]]) == 3 assert extract_times([["1","1","0","0"],["1","1","0","0"],["0","1","0","0"],["0","0","0","1"]]) == 2
25
Write a Python function according to the function name and the problem description in the docstring below. def pod_probability(m: int) -> float: """ An interstellar transport vessel is equipped with precisely m individual passenger pods, each uniquely assigned to m traveling spacefarers based on their purchas...
{ "difficulty_type": "Redefinition" }
assert pod_probability(1) == 1.00000 assert pod_probability(2) == 0.50000
26
Write a Python function according to the function name and the problem description in the docstring below. def state_element(n: int) -> int: """ There is a sequence of x elements that are initially in a specific state. You first change the state of all the elements, then you change the state of every second e...
{ "difficulty_type": "Redefinition" }
assert state_element(121) == 11 assert state_element(20) == 4
27
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def arrange_conference(windowsA: List[List[int]], windowsB: List[List[int]], conferenceTime: int) -> List[int]: """ Consider the time windows of availability for two separate par...
{ "difficulty_type": "Redefinition" }
assert arrange_conference(windowsA = [[10,50],[60,120],[140,210]], windowsB = [[0,15],[60,70]], conferenceTime = 8) == [60,68] assert arrange_conference(windowsA = [[10,50],[60,120],[140,210]], windowsB = [[0,15],[60,70]], conferenceTime = 12) == []
28
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def top_records(entry: List[List[int]]) -> List[List[int]]: """ Imagine a dataset containing multiple records of athletes with different identification numbers, where each record...
{ "difficulty_type": "Redefinition" }
assert top_records(entry = [[1,91],[1,92],[2,93],[2,97],[1,60],[2,77],[1,65],[1,87],[1,100],[2,100],[2,76]]) == [[1,87],[2,88]] assert top_records(entry = [[1,100],[7,100],[1,100],[7,100],[1,100],[7,100],[1,100],[7,100],[1,100],[7,100]]) == [[1,100],[7,100]]
29
Write a Python function according to the function name and the problem description in the docstring below. def sum_perfect_integer(lower_bound: int, higher_bound: int, n: int): """You are given positive integers lower_bound, higher_bound, and n. A number is perfect if it meets both of the following condition...
{ "difficulty_type": "Redefinition" }
assert sum_perfect_integer(4, 4, 1) == 0 assert sum_perfect_integer(1, 10, 1) == 1
30
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def maximum_size_after_removal(nums1: List[int], nums2: List[int]): """ You are given two memory quantities nums1 and nums2 whose subscripts start from 0, and their lengths are both ...
{ "difficulty_type": "Redefinition" }
assert maximum_size_after_removal([3,4], [1,2]) == 2 assert maximum_size_after_removal([1,2,1,2], [1,1,1,1]) == 2
31
Write a Python function according to the function name and the problem description in the docstring below. def get_maximum_special_substring(s: str) -> int: """Determine the length of the longest substring in a given string 's', which consists solely of a single lower English character and the entire substring ap...
{ "difficulty_type": "Redefinition" }
assert get_maximum_special_substring("aaaa") == 2 assert get_maximum_special_substring("aeebcccdd") == 1
32
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def find_peak(mountain: List[int]) -> List[int]: """ You need to identify all the peaks in a given array named 'mountain'. A peak is defined as any element that is strictly g...
{ "difficulty_type": "Redefinition" }
assert find_peak([1,2,4]) == [] assert find_peak([9,2,4,7,3]) == [3]
33
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def similar_matrix(mat: List[List[int]], k: int) -> bool: """ You have a matrix 'mat' sized m x n, starting with index 0. Shift odd-numbered rows right and even-numbered rows...
{ "difficulty_type": "Redefinition" }
assert similar_matrix([[2,2]], 3) == True assert similar_matrix([[3,1,4,1],[1,4,3,1],[2,4,1,2]], 2) == False
34
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def find_k_or(nums: List[int], k: int) -> int: """ You have an array of integers named 'nums' and an integer 'k'. The 'K-or' of nums is a non-negative integer defined by the ...
{ "difficulty_type": "Redefinition" }
assert find_k_or([8,11,9,7],1) == 15 assert find_k_or([2,12,1,11,4,5],6) == 0
35
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def max_profit(prices: List[int]) -> int: """ Given an array, its i-th element represents the price per ton of water on the i-th day. You can store water in a reservoir, and your...
{ "difficulty_type": "Redefinition" }
assert max_profit([3,3,5,0,0,3,1,4]) == 30 assert max_profit([1,2,3,4,5]) == 20 assert max_profit([7,6,4,3,1]) == 0
36
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def winning_probability(numbers: List[int]) -> float: """In a raffle, lucky number is defined as containing only the factors 3, 5, 7, e.g. 15, 21. The system will generates a random ...
{ "difficulty_type": "Redefinition" }
assert winning_probability([1, 4, 12, 21, 33]) == 0.333 assert winning_probability([35, 22, 11]) == 0 assert winning_probability([2, 50, 24, 49]) == 0.25
37
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def symmetry_number(n: int) -> List[int]: """If a number is equal to its inverse order, it is called a symmetric number, e.g., '121'. Noting that all single digits are symmetric numb...
{ "difficulty_type": "Redefinition" }
assert symmetry_number(10) == [9, 5, 6] assert symmetry_number(50) == [13, 6, 8]
38
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def brew_capability(brew_counts: List[int]) -> int: """ You are given an integer array `brew_counts`, where `brew_counts[i]` represents the number of brews needed for different ...
{ "difficulty_type": "Redefinition" }
assert brew_capability([3, 0, 6, 1, 5]) == 3 assert brew_capability([1, 3, 1]) == 1
39
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def triangular_pair_of_a_to_b(a:int,b:int)->int: """A triangular number is a term in a sequence formed by the sum of natural numbers, with the nth triangular number represented as T...
{ "difficulty_type": "Redefinition" }
assert triangular_pair_of_a_to_b(3,4) == 2 assert triangular_pair_of_a_to_b(3,5) == 0
40
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def next_fibonacci(numbers: List[int]) -> List[int]: """Given a sequence, where each number is greater than 10000 and belongs to the Fibonacci sequence, this function quickly cal...
{ "difficulty_type": "Shortcut" }
assert next_fibonacci([196418, 121393, 10946]) == [317811, 196418, 17711]
41
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def largest_multiple_of_three(digits: List[int]) -> str: """Given an array, concatenate any number of digits in any order to form the largest number that is divisible by 3, and r...
{ "difficulty_type": "Shortcut" }
assert largest_multiple_of_three([1]) == "" assert largest_multiple_of_three([1, 9, 9, 7]) == "99"
42
Write a Python function according to the function name and the problem description in the docstring below. def largest_number(n: int, x: int) -> int: """When Jason was typing on the keyboard, he noticed that the editor malfunctioned. Despite having already entered an integer, he wants to rearrange the digits ...
{ "difficulty_type": "Shortcut" }
assert largest_number(28981, 1) == 98128 assert largest_number(18929, 2) == 99821
43
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def num_even_product(nums: List[int]) -> int: """Given an integer array nums, return the number of subarrays of this array with an even product. A subarray is a contiguous non-em...
{ "difficulty_type": "Shortcut" }
assert num_even_product([1,2,3,4]) == 8 assert num_even_product([3,9,11]) == 0
44
Write a Python function according to the function name and the problem description in the docstring below. def counting_game(n: int) -> int: """In a playful counting game, children start counting from 1 but they skip any number that contains the digit 9, considering it to be unlucky. This results in a sequenc...
{ "difficulty_type": "Shortcut" }
assert counting_game(4) == 4 assert counting_game(10) == 11
45
Write a Python function according to the function name and the problem description in the docstring below. def longest_string(a: int, b: int, c: int) -> int: """ You are given three integers a, b, and c. You have a strings equal to "OO", b strings equal to "PP", and c strings equal to "OP". You want to c...
{ "difficulty_type": "Shortcut" }
assert longestString(2,5,1) == 12 assert longestString(3,2,2) == 14
46
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def nums_erase(nums: List[int]) -> bool: """ You are provided with a sequence of whole numbers delineated as 'nums', inscribed upon an erasable surface intended for mathematical ...
{ "difficulty_type": "Shortcut" }
assert nums_erase([1,1,2]) == False assert nums_erase([0,1]) == True
47
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def is_vshape(points: List[List[int]]) -> bool: """ Suppose you have a list `vertices`, with each element vertices[i] = [ai, bi] signifying the coordinates of a vertex in a 2D sp...
{ "difficulty_type": "Shortcut" }
assert is_vshape([[1,1], [2,3], [3,2]]) == True assert is_vshape([[1,1], [2,2], [3,3]]) == False
48
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def max_count(banned: List[int], n: int, maxSum: int) -> int: """ Given an array of integers `banned`, and two additional integers `n` and `maxSum`, determine the maximum number ...
{ "difficulty_type": "Shortcut" }
assert max_count([1,4,6], 6, 4) == 1 assert max_count([4,3,5,6], 7, 18) == 3
49
Write a Python function according to the function name and the problem description in the docstring below. def ab_string(x: int, y: int, z: int) -> int: """In the beading activity, there are x number of 'AA', y number of 'BB', and z number of 'AB' letter style beads. Beads are indivisible, and we do not want 'AAA...
{ "difficulty_type": "Shortcut" }
assert ab_string(2,5,1) == 12 assert ab_string(3,2,2) == 14
50
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def check_tail_zeros(nums: List[int]) -> bool: """Given an array of positive integers, determine if you can choose two or more elements from the array so that the bitwise OR of these...
{ "difficulty_type": "Shortcut" }
assert check_tail_zeros([1,2,10,12,20]) == True assert check_tail_zeros([2,4,8,16]) == True
51
Write a Python function according to the function name and the problem description in the docstring below. def divide_white_black(s: str) -> int: """ There are n balls on a table, each either black or white. You have a binary string s of length n, starting from index 0, where '1' represents a black ball ...
{ "difficulty_type": "Shortcut" }
assert divide_white_black("001") == 0 assert divide_white_black("1100") == 4
52
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def minimum_sum(nums1: List[int], nums2: List[int]) -> int: """ Given two arrays, 'nums1' and 'nums2', consisting of positive integers and zeros, replace all zeros in both ar...
{ "difficulty_type": "Shortcut" }
assert minimum_sum([1,4],[2,3]) == 5 assert minimum_sum([2,4,6,8],[1,2]) == -1
53
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def is_maximum_sum_array(arr:List[int])->int: """Given an array of real numbers a[1] to a[n], you are allowed to perform any number of operations. In each operation, you select an in...
{ "difficulty_type": "Shortcut" }
assert is_maximum_sum_array([1,3,2]) == 0 assert is_maximum_sum_array([1,2,3]) == 1
54
Write a Python function according to the function name and the problem description in the docstring below. def minimum_birds(num_containers: int) -> int: """ You have n sealed containers, each containing a different type of food. One of these foods is toxic, while the others are safe. You have some birds that...
{ "difficulty_type": "Shortcut" }
assert minimum_birds(8) == 3 assert minimum_birds(16) == 4 assert minimum_birds(1024) == 10
55
Write a Python function according to the function name and the problem description in the docstring below. def sit_on_seat(n: int) -> float: """ "Waiting for Spring" is a popular movie released in early 2024, and it is hard to get a ticket. Therefore, it is no surprise that all the seats for this film in Hall 1 o...
{ "difficulty_type": "Shortcut" }
assert sit_on_seat(1) == 1 assert sit_on_seat(2) == 0.5
56
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def minimal_avg_distance(nums: List[int]) -> int: """The minimum distance of an array is defined as the minimum absolute value of the difference between any two elements, the maximum...
{ "difficulty_type": "Shortcut" }
assert minimal_avg_distance([1,4,3]) == 0 assert minimal_avg_distance([1,4,7,8,5]) == 3
57
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def fall_time(center:List[int],radius:int,position:List[List[int]])->int: """ There is a round table with a delicious cake placed at its center. Several ants are positioned around th...
{ "difficulty_type": "Shortcut" }
assert fall_time([0,0],5,[[1,0]]) == 6 assert fall_time([0,0],5,[[1,0],[2,0],[2,2]]) == 8
58
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def danger_corner(points:List[List[int]])->int: """Given n points on a 2D x-y plane, where the coordinates of each point are integers, these points form a polygon with each side eith...
{ "difficulty_type": "Shortcut" }
assert danger_corner([[0,0],[0,1],[1,1],[1,2],[2,2],[2,0]]) == 1 assert danger_corner([[0,0],[0,1],[1,1],[1,0]]) == 0
59
Write a Python function according to the function name and the problem description in the docstring below. def reach_number(target: int) -> int: """A car starts from position 0 and drives on an infinite road. The car can move numMoves times, and each move can choose to move left or right. It is required that only...
{ "difficulty_type": "Shortcut" }
assert reach_number(2) == 3 assert reach_number(3) == 2
60
Write a Python function according to the function name and the problem description in the docstring below. def morning_commute(a: int, b: int, c: int, d: int): """There are two companies located at both ends of a straight road, with two towns in the middle. Every morning, 'a' people from the left town commute...
{ "difficulty_type": "Commonsense" }
assert morning_commute(7,3,4,6) == 12 assert morning_commute(17,31,13,40) == 403
61
Write a Python function according to the function name and the problem description in the docstring below. def calculate_time(time1: str, time2: str) -> int: """Given two strings formatted as "hh:mm:ss" representing two time in one day, calculate the difference in seconds between the two time. If the values a...
{ "difficulty_type": "Commonsense" }
assert calculate_time("00:01:10", "05:06:58") == 18348 assert calculate_time("08:10:00", "08:09:18") == 42
62
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def max_water_container(height: List[int]) -> int: """Given an integer array 'height' of length 'n'. There are 'n' vertical lines where the ith line has its two endpoints at (i, ...
{ "difficulty_type": "Commonsense" }
assert max_water_container([1,1]) == 1 assert max_water_container([1,2,3,4]) == 4
63
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def from_starting_station(money: List[int], toll: List[int]) -> int: """There is a circular road with 'n' stations, each station has either a good person or a bad person. A good ...
{ "difficulty_type": "Commonsense" }
assert from_starting_station([2,3,4], [3,4,3]) == -1 assert from_starting_station([1,2,3,4,5], [3,4,5,1,2]) == 3
64
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def number_of_covered_point(tracks: List[List[int]]) -> int: """Given a 2D integer array 'tracks' representing intervals of trains parking on a railway track. For any index i, tr...
{ "difficulty_type": "Commonsense" }
assert number_of_covered_point([[1,4],[6,8]]) == 7 assert number_of_covered_point([[3,6],[4,7],[6,8]]) == 6
65
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def sort_binary(arr: List[int]) -> List[int]: """ Arrange an array of integers in ascending order based on the count of 1's in their binary form. For integers with an identical c...
{ "difficulty_type": "Commonsense" }
assert sort_binary([0,1,2,3,4,5,6,7,8]) == [0,1,2,4,8,3,5,6,7] assert sort_binary([1024,512,256,128,64,32,16,8,4,2,1]) == [1,2,4,8,16,32,64,128,256,512,1024]
66
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def convex_polygon(points: List[List[int]]) -> bool: """ Imagine that you have been supplied with an array of coordinate pairs, where each pair represents a point on the Cartesia...
{ "difficulty_type": "Commonsense" }
assert convex_polygon([[0,0],[0,5],[5,5],[5,0]]) == True assert convex_polygon([[0,0],[0,10],[10,10],[10,0],[5,5]]) == False
67
Write a Python function according to the function name and the problem description in the docstring below. def knight_dialer(n: int) -> int: """Given a knight and a two-dimensional matrix chessboard [['1','2','3'],['4','5','6'],['7','8',' 9'],['*','0','#']]. Initially, the knight can be in any position on the che...
{ "difficulty_type": "Commonsense" }
assert knight_dialer(1) == 10 assert knight_dialer(2) == 20
68
Write a Python function according to the function name and the problem description in the docstring below. import heapq from typing import List def trap_water(heightMap: List[List[int]]) -> int: """When designing a landmark building composed of multiple cuboids with a base area of ​​1*1, the designer wants to c...
{ "difficulty_type": "Commonsense" }
assert trapRainWater([[1,4,3,1,3,2],[3,2,1,3,2,4],[2,3,3,2,3,1]]) == 4 assert trapRainWater([[3,3,3,3,3],[3,2,2,2,3],[3,2,1,2,3],[3,2,2,2,3],[3,3,3,3,3]]) == 10
69
Write a Python function according to the function name and the problem description in the docstring below. def optical_experiment(m: int, n: int) -> int: """In the school's optical laboratory, there is a square device with mirrors on all four sides. Except for the northwest corner of the device, there is a li...
{ "difficulty_type": "Commonsense" }
assert optical_experiment(1, 1) == 1 assert optical_experiment(3, 2) == 0
70
Write a Python function according to the function name and the problem description in the docstring below. def word_pronunciation(num: int) -> str: """At a ceremony, the host will read out the number of guests present today. The number of guests num is now given. Please complete the code and output the correct pr...
{ "difficulty_type": "Commonsense" }
assert word_pronunciation(123) == "One Hundred Twenty Three" assert word_pronunciation(12345) == "Twelve Thousand Three Hundred Forty Five"
71
Write a Python function according to the function name and the problem description in the docstring below. def remove_similar_equal_characters(word: str) -> int: """ In a single operation, you can change any character in a word to any other lowercase English letter. Your task is to determine the minimum n...
{ "difficulty_type": "Commonsense" }
assert remove_similar_equal_characters("bozhijiang") == 2 assert remove_similar_equal_characters("abddez") == 2
72
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def widest_vertical_region_width(points: List[List[int]]) -> int: """ You are given n points on a 2D plane, where points[i] = [xi, yi] represents the x and y coordinates of the i...
{ "difficulty_type": "Commonsense" }
assert widest_vertical_region_width([[1,2],[3,4]]) == 2 assert widest_vertical_region_width([[1,0],[1,4],[5,3]]) == 4
73
Write a Python function according to the function name and the problem description in the docstring below. def chess_square_color(coordinates: str) -> bool: """ You are given a coordinate string 'coordinates' representing the position of a square on a chessboard. If the color of the given square is white...
{ "difficulty_type": "Commonsense" }
assert chess_square_color("h3") == True assert chess_square_color("b2") == False
74
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def celsius_to_kelvin_fahrenheit(celsius: float) -> List[float]: """ You are given a non-negative floating point number celsius representing a temperature rounded to two decimal ...
{ "difficulty_type": "Commonsense" }
assert celsius_to_kelvin_fahrenheit(37.50) == [310.65000,99.50000] assert celsius_to_kelvin_fahrenheit(122) == [395.15000,251.60000]
75
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def can_pooling(trips: List[List[int]]) -> bool: """In order to promote the development of tourism, City A organized a "Chasing the Sunset" event. The event encourages local residen...
{ "difficulty_type": "Commonsense" }
assert can_pooling([[2,1,5],[3,3,7]]) == False assert can_pooling([[2,1,5],[3,8,9]]) == True
76
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def store_water(rains: List[int]) -> List[int]: """In a region where water is extremely lacking, so that rainwater is one of their important sources of water. Whenever it rains, peop...
{ "difficulty_type": "Commonsense" }
assert store_water([1,2]) == [-1,-1] assert store_water([1,0,2,0,1,2]) == [-1,1,-1,2,-1,-1] assert store_water([1,2,0,1,1]) == []
77
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def longest_wiggle_seq(price: List[int]) -> int: """In the stock market, stock prices always fluctuate frequently, going up and down. For those who speculate in stocks, every time wh...
{ "difficulty_type": "Commonsense" }
assert longest_wiggle_seq([1,6,3,4,2]) == 5 assert longest_wiggle_seq([1,4,5,3]) == 3
78
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def rank_task(tasks: List[List[int]]) ->List[int]: """Given a list of tasks named tasks, which contains n individual tasks, and the index of the list starting from 0 to n-1 denote th...
{ "difficulty_type": "Commonsense" }
assert rank_task([[1,3],[3,5],[3,2]] == [0,2,1] assert rank_task([[2,10],[2,6],[3,5],[3,3],[3,1]]) == [1,4,3,2,0]
79
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def is_square(p1: List[int], p2: List[int], p3: List[int], p4: List[int]) -> bool: """Given the coordinates of four points in the plane, please determine whether the four points can...
{ "difficulty_type": "Commonsense" }
assert is_square([0,0], [1,1], [1,0], [0,1]) == True assert is_square([0,0], [1,1], [1,0], [0,12]) == False
80
Write a Python function according to the function name and the problem description in the docstring below. def is_isosceles_triangle(x1, y1, x2, y2, x3, y3): """Given the coordinates of three points in a two-dimensional plane, tell whether the figure formed by connecting these three points is an isosceles tri...
{ "difficulty_type": "Cornercase" }
assert is_isosceles_triangle(0, 0, 1, 0, 1, 1) == True assert is_isosceles_triangle(0, 0, 2, 0, 2, 1) == False
81
Write a Python function according to the function name and the problem description in the docstring below. def decorate_ways(n: int, m: int) -> int: """For Christmas, various colored balls are to be tied to a string for decoration. There are a total of n different colors of balls and a string that has m posit...
{ "difficulty_type": "Cornercase" }
assert decorate_ways(3, 2) == 6 assert decorate_ways(7, 3) == 1344
82
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def four_dimensional_hyperplane(nums: List[int], target: int) -> List[List[int]]: """In a high-dimensional space, given an array nums containing n integers, the goal is to find all ...
{ "difficulty_type": "Cornercase" }
assert four_dimensional_hyperplane([1,1,1], 6) == [] assert four_dimensional_hyperplane([1,2,3,4,5], 14) == [[2,3,4,5]]
83
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def min_moves_to_equal_array(nums: List[int]): """Given an integer array `nums`, you can select any number of elements in each move, and for each selected element, decrease its v...
{ "difficulty_type": "Cornercase" }
assert min_moves_to_equal_array([0, 1]) == -1 assert min_moves_to_equal_array([3,1,5]) == 2
84
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def pixelquad_number(matrix: List[List[int]]) -> int: """Given an m x n integer matrix grid consisting only of 0s and 1s, return the number of "PixelQuads" it contains. A "PixelQ...
{ "difficulty_type": "Cornercase" }
assert pixelquad_number([[1,1,1,1,1,1]]) == 0 assert pixelquad_number([[1,1,1],[1,1,1]]) == 3
85
Write a Python function according to the function name and the problem description in the docstring below. def num_cuts(n: int) -> int: """ What is the minimum number of cuts needed to divide a circle into n equal slices, given the integer n, assuming the following valid cuts: 1. A cut defined by a straig...
{ "difficulty_type": "Cornercase" }
assert num_cuts(4) == 2 assert num_cuts(3) == 3
86
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def card_game(cards: List[int]) -> bool: """ In a newly invented card game by Claire and David, there lies a sequence of n cards, each inscribed with a numerical figure represent...
{ "difficulty_type": "Cornercase" }
assert card_game([2,1]) == True assert card_game([2]) == False
87
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def two_probes(probeA: List[int], probeB: List[int]) -> str: """ A field study is in progress, with data being gathered in real-time. To validate the reliability of the observati...
{ "difficulty_type": "Cornercase" }
assert two_probes([2,3,4,5], [2,1,3,4]) == "A" assert two_probes([2,2,2,2,2], [2,2,2,2,5]) == -1
88
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def catalog_search(titles: List[str], query: str) -> int: """ Library Catalog Search. Imagine an alphabetically ordered catalogue of book titles where several entries may be blan...
{ "difficulty_type": "Cornercase" }
assert catalog_search(["alpha", "", "", "", "gamma", "", "", "kappa", "", "", "sigma", "", ""], "beta") == -1 assert catalog_search(["alpha", "", "", "", "gamma", "", "", "kappa", "", "", "sigma", "", ""], "gamma") == 4
89
Write a Python function according to the function name and the problem description in the docstring below. def correct_slogan(s: str, p: str) -> bool: """In an activity to collect slogans, a slogan s and its requirement p are given. Please determine whether the slogan s satisfies the rules of p? p contains only l...
{ "difficulty_type": "Cornercase" }
assert correct_slogan("ab", ".*") == True assert correct_slogan("aa", "a*") == True
90
Write a Python function according to the function name and the problem description in the docstring below. def get_min_flip_cost_to_match(s1: str, s2: str, x: int) -> int: """ You are given two binary strings s1 and s2 of length n, and a positive integer x. You can perform the following operations on s1 ...
{ "difficulty_type": "Cornercase" }
assert get_min_flip_cost_to_match("1100","0011",3) == 2 assert get_min_flip_cost_to_match("100","001",2) == 2
91
Write a Python function according to the function name and the problem description in the docstring below. def space_centered_text(text: str) -> str: """ Given a string text consisting of words and spaces, we first split the string into words based on spaces and count the number of spaces. If there is on...
{ "difficulty_type": "Cornercase" }
assert space_centered_text(" bo is the god ") == "bo is the god " assert space_centered_text("we like the bo ") == "we like the bo "
92
Write a Python function according to the function name and the problem description in the docstring below. def power(x: float, n: int) -> float: """ Implement the function pow(x, n), which calculates x raised to the power of n (i.e. xn)."""
{ "difficulty_type": "Cornercase" }
assert power(2.00000,0) == 1.00000 assert power(1.00000,1) == 1.00000
93
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def min_divisor_below_threshold(nums: List[int], threshold: int) -> int: """ You are given an integer array nums and a positive integer threshold. You need to pick a positiv...
{ "difficulty_type": "Cornercase" }
assert min_divisor_below_threshold([1,8],4) == 3 assert min_divisor_below_threshold([1,2,5,9],6) == 5
94
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def allocate_to_minimize_max(n: int, quantities: List[int]) -> int: """ You are given an integer n representing the number of retail stores. There are m different products in tot...
{ "difficulty_type": "Cornercase" }
assert allocate_to_minimize_max(3,[1,4]) == 2 assert allocate_to_minimize_max(4,[1.10]) == 4
95
Write a Python function according to the function name and the problem description in the docstring below. from typing import List import collections def land_shape(grid: List[List[int]]) -> int: """There is an open space in Alice's backyard. She divided the open space into m*n parts, and each part can choose t...
{ "difficulty_type": "Cornercase" }
assert land_shape([[1,1,1]]) == 1 assert land_shape([[1,1,0,0,0],[1,1,0,0,0],[0,0,1,0,0],[0,0,0,1,1]]) == 3
96
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def same_network(ip_list: List[List[str]]) -> int: """Given two ip addresses and corresponding subnet masks, determine whether the two ip belong to the same network segment. The same...
{ "difficulty_type": "Cornercase" }
assert same_network([["192.168.1.1", "255.255.255.0"], ["192.168.1.2", "255.255.255.0"]]) == True assert same_network([["xs.0.0.0", "255.255.0.0"], ["1.a.0.0", "255.255.0.0"]]) == False
97
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def calculate_maximum_profit(roads:List[int])->int: """A beautiful island is under development and now needs a ring road to be built. The ring road is divided into n parts, and sever...
{ "difficulty_type": "Cornercase" }
assert calculate_maximum_profit([2,3,2] == 3 assert calculate_maximum_profit([0]) == 0
98
Write a Python function according to the function name and the problem description in the docstring below. from typing import List def is_cube(points: List[List[int]])->int: """Given 8 points in 3D space, determine whether a cube can be formed."""
{ "difficulty_type": "Cornercase" }
assert is_cube([[0,0,0],[1,0,0],[0,1,0],[1,1,0],[0,0,1],[0,1,1],[1,0,1],[1,1,1]]) == 1 assert is_cube([[0,0,0],[1,0,0],[0,1,0],[1,1,0],[0,0,1],[0,1,1],[1,0,1],[1,3,1]]) == 0
99
Write a Python function according to the function name and the problem description in the docstring below. def population_growth(n: int) -> bool: """Assume that population growth strictly follows the formula x_k = x_0(1+r)^k. Among them, the population growth rate is r, this year's population is x_0, and the popu...
{ "difficulty_type": "Cornercase" }
assert population_growth(1) == True assert population_growth(3) == False
100
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
82