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_182
Write a function to find uppercase, lowercase, special character and numeric values using regex.
182
mbpp
2
2024-11-26T21:40:54.214588
import re def find_character(string): uppercase_characters = re.findall(r"[A-Z]", string) lowercase_characters = re.findall(r"[a-z]", string) numerical_characters = re.findall(r"[0-9]", string) special_characters = re.findall(r"[, .!?]", string) return uppercase_characters, lowercase_characters, num...
find_character
easy
[{"input": "\"HeyFolks32\"", "output": "(['H', 'F'], ['e', 'y', 'o', 'l', 'k', 's'], ['3', '2'], [])", "testtype": "functional"}]
Mbpp_183
Write a function to count all the distinct pairs having a difference of k in any array.
183
mbpp
0
2024-11-26T21:40:54.214959
def count_pairs(arr, n, k): count=0; for i in range(0,n): for j in range(i+1, n): if arr[i] - arr[j] == k or arr[j] - arr[i] == k: count += 1 return count
count_pairs
easy
[{"input": "[1, 5, 3, 4, 2], 5, 3", "output": "2", "testtype": "functional"}]
Mbpp_183
Write a function to count all the distinct pairs having a difference of k in any array.
183
mbpp
1
2024-11-26T21:40:54.215292
def count_pairs(arr, n, k): count=0; for i in range(0,n): for j in range(i+1, n): if arr[i] - arr[j] == k or arr[j] - arr[i] == k: count += 1 return count
count_pairs
easy
[{"input": "[8, 12, 16, 4, 0, 20], 6, 4", "output": "5", "testtype": "functional"}]
Mbpp_183
Write a function to count all the distinct pairs having a difference of k in any array.
183
mbpp
2
2024-11-26T21:40:54.215604
def count_pairs(arr, n, k): count=0; for i in range(0,n): for j in range(i+1, n): if arr[i] - arr[j] == k or arr[j] - arr[i] == k: count += 1 return count
count_pairs
easy
[{"input": "[2, 4, 1, 3, 4], 5, 2", "output": "3", "testtype": "functional"}]
Mbpp_184
Write a function to find all the values in a list that are greater than a specified number.
184
mbpp
0
2024-11-26T21:40:54.215809
def greater_specificnum(list,num): greater_specificnum=all(x >= num for x in list) return greater_specificnum
greater_specificnum
easy
[{"input": "[220, 330, 500],200", "output": "True", "testtype": "functional"}]
Mbpp_184
Write a function to find all the values in a list that are greater than a specified number.
184
mbpp
1
2024-11-26T21:40:54.215952
def greater_specificnum(list,num): greater_specificnum=all(x >= num for x in list) return greater_specificnum
greater_specificnum
easy
[{"input": "[12, 17, 21],20", "output": "False", "testtype": "functional"}]
Mbpp_184
Write a function to find all the values in a list that are greater than a specified number.
184
mbpp
2
2024-11-26T21:40:54.216100
def greater_specificnum(list,num): greater_specificnum=all(x >= num for x in list) return greater_specificnum
greater_specificnum
easy
[{"input": "[1,2,3,4],10", "output": "False", "testtype": "functional"}]
Mbpp_185
Write a function to find the focus of a parabola.
185
mbpp
0
2024-11-26T21:40:54.216327
def parabola_focus(a, b, c): focus= (((-b / (2 * a)),(((4 * a * c) - (b * b) + 1) / (4 * a)))) return focus
parabola_focus
easy
[{"input": "5,3,2", "output": "(-0.3, 1.6)", "testtype": "functional"}]
Mbpp_185
Write a function to find the focus of a parabola.
185
mbpp
1
2024-11-26T21:40:54.216539
def parabola_focus(a, b, c): focus= (((-b / (2 * a)),(((4 * a * c) - (b * b) + 1) / (4 * a)))) return focus
parabola_focus
easy
[{"input": "9,8,4", "output": "(-0.4444444444444444, 2.25)", "testtype": "functional"}]
Mbpp_185
Write a function to find the focus of a parabola.
185
mbpp
2
2024-11-26T21:40:54.216778
def parabola_focus(a, b, c): focus= (((-b / (2 * a)),(((4 * a * c) - (b * b) + 1) / (4 * a)))) return focus
parabola_focus
easy
[{"input": "2,4,6", "output": "(-1.0, 4.125)", "testtype": "functional"}]
Mbpp_186
Write a function to search some literals strings in a string by using regex.
186
mbpp
0
2024-11-26T21:40:54.216965
import re def check_literals(text, patterns): for pattern in patterns: if re.search(pattern, text): return ('Matched!') else: return ('Not Matched!')
check_literals
easy
[{"input": "'The quick brown fox jumps over the lazy dog.',['fox']", "output": "'Matched!'", "testtype": "functional"}]
Mbpp_186
Write a function to search some literals strings in a string by using regex.
186
mbpp
1
2024-11-26T21:40:54.217135
import re def check_literals(text, patterns): for pattern in patterns: if re.search(pattern, text): return ('Matched!') else: return ('Not Matched!')
check_literals
easy
[{"input": "'The quick brown fox jumps over the lazy dog.',['horse']", "output": "'Not Matched!'", "testtype": "functional"}]
Mbpp_186
Write a function to search some literals strings in a string by using regex.
186
mbpp
2
2024-11-26T21:40:54.217293
import re def check_literals(text, patterns): for pattern in patterns: if re.search(pattern, text): return ('Matched!') else: return ('Not Matched!')
check_literals
easy
[{"input": "'The quick brown fox jumps over the lazy dog.',['lazy']", "output": "'Matched!'", "testtype": "functional"}]
Mbpp_187
Write a function to find the longest common subsequence for the given two sequences.
187
mbpp
0
2024-11-26T21:40:54.217692
def longest_common_subsequence(X, Y, m, n): if m == 0 or n == 0: return 0 elif X[m-1] == Y[n-1]: return 1 + longest_common_subsequence(X, Y, m-1, n-1) else: return max(longest_common_subsequence(X, Y, m, n-1), longest_common_subsequence(X, Y, m-1, n))
longest_common_subsequence
easy
[{"input": "\"AGGTAB\" , \"GXTXAYB\", 6, 7", "output": "4", "testtype": "functional"}]
Mbpp_187
Write a function to find the longest common subsequence for the given two sequences.
187
mbpp
1
2024-11-26T21:40:54.218058
def longest_common_subsequence(X, Y, m, n): if m == 0 or n == 0: return 0 elif X[m-1] == Y[n-1]: return 1 + longest_common_subsequence(X, Y, m-1, n-1) else: return max(longest_common_subsequence(X, Y, m, n-1), longest_common_subsequence(X, Y, m-1, n))
longest_common_subsequence
easy
[{"input": "\"ABCDGH\" , \"AEDFHR\", 6, 6", "output": "3", "testtype": "functional"}]
Mbpp_187
Write a function to find the longest common subsequence for the given two sequences.
187
mbpp
2
2024-11-26T21:40:54.218420
def longest_common_subsequence(X, Y, m, n): if m == 0 or n == 0: return 0 elif X[m-1] == Y[n-1]: return 1 + longest_common_subsequence(X, Y, m-1, n-1) else: return max(longest_common_subsequence(X, Y, m, n-1), longest_common_subsequence(X, Y, m-1, n))
longest_common_subsequence
easy
[{"input": "\"AXYT\" , \"AYZX\", 4, 4", "output": "2", "testtype": "functional"}]
Mbpp_188
Write a python function to check whether the given number can be represented by product of two squares or not.
188
mbpp
0
2024-11-26T21:40:54.218734
def prod_Square(n): for i in range(2,(n) + 1): if (i*i < (n+1)): for j in range(2,n + 1): if ((i*i*j*j) == n): return True; return False;
prod_Square
easy
[{"input": "25", "output": "False", "testtype": "functional"}]
Mbpp_188
Write a python function to check whether the given number can be represented by product of two squares or not.
188
mbpp
1
2024-11-26T21:40:54.219020
def prod_Square(n): for i in range(2,(n) + 1): if (i*i < (n+1)): for j in range(2,n + 1): if ((i*i*j*j) == n): return True; return False;
prod_Square
easy
[{"input": "30", "output": "False", "testtype": "functional"}]
Mbpp_188
Write a python function to check whether the given number can be represented by product of two squares or not.
188
mbpp
2
2024-11-26T21:40:54.219359
def prod_Square(n): for i in range(2,(n) + 1): if (i*i < (n+1)): for j in range(2,n + 1): if ((i*i*j*j) == n): return True; return False;
prod_Square
easy
[{"input": "16", "output": "True", "testtype": "functional"}]
Mbpp_189
Write a python function to find the first missing positive number.
189
mbpp
0
2024-11-26T21:40:54.221994
def first_Missing_Positive(arr,n): ptr = 0 for i in range(n): if arr[i] == 1: ptr = 1 break if ptr == 0: return(1) for i in range(n): if arr[i] <= 0 or arr[i] > n: arr[i] = 1 for i in range(n): arr[(arr[i] - 1) % n] += ...
first_Missing_Positive
easy
[{"input": "[1,2,3,-1,5],5", "output": "4", "testtype": "functional"}]
Mbpp_189
Write a python function to find the first missing positive number.
189
mbpp
1
2024-11-26T21:40:54.222612
def first_Missing_Positive(arr,n): ptr = 0 for i in range(n): if arr[i] == 1: ptr = 1 break if ptr == 0: return(1) for i in range(n): if arr[i] <= 0 or arr[i] > n: arr[i] = 1 for i in range(n): arr[(arr[i] - 1) % n] += ...
first_Missing_Positive
easy
[{"input": "[0,-1,-2,1,5,8],6", "output": "2", "testtype": "functional"}]
Mbpp_189
Write a python function to find the first missing positive number.
189
mbpp
2
2024-11-26T21:40:54.223260
def first_Missing_Positive(arr,n): ptr = 0 for i in range(n): if arr[i] == 1: ptr = 1 break if ptr == 0: return(1) for i in range(n): if arr[i] <= 0 or arr[i] > n: arr[i] = 1 for i in range(n): arr[(arr[i] - 1) % n] += ...
first_Missing_Positive
easy
[{"input": "[0,1,2,5,-8],5", "output": "3", "testtype": "functional"}]
Mbpp_190
Write a python function to count the number of integral co-ordinates that lie inside a square.
190
mbpp
0
2024-11-26T21:40:54.223453
def count_Intgral_Points(x1,y1,x2,y2): return ((y2 - y1 - 1) * (x2 - x1 - 1))
count_Intgral_Points
easy
[{"input": "1,1,4,4", "output": "4", "testtype": "functional"}]
Mbpp_190
Write a python function to count the number of integral co-ordinates that lie inside a square.
190
mbpp
1
2024-11-26T21:40:54.223596
def count_Intgral_Points(x1,y1,x2,y2): return ((y2 - y1 - 1) * (x2 - x1 - 1))
count_Intgral_Points
easy
[{"input": "1,2,1,2", "output": "1", "testtype": "functional"}]
Mbpp_190
Write a python function to count the number of integral co-ordinates that lie inside a square.
190
mbpp
2
2024-11-26T21:40:54.223747
def count_Intgral_Points(x1,y1,x2,y2): return ((y2 - y1 - 1) * (x2 - x1 - 1))
count_Intgral_Points
easy
[{"input": "4,2,6,4", "output": "1", "testtype": "functional"}]
Mbpp_191
Write a function to check whether the given month name contains 30 days or not.
191
mbpp
0
2024-11-26T21:40:54.223919
def check_monthnumber(monthname3): if monthname3 =="April" or monthname3== "June" or monthname3== "September" or monthname3== "November": return True else: return False
check_monthnumber
easy
[{"input": "\"February\"", "output": "False", "testtype": "functional"}]
Mbpp_191
Write a function to check whether the given month name contains 30 days or not.
191
mbpp
1
2024-11-26T21:40:54.224097
def check_monthnumber(monthname3): if monthname3 =="April" or monthname3== "June" or monthname3== "September" or monthname3== "November": return True else: return False
check_monthnumber
easy
[{"input": "\"June\"", "output": "True", "testtype": "functional"}]
Mbpp_191
Write a function to check whether the given month name contains 30 days or not.
191
mbpp
2
2024-11-26T21:40:54.224248
def check_monthnumber(monthname3): if monthname3 =="April" or monthname3== "June" or monthname3== "September" or monthname3== "November": return True else: return False
check_monthnumber
easy
[{"input": "\"April\"", "output": "True", "testtype": "functional"}]
Mbpp_192
Write a python function to check whether a string has atleast one letter and one number.
192
mbpp
0
2024-11-26T21:40:54.224478
def check_String(str): flag_l = False flag_n = False for i in str: if i.isalpha(): flag_l = True if i.isdigit(): flag_n = True return flag_l and flag_n
check_String
easy
[{"input": "'thishasboth29'", "output": "True", "testtype": "functional"}]
Mbpp_192
Write a python function to check whether a string has atleast one letter and one number.
192
mbpp
1
2024-11-26T21:40:54.224711
def check_String(str): flag_l = False flag_n = False for i in str: if i.isalpha(): flag_l = True if i.isdigit(): flag_n = True return flag_l and flag_n
check_String
easy
[{"input": "'python'", "output": "False", "testtype": "functional"}]
Mbpp_193
Write a function to remove the duplicates from the given tuple.
193
mbpp
0
2024-11-26T21:40:54.224993
def remove_tuple(test_tup): res = tuple(set(test_tup)) return (res)
remove_tuple
easy
[{"input": "(1, 3, 5, 2, 3, 5, 1, 1, 3)", "output": "(1, 2, 3, 5)", "testtype": "functional"}]
Mbpp_193
Write a function to remove the duplicates from the given tuple.
193
mbpp
1
2024-11-26T21:40:54.225124
def remove_tuple(test_tup): res = tuple(set(test_tup)) return (res)
remove_tuple
easy
[{"input": "(2, 3, 4, 4, 5, 6, 6, 7, 8, 8)", "output": "(2, 3, 4, 5, 6, 7, 8)", "testtype": "functional"}]
Mbpp_193
Write a function to remove the duplicates from the given tuple.
193
mbpp
2
2024-11-26T21:40:54.225238
def remove_tuple(test_tup): res = tuple(set(test_tup)) return (res)
remove_tuple
easy
[{"input": "(11, 12, 13, 11, 11, 12, 14, 13)", "output": "(11, 12, 13, 14)", "testtype": "functional"}]
Mbpp_194
Write a python function to convert octal number to decimal number.
194
mbpp
0
2024-11-26T21:40:54.225530
def octal_To_Decimal(n): num = n; dec_value = 0; base = 1; temp = num; while (temp): last_digit = temp % 10; temp = int(temp / 10); dec_value += last_digit*base; base = base * 8; return dec_value;
octal_To_Decimal
easy
[{"input": "25", "output": "21", "testtype": "functional"}]
Mbpp_194
Write a python function to convert octal number to decimal number.
194
mbpp
1
2024-11-26T21:40:54.225875
def octal_To_Decimal(n): num = n; dec_value = 0; base = 1; temp = num; while (temp): last_digit = temp % 10; temp = int(temp / 10); dec_value += last_digit*base; base = base * 8; return dec_value;
octal_To_Decimal
easy
[{"input": "30", "output": "24", "testtype": "functional"}]
Mbpp_194
Write a python function to convert octal number to decimal number.
194
mbpp
2
2024-11-26T21:40:54.226180
def octal_To_Decimal(n): num = n; dec_value = 0; base = 1; temp = num; while (temp): last_digit = temp % 10; temp = int(temp / 10); dec_value += last_digit*base; base = base * 8; return dec_value;
octal_To_Decimal
easy
[{"input": "40", "output": "32", "testtype": "functional"}]
Mbpp_195
Write a python function to find the first position of an element in a sorted array.
195
mbpp
0
2024-11-26T21:40:54.226603
def first(arr,x,n): low = 0 high = n - 1 res = -1 while (low <= high): mid = (low + high) // 2 if arr[mid] > x: high = mid - 1 elif arr[mid] < x: low = mid + 1 else: res = mid high = mid - 1 return res
first
easy
[{"input": "[1,2,3,4,5,6,6],6,6", "output": "5", "testtype": "functional"}]
Mbpp_195
Write a python function to find the first position of an element in a sorted array.
195
mbpp
1
2024-11-26T21:40:54.227174
def first(arr,x,n): low = 0 high = n - 1 res = -1 while (low <= high): mid = (low + high) // 2 if arr[mid] > x: high = mid - 1 elif arr[mid] < x: low = mid + 1 else: res = mid high = mid - 1 return res
first
easy
[{"input": "[1,2,2,2,3,2,2,4,2],2,9", "output": "1", "testtype": "functional"}]
Mbpp_195
Write a python function to find the first position of an element in a sorted array.
195
mbpp
2
2024-11-26T21:40:54.227555
def first(arr,x,n): low = 0 high = n - 1 res = -1 while (low <= high): mid = (low + high) // 2 if arr[mid] > x: high = mid - 1 elif arr[mid] < x: low = mid + 1 else: res = mid high = mid - 1 return res
first
easy
[{"input": "[1,2,3],1,3", "output": "0", "testtype": "functional"}]
Mbpp_196
Write a function to remove all the tuples with length k.
196
mbpp
0
2024-11-26T21:40:54.227759
def remove_tuples(test_list, K): res = [ele for ele in test_list if len(ele) != K] return (res)
remove_tuples
easy
[{"input": "[(4, 5), (4, ), (8, 6, 7), (1, ), (3, 4, 6, 7)] , 1", "output": "[(4, 5), (8, 6, 7), (3, 4, 6, 7)]", "testtype": "functional"}]
Mbpp_196
Write a function to remove all the tuples with length k.
196
mbpp
1
2024-11-26T21:40:54.227924
def remove_tuples(test_list, K): res = [ele for ele in test_list if len(ele) != K] return (res)
remove_tuples
easy
[{"input": "[(4, 5), (4,5), (6, 7), (1, 2, 3), (3, 4, 6, 7)] ,2", "output": "[(1, 2, 3), (3, 4, 6, 7)]", "testtype": "functional"}]
Mbpp_196
Write a function to remove all the tuples with length k.
196
mbpp
2
2024-11-26T21:40:54.228067
def remove_tuples(test_list, K): res = [ele for ele in test_list if len(ele) != K] return (res)
remove_tuples
easy
[{"input": "[(1, 4, 4), (4, 3), (8, 6, 7), (1, ), (3, 6, 7)] , 3", "output": "[(4, 3), (1,)]", "testtype": "functional"}]
Mbpp_197
Write a function to perform the exponentiation of the given two tuples.
197
mbpp
0
2024-11-26T21:40:54.228259
def find_exponentio(test_tup1, test_tup2): res = tuple(ele1 ** ele2 for ele1, ele2 in zip(test_tup1, test_tup2)) return (res)
find_exponentio
easy
[{"input": "(10, 4, 5, 6), (5, 6, 7, 5)", "output": "(100000, 4096, 78125, 7776)", "testtype": "functional"}]
Mbpp_197
Write a function to perform the exponentiation of the given two tuples.
197
mbpp
1
2024-11-26T21:40:54.228418
def find_exponentio(test_tup1, test_tup2): res = tuple(ele1 ** ele2 for ele1, ele2 in zip(test_tup1, test_tup2)) return (res)
find_exponentio
easy
[{"input": "(11, 5, 6, 7), (6, 7, 8, 6)", "output": "(1771561, 78125, 1679616, 117649)", "testtype": "functional"}]
Mbpp_197
Write a function to perform the exponentiation of the given two tuples.
197
mbpp
2
2024-11-26T21:40:54.228588
def find_exponentio(test_tup1, test_tup2): res = tuple(ele1 ** ele2 for ele1, ele2 in zip(test_tup1, test_tup2)) return (res)
find_exponentio
easy
[{"input": "(12, 6, 7, 8), (7, 8, 9, 7)", "output": "(35831808, 1679616, 40353607, 2097152)", "testtype": "functional"}]
Mbpp_198
Write a function to find the largest triangle that can be inscribed in an ellipse.
198
mbpp
0
2024-11-26T21:40:54.228871
import math def largest_triangle(a,b): if (a < 0 or b < 0): return -1 area = (3 * math.sqrt(3) * pow(a, 2)) / (4 * b); return area
largest_triangle
easy
[{"input": "4,2", "output": "10.392304845413264", "testtype": "functional"}]
Mbpp_198
Write a function to find the largest triangle that can be inscribed in an ellipse.
198
mbpp
1
2024-11-26T21:40:54.229120
import math def largest_triangle(a,b): if (a < 0 or b < 0): return -1 area = (3 * math.sqrt(3) * pow(a, 2)) / (4 * b); return area
largest_triangle
easy
[{"input": "5,7", "output": "4.639421805988064", "testtype": "functional"}]
Mbpp_198
Write a function to find the largest triangle that can be inscribed in an ellipse.
198
mbpp
2
2024-11-26T21:40:54.229350
import math def largest_triangle(a,b): if (a < 0 or b < 0): return -1 area = (3 * math.sqrt(3) * pow(a, 2)) / (4 * b); return area
largest_triangle
easy
[{"input": "9,1", "output": "105.2220865598093", "testtype": "functional"}]
Mbpp_199
Write a python function to find highest power of 2 less than or equal to given number.
199
mbpp
0
2024-11-26T21:40:54.229581
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_199
Write a python function to find highest power of 2 less than or equal to given number.
199
mbpp
1
2024-11-26T21:40:54.229814
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_199
Write a python function to find highest power of 2 less than or equal to given number.
199
mbpp
2
2024-11-26T21:40:54.230810
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_200
Write a function to find all index positions of the maximum values in a given list.
200
mbpp
0
2024-11-26T21:40:54.231048
def position_max(list1): max_val = max(list1) max_result = [i for i, j in enumerate(list1) if j == max_val] return max_result
position_max
easy
[{"input": "[12,33,23,10,67,89,45,667,23,12,11,10,54]", "output": "[7]", "testtype": "functional"}]
Mbpp_200
Write a function to find all index positions of the maximum values in a given list.
200
mbpp
1
2024-11-26T21:40:54.231238
def position_max(list1): max_val = max(list1) max_result = [i for i, j in enumerate(list1) if j == max_val] return max_result
position_max
easy
[{"input": "[1,2,2,2,4,4,4,5,5,5,5]", "output": "[7,8,9,10]", "testtype": "functional"}]
Mbpp_200
Write a function to find all index positions of the maximum values in a given list.
200
mbpp
2
2024-11-26T21:40:54.231418
def position_max(list1): max_val = max(list1) max_result = [i for i, j in enumerate(list1) if j == max_val] return max_result
position_max
easy
[{"input": "[2,1,5,6,8,3,4,9,10,11,8,12]", "output": "[11]", "testtype": "functional"}]
Mbpp_201
Write a python function to check whether the elements in a list are same or not.
201
mbpp
0
2024-11-26T21:40:54.231531
def chkList(lst): return len(set(lst)) == 1
chkList
easy
[{"input": "['one','one','one']", "output": "True", "testtype": "functional"}]
Mbpp_201
Write a python function to check whether the elements in a list are same or not.
201
mbpp
1
2024-11-26T21:40:54.231655
def chkList(lst): return len(set(lst)) == 1
chkList
easy
[{"input": "['one','Two','Three']", "output": "False", "testtype": "functional"}]
Mbpp_201
Write a python function to check whether the elements in a list are same or not.
201
mbpp
2
2024-11-26T21:40:54.231766
def chkList(lst): return len(set(lst)) == 1
chkList
easy
[{"input": "['bigdata','python','Django']", "output": "False", "testtype": "functional"}]
Mbpp_202
Write a function to remove even characters in a string.
202
mbpp
0
2024-11-26T21:40:54.231992
def remove_even(str1): str2 = '' for i in range(1, len(str1) + 1): if(i % 2 != 0): str2 = str2 + str1[i - 1] return str2
remove_even
easy
[{"input": "\"python\"", "output": "(\"pto\")", "testtype": "functional"}]
Mbpp_202
Write a function to remove even characters in a string.
202
mbpp
1
2024-11-26T21:40:54.232213
def remove_even(str1): str2 = '' for i in range(1, len(str1) + 1): if(i % 2 != 0): str2 = str2 + str1[i - 1] return str2
remove_even
easy
[{"input": "\"program\"", "output": "(\"porm\")", "testtype": "functional"}]
Mbpp_202
Write a function to remove even characters in a string.
202
mbpp
2
2024-11-26T21:40:54.232449
def remove_even(str1): str2 = '' for i in range(1, len(str1) + 1): if(i % 2 != 0): str2 = str2 + str1[i - 1] return str2
remove_even
easy
[{"input": "\"language\"", "output": "(\"lnug\")", "testtype": "functional"}]
Mbpp_203
Write a python function to find the hamming distance between given two integers.
203
mbpp
0
2024-11-26T21:40:54.232745
def hamming_Distance(n1,n2) : x = n1 ^ n2 setBits = 0 while (x > 0) : setBits += x & 1 x >>= 1 return setBits
hamming_Distance
easy
[{"input": "4,8", "output": "2", "testtype": "functional"}]
Mbpp_203
Write a python function to find the hamming distance between given two integers.
203
mbpp
1
2024-11-26T21:40:54.232948
def hamming_Distance(n1,n2) : x = n1 ^ n2 setBits = 0 while (x > 0) : setBits += x & 1 x >>= 1 return setBits
hamming_Distance
easy
[{"input": "2,4", "output": "2", "testtype": "functional"}]
Mbpp_203
Write a python function to find the hamming distance between given two integers.
203
mbpp
2
2024-11-26T21:40:54.233136
def hamming_Distance(n1,n2) : x = n1 ^ n2 setBits = 0 while (x > 0) : setBits += x & 1 x >>= 1 return setBits
hamming_Distance
easy
[{"input": "1,2", "output": "2", "testtype": "functional"}]
Mbpp_204
Write a python function to count the occurrence of a given character in a string.
204
mbpp
0
2024-11-26T21:40:54.233347
def count(s,c) : res = 0 for i in range(len(s)) : if (s[i] == c): res = res + 1 return res
count
easy
[{"input": "\"abcc\",\"c\"", "output": "2", "testtype": "functional"}]
Mbpp_204
Write a python function to count the occurrence of a given character in a string.
204
mbpp
1
2024-11-26T21:40:54.233543
def count(s,c) : res = 0 for i in range(len(s)) : if (s[i] == c): res = res + 1 return res
count
easy
[{"input": "\"ababca\",\"a\"", "output": "3", "testtype": "functional"}]
Mbpp_204
Write a python function to count the occurrence of a given character in a string.
204
mbpp
2
2024-11-26T21:40:54.233771
def count(s,c) : res = 0 for i in range(len(s)) : if (s[i] == c): res = res + 1 return res
count
easy
[{"input": "\"mnmm0pm\",\"m\"", "output": "4", "testtype": "functional"}]
Mbpp_205
Write a function to find the inversions of tuple elements in the given tuple list.
205
mbpp
0
2024-11-26T21:40:54.233955
def inversion_elements(test_tup): res = tuple(list(map(lambda x: ~x, list(test_tup)))) return (res)
inversion_elements
easy
[{"input": "(7, 8, 9, 1, 10, 7)", "output": "(-8, -9, -10, -2, -11, -8)", "testtype": "functional"}]
Mbpp_205
Write a function to find the inversions of tuple elements in the given tuple list.
205
mbpp
1
2024-11-26T21:40:54.234126
def inversion_elements(test_tup): res = tuple(list(map(lambda x: ~x, list(test_tup)))) return (res)
inversion_elements
easy
[{"input": "(2, 4, 5, 6, 1, 7)", "output": "(-3, -5, -6, -7, -2, -8)", "testtype": "functional"}]
Mbpp_205
Write a function to find the inversions of tuple elements in the given tuple list.
205
mbpp
2
2024-11-26T21:40:54.234292
def inversion_elements(test_tup): res = tuple(list(map(lambda x: ~x, list(test_tup)))) return (res)
inversion_elements
easy
[{"input": "(8, 9, 11, 14, 12, 13)", "output": "(-9, -10, -12, -15, -13, -14)", "testtype": "functional"}]
Mbpp_206
Write a function to perform the adjacent element concatenation in the given tuples.
206
mbpp
0
2024-11-26T21:40:54.234487
def concatenate_elements(test_tup): res = tuple(i + j for i, j in zip(test_tup, test_tup[1:])) return (res)
concatenate_elements
easy
[{"input": "(\"DSP \", \"IS \", \"BEST \", \"FOR \", \"ALL \", \"UTS\")", "output": "('DSP IS ', 'IS BEST ', 'BEST FOR ', 'FOR ALL ', 'ALL UTS')", "testtype": "functional"}]
Mbpp_206
Write a function to perform the adjacent element concatenation in the given tuples.
206
mbpp
1
2024-11-26T21:40:54.234687
def concatenate_elements(test_tup): res = tuple(i + j for i, j in zip(test_tup, test_tup[1:])) return (res)
concatenate_elements
easy
[{"input": "(\"RES \", \"IS \", \"BEST \", \"FOR \", \"ALL \", \"QESR\")", "output": "('RES IS ', 'IS BEST ', 'BEST FOR ', 'FOR ALL ', 'ALL QESR')", "testtype": "functional"}]
Mbpp_206
Write a function to perform the adjacent element concatenation in the given tuples.
206
mbpp
2
2024-11-26T21:40:54.234874
def concatenate_elements(test_tup): res = tuple(i + j for i, j in zip(test_tup, test_tup[1:])) return (res)
concatenate_elements
easy
[{"input": "(\"MSAM\", \"IS \", \"BEST \", \"FOR \", \"ALL \", \"SKD\")", "output": "('MSAMIS ', 'IS BEST ', 'BEST FOR ', 'FOR ALL ', 'ALL SKD')", "testtype": "functional"}]
Mbpp_207
Write a function to count the longest repeating subsequences such that the two subsequences don’t have same string characters at same positions.
207
mbpp
0
2024-11-26T21:40:54.235506
def find_longest_repeating_subseq(str): n = len(str) dp = [[0 for k in range(n+1)] for l in range(n+1)] for i in range(1, n+1): for j in range(1, n+1): if (str[i-1] == str[j-1] and i != j): dp[i][j] = 1 + dp[i-1][j-1] else: dp[i][j] = max(dp[i][j-1], dp[i-1][j]) return dp[n][n]
find_longest_repeating_subseq
easy
[{"input": "\"AABEBCDD\"", "output": "3", "testtype": "functional"}]
Mbpp_207
Write a function to count the longest repeating subsequences such that the two subsequences don’t have same string characters at same positions.
207
mbpp
1
2024-11-26T21:40:54.236133
def find_longest_repeating_subseq(str): n = len(str) dp = [[0 for k in range(n+1)] for l in range(n+1)] for i in range(1, n+1): for j in range(1, n+1): if (str[i-1] == str[j-1] and i != j): dp[i][j] = 1 + dp[i-1][j-1] else: dp[i][j] = max(dp[i][j-1], dp[i-1][j]) return dp[n][n]
find_longest_repeating_subseq
easy
[{"input": "\"aabb\"", "output": "2", "testtype": "functional"}]
Mbpp_207
Write a function to count the longest repeating subsequences such that the two subsequences don’t have same string characters at same positions.
207
mbpp
2
2024-11-26T21:40:54.236846
def find_longest_repeating_subseq(str): n = len(str) dp = [[0 for k in range(n+1)] for l in range(n+1)] for i in range(1, n+1): for j in range(1, n+1): if (str[i-1] == str[j-1] and i != j): dp[i][j] = 1 + dp[i-1][j-1] else: dp[i][j] = max(dp[i][j-1], dp[i-1][j]) return dp[n][n]
find_longest_repeating_subseq
easy
[{"input": "\"aab\"", "output": "1", "testtype": "functional"}]
Mbpp_208
Write a function to check the given decimal with a precision of 2 by using regex.
208
mbpp
0
2024-11-26T21:40:54.237060
import re def is_decimal(num): num_fetch = re.compile(r"""^[0-9]+(\.[0-9]{1,2})?$""") result = num_fetch.search(num) return bool(result)
is_decimal
easy
[{"input": "'123.11'", "output": "True", "testtype": "functional"}]
Mbpp_208
Write a function to check the given decimal with a precision of 2 by using regex.
208
mbpp
1
2024-11-26T21:40:54.237297
import re def is_decimal(num): num_fetch = re.compile(r"""^[0-9]+(\.[0-9]{1,2})?$""") result = num_fetch.search(num) return bool(result)
is_decimal
easy
[{"input": "'0.21'", "output": "True", "testtype": "functional"}]
Mbpp_208
Write a function to check the given decimal with a precision of 2 by using regex.
208
mbpp
2
2024-11-26T21:40:54.237477
import re def is_decimal(num): num_fetch = re.compile(r"""^[0-9]+(\.[0-9]{1,2})?$""") result = num_fetch.search(num) return bool(result)
is_decimal
easy
[{"input": "'123.1214'", "output": "False", "testtype": "functional"}]
Mbpp_209
Write a function to delete the smallest element from the given heap and then insert a new item.
209
mbpp
0
2024-11-26T21:40:54.237659
import heapq as hq def heap_replace(heap,a): hq.heapify(heap) hq.heapreplace(heap, a) return heap
heap_replace
easy
[{"input": " [25, 44, 68, 21, 39, 23, 89],21", "output": "[21, 25, 23, 44, 39, 68, 89]", "testtype": "functional"}]
Mbpp_209
Write a function to delete the smallest element from the given heap and then insert a new item.
209
mbpp
1
2024-11-26T21:40:54.237817
import heapq as hq def heap_replace(heap,a): hq.heapify(heap) hq.heapreplace(heap, a) return heap
heap_replace
easy
[{"input": "[25, 44, 68, 21, 39, 23, 89],110", "output": "[23, 25, 68, 44, 39, 110, 89]", "testtype": "functional"}]
Mbpp_209
Write a function to delete the smallest element from the given heap and then insert a new item.
209
mbpp
2
2024-11-26T21:40:54.237957
import heapq as hq def heap_replace(heap,a): hq.heapify(heap) hq.heapreplace(heap, a) return heap
heap_replace
easy
[{"input": "[25, 44, 68, 21, 39, 23, 89],500", "output": "[23, 25, 68, 44, 39, 500, 89]", "testtype": "functional"}]
Mbpp_210
Write a function to check that the given string contains only a certain set of characters(in this case a-z, a-z and 0-9) by using regex.
210
mbpp
0
2024-11-26T21:40:54.238122
import re def is_allowed_specific_char(string): get_char = re.compile(r'[^a-zA-Z0-9.]') string = get_char.search(string) return not bool(string)
is_allowed_specific_char
easy
[{"input": "\"ABCDEFabcdef123450\"", "output": "True", "testtype": "functional"}]
Mbpp_210
Write a function to check that the given string contains only a certain set of characters(in this case a-z, a-z and 0-9) by using regex.
210
mbpp
1
2024-11-26T21:40:54.238446
import re def is_allowed_specific_char(string): get_char = re.compile(r'[^a-zA-Z0-9.]') string = get_char.search(string) return not bool(string)
is_allowed_specific_char
easy
[{"input": "\"*&%@#!}{\"", "output": "False", "testtype": "functional"}]
Mbpp_210
Write a function to check that the given string contains only a certain set of characters(in this case a-z, a-z and 0-9) by using regex.
210
mbpp
2
2024-11-26T21:40:54.238663
import re def is_allowed_specific_char(string): get_char = re.compile(r'[^a-zA-Z0-9.]') string = get_char.search(string) return not bool(string)
is_allowed_specific_char
easy
[{"input": "\"HELLOhowareyou98765\"", "output": "True", "testtype": "functional"}]
Mbpp_211
Write a python function to count numbers whose oth and nth bits are set.
211
mbpp
0
2024-11-26T21:40:54.238835
def count_Num(n): if (n == 1): return 1 count = pow(2,n - 2) return count
count_Num
easy
[{"input": "2", "output": "1", "testtype": "functional"}]
Mbpp_211
Write a python function to count numbers whose oth and nth bits are set.
211
mbpp
1
2024-11-26T21:40:54.238973
def count_Num(n): if (n == 1): return 1 count = pow(2,n - 2) return count
count_Num
easy
[{"input": "3", "output": "2", "testtype": "functional"}]
Mbpp_211
Write a python function to count numbers whose oth and nth bits are set.
211
mbpp
2
2024-11-26T21:40:54.239111
def count_Num(n): if (n == 1): return 1 count = pow(2,n - 2) return count
count_Num
easy
[{"input": "1", "output": "1", "testtype": "functional"}]
Mbpp_212
Write a python function to find the sum of fourth power of n natural numbers.
212
mbpp
0
2024-11-26T21:40:54.239337
import math def fourth_Power_Sum(n): sum = 0 for i in range(1,n+1) : sum = sum + (i*i*i*i) return sum
fourth_Power_Sum
easy
[{"input": "2", "output": "17", "testtype": "functional"}]
Mbpp_212
Write a python function to find the sum of fourth power of n natural numbers.
212
mbpp
1
2024-11-26T21:40:54.239532
import math def fourth_Power_Sum(n): sum = 0 for i in range(1,n+1) : sum = sum + (i*i*i*i) return sum
fourth_Power_Sum
easy
[{"input": "4", "output": "354", "testtype": "functional"}]
Mbpp_212
Write a python function to find the sum of fourth power of n natural numbers.
212
mbpp
2
2024-11-26T21:40:54.239744
import math def fourth_Power_Sum(n): sum = 0 for i in range(1,n+1) : sum = sum + (i*i*i*i) return sum
fourth_Power_Sum
easy
[{"input": "6", "output": "2275", "testtype": "functional"}]
Mbpp_213
Write a function to perform the concatenation of two string tuples.
213
mbpp
0
2024-11-26T21:40:54.239944
def concatenate_strings(test_tup1, test_tup2): res = tuple(ele1 + ele2 for ele1, ele2 in zip(test_tup1, test_tup2)) return (res)
concatenate_strings
easy
[{"input": "(\"Manjeet\", \"Nikhil\", \"Akshat\"), (\" Singh\", \" Meherwal\", \" Garg\")", "output": "('Manjeet Singh', 'Nikhil Meherwal', 'Akshat Garg')", "testtype": "functional"}]
Mbpp_213
Write a function to perform the concatenation of two string tuples.
213
mbpp
1
2024-11-26T21:40:54.240122
def concatenate_strings(test_tup1, test_tup2): res = tuple(ele1 + ele2 for ele1, ele2 in zip(test_tup1, test_tup2)) return (res)
concatenate_strings
easy
[{"input": "(\"Shaik\", \"Ayesha\", \"Sanya\"), (\" Dawood\", \" Begum\", \" Singh\")", "output": "('Shaik Dawood', 'Ayesha Begum', 'Sanya Singh')", "testtype": "functional"}]
Mbpp_213
Write a function to perform the concatenation of two string tuples.
213
mbpp
2
2024-11-26T21:40:54.240312
def concatenate_strings(test_tup1, test_tup2): res = tuple(ele1 + ele2 for ele1, ele2 in zip(test_tup1, test_tup2)) return (res)
concatenate_strings
easy
[{"input": "(\"Harpreet\", \"Priyanka\", \"Muskan\"), (\"Kour\", \" Agarwal\", \"Sethi\")", "output": "('HarpreetKour', 'Priyanka Agarwal', 'MuskanSethi')", "testtype": "functional"}]
Mbpp_214
Write a function to convert radians to degrees.
214
mbpp
0
2024-11-26T21:40:54.240477
import math def degree_radian(radian): degree = radian*(180/math.pi) return degree
degree_radian
easy
[{"input": "90", "output": "5156.620156177409", "testtype": "functional"}]
Mbpp_214
Write a function to convert radians to degrees.
214
mbpp
1
2024-11-26T21:40:54.240599
import math def degree_radian(radian): degree = radian*(180/math.pi) return degree
degree_radian
easy
[{"input": "60", "output": "3437.746770784939", "testtype": "functional"}]
Mbpp_214
Write a function to convert radians to degrees.
214
mbpp
2
2024-11-26T21:40:54.240744
import math def degree_radian(radian): degree = radian*(180/math.pi) return degree
degree_radian
easy
[{"input": "120", "output": "6875.493541569878", "testtype": "functional"}]
Mbpp_216
Write a function to check if a nested list is a subset of another nested list.
216
mbpp
0
2024-11-26T21:40:54.241455
def check_subset_list(list1, list2): l1, l2 = list1[0], list2[0] exist = True for i in list2: if i not in list1: exist = False return exist
check_subset_list
easy
[{"input": "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],[[12, 18, 23, 25, 45], [7, 11, 19, 24, 28], [1, 5, 8, 18, 15, 16]]", "output": "False", "testtype": "functional"}]
Mbpp_216
Write a function to check if a nested list is a subset of another nested list.
216
mbpp
1
2024-11-26T21:40:54.241692
def check_subset_list(list1, list2): l1, l2 = list1[0], list2[0] exist = True for i in list2: if i not in list1: exist = False return exist
check_subset_list
easy
[{"input": "[[2, 3, 1], [4, 5], [6, 8]],[[4, 5], [6, 8]]", "output": "True", "testtype": "functional"}]
Mbpp_216
Write a function to check if a nested list is a subset of another nested list.
216
mbpp
2
2024-11-26T21:40:54.241915
def check_subset_list(list1, list2): l1, l2 = list1[0], list2[0] exist = True for i in list2: if i not in list1: exist = False return exist
check_subset_list
easy
[{"input": "[['a', 'b'], ['e'], ['c', 'd']],[['g']]", "output": "False", "testtype": "functional"}]
Mbpp_217
Write a python function to find the first repeated character in a given string.
217
mbpp
0
2024-11-26T21:40:54.242103
def first_Repeated_Char(str): h = {} for ch in str: if ch in h: return ch; else: h[ch] = 0 return '\0'
first_Repeated_Char
easy
[{"input": "\"Google\"", "output": "\"o\"", "testtype": "functional"}]