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_42
Write a python function to find the sum of repeated elements in a given array.
42
mbpp
3
2024-11-26T21:40:54.105459
def find_Sum(arr,n): return sum([x for x in arr if arr.count(x) > 1])
find_Sum
easy
[{"input": "[1,1,2,3,4,5,6,3,5],9", "output": "18", "testtype": "functional"}]
Mbpp_43
Write a function to find sequences of lowercase letters joined with an underscore using regex.
43
mbpp
0
2024-11-26T21:40:54.105616
import re def text_match(text): patterns = '^[a-z]+_[a-z]+$' if re.search(patterns, text): return ('Found a match!') else: return ('Not matched!')
text_match
easy
[{"input": "\"aab_cbbbc\"", "output": "'Found a match!'", "testtype": "functional"}]
Mbpp_43
Write a function to find sequences of lowercase letters joined with an underscore using regex.
43
mbpp
1
2024-11-26T21:40:54.105777
import re def text_match(text): patterns = '^[a-z]+_[a-z]+$' if re.search(patterns, text): return ('Found a match!') else: return ('Not matched!')
text_match
easy
[{"input": "\"aab_Abbbc\"", "output": "'Not matched!'", "testtype": "functional"}]
Mbpp_43
Write a function to find sequences of lowercase letters joined with an underscore using regex.
43
mbpp
2
2024-11-26T21:40:54.105919
import re def text_match(text): patterns = '^[a-z]+_[a-z]+$' if re.search(patterns, text): return ('Found a match!') else: return ('Not matched!')
text_match
easy
[{"input": "\"Aaab_abbbc\"", "output": "'Not matched!'", "testtype": "functional"}]
Mbpp_43
Write a function to find sequences of lowercase letters joined with an underscore using regex.
43
mbpp
3
2024-11-26T21:40:54.106056
import re def text_match(text): patterns = '^[a-z]+_[a-z]+$' if re.search(patterns, text): return ('Found a match!') else: return ('Not matched!')
text_match
easy
[{"input": "\"aab-cbbbc\"", "output": "'Not matched!'", "testtype": "functional"}]
Mbpp_44
Write a function that matches a word at the beginning of a string.
44
mbpp
0
2024-11-26T21:40:54.106220
import re def text_match_string(text): patterns = '^\w+' if re.search(patterns, text): return 'Found a match!' else: return 'Not matched!'
text_match_string
easy
[{"input": "\" python\"", "output": "('Not matched!')", "testtype": "functional"}]
Mbpp_44
Write a function that matches a word at the beginning of a string.
44
mbpp
1
2024-11-26T21:40:54.106376
import re def text_match_string(text): patterns = '^\w+' if re.search(patterns, text): return 'Found a match!' else: return 'Not matched!'
text_match_string
easy
[{"input": "\"python\"", "output": "('Found a match!')", "testtype": "functional"}]
Mbpp_44
Write a function that matches a word at the beginning of a string.
44
mbpp
2
2024-11-26T21:40:54.106673
import re def text_match_string(text): patterns = '^\w+' if re.search(patterns, text): return 'Found a match!' else: return 'Not matched!'
text_match_string
easy
[{"input": "\" lang\"", "output": "('Not matched!')", "testtype": "functional"}]
Mbpp_44
Write a function that matches a word at the beginning of a string.
44
mbpp
3
2024-11-26T21:40:54.106934
import re def text_match_string(text): patterns = '^\w+' if re.search(patterns, text): return 'Found a match!' else: return 'Not matched!'
text_match_string
easy
[{"input": "\"foo\"", "output": "('Found a match!')", "testtype": "functional"}]
Mbpp_46
Write a python function to determine whether all the numbers are different from each other are not.
46
mbpp
0
2024-11-26T21:40:54.107873
def test_distinct(data): if len(data) == len(set(data)): return True else: return False;
test_distinct
easy
[{"input": "[1,5,7,9]", "output": "True", "testtype": "functional"}]
Mbpp_46
Write a python function to determine whether all the numbers are different from each other are not.
46
mbpp
1
2024-11-26T21:40:54.108049
def test_distinct(data): if len(data) == len(set(data)): return True else: return False;
test_distinct
easy
[{"input": "[2,4,5,5,7,9]", "output": "False", "testtype": "functional"}]
Mbpp_46
Write a python function to determine whether all the numbers are different from each other are not.
46
mbpp
2
2024-11-26T21:40:54.108188
def test_distinct(data): if len(data) == len(set(data)): return True else: return False;
test_distinct
easy
[{"input": "[1,2,3]", "output": "True", "testtype": "functional"}]
Mbpp_47
Write a python function to find the last digit when factorial of a divides factorial of b.
47
mbpp
0
2024-11-26T21:40:54.108491
def compute_Last_Digit(A,B): variable = 1 if (A == B): return 1 elif ((B - A) >= 5): return 0 else: for i in range(A + 1,B + 1): variable = (variable * (i % 10)) % 10 return variable % 10
compute_Last_Digit
easy
[{"input": "2,4", "output": "2", "testtype": "functional"}]
Mbpp_47
Write a python function to find the last digit when factorial of a divides factorial of b.
47
mbpp
1
2024-11-26T21:40:54.108788
def compute_Last_Digit(A,B): variable = 1 if (A == B): return 1 elif ((B - A) >= 5): return 0 else: for i in range(A + 1,B + 1): variable = (variable * (i % 10)) % 10 return variable % 10
compute_Last_Digit
easy
[{"input": "6,8", "output": "6", "testtype": "functional"}]
Mbpp_47
Write a python function to find the last digit when factorial of a divides factorial of b.
47
mbpp
2
2024-11-26T21:40:54.109071
def compute_Last_Digit(A,B): variable = 1 if (A == B): return 1 elif ((B - A) >= 5): return 0 else: for i in range(A + 1,B + 1): variable = (variable * (i % 10)) % 10 return variable % 10
compute_Last_Digit
easy
[{"input": "1,2", "output": "2", "testtype": "functional"}]
Mbpp_47
Write a python function to find the last digit when factorial of a divides factorial of b.
47
mbpp
3
2024-11-26T21:40:54.109349
def compute_Last_Digit(A,B): variable = 1 if (A == B): return 1 elif ((B - A) >= 5): return 0 else: for i in range(A + 1,B + 1): variable = (variable * (i % 10)) % 10 return variable % 10
compute_Last_Digit
easy
[{"input": "3,7", "output": "0", "testtype": "functional"}]
Mbpp_47
Write a python function to find the last digit when factorial of a divides factorial of b.
47
mbpp
4
2024-11-26T21:40:54.109654
def compute_Last_Digit(A,B): variable = 1 if (A == B): return 1 elif ((B - A) >= 5): return 0 else: for i in range(A + 1,B + 1): variable = (variable * (i % 10)) % 10 return variable % 10
compute_Last_Digit
easy
[{"input": "20,23", "output": "6", "testtype": "functional"}]
Mbpp_47
Write a python function to find the last digit when factorial of a divides factorial of b.
47
mbpp
5
2024-11-26T21:40:54.109936
def compute_Last_Digit(A,B): variable = 1 if (A == B): return 1 elif ((B - A) >= 5): return 0 else: for i in range(A + 1,B + 1): variable = (variable * (i % 10)) % 10 return variable % 10
compute_Last_Digit
easy
[{"input": "1021,1024", "output": "4", "testtype": "functional"}]
Mbpp_48
Write a python function to set all odd bits of a given number.
48
mbpp
0
2024-11-26T21:40:54.110384
def odd_bit_set_number(n): count = 0;res = 0;temp = n while temp > 0: if count % 2 == 0: res |= (1 << count) count += 1 temp >>= 1 return (n | res)
odd_bit_set_number
easy
[{"input": "10", "output": "15", "testtype": "functional"}]
Mbpp_48
Write a python function to set all odd bits of a given number.
48
mbpp
1
2024-11-26T21:40:54.110760
def odd_bit_set_number(n): count = 0;res = 0;temp = n while temp > 0: if count % 2 == 0: res |= (1 << count) count += 1 temp >>= 1 return (n | res)
odd_bit_set_number
easy
[{"input": "20", "output": "21", "testtype": "functional"}]
Mbpp_48
Write a python function to set all odd bits of a given number.
48
mbpp
2
2024-11-26T21:40:54.111028
def odd_bit_set_number(n): count = 0;res = 0;temp = n while temp > 0: if count % 2 == 0: res |= (1 << count) count += 1 temp >>= 1 return (n | res)
odd_bit_set_number
easy
[{"input": "30", "output": "31", "testtype": "functional"}]
Mbpp_49
Write a function to extract every first or specified element from a given two-dimensional list.
49
mbpp
0
2024-11-26T21:40:54.111192
def specified_element(nums, N): result = [i[N] for i in nums] return result
specified_element
easy
[{"input": "[[1, 2, 3, 2], [4, 5, 6, 2], [7, 1, 9, 5]],0", "output": "[1, 4, 7]", "testtype": "functional"}]
Mbpp_49
Write a function to extract every first or specified element from a given two-dimensional list.
49
mbpp
1
2024-11-26T21:40:54.111344
def specified_element(nums, N): result = [i[N] for i in nums] return result
specified_element
easy
[{"input": "[[1, 2, 3, 2], [4, 5, 6, 2], [7, 1, 9, 5]],2", "output": "[3, 6, 9]", "testtype": "functional"}]
Mbpp_49
Write a function to extract every first or specified element from a given two-dimensional list.
49
mbpp
2
2024-11-26T21:40:54.111473
def specified_element(nums, N): result = [i[N] for i in nums] return result
specified_element
easy
[{"input": "[[1, 2, 3, 2], [4, 5, 6, 2], [7, 1, 9, 5]],1", "output": "[2,5,1]", "testtype": "functional"}]
Mbpp_50
Write a function to find the list with minimum length using lambda function.
50
mbpp
0
2024-11-26T21:40:54.111866
def min_length_list(input_list): min_length = min(len(x) for x in input_list ) min_list = min(input_list, key = lambda i: len(i)) return(min_length, min_list)
min_length_list
easy
[{"input": "[[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]]", "output": "(1, [0])", "testtype": "functional"}]
Mbpp_50
Write a function to find the list with minimum length using lambda function.
50
mbpp
1
2024-11-26T21:40:54.112154
def min_length_list(input_list): min_length = min(len(x) for x in input_list ) min_list = min(input_list, key = lambda i: len(i)) return(min_length, min_list)
min_length_list
easy
[{"input": "[[1,2,3,4,5],[1,2,3,4],[1,2,3],[1,2],[1]]", "output": "(1,[1])", "testtype": "functional"}]
Mbpp_50
Write a function to find the list with minimum length using lambda function.
50
mbpp
2
2024-11-26T21:40:54.112380
def min_length_list(input_list): min_length = min(len(x) for x in input_list ) min_list = min(input_list, key = lambda i: len(i)) return(min_length, min_list)
min_length_list
easy
[{"input": "[[3,4,5],[6,7,8,9],[10,11,12],[1,2]]", "output": "(2,[1,2])", "testtype": "functional"}]
Mbpp_51
Write a function to print check if the triangle is equilateral or not.
51
mbpp
0
2024-11-26T21:40:54.112521
def check_equilateral(x,y,z): if x == y == z: return True else: return False
check_equilateral
easy
[{"input": "6,8,12", "output": "False", "testtype": "functional"}]
Mbpp_51
Write a function to print check if the triangle is equilateral or not.
51
mbpp
1
2024-11-26T21:40:54.112669
def check_equilateral(x,y,z): if x == y == z: return True else: return False
check_equilateral
easy
[{"input": "6,6,12", "output": "False", "testtype": "functional"}]
Mbpp_51
Write a function to print check if the triangle is equilateral or not.
51
mbpp
2
2024-11-26T21:40:54.112804
def check_equilateral(x,y,z): if x == y == z: return True else: return False
check_equilateral
easy
[{"input": "6,6,6", "output": "True", "testtype": "functional"}]
Mbpp_52
Write a function to caluclate area of a parallelogram.
52
mbpp
0
2024-11-26T21:40:54.112911
def parallelogram_area(b,h): area=b*h return area
parallelogram_area
easy
[{"input": "10,20", "output": "200", "testtype": "functional"}]
Mbpp_52
Write a function to caluclate area of a parallelogram.
52
mbpp
1
2024-11-26T21:40:54.113008
def parallelogram_area(b,h): area=b*h return area
parallelogram_area
easy
[{"input": "15,20", "output": "300", "testtype": "functional"}]
Mbpp_52
Write a function to caluclate area of a parallelogram.
52
mbpp
2
2024-11-26T21:40:54.113110
def parallelogram_area(b,h): area=b*h return area
parallelogram_area
easy
[{"input": "8,9", "output": "72", "testtype": "functional"}]
Mbpp_53
Write a python function to check whether the first and last characters of a given string are equal or not.
53
mbpp
0
2024-11-26T21:40:54.113259
def check_Equality(str): if (str[0] == str[-1]): return ("Equal") else: return ("Not Equal")
check_Equality
easy
[{"input": "\"abcda\"", "output": "\"Equal\"", "testtype": "functional"}]
Mbpp_53
Write a python function to check whether the first and last characters of a given string are equal or not.
53
mbpp
1
2024-11-26T21:40:54.113397
def check_Equality(str): if (str[0] == str[-1]): return ("Equal") else: return ("Not Equal")
check_Equality
easy
[{"input": "\"ab\"", "output": "\"Not Equal\"", "testtype": "functional"}]
Mbpp_53
Write a python function to check whether the first and last characters of a given string are equal or not.
53
mbpp
2
2024-11-26T21:40:54.113540
def check_Equality(str): if (str[0] == str[-1]): return ("Equal") else: return ("Not Equal")
check_Equality
easy
[{"input": "\"mad\"", "output": "\"Not Equal\"", "testtype": "functional"}]
Mbpp_54
Write a function to sort the given array by using counting sort.
54
mbpp
0
2024-11-26T21:40:54.114006
def counting_sort(my_list): max_value = 0 for i in range(len(my_list)): if my_list[i] > max_value: max_value = my_list[i] buckets = [0] * (max_value + 1) for i in my_list: buckets[i] += 1 i = 0 for j in range(max_value + 1): for a in range(buckets[j]): my_list[i] = j i += 1 return my_list
counting_sort
easy
[{"input": "[1,23,4,5,6,7,8]", "output": "[1, 4, 5, 6, 7, 8, 23]", "testtype": "functional"}]
Mbpp_54
Write a function to sort the given array by using counting sort.
54
mbpp
1
2024-11-26T21:40:54.114449
def counting_sort(my_list): max_value = 0 for i in range(len(my_list)): if my_list[i] > max_value: max_value = my_list[i] buckets = [0] * (max_value + 1) for i in my_list: buckets[i] += 1 i = 0 for j in range(max_value + 1): for a in range(buckets[j]): my_list[i] = j i += 1 return my_list
counting_sort
easy
[{"input": "[12, 9, 28, 33, 69, 45]", "output": "[9, 12, 28, 33, 45, 69]", "testtype": "functional"}]
Mbpp_54
Write a function to sort the given array by using counting sort.
54
mbpp
2
2024-11-26T21:40:54.114902
def counting_sort(my_list): max_value = 0 for i in range(len(my_list)): if my_list[i] > max_value: max_value = my_list[i] buckets = [0] * (max_value + 1) for i in my_list: buckets[i] += 1 i = 0 for j in range(max_value + 1): for a in range(buckets[j]): my_list[i] = j i += 1 return my_list
counting_sort
easy
[{"input": "[8, 4, 14, 3, 2, 1]", "output": "[1, 2, 3, 4, 8, 14]", "testtype": "functional"}]
Mbpp_55
Write a function to find t-nth term of geometric series.
55
mbpp
0
2024-11-26T21:40:54.115097
import math def tn_gp(a,n,r): tn = a * (math.pow(r, n - 1)) return tn
tn_gp
easy
[{"input": "1,5,2", "output": "16", "testtype": "functional"}]
Mbpp_55
Write a function to find t-nth term of geometric series.
55
mbpp
1
2024-11-26T21:40:54.115268
import math def tn_gp(a,n,r): tn = a * (math.pow(r, n - 1)) return tn
tn_gp
easy
[{"input": "1,5,4", "output": "256", "testtype": "functional"}]
Mbpp_55
Write a function to find t-nth term of geometric series.
55
mbpp
2
2024-11-26T21:40:54.115416
import math def tn_gp(a,n,r): tn = a * (math.pow(r, n - 1)) return tn
tn_gp
easy
[{"input": "2,6,3", "output": "486", "testtype": "functional"}]
Mbpp_57
Write a python function to find the largest number that can be formed with the given digits.
57
mbpp
0
2024-11-26T21:40:54.116084
def find_Max_Num(arr,n) : arr.sort(reverse = True) num = arr[0] for i in range(1,n) : num = num * 10 + arr[i] return num
find_Max_Num
easy
[{"input": "[1,2,3],3", "output": "321", "testtype": "functional"}]
Mbpp_57
Write a python function to find the largest number that can be formed with the given digits.
57
mbpp
1
2024-11-26T21:40:54.116343
def find_Max_Num(arr,n) : arr.sort(reverse = True) num = arr[0] for i in range(1,n) : num = num * 10 + arr[i] return num
find_Max_Num
easy
[{"input": "[4,5,6,1],4", "output": "6541", "testtype": "functional"}]
Mbpp_57
Write a python function to find the largest number that can be formed with the given digits.
57
mbpp
2
2024-11-26T21:40:54.116564
def find_Max_Num(arr,n) : arr.sort(reverse = True) num = arr[0] for i in range(1,n) : num = num * 10 + arr[i] return num
find_Max_Num
easy
[{"input": "[1,2,3,9],4", "output": "9321", "testtype": "functional"}]
Mbpp_58
Write a python function to check whether the given two integers have opposite sign or not.
58
mbpp
0
2024-11-26T21:40:54.116694
def opposite_Signs(x,y): return ((x ^ y) < 0);
opposite_Signs
easy
[{"input": "1,-2", "output": "True", "testtype": "functional"}]
Mbpp_58
Write a python function to check whether the given two integers have opposite sign or not.
58
mbpp
1
2024-11-26T21:40:54.116794
def opposite_Signs(x,y): return ((x ^ y) < 0);
opposite_Signs
easy
[{"input": "3,2", "output": "False", "testtype": "functional"}]
Mbpp_58
Write a python function to check whether the given two integers have opposite sign or not.
58
mbpp
2
2024-11-26T21:40:54.116887
def opposite_Signs(x,y): return ((x ^ y) < 0);
opposite_Signs
easy
[{"input": "-10,-10", "output": "False", "testtype": "functional"}]
Mbpp_59
Write a function to find the nth octagonal number.
59
mbpp
0
2024-11-26T21:40:54.116996
def is_octagonal(n): return 3 * n * n - 2 * n
is_octagonal
easy
[{"input": "5", "output": "65", "testtype": "functional"}]
Mbpp_59
Write a function to find the nth octagonal number.
59
mbpp
1
2024-11-26T21:40:54.117105
def is_octagonal(n): return 3 * n * n - 2 * n
is_octagonal
easy
[{"input": "10", "output": "280", "testtype": "functional"}]
Mbpp_59
Write a function to find the nth octagonal number.
59
mbpp
2
2024-11-26T21:40:54.117199
def is_octagonal(n): return 3 * n * n - 2 * n
is_octagonal
easy
[{"input": "15", "output": "645", "testtype": "functional"}]
Mbpp_60
Write a function to find the maximum length of the subsequence with difference between adjacent elements for the given array.
60
mbpp
0
2024-11-26T21:40:54.117721
def max_len_sub( arr, n): mls=[] max = 0 for i in range(n): mls.append(1) for i in range(n): for j in range(i): if (abs(arr[i] - arr[j]) <= 1 and mls[i] < mls[j] + 1): mls[i] = mls[j] + 1 for i in range(n): if (max < mls[i]): max = mls[i] return max
max_len_sub
easy
[{"input": "[2, 5, 6, 3, 7, 6, 5, 8], 8", "output": "5", "testtype": "functional"}]
Mbpp_60
Write a function to find the maximum length of the subsequence with difference between adjacent elements for the given array.
60
mbpp
1
2024-11-26T21:40:54.118195
def max_len_sub( arr, n): mls=[] max = 0 for i in range(n): mls.append(1) for i in range(n): for j in range(i): if (abs(arr[i] - arr[j]) <= 1 and mls[i] < mls[j] + 1): mls[i] = mls[j] + 1 for i in range(n): if (max < mls[i]): max = mls[i] return max
max_len_sub
easy
[{"input": "[-2, -1, 5, -1, 4, 0, 3], 7", "output": "4", "testtype": "functional"}]
Mbpp_60
Write a function to find the maximum length of the subsequence with difference between adjacent elements for the given array.
60
mbpp
2
2024-11-26T21:40:54.118657
def max_len_sub( arr, n): mls=[] max = 0 for i in range(n): mls.append(1) for i in range(n): for j in range(i): if (abs(arr[i] - arr[j]) <= 1 and mls[i] < mls[j] + 1): mls[i] = mls[j] + 1 for i in range(n): if (max < mls[i]): max = mls[i] return max
max_len_sub
easy
[{"input": "[9, 11, 13, 15, 18], 5", "output": "1", "testtype": "functional"}]
Mbpp_61
Write a python function to count number of substrings with the sum of digits equal to their length.
61
mbpp
0
2024-11-26T21:40:54.119047
from collections import defaultdict def count_Substrings(s,n): count,sum = 0,0 mp = defaultdict(lambda : 0) mp[0] += 1 for i in range(n): sum += ord(s[i]) - ord('0') count += mp[sum - (i + 1)] mp[sum - (i + 1)] += 1 return count
count_Substrings
easy
[{"input": "'112112',6", "output": "6", "testtype": "functional"}]
Mbpp_61
Write a python function to count number of substrings with the sum of digits equal to their length.
61
mbpp
1
2024-11-26T21:40:54.119403
from collections import defaultdict def count_Substrings(s,n): count,sum = 0,0 mp = defaultdict(lambda : 0) mp[0] += 1 for i in range(n): sum += ord(s[i]) - ord('0') count += mp[sum - (i + 1)] mp[sum - (i + 1)] += 1 return count
count_Substrings
easy
[{"input": "'111',3", "output": "6", "testtype": "functional"}]
Mbpp_61
Write a python function to count number of substrings with the sum of digits equal to their length.
61
mbpp
2
2024-11-26T21:40:54.119759
from collections import defaultdict def count_Substrings(s,n): count,sum = 0,0 mp = defaultdict(lambda : 0) mp[0] += 1 for i in range(n): sum += ord(s[i]) - ord('0') count += mp[sum - (i + 1)] mp[sum - (i + 1)] += 1 return count
count_Substrings
easy
[{"input": "'1101112',7", "output": "12", "testtype": "functional"}]
Mbpp_62
Write a python function to find smallest number in a list.
62
mbpp
0
2024-11-26T21:40:54.119850
def smallest_num(xs): return min(xs)
smallest_num
easy
[{"input": "[10, 20, 1, 45, 99]", "output": "1", "testtype": "functional"}]
Mbpp_62
Write a python function to find smallest number in a list.
62
mbpp
1
2024-11-26T21:40:54.119923
def smallest_num(xs): return min(xs)
smallest_num
easy
[{"input": "[1, 2, 3]", "output": "1", "testtype": "functional"}]
Mbpp_62
Write a python function to find smallest number in a list.
62
mbpp
2
2024-11-26T21:40:54.119993
def smallest_num(xs): return min(xs)
smallest_num
easy
[{"input": "[45, 46, 50, 60]", "output": "45", "testtype": "functional"}]
Mbpp_63
Write a function to find the maximum difference between available pairs in the given tuple list.
63
mbpp
0
2024-11-26T21:40:54.120173
def max_difference(test_list): temp = [abs(b - a) for a, b in test_list] res = max(temp) return (res)
max_difference
easy
[{"input": "[(3, 5), (1, 7), (10, 3), (1, 2)]", "output": "7", "testtype": "functional"}]
Mbpp_63
Write a function to find the maximum difference between available pairs in the given tuple list.
63
mbpp
1
2024-11-26T21:40:54.120333
def max_difference(test_list): temp = [abs(b - a) for a, b in test_list] res = max(temp) return (res)
max_difference
easy
[{"input": "[(4, 6), (2, 17), (9, 13), (11, 12)]", "output": "15", "testtype": "functional"}]
Mbpp_63
Write a function to find the maximum difference between available pairs in the given tuple list.
63
mbpp
2
2024-11-26T21:40:54.120492
def max_difference(test_list): temp = [abs(b - a) for a, b in test_list] res = max(temp) return (res)
max_difference
easy
[{"input": "[(12, 35), (21, 27), (13, 23), (41, 22)]", "output": "23", "testtype": "functional"}]
Mbpp_64
Write a function to sort a list of tuples using lambda.
64
mbpp
0
2024-11-26T21:40:54.120647
def subject_marks(subjectmarks): #subject_marks = [('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)]) subjectmarks.sort(key = lambda x: x[1]) return subjectmarks
subject_marks
easy
[{"input": "[('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)]", "output": "[('Social sciences', 82), ('English', 88), ('Science', 90), ('Maths', 97)]", "testtype": "functional"}]
Mbpp_64
Write a function to sort a list of tuples using lambda.
64
mbpp
1
2024-11-26T21:40:54.120776
def subject_marks(subjectmarks): #subject_marks = [('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)]) subjectmarks.sort(key = lambda x: x[1]) return subjectmarks
subject_marks
easy
[{"input": "[('Telugu',49),('Hindhi',54),('Social',33)]", "output": "([('Social',33),('Telugu',49),('Hindhi',54)])", "testtype": "functional"}]
Mbpp_64
Write a function to sort a list of tuples using lambda.
64
mbpp
2
2024-11-26T21:40:54.120900
def subject_marks(subjectmarks): #subject_marks = [('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)]) subjectmarks.sort(key = lambda x: x[1]) return subjectmarks
subject_marks
easy
[{"input": "[('Physics',96),('Chemistry',97),('Biology',45)]", "output": "([('Biology',45),('Physics',96),('Chemistry',97)])", "testtype": "functional"}]
Mbpp_65
Write a function of recursion list sum.
65
mbpp
0
2024-11-26T21:40:54.121128
def recursive_list_sum(data_list): total = 0 for element in data_list: if type(element) == type([]): total = total + recursive_list_sum(element) else: total = total + element return total
recursive_list_sum
easy
[{"input": "([1, 2, [3,4],[5,6]])", "output": "21", "testtype": "functional"}]
Mbpp_65
Write a function of recursion list sum.
65
mbpp
1
2024-11-26T21:40:54.121330
def recursive_list_sum(data_list): total = 0 for element in data_list: if type(element) == type([]): total = total + recursive_list_sum(element) else: total = total + element return total
recursive_list_sum
easy
[{"input": "([7, 10, [15,14],[19,41]])", "output": "106", "testtype": "functional"}]
Mbpp_65
Write a function of recursion list sum.
65
mbpp
2
2024-11-26T21:40:54.121529
def recursive_list_sum(data_list): total = 0 for element in data_list: if type(element) == type([]): total = total + recursive_list_sum(element) else: total = total + element return total
recursive_list_sum
easy
[{"input": "([10, 20, [30,40],[50,60]])", "output": "210", "testtype": "functional"}]
Mbpp_66
Write a python function to count positive numbers in a list.
66
mbpp
0
2024-11-26T21:40:54.121684
def pos_count(list): pos_count= 0 for num in list: if num >= 0: pos_count += 1 return pos_count
pos_count
easy
[{"input": "[1,-2,3,-4]", "output": "2", "testtype": "functional"}]
Mbpp_66
Write a python function to count positive numbers in a list.
66
mbpp
1
2024-11-26T21:40:54.121819
def pos_count(list): pos_count= 0 for num in list: if num >= 0: pos_count += 1 return pos_count
pos_count
easy
[{"input": "[3,4,5,-1]", "output": "3", "testtype": "functional"}]
Mbpp_66
Write a python function to count positive numbers in a list.
66
mbpp
2
2024-11-26T21:40:54.121946
def pos_count(list): pos_count= 0 for num in list: if num >= 0: pos_count += 1 return pos_count
pos_count
easy
[{"input": "[1,2,3,4]", "output": "4", "testtype": "functional"}]
Mbpp_67
Write a function to find the number of ways to partition a set of bell numbers.
67
mbpp
0
2024-11-26T21:40:54.122582
def bell_number(n): bell = [[0 for i in range(n+1)] for j in range(n+1)] bell[0][0] = 1 for i in range(1, n+1): bell[i][0] = bell[i-1][i-1] for j in range(1, i+1): bell[i][j] = bell[i-1][j-1] + bell[i][j-1] return bell[n][0]
bell_number
easy
[{"input": "2", "output": "2", "testtype": "functional"}]
Mbpp_67
Write a function to find the number of ways to partition a set of bell numbers.
67
mbpp
1
2024-11-26T21:40:54.123224
def bell_number(n): bell = [[0 for i in range(n+1)] for j in range(n+1)] bell[0][0] = 1 for i in range(1, n+1): bell[i][0] = bell[i-1][i-1] for j in range(1, i+1): bell[i][j] = bell[i-1][j-1] + bell[i][j-1] return bell[n][0]
bell_number
easy
[{"input": "10", "output": "115975", "testtype": "functional"}]
Mbpp_67
Write a function to find the number of ways to partition a set of bell numbers.
67
mbpp
2
2024-11-26T21:40:54.123771
def bell_number(n): bell = [[0 for i in range(n+1)] for j in range(n+1)] bell[0][0] = 1 for i in range(1, n+1): bell[i][0] = bell[i-1][i-1] for j in range(1, i+1): bell[i][j] = bell[i-1][j-1] + bell[i][j-1] return bell[n][0]
bell_number
easy
[{"input": "56", "output": "6775685320645824322581483068371419745979053216268760300", "testtype": "functional"}]
Mbpp_68
Write a python function to check whether the given array is monotonic or not.
68
mbpp
0
2024-11-26T21:40:54.124084
def is_Monotonic(A): return (all(A[i] <= A[i + 1] for i in range(len(A) - 1)) or all(A[i] >= A[i + 1] for i in range(len(A) - 1)))
is_Monotonic
easy
[{"input": "[6, 5, 4, 4]", "output": "True", "testtype": "functional"}]
Mbpp_68
Write a python function to check whether the given array is monotonic or not.
68
mbpp
1
2024-11-26T21:40:54.124373
def is_Monotonic(A): return (all(A[i] <= A[i + 1] for i in range(len(A) - 1)) or all(A[i] >= A[i + 1] for i in range(len(A) - 1)))
is_Monotonic
easy
[{"input": "[1, 2, 2, 3]", "output": "True", "testtype": "functional"}]
Mbpp_68
Write a python function to check whether the given array is monotonic or not.
68
mbpp
2
2024-11-26T21:40:54.124661
def is_Monotonic(A): return (all(A[i] <= A[i + 1] for i in range(len(A) - 1)) or all(A[i] >= A[i + 1] for i in range(len(A) - 1)))
is_Monotonic
easy
[{"input": "[1, 3, 2]", "output": "False", "testtype": "functional"}]
Mbpp_69
Write a function to check whether a list contains the given sublist or not.
69
mbpp
0
2024-11-26T21:40:54.125160
def is_sublist(l, s): sub_set = False if s == []: sub_set = True elif s == l: sub_set = True elif len(s) > len(l): sub_set = False else: for i in range(len(l)): if l[i] == s[0]: n = 1 while (n < len(s)) and (l[i+n] == s[n]): n += 1 if n == len(s): sub_set = True return sub_set
is_sublist
easy
[{"input": "[2,4,3,5,7],[3,7]", "output": "False", "testtype": "functional"}]
Mbpp_69
Write a function to check whether a list contains the given sublist or not.
69
mbpp
1
2024-11-26T21:40:54.125853
def is_sublist(l, s): sub_set = False if s == []: sub_set = True elif s == l: sub_set = True elif len(s) > len(l): sub_set = False else: for i in range(len(l)): if l[i] == s[0]: n = 1 while (n < len(s)) and (l[i+n] == s[n]): n += 1 if n == len(s): sub_set = True return sub_set
is_sublist
easy
[{"input": "[2,4,3,5,7],[4,3]", "output": "True", "testtype": "functional"}]
Mbpp_69
Write a function to check whether a list contains the given sublist or not.
69
mbpp
2
2024-11-26T21:40:54.126413
def is_sublist(l, s): sub_set = False if s == []: sub_set = True elif s == l: sub_set = True elif len(s) > len(l): sub_set = False else: for i in range(len(l)): if l[i] == s[0]: n = 1 while (n < len(s)) and (l[i+n] == s[n]): n += 1 if n == len(s): sub_set = True return sub_set
is_sublist
easy
[{"input": "[2,4,3,5,7],[1,6]", "output": "False", "testtype": "functional"}]
Mbpp_71
Write a function to sort a list of elements using comb sort.
71
mbpp
0
2024-11-26T21:40:54.127452
def comb_sort(nums): shrink_fact = 1.3 gaps = len(nums) swapped = True i = 0 while gaps > 1 or swapped: gaps = int(float(gaps) / shrink_fact) swapped = False i = 0 while gaps + i < len(nums): if nums[i] > nums[i+gaps]: nums[i], nums[i+gaps] = nums[i+gaps], nums[i] swapped = True i += 1 return nums
comb_sort
easy
[{"input": "[5, 15, 37, 25, 79]", "output": "[5, 15, 25, 37, 79]", "testtype": "functional"}]
Mbpp_71
Write a function to sort a list of elements using comb sort.
71
mbpp
1
2024-11-26T21:40:54.127996
def comb_sort(nums): shrink_fact = 1.3 gaps = len(nums) swapped = True i = 0 while gaps > 1 or swapped: gaps = int(float(gaps) / shrink_fact) swapped = False i = 0 while gaps + i < len(nums): if nums[i] > nums[i+gaps]: nums[i], nums[i+gaps] = nums[i+gaps], nums[i] swapped = True i += 1 return nums
comb_sort
easy
[{"input": "[41, 32, 15, 19, 22]", "output": "[15, 19, 22, 32, 41]", "testtype": "functional"}]
Mbpp_71
Write a function to sort a list of elements using comb sort.
71
mbpp
2
2024-11-26T21:40:54.128488
def comb_sort(nums): shrink_fact = 1.3 gaps = len(nums) swapped = True i = 0 while gaps > 1 or swapped: gaps = int(float(gaps) / shrink_fact) swapped = False i = 0 while gaps + i < len(nums): if nums[i] > nums[i+gaps]: nums[i], nums[i+gaps] = nums[i+gaps], nums[i] swapped = True i += 1 return nums
comb_sort
easy
[{"input": "[99, 15, 13, 47]", "output": "[13, 15, 47, 99]", "testtype": "functional"}]
Mbpp_72
Write a python function to check whether the given number can be represented as difference of two squares or not.
72
mbpp
0
2024-11-26T21:40:54.128621
def dif_Square(n): if (n % 4 != 2): return True return False
dif_Square
easy
[{"input": "5", "output": "True", "testtype": "functional"}]
Mbpp_72
Write a python function to check whether the given number can be represented as difference of two squares or not.
72
mbpp
1
2024-11-26T21:40:54.128748
def dif_Square(n): if (n % 4 != 2): return True return False
dif_Square
easy
[{"input": "10", "output": "False", "testtype": "functional"}]
Mbpp_72
Write a python function to check whether the given number can be represented as difference of two squares or not.
72
mbpp
2
2024-11-26T21:40:54.128855
def dif_Square(n): if (n % 4 != 2): return True return False
dif_Square
easy
[{"input": "15", "output": "True", "testtype": "functional"}]
Mbpp_73
Write a function to split the given string with multiple delimiters by using regex.
73
mbpp
0
2024-11-26T21:40:54.128994
import re def multiple_split(text): return (re.split('; |, |\*|\n',text))
multiple_split
easy
[{"input": "'Forces of the \\ndarkness*are coming into the play.'", "output": "['Forces of the ', 'darkness', 'are coming into the play.']", "testtype": "functional"}]
Mbpp_73
Write a function to split the given string with multiple delimiters by using regex.
73
mbpp
1
2024-11-26T21:40:54.129112
import re def multiple_split(text): return (re.split('; |, |\*|\n',text))
multiple_split
easy
[{"input": "'Mi Box runs on the \\n Latest android*which has google assistance and chromecast.'", "output": "['Mi Box runs on the ', ' Latest android', 'which has google assistance and chromecast.']", "testtype": "functional"}]
Mbpp_73
Write a function to split the given string with multiple delimiters by using regex.
73
mbpp
2
2024-11-26T21:40:54.129229
import re def multiple_split(text): return (re.split('; |, |\*|\n',text))
multiple_split
easy
[{"input": "'Certain services\\nare subjected to change*over the seperate subscriptions.'", "output": "['Certain services', 'are subjected to change', 'over the seperate subscriptions.']", "testtype": "functional"}]
Mbpp_74
Write a function to check whether it follows the sequence given in the patterns array.
74
mbpp
0
2024-11-26T21:40:54.129973
def is_samepatterns(colors, patterns): if len(colors) != len(patterns): return False sdict = {} pset = set() sset = set() for i in range(len(patterns)): pset.add(patterns[i]) sset.add(colors[i]) if patterns[i] not in sdict.keys(): sdict[patterns[i]] = [] keys = sdict[patterns[i]] keys.append(colors[i]) sdict[patterns[i]] = keys if len(pset) != len(sset): return False for values in sdict.values(): for i in range(len(values) - 1): if values[i] != values[i+1]: return False return True
is_samepatterns
easy
[{"input": "[\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"]", "output": "True", "testtype": "functional"}]
Mbpp_74
Write a function to check whether it follows the sequence given in the patterns array.
74
mbpp
1
2024-11-26T21:40:54.130701
def is_samepatterns(colors, patterns): if len(colors) != len(patterns): return False sdict = {} pset = set() sset = set() for i in range(len(patterns)): pset.add(patterns[i]) sset.add(colors[i]) if patterns[i] not in sdict.keys(): sdict[patterns[i]] = [] keys = sdict[patterns[i]] keys.append(colors[i]) sdict[patterns[i]] = keys if len(pset) != len(sset): return False for values in sdict.values(): for i in range(len(values) - 1): if values[i] != values[i+1]: return False return True
is_samepatterns
easy
[{"input": "[\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"]", "output": "False", "testtype": "functional"}]
Mbpp_74
Write a function to check whether it follows the sequence given in the patterns array.
74
mbpp
2
2024-11-26T21:40:54.131438
def is_samepatterns(colors, patterns): if len(colors) != len(patterns): return False sdict = {} pset = set() sset = set() for i in range(len(patterns)): pset.add(patterns[i]) sset.add(colors[i]) if patterns[i] not in sdict.keys(): sdict[patterns[i]] = [] keys = sdict[patterns[i]] keys.append(colors[i]) sdict[patterns[i]] = keys if len(pset) != len(sset): return False for values in sdict.values(): for i in range(len(values) - 1): if values[i] != values[i+1]: return False return True
is_samepatterns
easy
[{"input": "[\"red\",\"green\",\"greenn\"], [\"a\",\"b\"]", "output": "False", "testtype": "functional"}]
Mbpp_75
Write a function to find tuples which have all elements divisible by k from the given list of tuples.
75
mbpp
0
2024-11-26T21:40:54.131682
def find_tuples(test_list, K): res = [sub for sub in test_list if all(ele % K == 0 for ele in sub)] return (str(res))
find_tuples
easy
[{"input": "[(6, 24, 12), (7, 9, 6), (12, 18, 21)], 6", "output": "'[(6, 24, 12)]'", "testtype": "functional"}]
Mbpp_75
Write a function to find tuples which have all elements divisible by k from the given list of tuples.
75
mbpp
1
2024-11-26T21:40:54.131881
def find_tuples(test_list, K): res = [sub for sub in test_list if all(ele % K == 0 for ele in sub)] return (str(res))
find_tuples
easy
[{"input": "[(5, 25, 30), (4, 2, 3), (7, 8, 9)], 5", "output": "'[(5, 25, 30)]'", "testtype": "functional"}]
Mbpp_75
Write a function to find tuples which have all elements divisible by k from the given list of tuples.
75
mbpp
2
2024-11-26T21:40:54.132072
def find_tuples(test_list, K): res = [sub for sub in test_list if all(ele % K == 0 for ele in sub)] return (str(res))
find_tuples
easy
[{"input": "[(7, 9, 16), (8, 16, 4), (19, 17, 18)], 4", "output": "'[(8, 16, 4)]'", "testtype": "functional"}]
Mbpp_76
Write a python function to count the number of squares in a rectangle.
76
mbpp
0
2024-11-26T21:40:54.132362
def count_Squares(m,n): if(n < m): temp = m m = n n = temp return ((m * (m + 1) * (2 * m + 1) / 6 + (n - m) * m * (m + 1) / 2))
count_Squares
easy
[{"input": "4,3", "output": "20", "testtype": "functional"}]
Mbpp_76
Write a python function to count the number of squares in a rectangle.
76
mbpp
1
2024-11-26T21:40:54.132608
def count_Squares(m,n): if(n < m): temp = m m = n n = temp return ((m * (m + 1) * (2 * m + 1) / 6 + (n - m) * m * (m + 1) / 2))
count_Squares
easy
[{"input": "2,2", "output": "5", "testtype": "functional"}]
Mbpp_76
Write a python function to count the number of squares in a rectangle.
76
mbpp
2
2024-11-26T21:40:54.132906
def count_Squares(m,n): if(n < m): temp = m m = n n = temp return ((m * (m + 1) * (2 * m + 1) / 6 + (n - m) * m * (m + 1) / 2))
count_Squares
easy
[{"input": "1,1", "output": "1", "testtype": "functional"}]
Mbpp_77
Write a python function to find the difference between sum of even and odd digits.
77
mbpp
1
2024-11-26T21:40:54.134541
def is_Diff(n): return (n % 11 == 0)
is_Diff
easy
[{"input": "1212112", "output": "True", "testtype": "functional"}]