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_319
Write a function to find all five characters long word in the given string by using regex.
319
mbpp
2
2024-11-26T21:40:54.338146
import re def find_long_word(text): return (re.findall(r"\b\w{5}\b", text))
find_long_word
easy
[{"input": "'Streaming Media Player'", "output": "['Media']", "testtype": "functional"}]
Mbpp_320
Write a function to calculate the difference between the squared sum of first n natural numbers and the sum of squared first n natural numbers.
320
mbpp
0
2024-11-26T21:40:54.338387
def sum_difference(n): sumofsquares = 0 squareofsum = 0 for num in range(1, n+1): sumofsquares += num * num squareofsum += num squareofsum = squareofsum ** 2 return squareofsum - sumofsquares
sum_difference
easy
[{"input": "12", "output": "5434", "testtype": "functional"}]
Mbpp_320
Write a function to calculate the difference between the squared sum of first n natural numbers and the sum of squared first n natural numbers.
320
mbpp
1
2024-11-26T21:40:54.338616
def sum_difference(n): sumofsquares = 0 squareofsum = 0 for num in range(1, n+1): sumofsquares += num * num squareofsum += num squareofsum = squareofsum ** 2 return squareofsum - sumofsquares
sum_difference
easy
[{"input": "20", "output": "41230", "testtype": "functional"}]
Mbpp_320
Write a function to calculate the difference between the squared sum of first n natural numbers and the sum of squared first n natural numbers.
320
mbpp
2
2024-11-26T21:40:54.338866
def sum_difference(n): sumofsquares = 0 squareofsum = 0 for num in range(1, n+1): sumofsquares += num * num squareofsum += num squareofsum = squareofsum ** 2 return squareofsum - sumofsquares
sum_difference
easy
[{"input": "54", "output": "2151270", "testtype": "functional"}]
Mbpp_321
Write a function to find the demlo number for the given number.
321
mbpp
0
2024-11-26T21:40:54.339182
def find_demlo(s): l = len(s) res = "" for i in range(1,l+1): res = res + str(i) for i in range(l-1,0,-1): res = res + str(i) return res
find_demlo
easy
[{"input": "\"111111\"", "output": "'12345654321'", "testtype": "functional"}]
Mbpp_321
Write a function to find the demlo number for the given number.
321
mbpp
1
2024-11-26T21:40:54.339485
def find_demlo(s): l = len(s) res = "" for i in range(1,l+1): res = res + str(i) for i in range(l-1,0,-1): res = res + str(i) return res
find_demlo
easy
[{"input": "\"1111\"", "output": "'1234321'", "testtype": "functional"}]
Mbpp_321
Write a function to find the demlo number for the given number.
321
mbpp
2
2024-11-26T21:40:54.343216
def find_demlo(s): l = len(s) res = "" for i in range(1,l+1): res = res + str(i) for i in range(l-1,0,-1): res = res + str(i) return res
find_demlo
easy
[{"input": "\"13333122222\"", "output": "'123456789101110987654321'", "testtype": "functional"}]
Mbpp_322
Write a function to find all index positions of the minimum values in a given list.
322
mbpp
0
2024-11-26T21:40:54.343524
def position_min(list1): min_val = min(list1) min_result = [i for i, j in enumerate(list1) if j == min_val] return min_result
position_min
easy
[{"input": "[12,33,23,10,67,89,45,667,23,12,11,10,54]", "output": "[3,11]", "testtype": "functional"}]
Mbpp_322
Write a function to find all index positions of the minimum values in a given list.
322
mbpp
1
2024-11-26T21:40:54.343734
def position_min(list1): min_val = min(list1) min_result = [i for i, j in enumerate(list1) if j == min_val] return min_result
position_min
easy
[{"input": "[1,2,2,2,4,4,4,5,5,5,5]", "output": "[0]", "testtype": "functional"}]
Mbpp_322
Write a function to find all index positions of the minimum values in a given list.
322
mbpp
2
2024-11-26T21:40:54.343917
def position_min(list1): min_val = min(list1) min_result = [i for i, j in enumerate(list1) if j == min_val] return min_result
position_min
easy
[{"input": "[2,1,5,6,8,3,4,9,10,11,8,12]", "output": "[1]", "testtype": "functional"}]
Mbpp_324
Write a function to extract the sum of alternate chains of tuples.
324
mbpp
0
2024-11-26T21:40:54.345320
def sum_of_alternates(test_tuple): sum1 = 0 sum2 = 0 for idx, ele in enumerate(test_tuple): if idx % 2: sum1 += ele else: sum2 += ele return ((sum1),(sum2))
sum_of_alternates
easy
[{"input": "(5, 6, 3, 6, 10, 34)", "output": "(46, 18)", "testtype": "functional"}]
Mbpp_324
Write a function to extract the sum of alternate chains of tuples.
324
mbpp
1
2024-11-26T21:40:54.345555
def sum_of_alternates(test_tuple): sum1 = 0 sum2 = 0 for idx, ele in enumerate(test_tuple): if idx % 2: sum1 += ele else: sum2 += ele return ((sum1),(sum2))
sum_of_alternates
easy
[{"input": "(1, 2, 3, 4, 5)", "output": "(6, 9)", "testtype": "functional"}]
Mbpp_324
Write a function to extract the sum of alternate chains of tuples.
324
mbpp
2
2024-11-26T21:40:54.345793
def sum_of_alternates(test_tuple): sum1 = 0 sum2 = 0 for idx, ele in enumerate(test_tuple): if idx % 2: sum1 += ele else: sum2 += ele return ((sum1),(sum2))
sum_of_alternates
easy
[{"input": "(6, 7, 8, 9, 4, 5)", "output": "(21, 18)", "testtype": "functional"}]
Mbpp_325
Write a python function to find the minimum number of squares whose sum is equal to a given number.
325
mbpp
0
2024-11-26T21:40:54.346101
def get_Min_Squares(n): if n <= 3: return n; res = n for x in range(1,n + 1): temp = x * x; if temp > n: break else: res = min(res,1 + get_Min_Squares(n - temp)) return res;
get_Min_Squares
easy
[{"input": "6", "output": "3", "testtype": "functional"}]
Mbpp_325
Write a python function to find the minimum number of squares whose sum is equal to a given number.
325
mbpp
1
2024-11-26T21:40:54.346397
def get_Min_Squares(n): if n <= 3: return n; res = n for x in range(1,n + 1): temp = x * x; if temp > n: break else: res = min(res,1 + get_Min_Squares(n - temp)) return res;
get_Min_Squares
easy
[{"input": "2", "output": "2", "testtype": "functional"}]
Mbpp_325
Write a python function to find the minimum number of squares whose sum is equal to a given number.
325
mbpp
2
2024-11-26T21:40:54.346684
def get_Min_Squares(n): if n <= 3: return n; res = n for x in range(1,n + 1): temp = x * x; if temp > n: break else: res = min(res,1 + get_Min_Squares(n - temp)) return res;
get_Min_Squares
easy
[{"input": "4", "output": "1", "testtype": "functional"}]
Mbpp_326
Write a function to get the word with most number of occurrences in the given strings list.
326
mbpp
0
2024-11-26T21:40:54.346949
from collections import defaultdict def most_occurrences(test_list): temp = defaultdict(int) for sub in test_list: for wrd in sub.split(): temp[wrd] += 1 res = max(temp, key=temp.get) return (str(res))
most_occurrences
easy
[{"input": "[\"UTS is best for RTF\", \"RTF love UTS\", \"UTS is best\"] ", "output": "'UTS'", "testtype": "functional"}]
Mbpp_326
Write a function to get the word with most number of occurrences in the given strings list.
326
mbpp
1
2024-11-26T21:40:54.347226
from collections import defaultdict def most_occurrences(test_list): temp = defaultdict(int) for sub in test_list: for wrd in sub.split(): temp[wrd] += 1 res = max(temp, key=temp.get) return (str(res))
most_occurrences
easy
[{"input": "[\"Its been a great year\", \"this year is so worse\", \"this year is okay\"] ", "output": "'year'", "testtype": "functional"}]
Mbpp_326
Write a function to get the word with most number of occurrences in the given strings list.
326
mbpp
2
2024-11-26T21:40:54.347486
from collections import defaultdict def most_occurrences(test_list): temp = defaultdict(int) for sub in test_list: for wrd in sub.split(): temp[wrd] += 1 res = max(temp, key=temp.get) return (str(res))
most_occurrences
easy
[{"input": "[\"Families can be reunited\", \"people can be reunited\", \"Tasks can be achieved \"] ", "output": "'can'", "testtype": "functional"}]
Mbpp_327
Write a function to print check if the triangle is isosceles or not.
327
mbpp
0
2024-11-26T21:40:54.347680
def check_isosceles(x,y,z): if x==y or y==z or z==x: return True else: return False
check_isosceles
easy
[{"input": "6,8,12", "output": "False", "testtype": "functional"}]
Mbpp_327
Write a function to print check if the triangle is isosceles or not.
327
mbpp
1
2024-11-26T21:40:54.347833
def check_isosceles(x,y,z): if x==y or y==z or z==x: return True else: return False
check_isosceles
easy
[{"input": "6,6,12", "output": "True", "testtype": "functional"}]
Mbpp_327
Write a function to print check if the triangle is isosceles or not.
327
mbpp
2
2024-11-26T21:40:54.347988
def check_isosceles(x,y,z): if x==y or y==z or z==x: return True else: return False
check_isosceles
easy
[{"input": "6,16,20", "output": "False", "testtype": "functional"}]
Mbpp_328
Write a function to rotate a given list by specified number of items to the left direction.
328
mbpp
0
2024-11-26T21:40:54.348140
def rotate_left(list1,m,n): result = list1[m:]+list1[:n] return result
rotate_left
easy
[{"input": "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],3,4", "output": "[4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4]", "testtype": "functional"}]
Mbpp_328
Write a function to rotate a given list by specified number of items to the left direction.
328
mbpp
1
2024-11-26T21:40:54.348289
def rotate_left(list1,m,n): result = list1[m:]+list1[:n] return result
rotate_left
easy
[{"input": "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],2,2", "output": "[3, 4, 5, 6, 7, 8, 9, 10, 1, 2]", "testtype": "functional"}]
Mbpp_328
Write a function to rotate a given list by specified number of items to the left direction.
328
mbpp
2
2024-11-26T21:40:54.348424
def rotate_left(list1,m,n): result = list1[m:]+list1[:n] return result
rotate_left
easy
[{"input": "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],5,2", "output": "[6, 7, 8, 9, 10, 1, 2]", "testtype": "functional"}]
Mbpp_329
Write a python function to count negative numbers in a list.
329
mbpp
0
2024-11-26T21:40:54.348675
def neg_count(list): neg_count= 0 for num in list: if num <= 0: neg_count += 1 return neg_count
neg_count
easy
[{"input": "[-1,-2,3,-4,-5]", "output": "4", "testtype": "functional"}]
Mbpp_329
Write a python function to count negative numbers in a list.
329
mbpp
1
2024-11-26T21:40:54.348836
def neg_count(list): neg_count= 0 for num in list: if num <= 0: neg_count += 1 return neg_count
neg_count
easy
[{"input": "[1,2,3]", "output": "0", "testtype": "functional"}]
Mbpp_329
Write a python function to count negative numbers in a list.
329
mbpp
2
2024-11-26T21:40:54.348980
def neg_count(list): neg_count= 0 for num in list: if num <= 0: neg_count += 1 return neg_count
neg_count
easy
[{"input": "[1,2,-3,-10,20]", "output": "2", "testtype": "functional"}]
Mbpp_330
Write a function to find all three, four, five characters long words in the given string by using regex.
330
mbpp
0
2024-11-26T21:40:54.349099
import re def find_char(text): return (re.findall(r"\b\w{3,5}\b", text))
find_char
easy
[{"input": "'For the four consumer complaints contact manager AKR reddy'", "output": "['For', 'the', 'four', 'AKR', 'reddy']", "testtype": "functional"}]
Mbpp_330
Write a function to find all three, four, five characters long words in the given string by using regex.
330
mbpp
1
2024-11-26T21:40:54.349216
import re def find_char(text): return (re.findall(r"\b\w{3,5}\b", text))
find_char
easy
[{"input": "'Certain service are subject to change MSR'", "output": "['are', 'MSR']", "testtype": "functional"}]
Mbpp_330
Write a function to find all three, four, five characters long words in the given string by using regex.
330
mbpp
2
2024-11-26T21:40:54.349319
import re def find_char(text): return (re.findall(r"\b\w{3,5}\b", text))
find_char
easy
[{"input": "'Third party legal desclaimers'", "output": "['Third', 'party', 'legal']", "testtype": "functional"}]
Mbpp_331
Write a python function to count unset bits of a given number.
331
mbpp
0
2024-11-26T21:40:54.349544
def count_unset_bits(n): count = 0 x = 1 while(x < n + 1): if ((x & n) == 0): count += 1 x = x << 1 return count
count_unset_bits
easy
[{"input": "2", "output": "1", "testtype": "functional"}]
Mbpp_331
Write a python function to count unset bits of a given number.
331
mbpp
1
2024-11-26T21:40:54.349763
def count_unset_bits(n): count = 0 x = 1 while(x < n + 1): if ((x & n) == 0): count += 1 x = x << 1 return count
count_unset_bits
easy
[{"input": "4", "output": "2", "testtype": "functional"}]
Mbpp_331
Write a python function to count unset bits of a given number.
331
mbpp
2
2024-11-26T21:40:54.349968
def count_unset_bits(n): count = 0 x = 1 while(x < n + 1): if ((x & n) == 0): count += 1 x = x << 1 return count
count_unset_bits
easy
[{"input": "6", "output": "1", "testtype": "functional"}]
Mbpp_332
Write a function to count character frequency of a given string.
332
mbpp
0
2024-11-26T21:40:54.350203
def char_frequency(str1): dict = {} for n in str1: keys = dict.keys() if n in keys: dict[n] += 1 else: dict[n] = 1 return dict
char_frequency
easy
[{"input": "'python'", "output": "{'p': 1, 'y': 1, 't': 1, 'h': 1, 'o': 1, 'n': 1}", "testtype": "functional"}]
Mbpp_332
Write a function to count character frequency of a given string.
332
mbpp
1
2024-11-26T21:40:54.350415
def char_frequency(str1): dict = {} for n in str1: keys = dict.keys() if n in keys: dict[n] += 1 else: dict[n] = 1 return dict
char_frequency
easy
[{"input": "'program'", "output": "{'p': 1, 'r': 2, 'o': 1, 'g': 1, 'a': 1, 'm': 1}", "testtype": "functional"}]
Mbpp_332
Write a function to count character frequency of a given string.
332
mbpp
2
2024-11-26T21:40:54.350627
def char_frequency(str1): dict = {} for n in str1: keys = dict.keys() if n in keys: dict[n] += 1 else: dict[n] = 1 return dict
char_frequency
easy
[{"input": "'language'", "output": "{'l': 1, 'a': 2, 'n': 1, 'g': 2, 'u': 1, 'e': 1}", "testtype": "functional"}]
Mbpp_333
Write a python function to sort a list according to the second element in sublist.
333
mbpp
0
2024-11-26T21:40:54.350791
def Sort(sub_li): sub_li.sort(key = lambda x: x[1]) return sub_li
Sort
easy
[{"input": "[['a', 10], ['b', 5], ['c', 20], ['d', 15]]", "output": "[['b', 5], ['a', 10], ['d', 15], ['c', 20]]", "testtype": "functional"}]
Mbpp_333
Write a python function to sort a list according to the second element in sublist.
333
mbpp
1
2024-11-26T21:40:54.350924
def Sort(sub_li): sub_li.sort(key = lambda x: x[1]) return sub_li
Sort
easy
[{"input": "[['452', 10], ['256', 5], ['100', 20], ['135', 15]]", "output": "[['256', 5], ['452', 10], ['135', 15], ['100', 20]]", "testtype": "functional"}]
Mbpp_333
Write a python function to sort a list according to the second element in sublist.
333
mbpp
2
2024-11-26T21:40:54.351056
def Sort(sub_li): sub_li.sort(key = lambda x: x[1]) return sub_li
Sort
easy
[{"input": "[['rishi', 10], ['akhil', 5], ['ramya', 20], ['gaur', 15]]", "output": "[['akhil', 5], ['rishi', 10], ['gaur', 15], ['ramya', 20]]", "testtype": "functional"}]
Mbpp_334
Write a python function to check whether the triangle is valid or not if sides are given.
334
mbpp
0
2024-11-26T21:40:54.351261
def check_Validity(a,b,c): if (a + b <= c) or (a + c <= b) or (b + c <= a) : return False else: return True
check_Validity
easy
[{"input": "1,2,3", "output": "False", "testtype": "functional"}]
Mbpp_334
Write a python function to check whether the triangle is valid or not if sides are given.
334
mbpp
1
2024-11-26T21:40:54.351444
def check_Validity(a,b,c): if (a + b <= c) or (a + c <= b) or (b + c <= a) : return False else: return True
check_Validity
easy
[{"input": "2,3,5", "output": "False", "testtype": "functional"}]
Mbpp_334
Write a python function to check whether the triangle is valid or not if sides are given.
334
mbpp
2
2024-11-26T21:40:54.351624
def check_Validity(a,b,c): if (a + b <= c) or (a + c <= b) or (b + c <= a) : return False else: return True
check_Validity
easy
[{"input": "7,10,5", "output": "True", "testtype": "functional"}]
Mbpp_335
Write a function to find the sum of arithmetic progression.
335
mbpp
0
2024-11-26T21:40:54.353220
def ap_sum(a,n,d): total = (n * (2 * a + (n - 1) * d)) / 2 return total
ap_sum
easy
[{"input": "1,5,2", "output": "25", "testtype": "functional"}]
Mbpp_335
Write a function to find the sum of arithmetic progression.
335
mbpp
1
2024-11-26T21:40:54.353400
def ap_sum(a,n,d): total = (n * (2 * a + (n - 1) * d)) / 2 return total
ap_sum
easy
[{"input": "2,6,4", "output": "72", "testtype": "functional"}]
Mbpp_335
Write a function to find the sum of arithmetic progression.
335
mbpp
2
2024-11-26T21:40:54.353560
def ap_sum(a,n,d): total = (n * (2 * a + (n - 1) * d)) / 2 return total
ap_sum
easy
[{"input": "1,4,5", "output": "34", "testtype": "functional"}]
Mbpp_336
Write a function to check whether the given month name contains 28 days or not.
336
mbpp
0
2024-11-26T21:40:54.353698
def check_monthnum(monthname1): if monthname1 == "February": return True else: return False
check_monthnum
easy
[{"input": "\"February\"", "output": "True", "testtype": "functional"}]
Mbpp_336
Write a function to check whether the given month name contains 28 days or not.
336
mbpp
1
2024-11-26T21:40:54.353802
def check_monthnum(monthname1): if monthname1 == "February": return True else: return False
check_monthnum
easy
[{"input": "\"January\"", "output": "False", "testtype": "functional"}]
Mbpp_336
Write a function to check whether the given month name contains 28 days or not.
336
mbpp
2
2024-11-26T21:40:54.353945
def check_monthnum(monthname1): if monthname1 == "February": return True else: return False
check_monthnum
easy
[{"input": "\"March\"", "output": "False", "testtype": "functional"}]
Mbpp_337
Write a function that matches a word at the end of a string, with optional punctuation.
337
mbpp
0
2024-11-26T21:40:54.354134
import re def text_match_word(text): patterns = '\w+\S*$' if re.search(patterns, text): return 'Found a match!' else: return 'Not matched!'
text_match_word
easy
[{"input": "\"python.\"", "output": "('Found a match!')", "testtype": "functional"}]
Mbpp_337
Write a function that matches a word at the end of a string, with optional punctuation.
337
mbpp
1
2024-11-26T21:40:54.354280
import re def text_match_word(text): patterns = '\w+\S*$' if re.search(patterns, text): return 'Found a match!' else: return 'Not matched!'
text_match_word
easy
[{"input": "\"python.\"", "output": "('Found a match!')", "testtype": "functional"}]
Mbpp_337
Write a function that matches a word at the end of a string, with optional punctuation.
337
mbpp
2
2024-11-26T21:40:54.354423
import re def text_match_word(text): patterns = '\w+\S*$' if re.search(patterns, text): return 'Found a match!' else: return 'Not matched!'
text_match_word
easy
[{"input": "\" lang .\"", "output": "('Not matched!')", "testtype": "functional"}]
Mbpp_339
Write a python function to find the maximum occuring divisor in an interval.
339
mbpp
0
2024-11-26T21:40:54.355184
def find_Divisor(x,y): if (x==y): return y return 2
find_Divisor
easy
[{"input": "2,2", "output": "2", "testtype": "functional"}]
Mbpp_339
Write a python function to find the maximum occuring divisor in an interval.
339
mbpp
1
2024-11-26T21:40:54.355300
def find_Divisor(x,y): if (x==y): return y return 2
find_Divisor
easy
[{"input": "2,5", "output": "2", "testtype": "functional"}]
Mbpp_339
Write a python function to find the maximum occuring divisor in an interval.
339
mbpp
2
2024-11-26T21:40:54.355405
def find_Divisor(x,y): if (x==y): return y return 2
find_Divisor
easy
[{"input": "5,10", "output": "2", "testtype": "functional"}]
Mbpp_340
Write a python function to find the sum of the three lowest positive numbers from a given list of numbers.
340
mbpp
0
2024-11-26T21:40:54.355562
def sum_three_smallest_nums(lst): return sum(sorted([x for x in lst if x > 0])[:3])
sum_three_smallest_nums
easy
[{"input": "[10,20,30,40,50,60,7]", "output": "37", "testtype": "functional"}]
Mbpp_340
Write a python function to find the sum of the three lowest positive numbers from a given list of numbers.
340
mbpp
1
2024-11-26T21:40:54.355732
def sum_three_smallest_nums(lst): return sum(sorted([x for x in lst if x > 0])[:3])
sum_three_smallest_nums
easy
[{"input": "[1,2,3,4,5]", "output": "6", "testtype": "functional"}]
Mbpp_340
Write a python function to find the sum of the three lowest positive numbers from a given list of numbers.
340
mbpp
2
2024-11-26T21:40:54.355876
def sum_three_smallest_nums(lst): return sum(sorted([x for x in lst if x > 0])[:3])
sum_three_smallest_nums
easy
[{"input": "[0,1,2,3,4,5]", "output": "6", "testtype": "functional"}]
Mbpp_341
Write a function to convert the given set into ordered tuples.
341
mbpp
0
2024-11-26T21:40:54.355988
def set_to_tuple(s): t = tuple(sorted(s)) return (t)
set_to_tuple
easy
[{"input": "{1, 2, 3, 4, 5}", "output": "(1, 2, 3, 4, 5)", "testtype": "functional"}]
Mbpp_341
Write a function to convert the given set into ordered tuples.
341
mbpp
1
2024-11-26T21:40:54.356114
def set_to_tuple(s): t = tuple(sorted(s)) return (t)
set_to_tuple
easy
[{"input": "{6, 7, 8, 9, 10, 11}", "output": "(6, 7, 8, 9, 10, 11)", "testtype": "functional"}]
Mbpp_341
Write a function to convert the given set into ordered tuples.
341
mbpp
2
2024-11-26T21:40:54.356344
def set_to_tuple(s): t = tuple(sorted(s)) return (t)
set_to_tuple
easy
[{"input": "{12, 13, 14, 15, 16}", "output": "(12, 13, 14, 15, 16)", "testtype": "functional"}]
Mbpp_343
Write a function to calculate the number of digits and letters in a string.
343
mbpp
0
2024-11-26T21:40:54.358235
def dig_let(s): d=l=0 for c in s: if c.isdigit(): d=d+1 elif c.isalpha(): l=l+1 else: pass return (l,d)
dig_let
easy
[{"input": "\"python\"", "output": "(6,0)", "testtype": "functional"}]
Mbpp_343
Write a function to calculate the number of digits and letters in a string.
343
mbpp
1
2024-11-26T21:40:54.358490
def dig_let(s): d=l=0 for c in s: if c.isdigit(): d=d+1 elif c.isalpha(): l=l+1 else: pass return (l,d)
dig_let
easy
[{"input": "\"program\"", "output": "(7,0)", "testtype": "functional"}]
Mbpp_343
Write a function to calculate the number of digits and letters in a string.
343
mbpp
2
2024-11-26T21:40:54.358756
def dig_let(s): d=l=0 for c in s: if c.isdigit(): d=d+1 elif c.isalpha(): l=l+1 else: pass return (l,d)
dig_let
easy
[{"input": "\"python3.0\"", "output": "(6,2)", "testtype": "functional"}]
Mbpp_344
Write a python function to find number of elements with odd factors in a given range.
344
mbpp
0
2024-11-26T21:40:54.358895
def count_Odd_Squares(n,m): return int(m**0.5) - int((n-1)**0.5)
count_Odd_Squares
easy
[{"input": "5,100", "output": "8", "testtype": "functional"}]
Mbpp_344
Write a python function to find number of elements with odd factors in a given range.
344
mbpp
1
2024-11-26T21:40:54.359033
def count_Odd_Squares(n,m): return int(m**0.5) - int((n-1)**0.5)
count_Odd_Squares
easy
[{"input": "8,65", "output": "6", "testtype": "functional"}]
Mbpp_344
Write a python function to find number of elements with odd factors in a given range.
344
mbpp
2
2024-11-26T21:40:54.359178
def count_Odd_Squares(n,m): return int(m**0.5) - int((n-1)**0.5)
count_Odd_Squares
easy
[{"input": "2,5", "output": "1", "testtype": "functional"}]
Mbpp_345
Write a function to find the difference between two consecutive numbers in a given list.
345
mbpp
0
2024-11-26T21:40:54.359387
def diff_consecutivenums(nums): result = [b-a for a, b in zip(nums[:-1], nums[1:])] return result
diff_consecutivenums
easy
[{"input": "[1, 1, 3, 4, 4, 5, 6, 7]", "output": "[0, 2, 1, 0, 1, 1, 1]", "testtype": "functional"}]
Mbpp_345
Write a function to find the difference between two consecutive numbers in a given list.
345
mbpp
1
2024-11-26T21:40:54.359577
def diff_consecutivenums(nums): result = [b-a for a, b in zip(nums[:-1], nums[1:])] return result
diff_consecutivenums
easy
[{"input": "[4, 5, 8, 9, 6, 10]", "output": "[1, 3, 1, -3, 4]", "testtype": "functional"}]
Mbpp_345
Write a function to find the difference between two consecutive numbers in a given list.
345
mbpp
2
2024-11-26T21:40:54.359800
def diff_consecutivenums(nums): result = [b-a for a, b in zip(nums[:-1], nums[1:])] return result
diff_consecutivenums
easy
[{"input": "[0, 1, 2, 3, 4, 4, 4, 4, 5, 7]", "output": "[1, 1, 1, 1, 0, 0, 0, 1, 2]", "testtype": "functional"}]
Mbpp_346
Write a function to find entringer number e(n, k).
346
mbpp
0
2024-11-26T21:40:54.360048
def zigzag(n, k): if (n == 0 and k == 0): return 1 if (k == 0): return 0 return zigzag(n, k - 1) + zigzag(n - 1, n - k)
zigzag
easy
[{"input": "4, 3", "output": "5", "testtype": "functional"}]
Mbpp_346
Write a function to find entringer number e(n, k).
346
mbpp
1
2024-11-26T21:40:54.360309
def zigzag(n, k): if (n == 0 and k == 0): return 1 if (k == 0): return 0 return zigzag(n, k - 1) + zigzag(n - 1, n - k)
zigzag
easy
[{"input": "4, 2", "output": "4", "testtype": "functional"}]
Mbpp_346
Write a function to find entringer number e(n, k).
346
mbpp
2
2024-11-26T21:40:54.360549
def zigzag(n, k): if (n == 0 and k == 0): return 1 if (k == 0): return 0 return zigzag(n, k - 1) + zigzag(n - 1, n - k)
zigzag
easy
[{"input": "3, 1", "output": "1", "testtype": "functional"}]
Mbpp_347
Write a python function to count the number of squares in a rectangle.
347
mbpp
0
2024-11-26T21:40:54.360810
def count_Squares(m,n): if (n < m): temp = m m = n n = temp return n * (n + 1) * (3 * m - n + 1) // 6
count_Squares
easy
[{"input": "4,3", "output": "20", "testtype": "functional"}]
Mbpp_347
Write a python function to count the number of squares in a rectangle.
347
mbpp
1
2024-11-26T21:40:54.361032
def count_Squares(m,n): if (n < m): temp = m m = n n = temp return n * (n + 1) * (3 * m - n + 1) // 6
count_Squares
easy
[{"input": "1,2", "output": "2", "testtype": "functional"}]
Mbpp_347
Write a python function to count the number of squares in a rectangle.
347
mbpp
2
2024-11-26T21:40:54.361847
def count_Squares(m,n): if (n < m): temp = m m = n n = temp return n * (n + 1) * (3 * m - n + 1) // 6
count_Squares
easy
[{"input": "2,2", "output": "5", "testtype": "functional"}]
Mbpp_349
Write a python function to check whether the given string is a binary string or not.
349
mbpp
0
2024-11-26T21:40:54.363024
def check(string) : p = set(string) s = {'0', '1'} if s == p or p == {'0'} or p == {'1'}: return ("Yes") else : return ("No")
check
easy
[{"input": "\"01010101010\"", "output": "\"Yes\"", "testtype": "functional"}]
Mbpp_349
Write a python function to check whether the given string is a binary string or not.
349
mbpp
1
2024-11-26T21:40:54.363403
def check(string) : p = set(string) s = {'0', '1'} if s == p or p == {'0'} or p == {'1'}: return ("Yes") else : return ("No")
check
easy
[{"input": "\"name0\"", "output": "\"No\"", "testtype": "functional"}]
Mbpp_349
Write a python function to check whether the given string is a binary string or not.
349
mbpp
2
2024-11-26T21:40:54.364608
def check(string) : p = set(string) s = {'0', '1'} if s == p or p == {'0'} or p == {'1'}: return ("Yes") else : return ("No")
check
easy
[{"input": "\"101\"", "output": "\"Yes\"", "testtype": "functional"}]
Mbpp_350
Write a python function to minimize the length of the string by removing occurrence of only one character.
350
mbpp
0
2024-11-26T21:40:54.365063
def minimum_Length(s) : maxOcc = 0 n = len(s) arr = [0]*26 for i in range(n) : arr[ord(s[i]) -ord('a')] += 1 for i in range(26) : if arr[i] > maxOcc : maxOcc = arr[i] return n - maxOcc
minimum_Length
easy
[{"input": "\"mnm\"", "output": "1", "testtype": "functional"}]
Mbpp_350
Write a python function to minimize the length of the string by removing occurrence of only one character.
350
mbpp
1
2024-11-26T21:40:54.365683
def minimum_Length(s) : maxOcc = 0 n = len(s) arr = [0]*26 for i in range(n) : arr[ord(s[i]) -ord('a')] += 1 for i in range(26) : if arr[i] > maxOcc : maxOcc = arr[i] return n - maxOcc
minimum_Length
easy
[{"input": "\"abcda\"", "output": "3", "testtype": "functional"}]
Mbpp_350
Write a python function to minimize the length of the string by removing occurrence of only one character.
350
mbpp
2
2024-11-26T21:40:54.366239
def minimum_Length(s) : maxOcc = 0 n = len(s) arr = [0]*26 for i in range(n) : arr[ord(s[i]) -ord('a')] += 1 for i in range(26) : if arr[i] > maxOcc : maxOcc = arr[i] return n - maxOcc
minimum_Length
easy
[{"input": "\"abcb\"", "output": "2", "testtype": "functional"}]
Mbpp_351
Write a python function to find the first element occurring k times in a given array.
351
mbpp
0
2024-11-26T21:40:54.366776
def first_Element(arr,n,k): count_map = {}; for i in range(0, n): if(arr[i] in count_map.keys()): count_map[arr[i]] += 1 else: count_map[arr[i]] = 1 i += 1 for i in range(0, n): if (count_map[arr[i]] == k): return arr[i] i += 1 return -1
first_Element
easy
[{"input": "[0,1,2,3,4,5],6,1", "output": "0", "testtype": "functional"}]
Mbpp_351
Write a python function to find the first element occurring k times in a given array.
351
mbpp
1
2024-11-26T21:40:54.367301
def first_Element(arr,n,k): count_map = {}; for i in range(0, n): if(arr[i] in count_map.keys()): count_map[arr[i]] += 1 else: count_map[arr[i]] = 1 i += 1 for i in range(0, n): if (count_map[arr[i]] == k): return arr[i] i += 1 return -1
first_Element
easy
[{"input": "[1,2,1,3,4],5,2", "output": "1", "testtype": "functional"}]
Mbpp_351
Write a python function to find the first element occurring k times in a given array.
351
mbpp
2
2024-11-26T21:40:54.368149
def first_Element(arr,n,k): count_map = {}; for i in range(0, n): if(arr[i] in count_map.keys()): count_map[arr[i]] += 1 else: count_map[arr[i]] = 1 i += 1 for i in range(0, n): if (count_map[arr[i]] == k): return arr[i] i += 1 return -1
first_Element
easy
[{"input": "[2,3,4,3,5,7,1,2,3,5],10,2", "output": "2", "testtype": "functional"}]
Mbpp_352
Write a python function to check whether all the characters in a given string are unique.
352
mbpp
0
2024-11-26T21:40:54.368485
def unique_Characters(str): for i in range(len(str)): for j in range(i + 1,len(str)): if (str[i] == str[j]): return False; return True;
unique_Characters
easy
[{"input": "'aba'", "output": "False", "testtype": "functional"}]
Mbpp_352
Write a python function to check whether all the characters in a given string are unique.
352
mbpp
1
2024-11-26T21:40:54.368794
def unique_Characters(str): for i in range(len(str)): for j in range(i + 1,len(str)): if (str[i] == str[j]): return False; return True;
unique_Characters
easy
[{"input": "'abc'", "output": "True", "testtype": "functional"}]
Mbpp_352
Write a python function to check whether all the characters in a given string are unique.
352
mbpp
2
2024-11-26T21:40:54.369041
def unique_Characters(str): for i in range(len(str)): for j in range(i + 1,len(str)): if (str[i] == str[j]): return False; return True;
unique_Characters
easy
[{"input": "'abab'", "output": "False", "testtype": "functional"}]
Mbpp_353
Write a function to remove a specified column from a given nested list.
353
mbpp
0
2024-11-26T21:40:54.369189
def remove_column(list1, n): for i in list1: del i[n] return list1
remove_column
easy
[{"input": "[[1, 2, 3], [2, 4, 5], [1, 1, 1]],0", "output": "[[2, 3], [4, 5], [1, 1]]", "testtype": "functional"}]
Mbpp_353
Write a function to remove a specified column from a given nested list.
353
mbpp
1
2024-11-26T21:40:54.369314
def remove_column(list1, n): for i in list1: del i[n] return list1
remove_column
easy
[{"input": "[[1, 2, 3], [-2, 4, -5], [1, -1, 1]],2", "output": "[[1, 2], [-2, 4], [1, -1]]", "testtype": "functional"}]
Mbpp_353
Write a function to remove a specified column from a given nested list.
353
mbpp
2
2024-11-26T21:40:54.369435
def remove_column(list1, n): for i in list1: del i[n] return list1
remove_column
easy
[{"input": "[[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]],0", "output": "[[3], [7], [3], [15, 17], [7], [11]]", "testtype": "functional"}]
Mbpp_354
Write a function to find t-nth term of arithemetic progression.
354
mbpp
0
2024-11-26T21:40:54.369570
def tn_ap(a,n,d): tn = a + (n - 1) * d return tn
tn_ap
easy
[{"input": "1,5,2", "output": "9", "testtype": "functional"}]
Mbpp_354
Write a function to find t-nth term of arithemetic progression.
354
mbpp
1
2024-11-26T21:40:54.369724
def tn_ap(a,n,d): tn = a + (n - 1) * d return tn
tn_ap
easy
[{"input": "2,6,4", "output": "22", "testtype": "functional"}]
Mbpp_354
Write a function to find t-nth term of arithemetic progression.
354
mbpp
2
2024-11-26T21:40:54.369857
def tn_ap(a,n,d): tn = a + (n - 1) * d return tn
tn_ap
easy
[{"input": "1,4,5", "output": "16", "testtype": "functional"}]
Mbpp_355
Write a python function to count the number of rectangles in a circle of radius r.
355
mbpp
0
2024-11-26T21:40:54.370210
def count_Rectangles(radius): rectangles = 0 diameter = 2 * radius diameterSquare = diameter * diameter for a in range(1, 2 * radius): for b in range(1, 2 * radius): diagnalLengthSquare = (a * a + b * b) if (diagnalLengthSquare <= diameterSquare) : rectangles += 1 return rectangles
count_Rectangles
easy
[{"input": "2", "output": "8", "testtype": "functional"}]
Mbpp_355
Write a python function to count the number of rectangles in a circle of radius r.
355
mbpp
1
2024-11-26T21:40:54.370541
def count_Rectangles(radius): rectangles = 0 diameter = 2 * radius diameterSquare = diameter * diameter for a in range(1, 2 * radius): for b in range(1, 2 * radius): diagnalLengthSquare = (a * a + b * b) if (diagnalLengthSquare <= diameterSquare) : rectangles += 1 return rectangles
count_Rectangles
easy
[{"input": "1", "output": "1", "testtype": "functional"}]
Mbpp_355
Write a python function to count the number of rectangles in a circle of radius r.
355
mbpp
2
2024-11-26T21:40:54.370924
def count_Rectangles(radius): rectangles = 0 diameter = 2 * radius diameterSquare = diameter * diameter for a in range(1, 2 * radius): for b in range(1, 2 * radius): diagnalLengthSquare = (a * a + b * b) if (diagnalLengthSquare <= diameterSquare) : rectangles += 1 return rectangles
count_Rectangles
easy
[{"input": "0", "output": "0", "testtype": "functional"}]
Mbpp_356
Write a function to find the third angle of a triangle using two angles.
356
mbpp
0
2024-11-26T21:40:54.371062
def find_angle(a,b): c = 180 - (a + b) return c
find_angle
easy
[{"input": "47,89", "output": "44", "testtype": "functional"}]
Mbpp_356
Write a function to find the third angle of a triangle using two angles.
356
mbpp
1
2024-11-26T21:40:54.371471
def find_angle(a,b): c = 180 - (a + b) return c
find_angle
easy
[{"input": "45,95", "output": "40", "testtype": "functional"}]
Mbpp_356
Write a function to find the third angle of a triangle using two angles.
356
mbpp
2
2024-11-26T21:40:54.371593
def find_angle(a,b): c = 180 - (a + b) return c
find_angle
easy
[{"input": "50,40", "output": "90", "testtype": "functional"}]