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_392
Write a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n).
392
mbpp
1
2024-11-26T21:40:54.396239
def get_max_sum (n): res = list() res.append(0) res.append(1) i = 2 while i<n + 1: res.append(max(i, (res[int(i / 2)] + res[int(i / 3)] + res[int(i / 4)] + res[int(i / 5)]))) i = i + 1 return res[n]
get_max_sum
easy
[{"input": "10", "output": "12", "testtype": "functional"}]
Mbpp_392
Write a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n).
392
mbpp
2
2024-11-26T21:40:54.396726
def get_max_sum (n): res = list() res.append(0) res.append(1) i = 2 while i<n + 1: res.append(max(i, (res[int(i / 2)] + res[int(i / 3)] + res[int(i / 4)] + res[int(i / 5)]))) i = i + 1 return res[n]
get_max_sum
easy
[{"input": "2", "output": "2", "testtype": "functional"}]
Mbpp_393
Write a function to find the list with maximum length using lambda function.
393
mbpp
0
2024-11-26T21:40:54.396986
def max_length_list(input_list): max_length = max(len(x) for x in input_list ) max_list = max(input_list, key = lambda i: len(i)) return(max_length, max_list)
max_length_list
easy
[{"input": "[[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]]", "output": "(3, [13, 15, 17])", "testtype": "functional"}]
Mbpp_393
Write a function to find the list with maximum length using lambda function.
393
mbpp
1
2024-11-26T21:40:54.397201
def max_length_list(input_list): max_length = max(len(x) for x in input_list ) max_list = max(input_list, key = lambda i: len(i)) return(max_length, max_list)
max_length_list
easy
[{"input": "[[1,2,3,4,5],[1,2,3,4],[1,2,3],[1,2],[1]]", "output": "(5,[1,2,3,4,5])", "testtype": "functional"}]
Mbpp_393
Write a function to find the list with maximum length using lambda function.
393
mbpp
2
2024-11-26T21:40:54.397419
def max_length_list(input_list): max_length = max(len(x) for x in input_list ) max_list = max(input_list, key = lambda i: len(i)) return(max_length, max_list)
max_length_list
easy
[{"input": "[[3,4,5],[6,7,8,9],[10,11,12]]", "output": "(4,[6,7,8,9])", "testtype": "functional"}]
Mbpp_394
Write a function to check if given tuple is distinct or not.
394
mbpp
0
2024-11-26T21:40:54.397704
def check_distinct(test_tup): res = True temp = set() for ele in test_tup: if ele in temp: res = False break temp.add(ele) return (res)
check_distinct
easy
[{"input": "(1, 4, 5, 6, 1, 4)", "output": "False", "testtype": "functional"}]
Mbpp_394
Write a function to check if given tuple is distinct or not.
394
mbpp
1
2024-11-26T21:40:54.397914
def check_distinct(test_tup): res = True temp = set() for ele in test_tup: if ele in temp: res = False break temp.add(ele) return (res)
check_distinct
easy
[{"input": "(1, 4, 5, 6)", "output": "True", "testtype": "functional"}]
Mbpp_394
Write a function to check if given tuple is distinct or not.
394
mbpp
2
2024-11-26T21:40:54.398124
def check_distinct(test_tup): res = True temp = set() for ele in test_tup: if ele in temp: res = False break temp.add(ele) return (res)
check_distinct
easy
[{"input": "(2, 3, 4, 5, 6)", "output": "True", "testtype": "functional"}]
Mbpp_395
Write a python function to find the first non-repeated character in a given string.
395
mbpp
0
2024-11-26T21:40:54.398454
def first_non_repeating_character(str1): char_order = [] ctr = {} for c in str1: if c in ctr: ctr[c] += 1 else: ctr[c] = 1 char_order.append(c) for c in char_order: if ctr[c] == 1: return c return None
first_non_repeating_character
easy
[{"input": "\"abcabc\"", "output": "None", "testtype": "functional"}]
Mbpp_395
Write a python function to find the first non-repeated character in a given string.
395
mbpp
1
2024-11-26T21:40:54.398874
def first_non_repeating_character(str1): char_order = [] ctr = {} for c in str1: if c in ctr: ctr[c] += 1 else: ctr[c] = 1 char_order.append(c) for c in char_order: if ctr[c] == 1: return c return None
first_non_repeating_character
easy
[{"input": "\"abc\"", "output": "\"a\"", "testtype": "functional"}]
Mbpp_395
Write a python function to find the first non-repeated character in a given string.
395
mbpp
2
2024-11-26T21:40:54.399202
def first_non_repeating_character(str1): char_order = [] ctr = {} for c in str1: if c in ctr: ctr[c] += 1 else: ctr[c] = 1 char_order.append(c) for c in char_order: if ctr[c] == 1: return c return None
first_non_repeating_character
easy
[{"input": "\"ababc\"", "output": "\"c\"", "testtype": "functional"}]
Mbpp_396
Write a function to check whether the given string starts and ends with the same character or not using regex.
396
mbpp
0
2024-11-26T21:40:54.399376
import re regex = r'^[a-z]$|^([a-z]).*\1$' def check_char(string): if(re.search(regex, string)): return "Valid" else: return "Invalid"
check_char
easy
[{"input": "\"abba\"", "output": "\"Valid\"", "testtype": "functional"}]
Mbpp_396
Write a function to check whether the given string starts and ends with the same character or not using regex.
396
mbpp
1
2024-11-26T21:40:54.399514
import re regex = r'^[a-z]$|^([a-z]).*\1$' def check_char(string): if(re.search(regex, string)): return "Valid" else: return "Invalid"
check_char
easy
[{"input": "\"a\"", "output": "\"Valid\"", "testtype": "functional"}]
Mbpp_396
Write a function to check whether the given string starts and ends with the same character or not using regex.
396
mbpp
2
2024-11-26T21:40:54.399663
import re regex = r'^[a-z]$|^([a-z]).*\1$' def check_char(string): if(re.search(regex, string)): return "Valid" else: return "Invalid"
check_char
easy
[{"input": "\"abcd\"", "output": "\"Invalid\"", "testtype": "functional"}]
Mbpp_397
Write a function to find the median of three specific numbers.
397
mbpp
0
2024-11-26T21:40:54.399948
def median_numbers(a,b,c): if a > b: if a < c: median = a elif b > c: median = b else: median = c else: if a > c: median = a elif b < c: median = b else: median = c return median
median_numbers
easy
[{"input": "25,55,65", "output": "55.0", "testtype": "functional"}]
Mbpp_397
Write a function to find the median of three specific numbers.
397
mbpp
1
2024-11-26T21:40:54.400217
def median_numbers(a,b,c): if a > b: if a < c: median = a elif b > c: median = b else: median = c else: if a > c: median = a elif b < c: median = b else: median = c return median
median_numbers
easy
[{"input": "20,10,30", "output": "20.0", "testtype": "functional"}]
Mbpp_397
Write a function to find the median of three specific numbers.
397
mbpp
2
2024-11-26T21:40:54.400506
def median_numbers(a,b,c): if a > b: if a < c: median = a elif b > c: median = b else: median = c else: if a > c: median = a elif b < c: median = b else: median = c return median
median_numbers
easy
[{"input": "15,45,75", "output": "45.0", "testtype": "functional"}]
Mbpp_398
Write a function to compute the sum of digits of each number of a given list.
398
mbpp
0
2024-11-26T21:40:54.400679
def sum_of_digits(nums): return sum(int(el) for n in nums for el in str(n) if el.isdigit())
sum_of_digits
easy
[{"input": "[10,2,56]", "output": "14", "testtype": "functional"}]
Mbpp_398
Write a function to compute the sum of digits of each number of a given list.
398
mbpp
1
2024-11-26T21:40:54.400824
def sum_of_digits(nums): return sum(int(el) for n in nums for el in str(n) if el.isdigit())
sum_of_digits
easy
[{"input": "[[10,20,4,5,'b',70,'a']]", "output": "19", "testtype": "functional"}]
Mbpp_398
Write a function to compute the sum of digits of each number of a given list.
398
mbpp
2
2024-11-26T21:40:54.400962
def sum_of_digits(nums): return sum(int(el) for n in nums for el in str(n) if el.isdigit())
sum_of_digits
easy
[{"input": "[10,20,-4,5,-70]", "output": "19", "testtype": "functional"}]
Mbpp_399
Write a function to perform the mathematical bitwise xor operation across the given tuples.
399
mbpp
0
2024-11-26T21:40:54.401132
def bitwise_xor(test_tup1, test_tup2): res = tuple(ele1 ^ ele2 for ele1, ele2 in zip(test_tup1, test_tup2)) return (res)
bitwise_xor
easy
[{"input": "(10, 4, 6, 9), (5, 2, 3, 3)", "output": "(15, 6, 5, 10)", "testtype": "functional"}]
Mbpp_399
Write a function to perform the mathematical bitwise xor operation across the given tuples.
399
mbpp
1
2024-11-26T21:40:54.401288
def bitwise_xor(test_tup1, test_tup2): res = tuple(ele1 ^ ele2 for ele1, ele2 in zip(test_tup1, test_tup2)) return (res)
bitwise_xor
easy
[{"input": "(11, 5, 7, 10), (6, 3, 4, 4)", "output": "(13, 6, 3, 14)", "testtype": "functional"}]
Mbpp_399
Write a function to perform the mathematical bitwise xor operation across the given tuples.
399
mbpp
2
2024-11-26T21:40:54.401480
def bitwise_xor(test_tup1, test_tup2): res = tuple(ele1 ^ ele2 for ele1, ele2 in zip(test_tup1, test_tup2)) return (res)
bitwise_xor
easy
[{"input": "(12, 6, 8, 11), (7, 4, 5, 6)", "output": "(11, 2, 13, 13)", "testtype": "functional"}]
Mbpp_400
Write a function to extract the frequency of unique tuples in the given list order irrespective.
400
mbpp
0
2024-11-26T21:40:54.401668
def extract_freq(test_list): res = len(list(set(tuple(sorted(sub)) for sub in test_list))) return (res)
extract_freq
easy
[{"input": "[(3, 4), (1, 2), (4, 3), (5, 6)] ", "output": "3", "testtype": "functional"}]
Mbpp_400
Write a function to extract the frequency of unique tuples in the given list order irrespective.
400
mbpp
1
2024-11-26T21:40:54.401829
def extract_freq(test_list): res = len(list(set(tuple(sorted(sub)) for sub in test_list))) return (res)
extract_freq
easy
[{"input": "[(4, 15), (2, 3), (5, 4), (6, 7)] ", "output": "4", "testtype": "functional"}]
Mbpp_400
Write a function to extract the frequency of unique tuples in the given list order irrespective.
400
mbpp
2
2024-11-26T21:40:54.401978
def extract_freq(test_list): res = len(list(set(tuple(sorted(sub)) for sub in test_list))) return (res)
extract_freq
easy
[{"input": "[(5, 16), (2, 3), (6, 5), (6, 9)] ", "output": "4", "testtype": "functional"}]
Mbpp_401
Write a function to perform index wise addition of tuple elements in the given two nested tuples.
401
mbpp
0
2024-11-26T21:40:54.402193
def add_nested_tuples(test_tup1, test_tup2): res = tuple(tuple(a + b for a, b in zip(tup1, tup2)) for tup1, tup2 in zip(test_tup1, test_tup2)) return (res)
add_nested_tuples
easy
[{"input": "((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))", "output": "((7, 10), (7, 14), (3, 10), (8, 13))", "testtype": "functional"}]
Mbpp_401
Write a function to perform index wise addition of tuple elements in the given two nested tuples.
401
mbpp
1
2024-11-26T21:40:54.402409
def add_nested_tuples(test_tup1, test_tup2): res = tuple(tuple(a + b for a, b in zip(tup1, tup2)) for tup1, tup2 in zip(test_tup1, test_tup2)) return (res)
add_nested_tuples
easy
[{"input": "((2, 4), (5, 6), (3, 10), (2, 11)), ((7, 8), (4, 10), (2, 2), (8, 4))", "output": "((9, 12), (9, 16), (5, 12), (10, 15))", "testtype": "functional"}]
Mbpp_401
Write a function to perform index wise addition of tuple elements in the given two nested tuples.
401
mbpp
2
2024-11-26T21:40:54.402614
def add_nested_tuples(test_tup1, test_tup2): res = tuple(tuple(a + b for a, b in zip(tup1, tup2)) for tup1, tup2 in zip(test_tup1, test_tup2)) return (res)
add_nested_tuples
easy
[{"input": "((3, 5), (6, 7), (4, 11), (3, 12)), ((8, 9), (5, 11), (3, 3), (9, 5))", "output": "((11, 14), (11, 18), (7, 14), (12, 17))", "testtype": "functional"}]
Mbpp_402
Write a function to compute the value of ncr%p.
402
mbpp
0
2024-11-26T21:40:54.403013
def ncr_modp(n, r, p): C = [0 for i in range(r+1)] C[0] = 1 for i in range(1, n+1): for j in range(min(i, r), 0, -1): C[j] = (C[j] + C[j-1]) % p return C[r]
ncr_modp
easy
[{"input": "10,2,13", "output": "6", "testtype": "functional"}]
Mbpp_402
Write a function to compute the value of ncr%p.
402
mbpp
1
2024-11-26T21:40:54.403365
def ncr_modp(n, r, p): C = [0 for i in range(r+1)] C[0] = 1 for i in range(1, n+1): for j in range(min(i, r), 0, -1): C[j] = (C[j] + C[j-1]) % p return C[r]
ncr_modp
easy
[{"input": "15,12,43", "output": "25", "testtype": "functional"}]
Mbpp_402
Write a function to compute the value of ncr%p.
402
mbpp
2
2024-11-26T21:40:54.403719
def ncr_modp(n, r, p): C = [0 for i in range(r+1)] C[0] = 1 for i in range(1, n+1): for j in range(min(i, r), 0, -1): C[j] = (C[j] + C[j-1]) % p return C[r]
ncr_modp
easy
[{"input": "17,9,18", "output": "10", "testtype": "functional"}]
Mbpp_403
Write a function to check if a url is valid or not using regex.
403
mbpp
0
2024-11-26T21:40:54.403997
import re def is_valid_URL(str): regex = ("((http|https)://)(www.)?" + "[a-zA-Z0-9@:%._\\+~#?&//=]" + "{2,256}\\.[a-z]" + "{2,6}\\b([-a-zA-Z0-9@:%" + "._\\+~#?&//=]*)") p = re.compile(regex) if (str == None): return False if(re.search(p, str)): return True else: return False
is_valid_URL
easy
[{"input": "\"https://www.google.com\"", "output": "True", "testtype": "functional"}]
Mbpp_403
Write a function to check if a url is valid or not using regex.
403
mbpp
1
2024-11-26T21:40:54.404247
import re def is_valid_URL(str): regex = ("((http|https)://)(www.)?" + "[a-zA-Z0-9@:%._\\+~#?&//=]" + "{2,256}\\.[a-z]" + "{2,6}\\b([-a-zA-Z0-9@:%" + "._\\+~#?&//=]*)") p = re.compile(regex) if (str == None): return False if(re.search(p, str)): return True else: return False
is_valid_URL
easy
[{"input": "\"https:/www.gmail.com\"", "output": "False", "testtype": "functional"}]
Mbpp_403
Write a function to check if a url is valid or not using regex.
403
mbpp
2
2024-11-26T21:40:54.404496
import re def is_valid_URL(str): regex = ("((http|https)://)(www.)?" + "[a-zA-Z0-9@:%._\\+~#?&//=]" + "{2,256}\\.[a-z]" + "{2,6}\\b([-a-zA-Z0-9@:%" + "._\\+~#?&//=]*)") p = re.compile(regex) if (str == None): return False if(re.search(p, str)): return True else: return False
is_valid_URL
easy
[{"input": "\"https:// www.redit.com\"", "output": "False", "testtype": "functional"}]
Mbpp_404
Write a python function to find the minimum of two numbers.
404
mbpp
0
2024-11-26T21:40:54.404608
def minimum(a,b): if a <= b: return a else: return b
minimum
easy
[{"input": "1,2", "output": "1", "testtype": "functional"}]
Mbpp_404
Write a python function to find the minimum of two numbers.
404
mbpp
1
2024-11-26T21:40:54.404722
def minimum(a,b): if a <= b: return a else: return b
minimum
easy
[{"input": "-5,-4", "output": "-5", "testtype": "functional"}]
Mbpp_404
Write a python function to find the minimum of two numbers.
404
mbpp
2
2024-11-26T21:40:54.404821
def minimum(a,b): if a <= b: return a else: return b
minimum
easy
[{"input": "0,0", "output": "0", "testtype": "functional"}]
Mbpp_405
Write a function to check whether an element exists within a tuple.
405
mbpp
0
2024-11-26T21:40:54.404929
def check_tuplex(tuplex,tuple1): if tuple1 in tuplex: return True else: return False
check_tuplex
easy
[{"input": "(\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),'r'", "output": "True", "testtype": "functional"}]
Mbpp_405
Write a function to check whether an element exists within a tuple.
405
mbpp
1
2024-11-26T21:40:54.405032
def check_tuplex(tuplex,tuple1): if tuple1 in tuplex: return True else: return False
check_tuplex
easy
[{"input": "(\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),'5'", "output": "False", "testtype": "functional"}]
Mbpp_405
Write a function to check whether an element exists within a tuple.
405
mbpp
2
2024-11-26T21:40:54.405132
def check_tuplex(tuplex,tuple1): if tuple1 in tuplex: return True else: return False
check_tuplex
easy
[{"input": "(\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\",\"e\"),3", "output": "True", "testtype": "functional"}]
Mbpp_406
Write a python function to find the parity of a given number.
406
mbpp
0
2024-11-26T21:40:54.405431
def find_Parity(x): y = x ^ (x >> 1); y = y ^ (y >> 2); y = y ^ (y >> 4); y = y ^ (y >> 8); y = y ^ (y >> 16); if (y & 1): return ("Odd Parity"); return ("Even Parity");
find_Parity
easy
[{"input": "12", "output": "\"Even Parity\"", "testtype": "functional"}]
Mbpp_406
Write a python function to find the parity of a given number.
406
mbpp
1
2024-11-26T21:40:54.405720
def find_Parity(x): y = x ^ (x >> 1); y = y ^ (y >> 2); y = y ^ (y >> 4); y = y ^ (y >> 8); y = y ^ (y >> 16); if (y & 1): return ("Odd Parity"); return ("Even Parity");
find_Parity
easy
[{"input": "7", "output": "\"Odd Parity\"", "testtype": "functional"}]
Mbpp_406
Write a python function to find the parity of a given number.
406
mbpp
2
2024-11-26T21:40:54.405994
def find_Parity(x): y = x ^ (x >> 1); y = y ^ (y >> 2); y = y ^ (y >> 4); y = y ^ (y >> 8); y = y ^ (y >> 16); if (y & 1): return ("Odd Parity"); return ("Even Parity");
find_Parity
easy
[{"input": "10", "output": "\"Even Parity\"", "testtype": "functional"}]
Mbpp_407
Write a function to create the next bigger number by rearranging the digits of a given number.
407
mbpp
0
2024-11-26T21:40:54.406488
def rearrange_bigger(n): nums = list(str(n)) for i in range(len(nums)-2,-1,-1): if nums[i] < nums[i+1]: z = nums[i:] y = min(filter(lambda x: x > z[0], z)) z.remove(y) z.sort() nums[i:] = [y] + z return int("".join(nums)) return False
rearrange_bigger
easy
[{"input": "12", "output": "21", "testtype": "functional"}]
Mbpp_407
Write a function to create the next bigger number by rearranging the digits of a given number.
407
mbpp
1
2024-11-26T21:40:54.406965
def rearrange_bigger(n): nums = list(str(n)) for i in range(len(nums)-2,-1,-1): if nums[i] < nums[i+1]: z = nums[i:] y = min(filter(lambda x: x > z[0], z)) z.remove(y) z.sort() nums[i:] = [y] + z return int("".join(nums)) return False
rearrange_bigger
easy
[{"input": "10", "output": "False", "testtype": "functional"}]
Mbpp_407
Write a function to create the next bigger number by rearranging the digits of a given number.
407
mbpp
2
2024-11-26T21:40:54.407424
def rearrange_bigger(n): nums = list(str(n)) for i in range(len(nums)-2,-1,-1): if nums[i] < nums[i+1]: z = nums[i:] y = min(filter(lambda x: x > z[0], z)) z.remove(y) z.sort() nums[i:] = [y] + z return int("".join(nums)) return False
rearrange_bigger
easy
[{"input": "102", "output": "120", "testtype": "functional"}]
Mbpp_409
Write a function to find the minimum product from the pairs of tuples within a given list.
409
mbpp
0
2024-11-26T21:40:54.408471
def min_product_tuple(list1): result_min = min([abs(x * y) for x, y in list1] ) return result_min
min_product_tuple
easy
[{"input": "[(2, 7), (2, 6), (1, 8), (4, 9)] ", "output": "8", "testtype": "functional"}]
Mbpp_409
Write a function to find the minimum product from the pairs of tuples within a given list.
409
mbpp
1
2024-11-26T21:40:54.408624
def min_product_tuple(list1): result_min = min([abs(x * y) for x, y in list1] ) return result_min
min_product_tuple
easy
[{"input": "[(10,20), (15,2), (5,10)] ", "output": "30", "testtype": "functional"}]
Mbpp_409
Write a function to find the minimum product from the pairs of tuples within a given list.
409
mbpp
2
2024-11-26T21:40:54.408783
def min_product_tuple(list1): result_min = min([abs(x * y) for x, y in list1] ) return result_min
min_product_tuple
easy
[{"input": "[(11,44), (10,15), (20,5), (12, 9)] ", "output": "100", "testtype": "functional"}]
Mbpp_410
Write a function to find the minimum value in a given heterogeneous list.
410
mbpp
0
2024-11-26T21:40:54.408923
def min_val(listval): min_val = min(i for i in listval if isinstance(i, int)) return min_val
min_val
easy
[{"input": "['Python', 3, 2, 4, 5, 'version']", "output": "2", "testtype": "functional"}]
Mbpp_410
Write a function to find the minimum value in a given heterogeneous list.
410
mbpp
1
2024-11-26T21:40:54.409051
def min_val(listval): min_val = min(i for i in listval if isinstance(i, int)) return min_val
min_val
easy
[{"input": "['Python', 15, 20, 25]", "output": "15", "testtype": "functional"}]
Mbpp_410
Write a function to find the minimum value in a given heterogeneous list.
410
mbpp
2
2024-11-26T21:40:54.409178
def min_val(listval): min_val = min(i for i in listval if isinstance(i, int)) return min_val
min_val
easy
[{"input": "['Python', 30, 20, 40, 50, 'version']", "output": "20", "testtype": "functional"}]
Mbpp_411
Write a function to convert the given snake case string to camel case string by using regex.
411
mbpp
0
2024-11-26T21:40:54.409340
import re def snake_to_camel(word): return ''.join(x.capitalize() or '_' for x in word.split('_'))
snake_to_camel
easy
[{"input": "'android_tv'", "output": "'AndroidTv'", "testtype": "functional"}]
Mbpp_411
Write a function to convert the given snake case string to camel case string by using regex.
411
mbpp
1
2024-11-26T21:40:54.409479
import re def snake_to_camel(word): return ''.join(x.capitalize() or '_' for x in word.split('_'))
snake_to_camel
easy
[{"input": "'google_pixel'", "output": "'GooglePixel'", "testtype": "functional"}]
Mbpp_411
Write a function to convert the given snake case string to camel case string by using regex.
411
mbpp
2
2024-11-26T21:40:54.409611
import re def snake_to_camel(word): return ''.join(x.capitalize() or '_' for x in word.split('_'))
snake_to_camel
easy
[{"input": "'apple_watch'", "output": "'AppleWatch'", "testtype": "functional"}]
Mbpp_412
Write a python function to remove odd numbers from a given list.
412
mbpp
0
2024-11-26T21:40:54.409773
def remove_odd(l): for i in l: if i % 2 != 0: l.remove(i) return l
remove_odd
easy
[{"input": "[1,2,3]", "output": "[2]", "testtype": "functional"}]
Mbpp_412
Write a python function to remove odd numbers from a given list.
412
mbpp
1
2024-11-26T21:40:54.409911
def remove_odd(l): for i in l: if i % 2 != 0: l.remove(i) return l
remove_odd
easy
[{"input": "[2,4,6]", "output": "[2,4,6]", "testtype": "functional"}]
Mbpp_412
Write a python function to remove odd numbers from a given list.
412
mbpp
2
2024-11-26T21:40:54.410048
def remove_odd(l): for i in l: if i % 2 != 0: l.remove(i) return l
remove_odd
easy
[{"input": "[10,20,3]", "output": "[10,20]", "testtype": "functional"}]
Mbpp_413
Write a function to extract the nth element from a given list of tuples.
413
mbpp
0
2024-11-26T21:40:54.410184
def extract_nth_element(list1, n): result = [x[n] for x in list1] return result
extract_nth_element
easy
[{"input": "[('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,0", "output": "['Greyson Fulton', 'Brady Kent', 'Wyatt Knott', 'Beau Turnbull']", "testtype": "functional"}]
Mbpp_413
Write a function to extract the nth element from a given list of tuples.
413
mbpp
1
2024-11-26T21:40:54.410311
def extract_nth_element(list1, n): result = [x[n] for x in list1] return result
extract_nth_element
easy
[{"input": "[('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,2", "output": "[99, 96, 94, 98]", "testtype": "functional"}]
Mbpp_413
Write a function to extract the nth element from a given list of tuples.
413
mbpp
2
2024-11-26T21:40:54.410442
def extract_nth_element(list1, n): result = [x[n] for x in list1] return result
extract_nth_element
easy
[{"input": "[('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)],1", "output": "[98, 97, 91, 94]", "testtype": "functional"}]
Mbpp_414
Write a python function to check whether the value exists in a sequence or not.
414
mbpp
0
2024-11-26T21:40:54.410751
def overlapping(list1,list2): c=0 d=0 for i in list1: c+=1 for i in list2: d+=1 for i in range(0,c): for j in range(0,d): if(list1[i]==list2[j]): return 1 return 0
overlapping
easy
[{"input": "[1,2,3,4,5],[6,7,8,9]", "output": "False", "testtype": "functional"}]
Mbpp_414
Write a python function to check whether the value exists in a sequence or not.
414
mbpp
1
2024-11-26T21:40:54.411029
def overlapping(list1,list2): c=0 d=0 for i in list1: c+=1 for i in list2: d+=1 for i in range(0,c): for j in range(0,d): if(list1[i]==list2[j]): return 1 return 0
overlapping
easy
[{"input": "[1,2,3],[4,5,6]", "output": "False", "testtype": "functional"}]
Mbpp_414
Write a python function to check whether the value exists in a sequence or not.
414
mbpp
2
2024-11-26T21:40:54.411299
def overlapping(list1,list2): c=0 d=0 for i in list1: c+=1 for i in list2: d+=1 for i in range(0,c): for j in range(0,d): if(list1[i]==list2[j]): return 1 return 0
overlapping
easy
[{"input": "[1,4,5],[1,4,5]", "output": "True", "testtype": "functional"}]
Mbpp_415
Write a python function to find a pair with highest product from a given array of integers.
415
mbpp
0
2024-11-26T21:40:54.411739
def max_Product(arr): arr_len = len(arr) if (arr_len < 2): return ("No pairs exists") x = arr[0]; y = arr[1] for i in range(0,arr_len): for j in range(i + 1,arr_len): if (arr[i] * arr[j] > x * y): x = arr[i]; y = arr[j] return x,y
max_Product
easy
[{"input": "[1,2,3,4,7,0,8,4]", "output": "(7,8)", "testtype": "functional"}]
Mbpp_415
Write a python function to find a pair with highest product from a given array of integers.
415
mbpp
1
2024-11-26T21:40:54.412143
def max_Product(arr): arr_len = len(arr) if (arr_len < 2): return ("No pairs exists") x = arr[0]; y = arr[1] for i in range(0,arr_len): for j in range(i + 1,arr_len): if (arr[i] * arr[j] > x * y): x = arr[i]; y = arr[j] return x,y
max_Product
easy
[{"input": "[0,-1,-2,-4,5,0,-6]", "output": "(-4,-6)", "testtype": "functional"}]
Mbpp_415
Write a python function to find a pair with highest product from a given array of integers.
415
mbpp
2
2024-11-26T21:40:54.412539
def max_Product(arr): arr_len = len(arr) if (arr_len < 2): return ("No pairs exists") x = arr[0]; y = arr[1] for i in range(0,arr_len): for j in range(i + 1,arr_len): if (arr[i] * arr[j] > x * y): x = arr[i]; y = arr[j] return x,y
max_Product
easy
[{"input": "[1,2,3]", "output": "(2,3)", "testtype": "functional"}]
Mbpp_416
Write a function to find the maximum sum we can make by dividing number in three parts recursively and summing them up together for the given number.
416
mbpp
0
2024-11-26T21:40:54.412964
MAX = 1000000 def breakSum(n): dp = [0]*(n+1) dp[0] = 0 dp[1] = 1 for i in range(2, n+1): dp[i] = max(dp[int(i/2)] + dp[int(i/3)] + dp[int(i/4)], i); return dp[n]
breakSum
easy
[{"input": "12", "output": "13", "testtype": "functional"}]
Mbpp_416
Write a function to find the maximum sum we can make by dividing number in three parts recursively and summing them up together for the given number.
416
mbpp
1
2024-11-26T21:40:54.413370
MAX = 1000000 def breakSum(n): dp = [0]*(n+1) dp[0] = 0 dp[1] = 1 for i in range(2, n+1): dp[i] = max(dp[int(i/2)] + dp[int(i/3)] + dp[int(i/4)], i); return dp[n]
breakSum
easy
[{"input": "24", "output": "27", "testtype": "functional"}]
Mbpp_416
Write a function to find the maximum sum we can make by dividing number in three parts recursively and summing them up together for the given number.
416
mbpp
2
2024-11-26T21:40:54.413748
MAX = 1000000 def breakSum(n): dp = [0]*(n+1) dp[0] = 0 dp[1] = 1 for i in range(2, n+1): dp[i] = max(dp[int(i/2)] + dp[int(i/3)] + dp[int(i/4)], i); return dp[n]
breakSum
easy
[{"input": "23", "output": "23", "testtype": "functional"}]
Mbpp_417
Write a function to find common first element in given list of tuple.
417
mbpp
0
2024-11-26T21:40:54.414049
def group_tuples(Input): out = {} for elem in Input: try: out[elem[0]].extend(elem[1:]) except KeyError: out[elem[0]] = list(elem) return [tuple(values) for values in out.values()]
group_tuples
easy
[{"input": "[('x', 'y'), ('x', 'z'), ('w', 't')]", "output": "[('x', 'y', 'z'), ('w', 't')]", "testtype": "functional"}]
Mbpp_417
Write a function to find common first element in given list of tuple.
417
mbpp
1
2024-11-26T21:40:54.414319
def group_tuples(Input): out = {} for elem in Input: try: out[elem[0]].extend(elem[1:]) except KeyError: out[elem[0]] = list(elem) return [tuple(values) for values in out.values()]
group_tuples
easy
[{"input": "[('a', 'b'), ('a', 'c'), ('d', 'e')]", "output": "[('a', 'b', 'c'), ('d', 'e')]", "testtype": "functional"}]
Mbpp_417
Write a function to find common first element in given list of tuple.
417
mbpp
2
2024-11-26T21:40:54.414592
def group_tuples(Input): out = {} for elem in Input: try: out[elem[0]].extend(elem[1:]) except KeyError: out[elem[0]] = list(elem) return [tuple(values) for values in out.values()]
group_tuples
easy
[{"input": "[('f', 'g'), ('f', 'g'), ('h', 'i')]", "output": "[('f', 'g', 'g'), ('h', 'i')]", "testtype": "functional"}]
Mbpp_418
Write a python function to find the sublist having maximum length.
418
mbpp
0
2024-11-26T21:40:54.414729
def Find_Max(lst): maxList = max((x) for x in lst) return maxList
Find_Max
easy
[{"input": "[['A'],['A','B'],['A','B','C']]", "output": "['A','B','C']", "testtype": "functional"}]
Mbpp_418
Write a python function to find the sublist having maximum length.
418
mbpp
1
2024-11-26T21:40:54.414839
def Find_Max(lst): maxList = max((x) for x in lst) return maxList
Find_Max
easy
[{"input": "[[1],[1,2],[1,2,3]]", "output": "[1,2,3]", "testtype": "functional"}]
Mbpp_418
Write a python function to find the sublist having maximum length.
418
mbpp
2
2024-11-26T21:40:54.414944
def Find_Max(lst): maxList = max((x) for x in lst) return maxList
Find_Max
easy
[{"input": "[[1,1],[1,2,3],[1,5,6,1]]", "output": "[1,5,6,1]", "testtype": "functional"}]
Mbpp_419
Write a function to round every number of a given list of numbers and print the total sum multiplied by the length of the list.
419
mbpp
0
2024-11-26T21:40:54.415106
def round_and_sum(list1): lenght=len(list1) round_and_sum=sum(list(map(round,list1))* lenght) return round_and_sum
round_and_sum
easy
[{"input": "[22.4, 4.0, -16.22, -9.10, 11.00, -12.22, 14.20, -5.20, 17.50]", "output": "243", "testtype": "functional"}]
Mbpp_419
Write a function to round every number of a given list of numbers and print the total sum multiplied by the length of the list.
419
mbpp
1
2024-11-26T21:40:54.415257
def round_and_sum(list1): lenght=len(list1) round_and_sum=sum(list(map(round,list1))* lenght) return round_and_sum
round_and_sum
easy
[{"input": "[5,2,9,24.3,29]", "output": "345", "testtype": "functional"}]
Mbpp_419
Write a function to round every number of a given list of numbers and print the total sum multiplied by the length of the list.
419
mbpp
2
2024-11-26T21:40:54.415412
def round_and_sum(list1): lenght=len(list1) round_and_sum=sum(list(map(round,list1))* lenght) return round_and_sum
round_and_sum
easy
[{"input": "[25.0,56.7,89.2]", "output": "513", "testtype": "functional"}]
Mbpp_420
Write a python function to find the cube sum of first n even natural numbers.
420
mbpp
0
2024-11-26T21:40:54.415600
def cube_Sum(n): sum = 0 for i in range(1,n + 1): sum += (2*i)*(2*i)*(2*i) return sum
cube_Sum
easy
[{"input": "2", "output": "72", "testtype": "functional"}]
Mbpp_420
Write a python function to find the cube sum of first n even natural numbers.
420
mbpp
1
2024-11-26T21:40:54.415785
def cube_Sum(n): sum = 0 for i in range(1,n + 1): sum += (2*i)*(2*i)*(2*i) return sum
cube_Sum
easy
[{"input": "3", "output": "288", "testtype": "functional"}]
Mbpp_420
Write a python function to find the cube sum of first n even natural numbers.
420
mbpp
2
2024-11-26T21:40:54.415968
def cube_Sum(n): sum = 0 for i in range(1,n + 1): sum += (2*i)*(2*i)*(2*i) return sum
cube_Sum
easy
[{"input": "4", "output": "800", "testtype": "functional"}]
Mbpp_421
Write a function to concatenate each element of tuple by the delimiter.
421
mbpp
0
2024-11-26T21:40:54.416209
def concatenate_tuple(test_tup): delim = "-" res = ''.join([str(ele) + delim for ele in test_tup]) res = res[ : len(res) - len(delim)] return (str(res))
concatenate_tuple
easy
[{"input": "(\"ID\", \"is\", 4, \"UTS\") ", "output": "'ID-is-4-UTS'", "testtype": "functional"}]
Mbpp_421
Write a function to concatenate each element of tuple by the delimiter.
421
mbpp
1
2024-11-26T21:40:54.416439
def concatenate_tuple(test_tup): delim = "-" res = ''.join([str(ele) + delim for ele in test_tup]) res = res[ : len(res) - len(delim)] return (str(res))
concatenate_tuple
easy
[{"input": "(\"QWE\", \"is\", 4, \"RTY\") ", "output": "'QWE-is-4-RTY'", "testtype": "functional"}]
Mbpp_421
Write a function to concatenate each element of tuple by the delimiter.
421
mbpp
2
2024-11-26T21:40:54.416675
def concatenate_tuple(test_tup): delim = "-" res = ''.join([str(ele) + delim for ele in test_tup]) res = res[ : len(res) - len(delim)] return (str(res))
concatenate_tuple
easy
[{"input": "(\"ZEN\", \"is\", 4, \"OP\") ", "output": "'ZEN-is-4-OP'", "testtype": "functional"}]
Mbpp_422
Write a python function to find the average of cubes of first n natural numbers.
422
mbpp
0
2024-11-26T21:40:54.416941
def find_Average_Of_Cube(n): sum = 0 for i in range(1, n + 1): sum += i * i * i return round(sum / n, 6)
find_Average_Of_Cube
easy
[{"input": "2", "output": "4.5", "testtype": "functional"}]
Mbpp_422
Write a python function to find the average of cubes of first n natural numbers.
422
mbpp
1
2024-11-26T21:40:54.417121
def find_Average_Of_Cube(n): sum = 0 for i in range(1, n + 1): sum += i * i * i return round(sum / n, 6)
find_Average_Of_Cube
easy
[{"input": "3", "output": "12", "testtype": "functional"}]
Mbpp_422
Write a python function to find the average of cubes of first n natural numbers.
422
mbpp
2
2024-11-26T21:40:54.417295
def find_Average_Of_Cube(n): sum = 0 for i in range(1, n + 1): sum += i * i * i return round(sum / n, 6)
find_Average_Of_Cube
easy
[{"input": "1", "output": "1", "testtype": "functional"}]
Mbpp_423
Write a function to solve gold mine problem.
423
mbpp
0
2024-11-26T21:40:54.418147
def get_maxgold(gold, m, n): goldTable = [[0 for i in range(n)] for j in range(m)] for col in range(n-1, -1, -1): for row in range(m): if (col == n-1): right = 0 else: right = goldTable[row][col+1] if (row == 0 or col == n-1): right_up = 0 else: right_up = goldTable[row-1][col+1] if (row == m-1 or col == n-1): right_down = 0 else: right_down = goldTable[row+1][col+1] goldTable[row][col] = gold[row][col] + max(right, right_up, right_down) res = goldTable[0][0] for i in range(1, m): res = max(res, goldTable[i][0]) return res
get_maxgold
easy
[{"input": "[[1, 3, 1, 5],[2, 2, 4, 1],[5, 0, 2, 3],[0, 6, 1, 2]],4,4", "output": "16", "testtype": "functional"}]
Mbpp_423
Write a function to solve gold mine problem.
423
mbpp
1
2024-11-26T21:40:54.419023
def get_maxgold(gold, m, n): goldTable = [[0 for i in range(n)] for j in range(m)] for col in range(n-1, -1, -1): for row in range(m): if (col == n-1): right = 0 else: right = goldTable[row][col+1] if (row == 0 or col == n-1): right_up = 0 else: right_up = goldTable[row-1][col+1] if (row == m-1 or col == n-1): right_down = 0 else: right_down = goldTable[row+1][col+1] goldTable[row][col] = gold[row][col] + max(right, right_up, right_down) res = goldTable[0][0] for i in range(1, m): res = max(res, goldTable[i][0]) return res
get_maxgold
easy
[{"input": "[[10,20],[30,40]],2,2", "output": "70", "testtype": "functional"}]
Mbpp_423
Write a function to solve gold mine problem.
423
mbpp
2
2024-11-26T21:40:54.419931
def get_maxgold(gold, m, n): goldTable = [[0 for i in range(n)] for j in range(m)] for col in range(n-1, -1, -1): for row in range(m): if (col == n-1): right = 0 else: right = goldTable[row][col+1] if (row == 0 or col == n-1): right_up = 0 else: right_up = goldTable[row-1][col+1] if (row == m-1 or col == n-1): right_down = 0 else: right_down = goldTable[row+1][col+1] goldTable[row][col] = gold[row][col] + max(right, right_up, right_down) res = goldTable[0][0] for i in range(1, m): res = max(res, goldTable[i][0]) return res
get_maxgold
easy
[{"input": "[[4,9],[3,7]],2,2", "output": "13", "testtype": "functional"}]
Mbpp_424
Write a function to extract only the rear index element of each string in the given tuple.
424
mbpp
0
2024-11-26T21:40:54.420129
def extract_rear(test_tuple): res = list(sub[len(sub) - 1] for sub in test_tuple) return (res)
extract_rear
easy
[{"input": "('Mers', 'for', 'Vers') ", "output": "['s', 'r', 's']", "testtype": "functional"}]
Mbpp_424
Write a function to extract only the rear index element of each string in the given tuple.
424
mbpp
1
2024-11-26T21:40:54.420265
def extract_rear(test_tuple): res = list(sub[len(sub) - 1] for sub in test_tuple) return (res)
extract_rear
easy
[{"input": "('Avenge', 'for', 'People') ", "output": "['e', 'r', 'e']", "testtype": "functional"}]
Mbpp_424
Write a function to extract only the rear index element of each string in the given tuple.
424
mbpp
2
2024-11-26T21:40:54.420429
def extract_rear(test_tuple): res = list(sub[len(sub) - 1] for sub in test_tuple) return (res)
extract_rear
easy
[{"input": "('Gotta', 'get', 'go') ", "output": "['a', 't', 'o']", "testtype": "functional"}]
Mbpp_425
Write a function to count the number of sublists containing a particular element.
425
mbpp
0
2024-11-26T21:40:54.420614
def count_element_in_list(list1, x): ctr = 0 for i in range(len(list1)): if x in list1[i]: ctr+= 1 return ctr
count_element_in_list
easy
[{"input": "[[1, 3], [5, 7], [1, 11], [1, 15, 7]],1", "output": "3", "testtype": "functional"}]
Mbpp_425
Write a function to count the number of sublists containing a particular element.
425
mbpp
1
2024-11-26T21:40:54.420838
def count_element_in_list(list1, x): ctr = 0 for i in range(len(list1)): if x in list1[i]: ctr+= 1 return ctr
count_element_in_list
easy
[{"input": "[['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'A'", "output": "3", "testtype": "functional"}]
Mbpp_425
Write a function to count the number of sublists containing a particular element.
425
mbpp
2
2024-11-26T21:40:54.421027
def count_element_in_list(list1, x): ctr = 0 for i in range(len(list1)): if x in list1[i]: ctr+= 1 return ctr
count_element_in_list
easy
[{"input": "[['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'E'", "output": "1", "testtype": "functional"}]
Mbpp_426
Write a function to filter odd numbers using lambda function.
426
mbpp
0
2024-11-26T21:40:54.421426
def filter_oddnumbers(nums): odd_nums = list(filter(lambda x: x%2 != 0, nums)) return odd_nums
filter_oddnumbers
easy
[{"input": "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]", "output": "[1,3,5,7,9]", "testtype": "functional"}]
Mbpp_426
Write a function to filter odd numbers using lambda function.
426
mbpp
1
2024-11-26T21:40:54.421648
def filter_oddnumbers(nums): odd_nums = list(filter(lambda x: x%2 != 0, nums)) return odd_nums
filter_oddnumbers
easy
[{"input": "[10,20,45,67,84,93]", "output": "[45,67,93]", "testtype": "functional"}]