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_460
Write a python function to get the first element of each sublist.
460
mbpp
0
2024-11-26T21:40:54.445875
def Extract(lst): return [item[0] for item in lst]
Extract
easy
[{"input": "[[1, 2], [3, 4, 5], [6, 7, 8, 9]]", "output": "[1, 3, 6]", "testtype": "functional"}]
Mbpp_460
Write a python function to get the first element of each sublist.
460
mbpp
1
2024-11-26T21:40:54.445976
def Extract(lst): return [item[0] for item in lst]
Extract
easy
[{"input": "[[1,2,3],[4, 5]]", "output": "[1,4]", "testtype": "functional"}]
Mbpp_460
Write a python function to get the first element of each sublist.
460
mbpp
2
2024-11-26T21:40:54.446074
def Extract(lst): return [item[0] for item in lst]
Extract
easy
[{"input": "[[9,8,1],[1,2]]", "output": "[9,1]", "testtype": "functional"}]
Mbpp_461
Write a python function to count the upper case characters in a given string.
461
mbpp
0
2024-11-26T21:40:54.446302
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
upper_ctr
easy
[{"input": "'PYthon'", "output": "1", "testtype": "functional"}]
Mbpp_461
Write a python function to count the upper case characters in a given string.
461
mbpp
1
2024-11-26T21:40:54.446527
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
upper_ctr
easy
[{"input": "'BigData'", "output": "1", "testtype": "functional"}]
Mbpp_461
Write a python function to count the upper case characters in a given string.
461
mbpp
2
2024-11-26T21:40:54.446781
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
upper_ctr
easy
[{"input": "'program'", "output": "0", "testtype": "functional"}]
Mbpp_462
Write a function to find all possible combinations of the elements of a given list.
462
mbpp
0
2024-11-26T21:40:54.447073
def combinations_list(list1): if len(list1) == 0: return [[]] result = [] for el in combinations_list(list1[1:]): result += [el, el+[list1[0]]] return result
combinations_list
easy
[{"input": "['orange', 'red', 'green', 'blue']", "output": "[[], ['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', 'green', 'red'], ['blue', 'green', 'red', 'orange']]", "testtype": "functional"}]
Mbpp_462
Write a function to find all possible combinations of the elements of a given list.
462
mbpp
1
2024-11-26T21:40:54.447377
def combinations_list(list1): if len(list1) == 0: return [[]] result = [] for el in combinations_list(list1[1:]): result += [el, el+[list1[0]]] return result
combinations_list
easy
[{"input": "['red', 'green', 'blue', 'white', 'black', 'orange']", "output": "[[], ['red'], ['green'], ['green', 'red'], ['blue'], ['blue', 'red'], ['blue', 'green'], ['blue', 'green', 'red'], ['white'], ['white', 'red'], ['white', 'green'], ['white', 'green', 'red'], ['white', 'blue'], ['white', 'blue', 'red'], ['white', 'blue', 'green'], ['white', 'blue', 'green', 'red'], ['black'], ['black', 'red'], ['black', 'green'], ['black', 'green', 'red'], ['black', 'blue'], ['black', 'blue', 'red'], ['black', 'blue', 'green'], ['black', 'blue', 'green', 'red'], ['black', 'white'], ['black', 'white', 'red'], ['black', 'white', 'green'], ['black', 'white', 'green', 'red'], ['black', 'white', 'blue'], ['black', 'white', 'blue', 'red'], ['black', 'white', 'blue', 'green'], ['black', 'white', 'blue', 'green', 'red'], ['orange'], ['orange', 'red'], ['orange', 'green'], ['orange', 'green', 'red'], ['orange', 'blue'], ['orange', 'blue', 'red'], ['orange', 'blue', 'green'], ['orange', 'blue', 'green', 'red'], ['orange', 'white'], ['orange', 'white', 'red'], ['orange', 'white', 'green'], ['orange', 'white', 'green', 'red'], ['orange', 'white', 'blue'], ['orange', 'white', 'blue', 'red'], ['orange', 'white', 'blue', 'green'], ['orange', 'white', 'blue', 'green', 'red'], ['orange', 'black'], ['orange', 'black', 'red'], ['orange', 'black', 'green'], ['orange', 'black', 'green', 'red'], ['orange', 'black', 'blue'], ['orange', 'black', 'blue', 'red'], ['orange', 'black', 'blue', 'green'], ['orange', 'black', 'blue', 'green', 'red'], ['orange', 'black', 'white'], ['orange', 'black', 'white', 'red'], ['orange', 'black', 'white', 'green'], ['orange', 'black', 'white', 'green', 'red'], ['orange', 'black', 'white', 'blue'], ['orange', 'black', 'white', 'blue', 'red'], ['orange', 'black', 'white', 'blue', 'green'], ['orange', 'black', 'white', 'blue', 'green', 'red']]", "testtype": "functional"}]
Mbpp_462
Write a function to find all possible combinations of the elements of a given list.
462
mbpp
2
2024-11-26T21:40:54.448592
def combinations_list(list1): if len(list1) == 0: return [[]] result = [] for el in combinations_list(list1[1:]): result += [el, el+[list1[0]]] return result
combinations_list
easy
[{"input": "['red', 'green', 'black', 'orange']", "output": "[[], ['red'], ['green'], ['green', 'red'], ['black'], ['black', 'red'], ['black', 'green'], ['black', 'green', 'red'], ['orange'], ['orange', 'red'], ['orange', 'green'], ['orange', 'green', 'red'], ['orange', 'black'], ['orange', 'black', 'red'], ['orange', 'black', 'green'], ['orange', 'black', 'green', 'red']]", "testtype": "functional"}]
Mbpp_463
Write a function to find the maximum product subarray of the given array.
463
mbpp
0
2024-11-26T21:40:54.449301
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_ending_here = 1 else: temp = max_ending_here max_ending_here = max (min_ending_here * arr[i], 1) min_ending_here = temp * arr[i] if (max_so_far < max_ending_here): max_so_far = max_ending_here if flag == 0 and max_so_far == 0: return 0 return max_so_far
max_subarray_product
easy
[{"input": "[1, -2, -3, 0, 7, -8, -2]", "output": "112", "testtype": "functional"}]
Mbpp_463
Write a function to find the maximum product subarray of the given array.
463
mbpp
1
2024-11-26T21:40:54.449955
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_ending_here = 1 else: temp = max_ending_here max_ending_here = max (min_ending_here * arr[i], 1) min_ending_here = temp * arr[i] if (max_so_far < max_ending_here): max_so_far = max_ending_here if flag == 0 and max_so_far == 0: return 0 return max_so_far
max_subarray_product
easy
[{"input": "[6, -3, -10, 0, 2]", "output": "180", "testtype": "functional"}]
Mbpp_463
Write a function to find the maximum product subarray of the given array.
463
mbpp
2
2024-11-26T21:40:54.450580
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_ending_here = 1 else: temp = max_ending_here max_ending_here = max (min_ending_here * arr[i], 1) min_ending_here = temp * arr[i] if (max_so_far < max_ending_here): max_so_far = max_ending_here if flag == 0 and max_so_far == 0: return 0 return max_so_far
max_subarray_product
easy
[{"input": "[-2, -40, 0, -2, -3]", "output": "80", "testtype": "functional"}]
Mbpp_464
Write a function to check if all values are same in a dictionary.
464
mbpp
0
2024-11-26T21:40:54.450788
def check_value(dict, n): result = all(x == n for x in dict.values()) return result
check_value
easy
[{"input": "{'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},10", "output": "False", "testtype": "functional"}]
Mbpp_464
Write a function to check if all values are same in a dictionary.
464
mbpp
1
2024-11-26T21:40:54.450943
def check_value(dict, n): result = all(x == n for x in dict.values()) return result
check_value
easy
[{"input": "{'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},12", "output": "True", "testtype": "functional"}]
Mbpp_464
Write a function to check if all values are same in a dictionary.
464
mbpp
2
2024-11-26T21:40:54.451091
def check_value(dict, n): result = all(x == n for x in dict.values()) return result
check_value
easy
[{"input": "{'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},5", "output": "False", "testtype": "functional"}]
Mbpp_465
Write a function to drop empty items from a given dictionary.
465
mbpp
0
2024-11-26T21:40:54.451270
def drop_empty(dict1): dict1 = {key:value for (key, value) in dict1.items() if value is not None} return dict1
drop_empty
easy
[{"input": "{'c1': 'Red', 'c2': 'Green', 'c3':None}", "output": "{'c1': 'Red', 'c2': 'Green'}", "testtype": "functional"}]
Mbpp_465
Write a function to drop empty items from a given dictionary.
465
mbpp
1
2024-11-26T21:40:54.451438
def drop_empty(dict1): dict1 = {key:value for (key, value) in dict1.items() if value is not None} return dict1
drop_empty
easy
[{"input": "{'c1': 'Red', 'c2': None, 'c3':None}", "output": "{'c1': 'Red'}", "testtype": "functional"}]
Mbpp_465
Write a function to drop empty items from a given dictionary.
465
mbpp
2
2024-11-26T21:40:54.451610
def drop_empty(dict1): dict1 = {key:value for (key, value) in dict1.items() if value is not None} return dict1
drop_empty
easy
[{"input": "{'c1': None, 'c2': 'Green', 'c3':None}", "output": "{ 'c2': 'Green'}", "testtype": "functional"}]
Mbpp_467
Write a python function to convert decimal number to octal number.
467
mbpp
0
2024-11-26T21:40:54.453069
def decimal_to_Octal(deciNum): octalNum = 0 countval = 1; dNo = deciNum; while (deciNum!= 0): remainder= deciNum % 8; octalNum+= remainder*countval; countval= countval*10; deciNum //= 8; return (octalNum)
decimal_to_Octal
easy
[{"input": "10", "output": "12", "testtype": "functional"}]
Mbpp_467
Write a python function to convert decimal number to octal number.
467
mbpp
1
2024-11-26T21:40:54.453371
def decimal_to_Octal(deciNum): octalNum = 0 countval = 1; dNo = deciNum; while (deciNum!= 0): remainder= deciNum % 8; octalNum+= remainder*countval; countval= countval*10; deciNum //= 8; return (octalNum)
decimal_to_Octal
easy
[{"input": "2", "output": "2", "testtype": "functional"}]
Mbpp_467
Write a python function to convert decimal number to octal number.
467
mbpp
2
2024-11-26T21:40:54.453627
def decimal_to_Octal(deciNum): octalNum = 0 countval = 1; dNo = deciNum; while (deciNum!= 0): remainder= deciNum % 8; octalNum+= remainder*countval; countval= countval*10; deciNum //= 8; return (octalNum)
decimal_to_Octal
easy
[{"input": "33", "output": "41", "testtype": "functional"}]
Mbpp_468
Write a function to find the maximum product formed by multiplying numbers of an increasing subsequence of that array.
468
mbpp
0
2024-11-26T21:40:54.454087
def max_product(arr, n ): mpis =[0] * (n) for i in range(n): mpis[i] = arr[i] for i in range(1, n): for j in range(i): if (arr[i] > arr[j] and mpis[i] < (mpis[j] * arr[i])): mpis[i] = mpis[j] * arr[i] return max(mpis)
max_product
easy
[{"input": "[3, 100, 4, 5, 150, 6], 6", "output": "45000", "testtype": "functional"}]
Mbpp_468
Write a function to find the maximum product formed by multiplying numbers of an increasing subsequence of that array.
468
mbpp
1
2024-11-26T21:40:54.454530
def max_product(arr, n ): mpis =[0] * (n) for i in range(n): mpis[i] = arr[i] for i in range(1, n): for j in range(i): if (arr[i] > arr[j] and mpis[i] < (mpis[j] * arr[i])): mpis[i] = mpis[j] * arr[i] return max(mpis)
max_product
easy
[{"input": "[4, 42, 55, 68, 80], 5", "output": "50265600", "testtype": "functional"}]
Mbpp_468
Write a function to find the maximum product formed by multiplying numbers of an increasing subsequence of that array.
468
mbpp
2
2024-11-26T21:40:54.454980
def max_product(arr, n ): mpis =[0] * (n) for i in range(n): mpis[i] = arr[i] for i in range(1, n): for j in range(i): if (arr[i] > arr[j] and mpis[i] < (mpis[j] * arr[i])): mpis[i] = mpis[j] * arr[i] return max(mpis)
max_product
easy
[{"input": "[10, 22, 9, 33, 21, 50, 41, 60], 8", "output": "21780000", "testtype": "functional"}]
Mbpp_469
Write a function to find the maximum profit earned from a maximum of k stock transactions
469
mbpp
0
2024-11-26T21:40:54.455710
def max_profit(price, k): n = len(price) final_profit = [[None for x in range(n)] for y in range(k + 1)] for i in range(k + 1): for j in range(n): if i == 0 or j == 0: final_profit[i][j] = 0 else: max_so_far = 0 for x in range(j): curr_price = price[j] - price[x] + final_profit[i-1][x] if max_so_far < curr_price: max_so_far = curr_price final_profit[i][j] = max(final_profit[i][j-1], max_so_far) return final_profit[k][n-1]
max_profit
easy
[{"input": "[1, 5, 2, 3, 7, 6, 4, 5], 3", "output": "10", "testtype": "functional"}]
Mbpp_469
Write a function to find the maximum profit earned from a maximum of k stock transactions
469
mbpp
1
2024-11-26T21:40:54.456382
def max_profit(price, k): n = len(price) final_profit = [[None for x in range(n)] for y in range(k + 1)] for i in range(k + 1): for j in range(n): if i == 0 or j == 0: final_profit[i][j] = 0 else: max_so_far = 0 for x in range(j): curr_price = price[j] - price[x] + final_profit[i-1][x] if max_so_far < curr_price: max_so_far = curr_price final_profit[i][j] = max(final_profit[i][j-1], max_so_far) return final_profit[k][n-1]
max_profit
easy
[{"input": "[2, 4, 7, 5, 4, 3, 5], 2", "output": "7", "testtype": "functional"}]
Mbpp_469
Write a function to find the maximum profit earned from a maximum of k stock transactions
469
mbpp
2
2024-11-26T21:40:54.457019
def max_profit(price, k): n = len(price) final_profit = [[None for x in range(n)] for y in range(k + 1)] for i in range(k + 1): for j in range(n): if i == 0 or j == 0: final_profit[i][j] = 0 else: max_so_far = 0 for x in range(j): curr_price = price[j] - price[x] + final_profit[i-1][x] if max_so_far < curr_price: max_so_far = curr_price final_profit[i][j] = max(final_profit[i][j-1], max_so_far) return final_profit[k][n-1]
max_profit
easy
[{"input": "[10, 6, 8, 4, 2], 2", "output": "2", "testtype": "functional"}]
Mbpp_470
Write a function to find the pairwise addition of the elements of the given tuples.
470
mbpp
0
2024-11-26T21:40:54.457242
def add_pairwise(test_tup): res = tuple(i + j for i, j in zip(test_tup, test_tup[1:])) return (res)
add_pairwise
easy
[{"input": "(1, 5, 7, 8, 10)", "output": "(6, 12, 15, 18)", "testtype": "functional"}]
Mbpp_470
Write a function to find the pairwise addition of the elements of the given tuples.
470
mbpp
1
2024-11-26T21:40:54.457437
def add_pairwise(test_tup): res = tuple(i + j for i, j in zip(test_tup, test_tup[1:])) return (res)
add_pairwise
easy
[{"input": "(2, 6, 8, 9, 11)", "output": "(8, 14, 17, 20)", "testtype": "functional"}]
Mbpp_470
Write a function to find the pairwise addition of the elements of the given tuples.
470
mbpp
2
2024-11-26T21:40:54.457610
def add_pairwise(test_tup): res = tuple(i + j for i, j in zip(test_tup, test_tup[1:])) return (res)
add_pairwise
easy
[{"input": "(3, 7, 9, 10, 12)", "output": "(10, 16, 19, 22)", "testtype": "functional"}]
Mbpp_471
Write a python function to find remainder of array multiplication divided by n.
471
mbpp
0
2024-11-26T21:40:54.457865
def find_remainder(arr, lens, n): mul = 1 for i in range(lens): mul = (mul * (arr[i] % n)) % n return mul % n
find_remainder
easy
[{"input": "[ 100, 10, 5, 25, 35, 14 ],6,11", "output": "9", "testtype": "functional"}]
Mbpp_471
Write a python function to find remainder of array multiplication divided by n.
471
mbpp
1
2024-11-26T21:40:54.458080
def find_remainder(arr, lens, n): mul = 1 for i in range(lens): mul = (mul * (arr[i] % n)) % n return mul % n
find_remainder
easy
[{"input": "[1,1,1],3,1", "output": "0", "testtype": "functional"}]
Mbpp_471
Write a python function to find remainder of array multiplication divided by n.
471
mbpp
2
2024-11-26T21:40:54.458289
def find_remainder(arr, lens, n): mul = 1 for i in range(lens): mul = (mul * (arr[i] % n)) % n return mul % n
find_remainder
easy
[{"input": "[1,2,1],3,2", "output": "0", "testtype": "functional"}]
Mbpp_472
Write a python function to check whether the given list contains consecutive numbers or not.
472
mbpp
0
2024-11-26T21:40:54.458458
def check_Consecutive(l): return sorted(l) == list(range(min(l),max(l)+1))
check_Consecutive
easy
[{"input": "[1,2,3,4,5]", "output": "True", "testtype": "functional"}]
Mbpp_472
Write a python function to check whether the given list contains consecutive numbers or not.
472
mbpp
1
2024-11-26T21:40:54.458611
def check_Consecutive(l): return sorted(l) == list(range(min(l),max(l)+1))
check_Consecutive
easy
[{"input": "[1,2,3,5,6]", "output": "False", "testtype": "functional"}]
Mbpp_472
Write a python function to check whether the given list contains consecutive numbers or not.
472
mbpp
2
2024-11-26T21:40:54.458782
def check_Consecutive(l): return sorted(l) == list(range(min(l),max(l)+1))
check_Consecutive
easy
[{"input": "[1,2,1]", "output": "False", "testtype": "functional"}]
Mbpp_473
Write a function to find the tuple intersection of elements in the given tuple list irrespective of their order.
473
mbpp
0
2024-11-26T21:40:54.459020
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)
tuple_intersection
easy
[{"input": "[(3, 4), (5, 6), (9, 10), (4, 5)] , [(5, 4), (3, 4), (6, 5), (9, 11)]", "output": "{(4, 5), (3, 4), (5, 6)}", "testtype": "functional"}]
Mbpp_473
Write a function to find the tuple intersection of elements in the given tuple list irrespective of their order.
473
mbpp
1
2024-11-26T21:40:54.459239
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)
tuple_intersection
easy
[{"input": "[(4, 1), (7, 4), (11, 13), (17, 14)] , [(1, 4), (7, 4), (16, 12), (10, 13)]", "output": "{(4, 7), (1, 4)}", "testtype": "functional"}]
Mbpp_473
Write a function to find the tuple intersection of elements in the given tuple list irrespective of their order.
473
mbpp
2
2024-11-26T21:40:54.459618
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)
tuple_intersection
easy
[{"input": "[(2, 1), (3, 2), (1, 3), (1, 4)] , [(11, 2), (2, 3), (6, 2), (1, 3)]", "output": "{(1, 3), (2, 3)}", "testtype": "functional"}]
Mbpp_474
Write a function to replace characters in a string.
474
mbpp
0
2024-11-26T21:40:54.459841
def replace_char(str1,ch,newch): str2 = str1.replace(ch, newch) return str2
replace_char
easy
[{"input": "\"polygon\",'y','l'", "output": "(\"pollgon\")", "testtype": "functional"}]
Mbpp_474
Write a function to replace characters in a string.
474
mbpp
1
2024-11-26T21:40:54.459982
def replace_char(str1,ch,newch): str2 = str1.replace(ch, newch) return str2
replace_char
easy
[{"input": "\"character\",'c','a'", "output": "(\"aharaater\")", "testtype": "functional"}]
Mbpp_474
Write a function to replace characters in a string.
474
mbpp
2
2024-11-26T21:40:54.460167
def replace_char(str1,ch,newch): str2 = str1.replace(ch, newch) return str2
replace_char
easy
[{"input": "\"python\",'l','a'", "output": "(\"python\")", "testtype": "functional"}]
Mbpp_475
Write a function to sort counter by value.
475
mbpp
0
2024-11-26T21:40:54.460366
from collections import Counter def sort_counter(dict1): x = Counter(dict1) sort_counter=x.most_common() return sort_counter
sort_counter
easy
[{"input": "{'Math':81, 'Physics':83, 'Chemistry':87}", "output": "[('Chemistry', 87), ('Physics', 83), ('Math', 81)]", "testtype": "functional"}]
Mbpp_475
Write a function to sort counter by value.
475
mbpp
1
2024-11-26T21:40:54.460525
from collections import Counter def sort_counter(dict1): x = Counter(dict1) sort_counter=x.most_common() return sort_counter
sort_counter
easy
[{"input": "{'Math':400, 'Physics':300, 'Chemistry':250}", "output": "[('Math', 400), ('Physics', 300), ('Chemistry', 250)]", "testtype": "functional"}]
Mbpp_475
Write a function to sort counter by value.
475
mbpp
2
2024-11-26T21:40:54.460702
from collections import Counter def sort_counter(dict1): x = Counter(dict1) sort_counter=x.most_common() return sort_counter
sort_counter
easy
[{"input": "{'Math':900, 'Physics':1000, 'Chemistry':1250}", "output": "[('Chemistry', 1250), ('Physics', 1000), ('Math', 900)]", "testtype": "functional"}]
Mbpp_476
Write a python function to find the sum of the largest and smallest value in a given array.
476
mbpp
0
2024-11-26T21:40:54.460850
def big_sum(nums): sum= max(nums)+min(nums) return sum
big_sum
easy
[{"input": "[1,2,3]", "output": "4", "testtype": "functional"}]
Mbpp_476
Write a python function to find the sum of the largest and smallest value in a given array.
476
mbpp
1
2024-11-26T21:40:54.460972
def big_sum(nums): sum= max(nums)+min(nums) return sum
big_sum
easy
[{"input": "[-1,2,3,4]", "output": "3", "testtype": "functional"}]
Mbpp_476
Write a python function to find the sum of the largest and smallest value in a given array.
476
mbpp
2
2024-11-26T21:40:54.461104
def big_sum(nums): sum= max(nums)+min(nums) return sum
big_sum
easy
[{"input": "[2,3,6]", "output": "8", "testtype": "functional"}]
Mbpp_477
Write a python function to convert the given string to lower case.
477
mbpp
0
2024-11-26T21:40:54.461206
def is_lower(string): return (string.lower())
is_lower
easy
[{"input": "\"InValid\"", "output": "\"invalid\"", "testtype": "functional"}]
Mbpp_477
Write a python function to convert the given string to lower case.
477
mbpp
1
2024-11-26T21:40:54.461289
def is_lower(string): return (string.lower())
is_lower
easy
[{"input": "\"TruE\"", "output": "\"true\"", "testtype": "functional"}]
Mbpp_477
Write a python function to convert the given string to lower case.
477
mbpp
2
2024-11-26T21:40:54.461367
def is_lower(string): return (string.lower())
is_lower
easy
[{"input": "\"SenTenCE\"", "output": "\"sentence\"", "testtype": "functional"}]
Mbpp_478
Write a function to remove lowercase substrings from a given string.
478
mbpp
0
2024-11-26T21:40:54.461573
import re def remove_lowercase(str1): remove_lower = lambda text: re.sub('[a-z]', '', text) result = remove_lower(str1) return result
remove_lowercase
easy
[{"input": "\"PYTHon\"", "output": "('PYTH')", "testtype": "functional"}]
Mbpp_478
Write a function to remove lowercase substrings from a given string.
478
mbpp
1
2024-11-26T21:40:54.461779
import re def remove_lowercase(str1): remove_lower = lambda text: re.sub('[a-z]', '', text) result = remove_lower(str1) return result
remove_lowercase
easy
[{"input": "\"FInD\"", "output": "('FID')", "testtype": "functional"}]
Mbpp_478
Write a function to remove lowercase substrings from a given string.
478
mbpp
2
2024-11-26T21:40:54.461962
import re def remove_lowercase(str1): remove_lower = lambda text: re.sub('[a-z]', '', text) result = remove_lower(str1) return result
remove_lowercase
easy
[{"input": "\"STRinG\"", "output": "('STRG')", "testtype": "functional"}]
Mbpp_479
Write a python function to find the first digit of a given number.
479
mbpp
0
2024-11-26T21:40:54.462122
def first_Digit(n) : while n >= 10: n = n / 10; return int(n)
first_Digit
easy
[{"input": "123", "output": "1", "testtype": "functional"}]
Mbpp_479
Write a python function to find the first digit of a given number.
479
mbpp
1
2024-11-26T21:40:54.462264
def first_Digit(n) : while n >= 10: n = n / 10; return int(n)
first_Digit
easy
[{"input": "456", "output": "4", "testtype": "functional"}]
Mbpp_479
Write a python function to find the first digit of a given number.
479
mbpp
2
2024-11-26T21:40:54.462385
def first_Digit(n) : while n >= 10: n = n / 10; return int(n)
first_Digit
easy
[{"input": "12", "output": "1", "testtype": "functional"}]
Mbpp_480
Write a python function to find the maximum occurring character in a given string.
480
mbpp
0
2024-11-26T21:40:54.462780
def get_max_occuring_char(str1): ASCII_SIZE = 256 ctr = [0] * ASCII_SIZE max = -1 ch = '' for i in str1: ctr[ord(i)]+=1; for i in str1: if max < ctr[ord(i)]: max = ctr[ord(i)] ch = i return ch
get_max_occuring_char
easy
[{"input": "\"data\"", "output": "\"a\"", "testtype": "functional"}]
Mbpp_480
Write a python function to find the maximum occurring character in a given string.
480
mbpp
1
2024-11-26T21:40:54.463176
def get_max_occuring_char(str1): ASCII_SIZE = 256 ctr = [0] * ASCII_SIZE max = -1 ch = '' for i in str1: ctr[ord(i)]+=1; for i in str1: if max < ctr[ord(i)]: max = ctr[ord(i)] ch = i return ch
get_max_occuring_char
easy
[{"input": "\"create\"", "output": "\"e\"", "testtype": "functional"}]
Mbpp_480
Write a python function to find the maximum occurring character in a given string.
480
mbpp
2
2024-11-26T21:40:54.463541
def get_max_occuring_char(str1): ASCII_SIZE = 256 ctr = [0] * ASCII_SIZE max = -1 ch = '' for i in str1: ctr[ord(i)]+=1; for i in str1: if max < ctr[ord(i)]: max = ctr[ord(i)] ch = i return ch
get_max_occuring_char
easy
[{"input": "\"brilliant girl\"", "output": "\"i\"", "testtype": "functional"}]
Mbpp_481
Write a function to determine if there is a subset of the given set with sum equal to the given sum.
481
mbpp
0
2024-11-26T21:40:54.463937
def is_subset_sum(set, n, sum): if (sum == 0): return True if (n == 0): return False if (set[n - 1] > sum): return is_subset_sum(set, n - 1, sum) return is_subset_sum(set, n-1, sum) or is_subset_sum(set, n-1, sum-set[n-1])
is_subset_sum
easy
[{"input": "[3, 34, 4, 12, 5, 2], 6, 9", "output": "True", "testtype": "functional"}]
Mbpp_481
Write a function to determine if there is a subset of the given set with sum equal to the given sum.
481
mbpp
1
2024-11-26T21:40:54.464346
def is_subset_sum(set, n, sum): if (sum == 0): return True if (n == 0): return False if (set[n - 1] > sum): return is_subset_sum(set, n - 1, sum) return is_subset_sum(set, n-1, sum) or is_subset_sum(set, n-1, sum-set[n-1])
is_subset_sum
easy
[{"input": "[3, 34, 4, 12, 5, 2], 6, 30", "output": "False", "testtype": "functional"}]
Mbpp_481
Write a function to determine if there is a subset of the given set with sum equal to the given sum.
481
mbpp
2
2024-11-26T21:40:54.464759
def is_subset_sum(set, n, sum): if (sum == 0): return True if (n == 0): return False if (set[n - 1] > sum): return is_subset_sum(set, n - 1, sum) return is_subset_sum(set, n-1, sum) or is_subset_sum(set, n-1, sum-set[n-1])
is_subset_sum
easy
[{"input": "[3, 34, 4, 12, 5, 2], 6, 15", "output": "True", "testtype": "functional"}]
Mbpp_482
Write a function to find sequences of one upper case letter followed by lower case letters in the given string by using regex.
482
mbpp
0
2024-11-26T21:40:54.464961
import re def match(text): pattern = '[A-Z]+[a-z]+$' if re.search(pattern, text): return('Yes') else: return('No')
match
easy
[{"input": "\"Geeks\"", "output": "'Yes'", "testtype": "functional"}]
Mbpp_482
Write a function to find sequences of one upper case letter followed by lower case letters in the given string by using regex.
482
mbpp
1
2024-11-26T21:40:54.465136
import re def match(text): pattern = '[A-Z]+[a-z]+$' if re.search(pattern, text): return('Yes') else: return('No')
match
easy
[{"input": "\"geeksforGeeks\"", "output": "'Yes'", "testtype": "functional"}]
Mbpp_482
Write a function to find sequences of one upper case letter followed by lower case letters in the given string by using regex.
482
mbpp
2
2024-11-26T21:40:54.465294
import re def match(text): pattern = '[A-Z]+[a-z]+$' if re.search(pattern, text): return('Yes') else: return('No')
match
easy
[{"input": "\"geeks\"", "output": "'No'", "testtype": "functional"}]
Mbpp_483
Write a python function to find the first natural number whose factorial is divisible by x.
483
mbpp
0
2024-11-26T21:40:54.465532
def first_Factorial_Divisible_Number(x): i = 1; fact = 1; for i in range(1,x): fact = fact * i if (fact % x == 0): break return i
first_Factorial_Divisible_Number
easy
[{"input": "10", "output": "5", "testtype": "functional"}]
Mbpp_483
Write a python function to find the first natural number whose factorial is divisible by x.
483
mbpp
1
2024-11-26T21:40:54.465769
def first_Factorial_Divisible_Number(x): i = 1; fact = 1; for i in range(1,x): fact = fact * i if (fact % x == 0): break return i
first_Factorial_Divisible_Number
easy
[{"input": "15", "output": "5", "testtype": "functional"}]
Mbpp_483
Write a python function to find the first natural number whose factorial is divisible by x.
483
mbpp
2
2024-11-26T21:40:54.465989
def first_Factorial_Divisible_Number(x): i = 1; fact = 1; for i in range(1,x): fact = fact * i if (fact % x == 0): break return i
first_Factorial_Divisible_Number
easy
[{"input": "5", "output": "4", "testtype": "functional"}]
Mbpp_484
Write a function to remove the matching tuples from the given two tuples.
484
mbpp
0
2024-11-26T21:40:54.466172
def remove_matching_tuple(test_list1, test_list2): res = [sub for sub in test_list1 if sub not in test_list2] return (res)
remove_matching_tuple
easy
[{"input": "[('Hello', 'dude'), ('How', 'are'), ('you', '?')], [('Hello', 'dude'), ('How', 'are')]", "output": "[('you', '?')]", "testtype": "functional"}]
Mbpp_484
Write a function to remove the matching tuples from the given two tuples.
484
mbpp
1
2024-11-26T21:40:54.466325
def remove_matching_tuple(test_list1, test_list2): res = [sub for sub in test_list1 if sub not in test_list2] return (res)
remove_matching_tuple
easy
[{"input": "[('Part', 'of'), ('the', 'journey'), ('is ', 'end')], [('Journey', 'the'), ('is', 'end')]", "output": "[('Part', 'of'), ('the', 'journey'), ('is ', 'end')]", "testtype": "functional"}]
Mbpp_484
Write a function to remove the matching tuples from the given two tuples.
484
mbpp
2
2024-11-26T21:40:54.466475
def remove_matching_tuple(test_list1, test_list2): res = [sub for sub in test_list1 if sub not in test_list2] return (res)
remove_matching_tuple
easy
[{"input": "[('Its', 'been'), ('a', 'long'), ('day', 'without')], [('a', 'long'), ('my', 'friend')]", "output": "[('Its', 'been'), ('day', 'without')]", "testtype": "functional"}]
Mbpp_487
Write a function to sort a list of tuples in increasing order by the last element in each tuple.
487
mbpp
0
2024-11-26T21:40:54.468830
def sort_tuple(tup): lst = len(tup) for i in range(0, lst): for j in range(0, lst-i-1): if (tup[j][-1] > tup[j + 1][-1]): temp = tup[j] tup[j]= tup[j + 1] tup[j + 1]= temp return tup
sort_tuple
easy
[{"input": "[(1, 3), (3, 2), (2, 1)] ", "output": "[(2, 1), (3, 2), (1, 3)]", "testtype": "functional"}]
Mbpp_487
Write a function to sort a list of tuples in increasing order by the last element in each tuple.
487
mbpp
1
2024-11-26T21:40:54.469295
def sort_tuple(tup): lst = len(tup) for i in range(0, lst): for j in range(0, lst-i-1): if (tup[j][-1] > tup[j + 1][-1]): temp = tup[j] tup[j]= tup[j + 1] tup[j + 1]= temp return tup
sort_tuple
easy
[{"input": "[(2, 4), (3, 3), (1, 1)] ", "output": "[(1, 1), (3, 3), (2, 4)]", "testtype": "functional"}]
Mbpp_487
Write a function to sort a list of tuples in increasing order by the last element in each tuple.
487
mbpp
2
2024-11-26T21:40:54.469728
def sort_tuple(tup): lst = len(tup) for i in range(0, lst): for j in range(0, lst-i-1): if (tup[j][-1] > tup[j + 1][-1]): temp = tup[j] tup[j]= tup[j + 1] tup[j + 1]= temp return tup
sort_tuple
easy
[{"input": "[(3, 9), (6, 7), (4, 3)] ", "output": "[(4, 3), (6, 7), (3, 9)]", "testtype": "functional"}]
Mbpp_488
Write a function to find the area of a pentagon.
488
mbpp
0
2024-11-26T21:40:54.469959
import math def area_pentagon(a): area=(math.sqrt(5*(5+2*math.sqrt(5)))*pow(a,2))/4.0 return area
area_pentagon
easy
[{"input": "5", "output": "43.01193501472417", "testtype": "functional"}]
Mbpp_488
Write a function to find the area of a pentagon.
488
mbpp
1
2024-11-26T21:40:54.470175
import math def area_pentagon(a): area=(math.sqrt(5*(5+2*math.sqrt(5)))*pow(a,2))/4.0 return area
area_pentagon
easy
[{"input": "10", "output": "172.0477400588967", "testtype": "functional"}]
Mbpp_488
Write a function to find the area of a pentagon.
488
mbpp
2
2024-11-26T21:40:54.470368
import math def area_pentagon(a): area=(math.sqrt(5*(5+2*math.sqrt(5)))*pow(a,2))/4.0 return area
area_pentagon
easy
[{"input": "15", "output": "387.10741513251753", "testtype": "functional"}]
Mbpp_489
Write a python function to find the frequency of the largest value in a given array.
489
mbpp
0
2024-11-26T21:40:54.470699
def frequency_Of_Largest(n,arr): mn = arr[0] freq = 1 for i in range(1,n): if (arr[i] >mn): mn = arr[i] freq = 1 elif (arr[i] == mn): freq += 1 return freq
frequency_Of_Largest
easy
[{"input": "5,[1,2,3,4,4]", "output": "2", "testtype": "functional"}]
Mbpp_489
Write a python function to find the frequency of the largest value in a given array.
489
mbpp
1
2024-11-26T21:40:54.471004
def frequency_Of_Largest(n,arr): mn = arr[0] freq = 1 for i in range(1,n): if (arr[i] >mn): mn = arr[i] freq = 1 elif (arr[i] == mn): freq += 1 return freq
frequency_Of_Largest
easy
[{"input": "3,[5,6,5]", "output": "1", "testtype": "functional"}]
Mbpp_489
Write a python function to find the frequency of the largest value in a given array.
489
mbpp
2
2024-11-26T21:40:54.471501
def frequency_Of_Largest(n,arr): mn = arr[0] freq = 1 for i in range(1,n): if (arr[i] >mn): mn = arr[i] freq = 1 elif (arr[i] == mn): freq += 1 return freq
frequency_Of_Largest
easy
[{"input": "4,[2,7,7,7]", "output": "3", "testtype": "functional"}]
Mbpp_490
Write a function to extract all the pairs which are symmetric in the given tuple list.
490
mbpp
0
2024-11-26T21:40:54.471838
def extract_symmetric(test_list): temp = set(test_list) & {(b, a) for a, b in test_list} res = {(a, b) for a, b in temp if a < b} return (res)
extract_symmetric
easy
[{"input": "[(6, 7), (2, 3), (7, 6), (9, 8), (10, 2), (8, 9)] ", "output": "{(8, 9), (6, 7)}", "testtype": "functional"}]
Mbpp_490
Write a function to extract all the pairs which are symmetric in the given tuple list.
490
mbpp
1
2024-11-26T21:40:54.472114
def extract_symmetric(test_list): temp = set(test_list) & {(b, a) for a, b in test_list} res = {(a, b) for a, b in temp if a < b} return (res)
extract_symmetric
easy
[{"input": "[(7, 8), (3, 4), (8, 7), (10, 9), (11, 3), (9, 10)] ", "output": "{(9, 10), (7, 8)}", "testtype": "functional"}]
Mbpp_490
Write a function to extract all the pairs which are symmetric in the given tuple list.
490
mbpp
2
2024-11-26T21:40:54.472365
def extract_symmetric(test_list): temp = set(test_list) & {(b, a) for a, b in test_list} res = {(a, b) for a, b in temp if a < b} return (res)
extract_symmetric
easy
[{"input": "[(8, 9), (4, 5), (9, 8), (11, 10), (12, 4), (10, 11)] ", "output": "{(8, 9), (10, 11)}", "testtype": "functional"}]
Mbpp_491
Write a function to find the sum of geometric progression series.
491
mbpp
0
2024-11-26T21:40:54.472596
import math def sum_gp(a,n,r): total = (a * (1 - math.pow(r, n ))) / (1- r) return total
sum_gp
easy
[{"input": "1,5,2", "output": "31", "testtype": "functional"}]
Mbpp_491
Write a function to find the sum of geometric progression series.
491
mbpp
1
2024-11-26T21:40:54.472828
import math def sum_gp(a,n,r): total = (a * (1 - math.pow(r, n ))) / (1- r) return total
sum_gp
easy
[{"input": "1,5,4", "output": "341", "testtype": "functional"}]
Mbpp_491
Write a function to find the sum of geometric progression series.
491
mbpp
2
2024-11-26T21:40:54.473027
import math def sum_gp(a,n,r): total = (a * (1 - math.pow(r, n ))) / (1- r) return total
sum_gp
easy
[{"input": "2,6,3", "output": "728", "testtype": "functional"}]
Mbpp_492
Write a function to search an element in the given array by using binary search.
492
mbpp
0
2024-11-26T21:40:54.473468
def binary_search(item_list,item): first = 0 last = len(item_list)-1 found = False while( first<=last and not found): mid = (first + last)//2 if item_list[mid] == item : found = True else: if item < item_list[mid]: last = mid - 1 else: first = mid + 1 return found
binary_search
easy
[{"input": "[1,2,3,5,8], 6", "output": "False", "testtype": "functional"}]
Mbpp_492
Write a function to search an element in the given array by using binary search.
492
mbpp
1
2024-11-26T21:40:54.474050
def binary_search(item_list,item): first = 0 last = len(item_list)-1 found = False while( first<=last and not found): mid = (first + last)//2 if item_list[mid] == item : found = True else: if item < item_list[mid]: last = mid - 1 else: first = mid + 1 return found
binary_search
easy
[{"input": "[7, 8, 9, 10, 13], 10", "output": "True", "testtype": "functional"}]
Mbpp_492
Write a function to search an element in the given array by using binary search.
492
mbpp
2
2024-11-26T21:40:54.474504
def binary_search(item_list,item): first = 0 last = len(item_list)-1 found = False while( first<=last and not found): mid = (first + last)//2 if item_list[mid] == item : found = True else: if item < item_list[mid]: last = mid - 1 else: first = mid + 1 return found
binary_search
easy
[{"input": "[11, 13, 14, 19, 22, 36], 23", "output": "False", "testtype": "functional"}]
Mbpp_493
Write a function to calculate a grid of hexagon coordinates where function returns a list of lists containing 6 tuples of x, y point coordinates.
493
mbpp
0
2024-11-26T21:40:54.475908
import math def calculate_polygons(startx, starty, endx, endy, radius): sl = (2 * radius) * math.tan(math.pi / 6) p = sl * 0.5 b = sl * math.cos(math.radians(30)) w = b * 2 h = 2 * sl startx = startx - w starty = starty - h endx = endx + w endy = endy + h origx = startx origy = starty xoffset = b yoffset = 3 * p polygons = [] row = 1 counter = 0 while starty < endy: if row % 2 == 0: startx = origx + xoffset else: startx = origx while startx < endx: p1x = startx p1y = starty + p p2x = startx p2y = starty + (3 * p) p3x = startx + b p3y = starty + h p4x = startx + w p4y = starty + (3 * p) p5x = startx + w p5y = starty + p p6x = startx + b p6y = starty poly = [ (p1x, p1y), (p2x, p2y), (p3x, p3y), (p4x, p4y), (p5x, p5y), (p6x, p6y), (p1x, p1y)] polygons.append(poly) counter += 1 startx += w starty += yoffset row += 1 return polygons
calculate_polygons
easy
[{"input": "1,1, 4, 4, 3", "output": "[[(-5.0, -4.196152422706632), (-5.0, -0.7320508075688767), (-2.0, 1.0), (1.0, -0.7320508075688767), (1.0, -4.196152422706632), (-2.0, -5.928203230275509), (-5.0, -4.196152422706632)], [(1.0, -4.196152422706632), (1.0, -0.7320508075688767), (4.0, 1.0), (7.0, -0.7320508075688767), (7.0, -4.196152422706632), (4.0, -5.928203230275509), (1.0, -4.196152422706632)], [(7.0, -4.196152422706632), (7.0, -0.7320508075688767), (10.0, 1.0), (13.0, -0.7320508075688767), (13.0, -4.196152422706632), (10.0, -5.928203230275509), (7.0, -4.196152422706632)], [(-2.0, 1.0000000000000004), (-2.0, 4.464101615137755), (1.0, 6.196152422706632), (4.0, 4.464101615137755), (4.0, 1.0000000000000004), (1.0, -0.7320508075688767), (-2.0, 1.0000000000000004)], [(4.0, 1.0000000000000004), (4.0, 4.464101615137755), (7.0, 6.196152422706632), (10.0, 4.464101615137755), (10.0, 1.0000000000000004), (7.0, -0.7320508075688767), (4.0, 1.0000000000000004)], [(-5.0, 6.196152422706632), (-5.0, 9.660254037844387), (-2.0, 11.392304845413264), (1.0, 9.660254037844387), (1.0, 6.196152422706632), (-2.0, 4.464101615137755), (-5.0, 6.196152422706632)], [(1.0, 6.196152422706632), (1.0, 9.660254037844387), (4.0, 11.392304845413264), (7.0, 9.660254037844387), (7.0, 6.196152422706632), (4.0, 4.464101615137755), (1.0, 6.196152422706632)], [(7.0, 6.196152422706632), (7.0, 9.660254037844387), (10.0, 11.392304845413264), (13.0, 9.660254037844387), (13.0, 6.196152422706632), (10.0, 4.464101615137755), (7.0, 6.196152422706632)], [(-2.0, 11.392304845413264), (-2.0, 14.85640646055102), (1.0, 16.588457268119896), (4.0, 14.85640646055102), (4.0, 11.392304845413264), (1.0, 9.660254037844387), (-2.0, 11.392304845413264)], [(4.0, 11.392304845413264), (4.0, 14.85640646055102), (7.0, 16.588457268119896), (10.0, 14.85640646055102), (10.0, 11.392304845413264), (7.0, 9.660254037844387), (4.0, 11.392304845413264)]]", "testtype": "functional"}]
Mbpp_493
Write a function to calculate a grid of hexagon coordinates where function returns a list of lists containing 6 tuples of x, y point coordinates.
493
mbpp
1
2024-11-26T21:40:54.477513
import math def calculate_polygons(startx, starty, endx, endy, radius): sl = (2 * radius) * math.tan(math.pi / 6) p = sl * 0.5 b = sl * math.cos(math.radians(30)) w = b * 2 h = 2 * sl startx = startx - w starty = starty - h endx = endx + w endy = endy + h origx = startx origy = starty xoffset = b yoffset = 3 * p polygons = [] row = 1 counter = 0 while starty < endy: if row % 2 == 0: startx = origx + xoffset else: startx = origx while startx < endx: p1x = startx p1y = starty + p p2x = startx p2y = starty + (3 * p) p3x = startx + b p3y = starty + h p4x = startx + w p4y = starty + (3 * p) p5x = startx + w p5y = starty + p p6x = startx + b p6y = starty poly = [ (p1x, p1y), (p2x, p2y), (p3x, p3y), (p4x, p4y), (p5x, p5y), (p6x, p6y), (p1x, p1y)] polygons.append(poly) counter += 1 startx += w starty += yoffset row += 1 return polygons
calculate_polygons
easy
[{"input": "5,4,7,9,8", "output": "[[(-11.0, -9.856406460551018), (-11.0, -0.6188021535170058), (-3.0, 4.0), (5.0, -0.6188021535170058), (5.0, -9.856406460551018), (-3.0, -14.475208614068023), (-11.0, -9.856406460551018)], [(5.0, -9.856406460551018), (5.0, -0.6188021535170058), (13.0, 4.0), (21.0, -0.6188021535170058), (21.0, -9.856406460551018), (13.0, -14.475208614068023), (5.0, -9.856406460551018)], [(21.0, -9.856406460551018), (21.0, -0.6188021535170058), (29.0, 4.0), (37.0, -0.6188021535170058), (37.0, -9.856406460551018), (29.0, -14.475208614068023), (21.0, -9.856406460551018)], [(-3.0, 4.0), (-3.0, 13.237604307034012), (5.0, 17.856406460551018), (13.0, 13.237604307034012), (13.0, 4.0), (5.0, -0.6188021535170058), (-3.0, 4.0)], [(13.0, 4.0), (13.0, 13.237604307034012), (21.0, 17.856406460551018), (29.0, 13.237604307034012), (29.0, 4.0), (21.0, -0.6188021535170058), (13.0, 4.0)], [(-11.0, 17.856406460551018), (-11.0, 27.09401076758503), (-3.0, 31.712812921102035), (5.0, 27.09401076758503), (5.0, 17.856406460551018), (-3.0, 13.237604307034012), (-11.0, 17.856406460551018)], [(5.0, 17.856406460551018), (5.0, 27.09401076758503), (13.0, 31.712812921102035), (21.0, 27.09401076758503), (21.0, 17.856406460551018), (13.0, 13.237604307034012), (5.0, 17.856406460551018)], [(21.0, 17.856406460551018), (21.0, 27.09401076758503), (29.0, 31.712812921102035), (37.0, 27.09401076758503), (37.0, 17.856406460551018), (29.0, 13.237604307034012), (21.0, 17.856406460551018)], [(-3.0, 31.712812921102035), (-3.0, 40.95041722813605), (5.0, 45.569219381653056), (13.0, 40.95041722813605), (13.0, 31.712812921102035), (5.0, 27.09401076758503), (-3.0, 31.712812921102035)], [(13.0, 31.712812921102035), (13.0, 40.95041722813605), (21.0, 45.569219381653056), (29.0, 40.95041722813605), (29.0, 31.712812921102035), (21.0, 27.09401076758503), (13.0, 31.712812921102035)]]", "testtype": "functional"}]
Mbpp_493
Write a function to calculate a grid of hexagon coordinates where function returns a list of lists containing 6 tuples of x, y point coordinates.
493
mbpp
2
2024-11-26T21:40:54.478901
import math def calculate_polygons(startx, starty, endx, endy, radius): sl = (2 * radius) * math.tan(math.pi / 6) p = sl * 0.5 b = sl * math.cos(math.radians(30)) w = b * 2 h = 2 * sl startx = startx - w starty = starty - h endx = endx + w endy = endy + h origx = startx origy = starty xoffset = b yoffset = 3 * p polygons = [] row = 1 counter = 0 while starty < endy: if row % 2 == 0: startx = origx + xoffset else: startx = origx while startx < endx: p1x = startx p1y = starty + p p2x = startx p2y = starty + (3 * p) p3x = startx + b p3y = starty + h p4x = startx + w p4y = starty + (3 * p) p5x = startx + w p5y = starty + p p6x = startx + b p6y = starty poly = [ (p1x, p1y), (p2x, p2y), (p3x, p3y), (p4x, p4y), (p5x, p5y), (p6x, p6y), (p1x, p1y)] polygons.append(poly) counter += 1 startx += w starty += yoffset row += 1 return polygons
calculate_polygons
easy
[{"input": "9,6,4,3,2", "output": "[[(5.0, 2.5358983848622456), (5.0, 4.8452994616207485), (7.0, 6.0), (9.0, 4.8452994616207485), (9.0, 2.5358983848622456), (7.0, 1.3811978464829942), (5.0, 2.5358983848622456)], [(7.0, 6.0), (7.0, 8.309401076758503), (9.0, 9.464101615137753), (11.0, 8.309401076758503), (11.0, 6.0), (9.0, 4.8452994616207485), (7.0, 6.0)]]", "testtype": "functional"}]
Mbpp_494
Write a function to convert the given binary tuple to integer.
494
mbpp
0
2024-11-26T21:40:54.479166
def binary_to_integer(test_tup): res = int("".join(str(ele) for ele in test_tup), 2) return (str(res))
binary_to_integer
easy
[{"input": "(1, 1, 0, 1, 0, 0, 1)", "output": "'105'", "testtype": "functional"}]
Mbpp_494
Write a function to convert the given binary tuple to integer.
494
mbpp
1
2024-11-26T21:40:54.479350
def binary_to_integer(test_tup): res = int("".join(str(ele) for ele in test_tup), 2) return (str(res))
binary_to_integer
easy
[{"input": "(0, 1, 1, 0, 0, 1, 0, 1)", "output": "'101'", "testtype": "functional"}]
Mbpp_494
Write a function to convert the given binary tuple to integer.
494
mbpp
2
2024-11-26T21:40:54.479531
def binary_to_integer(test_tup): res = int("".join(str(ele) for ele in test_tup), 2) return (str(res))
binary_to_integer
easy
[{"input": "(1, 1, 0, 1, 0, 1)", "output": "'53'", "testtype": "functional"}]
Mbpp_495
Write a function to remove lowercase substrings from a given string by using regex.
495
mbpp
0
2024-11-26T21:40:54.479754
import re def remove_lowercase(str1): remove_lower = lambda text: re.sub('[a-z]', '', text) result = remove_lower(str1) return (result)
remove_lowercase
easy
[{"input": "'KDeoALOklOOHserfLoAJSIskdsf'", "output": "'KDALOOOHLAJSI'", "testtype": "functional"}]
Mbpp_495
Write a function to remove lowercase substrings from a given string by using regex.
495
mbpp
1
2024-11-26T21:40:54.479942
import re def remove_lowercase(str1): remove_lower = lambda text: re.sub('[a-z]', '', text) result = remove_lower(str1) return (result)
remove_lowercase
easy
[{"input": "'ProducTnamEstreAmIngMediAplAYer'", "output": "'PTEAIMAAY'", "testtype": "functional"}]
Mbpp_495
Write a function to remove lowercase substrings from a given string by using regex.
495
mbpp
2
2024-11-26T21:40:54.480138
import re def remove_lowercase(str1): remove_lower = lambda text: re.sub('[a-z]', '', text) result = remove_lower(str1) return (result)
remove_lowercase
easy
[{"input": "'maNufacTuredbYSheZenTechNolOGIes'", "output": "'NTYSZTNOGI'", "testtype": "functional"}]
Mbpp_496
Write a function to find the smallest integers from a given list of numbers using heap queue algorithm.
496
mbpp
0
2024-11-26T21:40:54.480297
import heapq as hq def heap_queue_smallest(nums,n): smallest_nums = hq.nsmallest(n, nums) return smallest_nums
heap_queue_smallest
easy
[{"input": " [25, 35, 22, 85, 14, 65, 75, 25, 58],3", "output": "[14, 22, 25]", "testtype": "functional"}]