question_title
stringlengths 7
8
| question_content
stringlengths 37
191
| question_id
stringlengths 2
3
| contest_id
stringclasses 1
value | test_id
int64 0
5
| contest_date
timestamp[us] | starter_code
stringlengths 37
1.33k
| function_name
stringlengths 3
32
| difficulty
stringclasses 1
value | test
stringlengths 57
1.94k
|
---|---|---|---|---|---|---|---|---|---|
Mbpp_357 | Write a function to find the maximum element of all the given tuple records. | 357 | mbpp | 0 | 2024-11-26T21:40:54.371802 | def find_max(test_list):
res = max(int(j) for i in test_list for j in i)
return (res) | find_max | easy | [{"input": "[(2, 4), (6, 7), (5, 1), (6, 10), (8, 7)]", "output": "10", "testtype": "functional"}] |
Mbpp_357 | Write a function to find the maximum element of all the given tuple records. | 357 | mbpp | 1 | 2024-11-26T21:40:54.371965 | def find_max(test_list):
res = max(int(j) for i in test_list for j in i)
return (res) | find_max | easy | [{"input": "[(3, 5), (7, 8), (6, 2), (7, 11), (9, 8)]", "output": "11", "testtype": "functional"}] |
Mbpp_357 | Write a function to find the maximum element of all the given tuple records. | 357 | mbpp | 2 | 2024-11-26T21:40:54.372119 | def find_max(test_list):
res = max(int(j) for i in test_list for j in i)
return (res) | find_max | easy | [{"input": "[(4, 6), (8, 9), (7, 3), (8, 12), (10, 9)]", "output": "12", "testtype": "functional"}] |
Mbpp_358 | Write a function to find modulo division of two lists using map and lambda function. | 358 | mbpp | 0 | 2024-11-26T21:40:54.372305 | def moddiv_list(nums1,nums2):
result = map(lambda x, y: x % y, nums1, nums2)
return list(result) | moddiv_list | easy | [{"input": "[4,5,6],[1, 2, 3]", "output": "[0, 1, 0]", "testtype": "functional"}] |
Mbpp_358 | Write a function to find modulo division of two lists using map and lambda function. | 358 | mbpp | 1 | 2024-11-26T21:40:54.372488 | def moddiv_list(nums1,nums2):
result = map(lambda x, y: x % y, nums1, nums2)
return list(result) | moddiv_list | easy | [{"input": "[3,2],[1,4]", "output": "[0, 2]", "testtype": "functional"}] |
Mbpp_358 | Write a function to find modulo division of two lists using map and lambda function. | 358 | mbpp | 2 | 2024-11-26T21:40:54.372688 | def moddiv_list(nums1,nums2):
result = map(lambda x, y: x % y, nums1, nums2)
return list(result) | moddiv_list | easy | [{"input": "[90,120],[50,70]", "output": "[40, 50]", "testtype": "functional"}] |
Mbpp_359 | Write a python function to check whether one root of the quadratic equation is twice of the other or not. | 359 | mbpp | 0 | 2024-11-26T21:40:54.373051 | def Check_Solution(a,b,c):
if (2*b*b == 9*a*c):
return ("Yes");
else:
return ("No"); | Check_Solution | easy | [{"input": "1,3,2", "output": "\"Yes\"", "testtype": "functional"}] |
Mbpp_359 | Write a python function to check whether one root of the quadratic equation is twice of the other or not. | 359 | mbpp | 1 | 2024-11-26T21:40:54.373288 | def Check_Solution(a,b,c):
if (2*b*b == 9*a*c):
return ("Yes");
else:
return ("No"); | Check_Solution | easy | [{"input": "1,2,3", "output": "\"No\"", "testtype": "functional"}] |
Mbpp_359 | Write a python function to check whether one root of the quadratic equation is twice of the other or not. | 359 | mbpp | 2 | 2024-11-26T21:40:54.373483 | def Check_Solution(a,b,c):
if (2*b*b == 9*a*c):
return ("Yes");
else:
return ("No"); | Check_Solution | easy | [{"input": "1,-5,6", "output": "\"No\"", "testtype": "functional"}] |
Mbpp_360 | Write a function to find the n’th carol number. | 360 | mbpp | 0 | 2024-11-26T21:40:54.373628 | def get_carol(n):
result = (2**n) - 1
return result * result - 2 | get_carol | easy | [{"input": "2", "output": "7", "testtype": "functional"}] |
Mbpp_360 | Write a function to find the n’th carol number. | 360 | mbpp | 1 | 2024-11-26T21:40:54.373780 | def get_carol(n):
result = (2**n) - 1
return result * result - 2 | get_carol | easy | [{"input": "4", "output": "223", "testtype": "functional"}] |
Mbpp_360 | Write a function to find the n’th carol number. | 360 | mbpp | 2 | 2024-11-26T21:40:54.373908 | def get_carol(n):
result = (2**n) - 1
return result * result - 2 | get_carol | easy | [{"input": "5", "output": "959", "testtype": "functional"}] |
Mbpp_361 | Write a function to remove empty lists from a given list of lists. | 361 | mbpp | 0 | 2024-11-26T21:40:54.374036 | def remove_empty(list1):
remove_empty = [x for x in list1 if x]
return remove_empty | remove_empty | easy | [{"input": "[[], [], [], 'Red', 'Green', [1,2], 'Blue', [], []]", "output": "['Red', 'Green', [1, 2], 'Blue']", "testtype": "functional"}] |
Mbpp_361 | Write a function to remove empty lists from a given list of lists. | 361 | mbpp | 1 | 2024-11-26T21:40:54.374149 | def remove_empty(list1):
remove_empty = [x for x in list1 if x]
return remove_empty | remove_empty | easy | [{"input": "[[], [], [],[],[], 'Green', [1,2], 'Blue', [], []]", "output": "[ 'Green', [1, 2], 'Blue']", "testtype": "functional"}] |
Mbpp_361 | Write a function to remove empty lists from a given list of lists. | 361 | mbpp | 2 | 2024-11-26T21:40:54.374263 | def remove_empty(list1):
remove_empty = [x for x in list1 if x]
return remove_empty | remove_empty | easy | [{"input": "[[], [], [], 'Python',[],[], 'programming', 'language',[],[],[], [], []]", "output": "['Python', 'programming', 'language']", "testtype": "functional"}] |
Mbpp_362 | Write a python function to find the item with maximum occurrences in a given list. | 362 | mbpp | 0 | 2024-11-26T21:40:54.374538 | def max_occurrences(nums):
max_val = 0
result = nums[0]
for i in nums:
occu = nums.count(i)
if occu > max_val:
max_val = occu
result = i
return result | max_occurrences | easy | [{"input": "[1,2,3,1,2,3,12,4,2]", "output": "2", "testtype": "functional"}] |
Mbpp_362 | Write a python function to find the item with maximum occurrences in a given list. | 362 | mbpp | 1 | 2024-11-26T21:40:54.374796 | def max_occurrences(nums):
max_val = 0
result = nums[0]
for i in nums:
occu = nums.count(i)
if occu > max_val:
max_val = occu
result = i
return result | max_occurrences | easy | [{"input": "[1,2,6,7,0,1,0,1,0]", "output": "1,0", "testtype": "functional"}] |
Mbpp_362 | Write a python function to find the item with maximum occurrences in a given list. | 362 | mbpp | 2 | 2024-11-26T21:40:54.375033 | def max_occurrences(nums):
max_val = 0
result = nums[0]
for i in nums:
occu = nums.count(i)
if occu > max_val:
max_val = occu
result = i
return result | max_occurrences | easy | [{"input": "[1,2,3,1,2,4,1]", "output": "1", "testtype": "functional"}] |
Mbpp_363 | Write a function to add the k elements to each element in the tuple. | 363 | mbpp | 0 | 2024-11-26T21:40:54.375216 | def add_K_element(test_list, K):
res = [tuple(j + K for j in sub ) for sub in test_list]
return (res) | add_K_element | easy | [{"input": "[(1, 3, 4), (2, 4, 6), (3, 8, 1)], 4", "output": "[(5, 7, 8), (6, 8, 10), (7, 12, 5)]", "testtype": "functional"}] |
Mbpp_363 | Write a function to add the k elements to each element in the tuple. | 363 | mbpp | 1 | 2024-11-26T21:40:54.375400 | def add_K_element(test_list, K):
res = [tuple(j + K for j in sub ) for sub in test_list]
return (res) | add_K_element | easy | [{"input": "[(1, 2, 3), (4, 5, 6), (7, 8, 9)], 8", "output": "[(9, 10, 11), (12, 13, 14), (15, 16, 17)]", "testtype": "functional"}] |
Mbpp_363 | Write a function to add the k elements to each element in the tuple. | 363 | mbpp | 2 | 2024-11-26T21:40:54.375581 | def add_K_element(test_list, K):
res = [tuple(j + K for j in sub ) for sub in test_list]
return (res) | add_K_element | easy | [{"input": "[(11, 12, 13), (14, 15, 16), (17, 18, 19)], 9", "output": "[(20, 21, 22), (23, 24, 25), (26, 27, 28)]", "testtype": "functional"}] |
Mbpp_365 | Write a python function to count the number of digits of a given number. | 365 | mbpp | 0 | 2024-11-26T21:40:54.376378 | def count_Digit(n):
count = 0
while n != 0:
n //= 10
count += 1
return count | count_Digit | easy | [{"input": "12345", "output": "5", "testtype": "functional"}] |
Mbpp_365 | Write a python function to count the number of digits of a given number. | 365 | mbpp | 1 | 2024-11-26T21:40:54.376537 | def count_Digit(n):
count = 0
while n != 0:
n //= 10
count += 1
return count | count_Digit | easy | [{"input": "11223305", "output": "8", "testtype": "functional"}] |
Mbpp_365 | Write a python function to count the number of digits of a given number. | 365 | mbpp | 2 | 2024-11-26T21:40:54.376705 | def count_Digit(n):
count = 0
while n != 0:
n //= 10
count += 1
return count | count_Digit | easy | [{"input": "4123459", "output": "7", "testtype": "functional"}] |
Mbpp_366 | Write a python function to find the largest product of the pair of adjacent elements from a given list of integers. | 366 | mbpp | 0 | 2024-11-26T21:40:54.376879 | def adjacent_num_product(list_nums):
return max(a*b for a, b in zip(list_nums, list_nums[1:])) | adjacent_num_product | easy | [{"input": "[1,2,3,4,5,6]", "output": "30", "testtype": "functional"}] |
Mbpp_366 | Write a python function to find the largest product of the pair of adjacent elements from a given list of integers. | 366 | mbpp | 1 | 2024-11-26T21:40:54.377041 | def adjacent_num_product(list_nums):
return max(a*b for a, b in zip(list_nums, list_nums[1:])) | adjacent_num_product | easy | [{"input": "[1,2,3,4,5]", "output": "20", "testtype": "functional"}] |
Mbpp_366 | Write a python function to find the largest product of the pair of adjacent elements from a given list of integers. | 366 | mbpp | 2 | 2024-11-26T21:40:54.377190 | def adjacent_num_product(list_nums):
return max(a*b for a, b in zip(list_nums, list_nums[1:])) | adjacent_num_product | easy | [{"input": "[2,3]", "output": "6", "testtype": "functional"}] |
Mbpp_368 | Write a function to repeat the given tuple n times. | 368 | mbpp | 0 | 2024-11-26T21:40:54.378160 | def repeat_tuples(test_tup, N):
res = ((test_tup, ) * N)
return (res) | repeat_tuples | easy | [{"input": "(1, 3), 4", "output": "((1, 3), (1, 3), (1, 3), (1, 3))", "testtype": "functional"}] |
Mbpp_368 | Write a function to repeat the given tuple n times. | 368 | mbpp | 1 | 2024-11-26T21:40:54.378282 | def repeat_tuples(test_tup, N):
res = ((test_tup, ) * N)
return (res) | repeat_tuples | easy | [{"input": "(1, 2), 3", "output": "((1, 2), (1, 2), (1, 2))", "testtype": "functional"}] |
Mbpp_368 | Write a function to repeat the given tuple n times. | 368 | mbpp | 2 | 2024-11-26T21:40:54.378413 | def repeat_tuples(test_tup, N):
res = ((test_tup, ) * N)
return (res) | repeat_tuples | easy | [{"input": "(3, 4), 5", "output": "((3, 4), (3, 4), (3, 4), (3, 4), (3, 4))", "testtype": "functional"}] |
Mbpp_369 | Write a function to find the lateral surface area of cuboid | 369 | mbpp | 0 | 2024-11-26T21:40:54.378542 | def lateralsurface_cuboid(l,w,h):
LSA = 2*h*(l+w)
return LSA | lateralsurface_cuboid | easy | [{"input": "8,5,6", "output": "156", "testtype": "functional"}] |
Mbpp_369 | Write a function to find the lateral surface area of cuboid | 369 | mbpp | 1 | 2024-11-26T21:40:54.378685 | def lateralsurface_cuboid(l,w,h):
LSA = 2*h*(l+w)
return LSA | lateralsurface_cuboid | easy | [{"input": "7,9,10", "output": "320", "testtype": "functional"}] |
Mbpp_369 | Write a function to find the lateral surface area of cuboid | 369 | mbpp | 2 | 2024-11-26T21:40:54.378811 | def lateralsurface_cuboid(l,w,h):
LSA = 2*h*(l+w)
return LSA | lateralsurface_cuboid | easy | [{"input": "10,20,30", "output": "1800", "testtype": "functional"}] |
Mbpp_370 | Write a function to sort a tuple by its float element. | 370 | mbpp | 0 | 2024-11-26T21:40:54.379005 | def float_sort(price):
float_sort=sorted(price, key=lambda x: float(x[1]), reverse=True)
return float_sort | float_sort | easy | [{"input": "[('item1', '12.20'), ('item2', '15.10'), ('item3', '24.5')]", "output": "[('item3', '24.5'), ('item2', '15.10'), ('item1', '12.20')]", "testtype": "functional"}] |
Mbpp_370 | Write a function to sort a tuple by its float element. | 370 | mbpp | 1 | 2024-11-26T21:40:54.379153 | def float_sort(price):
float_sort=sorted(price, key=lambda x: float(x[1]), reverse=True)
return float_sort | float_sort | easy | [{"input": "[('item1', '15'), ('item2', '10'), ('item3', '20')]", "output": "[('item3', '20'), ('item1', '15'), ('item2', '10')]", "testtype": "functional"}] |
Mbpp_370 | Write a function to sort a tuple by its float element. | 370 | mbpp | 2 | 2024-11-26T21:40:54.379317 | def float_sort(price):
float_sort=sorted(price, key=lambda x: float(x[1]), reverse=True)
return float_sort | float_sort | easy | [{"input": "[('item1', '5'), ('item2', '10'), ('item3', '14')]", "output": "[('item3', '14'), ('item2', '10'), ('item1', '5')]", "testtype": "functional"}] |
Mbpp_371 | Write a function to find the smallest missing element in a sorted array. | 371 | mbpp | 0 | 2024-11-26T21:40:54.379843 | def smallest_missing(A, left_element, right_element):
if left_element > right_element:
return left_element
mid = left_element + (right_element - left_element) // 2
if A[mid] == mid:
return smallest_missing(A, mid + 1, right_element)
else:
return smallest_missing(A, left_element, mid - 1) | smallest_missing | easy | [{"input": "[0, 1, 2, 3, 4, 5, 6], 0, 6", "output": "7", "testtype": "functional"}] |
Mbpp_371 | Write a function to find the smallest missing element in a sorted array. | 371 | mbpp | 1 | 2024-11-26T21:40:54.380025 | def smallest_missing(A, left_element, right_element):
if left_element > right_element:
return left_element
mid = left_element + (right_element - left_element) // 2
if A[mid] == mid:
return smallest_missing(A, mid + 1, right_element)
else:
return smallest_missing(A, left_element, mid - 1) | smallest_missing | easy | [{"input": "[0, 1, 2, 6, 9, 11, 15], 0, 6", "output": "3", "testtype": "functional"}] |
Mbpp_371 | Write a function to find the smallest missing element in a sorted array. | 371 | mbpp | 2 | 2024-11-26T21:40:54.380193 | def smallest_missing(A, left_element, right_element):
if left_element > right_element:
return left_element
mid = left_element + (right_element - left_element) // 2
if A[mid] == mid:
return smallest_missing(A, mid + 1, right_element)
else:
return smallest_missing(A, left_element, mid - 1) | smallest_missing | easy | [{"input": "[1, 2, 3, 4, 6, 9, 11, 15], 0, 7", "output": "0", "testtype": "functional"}] |
Mbpp_372 | Write a function to sort a given list of elements in ascending order using heap queue algorithm. | 372 | mbpp | 0 | 2024-11-26T21:40:54.380331 | import heapq as hq
def heap_assending(nums):
hq.heapify(nums)
s_result = [hq.heappop(nums) for i in range(len(nums))]
return s_result | heap_assending | easy | [{"input": "[18, 14, 10, 9, 8, 7, 9, 3, 2, 4, 1]", "output": "[1, 2, 3, 4, 7, 8, 9, 9, 10, 14, 18]", "testtype": "functional"}] |
Mbpp_372 | Write a function to sort a given list of elements in ascending order using heap queue algorithm. | 372 | mbpp | 1 | 2024-11-26T21:40:54.380450 | import heapq as hq
def heap_assending(nums):
hq.heapify(nums)
s_result = [hq.heappop(nums) for i in range(len(nums))]
return s_result | heap_assending | easy | [{"input": "[25, 35, 22, 85, 14, 65, 75, 25, 58]", "output": "[14, 22, 25, 25, 35, 58, 65, 75, 85]", "testtype": "functional"}] |
Mbpp_372 | Write a function to sort a given list of elements in ascending order using heap queue algorithm. | 372 | mbpp | 2 | 2024-11-26T21:40:54.380557 | import heapq as hq
def heap_assending(nums):
hq.heapify(nums)
s_result = [hq.heappop(nums) for i in range(len(nums))]
return s_result | heap_assending | easy | [{"input": "[1, 3, 5, 7, 9, 2, 4, 6, 8, 0]", "output": "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]", "testtype": "functional"}] |
Mbpp_373 | Write a function to find the volume of a cuboid. | 373 | mbpp | 0 | 2024-11-26T21:40:54.380628 | def volume_cuboid(l,w,h):
volume=l*w*h
return volume | volume_cuboid | easy | [{"input": "1,2,3", "output": "6", "testtype": "functional"}] |
Mbpp_373 | Write a function to find the volume of a cuboid. | 373 | mbpp | 1 | 2024-11-26T21:40:54.380735 | def volume_cuboid(l,w,h):
volume=l*w*h
return volume | volume_cuboid | easy | [{"input": "5,7,9", "output": "315", "testtype": "functional"}] |
Mbpp_373 | Write a function to find the volume of a cuboid. | 373 | mbpp | 2 | 2024-11-26T21:40:54.380801 | def volume_cuboid(l,w,h):
volume=l*w*h
return volume | volume_cuboid | easy | [{"input": "10,15,21", "output": "3150", "testtype": "functional"}] |
Mbpp_374 | Write a function to print all permutations of a given string including duplicates. | 374 | mbpp | 0 | 2024-11-26T21:40:54.381101 | def permute_string(str):
if len(str) == 0:
return ['']
prev_list = permute_string(str[1:len(str)])
next_list = []
for i in range(0,len(prev_list)):
for j in range(0,len(str)):
new_str = prev_list[i][0:j]+str[0]+prev_list[i][j:len(str)-1]
if new_str not in next_list:
next_list.append(new_str)
return next_list | permute_string | easy | [{"input": "'ab'", "output": "['ab', 'ba']", "testtype": "functional"}] |
Mbpp_374 | Write a function to print all permutations of a given string including duplicates. | 374 | mbpp | 1 | 2024-11-26T21:40:54.381369 | def permute_string(str):
if len(str) == 0:
return ['']
prev_list = permute_string(str[1:len(str)])
next_list = []
for i in range(0,len(prev_list)):
for j in range(0,len(str)):
new_str = prev_list[i][0:j]+str[0]+prev_list[i][j:len(str)-1]
if new_str not in next_list:
next_list.append(new_str)
return next_list | permute_string | easy | [{"input": "'abc'", "output": "['abc', 'bac', 'bca', 'acb', 'cab', 'cba']", "testtype": "functional"}] |
Mbpp_374 | Write a function to print all permutations of a given string including duplicates. | 374 | mbpp | 2 | 2024-11-26T21:40:54.381647 | def permute_string(str):
if len(str) == 0:
return ['']
prev_list = permute_string(str[1:len(str)])
next_list = []
for i in range(0,len(prev_list)):
for j in range(0,len(str)):
new_str = prev_list[i][0:j]+str[0]+prev_list[i][j:len(str)-1]
if new_str not in next_list:
next_list.append(new_str)
return next_list | permute_string | easy | [{"input": "'abcd'", "output": "['abcd', 'bacd', 'bcad', 'bcda', 'acbd', 'cabd', 'cbad', 'cbda', 'acdb', 'cadb', 'cdab', 'cdba', 'abdc', 'badc', 'bdac', 'bdca', 'adbc', 'dabc', 'dbac', 'dbca', 'adcb', 'dacb', 'dcab', 'dcba']", "testtype": "functional"}] |
Mbpp_375 | Write a function to round the given number to the nearest multiple of a specific number. | 375 | mbpp | 0 | 2024-11-26T21:40:54.381792 | def round_num(n,m):
a = (n //m) * m
b = a + m
return (b if n - a > b - n else a) | round_num | easy | [{"input": "4722,10", "output": "4720", "testtype": "functional"}] |
Mbpp_375 | Write a function to round the given number to the nearest multiple of a specific number. | 375 | mbpp | 1 | 2024-11-26T21:40:54.381900 | def round_num(n,m):
a = (n //m) * m
b = a + m
return (b if n - a > b - n else a) | round_num | easy | [{"input": "1111,5", "output": "1110", "testtype": "functional"}] |
Mbpp_375 | Write a function to round the given number to the nearest multiple of a specific number. | 375 | mbpp | 2 | 2024-11-26T21:40:54.382002 | def round_num(n,m):
a = (n //m) * m
b = a + m
return (b if n - a > b - n else a) | round_num | easy | [{"input": "219,2", "output": "218", "testtype": "functional"}] |
Mbpp_376 | Write a function to remove tuple elements that occur more than once and replace the duplicates with some custom value. | 376 | mbpp | 0 | 2024-11-26T21:40:54.382146 | def remove_replica(test_tup):
temp = set()
res = tuple(ele if ele not in temp and not temp.add(ele)
else 'MSP' for ele in test_tup)
return (res) | remove_replica | easy | [{"input": "(1, 1, 4, 4, 4, 5, 5, 6, 7, 7)", "output": "(1, 'MSP', 4, 'MSP', 'MSP', 5, 'MSP', 6, 7, 'MSP')", "testtype": "functional"}] |
Mbpp_376 | Write a function to remove tuple elements that occur more than once and replace the duplicates with some custom value. | 376 | mbpp | 1 | 2024-11-26T21:40:54.382267 | def remove_replica(test_tup):
temp = set()
res = tuple(ele if ele not in temp and not temp.add(ele)
else 'MSP' for ele in test_tup)
return (res) | remove_replica | easy | [{"input": "(2, 3, 4, 4, 5, 6, 6, 7, 8, 9, 9)", "output": "(2, 3, 4, 'MSP', 5, 6, 'MSP', 7, 8, 9, 'MSP')", "testtype": "functional"}] |
Mbpp_376 | Write a function to remove tuple elements that occur more than once and replace the duplicates with some custom value. | 376 | mbpp | 2 | 2024-11-26T21:40:54.382383 | def remove_replica(test_tup):
temp = set()
res = tuple(ele if ele not in temp and not temp.add(ele)
else 'MSP' for ele in test_tup)
return (res) | remove_replica | easy | [{"input": "(2, 2, 5, 4, 5, 7, 5, 6, 7, 7)", "output": "(2, 'MSP', 5, 4, 'MSP', 7, 'MSP', 6, 'MSP', 'MSP')", "testtype": "functional"}] |
Mbpp_377 | Write a python function to remove all occurrences of a character in a given string. | 377 | mbpp | 0 | 2024-11-26T21:40:54.382526 | def remove_Char(s,c) :
counts = s.count(c)
s = list(s)
while counts :
s.remove(c)
counts -= 1
s = '' . join(s)
return (s) | remove_Char | easy | [{"input": "\"aba\",'a'", "output": "\"b\"", "testtype": "functional"}] |
Mbpp_377 | Write a python function to remove all occurrences of a character in a given string. | 377 | mbpp | 1 | 2024-11-26T21:40:54.382710 | def remove_Char(s,c) :
counts = s.count(c)
s = list(s)
while counts :
s.remove(c)
counts -= 1
s = '' . join(s)
return (s) | remove_Char | easy | [{"input": "\"toggle\",'g'", "output": "\"tole\"", "testtype": "functional"}] |
Mbpp_377 | Write a python function to remove all occurrences of a character in a given string. | 377 | mbpp | 2 | 2024-11-26T21:40:54.382960 | def remove_Char(s,c) :
counts = s.count(c)
s = list(s)
while counts :
s.remove(c)
counts -= 1
s = '' . join(s)
return (s) | remove_Char | easy | [{"input": "\"aabbc\",'b'", "output": "\"aac\"", "testtype": "functional"}] |
Mbpp_378 | Write a python function to shift last element to first position in the given list. | 378 | mbpp | 0 | 2024-11-26T21:40:54.383126 | def move_first(test_list):
test_list = test_list[-1:] + test_list[:-1]
return test_list | move_first | easy | [{"input": "[1,2,3,4]", "output": "[4,1,2,3]", "testtype": "functional"}] |
Mbpp_378 | Write a python function to shift last element to first position in the given list. | 378 | mbpp | 1 | 2024-11-26T21:40:54.383257 | def move_first(test_list):
test_list = test_list[-1:] + test_list[:-1]
return test_list | move_first | easy | [{"input": "[0,1,2,3]", "output": "[3,0,1,2]", "testtype": "functional"}] |
Mbpp_378 | Write a python function to shift last element to first position in the given list. | 378 | mbpp | 2 | 2024-11-26T21:40:54.383381 | def move_first(test_list):
test_list = test_list[-1:] + test_list[:-1]
return test_list | move_first | easy | [{"input": "[9,8,7,1]", "output": "[1,9,8,7]", "testtype": "functional"}] |
Mbpp_379 | Write a function to find the surface area of a cuboid. | 379 | mbpp | 0 | 2024-11-26T21:40:54.383536 | def surfacearea_cuboid(l,w,h):
SA = 2*(l*w + l * h + w * h)
return SA | surfacearea_cuboid | easy | [{"input": "1,2,3", "output": "22", "testtype": "functional"}] |
Mbpp_379 | Write a function to find the surface area of a cuboid. | 379 | mbpp | 1 | 2024-11-26T21:40:54.383701 | def surfacearea_cuboid(l,w,h):
SA = 2*(l*w + l * h + w * h)
return SA | surfacearea_cuboid | easy | [{"input": "5,7,9", "output": "286", "testtype": "functional"}] |
Mbpp_379 | Write a function to find the surface area of a cuboid. | 379 | mbpp | 2 | 2024-11-26T21:40:54.383849 | def surfacearea_cuboid(l,w,h):
SA = 2*(l*w + l * h + w * h)
return SA | surfacearea_cuboid | easy | [{"input": "10,15,21", "output": "1350", "testtype": "functional"}] |
Mbpp_380 | Write a function to generate a two-dimensional array. | 380 | mbpp | 0 | 2024-11-26T21:40:54.384156 | def multi_list(rownum,colnum):
multi_list = [[0 for col in range(colnum)] for row in range(rownum)]
for row in range(rownum):
for col in range(colnum):
multi_list[row][col]= row*col
return multi_list
| multi_list | easy | [{"input": "3,4", "output": "[[0, 0, 0, 0], [0, 1, 2, 3], [0, 2, 4, 6]]", "testtype": "functional"}] |
Mbpp_380 | Write a function to generate a two-dimensional array. | 380 | mbpp | 1 | 2024-11-26T21:40:54.384429 | def multi_list(rownum,colnum):
multi_list = [[0 for col in range(colnum)] for row in range(rownum)]
for row in range(rownum):
for col in range(colnum):
multi_list[row][col]= row*col
return multi_list
| multi_list | easy | [{"input": "5,7", "output": "[[0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 3, 4, 5, 6], [0, 2, 4, 6, 8, 10, 12], [0, 3, 6, 9, 12, 15, 18], [0, 4, 8, 12, 16, 20, 24]]", "testtype": "functional"}] |
Mbpp_380 | Write a function to generate a two-dimensional array. | 380 | mbpp | 2 | 2024-11-26T21:40:54.384715 | def multi_list(rownum,colnum):
multi_list = [[0 for col in range(colnum)] for row in range(rownum)]
for row in range(rownum):
for col in range(colnum):
multi_list[row][col]= row*col
return multi_list
| multi_list | easy | [{"input": "10,15", "output": "[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28], [0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42], [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56], [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70], [0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84], [0, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98], [0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112], [0, 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126]]", "testtype": "functional"}] |
Mbpp_381 | Write a function to sort a list of lists by a given index of the inner list. | 381 | mbpp | 0 | 2024-11-26T21:40:54.384901 | from operator import itemgetter
def index_on_inner_list(list_data, index_no):
result = sorted(list_data, key=itemgetter(index_no))
return result | index_on_inner_list | easy | [{"input": "[('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,0", "output": "[('Beau Turnbull', 94, 98), ('Brady Kent', 97, 96), ('Greyson Fulton', 98, 99), ('Wyatt Knott', 91, 94)]", "testtype": "functional"}] |
Mbpp_381 | Write a function to sort a list of lists by a given index of the inner list. | 381 | mbpp | 1 | 2024-11-26T21:40:54.385052 | from operator import itemgetter
def index_on_inner_list(list_data, index_no):
result = sorted(list_data, key=itemgetter(index_no))
return result | index_on_inner_list | easy | [{"input": "[('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,1", "output": "[('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98), ('Brady Kent', 97, 96), ('Greyson Fulton', 98, 99)]", "testtype": "functional"}] |
Mbpp_381 | Write a function to sort a list of lists by a given index of the inner list. | 381 | mbpp | 2 | 2024-11-26T21:40:54.385206 | from operator import itemgetter
def index_on_inner_list(list_data, index_no):
result = sorted(list_data, key=itemgetter(index_no))
return result | index_on_inner_list | easy | [{"input": "[('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,2", "output": "[('Wyatt Knott', 91, 94), ('Brady Kent', 97, 96), ('Beau Turnbull', 94, 98), ('Greyson Fulton', 98, 99)]", "testtype": "functional"}] |
Mbpp_382 | Write a function to find the number of rotations in a circularly sorted array. | 382 | mbpp | 0 | 2024-11-26T21:40:54.385876 | def find_rotation_count(A):
(left, right) = (0, len(A) - 1)
while left <= right:
if A[left] <= A[right]:
return left
mid = (left + right) // 2
next = (mid + 1) % len(A)
prev = (mid - 1 + len(A)) % len(A)
if A[mid] <= A[next] and A[mid] <= A[prev]:
return mid
elif A[mid] <= A[right]:
right = mid - 1
elif A[mid] >= A[left]:
left = mid + 1
return -1 | find_rotation_count | easy | [{"input": "[8, 9, 10, 1, 2, 3, 4, 5, 6, 7]", "output": "3", "testtype": "functional"}] |
Mbpp_382 | Write a function to find the number of rotations in a circularly sorted array. | 382 | mbpp | 1 | 2024-11-26T21:40:54.386456 | def find_rotation_count(A):
(left, right) = (0, len(A) - 1)
while left <= right:
if A[left] <= A[right]:
return left
mid = (left + right) // 2
next = (mid + 1) % len(A)
prev = (mid - 1 + len(A)) % len(A)
if A[mid] <= A[next] and A[mid] <= A[prev]:
return mid
elif A[mid] <= A[right]:
right = mid - 1
elif A[mid] >= A[left]:
left = mid + 1
return -1 | find_rotation_count | easy | [{"input": "[8, 9, 10,2, 5, 6]", "output": "3", "testtype": "functional"}] |
Mbpp_382 | Write a function to find the number of rotations in a circularly sorted array. | 382 | mbpp | 2 | 2024-11-26T21:40:54.387144 | def find_rotation_count(A):
(left, right) = (0, len(A) - 1)
while left <= right:
if A[left] <= A[right]:
return left
mid = (left + right) // 2
next = (mid + 1) % len(A)
prev = (mid - 1 + len(A)) % len(A)
if A[mid] <= A[next] and A[mid] <= A[prev]:
return mid
elif A[mid] <= A[right]:
right = mid - 1
elif A[mid] >= A[left]:
left = mid + 1
return -1 | find_rotation_count | easy | [{"input": "[2, 5, 6, 8, 9, 10]", "output": "0", "testtype": "functional"}] |
Mbpp_383 | Write a python function to toggle all odd bits of a given number. | 383 | mbpp | 0 | 2024-11-26T21:40:54.387461 | def even_bit_toggle_number(n) :
res = 0; count = 0; temp = n
while(temp > 0 ) :
if (count % 2 == 0) :
res = res | (1 << count)
count = count + 1
temp >>= 1
return n ^ res | even_bit_toggle_number | easy | [{"input": "10", "output": "15", "testtype": "functional"}] |
Mbpp_383 | Write a python function to toggle all odd bits of a given number. | 383 | mbpp | 1 | 2024-11-26T21:40:54.387747 | def even_bit_toggle_number(n) :
res = 0; count = 0; temp = n
while(temp > 0 ) :
if (count % 2 == 0) :
res = res | (1 << count)
count = count + 1
temp >>= 1
return n ^ res | even_bit_toggle_number | easy | [{"input": "20", "output": "1", "testtype": "functional"}] |
Mbpp_383 | Write a python function to toggle all odd bits of a given number. | 383 | mbpp | 2 | 2024-11-26T21:40:54.388014 | def even_bit_toggle_number(n) :
res = 0; count = 0; temp = n
while(temp > 0 ) :
if (count % 2 == 0) :
res = res | (1 << count)
count = count + 1
temp >>= 1
return n ^ res | even_bit_toggle_number | easy | [{"input": "30", "output": "11", "testtype": "functional"}] |
Mbpp_384 | Write a python function to find the frequency of the smallest value in a given array. | 384 | mbpp | 0 | 2024-11-26T21:40:54.388537 | def frequency_Of_Smallest(n,arr):
mn = arr[0]
freq = 1
for i in range(1,n):
if (arr[i] < mn):
mn = arr[i]
freq = 1
elif (arr[i] == mn):
freq += 1
return freq | frequency_Of_Smallest | easy | [{"input": "5,[1,2,3,4,3]", "output": "1", "testtype": "functional"}] |
Mbpp_384 | Write a python function to find the frequency of the smallest value in a given array. | 384 | mbpp | 1 | 2024-11-26T21:40:54.388924 | def frequency_Of_Smallest(n,arr):
mn = arr[0]
freq = 1
for i in range(1,n):
if (arr[i] < mn):
mn = arr[i]
freq = 1
elif (arr[i] == mn):
freq += 1
return freq | frequency_Of_Smallest | easy | [{"input": "7,[3,1,2,5,6,2,3]", "output": "1", "testtype": "functional"}] |
Mbpp_384 | Write a python function to find the frequency of the smallest value in a given array. | 384 | mbpp | 2 | 2024-11-26T21:40:54.389257 | def frequency_Of_Smallest(n,arr):
mn = arr[0]
freq = 1
for i in range(1,n):
if (arr[i] < mn):
mn = arr[i]
freq = 1
elif (arr[i] == mn):
freq += 1
return freq | frequency_Of_Smallest | easy | [{"input": "7,[3,3,6,3,7,4,9]", "output": "3", "testtype": "functional"}] |
Mbpp_385 | Write a function to find the n'th perrin number using recursion. | 385 | mbpp | 0 | 2024-11-26T21:40:54.389526 | def get_perrin(n):
if (n == 0):
return 3
if (n == 1):
return 0
if (n == 2):
return 2
return get_perrin(n - 2) + get_perrin(n - 3) | get_perrin | easy | [{"input": "9", "output": "12", "testtype": "functional"}] |
Mbpp_385 | Write a function to find the n'th perrin number using recursion. | 385 | mbpp | 1 | 2024-11-26T21:40:54.389790 | def get_perrin(n):
if (n == 0):
return 3
if (n == 1):
return 0
if (n == 2):
return 2
return get_perrin(n - 2) + get_perrin(n - 3) | get_perrin | easy | [{"input": "4", "output": "2", "testtype": "functional"}] |
Mbpp_385 | Write a function to find the n'th perrin number using recursion. | 385 | mbpp | 2 | 2024-11-26T21:40:54.390020 | def get_perrin(n):
if (n == 0):
return 3
if (n == 1):
return 0
if (n == 2):
return 2
return get_perrin(n - 2) + get_perrin(n - 3) | get_perrin | easy | [{"input": "6", "output": "5", "testtype": "functional"}] |
Mbpp_386 | Write a function to find out the minimum no of swaps required for bracket balancing in the given string. | 386 | mbpp | 0 | 2024-11-26T21:40:54.390666 | def swap_count(s):
chars = s
count_left = 0
count_right = 0
swap = 0
imbalance = 0;
for i in range(len(chars)):
if chars[i] == '[':
count_left += 1
if imbalance > 0:
swap += imbalance
imbalance -= 1
elif chars[i] == ']':
count_right += 1
imbalance = (count_right - count_left)
return swap | swap_count | easy | [{"input": "\"[]][][\"", "output": "2", "testtype": "functional"}] |
Mbpp_386 | Write a function to find out the minimum no of swaps required for bracket balancing in the given string. | 386 | mbpp | 1 | 2024-11-26T21:40:54.391106 | def swap_count(s):
chars = s
count_left = 0
count_right = 0
swap = 0
imbalance = 0;
for i in range(len(chars)):
if chars[i] == '[':
count_left += 1
if imbalance > 0:
swap += imbalance
imbalance -= 1
elif chars[i] == ']':
count_right += 1
imbalance = (count_right - count_left)
return swap | swap_count | easy | [{"input": "\"[[][]]\"", "output": "0", "testtype": "functional"}] |
Mbpp_386 | Write a function to find out the minimum no of swaps required for bracket balancing in the given string. | 386 | mbpp | 2 | 2024-11-26T21:40:54.391495 | def swap_count(s):
chars = s
count_left = 0
count_right = 0
swap = 0
imbalance = 0;
for i in range(len(chars)):
if chars[i] == '[':
count_left += 1
if imbalance > 0:
swap += imbalance
imbalance -= 1
elif chars[i] == ']':
count_right += 1
imbalance = (count_right - count_left)
return swap | swap_count | easy | [{"input": "\"[[][]]][\"", "output": "1", "testtype": "functional"}] |
Mbpp_387 | Write a python function to check whether the hexadecimal number is even or odd. | 387 | mbpp | 0 | 2024-11-26T21:40:54.391937 | def even_or_odd(N):
l = len(N)
if (N[l-1] =='0'or N[l-1] =='2'or
N[l-1] =='4'or N[l-1] =='6'or
N[l-1] =='8'or N[l-1] =='A'or
N[l-1] =='C'or N[l-1] =='E'):
return ("Even")
else:
return ("Odd") | even_or_odd | easy | [{"input": "\"AB3454D\"", "output": "\"Odd\"", "testtype": "functional"}] |
Mbpp_387 | Write a python function to check whether the hexadecimal number is even or odd. | 387 | mbpp | 1 | 2024-11-26T21:40:54.392377 | def even_or_odd(N):
l = len(N)
if (N[l-1] =='0'or N[l-1] =='2'or
N[l-1] =='4'or N[l-1] =='6'or
N[l-1] =='8'or N[l-1] =='A'or
N[l-1] =='C'or N[l-1] =='E'):
return ("Even")
else:
return ("Odd") | even_or_odd | easy | [{"input": "\"ABC\"", "output": "\"Even\"", "testtype": "functional"}] |
Mbpp_387 | Write a python function to check whether the hexadecimal number is even or odd. | 387 | mbpp | 2 | 2024-11-26T21:40:54.392879 | def even_or_odd(N):
l = len(N)
if (N[l-1] =='0'or N[l-1] =='2'or
N[l-1] =='4'or N[l-1] =='6'or
N[l-1] =='8'or N[l-1] =='A'or
N[l-1] =='C'or N[l-1] =='E'):
return ("Even")
else:
return ("Odd") | even_or_odd | easy | [{"input": "\"AAD\"", "output": "\"Odd\"", "testtype": "functional"}] |
Mbpp_388 | Write a python function to find the highest power of 2 that is less than or equal to n. | 388 | mbpp | 0 | 2024-11-26T21:40:54.393141 | def highest_Power_of_2(n):
res = 0;
for i in range(n, 0, -1):
if ((i & (i - 1)) == 0):
res = i;
break;
return res; | highest_Power_of_2 | easy | [{"input": "10", "output": "8", "testtype": "functional"}] |
Mbpp_388 | Write a python function to find the highest power of 2 that is less than or equal to n. | 388 | mbpp | 1 | 2024-11-26T21:40:54.393375 | def highest_Power_of_2(n):
res = 0;
for i in range(n, 0, -1):
if ((i & (i - 1)) == 0):
res = i;
break;
return res; | highest_Power_of_2 | easy | [{"input": "19", "output": "16", "testtype": "functional"}] |
Mbpp_388 | Write a python function to find the highest power of 2 that is less than or equal to n. | 388 | mbpp | 2 | 2024-11-26T21:40:54.393600 | def highest_Power_of_2(n):
res = 0;
for i in range(n, 0, -1):
if ((i & (i - 1)) == 0):
res = i;
break;
return res; | highest_Power_of_2 | easy | [{"input": "32", "output": "32", "testtype": "functional"}] |
Mbpp_389 | Write a function to find the n'th lucas number. | 389 | mbpp | 0 | 2024-11-26T21:40:54.393814 | def find_lucas(n):
if (n == 0):
return 2
if (n == 1):
return 1
return find_lucas(n - 1) + find_lucas(n - 2) | find_lucas | easy | [{"input": "9", "output": "76", "testtype": "functional"}] |
Mbpp_389 | Write a function to find the n'th lucas number. | 389 | mbpp | 1 | 2024-11-26T21:40:54.394010 | def find_lucas(n):
if (n == 0):
return 2
if (n == 1):
return 1
return find_lucas(n - 1) + find_lucas(n - 2) | find_lucas | easy | [{"input": "4", "output": "7", "testtype": "functional"}] |
Mbpp_389 | Write a function to find the n'th lucas number. | 389 | mbpp | 2 | 2024-11-26T21:40:54.394193 | def find_lucas(n):
if (n == 0):
return 2
if (n == 1):
return 1
return find_lucas(n - 1) + find_lucas(n - 2) | find_lucas | easy | [{"input": "3", "output": "4", "testtype": "functional"}] |
Mbpp_390 | Write a function to insert a given string at the beginning of all items in a list. | 390 | mbpp | 0 | 2024-11-26T21:40:54.394364 | def add_string(list,string):
add_string=[string.format(i) for i in list]
return add_string | add_string | easy | [{"input": "[1,2,3,4],'temp{0}'", "output": "['temp1', 'temp2', 'temp3', 'temp4']", "testtype": "functional"}] |
Mbpp_390 | Write a function to insert a given string at the beginning of all items in a list. | 390 | mbpp | 1 | 2024-11-26T21:40:54.394502 | def add_string(list,string):
add_string=[string.format(i) for i in list]
return add_string | add_string | easy | [{"input": "['a','b','c','d'], 'python{0}'", "output": "[ 'pythona', 'pythonb', 'pythonc', 'pythond']", "testtype": "functional"}] |
Mbpp_390 | Write a function to insert a given string at the beginning of all items in a list. | 390 | mbpp | 2 | 2024-11-26T21:40:54.394630 | def add_string(list,string):
add_string=[string.format(i) for i in list]
return add_string | add_string | easy | [{"input": "[5,6,7,8],'string{0}'", "output": "['string5', 'string6', 'string7', 'string8']", "testtype": "functional"}] |
Mbpp_391 | Write a function to convert more than one list to nested dictionary. | 391 | mbpp | 0 | 2024-11-26T21:40:54.394866 | def convert_list_dictionary(l1, l2, l3):
result = [{x: {y: z}} for (x, y, z) in zip(l1, l2, l3)]
return result | convert_list_dictionary | easy | [{"input": "[\"S001\", \"S002\", \"S003\", \"S004\"],[\"Adina Park\", \"Leyton Marsh\", \"Duncan Boyle\", \"Saim Richards\"] ,[85, 98, 89, 92]", "output": "[{'S001': {'Adina Park': 85}}, {'S002': {'Leyton Marsh': 98}}, {'S003': {'Duncan Boyle': 89}}, {'S004': {'Saim Richards': 92}}]", "testtype": "functional"}] |
Mbpp_391 | Write a function to convert more than one list to nested dictionary. | 391 | mbpp | 1 | 2024-11-26T21:40:54.395074 | def convert_list_dictionary(l1, l2, l3):
result = [{x: {y: z}} for (x, y, z) in zip(l1, l2, l3)]
return result | convert_list_dictionary | easy | [{"input": "[\"abc\",\"def\",\"ghi\",\"jkl\"],[\"python\",\"program\",\"language\",\"programs\"],[100,200,300,400]", "output": "[{'abc':{'python':100}},{'def':{'program':200}},{'ghi':{'language':300}},{'jkl':{'programs':400}}]", "testtype": "functional"}] |
Mbpp_391 | Write a function to convert more than one list to nested dictionary. | 391 | mbpp | 2 | 2024-11-26T21:40:54.395271 | def convert_list_dictionary(l1, l2, l3):
result = [{x: {y: z}} for (x, y, z) in zip(l1, l2, l3)]
return result | convert_list_dictionary | easy | [{"input": "[\"A1\",\"A2\",\"A3\",\"A4\"],[\"java\",\"C\",\"C++\",\"DBMS\"],[10,20,30,40]", "output": "[{'A1':{'java':10}},{'A2':{'C':20}},{'A3':{'C++':30}},{'A4':{'DBMS':40}}]", "testtype": "functional"}] |
Mbpp_392 | Write a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n). | 392 | mbpp | 0 | 2024-11-26T21:40:54.395772 | def get_max_sum (n):
res = list()
res.append(0)
res.append(1)
i = 2
while i<n + 1:
res.append(max(i, (res[int(i / 2)]
+ res[int(i / 3)] +
res[int(i / 4)]
+ res[int(i / 5)])))
i = i + 1
return res[n] | get_max_sum | easy | [{"input": "60", "output": "106", "testtype": "functional"}] |