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/405/L4 | [] | [] | MBPP_Infilling | [
[
"(\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),'r'",
"True"
],
[
"(\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),'5'",
"False"
],
[
"(\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\",\"e\"),3",
"True"
]
] | check_tuplex | [] | Write a function to check whether an element exists within a tuple. | def check_tuplex(tuplex, tuple1):
"""Write a function to check whether an element exists within a tuple. """
if tuple1 in tuplex:
return True
else: |
return False
| |
code_infilling | python | python | MBPP/406/L1 | [] | [] | MBPP_Infilling | y = y ^ y >> 2
y = y ^ y >> 4
y = y ^ y >> 8
y = y ^ y >> 16
if y & 1:
return True
return False | [
[
"12",
"False"
],
[
"7",
"True"
],
[
"10",
"False"
]
] | find_Parity | [] | Write a python function to find whether the parity of a given number is odd. | def find_Parity(x):
"""Write a python function to find whether the parity of a given number is odd. """
|
y = x ^ x >> 1
|
code_infilling | python | python | MBPP/406/L2 | [] | [] | MBPP_Infilling | y = y ^ y >> 4
y = y ^ y >> 8
y = y ^ y >> 16
if y & 1:
return True
return False | [
[
"12",
"False"
],
[
"7",
"True"
],
[
"10",
"False"
]
] | find_Parity | [] | Write a python function to find whether the parity of a given number is odd. | def find_Parity(x):
"""Write a python function to find whether the parity of a given number is odd. """
y = x ^ x >> 1 |
y = y ^ y >> 2
|
code_infilling | python | python | MBPP/406/L3 | [] | [] | MBPP_Infilling | y = y ^ y >> 8
y = y ^ y >> 16
if y & 1:
return True
return False | [
[
"12",
"False"
],
[
"7",
"True"
],
[
"10",
"False"
]
] | find_Parity | [] | Write a python function to find whether the parity of a given number is odd. | def find_Parity(x):
"""Write a python function to find whether the parity of a given number is odd. """
y = x ^ x >> 1
y = y ^ y >> 2 |
y = y ^ y >> 4
|
code_infilling | python | python | MBPP/406/L4 | [] | [] | MBPP_Infilling | y = y ^ y >> 16
if y & 1:
return True
return False | [
[
"12",
"False"
],
[
"7",
"True"
],
[
"10",
"False"
]
] | find_Parity | [] | Write a python function to find whether the parity of a given number is odd. | def find_Parity(x):
"""Write a python function to find whether the parity of a given number is odd. """
y = x ^ x >> 1
y = y ^ y >> 2
y = y ^ y >> 4 |
y = y ^ y >> 8
|
code_infilling | python | python | MBPP/406/L5 | [] | [] | MBPP_Infilling | if y & 1:
return True
return False | [
[
"12",
"False"
],
[
"7",
"True"
],
[
"10",
"False"
]
] | find_Parity | [] | Write a python function to find whether the parity of a given number is odd. | def find_Parity(x):
"""Write a python function to find whether the parity of a given number is odd. """
y = x ^ x >> 1
y = y ^ y >> 2
y = y ^ y >> 4
y = y ^ y >> 8 |
y = y ^ y >> 16
|
code_infilling | python | python | MBPP/406/L6 | [] | [] | MBPP_Infilling | return True
return False | [
[
"12",
"False"
],
[
"7",
"True"
],
[
"10",
"False"
]
] | find_Parity | [] | Write a python function to find whether the parity of a given number is odd. | def find_Parity(x):
"""Write a python function to find whether the parity of a given number is odd. """
y = x ^ x >> 1
y = y ^ y >> 2
y = y ^ y >> 4
y = y ^ y >> 8
y = y ^ y >> 16 |
if y & 1:
|
code_infilling | python | python | MBPP/406/L7 | [] | [] | MBPP_Infilling | return False | [
[
"12",
"False"
],
[
"7",
"True"
],
[
"10",
"False"
]
] | find_Parity | [] | Write a python function to find whether the parity of a given number is odd. | def find_Parity(x):
"""Write a python function to find whether the parity of a given number is odd. """
y = x ^ x >> 1
y = y ^ y >> 2
y = y ^ y >> 4
y = y ^ y >> 8
y = y ^ y >> 16
if y & 1: |
return True
|
code_infilling | python | python | MBPP/406/L8 | [] | [] | MBPP_Infilling | [
[
"12",
"False"
],
[
"7",
"True"
],
[
"10",
"False"
]
] | find_Parity | [] | Write a python function to find whether the parity of a given number is odd. | def find_Parity(x):
"""Write a python function to find whether the parity of a given number is odd. """
y = x ^ x >> 1
y = y ^ y >> 2
y = y ^ y >> 4
y = y ^ y >> 8
y = y ^ y >> 16
if y & 1:
return True |
return False
| |
code_infilling | python | python | MBPP/407/L1 | [] | [] | MBPP_Infilling | for i in range(len(nums) - 2, -1, -1):
if nums[i] < nums[i + 1]:
z = nums[i:]
y = min(filter(lambda x: x > z[0], z))
z.remove(y)
z.sort()
nums[i:] = [y] + z
return int(''.join(nums))
return False | [
[
"12",
"21"
],
[
"10",
"False"
],
[
"102",
"120"
]
] | rearrange_bigger | [] | Write a function to create the next bigger number by rearranging the digits of a given number. | def rearrange_bigger(n):
"""Write a function to create the next bigger number by rearranging the digits of a given number. """
|
nums = list(str(n))
|
code_infilling | python | python | MBPP/407/L2 | [] | [] | MBPP_Infilling | if nums[i] < nums[i + 1]:
z = nums[i:]
y = min(filter(lambda x: x > z[0], z))
z.remove(y)
z.sort()
nums[i:] = [y] + z
return int(''.join(nums))
return False | [
[
"12",
"21"
],
[
"10",
"False"
],
[
"102",
"120"
]
] | rearrange_bigger | [] | Write a function to create the next bigger number by rearranging the digits of a given number. | def rearrange_bigger(n):
"""Write a function to create the next bigger number by rearranging the digits of a given number. """
nums = list(str(n)) |
for i in range(len(nums) - 2, -1, -1):
|
code_infilling | python | python | MBPP/407/L3 | [] | [] | MBPP_Infilling | z = nums[i:]
y = min(filter(lambda x: x > z[0], z))
z.remove(y)
z.sort()
nums[i:] = [y] + z
return int(''.join(nums))
return False | [
[
"12",
"21"
],
[
"10",
"False"
],
[
"102",
"120"
]
] | rearrange_bigger | [] | Write a function to create the next bigger number by rearranging the digits of a given number. | def rearrange_bigger(n):
"""Write a function to create the next bigger number by rearranging the digits of a given number. """
nums = list(str(n))
for i in range(len(nums) - 2, -1, -1): |
if nums[i] < nums[i + 1]:
|
code_infilling | python | python | MBPP/407/L4 | [] | [] | MBPP_Infilling | y = min(filter(lambda x: x > z[0], z))
z.remove(y)
z.sort()
nums[i:] = [y] + z
return int(''.join(nums))
return False | [
[
"12",
"21"
],
[
"10",
"False"
],
[
"102",
"120"
]
] | rearrange_bigger | [] | Write a function to create the next bigger number by rearranging the digits of a given number. | def rearrange_bigger(n):
"""Write a function to create the next bigger number by rearranging the digits of a given number. """
nums = list(str(n))
for i in range(len(nums) - 2, -1, -1):
if nums[i] < nums[i + 1]: |
z = nums[i:]
|
code_infilling | python | python | MBPP/407/L5 | [] | [] | MBPP_Infilling | z.remove(y)
z.sort()
nums[i:] = [y] + z
return int(''.join(nums))
return False | [
[
"12",
"21"
],
[
"10",
"False"
],
[
"102",
"120"
]
] | rearrange_bigger | [] | Write a function to create the next bigger number by rearranging the digits of a given number. | def rearrange_bigger(n):
"""Write a function to create the next bigger number by rearranging the digits of a given number. """
nums = list(str(n))
for i in range(len(nums) - 2, -1, -1):
if nums[i] < nums[i + 1]:
z = nums[i:] |
y = min(filter(lambda x: x > z[0], z))
|
code_infilling | python | python | MBPP/407/L6 | [] | [] | MBPP_Infilling | z.sort()
nums[i:] = [y] + z
return int(''.join(nums))
return False | [
[
"12",
"21"
],
[
"10",
"False"
],
[
"102",
"120"
]
] | rearrange_bigger | [] | Write a function to create the next bigger number by rearranging the digits of a given number. | def rearrange_bigger(n):
"""Write a function to create the next bigger number by rearranging the digits of a given number. """
nums = list(str(n))
for i in range(len(nums) - 2, -1, -1):
if nums[i] < nums[i + 1]:
z = nums[i:]
y = min(filter(lambda x: x > z[0], z)) |
z.remove(y)
|
code_infilling | python | python | MBPP/407/L7 | [] | [] | MBPP_Infilling | nums[i:] = [y] + z
return int(''.join(nums))
return False | [
[
"12",
"21"
],
[
"10",
"False"
],
[
"102",
"120"
]
] | rearrange_bigger | [] | Write a function to create the next bigger number by rearranging the digits of a given number. | def rearrange_bigger(n):
"""Write a function to create the next bigger number by rearranging the digits of a given number. """
nums = list(str(n))
for i in range(len(nums) - 2, -1, -1):
if nums[i] < nums[i + 1]:
z = nums[i:]
y = min(filter(lambda x: x > z[0], z))
... |
z.sort()
|
code_infilling | python | python | MBPP/407/L8 | [] | [] | MBPP_Infilling | return int(''.join(nums))
return False | [
[
"12",
"21"
],
[
"10",
"False"
],
[
"102",
"120"
]
] | rearrange_bigger | [] | Write a function to create the next bigger number by rearranging the digits of a given number. | def rearrange_bigger(n):
"""Write a function to create the next bigger number by rearranging the digits of a given number. """
nums = list(str(n))
for i in range(len(nums) - 2, -1, -1):
if nums[i] < nums[i + 1]:
z = nums[i:]
y = min(filter(lambda x: x > z[0], z))
... |
nums[i:] = [y] + z
|
code_infilling | python | python | MBPP/407/L9 | [] | [] | MBPP_Infilling | return False | [
[
"12",
"21"
],
[
"10",
"False"
],
[
"102",
"120"
]
] | rearrange_bigger | [] | Write a function to create the next bigger number by rearranging the digits of a given number. | def rearrange_bigger(n):
"""Write a function to create the next bigger number by rearranging the digits of a given number. """
nums = list(str(n))
for i in range(len(nums) - 2, -1, -1):
if nums[i] < nums[i + 1]:
z = nums[i:]
y = min(filter(lambda x: x > z[0], z))
... |
return int(''.join(nums))
|
code_infilling | python | python | MBPP/407/L10 | [] | [] | MBPP_Infilling | [
[
"12",
"21"
],
[
"10",
"False"
],
[
"102",
"120"
]
] | rearrange_bigger | [] | Write a function to create the next bigger number by rearranging the digits of a given number. | def rearrange_bigger(n):
"""Write a function to create the next bigger number by rearranging the digits of a given number. """
nums = list(str(n))
for i in range(len(nums) - 2, -1, -1):
if nums[i] < nums[i + 1]:
z = nums[i:]
y = min(filter(lambda x: x > z[0], z))
... |
return False
| |
code_infilling | python | python | MBPP/408/L3 | [] | [] | MBPP_Infilling |
def push(i, j):
if i < len(nums1) and j < len(nums2):
heapq.heappush(queue, [nums1[i] + nums2[j], i, j])
push(0, 0)
pairs = []
while queue and len(pairs) < k:
(_, i, j) = heapq.heappop(queue)
pairs.append([nums1[i], nums2[j]])
push(i, j + 1)
if j == 0... | [
[
"[1,3,7],[2,4,6],2",
"[[1, 2], [1, 4]]"
],
[
"[1,3,7],[2,4,6],1",
"[[1, 2]]"
],
[
"[1,3,7],[2,4,6],7",
"[[1, 2], [1, 4], [3, 2], [1, 6], [3, 4], [3, 6], [7, 2]]"
]
] | k_smallest_pairs | [
"import heapq"
] | Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. | import heapq
def k_smallest_pairs(nums1, nums2, k):
"""Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. """
|
queue = []
|
code_infilling | python | python | MBPP/408/L5 | [] | [] | MBPP_Infilling | if i < len(nums1) and j < len(nums2):
heapq.heappush(queue, [nums1[i] + nums2[j], i, j])
push(0, 0)
pairs = []
while queue and len(pairs) < k:
(_, i, j) = heapq.heappop(queue)
pairs.append([nums1[i], nums2[j]])
push(i, j + 1)
if j == 0:
push(i ... | [
[
"[1,3,7],[2,4,6],2",
"[[1, 2], [1, 4]]"
],
[
"[1,3,7],[2,4,6],1",
"[[1, 2]]"
],
[
"[1,3,7],[2,4,6],7",
"[[1, 2], [1, 4], [3, 2], [1, 6], [3, 4], [3, 6], [7, 2]]"
]
] | k_smallest_pairs | [
"import heapq"
] | Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. | import heapq
def k_smallest_pairs(nums1, nums2, k):
"""Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. """
queue = []
|
def push(i, j):
|
code_infilling | python | python | MBPP/408/L6 | [] | [] | MBPP_Infilling | heapq.heappush(queue, [nums1[i] + nums2[j], i, j])
push(0, 0)
pairs = []
while queue and len(pairs) < k:
(_, i, j) = heapq.heappop(queue)
pairs.append([nums1[i], nums2[j]])
push(i, j + 1)
if j == 0:
push(i + 1, 0)
return pairs | [
[
"[1,3,7],[2,4,6],2",
"[[1, 2], [1, 4]]"
],
[
"[1,3,7],[2,4,6],1",
"[[1, 2]]"
],
[
"[1,3,7],[2,4,6],7",
"[[1, 2], [1, 4], [3, 2], [1, 6], [3, 4], [3, 6], [7, 2]]"
]
] | k_smallest_pairs | [
"import heapq"
] | Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. | import heapq
def k_smallest_pairs(nums1, nums2, k):
"""Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. """
queue = []
def push(i, j): |
if i < len(nums1) and j < len(nums2):
|
code_infilling | python | python | MBPP/408/L7 | [] | [] | MBPP_Infilling | push(0, 0)
pairs = []
while queue and len(pairs) < k:
(_, i, j) = heapq.heappop(queue)
pairs.append([nums1[i], nums2[j]])
push(i, j + 1)
if j == 0:
push(i + 1, 0)
return pairs | [
[
"[1,3,7],[2,4,6],2",
"[[1, 2], [1, 4]]"
],
[
"[1,3,7],[2,4,6],1",
"[[1, 2]]"
],
[
"[1,3,7],[2,4,6],7",
"[[1, 2], [1, 4], [3, 2], [1, 6], [3, 4], [3, 6], [7, 2]]"
]
] | k_smallest_pairs | [
"import heapq"
] | Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. | import heapq
def k_smallest_pairs(nums1, nums2, k):
"""Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. """
queue = []
def push(i, j):
if i < len(nums1) and j < len(nums2): |
heapq.heappush(queue, [nums1[i] + nums2[j], i, j])
|
code_infilling | python | python | MBPP/408/L8 | [] | [] | MBPP_Infilling | pairs = []
while queue and len(pairs) < k:
(_, i, j) = heapq.heappop(queue)
pairs.append([nums1[i], nums2[j]])
push(i, j + 1)
if j == 0:
push(i + 1, 0)
return pairs | [
[
"[1,3,7],[2,4,6],2",
"[[1, 2], [1, 4]]"
],
[
"[1,3,7],[2,4,6],1",
"[[1, 2]]"
],
[
"[1,3,7],[2,4,6],7",
"[[1, 2], [1, 4], [3, 2], [1, 6], [3, 4], [3, 6], [7, 2]]"
]
] | k_smallest_pairs | [
"import heapq"
] | Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. | import heapq
def k_smallest_pairs(nums1, nums2, k):
"""Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. """
queue = []
def push(i, j):
if i < len(nums1) and j < len(nums2):
heapq.heappush(que... |
push(0, 0)
|
code_infilling | python | python | MBPP/408/L9 | [] | [] | MBPP_Infilling | while queue and len(pairs) < k:
(_, i, j) = heapq.heappop(queue)
pairs.append([nums1[i], nums2[j]])
push(i, j + 1)
if j == 0:
push(i + 1, 0)
return pairs | [
[
"[1,3,7],[2,4,6],2",
"[[1, 2], [1, 4]]"
],
[
"[1,3,7],[2,4,6],1",
"[[1, 2]]"
],
[
"[1,3,7],[2,4,6],7",
"[[1, 2], [1, 4], [3, 2], [1, 6], [3, 4], [3, 6], [7, 2]]"
]
] | k_smallest_pairs | [
"import heapq"
] | Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. | import heapq
def k_smallest_pairs(nums1, nums2, k):
"""Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. """
queue = []
def push(i, j):
if i < len(nums1) and j < len(nums2):
heapq.heappush(que... |
pairs = []
|
code_infilling | python | python | MBPP/408/L10 | [] | [] | MBPP_Infilling | (_, i, j) = heapq.heappop(queue)
pairs.append([nums1[i], nums2[j]])
push(i, j + 1)
if j == 0:
push(i + 1, 0)
return pairs | [
[
"[1,3,7],[2,4,6],2",
"[[1, 2], [1, 4]]"
],
[
"[1,3,7],[2,4,6],1",
"[[1, 2]]"
],
[
"[1,3,7],[2,4,6],7",
"[[1, 2], [1, 4], [3, 2], [1, 6], [3, 4], [3, 6], [7, 2]]"
]
] | k_smallest_pairs | [
"import heapq"
] | Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. | import heapq
def k_smallest_pairs(nums1, nums2, k):
"""Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. """
queue = []
def push(i, j):
if i < len(nums1) and j < len(nums2):
heapq.heappush(que... |
while queue and len(pairs) < k:
|
code_infilling | python | python | MBPP/408/L11 | [] | [] | MBPP_Infilling | pairs.append([nums1[i], nums2[j]])
push(i, j + 1)
if j == 0:
push(i + 1, 0)
return pairs | [
[
"[1,3,7],[2,4,6],2",
"[[1, 2], [1, 4]]"
],
[
"[1,3,7],[2,4,6],1",
"[[1, 2]]"
],
[
"[1,3,7],[2,4,6],7",
"[[1, 2], [1, 4], [3, 2], [1, 6], [3, 4], [3, 6], [7, 2]]"
]
] | k_smallest_pairs | [
"import heapq"
] | Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. | import heapq
def k_smallest_pairs(nums1, nums2, k):
"""Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. """
queue = []
def push(i, j):
if i < len(nums1) and j < len(nums2):
heapq.heappush(que... |
(_, i, j) = heapq.heappop(queue)
|
code_infilling | python | python | MBPP/408/L12 | [] | [] | MBPP_Infilling | push(i, j + 1)
if j == 0:
push(i + 1, 0)
return pairs | [
[
"[1,3,7],[2,4,6],2",
"[[1, 2], [1, 4]]"
],
[
"[1,3,7],[2,4,6],1",
"[[1, 2]]"
],
[
"[1,3,7],[2,4,6],7",
"[[1, 2], [1, 4], [3, 2], [1, 6], [3, 4], [3, 6], [7, 2]]"
]
] | k_smallest_pairs | [
"import heapq"
] | Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. | import heapq
def k_smallest_pairs(nums1, nums2, k):
"""Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. """
queue = []
def push(i, j):
if i < len(nums1) and j < len(nums2):
heapq.heappush(que... |
pairs.append([nums1[i], nums2[j]])
|
code_infilling | python | python | MBPP/408/L13 | [] | [] | MBPP_Infilling | if j == 0:
push(i + 1, 0)
return pairs | [
[
"[1,3,7],[2,4,6],2",
"[[1, 2], [1, 4]]"
],
[
"[1,3,7],[2,4,6],1",
"[[1, 2]]"
],
[
"[1,3,7],[2,4,6],7",
"[[1, 2], [1, 4], [3, 2], [1, 6], [3, 4], [3, 6], [7, 2]]"
]
] | k_smallest_pairs | [
"import heapq"
] | Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. | import heapq
def k_smallest_pairs(nums1, nums2, k):
"""Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. """
queue = []
def push(i, j):
if i < len(nums1) and j < len(nums2):
heapq.heappush(que... |
push(i, j + 1)
|
code_infilling | python | python | MBPP/408/L14 | [] | [] | MBPP_Infilling | push(i + 1, 0)
return pairs | [
[
"[1,3,7],[2,4,6],2",
"[[1, 2], [1, 4]]"
],
[
"[1,3,7],[2,4,6],1",
"[[1, 2]]"
],
[
"[1,3,7],[2,4,6],7",
"[[1, 2], [1, 4], [3, 2], [1, 6], [3, 4], [3, 6], [7, 2]]"
]
] | k_smallest_pairs | [
"import heapq"
] | Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. | import heapq
def k_smallest_pairs(nums1, nums2, k):
"""Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. """
queue = []
def push(i, j):
if i < len(nums1) and j < len(nums2):
heapq.heappush(que... |
if j == 0:
|
code_infilling | python | python | MBPP/408/L15 | [] | [] | MBPP_Infilling | return pairs | [
[
"[1,3,7],[2,4,6],2",
"[[1, 2], [1, 4]]"
],
[
"[1,3,7],[2,4,6],1",
"[[1, 2]]"
],
[
"[1,3,7],[2,4,6],7",
"[[1, 2], [1, 4], [3, 2], [1, 6], [3, 4], [3, 6], [7, 2]]"
]
] | k_smallest_pairs | [
"import heapq"
] | Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. | import heapq
def k_smallest_pairs(nums1, nums2, k):
"""Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. """
queue = []
def push(i, j):
if i < len(nums1) and j < len(nums2):
heapq.heappush(que... |
push(i + 1, 0)
|
code_infilling | python | python | MBPP/408/L16 | [] | [] | MBPP_Infilling | [
[
"[1,3,7],[2,4,6],2",
"[[1, 2], [1, 4]]"
],
[
"[1,3,7],[2,4,6],1",
"[[1, 2]]"
],
[
"[1,3,7],[2,4,6],7",
"[[1, 2], [1, 4], [3, 2], [1, 6], [3, 4], [3, 6], [7, 2]]"
]
] | k_smallest_pairs | [
"import heapq"
] | Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. | import heapq
def k_smallest_pairs(nums1, nums2, k):
"""Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. """
queue = []
def push(i, j):
if i < len(nums1) and j < len(nums2):
heapq.heappush(que... |
return pairs
| |
code_infilling | python | python | MBPP/409/L1 | [] | [] | MBPP_Infilling | return result_min | [
[
"[(2, 7), (2, 6), (1, 8), (4, 9)] ",
"8"
],
[
"[(10,20), (15,2), (5,10)] ",
"30"
],
[
"[(11,44), (10,15), (20,5), (12, 9)] ",
"100"
]
] | min_product_tuple | [] | Write a function to find the minimum product from the pairs of tuples within a given list. | def min_product_tuple(list1):
"""Write a function to find the minimum product from the pairs of tuples within a given list. """
|
result_min = min([abs(x * y) for (x, y) in list1])
|
code_infilling | python | python | MBPP/409/L2 | [] | [] | MBPP_Infilling | [
[
"[(2, 7), (2, 6), (1, 8), (4, 9)] ",
"8"
],
[
"[(10,20), (15,2), (5,10)] ",
"30"
],
[
"[(11,44), (10,15), (20,5), (12, 9)] ",
"100"
]
] | min_product_tuple | [] | Write a function to find the minimum product from the pairs of tuples within a given list. | def min_product_tuple(list1):
"""Write a function to find the minimum product from the pairs of tuples within a given list. """
result_min = min([abs(x * y) for (x, y) in list1]) |
return result_min
| |
code_infilling | python | python | MBPP/410/L1 | [] | [] | MBPP_Infilling | return min_val | [
[
"['Python', 3, 2, 4, 5, 'version']",
"2"
],
[
"['Python', 15, 20, 25]",
"15"
],
[
"['Python', 30, 20, 40, 50, 'version']",
"20"
]
] | min_val | [] | Write a function to find the minimum value in a given heterogeneous list. | def min_val(listval):
"""Write a function to find the minimum value in a given heterogeneous list. """
|
min_val = min((i for i in listval if isinstance(i, int)))
|
code_infilling | python | python | MBPP/410/L2 | [] | [] | MBPP_Infilling | [
[
"['Python', 3, 2, 4, 5, 'version']",
"2"
],
[
"['Python', 15, 20, 25]",
"15"
],
[
"['Python', 30, 20, 40, 50, 'version']",
"20"
]
] | min_val | [] | Write a function to find the minimum value in a given heterogeneous list. | def min_val(listval):
"""Write a function to find the minimum value in a given heterogeneous list. """
min_val = min((i for i in listval if isinstance(i, int))) |
return min_val
| |
code_infilling | python | python | MBPP/411/L3 | [] | [] | MBPP_Infilling | [
[
"'android_tv'",
"'AndroidTv'"
],
[
"'google_pixel'",
"'GooglePixel'"
],
[
"'apple_watch'",
"'AppleWatch'"
]
] | snake_to_camel | [
"import re"
] | Write a function to convert the given snake case string to camel case string. | import re
def snake_to_camel(word):
"""Write a function to convert the given snake case string to camel case string. """
|
return ''.join((x.capitalize() or '_' for x in word.split('_')))
| |
code_infilling | python | python | MBPP/412/L1 | [] | [] | MBPP_Infilling | if i % 2 != 0:
l.remove(i)
return l | [
[
"[1,2,3]",
"[2]"
],
[
"[2,4,6]",
"[2,4,6]"
],
[
"[10,20,3]",
"[10,20]"
]
] | remove_odd | [] | Write a python function to remove odd numbers from a given list. | def remove_odd(l):
"""Write a python function to remove odd numbers from a given list. """
|
for i in l:
|
code_infilling | python | python | MBPP/412/L2 | [] | [] | MBPP_Infilling | l.remove(i)
return l | [
[
"[1,2,3]",
"[2]"
],
[
"[2,4,6]",
"[2,4,6]"
],
[
"[10,20,3]",
"[10,20]"
]
] | remove_odd | [] | Write a python function to remove odd numbers from a given list. | def remove_odd(l):
"""Write a python function to remove odd numbers from a given list. """
for i in l: |
if i % 2 != 0:
|
code_infilling | python | python | MBPP/412/L3 | [] | [] | MBPP_Infilling | return l | [
[
"[1,2,3]",
"[2]"
],
[
"[2,4,6]",
"[2,4,6]"
],
[
"[10,20,3]",
"[10,20]"
]
] | remove_odd | [] | Write a python function to remove odd numbers from a given list. | def remove_odd(l):
"""Write a python function to remove odd numbers from a given list. """
for i in l:
if i % 2 != 0: |
l.remove(i)
|
code_infilling | python | python | MBPP/412/L4 | [] | [] | MBPP_Infilling | [
[
"[1,2,3]",
"[2]"
],
[
"[2,4,6]",
"[2,4,6]"
],
[
"[10,20,3]",
"[10,20]"
]
] | remove_odd | [] | Write a python function to remove odd numbers from a given list. | def remove_odd(l):
"""Write a python function to remove odd numbers from a given list. """
for i in l:
if i % 2 != 0:
l.remove(i) |
return l
| |
code_infilling | python | python | MBPP/413/L1 | [] | [] | MBPP_Infilling | return result | [
[
"[('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,0",
"['Greyson Fulton', 'Brady Kent', 'Wyatt Knott', 'Beau Turnbull']"
],
[
"[('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,2",
... | extract_nth_element | [] | Write a function to extract the nth element from a given list of tuples. | def extract_nth_element(list1, n):
"""Write a function to extract the nth element from a given list of tuples. """
|
result = [x[n] for x in list1]
|
code_infilling | python | python | MBPP/413/L2 | [] | [] | MBPP_Infilling | [
[
"[('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,0",
"['Greyson Fulton', 'Brady Kent', 'Wyatt Knott', 'Beau Turnbull']"
],
[
"[('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,2",
... | extract_nth_element | [] | Write a function to extract the nth element from a given list of tuples. | def extract_nth_element(list1, n):
"""Write a function to extract the nth element from a given list of tuples. """
result = [x[n] for x in list1] |
return result
| |
code_infilling | python | python | MBPP/414/L1 | [] | [] | MBPP_Infilling | for j in range(len(list2)):
if list1[i] == list2[j]:
return True
return False | [
[
"[1,2,3,4,5],[6,7,8,9]",
"False"
],
[
"[1,2,3],[4,5,6]",
"False"
],
[
"[1,4,5],[1,4,5]",
"True"
]
] | overlapping | [] | Write a python function to check whether any value in a sequence exists in a sequence or not. | def overlapping(list1, list2):
"""Write a python function to check whether any value in a sequence exists in a sequence or not. """
|
for i in range(len(list1)):
|
code_infilling | python | python | MBPP/414/L2 | [] | [] | MBPP_Infilling | if list1[i] == list2[j]:
return True
return False | [
[
"[1,2,3,4,5],[6,7,8,9]",
"False"
],
[
"[1,2,3],[4,5,6]",
"False"
],
[
"[1,4,5],[1,4,5]",
"True"
]
] | overlapping | [] | Write a python function to check whether any value in a sequence exists in a sequence or not. | def overlapping(list1, list2):
"""Write a python function to check whether any value in a sequence exists in a sequence or not. """
for i in range(len(list1)): |
for j in range(len(list2)):
|
code_infilling | python | python | MBPP/414/L3 | [] | [] | MBPP_Infilling | return True
return False | [
[
"[1,2,3,4,5],[6,7,8,9]",
"False"
],
[
"[1,2,3],[4,5,6]",
"False"
],
[
"[1,4,5],[1,4,5]",
"True"
]
] | overlapping | [] | Write a python function to check whether any value in a sequence exists in a sequence or not. | def overlapping(list1, list2):
"""Write a python function to check whether any value in a sequence exists in a sequence or not. """
for i in range(len(list1)):
for j in range(len(list2)): |
if list1[i] == list2[j]:
|
code_infilling | python | python | MBPP/414/L4 | [] | [] | MBPP_Infilling | return False | [
[
"[1,2,3,4,5],[6,7,8,9]",
"False"
],
[
"[1,2,3],[4,5,6]",
"False"
],
[
"[1,4,5],[1,4,5]",
"True"
]
] | overlapping | [] | Write a python function to check whether any value in a sequence exists in a sequence or not. | def overlapping(list1, list2):
"""Write a python function to check whether any value in a sequence exists in a sequence or not. """
for i in range(len(list1)):
for j in range(len(list2)):
if list1[i] == list2[j]: |
return True
|
code_infilling | python | python | MBPP/414/L5 | [] | [] | MBPP_Infilling | [
[
"[1,2,3,4,5],[6,7,8,9]",
"False"
],
[
"[1,2,3],[4,5,6]",
"False"
],
[
"[1,4,5],[1,4,5]",
"True"
]
] | overlapping | [] | Write a python function to check whether any value in a sequence exists in a sequence or not. | def overlapping(list1, list2):
"""Write a python function to check whether any value in a sequence exists in a sequence or not. """
for i in range(len(list1)):
for j in range(len(list2)):
if list1[i] == list2[j]:
return True |
return False
| |
code_infilling | python | python | MBPP/415/L1 | [] | [] | MBPP_Infilling | if arr_len < 2:
return 'No pairs exists'
x = arr[0]
y = arr[1]
for i in range(0, arr_len):
for j in range(i + 1, arr_len):
if arr[i] * arr[j] > x * y:
x = arr[i]
y = arr[j]
return (x, y) | [
[
"[1,2,3,4,7,0,8,4]",
"(7,8)"
],
[
"[0,-1,-2,-4,5,0,-6]",
"(-4,-6)"
],
[
"[1,2,3]",
"(2,3)"
]
] | max_Product | [] | Write a python function to find a pair with highest product from a given array of integers. | def max_Product(arr):
"""Write a python function to find a pair with highest product from a given array of integers. """
|
arr_len = len(arr)
|
code_infilling | python | python | MBPP/415/L2 | [] | [] | MBPP_Infilling | return 'No pairs exists'
x = arr[0]
y = arr[1]
for i in range(0, arr_len):
for j in range(i + 1, arr_len):
if arr[i] * arr[j] > x * y:
x = arr[i]
y = arr[j]
return (x, y) | [
[
"[1,2,3,4,7,0,8,4]",
"(7,8)"
],
[
"[0,-1,-2,-4,5,0,-6]",
"(-4,-6)"
],
[
"[1,2,3]",
"(2,3)"
]
] | max_Product | [] | Write a python function to find a pair with highest product from a given array of integers. | def max_Product(arr):
"""Write a python function to find a pair with highest product from a given array of integers. """
arr_len = len(arr) |
if arr_len < 2:
|
code_infilling | python | python | MBPP/415/L3 | [] | [] | MBPP_Infilling | x = arr[0]
y = arr[1]
for i in range(0, arr_len):
for j in range(i + 1, arr_len):
if arr[i] * arr[j] > x * y:
x = arr[i]
y = arr[j]
return (x, y) | [
[
"[1,2,3,4,7,0,8,4]",
"(7,8)"
],
[
"[0,-1,-2,-4,5,0,-6]",
"(-4,-6)"
],
[
"[1,2,3]",
"(2,3)"
]
] | max_Product | [] | Write a python function to find a pair with highest product from a given array of integers. | def max_Product(arr):
"""Write a python function to find a pair with highest product from a given array of integers. """
arr_len = len(arr)
if arr_len < 2: |
return 'No pairs exists'
|
code_infilling | python | python | MBPP/415/L4 | [] | [] | MBPP_Infilling | y = arr[1]
for i in range(0, arr_len):
for j in range(i + 1, arr_len):
if arr[i] * arr[j] > x * y:
x = arr[i]
y = arr[j]
return (x, y) | [
[
"[1,2,3,4,7,0,8,4]",
"(7,8)"
],
[
"[0,-1,-2,-4,5,0,-6]",
"(-4,-6)"
],
[
"[1,2,3]",
"(2,3)"
]
] | max_Product | [] | Write a python function to find a pair with highest product from a given array of integers. | def max_Product(arr):
"""Write a python function to find a pair with highest product from a given array of integers. """
arr_len = len(arr)
if arr_len < 2:
return 'No pairs exists' |
x = arr[0]
|
code_infilling | python | python | MBPP/415/L5 | [] | [] | MBPP_Infilling | for i in range(0, arr_len):
for j in range(i + 1, arr_len):
if arr[i] * arr[j] > x * y:
x = arr[i]
y = arr[j]
return (x, y) | [
[
"[1,2,3,4,7,0,8,4]",
"(7,8)"
],
[
"[0,-1,-2,-4,5,0,-6]",
"(-4,-6)"
],
[
"[1,2,3]",
"(2,3)"
]
] | max_Product | [] | Write a python function to find a pair with highest product from a given array of integers. | def max_Product(arr):
"""Write a python function to find a pair with highest product from a given array of integers. """
arr_len = len(arr)
if arr_len < 2:
return 'No pairs exists'
x = arr[0] |
y = arr[1]
|
code_infilling | python | python | MBPP/415/L6 | [] | [] | MBPP_Infilling | for j in range(i + 1, arr_len):
if arr[i] * arr[j] > x * y:
x = arr[i]
y = arr[j]
return (x, y) | [
[
"[1,2,3,4,7,0,8,4]",
"(7,8)"
],
[
"[0,-1,-2,-4,5,0,-6]",
"(-4,-6)"
],
[
"[1,2,3]",
"(2,3)"
]
] | max_Product | [] | Write a python function to find a pair with highest product from a given array of integers. | def max_Product(arr):
"""Write a python function to find a pair with highest product from a given array of integers. """
arr_len = len(arr)
if arr_len < 2:
return 'No pairs exists'
x = arr[0]
y = arr[1] |
for i in range(0, arr_len):
|
code_infilling | python | python | MBPP/415/L7 | [] | [] | MBPP_Infilling | if arr[i] * arr[j] > x * y:
x = arr[i]
y = arr[j]
return (x, y) | [
[
"[1,2,3,4,7,0,8,4]",
"(7,8)"
],
[
"[0,-1,-2,-4,5,0,-6]",
"(-4,-6)"
],
[
"[1,2,3]",
"(2,3)"
]
] | max_Product | [] | Write a python function to find a pair with highest product from a given array of integers. | def max_Product(arr):
"""Write a python function to find a pair with highest product from a given array of integers. """
arr_len = len(arr)
if arr_len < 2:
return 'No pairs exists'
x = arr[0]
y = arr[1]
for i in range(0, arr_len): |
for j in range(i + 1, arr_len):
|
code_infilling | python | python | MBPP/415/L8 | [] | [] | MBPP_Infilling | x = arr[i]
y = arr[j]
return (x, y) | [
[
"[1,2,3,4,7,0,8,4]",
"(7,8)"
],
[
"[0,-1,-2,-4,5,0,-6]",
"(-4,-6)"
],
[
"[1,2,3]",
"(2,3)"
]
] | max_Product | [] | Write a python function to find a pair with highest product from a given array of integers. | def max_Product(arr):
"""Write a python function to find a pair with highest product from a given array of integers. """
arr_len = len(arr)
if arr_len < 2:
return 'No pairs exists'
x = arr[0]
y = arr[1]
for i in range(0, arr_len):
for j in range(i + 1, arr_len): |
if arr[i] * arr[j] > x * y:
|
code_infilling | python | python | MBPP/415/L9 | [] | [] | MBPP_Infilling | y = arr[j]
return (x, y) | [
[
"[1,2,3,4,7,0,8,4]",
"(7,8)"
],
[
"[0,-1,-2,-4,5,0,-6]",
"(-4,-6)"
],
[
"[1,2,3]",
"(2,3)"
]
] | max_Product | [] | Write a python function to find a pair with highest product from a given array of integers. | def max_Product(arr):
"""Write a python function to find a pair with highest product from a given array of integers. """
arr_len = len(arr)
if arr_len < 2:
return 'No pairs exists'
x = arr[0]
y = arr[1]
for i in range(0, arr_len):
for j in range(i + 1, arr_len):
if... |
x = arr[i]
|
code_infilling | python | python | MBPP/415/L10 | [] | [] | MBPP_Infilling | return (x, y) | [
[
"[1,2,3,4,7,0,8,4]",
"(7,8)"
],
[
"[0,-1,-2,-4,5,0,-6]",
"(-4,-6)"
],
[
"[1,2,3]",
"(2,3)"
]
] | max_Product | [] | Write a python function to find a pair with highest product from a given array of integers. | def max_Product(arr):
"""Write a python function to find a pair with highest product from a given array of integers. """
arr_len = len(arr)
if arr_len < 2:
return 'No pairs exists'
x = arr[0]
y = arr[1]
for i in range(0, arr_len):
for j in range(i + 1, arr_len):
if... |
y = arr[j]
|
code_infilling | python | python | MBPP/415/L11 | [] | [] | MBPP_Infilling | [
[
"[1,2,3,4,7,0,8,4]",
"(7,8)"
],
[
"[0,-1,-2,-4,5,0,-6]",
"(-4,-6)"
],
[
"[1,2,3]",
"(2,3)"
]
] | max_Product | [] | Write a python function to find a pair with highest product from a given array of integers. | def max_Product(arr):
"""Write a python function to find a pair with highest product from a given array of integers. """
arr_len = len(arr)
if arr_len < 2:
return 'No pairs exists'
x = arr[0]
y = arr[1]
for i in range(0, arr_len):
for j in range(i + 1, arr_len):
if... |
return (x, y)
| |
code_infilling | python | python | MBPP/417/L1 | [] | [] | MBPP_Infilling | for elem in Input:
try:
out[elem[0]].extend(elem[1:])
except KeyError:
out[elem[0]] = list(elem)
return [tuple(values) for values in out.values()] | [
[
"[('x', 'y'), ('x', 'z'), ('w', 't')]",
"[('x', 'y', 'z'), ('w', 't')]"
],
[
"[('a', 'b'), ('a', 'c'), ('d', 'e')]",
"[('a', 'b', 'c'), ('d', 'e')]"
],
[
"[('f', 'g'), ('f', 'g'), ('h', 'i')]",
"[('f', 'g', 'g'), ('h', 'i')]"
]
] | group_tuples | [] | Write a function to find common first element in given list of tuple. | def group_tuples(Input):
"""Write a function to find common first element in given list of tuple. """
|
out = {}
|
code_infilling | python | python | MBPP/417/L2 | [] | [] | MBPP_Infilling | try:
out[elem[0]].extend(elem[1:])
except KeyError:
out[elem[0]] = list(elem)
return [tuple(values) for values in out.values()] | [
[
"[('x', 'y'), ('x', 'z'), ('w', 't')]",
"[('x', 'y', 'z'), ('w', 't')]"
],
[
"[('a', 'b'), ('a', 'c'), ('d', 'e')]",
"[('a', 'b', 'c'), ('d', 'e')]"
],
[
"[('f', 'g'), ('f', 'g'), ('h', 'i')]",
"[('f', 'g', 'g'), ('h', 'i')]"
]
] | group_tuples | [] | Write a function to find common first element in given list of tuple. | def group_tuples(Input):
"""Write a function to find common first element in given list of tuple. """
out = {} |
for elem in Input:
|
code_infilling | python | python | MBPP/417/L3 | [] | [] | MBPP_Infilling | out[elem[0]].extend(elem[1:])
except KeyError:
out[elem[0]] = list(elem)
return [tuple(values) for values in out.values()] | [
[
"[('x', 'y'), ('x', 'z'), ('w', 't')]",
"[('x', 'y', 'z'), ('w', 't')]"
],
[
"[('a', 'b'), ('a', 'c'), ('d', 'e')]",
"[('a', 'b', 'c'), ('d', 'e')]"
],
[
"[('f', 'g'), ('f', 'g'), ('h', 'i')]",
"[('f', 'g', 'g'), ('h', 'i')]"
]
] | group_tuples | [] | Write a function to find common first element in given list of tuple. | def group_tuples(Input):
"""Write a function to find common first element in given list of tuple. """
out = {}
for elem in Input: |
try:
|
code_infilling | python | python | MBPP/417/L4 | [] | [] | MBPP_Infilling | except KeyError:
out[elem[0]] = list(elem)
return [tuple(values) for values in out.values()] | [
[
"[('x', 'y'), ('x', 'z'), ('w', 't')]",
"[('x', 'y', 'z'), ('w', 't')]"
],
[
"[('a', 'b'), ('a', 'c'), ('d', 'e')]",
"[('a', 'b', 'c'), ('d', 'e')]"
],
[
"[('f', 'g'), ('f', 'g'), ('h', 'i')]",
"[('f', 'g', 'g'), ('h', 'i')]"
]
] | group_tuples | [] | Write a function to find common first element in given list of tuple. | def group_tuples(Input):
"""Write a function to find common first element in given list of tuple. """
out = {}
for elem in Input:
try: |
out[elem[0]].extend(elem[1:])
|
code_infilling | python | python | MBPP/417/L5 | [] | [] | MBPP_Infilling | out[elem[0]] = list(elem)
return [tuple(values) for values in out.values()] | [
[
"[('x', 'y'), ('x', 'z'), ('w', 't')]",
"[('x', 'y', 'z'), ('w', 't')]"
],
[
"[('a', 'b'), ('a', 'c'), ('d', 'e')]",
"[('a', 'b', 'c'), ('d', 'e')]"
],
[
"[('f', 'g'), ('f', 'g'), ('h', 'i')]",
"[('f', 'g', 'g'), ('h', 'i')]"
]
] | group_tuples | [] | Write a function to find common first element in given list of tuple. | def group_tuples(Input):
"""Write a function to find common first element in given list of tuple. """
out = {}
for elem in Input:
try:
out[elem[0]].extend(elem[1:]) |
except KeyError:
|
code_infilling | python | python | MBPP/417/L6 | [] | [] | MBPP_Infilling | return [tuple(values) for values in out.values()] | [
[
"[('x', 'y'), ('x', 'z'), ('w', 't')]",
"[('x', 'y', 'z'), ('w', 't')]"
],
[
"[('a', 'b'), ('a', 'c'), ('d', 'e')]",
"[('a', 'b', 'c'), ('d', 'e')]"
],
[
"[('f', 'g'), ('f', 'g'), ('h', 'i')]",
"[('f', 'g', 'g'), ('h', 'i')]"
]
] | group_tuples | [] | Write a function to find common first element in given list of tuple. | def group_tuples(Input):
"""Write a function to find common first element in given list of tuple. """
out = {}
for elem in Input:
try:
out[elem[0]].extend(elem[1:])
except KeyError: |
out[elem[0]] = list(elem)
|
code_infilling | python | python | MBPP/417/L7 | [] | [] | MBPP_Infilling | [
[
"[('x', 'y'), ('x', 'z'), ('w', 't')]",
"[('x', 'y', 'z'), ('w', 't')]"
],
[
"[('a', 'b'), ('a', 'c'), ('d', 'e')]",
"[('a', 'b', 'c'), ('d', 'e')]"
],
[
"[('f', 'g'), ('f', 'g'), ('h', 'i')]",
"[('f', 'g', 'g'), ('h', 'i')]"
]
] | group_tuples | [] | Write a function to find common first element in given list of tuple. | def group_tuples(Input):
"""Write a function to find common first element in given list of tuple. """
out = {}
for elem in Input:
try:
out[elem[0]].extend(elem[1:])
except KeyError:
out[elem[0]] = list(elem) |
return [tuple(values) for values in out.values()]
| |
code_infilling | python | python | MBPP/418/L1 | [] | [] | MBPP_Infilling | return maxList | [
[
"[['A'],['A','B'],['A','B','C']]",
"['A','B','C']"
],
[
"[[1],[1,2],[1,2,3]]",
"[1,2,3]"
],
[
"[[1,1],[1,2,3],[1,5,6,1]]",
"[1,5,6,1]"
]
] | Find_Max | [] | Write a python function to find the element of a list having maximum length. | def Find_Max(lst):
"""Write a python function to find the element of a list having maximum length. """
|
maxList = max((x for x in lst))
|
code_infilling | python | python | MBPP/418/L2 | [] | [] | MBPP_Infilling | [
[
"[['A'],['A','B'],['A','B','C']]",
"['A','B','C']"
],
[
"[[1],[1,2],[1,2,3]]",
"[1,2,3]"
],
[
"[[1,1],[1,2,3],[1,5,6,1]]",
"[1,5,6,1]"
]
] | Find_Max | [] | Write a python function to find the element of a list having maximum length. | def Find_Max(lst):
"""Write a python function to find the element of a list having maximum length. """
maxList = max((x for x in lst)) |
return maxList
| |
code_infilling | python | python | MBPP/419/L1 | [] | [] | MBPP_Infilling | round_and_sum = sum(list(map(round, list1)) * lenght)
return round_and_sum | [
[
"[22.4, 4.0, -16.22, -9.10, 11.00, -12.22, 14.20, -5.20, 17.50]",
"243"
],
[
"[5,2,9,24.3,29]",
"345"
],
[
"[25.0,56.7,89.2]",
"513"
]
] | round_and_sum | [] | Write a function to round every number of a given list of numbers and print the total sum multiplied by the length of the list. | def round_and_sum(list1):
"""Write a function to round every number of a given list of numbers and print the total sum multiplied by the length of the list. """
|
lenght = len(list1)
|
code_infilling | python | python | MBPP/419/L2 | [] | [] | MBPP_Infilling | return round_and_sum | [
[
"[22.4, 4.0, -16.22, -9.10, 11.00, -12.22, 14.20, -5.20, 17.50]",
"243"
],
[
"[5,2,9,24.3,29]",
"345"
],
[
"[25.0,56.7,89.2]",
"513"
]
] | round_and_sum | [] | Write a function to round every number of a given list of numbers and print the total sum multiplied by the length of the list. | def round_and_sum(list1):
"""Write a function to round every number of a given list of numbers and print the total sum multiplied by the length of the list. """
lenght = len(list1) |
round_and_sum = sum(list(map(round, list1)) * lenght)
|
code_infilling | python | python | MBPP/419/L3 | [] | [] | MBPP_Infilling | [
[
"[22.4, 4.0, -16.22, -9.10, 11.00, -12.22, 14.20, -5.20, 17.50]",
"243"
],
[
"[5,2,9,24.3,29]",
"345"
],
[
"[25.0,56.7,89.2]",
"513"
]
] | round_and_sum | [] | Write a function to round every number of a given list of numbers and print the total sum multiplied by the length of the list. | def round_and_sum(list1):
"""Write a function to round every number of a given list of numbers and print the total sum multiplied by the length of the list. """
lenght = len(list1)
round_and_sum = sum(list(map(round, list1)) * lenght) |
return round_and_sum
| |
code_infilling | python | python | MBPP/420/L1 | [] | [] | MBPP_Infilling | for i in range(1, n + 1):
sum += 2 * i * (2 * i) * (2 * i)
return sum | [
[
"2",
"72"
],
[
"3",
"288"
],
[
"4",
"800"
]
] | cube_Sum | [] | Write a python function to find the cube sum of first n even natural numbers. | def cube_Sum(n):
"""Write a python function to find the cube sum of first n even natural numbers. """
|
sum = 0
|
code_infilling | python | python | MBPP/420/L2 | [] | [] | MBPP_Infilling | sum += 2 * i * (2 * i) * (2 * i)
return sum | [
[
"2",
"72"
],
[
"3",
"288"
],
[
"4",
"800"
]
] | cube_Sum | [] | Write a python function to find the cube sum of first n even natural numbers. | def cube_Sum(n):
"""Write a python function to find the cube sum of first n even natural numbers. """
sum = 0 |
for i in range(1, n + 1):
|
code_infilling | python | python | MBPP/420/L3 | [] | [] | MBPP_Infilling | return sum | [
[
"2",
"72"
],
[
"3",
"288"
],
[
"4",
"800"
]
] | cube_Sum | [] | Write a python function to find the cube sum of first n even natural numbers. | def cube_Sum(n):
"""Write a python function to find the cube sum of first n even natural numbers. """
sum = 0
for i in range(1, n + 1): |
sum += 2 * i * (2 * i) * (2 * i)
|
code_infilling | python | python | MBPP/420/L4 | [] | [] | MBPP_Infilling | [
[
"2",
"72"
],
[
"3",
"288"
],
[
"4",
"800"
]
] | cube_Sum | [] | Write a python function to find the cube sum of first n even natural numbers. | def cube_Sum(n):
"""Write a python function to find the cube sum of first n even natural numbers. """
sum = 0
for i in range(1, n + 1):
sum += 2 * i * (2 * i) * (2 * i) |
return sum
| |
code_infilling | python | python | MBPP/421/L1 | [] | [] | MBPP_Infilling | res = ''.join([str(ele) + delim for ele in test_tup])
res = res[:len(res) - len(delim)]
return str(res) | [
[
"(\"ID\", \"is\", 4, \"UTS\") ",
"'ID-is-4-UTS'"
],
[
"(\"QWE\", \"is\", 4, \"RTY\") ",
"'QWE-is-4-RTY'"
],
[
"(\"ZEN\", \"is\", 4, \"OP\") ",
"'ZEN-is-4-OP'"
]
] | concatenate_tuple | [] | Write a function to concatenate each element of tuple by the delimiter. | def concatenate_tuple(test_tup):
"""Write a function to concatenate each element of tuple by the delimiter. """
|
delim = '-'
|
code_infilling | python | python | MBPP/421/L2 | [] | [] | MBPP_Infilling | res = res[:len(res) - len(delim)]
return str(res) | [
[
"(\"ID\", \"is\", 4, \"UTS\") ",
"'ID-is-4-UTS'"
],
[
"(\"QWE\", \"is\", 4, \"RTY\") ",
"'QWE-is-4-RTY'"
],
[
"(\"ZEN\", \"is\", 4, \"OP\") ",
"'ZEN-is-4-OP'"
]
] | concatenate_tuple | [] | Write a function to concatenate each element of tuple by the delimiter. | def concatenate_tuple(test_tup):
"""Write a function to concatenate each element of tuple by the delimiter. """
delim = '-' |
res = ''.join([str(ele) + delim for ele in test_tup])
|
code_infilling | python | python | MBPP/421/L3 | [] | [] | MBPP_Infilling | return str(res) | [
[
"(\"ID\", \"is\", 4, \"UTS\") ",
"'ID-is-4-UTS'"
],
[
"(\"QWE\", \"is\", 4, \"RTY\") ",
"'QWE-is-4-RTY'"
],
[
"(\"ZEN\", \"is\", 4, \"OP\") ",
"'ZEN-is-4-OP'"
]
] | concatenate_tuple | [] | Write a function to concatenate each element of tuple by the delimiter. | def concatenate_tuple(test_tup):
"""Write a function to concatenate each element of tuple by the delimiter. """
delim = '-'
res = ''.join([str(ele) + delim for ele in test_tup]) |
res = res[:len(res) - len(delim)]
|
code_infilling | python | python | MBPP/421/L4 | [] | [] | MBPP_Infilling | [
[
"(\"ID\", \"is\", 4, \"UTS\") ",
"'ID-is-4-UTS'"
],
[
"(\"QWE\", \"is\", 4, \"RTY\") ",
"'QWE-is-4-RTY'"
],
[
"(\"ZEN\", \"is\", 4, \"OP\") ",
"'ZEN-is-4-OP'"
]
] | concatenate_tuple | [] | Write a function to concatenate each element of tuple by the delimiter. | def concatenate_tuple(test_tup):
"""Write a function to concatenate each element of tuple by the delimiter. """
delim = '-'
res = ''.join([str(ele) + delim for ele in test_tup])
res = res[:len(res) - len(delim)] |
return str(res)
| |
code_infilling | python | python | MBPP/422/L1 | [] | [] | MBPP_Infilling | for i in range(1, n + 1):
sum += i * i * i
return round(sum / n, 6) | [
[
"2",
"4.5"
],
[
"3",
"12"
],
[
"1",
"1"
]
] | find_Average_Of_Cube | [] | Write a python function to find the average of cubes of first n natural numbers. | def find_Average_Of_Cube(n):
"""Write a python function to find the average of cubes of first n natural numbers. """
|
sum = 0
|
code_infilling | python | python | MBPP/422/L2 | [] | [] | MBPP_Infilling | sum += i * i * i
return round(sum / n, 6) | [
[
"2",
"4.5"
],
[
"3",
"12"
],
[
"1",
"1"
]
] | find_Average_Of_Cube | [] | Write a python function to find the average of cubes of first n natural numbers. | def find_Average_Of_Cube(n):
"""Write a python function to find the average of cubes of first n natural numbers. """
sum = 0 |
for i in range(1, n + 1):
|
code_infilling | python | python | MBPP/422/L3 | [] | [] | MBPP_Infilling | return round(sum / n, 6) | [
[
"2",
"4.5"
],
[
"3",
"12"
],
[
"1",
"1"
]
] | find_Average_Of_Cube | [] | Write a python function to find the average of cubes of first n natural numbers. | def find_Average_Of_Cube(n):
"""Write a python function to find the average of cubes of first n natural numbers. """
sum = 0
for i in range(1, n + 1): |
sum += i * i * i
|
code_infilling | python | python | MBPP/422/L4 | [] | [] | MBPP_Infilling | [
[
"2",
"4.5"
],
[
"3",
"12"
],
[
"1",
"1"
]
] | find_Average_Of_Cube | [] | Write a python function to find the average of cubes of first n natural numbers. | def find_Average_Of_Cube(n):
"""Write a python function to find the average of cubes of first n natural numbers. """
sum = 0
for i in range(1, n + 1):
sum += i * i * i |
return round(sum / n, 6)
| |
code_infilling | python | python | MBPP/424/L1 | [] | [] | MBPP_Infilling | return res | [
[
"('Mers', 'for', 'Vers') ",
"['s', 'r', 's']"
],
[
"('Avenge', 'for', 'People') ",
"['e', 'r', 'e']"
],
[
"('Gotta', 'get', 'go') ",
"['a', 't', 'o']"
]
] | extract_rear | [] | Write a function to extract only the rear index element of each string in the given tuple. | def extract_rear(test_tuple):
"""Write a function to extract only the rear index element of each string in the given tuple. """
|
res = list((sub[len(sub) - 1] for sub in test_tuple))
|
code_infilling | python | python | MBPP/424/L2 | [] | [] | MBPP_Infilling | [
[
"('Mers', 'for', 'Vers') ",
"['s', 'r', 's']"
],
[
"('Avenge', 'for', 'People') ",
"['e', 'r', 'e']"
],
[
"('Gotta', 'get', 'go') ",
"['a', 't', 'o']"
]
] | extract_rear | [] | Write a function to extract only the rear index element of each string in the given tuple. | def extract_rear(test_tuple):
"""Write a function to extract only the rear index element of each string in the given tuple. """
res = list((sub[len(sub) - 1] for sub in test_tuple)) |
return res
| |
code_infilling | python | python | MBPP/425/L1 | [] | [] | MBPP_Infilling | for i in range(len(list1)):
if x in list1[i]:
ctr += 1
return ctr | [
[
"[[1, 3], [5, 7], [1, 11], [1, 15, 7]],1",
"3"
],
[
"[['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'A'",
"3"
],
[
"[['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'E'",
"1"
]
] | count_element_in_list | [] | Write a function to count the number of sublists containing a particular element. | def count_element_in_list(list1, x):
"""Write a function to count the number of sublists containing a particular element. """
|
ctr = 0
|
code_infilling | python | python | MBPP/425/L2 | [] | [] | MBPP_Infilling | if x in list1[i]:
ctr += 1
return ctr | [
[
"[[1, 3], [5, 7], [1, 11], [1, 15, 7]],1",
"3"
],
[
"[['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'A'",
"3"
],
[
"[['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'E'",
"1"
]
] | count_element_in_list | [] | Write a function to count the number of sublists containing a particular element. | def count_element_in_list(list1, x):
"""Write a function to count the number of sublists containing a particular element. """
ctr = 0 |
for i in range(len(list1)):
|
code_infilling | python | python | MBPP/425/L3 | [] | [] | MBPP_Infilling | ctr += 1
return ctr | [
[
"[[1, 3], [5, 7], [1, 11], [1, 15, 7]],1",
"3"
],
[
"[['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'A'",
"3"
],
[
"[['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'E'",
"1"
]
] | count_element_in_list | [] | Write a function to count the number of sublists containing a particular element. | def count_element_in_list(list1, x):
"""Write a function to count the number of sublists containing a particular element. """
ctr = 0
for i in range(len(list1)): |
if x in list1[i]:
|
code_infilling | python | python | MBPP/425/L4 | [] | [] | MBPP_Infilling | return ctr | [
[
"[[1, 3], [5, 7], [1, 11], [1, 15, 7]],1",
"3"
],
[
"[['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'A'",
"3"
],
[
"[['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'E'",
"1"
]
] | count_element_in_list | [] | Write a function to count the number of sublists containing a particular element. | def count_element_in_list(list1, x):
"""Write a function to count the number of sublists containing a particular element. """
ctr = 0
for i in range(len(list1)):
if x in list1[i]: |
ctr += 1
|
code_infilling | python | python | MBPP/425/L5 | [] | [] | MBPP_Infilling | [
[
"[[1, 3], [5, 7], [1, 11], [1, 15, 7]],1",
"3"
],
[
"[['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'A'",
"3"
],
[
"[['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'E'",
"1"
]
] | count_element_in_list | [] | Write a function to count the number of sublists containing a particular element. | def count_element_in_list(list1, x):
"""Write a function to count the number of sublists containing a particular element. """
ctr = 0
for i in range(len(list1)):
if x in list1[i]:
ctr += 1 |
return ctr
| |
code_infilling | python | python | MBPP/426/L1 | [] | [] | MBPP_Infilling | return odd_nums | [
[
"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]",
"[1,3,5,7,9]"
],
[
"[10,20,45,67,84,93]",
"[45,67,93]"
],
[
"[5,7,9,8,6,4,3]",
"[5,7,9,3]"
]
] | filter_oddnumbers | [] | Write a function to filter odd numbers. | def filter_oddnumbers(nums):
"""Write a function to filter odd numbers. """
|
odd_nums = list(filter(lambda x: x % 2 != 0, nums))
|
code_infilling | python | python | MBPP/426/L2 | [] | [] | MBPP_Infilling | [
[
"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]",
"[1,3,5,7,9]"
],
[
"[10,20,45,67,84,93]",
"[45,67,93]"
],
[
"[5,7,9,8,6,4,3]",
"[5,7,9,3]"
]
] | filter_oddnumbers | [] | Write a function to filter odd numbers. | def filter_oddnumbers(nums):
"""Write a function to filter odd numbers. """
odd_nums = list(filter(lambda x: x % 2 != 0, nums)) |
return odd_nums
| |
code_infilling | python | python | MBPP/427/L3 | [] | [] | MBPP_Infilling | [
[
"\"2026-01-02\"",
"'02-01-2026'"
],
[
"\"2020-11-13\"",
"'13-11-2020'"
],
[
"\"2021-04-26\"",
"'26-04-2021'"
]
] | change_date_format | [
"import re"
] | Write a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format. | import re
def change_date_format(dt):
"""Write a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format. """
|
return re.sub('(\\d{4})-(\\d{1,2})-(\\d{1,2})', '\\3-\\2-\\1', dt)
| |
code_infilling | python | python | MBPP/428/L1 | [] | [] | MBPP_Infilling | while gap > 0:
for i in range(gap, len(my_list)):
current_item = my_list[i]
j = i
while j >= gap and my_list[j - gap] > current_item:
my_list[j] = my_list[j - gap]
j -= gap
my_list[j] = current_item
gap //= 2
return ... | [
[
"[12, 23, 4, 5, 3, 2, 12, 81, 56, 95]",
"[2, 3, 4, 5, 12, 12, 23, 56, 81, 95]"
],
[
"[24, 22, 39, 34, 87, 73, 68]",
"[22, 24, 34, 39, 68, 73, 87]"
],
[
"[32, 30, 16, 96, 82, 83, 74]",
"[16, 30, 32, 74, 82, 83, 96]"
]
] | shell_sort | [] | Write a function to sort the given array by using shell sort. | def shell_sort(my_list):
"""Write a function to sort the given array by using shell sort. """
|
gap = len(my_list) // 2
|
code_infilling | python | python | MBPP/428/L2 | [] | [] | MBPP_Infilling | for i in range(gap, len(my_list)):
current_item = my_list[i]
j = i
while j >= gap and my_list[j - gap] > current_item:
my_list[j] = my_list[j - gap]
j -= gap
my_list[j] = current_item
gap //= 2
return my_list | [
[
"[12, 23, 4, 5, 3, 2, 12, 81, 56, 95]",
"[2, 3, 4, 5, 12, 12, 23, 56, 81, 95]"
],
[
"[24, 22, 39, 34, 87, 73, 68]",
"[22, 24, 34, 39, 68, 73, 87]"
],
[
"[32, 30, 16, 96, 82, 83, 74]",
"[16, 30, 32, 74, 82, 83, 96]"
]
] | shell_sort | [] | Write a function to sort the given array by using shell sort. | def shell_sort(my_list):
"""Write a function to sort the given array by using shell sort. """
gap = len(my_list) // 2 |
while gap > 0:
|
code_infilling | python | python | MBPP/428/L3 | [] | [] | MBPP_Infilling | current_item = my_list[i]
j = i
while j >= gap and my_list[j - gap] > current_item:
my_list[j] = my_list[j - gap]
j -= gap
my_list[j] = current_item
gap //= 2
return my_list | [
[
"[12, 23, 4, 5, 3, 2, 12, 81, 56, 95]",
"[2, 3, 4, 5, 12, 12, 23, 56, 81, 95]"
],
[
"[24, 22, 39, 34, 87, 73, 68]",
"[22, 24, 34, 39, 68, 73, 87]"
],
[
"[32, 30, 16, 96, 82, 83, 74]",
"[16, 30, 32, 74, 82, 83, 96]"
]
] | shell_sort | [] | Write a function to sort the given array by using shell sort. | def shell_sort(my_list):
"""Write a function to sort the given array by using shell sort. """
gap = len(my_list) // 2
while gap > 0: |
for i in range(gap, len(my_list)):
|
code_infilling | python | python | MBPP/428/L4 | [] | [] | MBPP_Infilling | j = i
while j >= gap and my_list[j - gap] > current_item:
my_list[j] = my_list[j - gap]
j -= gap
my_list[j] = current_item
gap //= 2
return my_list | [
[
"[12, 23, 4, 5, 3, 2, 12, 81, 56, 95]",
"[2, 3, 4, 5, 12, 12, 23, 56, 81, 95]"
],
[
"[24, 22, 39, 34, 87, 73, 68]",
"[22, 24, 34, 39, 68, 73, 87]"
],
[
"[32, 30, 16, 96, 82, 83, 74]",
"[16, 30, 32, 74, 82, 83, 96]"
]
] | shell_sort | [] | Write a function to sort the given array by using shell sort. | def shell_sort(my_list):
"""Write a function to sort the given array by using shell sort. """
gap = len(my_list) // 2
while gap > 0:
for i in range(gap, len(my_list)): |
current_item = my_list[i]
|
code_infilling | python | python | MBPP/428/L5 | [] | [] | MBPP_Infilling | while j >= gap and my_list[j - gap] > current_item:
my_list[j] = my_list[j - gap]
j -= gap
my_list[j] = current_item
gap //= 2
return my_list | [
[
"[12, 23, 4, 5, 3, 2, 12, 81, 56, 95]",
"[2, 3, 4, 5, 12, 12, 23, 56, 81, 95]"
],
[
"[24, 22, 39, 34, 87, 73, 68]",
"[22, 24, 34, 39, 68, 73, 87]"
],
[
"[32, 30, 16, 96, 82, 83, 74]",
"[16, 30, 32, 74, 82, 83, 96]"
]
] | shell_sort | [] | Write a function to sort the given array by using shell sort. | def shell_sort(my_list):
"""Write a function to sort the given array by using shell sort. """
gap = len(my_list) // 2
while gap > 0:
for i in range(gap, len(my_list)):
current_item = my_list[i] |
j = i
|
code_infilling | python | python | MBPP/428/L6 | [] | [] | MBPP_Infilling | my_list[j] = my_list[j - gap]
j -= gap
my_list[j] = current_item
gap //= 2
return my_list | [
[
"[12, 23, 4, 5, 3, 2, 12, 81, 56, 95]",
"[2, 3, 4, 5, 12, 12, 23, 56, 81, 95]"
],
[
"[24, 22, 39, 34, 87, 73, 68]",
"[22, 24, 34, 39, 68, 73, 87]"
],
[
"[32, 30, 16, 96, 82, 83, 74]",
"[16, 30, 32, 74, 82, 83, 96]"
]
] | shell_sort | [] | Write a function to sort the given array by using shell sort. | def shell_sort(my_list):
"""Write a function to sort the given array by using shell sort. """
gap = len(my_list) // 2
while gap > 0:
for i in range(gap, len(my_list)):
current_item = my_list[i]
j = i |
while j >= gap and my_list[j - gap] > current_item:
|
code_infilling | python | python | MBPP/428/L7 | [] | [] | MBPP_Infilling | j -= gap
my_list[j] = current_item
gap //= 2
return my_list | [
[
"[12, 23, 4, 5, 3, 2, 12, 81, 56, 95]",
"[2, 3, 4, 5, 12, 12, 23, 56, 81, 95]"
],
[
"[24, 22, 39, 34, 87, 73, 68]",
"[22, 24, 34, 39, 68, 73, 87]"
],
[
"[32, 30, 16, 96, 82, 83, 74]",
"[16, 30, 32, 74, 82, 83, 96]"
]
] | shell_sort | [] | Write a function to sort the given array by using shell sort. | def shell_sort(my_list):
"""Write a function to sort the given array by using shell sort. """
gap = len(my_list) // 2
while gap > 0:
for i in range(gap, len(my_list)):
current_item = my_list[i]
j = i
while j >= gap and my_list[j - gap] > current_item: |
my_list[j] = my_list[j - gap]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.