source_file string | task_id int32 | prompt string | code string | test_imports list | test_list list |
|---|---|---|---|---|---|
charlessutton@: Benchmark Questions Verification V2.ipynb | 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. | def round_and_sum(list1):
lenght=len(list1)
round_and_sum=sum(list(map(round,list1))* lenght)
return round_and_sum | [] | [
"assert round_and_sum([22.4, 4.0, -16.22, -9.10, 11.00, -12.22, 14.20, -5.20, 17.50])==243",
"assert round_and_sum([5,2,9,24.3,29])==345",
"assert round_and_sum([25.0,56.7,89.2])==513"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 420 | Write a python function to find the cube sum of first n even natural numbers. | def cube_Sum(n):
sum = 0
for i in range(1,n + 1):
sum += (2*i)*(2*i)*(2*i)
return sum | [] | [
"assert cube_Sum(2) == 72",
"assert cube_Sum(3) == 288",
"assert cube_Sum(4) == 800"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 421 | Write a function to concatenate each element of tuple by the delimiter. | 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)) | [] | [
"assert concatenate_tuple((\"ID\", \"is\", 4, \"UTS\") ) == 'ID-is-4-UTS'",
"assert concatenate_tuple((\"QWE\", \"is\", 4, \"RTY\") ) == 'QWE-is-4-RTY'",
"assert concatenate_tuple((\"ZEN\", \"is\", 4, \"OP\") ) == 'ZEN-is-4-OP'"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 422 | Write a python function to find the average of cubes of first n natural numbers. | def find_Average_Of_Cube(n):
sum = 0
for i in range(1, n + 1):
sum += i * i * i
return round(sum / n, 6) | [] | [
"assert find_Average_Of_Cube(2) == 4.5",
"assert find_Average_Of_Cube(3) == 12",
"assert find_Average_Of_Cube(1) == 1"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 424 | Write a function to extract only the rear index element of each string in the given tuple. | def extract_rear(test_tuple):
res = list(sub[len(sub) - 1] for sub in test_tuple)
return (res) | [] | [
"assert extract_rear(('Mers', 'for', 'Vers') ) == ['s', 'r', 's']",
"assert extract_rear(('Avenge', 'for', 'People') ) == ['e', 'r', 'e']",
"assert extract_rear(('Gotta', 'get', 'go') ) == ['a', 't', 'o']"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 425 | Write a function to count the number of sublists containing a particular element. | def count_element_in_list(list1, x):
ctr = 0
for i in range(len(list1)):
if x in list1[i]:
ctr+= 1
return ctr | [] | [
"assert count_element_in_list([[1, 3], [5, 7], [1, 11], [1, 15, 7]],1)==3",
"assert count_element_in_list([['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'A')==3",
"assert count_element_in_list([['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'E')==1"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 426 | Write a function to filter odd numbers. | def filter_oddnumbers(nums):
odd_nums = list(filter(lambda x: x%2 != 0, nums))
return odd_nums | [] | [
"assert filter_oddnumbers([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1,3,5,7,9]",
"assert filter_oddnumbers([10,20,45,67,84,93])==[45,67,93]",
"assert filter_oddnumbers([5,7,9,8,6,4,3])==[5,7,9,3]"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 427 | Write a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format. | import re
def change_date_format(dt):
return re.sub(r'(\d{4})-(\d{1,2})-(\d{1,2})', '\\3-\\2-\\1', dt) | [] | [
"assert change_date_format(\"2026-01-02\") == '02-01-2026'",
"assert change_date_format(\"2020-11-13\") == '13-11-2020'",
"assert change_date_format(\"2021-04-26\") == '26-04-2021'"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 428 | Write a function to sort the given array by using shell sort. | def shell_sort(my_list):
gap = len(my_list) // 2
while gap > 0:
for i in range(gap, len(my_list)):
current_item = my_list[i]
j = i
while j >= gap and my_list[j - gap] > current_item:
my_list[j] = my_list[j - gap]
j -= gap
my... | [] | [
"assert shell_sort([12, 23, 4, 5, 3, 2, 12, 81, 56, 95]) == [2, 3, 4, 5, 12, 12, 23, 56, 81, 95]",
"assert shell_sort([24, 22, 39, 34, 87, 73, 68]) == [22, 24, 34, 39, 68, 73, 87]",
"assert shell_sort([32, 30, 16, 96, 82, 83, 74]) == [16, 30, 32, 74, 82, 83, 96]"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 429 | Write a function to extract the elementwise and tuples from the given two tuples. | def and_tuples(test_tup1, test_tup2):
res = tuple(ele1 & ele2 for ele1, ele2 in zip(test_tup1, test_tup2))
return (res) | [] | [
"assert and_tuples((10, 4, 6, 9), (5, 2, 3, 3)) == (0, 0, 2, 1)",
"assert and_tuples((1, 2, 3, 4), (5, 6, 7, 8)) == (1, 2, 3, 0)",
"assert and_tuples((8, 9, 11, 12), (7, 13, 14, 17)) == (0, 9, 10, 0)"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 430 | Write a function to find the directrix of a parabola. | def parabola_directrix(a, b, c):
directrix=((int)(c - ((b * b) + 1) * 4 * a ))
return directrix | [] | [
"assert parabola_directrix(5,3,2)==-198",
"assert parabola_directrix(9,8,4)==-2336",
"assert parabola_directrix(2,4,6)==-130"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 431 | Write a function that takes two lists and returns true if they have at least one common element. | def common_element(list1, list2):
result = False
for x in list1:
for y in list2:
if x == y:
result = True
return result | [] | [
"assert common_element([1,2,3,4,5], [5,6,7,8,9])==True",
"assert common_element([1,2,3,4,5], [6,7,8,9])==None",
"assert common_element(['a','b','c'], ['d','b','e'])==True"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 432 | Write a function to find the median length of a trapezium. | def median_trapezium(base1,base2,height):
median = 0.5 * (base1+ base2)
return median | [] | [
"assert median_trapezium(15,25,35)==20",
"assert median_trapezium(10,20,30)==15",
"assert median_trapezium(6,9,4)==7.5"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 433 | Write a function to check whether the entered number is greater than the elements of the given array. | def check_greater(arr, number):
arr.sort()
return number > arr[-1] | [] | [
"assert check_greater([1, 2, 3, 4, 5], 4) == False",
"assert check_greater([2, 3, 4, 5, 6], 8) == True",
"assert check_greater([9, 7, 4, 8, 6, 1], 11) == True"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 434 | Write a function that matches a string that has an a followed by one or more b's. | import re
def text_match_one(text):
patterns = 'ab+?'
if re.search(patterns, text):
return True
else:
return False
| [] | [
"assert text_match_one(\"ac\")==False",
"assert text_match_one(\"dc\")==False",
"assert text_match_one(\"abba\")==True"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 435 | Write a python function to find the last digit of a given number. | def last_Digit(n) :
return (n % 10) | [] | [
"assert last_Digit(123) == 3",
"assert last_Digit(25) == 5",
"assert last_Digit(30) == 0"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 436 | Write a python function to return the negative numbers in a list. | def neg_nos(list1):
out = []
for num in list1:
if num < 0:
out.append(num)
return out | [] | [
"assert neg_nos([-1,4,5,-6]) == [-1,-6]",
"assert neg_nos([-1,-2,3,4]) == [-1,-2]",
"assert neg_nos([-7,-6,8,9]) == [-7,-6]"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 437 | Write a function to remove odd characters in a string. | def remove_odd(str1):
str2 = ''
for i in range(1, len(str1) + 1):
if(i % 2 == 0):
str2 = str2 + str1[i - 1]
return str2 | [] | [
"assert remove_odd(\"python\")==(\"yhn\")",
"assert remove_odd(\"program\")==(\"rga\")",
"assert remove_odd(\"language\")==(\"agae\")"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 438 | Write a function to count bidirectional tuple pairs. | def count_bidirectional(test_list):
res = 0
for idx in range(0, len(test_list)):
for iidx in range(idx + 1, len(test_list)):
if test_list[iidx][0] == test_list[idx][1] and test_list[idx][1] == test_list[iidx][0]:
res += 1
return res | [] | [
"assert count_bidirectional([(5, 6), (1, 2), (6, 5), (9, 1), (6, 5), (2, 1)] ) == 3",
"assert count_bidirectional([(5, 6), (1, 3), (6, 5), (9, 1), (6, 5), (2, 1)] ) == 2",
"assert count_bidirectional([(5, 6), (1, 2), (6, 5), (9, 2), (6, 5), (2, 1)] ) == 4"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 439 | Write a function to join a list of multiple integers into a single integer. | def multiple_to_single(L):
x = int("".join(map(str, L)))
return x | [] | [
"assert multiple_to_single([11, 33, 50])==113350",
"assert multiple_to_single([-1,2,3,4,5,6])==-123456",
"assert multiple_to_single([10,15,20,25])==10152025"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 440 | Write a function to find the first adverb and their positions in a given sentence. | import re
def find_adverb_position(text):
for m in re.finditer(r"\w+ly", text):
return (m.start(), m.end(), m.group(0)) | [] | [
"assert find_adverb_position(\"clearly!! we can see the sky\")==(0, 7, 'clearly')",
"assert find_adverb_position(\"seriously!! there are many roses\")==(0, 9, 'seriously')",
"assert find_adverb_position(\"unfortunately!! sita is going to home\")==(0, 13, 'unfortunately')"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 441 | Write a function to find the surface area of a cube of a given size. | def surfacearea_cube(l):
surfacearea= 6*l*l
return surfacearea | [] | [
"assert surfacearea_cube(5)==150",
"assert surfacearea_cube(3)==54",
"assert surfacearea_cube(10)==600"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 442 | Write a function to find the ration of positive numbers in an array of integers. | from array import array
def positive_count(nums):
n = len(nums)
n1 = 0
for x in nums:
if x > 0:
n1 += 1
else:
None
return round(n1/n,2) | [] | [
"assert positive_count([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8])==0.54",
"assert positive_count([2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==0.69",
"assert positive_count([2, 4, -6, -9, 11, -12, 14, -5, 17])==0.56"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 443 | Write a python function to find the largest negative number from the given list. | def largest_neg(list1):
max = list1[0]
for x in list1:
if x < max :
max = x
return max | [] | [
"assert largest_neg([1,2,3,-4,-6]) == -6",
"assert largest_neg([1,2,3,-8,-9]) == -9",
"assert largest_neg([1,2,3,4,-1]) == -1"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 444 | Write a function to trim each tuple by k in the given tuple list. | def trim_tuple(test_list, K):
res = []
for ele in test_list:
N = len(ele)
res.append(tuple(list(ele)[K: N - K]))
return (str(res)) | [] | [
"assert trim_tuple([(5, 3, 2, 1, 4), (3, 4, 9, 2, 1),(9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 2) == '[(2,), (9,), (2,), (2,)]'",
"assert trim_tuple([(5, 3, 2, 1, 4), (3, 4, 9, 2, 1), (9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 1) == '[(3, 2, 1), (4, 9, 2), (1, 2, 3), (8, 2, 1)]'",
"assert trim_tuple([(7, 8, 4, 9), (11, 8, 12,... |
charlessutton@: Benchmark Questions Verification V2.ipynb | 445 | Write a function to perform index wise multiplication of tuple elements in the given two tuples. | def index_multiplication(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) | [] | [
"assert index_multiplication(((1, 3), (4, 5), (2, 9), (1, 10)),((6, 7), (3, 9), (1, 1), (7, 3)) ) == ((6, 21), (12, 45), (2, 9), (7, 30))",
"assert index_multiplication(((2, 4), (5, 6), (3, 10), (2, 11)),((7, 8), (4, 10), (2, 2), (8, 4)) ) == ((14, 32), (20, 60), (6, 20), (16, 44))",
"assert index_multiplicatio... |
charlessutton@: Benchmark Questions Verification V2.ipynb | 446 | Write a python function to count the occurence of all elements of list in a tuple. | from collections import Counter
def count_Occurrence(tup, lst):
count = 0
for item in tup:
if item in lst:
count+= 1
return count | [] | [
"assert count_Occurrence(('a', 'a', 'c', 'b', 'd'),['a', 'b'] ) == 3",
"assert count_Occurrence((1, 2, 3, 1, 4, 6, 7, 1, 4),[1, 4, 7]) == 6",
"assert count_Occurrence((1,2,3,4,5,6),[1,2]) == 2"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 447 | Write a function to find cubes of individual elements in a list. | def cube_nums(nums):
cube_nums = list(map(lambda x: x ** 3, nums))
return cube_nums | [] | [
"assert cube_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]",
"assert cube_nums([10,20,30])==([1000, 8000, 27000])",
"assert cube_nums([12,15])==([1728, 3375])"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 448 | Write a function to calculate the sum of perrin numbers. | def cal_sum(n):
a = 3
b = 0
c = 2
if (n == 0):
return 3
if (n == 1):
return 3
if (n == 2):
return 5
sum = 5
while (n > 2):
d = a + b
sum = sum + d
a = b
b = c
c = d
n = n-1
return sum | [] | [
"assert cal_sum(9) == 49",
"assert cal_sum(10) == 66",
"assert cal_sum(11) == 88"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 450 | Write a function to extract specified size of strings from a given list of string values. | def extract_string(str, l):
result = [e for e in str if len(e) == l]
return result | [] | [
"assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,8)==['practice', 'solution']",
"assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,6)==['Python']",
"assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,9)==['exercises']"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 451 | Write a function to remove all whitespaces from the given string. | import re
def remove_whitespaces(text1):
return (re.sub(r'\s+', '',text1)) | [] | [
"assert remove_whitespaces(' Google Flutter ') == 'GoogleFlutter'",
"assert remove_whitespaces(' Google Dart ') == 'GoogleDart'",
"assert remove_whitespaces(' iOS Swift ') == 'iOSSwift'"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 452 | Write a function that gives loss amount on a sale if the given amount has loss else return 0. | def loss_amount(actual_cost,sale_amount):
if(sale_amount > actual_cost):
amount = sale_amount - actual_cost
return amount
else:
return 0 | [] | [
"assert loss_amount(1500,1200)==0",
"assert loss_amount(100,200)==100",
"assert loss_amount(2000,5000)==3000"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 453 | Write a python function to find the sum of even factors of a number. | import math
def sumofFactors(n) :
if (n % 2 != 0) :
return 0
res = 1
for i in range(2, (int)(math.sqrt(n)) + 1) :
count = 0
curr_sum = 1
curr_term = 1
while (n % i == 0) :
count= count + 1
n = n // i
if (i == 2 and count ==... | [] | [
"assert sumofFactors(18) == 26",
"assert sumofFactors(30) == 48",
"assert sumofFactors(6) == 8"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 454 | Write a function that matches a word containing 'z'. | import re
def text_match_wordz(text):
patterns = '\w*z.\w*'
if re.search(patterns, text):
return True
else:
return False | [] | [
"assert text_match_wordz(\"pythonz.\")==True",
"assert text_match_wordz(\"xyz.\")==True",
"assert text_match_wordz(\" lang .\")==False"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 455 | Write a function to check whether the given month number contains 31 days or not. | def check_monthnumb_number(monthnum2):
if(monthnum2==1 or monthnum2==3 or monthnum2==5 or monthnum2==7 or monthnum2==8 or monthnum2==10 or monthnum2==12):
return True
else:
return False | [] | [
"assert check_monthnumb_number(5)==True",
"assert check_monthnumb_number(2)==False",
"assert check_monthnumb_number(6)==False"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 456 | Write a function to reverse each string in a given list of string values. | def reverse_string_list(stringlist):
result = [x[::-1] for x in stringlist]
return result | [] | [
"assert reverse_string_list(['Red', 'Green', 'Blue', 'White', 'Black'])==['deR', 'neerG', 'eulB', 'etihW', 'kcalB']",
"assert reverse_string_list(['john','amal','joel','george'])==['nhoj','lama','leoj','egroeg']",
"assert reverse_string_list(['jack','john','mary'])==['kcaj','nhoj','yram']"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 457 | Write a python function to find the sublist having minimum length. | def Find_Min(lst):
return min(lst, key=len) | [] | [
"assert Find_Min([[1],[1,2],[1,2,3]]) == [1]",
"assert Find_Min([[1,1],[1,1,1],[1,2,7,8]]) == [1,1]",
"assert Find_Min([['x'],['x','y'],['x','y','z']]) == ['x']"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 458 | Write a function to find the area of a rectangle. | def rectangle_area(l,b):
area=l*b
return area | [] | [
"assert rectangle_area(10,20)==200",
"assert rectangle_area(10,5)==50",
"assert rectangle_area(4,2)==8"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 459 | Write a function to remove uppercase substrings from a given string. | import re
def remove_uppercase(str1):
return re.sub('[A-Z]', '', str1) | [] | [
"assert remove_uppercase('cAstyoUrFavoRitETVshoWs') == 'cstyoravoitshos'",
"assert remove_uppercase('wAtchTheinTernEtrAdIo') == 'wtchheinerntrdo'",
"assert remove_uppercase('VoicESeaRchAndreComMendaTionS') == 'oiceachndreomendaion'"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 460 | Write a python function to get the first element of each sublist. | def Extract(lst):
return [item[0] for item in lst] | [] | [
"assert Extract([[1, 2], [3, 4, 5], [6, 7, 8, 9]]) == [1, 3, 6]",
"assert Extract([[1,2,3],[4, 5]]) == [1,4]",
"assert Extract([[9,8,1],[1,2]]) == [9,1]"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 461 | Write a python function to count the upper case characters in a given string. | def upper_ctr(str):
upper_ctr = 0
for i in range(len(str)):
if str[i] >= 'A' and str[i] <= 'Z': upper_ctr += 1
return upper_ctr | [] | [
"assert upper_ctr('PYthon') == 1",
"assert upper_ctr('BigData') == 1",
"assert upper_ctr('program') == 0"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 462 | Write a function to find all possible combinations of the elements of a given list. | def combinations_list(list1):
if len(list1) == 0:
return [[]]
result = []
for el in combinations_list(list1[1:]):
result += [el, el+[list1[0]]]
return result | [] | [
"assert combinations_list(['orange', 'red', 'green', 'blue'])==[[], ['orange'], ['red'], ['red', 'orange'], ['green'], ['green', 'orange'], ['green', 'red'], ['green', 'red', 'orange'], ['blue'], ['blue', 'orange'], ['blue', 'red'], ['blue', 'red', 'orange'], ['blue', 'green'], ['blue', 'green', 'orange'], ['blue',... |
charlessutton@: Benchmark Questions Verification V2.ipynb | 463 | Write a function to find the maximum product subarray of the given array. | def max_subarray_product(arr):
n = len(arr)
max_ending_here = 1
min_ending_here = 1
max_so_far = 0
flag = 0
for i in range(0, n):
if arr[i] > 0:
max_ending_here = max_ending_here * arr[i]
min_ending_here = min (min_ending_here * arr[i], 1)
flag = 1
elif arr[i] == 0:
max_ending_here = 1
min_endi... | [] | [
"assert max_subarray_product([1, -2, -3, 0, 7, -8, -2]) == 112",
"assert max_subarray_product([6, -3, -10, 0, 2]) == 180",
"assert max_subarray_product([-2, -40, 0, -2, -3]) == 80"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 464 | Write a function to check if all values are same in a dictionary. | def check_value(dict, n):
result = all(x == n for x in dict.values())
return result | [] | [
"assert check_value({'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},10)==False",
"assert check_value({'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},12)==True",
"assert check_value({'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'P... |
charlessutton@: Benchmark Questions Verification V2.ipynb | 465 | Write a function to drop empty items from a given dictionary. | def drop_empty(dict1):
dict1 = {key:value for (key, value) in dict1.items() if value is not None}
return dict1 | [] | [
"assert drop_empty({'c1': 'Red', 'c2': 'Green', 'c3':None})=={'c1': 'Red', 'c2': 'Green'}",
"assert drop_empty({'c1': 'Red', 'c2': None, 'c3':None})=={'c1': 'Red'}",
"assert drop_empty({'c1': None, 'c2': 'Green', 'c3':None})=={ 'c2': 'Green'}"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 468 | Write a function to find the maximum product formed by multiplying numbers of an increasing subsequence of that array. | def max_product(arr):
n = len(arr)
mpis = arr[:]
for i in range(n):
current_prod = arr[i]
j = i + 1
while j < n:
if arr[j-1] > arr[j]:
break
current_prod *= arr[j]
if current_prod > mpis[j]:
mpis[j] = current_prod
j = j + 1
return max(mpis) | [] | [
"assert max_product([3, 100, 4, 5, 150, 6]) == 3000",
"assert max_product([4, 42, 55, 68, 80]) == 50265600",
"assert max_product([10, 22, 9, 33, 21, 50, 41, 60]) == 2460"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 470 | Write a function to find the pairwise addition of the neighboring elements of the given tuple. | def add_pairwise(test_tup):
res = tuple(i + j for i, j in zip(test_tup, test_tup[1:]))
return (res) | [] | [
"assert add_pairwise((1, 5, 7, 8, 10)) == (6, 12, 15, 18)",
"assert add_pairwise((2, 6, 8, 9, 11)) == (8, 14, 17, 20)",
"assert add_pairwise((3, 7, 9, 10, 12)) == (10, 16, 19, 22)"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 471 | Write a python function to find the product of the array multiplication modulo n. | def find_remainder(arr, n):
mul = 1
for i in range(len(arr)):
mul = (mul * (arr[i] % n)) % n
return mul % n | [] | [
"assert find_remainder([ 100, 10, 5, 25, 35, 14 ],11) ==9",
"assert find_remainder([1,1,1],1) == 0",
"assert find_remainder([1,2,1],2) == 0"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 472 | Write a python function to check whether the given list contains consecutive numbers or not. | def check_Consecutive(l):
return sorted(l) == list(range(min(l),max(l)+1)) | [] | [
"assert check_Consecutive([1,2,3,4,5]) == True",
"assert check_Consecutive([1,2,3,5,6]) == False",
"assert check_Consecutive([1,2,1]) == False"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 473 | Write a function to find the tuple intersection of elements in the given tuple list irrespective of their order. | def tuple_intersection(test_list1, test_list2):
res = set([tuple(sorted(ele)) for ele in test_list1]) & set([tuple(sorted(ele)) for ele in test_list2])
return (res) | [] | [
"assert tuple_intersection([(3, 4), (5, 6), (9, 10), (4, 5)] , [(5, 4), (3, 4), (6, 5), (9, 11)]) == {(4, 5), (3, 4), (5, 6)}",
"assert tuple_intersection([(4, 1), (7, 4), (11, 13), (17, 14)] , [(1, 4), (7, 4), (16, 12), (10, 13)]) == {(4, 7), (1, 4)}",
"assert tuple_intersection([(2, 1), (3, 2), (1, 3), (1, 4)... |
charlessutton@: Benchmark Questions Verification V2.ipynb | 474 | Write a function to replace characters in a string. | def replace_char(str1,ch,newch):
str2 = str1.replace(ch, newch)
return str2 | [] | [
"assert replace_char(\"polygon\",'y','l')==(\"pollgon\")",
"assert replace_char(\"character\",'c','a')==(\"aharaater\")",
"assert replace_char(\"python\",'l','a')==(\"python\")"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 475 | Write a function to sort a dictionary by value. | from collections import Counter
def sort_counter(dict1):
x = Counter(dict1)
sort_counter=x.most_common()
return sort_counter | [] | [
"assert sort_counter({'Math':81, 'Physics':83, 'Chemistry':87})==[('Chemistry', 87), ('Physics', 83), ('Math', 81)]",
"assert sort_counter({'Math':400, 'Physics':300, 'Chemistry':250})==[('Math', 400), ('Physics', 300), ('Chemistry', 250)]",
"assert sort_counter({'Math':900, 'Physics':1000, 'Chemistry':1250})==... |
charlessutton@: Benchmark Questions Verification V2.ipynb | 476 | Write a python function to find the sum of the largest and smallest value in a given array. | def big_sum(nums):
sum= max(nums)+min(nums)
return sum | [] | [
"assert big_sum([1,2,3]) == 4",
"assert big_sum([-1,2,3,4]) == 3",
"assert big_sum([2,3,6]) == 8"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 477 | Write a python function to convert the given string to lower case. | def is_lower(string):
return (string.lower()) | [] | [
"assert is_lower(\"InValid\") == \"invalid\"",
"assert is_lower(\"TruE\") == \"true\"",
"assert is_lower(\"SenTenCE\") == \"sentence\""
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 478 | Write a function to remove lowercase substrings from a given string. | import re
def remove_lowercase(str1):
return re.sub('[a-z]', '', str1) | [] | [
"assert remove_lowercase(\"PYTHon\")==('PYTH')",
"assert remove_lowercase(\"FInD\")==('FID')",
"assert remove_lowercase(\"STRinG\")==('STRG')"
] |
charlessutton@: Benchmark Questions Verification V2.ipynb | 479 | Write a python function to find the first digit of a given number. | def first_Digit(n) :
while n >= 10:
n = n / 10
return int(n) | [] | [
"assert first_Digit(123) == 1",
"assert first_Digit(456) == 4",
"assert first_Digit(12) == 1"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.