task_name stringclasses 1
value | src_lang stringclasses 1
value | tgt_lang stringclasses 1
value | data_id stringlengths 10 12 | demos listlengths 0 0 | compare_func listlengths 0 0 | dataset_name stringclasses 1
value | suffix stringlengths 0 672 | test_cases listlengths 0 5 | entry_func stringlengths 3 31 | import_str listlengths 0 1 | doc_string stringlengths 39 252 | prefix stringlengths 80 786 | solution stringlengths 11 142 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
code_infilling | python | python | MBPP/95/L1 | [] | [] | MBPP_Infilling | return minLength | [
[
"[[1],[1,2]]",
"1"
],
[
"[[1,2],[1,2,3],[1,2,3,4]]",
"2"
],
[
"[[3,3,3],[4,4,4,4]]",
"3"
]
] | Find_Min_Length | [] | Write a python function to find the length of the smallest list in a list of lists. | def Find_Min_Length(lst):
"""Write a python function to find the length of the smallest list in a list of lists. """
|
minLength = min((len(x) for x in lst))
|
code_infilling | python | python | MBPP/95/L2 | [] | [] | MBPP_Infilling | [
[
"[[1],[1,2]]",
"1"
],
[
"[[1,2],[1,2,3],[1,2,3,4]]",
"2"
],
[
"[[3,3,3],[4,4,4,4]]",
"3"
]
] | Find_Min_Length | [] | Write a python function to find the length of the smallest list in a list of lists. | def Find_Min_Length(lst):
"""Write a python function to find the length of the smallest list in a list of lists. """
minLength = min((len(x) for x in lst)) |
return minLength
| |
code_infilling | python | python | MBPP/96/L1 | [] | [] | MBPP_Infilling | x = len([i for i in range(1, n + 1) if not n % i])
return x | [
[
"15",
"4"
],
[
"12",
"6"
],
[
"9",
"3"
]
] | divisor | [] | Write a python function to find the number of divisors of a given integer. | def divisor(n):
"""Write a python function to find the number of divisors of a given integer. """
|
for i in range(n):
|
code_infilling | python | python | MBPP/96/L2 | [] | [] | MBPP_Infilling | return x | [
[
"15",
"4"
],
[
"12",
"6"
],
[
"9",
"3"
]
] | divisor | [] | Write a python function to find the number of divisors of a given integer. | def divisor(n):
"""Write a python function to find the number of divisors of a given integer. """
for i in range(n): |
x = len([i for i in range(1, n + 1) if not n % i])
|
code_infilling | python | python | MBPP/96/L3 | [] | [] | MBPP_Infilling | [
[
"15",
"4"
],
[
"12",
"6"
],
[
"9",
"3"
]
] | divisor | [] | Write a python function to find the number of divisors of a given integer. | def divisor(n):
"""Write a python function to find the number of divisors of a given integer. """
for i in range(n):
x = len([i for i in range(1, n + 1) if not n % i]) |
return x
| |
code_infilling | python | python | MBPP/97/L1 | [] | [] | MBPP_Infilling | dic_data = {}
for num in list1:
if num in dic_data.keys():
dic_data[num] += 1
else:
key = num
value = 1
dic_data[key] = value
return dic_data | [
[
"[[1, 2, 3, 2], [4, 5, 6, 2], [7, 8, 9, 5]]",
"{1: 1, 2: 3, 3: 1, 4: 1, 5: 2, 6: 1, 7: 1, 8: 1, 9: 1}"
],
[
"[[1,2,3,4],[5,6,7,8],[9,10,11,12]]",
"{1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1,10:1,11:1,12:1}"
],
[
"[[20,30,40,17],[18,16,14,13],[10,20,30,40]]",
"{20:2,30:2,... | frequency_lists | [] | Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary. | def frequency_lists(list1):
"""Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary. """
|
list1 = [item for sublist in list1 for item in sublist]
|
code_infilling | python | python | MBPP/97/L2 | [] | [] | MBPP_Infilling | for num in list1:
if num in dic_data.keys():
dic_data[num] += 1
else:
key = num
value = 1
dic_data[key] = value
return dic_data | [
[
"[[1, 2, 3, 2], [4, 5, 6, 2], [7, 8, 9, 5]]",
"{1: 1, 2: 3, 3: 1, 4: 1, 5: 2, 6: 1, 7: 1, 8: 1, 9: 1}"
],
[
"[[1,2,3,4],[5,6,7,8],[9,10,11,12]]",
"{1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1,10:1,11:1,12:1}"
],
[
"[[20,30,40,17],[18,16,14,13],[10,20,30,40]]",
"{20:2,30:2,... | frequency_lists | [] | Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary. | def frequency_lists(list1):
"""Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary. """
list1 = [item for sublist in list1 for item in sublist] |
dic_data = {}
|
code_infilling | python | python | MBPP/97/L3 | [] | [] | MBPP_Infilling | if num in dic_data.keys():
dic_data[num] += 1
else:
key = num
value = 1
dic_data[key] = value
return dic_data | [
[
"[[1, 2, 3, 2], [4, 5, 6, 2], [7, 8, 9, 5]]",
"{1: 1, 2: 3, 3: 1, 4: 1, 5: 2, 6: 1, 7: 1, 8: 1, 9: 1}"
],
[
"[[1,2,3,4],[5,6,7,8],[9,10,11,12]]",
"{1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1,10:1,11:1,12:1}"
],
[
"[[20,30,40,17],[18,16,14,13],[10,20,30,40]]",
"{20:2,30:2,... | frequency_lists | [] | Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary. | def frequency_lists(list1):
"""Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary. """
list1 = [item for sublist in list1 for item in sublist]
dic_data = {} |
for num in list1:
|
code_infilling | python | python | MBPP/97/L4 | [] | [] | MBPP_Infilling | dic_data[num] += 1
else:
key = num
value = 1
dic_data[key] = value
return dic_data | [
[
"[[1, 2, 3, 2], [4, 5, 6, 2], [7, 8, 9, 5]]",
"{1: 1, 2: 3, 3: 1, 4: 1, 5: 2, 6: 1, 7: 1, 8: 1, 9: 1}"
],
[
"[[1,2,3,4],[5,6,7,8],[9,10,11,12]]",
"{1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1,10:1,11:1,12:1}"
],
[
"[[20,30,40,17],[18,16,14,13],[10,20,30,40]]",
"{20:2,30:2,... | frequency_lists | [] | Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary. | def frequency_lists(list1):
"""Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary. """
list1 = [item for sublist in list1 for item in sublist]
dic_data = {}
for num in list1: |
if num in dic_data.keys():
|
code_infilling | python | python | MBPP/97/L5 | [] | [] | MBPP_Infilling | else:
key = num
value = 1
dic_data[key] = value
return dic_data | [
[
"[[1, 2, 3, 2], [4, 5, 6, 2], [7, 8, 9, 5]]",
"{1: 1, 2: 3, 3: 1, 4: 1, 5: 2, 6: 1, 7: 1, 8: 1, 9: 1}"
],
[
"[[1,2,3,4],[5,6,7,8],[9,10,11,12]]",
"{1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1,10:1,11:1,12:1}"
],
[
"[[20,30,40,17],[18,16,14,13],[10,20,30,40]]",
"{20:2,30:2,... | frequency_lists | [] | Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary. | def frequency_lists(list1):
"""Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary. """
list1 = [item for sublist in list1 for item in sublist]
dic_data = {}
for num in list1:
if num in dic_data.keys(): |
dic_data[num] += 1
|
code_infilling | python | python | MBPP/97/L6 | [] | [] | MBPP_Infilling | key = num
value = 1
dic_data[key] = value
return dic_data | [
[
"[[1, 2, 3, 2], [4, 5, 6, 2], [7, 8, 9, 5]]",
"{1: 1, 2: 3, 3: 1, 4: 1, 5: 2, 6: 1, 7: 1, 8: 1, 9: 1}"
],
[
"[[1,2,3,4],[5,6,7,8],[9,10,11,12]]",
"{1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1,10:1,11:1,12:1}"
],
[
"[[20,30,40,17],[18,16,14,13],[10,20,30,40]]",
"{20:2,30:2,... | frequency_lists | [] | Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary. | def frequency_lists(list1):
"""Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary. """
list1 = [item for sublist in list1 for item in sublist]
dic_data = {}
for num in list1:
if num in dic_data.keys():
dic_data[num] += 1 |
else:
|
code_infilling | python | python | MBPP/97/L7 | [] | [] | MBPP_Infilling | value = 1
dic_data[key] = value
return dic_data | [
[
"[[1, 2, 3, 2], [4, 5, 6, 2], [7, 8, 9, 5]]",
"{1: 1, 2: 3, 3: 1, 4: 1, 5: 2, 6: 1, 7: 1, 8: 1, 9: 1}"
],
[
"[[1,2,3,4],[5,6,7,8],[9,10,11,12]]",
"{1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1,10:1,11:1,12:1}"
],
[
"[[20,30,40,17],[18,16,14,13],[10,20,30,40]]",
"{20:2,30:2,... | frequency_lists | [] | Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary. | def frequency_lists(list1):
"""Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary. """
list1 = [item for sublist in list1 for item in sublist]
dic_data = {}
for num in list1:
if num in dic_data.keys():
dic_data[num] += 1
... |
key = num
|
code_infilling | python | python | MBPP/97/L8 | [] | [] | MBPP_Infilling | dic_data[key] = value
return dic_data | [
[
"[[1, 2, 3, 2], [4, 5, 6, 2], [7, 8, 9, 5]]",
"{1: 1, 2: 3, 3: 1, 4: 1, 5: 2, 6: 1, 7: 1, 8: 1, 9: 1}"
],
[
"[[1,2,3,4],[5,6,7,8],[9,10,11,12]]",
"{1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1,10:1,11:1,12:1}"
],
[
"[[20,30,40,17],[18,16,14,13],[10,20,30,40]]",
"{20:2,30:2,... | frequency_lists | [] | Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary. | def frequency_lists(list1):
"""Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary. """
list1 = [item for sublist in list1 for item in sublist]
dic_data = {}
for num in list1:
if num in dic_data.keys():
dic_data[num] += 1
... |
value = 1
|
code_infilling | python | python | MBPP/97/L9 | [] | [] | MBPP_Infilling | return dic_data | [
[
"[[1, 2, 3, 2], [4, 5, 6, 2], [7, 8, 9, 5]]",
"{1: 1, 2: 3, 3: 1, 4: 1, 5: 2, 6: 1, 7: 1, 8: 1, 9: 1}"
],
[
"[[1,2,3,4],[5,6,7,8],[9,10,11,12]]",
"{1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1,10:1,11:1,12:1}"
],
[
"[[20,30,40,17],[18,16,14,13],[10,20,30,40]]",
"{20:2,30:2,... | frequency_lists | [] | Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary. | def frequency_lists(list1):
"""Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary. """
list1 = [item for sublist in list1 for item in sublist]
dic_data = {}
for num in list1:
if num in dic_data.keys():
dic_data[num] += 1
... |
dic_data[key] = value
|
code_infilling | python | python | MBPP/97/L10 | [] | [] | MBPP_Infilling | [
[
"[[1, 2, 3, 2], [4, 5, 6, 2], [7, 8, 9, 5]]",
"{1: 1, 2: 3, 3: 1, 4: 1, 5: 2, 6: 1, 7: 1, 8: 1, 9: 1}"
],
[
"[[1,2,3,4],[5,6,7,8],[9,10,11,12]]",
"{1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1,10:1,11:1,12:1}"
],
[
"[[20,30,40,17],[18,16,14,13],[10,20,30,40]]",
"{20:2,30:2,... | frequency_lists | [] | Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary. | def frequency_lists(list1):
"""Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary. """
list1 = [item for sublist in list1 for item in sublist]
dic_data = {}
for num in list1:
if num in dic_data.keys():
dic_data[num] += 1
... |
return dic_data
| |
code_infilling | python | python | MBPP/98/L1 | [] | [] | MBPP_Infilling | for x in numbers:
total *= x
return total / len(numbers) | [] | multiply_num | [] | Write a function to multiply all the numbers in a list and divide with the length of the list. | def multiply_num(numbers):
"""Write a function to multiply all the numbers in a list and divide with the length of the list. """
|
total = 1
|
code_infilling | python | python | MBPP/98/L2 | [] | [] | MBPP_Infilling | total *= x
return total / len(numbers) | [] | multiply_num | [] | Write a function to multiply all the numbers in a list and divide with the length of the list. | def multiply_num(numbers):
"""Write a function to multiply all the numbers in a list and divide with the length of the list. """
total = 1 |
for x in numbers:
|
code_infilling | python | python | MBPP/98/L3 | [] | [] | MBPP_Infilling | return total / len(numbers) | [] | multiply_num | [] | Write a function to multiply all the numbers in a list and divide with the length of the list. | def multiply_num(numbers):
"""Write a function to multiply all the numbers in a list and divide with the length of the list. """
total = 1
for x in numbers: |
total *= x
|
code_infilling | python | python | MBPP/98/L4 | [] | [] | MBPP_Infilling | [] | multiply_num | [] | Write a function to multiply all the numbers in a list and divide with the length of the list. | def multiply_num(numbers):
"""Write a function to multiply all the numbers in a list and divide with the length of the list. """
total = 1
for x in numbers:
total *= x |
return total / len(numbers)
| |
code_infilling | python | python | MBPP/99/L1 | [] | [] | MBPP_Infilling | [
[
"8",
"'1000'"
],
[
"18",
"'10010'"
],
[
"7",
"'111'"
]
] | decimal_to_binary | [] | Write a function to convert the given decimal number to its binary equivalent, represented as a string with no leading zeros. | def decimal_to_binary(n):
"""Write a function to convert the given decimal number to its binary equivalent, represented as a string with no leading zeros. """
|
return bin(n).replace('0b', '')
| |
code_infilling | python | python | MBPP/100/L3 | [] | [] | MBPP_Infilling | for i in range(num + 1, sys.maxsize):
if str(i) == str(i)[::-1]:
return i | [
[
"99",
"101"
],
[
"1221",
"1331"
],
[
"120",
"121"
]
] | next_smallest_palindrome | [
"import sys"
] | Write a function to find the next smallest palindrome of a specified integer, returned as an integer. | import sys
def next_smallest_palindrome(num):
"""Write a function to find the next smallest palindrome of a specified integer, returned as an integer. """
|
numstr = str(num)
|
code_infilling | python | python | MBPP/100/L4 | [] | [] | MBPP_Infilling | if str(i) == str(i)[::-1]:
return i | [
[
"99",
"101"
],
[
"1221",
"1331"
],
[
"120",
"121"
]
] | next_smallest_palindrome | [
"import sys"
] | Write a function to find the next smallest palindrome of a specified integer, returned as an integer. | import sys
def next_smallest_palindrome(num):
"""Write a function to find the next smallest palindrome of a specified integer, returned as an integer. """
numstr = str(num) |
for i in range(num + 1, sys.maxsize):
|
code_infilling | python | python | MBPP/100/L5 | [] | [] | MBPP_Infilling | return i | [
[
"99",
"101"
],
[
"1221",
"1331"
],
[
"120",
"121"
]
] | next_smallest_palindrome | [
"import sys"
] | Write a function to find the next smallest palindrome of a specified integer, returned as an integer. | import sys
def next_smallest_palindrome(num):
"""Write a function to find the next smallest palindrome of a specified integer, returned as an integer. """
numstr = str(num)
for i in range(num + 1, sys.maxsize): |
if str(i) == str(i)[::-1]:
|
code_infilling | python | python | MBPP/100/L6 | [] | [] | MBPP_Infilling | [
[
"99",
"101"
],
[
"1221",
"1331"
],
[
"120",
"121"
]
] | next_smallest_palindrome | [
"import sys"
] | Write a function to find the next smallest palindrome of a specified integer, returned as an integer. | import sys
def next_smallest_palindrome(num):
"""Write a function to find the next smallest palindrome of a specified integer, returned as an integer. """
numstr = str(num)
for i in range(num + 1, sys.maxsize):
if str(i) == str(i)[::-1]: |
return i
| |
code_infilling | python | python | MBPP/101/L1 | [] | [] | MBPP_Infilling | for i in range(n):
for j in range(0, n - i - 1):
if arr[j] > arr[j + 1]:
(arr[j], arr[j + 1] == arr[j + 1], arr[j])
return arr[k - 1] | [
[
"[12,3,5,7,19], 2",
"3"
],
[
"[17,24,8,23], 3",
"8"
],
[
"[16,21,25,36,4], 4",
"36"
]
] | kth_element | [] | Write a function to find the kth element in the given array using 1-based indexing. | def kth_element(arr, k):
"""Write a function to find the kth element in the given array using 1-based indexing. """
|
n = len(arr)
|
code_infilling | python | python | MBPP/101/L2 | [] | [] | MBPP_Infilling | for j in range(0, n - i - 1):
if arr[j] > arr[j + 1]:
(arr[j], arr[j + 1] == arr[j + 1], arr[j])
return arr[k - 1] | [
[
"[12,3,5,7,19], 2",
"3"
],
[
"[17,24,8,23], 3",
"8"
],
[
"[16,21,25,36,4], 4",
"36"
]
] | kth_element | [] | Write a function to find the kth element in the given array using 1-based indexing. | def kth_element(arr, k):
"""Write a function to find the kth element in the given array using 1-based indexing. """
n = len(arr) |
for i in range(n):
|
code_infilling | python | python | MBPP/101/L3 | [] | [] | MBPP_Infilling | if arr[j] > arr[j + 1]:
(arr[j], arr[j + 1] == arr[j + 1], arr[j])
return arr[k - 1] | [
[
"[12,3,5,7,19], 2",
"3"
],
[
"[17,24,8,23], 3",
"8"
],
[
"[16,21,25,36,4], 4",
"36"
]
] | kth_element | [] | Write a function to find the kth element in the given array using 1-based indexing. | def kth_element(arr, k):
"""Write a function to find the kth element in the given array using 1-based indexing. """
n = len(arr)
for i in range(n): |
for j in range(0, n - i - 1):
|
code_infilling | python | python | MBPP/101/L4 | [] | [] | MBPP_Infilling | (arr[j], arr[j + 1] == arr[j + 1], arr[j])
return arr[k - 1] | [
[
"[12,3,5,7,19], 2",
"3"
],
[
"[17,24,8,23], 3",
"8"
],
[
"[16,21,25,36,4], 4",
"36"
]
] | kth_element | [] | Write a function to find the kth element in the given array using 1-based indexing. | def kth_element(arr, k):
"""Write a function to find the kth element in the given array using 1-based indexing. """
n = len(arr)
for i in range(n):
for j in range(0, n - i - 1): |
if arr[j] > arr[j + 1]:
|
code_infilling | python | python | MBPP/101/L5 | [] | [] | MBPP_Infilling | return arr[k - 1] | [
[
"[12,3,5,7,19], 2",
"3"
],
[
"[17,24,8,23], 3",
"8"
],
[
"[16,21,25,36,4], 4",
"36"
]
] | kth_element | [] | Write a function to find the kth element in the given array using 1-based indexing. | def kth_element(arr, k):
"""Write a function to find the kth element in the given array using 1-based indexing. """
n = len(arr)
for i in range(n):
for j in range(0, n - i - 1):
if arr[j] > arr[j + 1]: |
(arr[j], arr[j + 1] == arr[j + 1], arr[j])
|
code_infilling | python | python | MBPP/101/L6 | [] | [] | MBPP_Infilling | [
[
"[12,3,5,7,19], 2",
"3"
],
[
"[17,24,8,23], 3",
"8"
],
[
"[16,21,25,36,4], 4",
"36"
]
] | kth_element | [] | Write a function to find the kth element in the given array using 1-based indexing. | def kth_element(arr, k):
"""Write a function to find the kth element in the given array using 1-based indexing. """
n = len(arr)
for i in range(n):
for j in range(0, n - i - 1):
if arr[j] > arr[j + 1]:
(arr[j], arr[j + 1] == arr[j + 1], arr[j]) |
return arr[k - 1]
| |
code_infilling | python | python | MBPP/102/L1 | [] | [] | MBPP_Infilling | return ''.join((x.capitalize() or '_' for x in word.split('_'))) | [
[
"'python_program'",
"'PythonProgram'"
],
[
"'python_language'",
"('PythonLanguage')"
],
[
"'programming_language'",
"('ProgrammingLanguage')"
]
] | snake_to_camel | [
"import re"
] | Write a function to convert a snake case string to camel case string. | def snake_to_camel(word):
"""Write a function to convert a snake case string to camel case string. """
|
import re
|
code_infilling | python | python | MBPP/102/L2 | [] | [] | MBPP_Infilling | [
[
"'python_program'",
"'PythonProgram'"
],
[
"'python_language'",
"('PythonLanguage')"
],
[
"'programming_language'",
"('ProgrammingLanguage')"
]
] | snake_to_camel | [
"import re"
] | Write a function to convert a snake case string to camel case string. | def snake_to_camel(word):
"""Write a function to convert a snake case string to camel case string. """
import re |
return ''.join((x.capitalize() or '_' for x in word.split('_')))
| |
code_infilling | python | python | MBPP/103/L1 | [] | [] | MBPP_Infilling | return 0
if m == 0:
return 1
return (n - m) * eulerian_num(n - 1, m - 1) + (m + 1) * eulerian_num(n - 1, m) | [
[
"3, 1",
"4"
],
[
"4, 1",
"11"
],
[
"5, 3",
"26"
]
] | eulerian_num | [] | Write a function to find the Eulerian number a(n, m). | def eulerian_num(n, m):
"""Write a function to find the Eulerian number a(n, m). """
|
if m >= n or n == 0:
|
code_infilling | python | python | MBPP/103/L2 | [] | [] | MBPP_Infilling | if m == 0:
return 1
return (n - m) * eulerian_num(n - 1, m - 1) + (m + 1) * eulerian_num(n - 1, m) | [
[
"3, 1",
"4"
],
[
"4, 1",
"11"
],
[
"5, 3",
"26"
]
] | eulerian_num | [] | Write a function to find the Eulerian number a(n, m). | def eulerian_num(n, m):
"""Write a function to find the Eulerian number a(n, m). """
if m >= n or n == 0: |
return 0
|
code_infilling | python | python | MBPP/103/L3 | [] | [] | MBPP_Infilling | return 1
return (n - m) * eulerian_num(n - 1, m - 1) + (m + 1) * eulerian_num(n - 1, m) | [
[
"3, 1",
"4"
],
[
"4, 1",
"11"
],
[
"5, 3",
"26"
]
] | eulerian_num | [] | Write a function to find the Eulerian number a(n, m). | def eulerian_num(n, m):
"""Write a function to find the Eulerian number a(n, m). """
if m >= n or n == 0:
return 0 |
if m == 0:
|
code_infilling | python | python | MBPP/103/L4 | [] | [] | MBPP_Infilling | return (n - m) * eulerian_num(n - 1, m - 1) + (m + 1) * eulerian_num(n - 1, m) | [
[
"3, 1",
"4"
],
[
"4, 1",
"11"
],
[
"5, 3",
"26"
]
] | eulerian_num | [] | Write a function to find the Eulerian number a(n, m). | def eulerian_num(n, m):
"""Write a function to find the Eulerian number a(n, m). """
if m >= n or n == 0:
return 0
if m == 0: |
return 1
|
code_infilling | python | python | MBPP/103/L5 | [] | [] | MBPP_Infilling | [
[
"3, 1",
"4"
],
[
"4, 1",
"11"
],
[
"5, 3",
"26"
]
] | eulerian_num | [] | Write a function to find the Eulerian number a(n, m). | def eulerian_num(n, m):
"""Write a function to find the Eulerian number a(n, m). """
if m >= n or n == 0:
return 0
if m == 0:
return 1 |
return (n - m) * eulerian_num(n - 1, m - 1) + (m + 1) * eulerian_num(n - 1, m)
| |
code_infilling | python | python | MBPP/104/L1 | [] | [] | MBPP_Infilling | return result | [
[
"([\"green\", \"orange\"], [\"black\", \"white\"], [\"white\", \"black\", \"orange\"])",
"[['green', 'orange'], ['black', 'white'], ['black', 'orange', 'white']]"
],
[
"([\" red \",\"green\" ],[\"blue \",\" black\"],[\" orange\",\"brown\"])",
"[[' red ', 'green'], [' black', 'blue '], [' orang... | sort_sublists | [] | Write a function to sort each sublist of strings in a given list of lists. | def sort_sublists(input_list):
"""Write a function to sort each sublist of strings in a given list of lists. """
|
result = [sorted(x, key=lambda x: x[0]) for x in input_list]
|
code_infilling | python | python | MBPP/104/L2 | [] | [] | MBPP_Infilling | [
[
"([\"green\", \"orange\"], [\"black\", \"white\"], [\"white\", \"black\", \"orange\"])",
"[['green', 'orange'], ['black', 'white'], ['black', 'orange', 'white']]"
],
[
"([\" red \",\"green\" ],[\"blue \",\" black\"],[\" orange\",\"brown\"])",
"[[' red ', 'green'], [' black', 'blue '], [' orang... | sort_sublists | [] | Write a function to sort each sublist of strings in a given list of lists. | def sort_sublists(input_list):
"""Write a function to sort each sublist of strings in a given list of lists. """
result = [sorted(x, key=lambda x: x[0]) for x in input_list] |
return result
| |
code_infilling | python | python | MBPP/105/L1 | [] | [] | MBPP_Infilling | [
[
"[True,False,True]",
"2"
],
[
"[False,False]",
"0"
],
[
"[True,True,True]",
"3"
]
] | count | [] | Write a python function to count true booleans in the given list. | def count(lst):
"""Write a python function to count true booleans in the given list. """
|
return sum(lst)
| |
code_infilling | python | python | MBPP/106/L1 | [] | [] | MBPP_Infilling | return res | [
[
"[5, 6, 7], (9, 10)",
"(9, 10, 5, 6, 7)"
],
[
"[6, 7, 8], (10, 11)",
"(10, 11, 6, 7, 8)"
],
[
"[7, 8, 9], (11, 12)",
"(11, 12, 7, 8, 9)"
]
] | add_lists | [] | Write a function to append the given list to the given tuples. | def add_lists(test_list, test_tup):
"""Write a function to append the given list to the given tuples. """
|
res = tuple(list(test_tup) + test_list)
|
code_infilling | python | python | MBPP/106/L2 | [] | [] | MBPP_Infilling | [
[
"[5, 6, 7], (9, 10)",
"(9, 10, 5, 6, 7)"
],
[
"[6, 7, 8], (10, 11)",
"(10, 11, 6, 7, 8)"
],
[
"[7, 8, 9], (11, 12)",
"(11, 12, 7, 8, 9)"
]
] | add_lists | [] | Write a function to append the given list to the given tuples. | def add_lists(test_list, test_tup):
"""Write a function to append the given list to the given tuples. """
res = tuple(list(test_tup) + test_list) |
return res
| |
code_infilling | python | python | MBPP/108/L3 | [] | [] | MBPP_Infilling | num2 = sorted(num2)
num3 = sorted(num3)
result = heapq.merge(num1, num2, num3)
return list(result) | [
[
"[25, 24, 15, 4, 5, 29, 110],[19, 20, 11, 56, 25, 233, 154],[24, 26, 54, 48]",
"[4, 5, 11, 15, 19, 20, 24, 24, 25, 25, 26, 29, 48, 54, 56, 110, 154, 233]"
],
[
"[1, 3, 5, 6, 8, 9], [2, 5, 7, 11], [1, 4, 7, 8, 12]",
"[1, 1, 2, 3, 4, 5, 5, 6, 7, 7, 8, 8, 9, 11, 12]"
],
[
"[18, 14, 10, 9,... | merge_sorted_list | [
"import heapq"
] | Write a function to merge three lists into a single sorted list. | import heapq
def merge_sorted_list(num1, num2, num3):
"""Write a function to merge three lists into a single sorted list. """
|
num1 = sorted(num1)
|
code_infilling | python | python | MBPP/108/L4 | [] | [] | MBPP_Infilling | num3 = sorted(num3)
result = heapq.merge(num1, num2, num3)
return list(result) | [
[
"[25, 24, 15, 4, 5, 29, 110],[19, 20, 11, 56, 25, 233, 154],[24, 26, 54, 48]",
"[4, 5, 11, 15, 19, 20, 24, 24, 25, 25, 26, 29, 48, 54, 56, 110, 154, 233]"
],
[
"[1, 3, 5, 6, 8, 9], [2, 5, 7, 11], [1, 4, 7, 8, 12]",
"[1, 1, 2, 3, 4, 5, 5, 6, 7, 7, 8, 8, 9, 11, 12]"
],
[
"[18, 14, 10, 9,... | merge_sorted_list | [
"import heapq"
] | Write a function to merge three lists into a single sorted list. | import heapq
def merge_sorted_list(num1, num2, num3):
"""Write a function to merge three lists into a single sorted list. """
num1 = sorted(num1) |
num2 = sorted(num2)
|
code_infilling | python | python | MBPP/108/L5 | [] | [] | MBPP_Infilling | result = heapq.merge(num1, num2, num3)
return list(result) | [
[
"[25, 24, 15, 4, 5, 29, 110],[19, 20, 11, 56, 25, 233, 154],[24, 26, 54, 48]",
"[4, 5, 11, 15, 19, 20, 24, 24, 25, 25, 26, 29, 48, 54, 56, 110, 154, 233]"
],
[
"[1, 3, 5, 6, 8, 9], [2, 5, 7, 11], [1, 4, 7, 8, 12]",
"[1, 1, 2, 3, 4, 5, 5, 6, 7, 7, 8, 8, 9, 11, 12]"
],
[
"[18, 14, 10, 9,... | merge_sorted_list | [
"import heapq"
] | Write a function to merge three lists into a single sorted list. | import heapq
def merge_sorted_list(num1, num2, num3):
"""Write a function to merge three lists into a single sorted list. """
num1 = sorted(num1)
num2 = sorted(num2) |
num3 = sorted(num3)
|
code_infilling | python | python | MBPP/108/L6 | [] | [] | MBPP_Infilling | return list(result) | [
[
"[25, 24, 15, 4, 5, 29, 110],[19, 20, 11, 56, 25, 233, 154],[24, 26, 54, 48]",
"[4, 5, 11, 15, 19, 20, 24, 24, 25, 25, 26, 29, 48, 54, 56, 110, 154, 233]"
],
[
"[1, 3, 5, 6, 8, 9], [2, 5, 7, 11], [1, 4, 7, 8, 12]",
"[1, 1, 2, 3, 4, 5, 5, 6, 7, 7, 8, 8, 9, 11, 12]"
],
[
"[18, 14, 10, 9,... | merge_sorted_list | [
"import heapq"
] | Write a function to merge three lists into a single sorted list. | import heapq
def merge_sorted_list(num1, num2, num3):
"""Write a function to merge three lists into a single sorted list. """
num1 = sorted(num1)
num2 = sorted(num2)
num3 = sorted(num3) |
result = heapq.merge(num1, num2, num3)
|
code_infilling | python | python | MBPP/108/L7 | [] | [] | MBPP_Infilling | [
[
"[25, 24, 15, 4, 5, 29, 110],[19, 20, 11, 56, 25, 233, 154],[24, 26, 54, 48]",
"[4, 5, 11, 15, 19, 20, 24, 24, 25, 25, 26, 29, 48, 54, 56, 110, 154, 233]"
],
[
"[1, 3, 5, 6, 8, 9], [2, 5, 7, 11], [1, 4, 7, 8, 12]",
"[1, 1, 2, 3, 4, 5, 5, 6, 7, 7, 8, 8, 9, 11, 12]"
],
[
"[18, 14, 10, 9,... | merge_sorted_list | [
"import heapq"
] | Write a function to merge three lists into a single sorted list. | import heapq
def merge_sorted_list(num1, num2, num3):
"""Write a function to merge three lists into a single sorted list. """
num1 = sorted(num1)
num2 = sorted(num2)
num3 = sorted(num3)
result = heapq.merge(num1, num2, num3) |
return list(result)
| |
code_infilling | python | python | MBPP/109/L1 | [] | [] | MBPP_Infilling | for i in range(0, n):
if s[i] == '1':
count = count + 1
return count | [
[
"\"011001\",6",
"3"
],
[
"\"11011\",5",
"4"
],
[
"\"1010\",4",
"2"
]
] | odd_Equivalent | [] | Write a python function to find the number of numbers with an odd value when rotating a binary string the given number of times. | def odd_Equivalent(s, n):
"""Write a python function to find the number of numbers with an odd value when rotating a binary string the given number of times. """
|
count = 0
|
code_infilling | python | python | MBPP/109/L2 | [] | [] | MBPP_Infilling | if s[i] == '1':
count = count + 1
return count | [
[
"\"011001\",6",
"3"
],
[
"\"11011\",5",
"4"
],
[
"\"1010\",4",
"2"
]
] | odd_Equivalent | [] | Write a python function to find the number of numbers with an odd value when rotating a binary string the given number of times. | def odd_Equivalent(s, n):
"""Write a python function to find the number of numbers with an odd value when rotating a binary string the given number of times. """
count = 0 |
for i in range(0, n):
|
code_infilling | python | python | MBPP/109/L3 | [] | [] | MBPP_Infilling | count = count + 1
return count | [
[
"\"011001\",6",
"3"
],
[
"\"11011\",5",
"4"
],
[
"\"1010\",4",
"2"
]
] | odd_Equivalent | [] | Write a python function to find the number of numbers with an odd value when rotating a binary string the given number of times. | def odd_Equivalent(s, n):
"""Write a python function to find the number of numbers with an odd value when rotating a binary string the given number of times. """
count = 0
for i in range(0, n): |
if s[i] == '1':
|
code_infilling | python | python | MBPP/109/L4 | [] | [] | MBPP_Infilling | return count | [
[
"\"011001\",6",
"3"
],
[
"\"11011\",5",
"4"
],
[
"\"1010\",4",
"2"
]
] | odd_Equivalent | [] | Write a python function to find the number of numbers with an odd value when rotating a binary string the given number of times. | def odd_Equivalent(s, n):
"""Write a python function to find the number of numbers with an odd value when rotating a binary string the given number of times. """
count = 0
for i in range(0, n):
if s[i] == '1': |
count = count + 1
|
code_infilling | python | python | MBPP/109/L5 | [] | [] | MBPP_Infilling | [
[
"\"011001\",6",
"3"
],
[
"\"11011\",5",
"4"
],
[
"\"1010\",4",
"2"
]
] | odd_Equivalent | [] | Write a python function to find the number of numbers with an odd value when rotating a binary string the given number of times. | def odd_Equivalent(s, n):
"""Write a python function to find the number of numbers with an odd value when rotating a binary string the given number of times. """
count = 0
for i in range(0, n):
if s[i] == '1':
count = count + 1 |
return count
| |
code_infilling | python | python | MBPP/111/L1 | [] | [] | MBPP_Infilling | return result | [
[
"[[12, 18, 23, 25, 45], [7, 12, 18, 24, 28], [1, 5, 8, 12, 15, 16, 18]]",
"set([18, 12])"
],
[
"[[12, 5, 23, 25, 45], [7, 11, 5, 23, 28], [1, 5, 8, 18, 23, 16]]",
"set([5,23])"
],
[
"[[2, 3,4, 1], [4, 5], [6,4, 8],[4, 5], [6, 8,4]]",
"set([4])"
]
] | common_in_nested_lists | [] | Write a function to find the common elements in given nested lists. | def common_in_nested_lists(nestedlist):
"""Write a function to find the common elements in given nested lists. """
|
result = list(set.intersection(*map(set, nestedlist)))
|
code_infilling | python | python | MBPP/111/L2 | [] | [] | MBPP_Infilling | [
[
"[[12, 18, 23, 25, 45], [7, 12, 18, 24, 28], [1, 5, 8, 12, 15, 16, 18]]",
"set([18, 12])"
],
[
"[[12, 5, 23, 25, 45], [7, 11, 5, 23, 28], [1, 5, 8, 18, 23, 16]]",
"set([5,23])"
],
[
"[[2, 3,4, 1], [4, 5], [6,4, 8],[4, 5], [6, 8,4]]",
"set([4])"
]
] | common_in_nested_lists | [] | Write a function to find the common elements in given nested lists. | def common_in_nested_lists(nestedlist):
"""Write a function to find the common elements in given nested lists. """
result = list(set.intersection(*map(set, nestedlist))) |
return result
| |
code_infilling | python | python | MBPP/113/L1 | [] | [] | MBPP_Infilling | if len(text) < 1:
return None
elif all((text[i] in '0123456789' for i in range(len(text)))):
return True
elif text[0] in '+-' and all((text[i] in '0123456789' for i in range(1, len(text)))):
return True
else:
return False | [
[
"\"python\"",
"False"
],
[
"\"1\"",
"True"
],
[
"\"12345\"",
"True"
]
] | check_integer | [] | Write a function to check if a string represents an integer or not. | def check_integer(text):
"""Write a function to check if a string represents an integer or not. """
|
text = text.strip()
|
code_infilling | python | python | MBPP/113/L2 | [] | [] | MBPP_Infilling | return None
elif all((text[i] in '0123456789' for i in range(len(text)))):
return True
elif text[0] in '+-' and all((text[i] in '0123456789' for i in range(1, len(text)))):
return True
else:
return False | [
[
"\"python\"",
"False"
],
[
"\"1\"",
"True"
],
[
"\"12345\"",
"True"
]
] | check_integer | [] | Write a function to check if a string represents an integer or not. | def check_integer(text):
"""Write a function to check if a string represents an integer or not. """
text = text.strip() |
if len(text) < 1:
|
code_infilling | python | python | MBPP/113/L3 | [] | [] | MBPP_Infilling | elif all((text[i] in '0123456789' for i in range(len(text)))):
return True
elif text[0] in '+-' and all((text[i] in '0123456789' for i in range(1, len(text)))):
return True
else:
return False | [
[
"\"python\"",
"False"
],
[
"\"1\"",
"True"
],
[
"\"12345\"",
"True"
]
] | check_integer | [] | Write a function to check if a string represents an integer or not. | def check_integer(text):
"""Write a function to check if a string represents an integer or not. """
text = text.strip()
if len(text) < 1: |
return None
|
code_infilling | python | python | MBPP/113/L4 | [] | [] | MBPP_Infilling | return True
elif text[0] in '+-' and all((text[i] in '0123456789' for i in range(1, len(text)))):
return True
else:
return False | [
[
"\"python\"",
"False"
],
[
"\"1\"",
"True"
],
[
"\"12345\"",
"True"
]
] | check_integer | [] | Write a function to check if a string represents an integer or not. | def check_integer(text):
"""Write a function to check if a string represents an integer or not. """
text = text.strip()
if len(text) < 1:
return None |
elif all((text[i] in '0123456789' for i in range(len(text)))):
|
code_infilling | python | python | MBPP/113/L5 | [] | [] | MBPP_Infilling | elif text[0] in '+-' and all((text[i] in '0123456789' for i in range(1, len(text)))):
return True
else:
return False | [
[
"\"python\"",
"False"
],
[
"\"1\"",
"True"
],
[
"\"12345\"",
"True"
]
] | check_integer | [] | Write a function to check if a string represents an integer or not. | def check_integer(text):
"""Write a function to check if a string represents an integer or not. """
text = text.strip()
if len(text) < 1:
return None
elif all((text[i] in '0123456789' for i in range(len(text)))): |
return True
|
code_infilling | python | python | MBPP/113/L6 | [] | [] | MBPP_Infilling | return True
else:
return False | [
[
"\"python\"",
"False"
],
[
"\"1\"",
"True"
],
[
"\"12345\"",
"True"
]
] | check_integer | [] | Write a function to check if a string represents an integer or not. | def check_integer(text):
"""Write a function to check if a string represents an integer or not. """
text = text.strip()
if len(text) < 1:
return None
elif all((text[i] in '0123456789' for i in range(len(text)))):
return True |
elif text[0] in '+-' and all((text[i] in '0123456789' for i in range(1, len(text)))):
|
code_infilling | python | python | MBPP/113/L7 | [] | [] | MBPP_Infilling | else:
return False | [
[
"\"python\"",
"False"
],
[
"\"1\"",
"True"
],
[
"\"12345\"",
"True"
]
] | check_integer | [] | Write a function to check if a string represents an integer or not. | def check_integer(text):
"""Write a function to check if a string represents an integer or not. """
text = text.strip()
if len(text) < 1:
return None
elif all((text[i] in '0123456789' for i in range(len(text)))):
return True
elif text[0] in '+-' and all((text[i] in '0123456789' fo... |
return True
|
code_infilling | python | python | MBPP/113/L8 | [] | [] | MBPP_Infilling | return False | [
[
"\"python\"",
"False"
],
[
"\"1\"",
"True"
],
[
"\"12345\"",
"True"
]
] | check_integer | [] | Write a function to check if a string represents an integer or not. | def check_integer(text):
"""Write a function to check if a string represents an integer or not. """
text = text.strip()
if len(text) < 1:
return None
elif all((text[i] in '0123456789' for i in range(len(text)))):
return True
elif text[0] in '+-' and all((text[i] in '0123456789' fo... |
else:
|
code_infilling | python | python | MBPP/113/L9 | [] | [] | MBPP_Infilling | [
[
"\"python\"",
"False"
],
[
"\"1\"",
"True"
],
[
"\"12345\"",
"True"
]
] | check_integer | [] | Write a function to check if a string represents an integer or not. | def check_integer(text):
"""Write a function to check if a string represents an integer or not. """
text = text.strip()
if len(text) < 1:
return None
elif all((text[i] in '0123456789' for i in range(len(text)))):
return True
elif text[0] in '+-' and all((text[i] in '0123456789' fo... |
return False
| |
code_infilling | python | python | MBPP/115/L1 | [] | [] | MBPP_Infilling | return empty_dit | [
[
"[{},{},{}]",
"True"
],
[
"[{1,2},{},{}]",
"False"
],
[
"{}",
"True"
]
] | empty_dit | [] | Write a function to check whether all dictionaries in a list are empty or not. | def empty_dit(list1):
"""Write a function to check whether all dictionaries in a list are empty or not. """
|
empty_dit = all((not d for d in list1))
|
code_infilling | python | python | MBPP/115/L2 | [] | [] | MBPP_Infilling | [
[
"[{},{},{}]",
"True"
],
[
"[{1,2},{},{}]",
"False"
],
[
"{}",
"True"
]
] | empty_dit | [] | Write a function to check whether all dictionaries in a list are empty or not. | def empty_dit(list1):
"""Write a function to check whether all dictionaries in a list are empty or not. """
empty_dit = all((not d for d in list1)) |
return empty_dit
| |
code_infilling | python | python | MBPP/116/L1 | [] | [] | MBPP_Infilling | return result | [
[
"(1,2,3)",
"123"
],
[
"(4,5,6)",
"456"
],
[
"(5,6,7)",
"567"
]
] | tuple_to_int | [] | Write a function to convert a given tuple of positive integers into a single integer. | def tuple_to_int(nums):
"""Write a function to convert a given tuple of positive integers into a single integer. """
|
result = int(''.join(map(str, nums)))
|
code_infilling | python | python | MBPP/116/L2 | [] | [] | MBPP_Infilling | [
[
"(1,2,3)",
"123"
],
[
"(4,5,6)",
"456"
],
[
"(5,6,7)",
"567"
]
] | tuple_to_int | [] | Write a function to convert a given tuple of positive integers into a single integer. | def tuple_to_int(nums):
"""Write a function to convert a given tuple of positive integers into a single integer. """
result = int(''.join(map(str, nums))) |
return result
| |
code_infilling | python | python | MBPP/117/L1 | [] | [] | MBPP_Infilling | for tup in test_list:
temp = []
for ele in tup:
if ele.isalpha():
temp.append(ele)
else:
temp.append(float(ele))
res.append((temp[0], temp[1]))
return res | [
[
" [(\"3\", \"4\"), (\"1\", \"26.45\"), (\"7.32\", \"8\"), (\"4\", \"8\")] ",
"[(3.0, 4.0), (1.0, 26.45), (7.32, 8.0), (4.0, 8.0)]"
],
[
" [(\"4\", \"4\"), (\"2\", \"27\"), (\"4.12\", \"9\"), (\"7\", \"11\")] ",
"[(4.0, 4.0), (2.0, 27.0), (4.12, 9.0), (7.0, 11.0)]"
],
[
" [(\"6\", \"78\... | list_to_float | [] | Write a function to convert all possible convertible elements in a list of lists to floats. | def list_to_float(test_list):
"""Write a function to convert all possible convertible elements in a list of lists to floats. """
|
res = []
|
code_infilling | python | python | MBPP/117/L2 | [] | [] | MBPP_Infilling | temp = []
for ele in tup:
if ele.isalpha():
temp.append(ele)
else:
temp.append(float(ele))
res.append((temp[0], temp[1]))
return res | [
[
" [(\"3\", \"4\"), (\"1\", \"26.45\"), (\"7.32\", \"8\"), (\"4\", \"8\")] ",
"[(3.0, 4.0), (1.0, 26.45), (7.32, 8.0), (4.0, 8.0)]"
],
[
" [(\"4\", \"4\"), (\"2\", \"27\"), (\"4.12\", \"9\"), (\"7\", \"11\")] ",
"[(4.0, 4.0), (2.0, 27.0), (4.12, 9.0), (7.0, 11.0)]"
],
[
" [(\"6\", \"78\... | list_to_float | [] | Write a function to convert all possible convertible elements in a list of lists to floats. | def list_to_float(test_list):
"""Write a function to convert all possible convertible elements in a list of lists to floats. """
res = [] |
for tup in test_list:
|
code_infilling | python | python | MBPP/117/L3 | [] | [] | MBPP_Infilling | for ele in tup:
if ele.isalpha():
temp.append(ele)
else:
temp.append(float(ele))
res.append((temp[0], temp[1]))
return res | [
[
" [(\"3\", \"4\"), (\"1\", \"26.45\"), (\"7.32\", \"8\"), (\"4\", \"8\")] ",
"[(3.0, 4.0), (1.0, 26.45), (7.32, 8.0), (4.0, 8.0)]"
],
[
" [(\"4\", \"4\"), (\"2\", \"27\"), (\"4.12\", \"9\"), (\"7\", \"11\")] ",
"[(4.0, 4.0), (2.0, 27.0), (4.12, 9.0), (7.0, 11.0)]"
],
[
" [(\"6\", \"78\... | list_to_float | [] | Write a function to convert all possible convertible elements in a list of lists to floats. | def list_to_float(test_list):
"""Write a function to convert all possible convertible elements in a list of lists to floats. """
res = []
for tup in test_list: |
temp = []
|
code_infilling | python | python | MBPP/117/L4 | [] | [] | MBPP_Infilling | if ele.isalpha():
temp.append(ele)
else:
temp.append(float(ele))
res.append((temp[0], temp[1]))
return res | [
[
" [(\"3\", \"4\"), (\"1\", \"26.45\"), (\"7.32\", \"8\"), (\"4\", \"8\")] ",
"[(3.0, 4.0), (1.0, 26.45), (7.32, 8.0), (4.0, 8.0)]"
],
[
" [(\"4\", \"4\"), (\"2\", \"27\"), (\"4.12\", \"9\"), (\"7\", \"11\")] ",
"[(4.0, 4.0), (2.0, 27.0), (4.12, 9.0), (7.0, 11.0)]"
],
[
" [(\"6\", \"78\... | list_to_float | [] | Write a function to convert all possible convertible elements in a list of lists to floats. | def list_to_float(test_list):
"""Write a function to convert all possible convertible elements in a list of lists to floats. """
res = []
for tup in test_list:
temp = [] |
for ele in tup:
|
code_infilling | python | python | MBPP/117/L5 | [] | [] | MBPP_Infilling | temp.append(ele)
else:
temp.append(float(ele))
res.append((temp[0], temp[1]))
return res | [
[
" [(\"3\", \"4\"), (\"1\", \"26.45\"), (\"7.32\", \"8\"), (\"4\", \"8\")] ",
"[(3.0, 4.0), (1.0, 26.45), (7.32, 8.0), (4.0, 8.0)]"
],
[
" [(\"4\", \"4\"), (\"2\", \"27\"), (\"4.12\", \"9\"), (\"7\", \"11\")] ",
"[(4.0, 4.0), (2.0, 27.0), (4.12, 9.0), (7.0, 11.0)]"
],
[
" [(\"6\", \"78\... | list_to_float | [] | Write a function to convert all possible convertible elements in a list of lists to floats. | def list_to_float(test_list):
"""Write a function to convert all possible convertible elements in a list of lists to floats. """
res = []
for tup in test_list:
temp = []
for ele in tup: |
if ele.isalpha():
|
code_infilling | python | python | MBPP/117/L6 | [] | [] | MBPP_Infilling | else:
temp.append(float(ele))
res.append((temp[0], temp[1]))
return res | [
[
" [(\"3\", \"4\"), (\"1\", \"26.45\"), (\"7.32\", \"8\"), (\"4\", \"8\")] ",
"[(3.0, 4.0), (1.0, 26.45), (7.32, 8.0), (4.0, 8.0)]"
],
[
" [(\"4\", \"4\"), (\"2\", \"27\"), (\"4.12\", \"9\"), (\"7\", \"11\")] ",
"[(4.0, 4.0), (2.0, 27.0), (4.12, 9.0), (7.0, 11.0)]"
],
[
" [(\"6\", \"78\... | list_to_float | [] | Write a function to convert all possible convertible elements in a list of lists to floats. | def list_to_float(test_list):
"""Write a function to convert all possible convertible elements in a list of lists to floats. """
res = []
for tup in test_list:
temp = []
for ele in tup:
if ele.isalpha(): |
temp.append(ele)
|
code_infilling | python | python | MBPP/117/L7 | [] | [] | MBPP_Infilling | temp.append(float(ele))
res.append((temp[0], temp[1]))
return res | [
[
" [(\"3\", \"4\"), (\"1\", \"26.45\"), (\"7.32\", \"8\"), (\"4\", \"8\")] ",
"[(3.0, 4.0), (1.0, 26.45), (7.32, 8.0), (4.0, 8.0)]"
],
[
" [(\"4\", \"4\"), (\"2\", \"27\"), (\"4.12\", \"9\"), (\"7\", \"11\")] ",
"[(4.0, 4.0), (2.0, 27.0), (4.12, 9.0), (7.0, 11.0)]"
],
[
" [(\"6\", \"78\... | list_to_float | [] | Write a function to convert all possible convertible elements in a list of lists to floats. | def list_to_float(test_list):
"""Write a function to convert all possible convertible elements in a list of lists to floats. """
res = []
for tup in test_list:
temp = []
for ele in tup:
if ele.isalpha():
temp.append(ele) |
else:
|
code_infilling | python | python | MBPP/117/L8 | [] | [] | MBPP_Infilling | res.append((temp[0], temp[1]))
return res | [
[
" [(\"3\", \"4\"), (\"1\", \"26.45\"), (\"7.32\", \"8\"), (\"4\", \"8\")] ",
"[(3.0, 4.0), (1.0, 26.45), (7.32, 8.0), (4.0, 8.0)]"
],
[
" [(\"4\", \"4\"), (\"2\", \"27\"), (\"4.12\", \"9\"), (\"7\", \"11\")] ",
"[(4.0, 4.0), (2.0, 27.0), (4.12, 9.0), (7.0, 11.0)]"
],
[
" [(\"6\", \"78\... | list_to_float | [] | Write a function to convert all possible convertible elements in a list of lists to floats. | def list_to_float(test_list):
"""Write a function to convert all possible convertible elements in a list of lists to floats. """
res = []
for tup in test_list:
temp = []
for ele in tup:
if ele.isalpha():
temp.append(ele)
else: |
temp.append(float(ele))
|
code_infilling | python | python | MBPP/117/L9 | [] | [] | MBPP_Infilling | return res | [
[
" [(\"3\", \"4\"), (\"1\", \"26.45\"), (\"7.32\", \"8\"), (\"4\", \"8\")] ",
"[(3.0, 4.0), (1.0, 26.45), (7.32, 8.0), (4.0, 8.0)]"
],
[
" [(\"4\", \"4\"), (\"2\", \"27\"), (\"4.12\", \"9\"), (\"7\", \"11\")] ",
"[(4.0, 4.0), (2.0, 27.0), (4.12, 9.0), (7.0, 11.0)]"
],
[
" [(\"6\", \"78\... | list_to_float | [] | Write a function to convert all possible convertible elements in a list of lists to floats. | def list_to_float(test_list):
"""Write a function to convert all possible convertible elements in a list of lists to floats. """
res = []
for tup in test_list:
temp = []
for ele in tup:
if ele.isalpha():
temp.append(ele)
else:
temp.a... |
res.append((temp[0], temp[1]))
|
code_infilling | python | python | MBPP/117/L10 | [] | [] | MBPP_Infilling | [
[
" [(\"3\", \"4\"), (\"1\", \"26.45\"), (\"7.32\", \"8\"), (\"4\", \"8\")] ",
"[(3.0, 4.0), (1.0, 26.45), (7.32, 8.0), (4.0, 8.0)]"
],
[
" [(\"4\", \"4\"), (\"2\", \"27\"), (\"4.12\", \"9\"), (\"7\", \"11\")] ",
"[(4.0, 4.0), (2.0, 27.0), (4.12, 9.0), (7.0, 11.0)]"
],
[
" [(\"6\", \"78\... | list_to_float | [] | Write a function to convert all possible convertible elements in a list of lists to floats. | def list_to_float(test_list):
"""Write a function to convert all possible convertible elements in a list of lists to floats. """
res = []
for tup in test_list:
temp = []
for ele in tup:
if ele.isalpha():
temp.append(ele)
else:
temp.a... |
return res
| |
code_infilling | python | python | MBPP/118/L1 | [] | [] | MBPP_Infilling | return lst | [
[
"\"python programming\"",
"['python','programming']"
],
[
"\"lists tuples strings\"",
"['lists','tuples','strings']"
],
[
"\"write a program\"",
"['write','a','program']"
]
] | string_to_list | [] | Write a function to convert a string to a list of strings split on the space character. | def string_to_list(string):
"""Write a function to convert a string to a list of strings split on the space character. """
|
lst = list(string.split(' '))
|
code_infilling | python | python | MBPP/118/L2 | [] | [] | MBPP_Infilling | [
[
"\"python programming\"",
"['python','programming']"
],
[
"\"lists tuples strings\"",
"['lists','tuples','strings']"
],
[
"\"write a program\"",
"['write','a','program']"
]
] | string_to_list | [] | Write a function to convert a string to a list of strings split on the space character. | def string_to_list(string):
"""Write a function to convert a string to a list of strings split on the space character. """
lst = list(string.split(' ')) |
return lst
| |
code_infilling | python | python | MBPP/119/L1 | [] | [] | MBPP_Infilling | XOR = 0
for i in range(n):
XOR = XOR ^ arr[i]
return XOR | [
[
"[1,1,2,2,3]",
"3"
],
[
"[1,1,3,3,4,4,5,5,7,7,8]",
"8"
],
[
"[1,2,2,3,3,4,4]",
"1"
]
] | search | [] | Write a python function to find the element that appears only once in a sorted array. | def search(arr):
"""Write a python function to find the element that appears only once in a sorted array. """
|
n = len(arr)
|
code_infilling | python | python | MBPP/119/L2 | [] | [] | MBPP_Infilling | for i in range(n):
XOR = XOR ^ arr[i]
return XOR | [
[
"[1,1,2,2,3]",
"3"
],
[
"[1,1,3,3,4,4,5,5,7,7,8]",
"8"
],
[
"[1,2,2,3,3,4,4]",
"1"
]
] | search | [] | Write a python function to find the element that appears only once in a sorted array. | def search(arr):
"""Write a python function to find the element that appears only once in a sorted array. """
n = len(arr) |
XOR = 0
|
code_infilling | python | python | MBPP/119/L3 | [] | [] | MBPP_Infilling | XOR = XOR ^ arr[i]
return XOR | [
[
"[1,1,2,2,3]",
"3"
],
[
"[1,1,3,3,4,4,5,5,7,7,8]",
"8"
],
[
"[1,2,2,3,3,4,4]",
"1"
]
] | search | [] | Write a python function to find the element that appears only once in a sorted array. | def search(arr):
"""Write a python function to find the element that appears only once in a sorted array. """
n = len(arr)
XOR = 0 |
for i in range(n):
|
code_infilling | python | python | MBPP/119/L4 | [] | [] | MBPP_Infilling | return XOR | [
[
"[1,1,2,2,3]",
"3"
],
[
"[1,1,3,3,4,4,5,5,7,7,8]",
"8"
],
[
"[1,2,2,3,3,4,4]",
"1"
]
] | search | [] | Write a python function to find the element that appears only once in a sorted array. | def search(arr):
"""Write a python function to find the element that appears only once in a sorted array. """
n = len(arr)
XOR = 0
for i in range(n): |
XOR = XOR ^ arr[i]
|
code_infilling | python | python | MBPP/119/L5 | [] | [] | MBPP_Infilling | [
[
"[1,1,2,2,3]",
"3"
],
[
"[1,1,3,3,4,4,5,5,7,7,8]",
"8"
],
[
"[1,2,2,3,3,4,4]",
"1"
]
] | search | [] | Write a python function to find the element that appears only once in a sorted array. | def search(arr):
"""Write a python function to find the element that appears only once in a sorted array. """
n = len(arr)
XOR = 0
for i in range(n):
XOR = XOR ^ arr[i] |
return XOR
| |
code_infilling | python | python | MBPP/120/L1 | [] | [] | MBPP_Infilling | return result_max | [
[
"[(2, 7), (2, 6), (1, 8), (4, 9)] ",
"36"
],
[
"[(10,20), (15,2), (5,10)] ",
"200"
],
[
"[(11,44), (10,15), (20,5), (12, 9)] ",
"484"
]
] | max_product_tuple | [] | Write a function to find the maximum absolute product between numbers in pairs of tuples within a given list. | def max_product_tuple(list1):
"""Write a function to find the maximum absolute product between numbers in pairs of tuples within a given list. """
|
result_max = max([abs(x * y) for (x, y) in list1])
|
code_infilling | python | python | MBPP/120/L2 | [] | [] | MBPP_Infilling | [
[
"[(2, 7), (2, 6), (1, 8), (4, 9)] ",
"36"
],
[
"[(10,20), (15,2), (5,10)] ",
"200"
],
[
"[(11,44), (10,15), (20,5), (12, 9)] ",
"484"
]
] | max_product_tuple | [] | Write a function to find the maximum absolute product between numbers in pairs of tuples within a given list. | def max_product_tuple(list1):
"""Write a function to find the maximum absolute product between numbers in pairs of tuples within a given list. """
result_max = max([abs(x * y) for (x, y) in list1]) |
return result_max
| |
code_infilling | python | python | MBPP/123/L1 | [] | [] | MBPP_Infilling | return 'Input is not an integer!'
if limit < 1:
return 'Input must be bigger than 0!'
amicables = set()
for num in range(2, limit + 1):
if num in amicables:
continue
sum_fact = sum([fact for fact in range(1, num) if num % fact == 0])
sum_fact2 = sum([fact ... | [
[
"999",
"504"
],
[
"9999",
"31626"
],
[
"99",
"0"
]
] | amicable_numbers_sum | [] | Write a function to sum all amicable numbers from 1 to a specified number. | def amicable_numbers_sum(limit):
"""Write a function to sum all amicable numbers from 1 to a specified number. """
|
if not isinstance(limit, int):
|
code_infilling | python | python | MBPP/123/L2 | [] | [] | MBPP_Infilling | if limit < 1:
return 'Input must be bigger than 0!'
amicables = set()
for num in range(2, limit + 1):
if num in amicables:
continue
sum_fact = sum([fact for fact in range(1, num) if num % fact == 0])
sum_fact2 = sum([fact for fact in range(1, sum_fact) if sum_fact... | [
[
"999",
"504"
],
[
"9999",
"31626"
],
[
"99",
"0"
]
] | amicable_numbers_sum | [] | Write a function to sum all amicable numbers from 1 to a specified number. | def amicable_numbers_sum(limit):
"""Write a function to sum all amicable numbers from 1 to a specified number. """
if not isinstance(limit, int): |
return 'Input is not an integer!'
|
code_infilling | python | python | MBPP/123/L3 | [] | [] | MBPP_Infilling | return 'Input must be bigger than 0!'
amicables = set()
for num in range(2, limit + 1):
if num in amicables:
continue
sum_fact = sum([fact for fact in range(1, num) if num % fact == 0])
sum_fact2 = sum([fact for fact in range(1, sum_fact) if sum_fact % fact == 0])
... | [
[
"999",
"504"
],
[
"9999",
"31626"
],
[
"99",
"0"
]
] | amicable_numbers_sum | [] | Write a function to sum all amicable numbers from 1 to a specified number. | def amicable_numbers_sum(limit):
"""Write a function to sum all amicable numbers from 1 to a specified number. """
if not isinstance(limit, int):
return 'Input is not an integer!' |
if limit < 1:
|
code_infilling | python | python | MBPP/123/L4 | [] | [] | MBPP_Infilling | amicables = set()
for num in range(2, limit + 1):
if num in amicables:
continue
sum_fact = sum([fact for fact in range(1, num) if num % fact == 0])
sum_fact2 = sum([fact for fact in range(1, sum_fact) if sum_fact % fact == 0])
if num == sum_fact2 and num != sum_fact:
... | [
[
"999",
"504"
],
[
"9999",
"31626"
],
[
"99",
"0"
]
] | amicable_numbers_sum | [] | Write a function to sum all amicable numbers from 1 to a specified number. | def amicable_numbers_sum(limit):
"""Write a function to sum all amicable numbers from 1 to a specified number. """
if not isinstance(limit, int):
return 'Input is not an integer!'
if limit < 1: |
return 'Input must be bigger than 0!'
|
code_infilling | python | python | MBPP/123/L5 | [] | [] | MBPP_Infilling | for num in range(2, limit + 1):
if num in amicables:
continue
sum_fact = sum([fact for fact in range(1, num) if num % fact == 0])
sum_fact2 = sum([fact for fact in range(1, sum_fact) if sum_fact % fact == 0])
if num == sum_fact2 and num != sum_fact:
amicables.... | [
[
"999",
"504"
],
[
"9999",
"31626"
],
[
"99",
"0"
]
] | amicable_numbers_sum | [] | Write a function to sum all amicable numbers from 1 to a specified number. | def amicable_numbers_sum(limit):
"""Write a function to sum all amicable numbers from 1 to a specified number. """
if not isinstance(limit, int):
return 'Input is not an integer!'
if limit < 1:
return 'Input must be bigger than 0!' |
amicables = set()
|
code_infilling | python | python | MBPP/123/L6 | [] | [] | MBPP_Infilling | if num in amicables:
continue
sum_fact = sum([fact for fact in range(1, num) if num % fact == 0])
sum_fact2 = sum([fact for fact in range(1, sum_fact) if sum_fact % fact == 0])
if num == sum_fact2 and num != sum_fact:
amicables.add(num)
amicables.add(s... | [
[
"999",
"504"
],
[
"9999",
"31626"
],
[
"99",
"0"
]
] | amicable_numbers_sum | [] | Write a function to sum all amicable numbers from 1 to a specified number. | def amicable_numbers_sum(limit):
"""Write a function to sum all amicable numbers from 1 to a specified number. """
if not isinstance(limit, int):
return 'Input is not an integer!'
if limit < 1:
return 'Input must be bigger than 0!'
amicables = set() |
for num in range(2, limit + 1):
|
code_infilling | python | python | MBPP/123/L7 | [] | [] | MBPP_Infilling | continue
sum_fact = sum([fact for fact in range(1, num) if num % fact == 0])
sum_fact2 = sum([fact for fact in range(1, sum_fact) if sum_fact % fact == 0])
if num == sum_fact2 and num != sum_fact:
amicables.add(num)
amicables.add(sum_fact2)
return sum(amic... | [
[
"999",
"504"
],
[
"9999",
"31626"
],
[
"99",
"0"
]
] | amicable_numbers_sum | [] | Write a function to sum all amicable numbers from 1 to a specified number. | def amicable_numbers_sum(limit):
"""Write a function to sum all amicable numbers from 1 to a specified number. """
if not isinstance(limit, int):
return 'Input is not an integer!'
if limit < 1:
return 'Input must be bigger than 0!'
amicables = set()
for num in range(2, limit + 1): |
if num in amicables:
|
code_infilling | python | python | MBPP/123/L8 | [] | [] | MBPP_Infilling | sum_fact = sum([fact for fact in range(1, num) if num % fact == 0])
sum_fact2 = sum([fact for fact in range(1, sum_fact) if sum_fact % fact == 0])
if num == sum_fact2 and num != sum_fact:
amicables.add(num)
amicables.add(sum_fact2)
return sum(amicables) | [
[
"999",
"504"
],
[
"9999",
"31626"
],
[
"99",
"0"
]
] | amicable_numbers_sum | [] | Write a function to sum all amicable numbers from 1 to a specified number. | def amicable_numbers_sum(limit):
"""Write a function to sum all amicable numbers from 1 to a specified number. """
if not isinstance(limit, int):
return 'Input is not an integer!'
if limit < 1:
return 'Input must be bigger than 0!'
amicables = set()
for num in range(2, limit + 1):... |
continue
|
code_infilling | python | python | MBPP/123/L9 | [] | [] | MBPP_Infilling | sum_fact2 = sum([fact for fact in range(1, sum_fact) if sum_fact % fact == 0])
if num == sum_fact2 and num != sum_fact:
amicables.add(num)
amicables.add(sum_fact2)
return sum(amicables) | [
[
"999",
"504"
],
[
"9999",
"31626"
],
[
"99",
"0"
]
] | amicable_numbers_sum | [] | Write a function to sum all amicable numbers from 1 to a specified number. | def amicable_numbers_sum(limit):
"""Write a function to sum all amicable numbers from 1 to a specified number. """
if not isinstance(limit, int):
return 'Input is not an integer!'
if limit < 1:
return 'Input must be bigger than 0!'
amicables = set()
for num in range(2, limit + 1):... |
sum_fact = sum([fact for fact in range(1, num) if num % fact == 0])
|
code_infilling | python | python | MBPP/123/L10 | [] | [] | MBPP_Infilling | if num == sum_fact2 and num != sum_fact:
amicables.add(num)
amicables.add(sum_fact2)
return sum(amicables) | [
[
"999",
"504"
],
[
"9999",
"31626"
],
[
"99",
"0"
]
] | amicable_numbers_sum | [] | Write a function to sum all amicable numbers from 1 to a specified number. | def amicable_numbers_sum(limit):
"""Write a function to sum all amicable numbers from 1 to a specified number. """
if not isinstance(limit, int):
return 'Input is not an integer!'
if limit < 1:
return 'Input must be bigger than 0!'
amicables = set()
for num in range(2, limit + 1):... |
sum_fact2 = sum([fact for fact in range(1, sum_fact) if sum_fact % fact == 0])
|
code_infilling | python | python | MBPP/123/L11 | [] | [] | MBPP_Infilling | amicables.add(num)
amicables.add(sum_fact2)
return sum(amicables) | [
[
"999",
"504"
],
[
"9999",
"31626"
],
[
"99",
"0"
]
] | amicable_numbers_sum | [] | Write a function to sum all amicable numbers from 1 to a specified number. | def amicable_numbers_sum(limit):
"""Write a function to sum all amicable numbers from 1 to a specified number. """
if not isinstance(limit, int):
return 'Input is not an integer!'
if limit < 1:
return 'Input must be bigger than 0!'
amicables = set()
for num in range(2, limit + 1):... |
if num == sum_fact2 and num != sum_fact:
|
code_infilling | python | python | MBPP/123/L12 | [] | [] | MBPP_Infilling | amicables.add(sum_fact2)
return sum(amicables) | [
[
"999",
"504"
],
[
"9999",
"31626"
],
[
"99",
"0"
]
] | amicable_numbers_sum | [] | Write a function to sum all amicable numbers from 1 to a specified number. | def amicable_numbers_sum(limit):
"""Write a function to sum all amicable numbers from 1 to a specified number. """
if not isinstance(limit, int):
return 'Input is not an integer!'
if limit < 1:
return 'Input must be bigger than 0!'
amicables = set()
for num in range(2, limit + 1):... |
amicables.add(num)
|
code_infilling | python | python | MBPP/123/L13 | [] | [] | MBPP_Infilling | return sum(amicables) | [
[
"999",
"504"
],
[
"9999",
"31626"
],
[
"99",
"0"
]
] | amicable_numbers_sum | [] | Write a function to sum all amicable numbers from 1 to a specified number. | def amicable_numbers_sum(limit):
"""Write a function to sum all amicable numbers from 1 to a specified number. """
if not isinstance(limit, int):
return 'Input is not an integer!'
if limit < 1:
return 'Input must be bigger than 0!'
amicables = set()
for num in range(2, limit + 1):... |
amicables.add(sum_fact2)
|
code_infilling | python | python | MBPP/123/L14 | [] | [] | MBPP_Infilling | [
[
"999",
"504"
],
[
"9999",
"31626"
],
[
"99",
"0"
]
] | amicable_numbers_sum | [] | Write a function to sum all amicable numbers from 1 to a specified number. | def amicable_numbers_sum(limit):
"""Write a function to sum all amicable numbers from 1 to a specified number. """
if not isinstance(limit, int):
return 'Input is not an integer!'
if limit < 1:
return 'Input must be bigger than 0!'
amicables = set()
for num in range(2, limit + 1):... |
return sum(amicables)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.