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_77 | Write a python function to find the difference between sum of even and odd digits. | 77 | mbpp | 2 | 2024-11-26T21:40:54.134707 | def is_Diff(n):
return (n % 11 == 0) | is_Diff | easy | [{"input": "1212", "output": "False", "testtype": "functional"}] |
Mbpp_78 | Write a python function to find number of integers with odd number of set bits. | 78 | mbpp | 0 | 2024-11-26T21:40:54.135024 | def count_With_Odd_SetBits(n):
if (n % 2 != 0):
return (n + 1) / 2
count = bin(n).count('1')
ans = n / 2
if (count % 2 != 0):
ans += 1
return ans | count_With_Odd_SetBits | easy | [{"input": "5", "output": "3", "testtype": "functional"}] |
Mbpp_78 | Write a python function to find number of integers with odd number of set bits. | 78 | mbpp | 1 | 2024-11-26T21:40:54.135312 | def count_With_Odd_SetBits(n):
if (n % 2 != 0):
return (n + 1) / 2
count = bin(n).count('1')
ans = n / 2
if (count % 2 != 0):
ans += 1
return ans | count_With_Odd_SetBits | easy | [{"input": "10", "output": "5", "testtype": "functional"}] |
Mbpp_78 | Write a python function to find number of integers with odd number of set bits. | 78 | mbpp | 2 | 2024-11-26T21:40:54.135602 | def count_With_Odd_SetBits(n):
if (n % 2 != 0):
return (n + 1) / 2
count = bin(n).count('1')
ans = n / 2
if (count % 2 != 0):
ans += 1
return ans | count_With_Odd_SetBits | easy | [{"input": "15", "output": "8", "testtype": "functional"}] |
Mbpp_79 | Write a python function to check whether the length of the word is odd or not. | 79 | mbpp | 0 | 2024-11-26T21:40:54.135839 | def word_len(s):
s = s.split(' ')
for word in s:
if len(word)%2!=0:
return True
else:
return False | word_len | easy | [{"input": "\"Hadoop\"", "output": "False", "testtype": "functional"}] |
Mbpp_79 | Write a python function to check whether the length of the word is odd or not. | 79 | mbpp | 1 | 2024-11-26T21:40:54.136030 | def word_len(s):
s = s.split(' ')
for word in s:
if len(word)%2!=0:
return True
else:
return False | word_len | easy | [{"input": "\"great\"", "output": "True", "testtype": "functional"}] |
Mbpp_79 | Write a python function to check whether the length of the word is odd or not. | 79 | mbpp | 2 | 2024-11-26T21:40:54.136219 | def word_len(s):
s = s.split(' ')
for word in s:
if len(word)%2!=0:
return True
else:
return False | word_len | easy | [{"input": "\"structure\"", "output": "True", "testtype": "functional"}] |
Mbpp_80 | Write a function to find the nth tetrahedral number. | 80 | mbpp | 0 | 2024-11-26T21:40:54.136351 | def tetrahedral_number(n):
return (n * (n + 1) * (n + 2)) / 6 | tetrahedral_number | easy | [{"input": "5", "output": "35.0", "testtype": "functional"}] |
Mbpp_80 | Write a function to find the nth tetrahedral number. | 80 | mbpp | 1 | 2024-11-26T21:40:54.136466 | def tetrahedral_number(n):
return (n * (n + 1) * (n + 2)) / 6 | tetrahedral_number | easy | [{"input": "6", "output": "56.0", "testtype": "functional"}] |
Mbpp_80 | Write a function to find the nth tetrahedral number. | 80 | mbpp | 2 | 2024-11-26T21:40:54.136586 | def tetrahedral_number(n):
return (n * (n + 1) * (n + 2)) / 6 | tetrahedral_number | easy | [{"input": "7", "output": "84.0", "testtype": "functional"}] |
Mbpp_81 | Write a function to zip the two given tuples. | 81 | mbpp | 0 | 2024-11-26T21:40:54.136862 | def zip_tuples(test_tup1, test_tup2):
res = []
for i, j in enumerate(test_tup1):
res.append((j, test_tup2[i % len(test_tup2)]))
return (res) | zip_tuples | easy | [{"input": "(7, 8, 4, 5, 9, 10),(1, 5, 6) ", "output": "[(7, 1), (8, 5), (4, 6), (5, 1), (9, 5), (10, 6)]", "testtype": "functional"}] |
Mbpp_81 | Write a function to zip the two given tuples. | 81 | mbpp | 1 | 2024-11-26T21:40:54.137095 | def zip_tuples(test_tup1, test_tup2):
res = []
for i, j in enumerate(test_tup1):
res.append((j, test_tup2[i % len(test_tup2)]))
return (res) | zip_tuples | easy | [{"input": "(8, 9, 5, 6, 10, 11),(2, 6, 7) ", "output": "[(8, 2), (9, 6), (5, 7), (6, 2), (10, 6), (11, 7)]", "testtype": "functional"}] |
Mbpp_81 | Write a function to zip the two given tuples. | 81 | mbpp | 2 | 2024-11-26T21:40:54.137321 | def zip_tuples(test_tup1, test_tup2):
res = []
for i, j in enumerate(test_tup1):
res.append((j, test_tup2[i % len(test_tup2)]))
return (res) | zip_tuples | easy | [{"input": "(9, 10, 6, 7, 11, 12),(3, 7, 8) ", "output": "[(9, 3), (10, 7), (6, 8), (7, 3), (11, 7), (12, 8)]", "testtype": "functional"}] |
Mbpp_82 | Write a function to find the volume of a sphere. | 82 | mbpp | 0 | 2024-11-26T21:40:54.137499 | import math
def volume_sphere(r):
volume=(4/3)*math.pi*r*r*r
return volume | volume_sphere | easy | [{"input": "10", "output": "4188.790204786391", "testtype": "functional"}] |
Mbpp_82 | Write a function to find the volume of a sphere. | 82 | mbpp | 1 | 2024-11-26T21:40:54.137665 | import math
def volume_sphere(r):
volume=(4/3)*math.pi*r*r*r
return volume | volume_sphere | easy | [{"input": "25", "output": "65449.84694978735", "testtype": "functional"}] |
Mbpp_82 | Write a function to find the volume of a sphere. | 82 | mbpp | 2 | 2024-11-26T21:40:54.137816 | import math
def volume_sphere(r):
volume=(4/3)*math.pi*r*r*r
return volume | volume_sphere | easy | [{"input": "20", "output": "33510.32163829113", "testtype": "functional"}] |
Mbpp_83 | Write a python function to find the character made by adding all the characters of the given string. | 83 | mbpp | 0 | 2024-11-26T21:40:54.138175 | def get_Char(strr):
summ = 0
for i in range(len(strr)):
summ += (ord(strr[i]) - ord('a') + 1)
if (summ % 26 == 0):
return ord('z')
else:
summ = summ % 26
return chr(ord('a') + summ - 1) | get_Char | easy | [{"input": "\"abc\"", "output": "\"f\"", "testtype": "functional"}] |
Mbpp_83 | Write a python function to find the character made by adding all the characters of the given string. | 83 | mbpp | 1 | 2024-11-26T21:40:54.138506 | def get_Char(strr):
summ = 0
for i in range(len(strr)):
summ += (ord(strr[i]) - ord('a') + 1)
if (summ % 26 == 0):
return ord('z')
else:
summ = summ % 26
return chr(ord('a') + summ - 1) | get_Char | easy | [{"input": "\"gfg\"", "output": "\"t\"", "testtype": "functional"}] |
Mbpp_83 | Write a python function to find the character made by adding all the characters of the given string. | 83 | mbpp | 2 | 2024-11-26T21:40:54.138875 | def get_Char(strr):
summ = 0
for i in range(len(strr)):
summ += (ord(strr[i]) - ord('a') + 1)
if (summ % 26 == 0):
return ord('z')
else:
summ = summ % 26
return chr(ord('a') + summ - 1) | get_Char | easy | [{"input": "\"ab\"", "output": "\"c\"", "testtype": "functional"}] |
Mbpp_84 | Write a function to find the n-th number in newman conway sequence. | 84 | mbpp | 0 | 2024-11-26T21:40:54.139117 | def sequence(n):
if n == 1 or n == 2:
return 1
else:
return sequence(sequence(n-1)) + sequence(n-sequence(n-1)) | sequence | easy | [{"input": "10", "output": "6", "testtype": "functional"}] |
Mbpp_84 | Write a function to find the n-th number in newman conway sequence. | 84 | mbpp | 1 | 2024-11-26T21:40:54.139330 | def sequence(n):
if n == 1 or n == 2:
return 1
else:
return sequence(sequence(n-1)) + sequence(n-sequence(n-1)) | sequence | easy | [{"input": "2", "output": "1", "testtype": "functional"}] |
Mbpp_84 | Write a function to find the n-th number in newman conway sequence. | 84 | mbpp | 2 | 2024-11-26T21:40:54.139530 | def sequence(n):
if n == 1 or n == 2:
return 1
else:
return sequence(sequence(n-1)) + sequence(n-sequence(n-1)) | sequence | easy | [{"input": "3", "output": "2", "testtype": "functional"}] |
Mbpp_85 | Write a function to find the surface area of a sphere. | 85 | mbpp | 0 | 2024-11-26T21:40:54.139690 | import math
def surfacearea_sphere(r):
surfacearea=4*math.pi*r*r
return surfacearea | surfacearea_sphere | easy | [{"input": "10", "output": "1256.6370614359173", "testtype": "functional"}] |
Mbpp_85 | Write a function to find the surface area of a sphere. | 85 | mbpp | 1 | 2024-11-26T21:40:54.139815 | import math
def surfacearea_sphere(r):
surfacearea=4*math.pi*r*r
return surfacearea | surfacearea_sphere | easy | [{"input": "15", "output": "2827.4333882308138", "testtype": "functional"}] |
Mbpp_85 | Write a function to find the surface area of a sphere. | 85 | mbpp | 2 | 2024-11-26T21:40:54.139941 | import math
def surfacearea_sphere(r):
surfacearea=4*math.pi*r*r
return surfacearea | surfacearea_sphere | easy | [{"input": "20", "output": "5026.548245743669", "testtype": "functional"}] |
Mbpp_86 | Write a function to find nth centered hexagonal number. | 86 | mbpp | 0 | 2024-11-26T21:40:54.140044 | def centered_hexagonal_number(n):
return 3 * n * (n - 1) + 1 | centered_hexagonal_number | easy | [{"input": "10", "output": "271", "testtype": "functional"}] |
Mbpp_86 | Write a function to find nth centered hexagonal number. | 86 | mbpp | 1 | 2024-11-26T21:40:54.140165 | def centered_hexagonal_number(n):
return 3 * n * (n - 1) + 1 | centered_hexagonal_number | easy | [{"input": "2", "output": "7", "testtype": "functional"}] |
Mbpp_86 | Write a function to find nth centered hexagonal number. | 86 | mbpp | 2 | 2024-11-26T21:40:54.140259 | def centered_hexagonal_number(n):
return 3 * n * (n - 1) + 1 | centered_hexagonal_number | easy | [{"input": "9", "output": "217", "testtype": "functional"}] |
Mbpp_87 | Write a function to merge three dictionaries into a single expression. | 87 | mbpp | 0 | 2024-11-26T21:40:54.140448 | import collections as ct
def merge_dictionaries_three(dict1,dict2, dict3):
merged_dict = dict(ct.ChainMap({},dict1,dict2,dict3))
return merged_dict | merge_dictionaries_three | easy | [{"input": "{ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" },{ \"O\": \"Orange\", \"W\": \"White\", \"B\": \"Black\" }", "output": "{'B': 'Black', 'R': 'Red', 'P': 'Pink', 'G': 'Green', 'W': 'White', 'O': 'Orange'}", "testtype": "functional"}] |
Mbpp_87 | Write a function to merge three dictionaries into a single expression. | 87 | mbpp | 1 | 2024-11-26T21:40:54.140610 | import collections as ct
def merge_dictionaries_three(dict1,dict2, dict3):
merged_dict = dict(ct.ChainMap({},dict1,dict2,dict3))
return merged_dict | merge_dictionaries_three | easy | [{"input": "{ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" },{\"L\":\"lavender\",\"B\":\"Blue\"}", "output": "{'W': 'White', 'P': 'Pink', 'B': 'Black', 'R': 'Red', 'G': 'Green', 'L': 'lavender'}", "testtype": "functional"}] |
Mbpp_87 | Write a function to merge three dictionaries into a single expression. | 87 | mbpp | 2 | 2024-11-26T21:40:54.140820 | import collections as ct
def merge_dictionaries_three(dict1,dict2, dict3):
merged_dict = dict(ct.ChainMap({},dict1,dict2,dict3))
return merged_dict | merge_dictionaries_three | easy | [{"input": "{ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" },{\"L\":\"lavender\",\"B\":\"Blue\"},{ \"G\": \"Green\", \"W\": \"White\" }", "output": "{'B': 'Black', 'P': 'Pink', 'R': 'Red', 'G': 'Green', 'L': 'lavender', 'W': 'White'}", "testtype": "functional"}] |
Mbpp_88 | Write a function to get the frequency of the elements in a list. | 88 | mbpp | 0 | 2024-11-26T21:40:54.140948 | import collections
def freq_count(list1):
freq_count= collections.Counter(list1)
return freq_count | freq_count | easy | [{"input": "[10,10,10,10,20,20,20,20,40,40,50,50,30]", "output": "({10: 4, 20: 4, 40: 2, 50: 2, 30: 1})", "testtype": "functional"}] |
Mbpp_88 | Write a function to get the frequency of the elements in a list. | 88 | mbpp | 1 | 2024-11-26T21:40:54.141062 | import collections
def freq_count(list1):
freq_count= collections.Counter(list1)
return freq_count | freq_count | easy | [{"input": "[1,2,3,4,3,2,4,1,3,1,4]", "output": "({1:3, 2:2,3:3,4:3})", "testtype": "functional"}] |
Mbpp_88 | Write a function to get the frequency of the elements in a list. | 88 | mbpp | 2 | 2024-11-26T21:40:54.141185 | import collections
def freq_count(list1):
freq_count= collections.Counter(list1)
return freq_count | freq_count | easy | [{"input": "[5,6,7,4,9,10,4,5,6,7,9,5]", "output": "({10:1,5:3,6:2,7:2,4:2,9:2})", "testtype": "functional"}] |
Mbpp_89 | Write a function to find the closest smaller number than n. | 89 | mbpp | 0 | 2024-11-26T21:40:54.141279 | def closest_num(N):
return (N - 1) | closest_num | easy | [{"input": "11", "output": "10", "testtype": "functional"}] |
Mbpp_89 | Write a function to find the closest smaller number than n. | 89 | mbpp | 1 | 2024-11-26T21:40:54.141355 | def closest_num(N):
return (N - 1) | closest_num | easy | [{"input": "7", "output": "6", "testtype": "functional"}] |
Mbpp_89 | Write a function to find the closest smaller number than n. | 89 | mbpp | 2 | 2024-11-26T21:40:54.141432 | def closest_num(N):
return (N - 1) | closest_num | easy | [{"input": "12", "output": "11", "testtype": "functional"}] |
Mbpp_90 | Write a python function to find the length of the longest word. | 90 | mbpp | 0 | 2024-11-26T21:40:54.141648 | def len_log(list1):
max=len(list1[0])
for i in list1:
if len(i)>max:
max=len(i)
return max | len_log | easy | [{"input": "[\"python\",\"PHP\",\"bigdata\"]", "output": "7", "testtype": "functional"}] |
Mbpp_90 | Write a python function to find the length of the longest word. | 90 | mbpp | 1 | 2024-11-26T21:40:54.141860 | def len_log(list1):
max=len(list1[0])
for i in list1:
if len(i)>max:
max=len(i)
return max | len_log | easy | [{"input": "[\"a\",\"ab\",\"abc\"]", "output": "3", "testtype": "functional"}] |
Mbpp_90 | Write a python function to find the length of the longest word. | 90 | mbpp | 2 | 2024-11-26T21:40:54.142058 | def len_log(list1):
max=len(list1[0])
for i in list1:
if len(i)>max:
max=len(i)
return max | len_log | easy | [{"input": "[\"small\",\"big\",\"tall\"]", "output": "5", "testtype": "functional"}] |
Mbpp_91 | Write a function to check if a substring is present in a given list of string values. | 91 | mbpp | 0 | 2024-11-26T21:40:54.142244 | def find_substring(str1, sub_str):
if any(sub_str in s for s in str1):
return True
return False | find_substring | easy | [{"input": "[\"red\", \"black\", \"white\", \"green\", \"orange\"],\"ack\"", "output": "True", "testtype": "functional"}] |
Mbpp_91 | Write a function to check if a substring is present in a given list of string values. | 91 | mbpp | 1 | 2024-11-26T21:40:54.142396 | def find_substring(str1, sub_str):
if any(sub_str in s for s in str1):
return True
return False | find_substring | easy | [{"input": "[\"red\", \"black\", \"white\", \"green\", \"orange\"],\"abc\"", "output": "False", "testtype": "functional"}] |
Mbpp_91 | Write a function to check if a substring is present in a given list of string values. | 91 | mbpp | 2 | 2024-11-26T21:40:54.142542 | def find_substring(str1, sub_str):
if any(sub_str in s for s in str1):
return True
return False | find_substring | easy | [{"input": "[\"red\", \"black\", \"white\", \"green\", \"orange\"],\"ange\"", "output": "True", "testtype": "functional"}] |
Mbpp_92 | Write a function to check whether the given number is undulating or not. | 92 | mbpp | 0 | 2024-11-26T21:40:54.142803 | def is_undulating(n):
if (len(n) <= 2):
return False
for i in range(2, len(n)):
if (n[i - 2] != n[i]):
return False
return True | is_undulating | easy | [{"input": "\"1212121\"", "output": "True", "testtype": "functional"}] |
Mbpp_92 | Write a function to check whether the given number is undulating or not. | 92 | mbpp | 1 | 2024-11-26T21:40:54.143063 | def is_undulating(n):
if (len(n) <= 2):
return False
for i in range(2, len(n)):
if (n[i - 2] != n[i]):
return False
return True | is_undulating | easy | [{"input": "\"1991\"", "output": "False", "testtype": "functional"}] |
Mbpp_92 | Write a function to check whether the given number is undulating or not. | 92 | mbpp | 2 | 2024-11-26T21:40:54.143318 | def is_undulating(n):
if (len(n) <= 2):
return False
for i in range(2, len(n)):
if (n[i - 2] != n[i]):
return False
return True | is_undulating | easy | [{"input": "\"121\"", "output": "True", "testtype": "functional"}] |
Mbpp_93 | Write a function to calculate the value of 'a' to the power 'b'. | 93 | mbpp | 0 | 2024-11-26T21:40:54.143542 | def power(a,b):
if b==0:
return 1
elif a==0:
return 0
elif b==1:
return a
else:
return a*power(a,b-1) | power | easy | [{"input": "3,4", "output": "81", "testtype": "functional"}] |
Mbpp_93 | Write a function to calculate the value of 'a' to the power 'b'. | 93 | mbpp | 1 | 2024-11-26T21:40:54.143772 | def power(a,b):
if b==0:
return 1
elif a==0:
return 0
elif b==1:
return a
else:
return a*power(a,b-1) | power | easy | [{"input": "2,3", "output": "8", "testtype": "functional"}] |
Mbpp_93 | Write a function to calculate the value of 'a' to the power 'b'. | 93 | mbpp | 2 | 2024-11-26T21:40:54.143981 | def power(a,b):
if b==0:
return 1
elif a==0:
return 0
elif b==1:
return a
else:
return a*power(a,b-1) | power | easy | [{"input": "5,5", "output": "3125", "testtype": "functional"}] |
Mbpp_94 | Write a function to extract the index minimum value record from the given tuples. | 94 | mbpp | 0 | 2024-11-26T21:40:54.144167 | from operator import itemgetter
def index_minimum(test_list):
res = min(test_list, key = itemgetter(1))[0]
return (res) | index_minimum | easy | [{"input": "[('Rash', 143), ('Manjeet', 200), ('Varsha', 100)]", "output": "'Varsha'", "testtype": "functional"}] |
Mbpp_94 | Write a function to extract the index minimum value record from the given tuples. | 94 | mbpp | 1 | 2024-11-26T21:40:54.144319 | from operator import itemgetter
def index_minimum(test_list):
res = min(test_list, key = itemgetter(1))[0]
return (res) | index_minimum | easy | [{"input": "[('Yash', 185), ('Dawood', 125), ('Sanya', 175)]", "output": "'Dawood'", "testtype": "functional"}] |
Mbpp_94 | Write a function to extract the index minimum value record from the given tuples. | 94 | mbpp | 2 | 2024-11-26T21:40:54.144687 | from operator import itemgetter
def index_minimum(test_list):
res = min(test_list, key = itemgetter(1))[0]
return (res) | index_minimum | easy | [{"input": "[('Sai', 345), ('Salman', 145), ('Ayesha', 96)]", "output": "'Ayesha'", "testtype": "functional"}] |
Mbpp_95 | Write a python function to find the minimum length of sublist. | 95 | mbpp | 0 | 2024-11-26T21:40:54.144865 | def Find_Min_Length(lst):
minLength = min(len(x) for x in lst )
return minLength | Find_Min_Length | easy | [{"input": "[[1],[1,2]]", "output": "1", "testtype": "functional"}] |
Mbpp_95 | Write a python function to find the minimum length of sublist. | 95 | mbpp | 1 | 2024-11-26T21:40:54.145004 | def Find_Min_Length(lst):
minLength = min(len(x) for x in lst )
return minLength | Find_Min_Length | easy | [{"input": "[[1,2],[1,2,3],[1,2,3,4]]", "output": "2", "testtype": "functional"}] |
Mbpp_95 | Write a python function to find the minimum length of sublist. | 95 | mbpp | 2 | 2024-11-26T21:40:54.145158 | def Find_Min_Length(lst):
minLength = min(len(x) for x in lst )
return minLength | Find_Min_Length | easy | [{"input": "[[3,3,3],[4,4,4,4]]", "output": "3", "testtype": "functional"}] |
Mbpp_96 | Write a python function to find the number of divisors of a given integer. | 96 | mbpp | 0 | 2024-11-26T21:40:54.145384 | def divisor(n):
for i in range(n):
x = len([i for i in range(1,n+1) if not n % i])
return x | divisor | easy | [{"input": "15", "output": "4", "testtype": "functional"}] |
Mbpp_96 | Write a python function to find the number of divisors of a given integer. | 96 | mbpp | 1 | 2024-11-26T21:40:54.145592 | def divisor(n):
for i in range(n):
x = len([i for i in range(1,n+1) if not n % i])
return x | divisor | easy | [{"input": "12", "output": "6", "testtype": "functional"}] |
Mbpp_96 | Write a python function to find the number of divisors of a given integer. | 96 | mbpp | 2 | 2024-11-26T21:40:54.145852 | def divisor(n):
for i in range(n):
x = len([i for i in range(1,n+1) if not n % i])
return x | divisor | easy | [{"input": "9", "output": "3", "testtype": "functional"}] |
Mbpp_97 | Write a function to find frequency count of list of lists. | 97 | mbpp | 0 | 2024-11-26T21:40:54.146235 | def frequency_lists(list1):
list1 = [item for sublist in list1 for item in sublist]
dic_data = {}
for num in list1:
if num in dic_data.keys():
dic_data[num] += 1
else:
key = num
value = 1
dic_data[key] = value
return dic_data
| frequency_lists | easy | [{"input": "[[1, 2, 3, 2], [4, 5, 6, 2], [7, 8, 9, 5]]", "output": "{1: 1, 2: 3, 3: 1, 4: 1, 5: 2, 6: 1, 7: 1, 8: 1, 9: 1}", "testtype": "functional"}] |
Mbpp_97 | Write a function to find frequency count of list of lists. | 97 | mbpp | 1 | 2024-11-26T21:40:54.146561 | def frequency_lists(list1):
list1 = [item for sublist in list1 for item in sublist]
dic_data = {}
for num in list1:
if num in dic_data.keys():
dic_data[num] += 1
else:
key = num
value = 1
dic_data[key] = value
return dic_data
| frequency_lists | easy | [{"input": "[[1,2,3,4],[5,6,7,8],[9,10,11,12]]", "output": "{1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1,10:1,11:1,12:1}", "testtype": "functional"}] |
Mbpp_97 | Write a function to find frequency count of list of lists. | 97 | mbpp | 2 | 2024-11-26T21:40:54.146877 | def frequency_lists(list1):
list1 = [item for sublist in list1 for item in sublist]
dic_data = {}
for num in list1:
if num in dic_data.keys():
dic_data[num] += 1
else:
key = num
value = 1
dic_data[key] = value
return dic_data
| frequency_lists | easy | [{"input": "[[20,30,40,17],[18,16,14,13],[10,20,30,40]]", "output": "{20:2,30:2,40:2,17: 1,18:1, 16: 1,14: 1,13: 1, 10: 1}", "testtype": "functional"}] |
Mbpp_98 | Write a function to multiply all the numbers in a list and divide with the length of the list. | 98 | mbpp | 0 | 2024-11-26T21:40:54.147069 | def multiply_num(numbers):
total = 1
for x in numbers:
total *= x
return total/len(numbers) | multiply_num | easy | [{"input": "(8, 2, 3, -1, 7)", "output": "-67.2", "testtype": "functional"}] |
Mbpp_98 | Write a function to multiply all the numbers in a list and divide with the length of the list. | 98 | mbpp | 1 | 2024-11-26T21:40:54.147233 | def multiply_num(numbers):
total = 1
for x in numbers:
total *= x
return total/len(numbers) | multiply_num | easy | [{"input": "(-10,-20,-30)", "output": "-2000.0", "testtype": "functional"}] |
Mbpp_98 | Write a function to multiply all the numbers in a list and divide with the length of the list. | 98 | mbpp | 2 | 2024-11-26T21:40:54.147383 | def multiply_num(numbers):
total = 1
for x in numbers:
total *= x
return total/len(numbers) | multiply_num | easy | [{"input": "(19,15,18)", "output": "1710.0", "testtype": "functional"}] |
Mbpp_99 | Write a function to convert the given decimal number to its binary equivalent. | 99 | mbpp | 0 | 2024-11-26T21:40:54.147500 | def decimal_to_binary(n):
return bin(n).replace("0b","") | decimal_to_binary | easy | [{"input": "8", "output": "'1000'", "testtype": "functional"}] |
Mbpp_99 | Write a function to convert the given decimal number to its binary equivalent. | 99 | mbpp | 1 | 2024-11-26T21:40:54.147600 | def decimal_to_binary(n):
return bin(n).replace("0b","") | decimal_to_binary | easy | [{"input": "18", "output": "'10010'", "testtype": "functional"}] |
Mbpp_99 | Write a function to convert the given decimal number to its binary equivalent. | 99 | mbpp | 2 | 2024-11-26T21:40:54.147727 | def decimal_to_binary(n):
return bin(n).replace("0b","") | decimal_to_binary | easy | [{"input": "7", "output": "'111'", "testtype": "functional"}] |
Mbpp_100 | Write a function to find the next smallest palindrome of a specified number. | 100 | mbpp | 0 | 2024-11-26T21:40:54.147978 | import sys
def next_smallest_palindrome(num):
numstr = str(num)
for i in range(num+1,sys.maxsize):
if str(i) == str(i)[::-1]:
return i | next_smallest_palindrome | easy | [{"input": "99", "output": "101", "testtype": "functional"}] |
Mbpp_100 | Write a function to find the next smallest palindrome of a specified number. | 100 | mbpp | 1 | 2024-11-26T21:40:54.148226 | import sys
def next_smallest_palindrome(num):
numstr = str(num)
for i in range(num+1,sys.maxsize):
if str(i) == str(i)[::-1]:
return i | next_smallest_palindrome | easy | [{"input": "1221", "output": "1331", "testtype": "functional"}] |
Mbpp_100 | Write a function to find the next smallest palindrome of a specified number. | 100 | mbpp | 2 | 2024-11-26T21:40:54.148468 | import sys
def next_smallest_palindrome(num):
numstr = str(num)
for i in range(num+1,sys.maxsize):
if str(i) == str(i)[::-1]:
return i | next_smallest_palindrome | easy | [{"input": "120", "output": "121", "testtype": "functional"}] |
Mbpp_101 | Write a function to find the kth element in the given array. | 101 | mbpp | 0 | 2024-11-26T21:40:54.148868 | def kth_element(arr, n, k):
for i in range(n):
for j in range(0, n-i-1):
if arr[j] > arr[j+1]:
arr[j], arr[j+1] == arr[j+1], arr[j]
return arr[k-1] | kth_element | easy | [{"input": "[12,3,5,7,19], 5, 2", "output": "3", "testtype": "functional"}] |
Mbpp_101 | Write a function to find the kth element in the given array. | 101 | mbpp | 1 | 2024-11-26T21:40:54.149235 | def kth_element(arr, n, k):
for i in range(n):
for j in range(0, n-i-1):
if arr[j] > arr[j+1]:
arr[j], arr[j+1] == arr[j+1], arr[j]
return arr[k-1] | kth_element | easy | [{"input": "[17,24,8,23], 4, 3", "output": "8", "testtype": "functional"}] |
Mbpp_101 | Write a function to find the kth element in the given array. | 101 | mbpp | 2 | 2024-11-26T21:40:54.149590 | def kth_element(arr, n, k):
for i in range(n):
for j in range(0, n-i-1):
if arr[j] > arr[j+1]:
arr[j], arr[j+1] == arr[j+1], arr[j]
return arr[k-1] | kth_element | easy | [{"input": "[16,21,25,36,4], 5, 4", "output": "36", "testtype": "functional"}] |
Mbpp_102 | Write a function to convert snake case string to camel case string. | 102 | mbpp | 0 | 2024-11-26T21:40:54.149812 | def snake_to_camel(word):
import re
return ''.join(x.capitalize() or '_' for x in word.split('_')) | snake_to_camel | easy | [{"input": "'python_program'", "output": "'PythonProgram'", "testtype": "functional"}] |
Mbpp_102 | Write a function to convert snake case string to camel case string. | 102 | mbpp | 1 | 2024-11-26T21:40:54.149973 | def snake_to_camel(word):
import re
return ''.join(x.capitalize() or '_' for x in word.split('_')) | snake_to_camel | easy | [{"input": "'python_language'", "output": "('PythonLanguage')", "testtype": "functional"}] |
Mbpp_102 | Write a function to convert snake case string to camel case string. | 102 | mbpp | 2 | 2024-11-26T21:40:54.150141 | def snake_to_camel(word):
import re
return ''.join(x.capitalize() or '_' for x in word.split('_')) | snake_to_camel | easy | [{"input": "'programming_language'", "output": "('ProgrammingLanguage')", "testtype": "functional"}] |
Mbpp_103 | Write a function to find eulerian number a(n, m). | 103 | mbpp | 0 | 2024-11-26T21:40:54.150429 | def eulerian_num(n, m):
if (m >= n or n == 0):
return 0
if (m == 0):
return 1
return ((n - m) * eulerian_num(n - 1, m - 1) +(m + 1) * eulerian_num(n - 1, m)) | eulerian_num | easy | [{"input": "3, 1", "output": "4", "testtype": "functional"}] |
Mbpp_103 | Write a function to find eulerian number a(n, m). | 103 | mbpp | 1 | 2024-11-26T21:40:54.150908 | def eulerian_num(n, m):
if (m >= n or n == 0):
return 0
if (m == 0):
return 1
return ((n - m) * eulerian_num(n - 1, m - 1) +(m + 1) * eulerian_num(n - 1, m)) | eulerian_num | easy | [{"input": "4, 1", "output": "11", "testtype": "functional"}] |
Mbpp_103 | Write a function to find eulerian number a(n, m). | 103 | mbpp | 2 | 2024-11-26T21:40:54.151395 | def eulerian_num(n, m):
if (m >= n or n == 0):
return 0
if (m == 0):
return 1
return ((n - m) * eulerian_num(n - 1, m - 1) +(m + 1) * eulerian_num(n - 1, m)) | eulerian_num | easy | [{"input": "5, 3", "output": "26", "testtype": "functional"}] |
Mbpp_104 | Write a function to sort each sublist of strings in a given list of lists using lambda function. | 104 | mbpp | 0 | 2024-11-26T21:40:54.151670 | def sort_sublists(input_list):
result = [sorted(x, key = lambda x:x[0]) for x in input_list]
return result
| sort_sublists | easy | [{"input": "([\"green\", \"orange\"], [\"black\", \"white\"], [\"white\", \"black\", \"orange\"])", "output": "[['green', 'orange'], ['black', 'white'], ['black', 'orange', 'white']]", "testtype": "functional"}] |
Mbpp_104 | Write a function to sort each sublist of strings in a given list of lists using lambda function. | 104 | mbpp | 1 | 2024-11-26T21:40:54.151867 | def sort_sublists(input_list):
result = [sorted(x, key = lambda x:x[0]) for x in input_list]
return result
| sort_sublists | easy | [{"input": "([\" red \",\"green\" ],[\"blue \",\" black\"],[\" orange\",\"brown\"])", "output": "[[' red ', 'green'], [' black', 'blue '], [' orange', 'brown']]", "testtype": "functional"}] |
Mbpp_104 | Write a function to sort each sublist of strings in a given list of lists using lambda function. | 104 | mbpp | 2 | 2024-11-26T21:40:54.152047 | def sort_sublists(input_list):
result = [sorted(x, key = lambda x:x[0]) for x in input_list]
return result
| sort_sublists | easy | [{"input": "([\"zilver\",\"gold\"], [\"magnesium\",\"aluminium\"], [\"steel\", \"bronze\"])", "output": "[['gold', 'zilver'],['aluminium', 'magnesium'], ['bronze', 'steel']]", "testtype": "functional"}] |
Mbpp_105 | Write a python function to count true booleans in the given list. | 105 | mbpp | 0 | 2024-11-26T21:40:54.152163 | def count(lst):
return sum(lst) | count | easy | [{"input": "[True,False,True]", "output": "2", "testtype": "functional"}] |
Mbpp_105 | Write a python function to count true booleans in the given list. | 105 | mbpp | 1 | 2024-11-26T21:40:54.152243 | def count(lst):
return sum(lst) | count | easy | [{"input": "[False,False]", "output": "0", "testtype": "functional"}] |
Mbpp_105 | Write a python function to count true booleans in the given list. | 105 | mbpp | 2 | 2024-11-26T21:40:54.152318 | def count(lst):
return sum(lst) | count | easy | [{"input": "[True,True,True]", "output": "3", "testtype": "functional"}] |
Mbpp_106 | Write a function to add the given list to the given tuples. | 106 | mbpp | 0 | 2024-11-26T21:40:54.152453 | def add_lists(test_list, test_tup):
res = tuple(list(test_tup) + test_list)
return (res) | add_lists | easy | [{"input": "[5, 6, 7], (9, 10)", "output": "(9, 10, 5, 6, 7)", "testtype": "functional"}] |
Mbpp_106 | Write a function to add the given list to the given tuples. | 106 | mbpp | 1 | 2024-11-26T21:40:54.152581 | def add_lists(test_list, test_tup):
res = tuple(list(test_tup) + test_list)
return (res) | add_lists | easy | [{"input": "[6, 7, 8], (10, 11)", "output": "(10, 11, 6, 7, 8)", "testtype": "functional"}] |
Mbpp_106 | Write a function to add the given list to the given tuples. | 106 | mbpp | 2 | 2024-11-26T21:40:54.152769 | def add_lists(test_list, test_tup):
res = tuple(list(test_tup) + test_list)
return (res) | add_lists | easy | [{"input": "[7, 8, 9], (11, 12)", "output": "(11, 12, 7, 8, 9)", "testtype": "functional"}] |
Mbpp_107 | Write a python function to count hexadecimal numbers for a given range. | 107 | mbpp | 0 | 2024-11-26T21:40:54.153280 | def count_Hexadecimal(L,R) :
count = 0;
for i in range(L,R + 1) :
if (i >= 10 and i <= 15) :
count += 1;
elif (i > 15) :
k = i;
while (k != 0) :
if (k % 16 >= 10) :
count += 1;
k = k // 16;
return count; | count_Hexadecimal | easy | [{"input": "10,15", "output": "6", "testtype": "functional"}] |
Mbpp_107 | Write a python function to count hexadecimal numbers for a given range. | 107 | mbpp | 1 | 2024-11-26T21:40:54.153728 | def count_Hexadecimal(L,R) :
count = 0;
for i in range(L,R + 1) :
if (i >= 10 and i <= 15) :
count += 1;
elif (i > 15) :
k = i;
while (k != 0) :
if (k % 16 >= 10) :
count += 1;
k = k // 16;
return count; | count_Hexadecimal | easy | [{"input": "2,4", "output": "0", "testtype": "functional"}] |
Mbpp_107 | Write a python function to count hexadecimal numbers for a given range. | 107 | mbpp | 2 | 2024-11-26T21:40:54.154186 | def count_Hexadecimal(L,R) :
count = 0;
for i in range(L,R + 1) :
if (i >= 10 and i <= 15) :
count += 1;
elif (i > 15) :
k = i;
while (k != 0) :
if (k % 16 >= 10) :
count += 1;
k = k // 16;
return count; | count_Hexadecimal | easy | [{"input": "15,16", "output": "1", "testtype": "functional"}] |
Mbpp_108 | Write a function to merge multiple sorted inputs into a single sorted iterator using heap queue algorithm. | 108 | mbpp | 0 | 2024-11-26T21:40:54.154474 | import heapq
def merge_sorted_list(num1,num2,num3):
num1=sorted(num1)
num2=sorted(num2)
num3=sorted(num3)
result = heapq.merge(num1,num2,num3)
return list(result) | merge_sorted_list | easy | [{"input": "[25, 24, 15, 4, 5, 29, 110],[19, 20, 11, 56, 25, 233, 154],[24, 26, 54, 48]", "output": "[4, 5, 11, 15, 19, 20, 24, 24, 25, 25, 26, 29, 48, 54, 56, 110, 154, 233]", "testtype": "functional"}] |
Mbpp_108 | Write a function to merge multiple sorted inputs into a single sorted iterator using heap queue algorithm. | 108 | mbpp | 1 | 2024-11-26T21:40:54.154770 | import heapq
def merge_sorted_list(num1,num2,num3):
num1=sorted(num1)
num2=sorted(num2)
num3=sorted(num3)
result = heapq.merge(num1,num2,num3)
return list(result) | merge_sorted_list | easy | [{"input": "[1, 3, 5, 6, 8, 9], [2, 5, 7, 11], [1, 4, 7, 8, 12]", "output": "[1, 1, 2, 3, 4, 5, 5, 6, 7, 7, 8, 8, 9, 11, 12]", "testtype": "functional"}] |
Mbpp_108 | Write a function to merge multiple sorted inputs into a single sorted iterator using heap queue algorithm. | 108 | mbpp | 2 | 2024-11-26T21:40:54.155009 | import heapq
def merge_sorted_list(num1,num2,num3):
num1=sorted(num1)
num2=sorted(num2)
num3=sorted(num3)
result = heapq.merge(num1,num2,num3)
return list(result) | merge_sorted_list | easy | [{"input": "[18, 14, 10, 9, 8, 7, 9, 3, 2, 4, 1],[25, 35, 22, 85, 14, 65, 75, 25, 58],[12, 74, 9, 50, 61, 41]", "output": "[1, 2, 3, 4, 7, 8, 9, 9, 9, 10, 12, 14, 14, 18, 22, 25, 25, 35, 41, 50, 58, 61, 65, 74, 75, 85]", "testtype": "functional"}] |
Mbpp_109 | Write a python function to find the count of rotations of a binary string with odd value. | 109 | mbpp | 0 | 2024-11-26T21:40:54.155238 | def odd_Equivalent(s,n):
count=0
for i in range(0,n):
if (s[i] == '1'):
count = count + 1
return count | odd_Equivalent | easy | [{"input": "\"011001\",6", "output": "3", "testtype": "functional"}] |
Mbpp_109 | Write a python function to find the count of rotations of a binary string with odd value. | 109 | mbpp | 1 | 2024-11-26T21:40:54.155437 | def odd_Equivalent(s,n):
count=0
for i in range(0,n):
if (s[i] == '1'):
count = count + 1
return count | odd_Equivalent | easy | [{"input": "\"11011\",5", "output": "4", "testtype": "functional"}] |
Mbpp_109 | Write a python function to find the count of rotations of a binary string with odd value. | 109 | mbpp | 2 | 2024-11-26T21:40:54.155658 | def odd_Equivalent(s,n):
count=0
for i in range(0,n):
if (s[i] == '1'):
count = count + 1
return count | odd_Equivalent | easy | [{"input": "\"1010\",4", "output": "2", "testtype": "functional"}] |
Mbpp_110 | Write a function to extract the ranges that are missing from the given list with the given start range and end range values. | 110 | mbpp | 0 | 2024-11-26T21:40:54.155998 | def extract_missing(test_list, strt_val, stop_val):
res = []
for sub in test_list:
if sub[0] > strt_val:
res.append((strt_val, sub[0]))
strt_val = sub[1]
if strt_val < stop_val:
res.append((strt_val, stop_val))
return (res) | extract_missing | easy | [{"input": "[(6, 9), (15, 34), (48, 70)], 2, 100", "output": "[(2, 6), (9, 100), (9, 15), (34, 100), (34, 48), (70, 100)]", "testtype": "functional"}] |
Mbpp_110 | Write a function to extract the ranges that are missing from the given list with the given start range and end range values. | 110 | mbpp | 1 | 2024-11-26T21:40:54.156340 | def extract_missing(test_list, strt_val, stop_val):
res = []
for sub in test_list:
if sub[0] > strt_val:
res.append((strt_val, sub[0]))
strt_val = sub[1]
if strt_val < stop_val:
res.append((strt_val, stop_val))
return (res) | extract_missing | easy | [{"input": "[(7, 2), (15, 19), (38, 50)], 5, 60", "output": "[(5, 7), (2, 60), (2, 15), (19, 60), (19, 38), (50, 60)]", "testtype": "functional"}] |
Mbpp_110 | Write a function to extract the ranges that are missing from the given list with the given start range and end range values. | 110 | mbpp | 2 | 2024-11-26T21:40:54.156702 | def extract_missing(test_list, strt_val, stop_val):
res = []
for sub in test_list:
if sub[0] > strt_val:
res.append((strt_val, sub[0]))
strt_val = sub[1]
if strt_val < stop_val:
res.append((strt_val, stop_val))
return (res) | extract_missing | easy | [{"input": "[(7, 2), (15, 19), (38, 50)], 1, 52", "output": "[(1, 7), (2, 52), (2, 15), (19, 52), (19, 38), (50, 52)]", "testtype": "functional"}] |