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/307/L3
|
[] |
[] |
MBPP_Infilling
|
tuplex_colon[m].append(n)
return tuplex_colon
|
[
[
"(\"HELLO\", 5, [], True) ,2,50",
"(\"HELLO\", 5, [50], True)"
],
[
"(\"HELLO\", 5, [], True) ,2,100",
"((\"HELLO\", 5, [100],True))"
],
[
"(\"HELLO\", 5, [], True) ,2,500",
"(\"HELLO\", 5, [500], True)"
]
] |
colon_tuplex
|
[
"from copy import deepcopy"
] |
Write a function to get a colon of a tuple.
|
from copy import deepcopy
def colon_tuplex(tuplex, m, n):
"""Write a function to get a colon of a tuple. """
|
tuplex_colon = deepcopy(tuplex)
|
code_infilling
|
python
|
python
|
MBPP/307/L4
|
[] |
[] |
MBPP_Infilling
|
return tuplex_colon
|
[
[
"(\"HELLO\", 5, [], True) ,2,50",
"(\"HELLO\", 5, [50], True)"
],
[
"(\"HELLO\", 5, [], True) ,2,100",
"((\"HELLO\", 5, [100],True))"
],
[
"(\"HELLO\", 5, [], True) ,2,500",
"(\"HELLO\", 5, [500], True)"
]
] |
colon_tuplex
|
[
"from copy import deepcopy"
] |
Write a function to get a colon of a tuple.
|
from copy import deepcopy
def colon_tuplex(tuplex, m, n):
"""Write a function to get a colon of a tuple. """
tuplex_colon = deepcopy(tuplex)
|
tuplex_colon[m].append(n)
|
code_infilling
|
python
|
python
|
MBPP/307/L5
|
[] |
[] |
MBPP_Infilling
|
[
[
"(\"HELLO\", 5, [], True) ,2,50",
"(\"HELLO\", 5, [50], True)"
],
[
"(\"HELLO\", 5, [], True) ,2,100",
"((\"HELLO\", 5, [100],True))"
],
[
"(\"HELLO\", 5, [], True) ,2,500",
"(\"HELLO\", 5, [500], True)"
]
] |
colon_tuplex
|
[
"from copy import deepcopy"
] |
Write a function to get a colon of a tuple.
|
from copy import deepcopy
def colon_tuplex(tuplex, m, n):
"""Write a function to get a colon of a tuple. """
tuplex_colon = deepcopy(tuplex)
tuplex_colon[m].append(n)
|
return tuplex_colon
|
|
code_infilling
|
python
|
python
|
MBPP/308/L1
|
[] |
[] |
MBPP_Infilling
|
return result
|
[
[
"[1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],3",
"[60, 54, 50]"
],
[
"[1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],4",
"[60, 54, 50, 48]"
],
[
"[1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],5",
"[60, 54, 50, 48, 45]"
]
] |
large_product
|
[] |
Write a function to find the specified number of largest products from two given lists, selecting one factor from each list.
|
def large_product(nums1, nums2, N):
"""Write a function to find the specified number of largest products from two given lists, selecting one factor from each list. """
|
result = sorted([x * y for x in nums1 for y in nums2], reverse=True)[:N]
|
code_infilling
|
python
|
python
|
MBPP/308/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"[1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],3",
"[60, 54, 50]"
],
[
"[1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],4",
"[60, 54, 50, 48]"
],
[
"[1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],5",
"[60, 54, 50, 48, 45]"
]
] |
large_product
|
[] |
Write a function to find the specified number of largest products from two given lists, selecting one factor from each list.
|
def large_product(nums1, nums2, N):
"""Write a function to find the specified number of largest products from two given lists, selecting one factor from each list. """
result = sorted([x * y for x in nums1 for y in nums2], reverse=True)[:N]
|
return result
|
|
code_infilling
|
python
|
python
|
MBPP/309/L1
|
[] |
[] |
MBPP_Infilling
|
return a
else:
return b
|
[
[
"5,10",
"10"
],
[
"-1,-2",
"-1"
],
[
"9,7",
"9"
]
] |
maximum
|
[] |
Write a python function to find the maximum of two numbers.
|
def maximum(a, b):
"""Write a python function to find the maximum of two numbers. """
|
if a >= b:
|
code_infilling
|
python
|
python
|
MBPP/309/L2
|
[] |
[] |
MBPP_Infilling
|
else:
return b
|
[
[
"5,10",
"10"
],
[
"-1,-2",
"-1"
],
[
"9,7",
"9"
]
] |
maximum
|
[] |
Write a python function to find the maximum of two numbers.
|
def maximum(a, b):
"""Write a python function to find the maximum of two numbers. """
if a >= b:
|
return a
|
code_infilling
|
python
|
python
|
MBPP/309/L3
|
[] |
[] |
MBPP_Infilling
|
return b
|
[
[
"5,10",
"10"
],
[
"-1,-2",
"-1"
],
[
"9,7",
"9"
]
] |
maximum
|
[] |
Write a python function to find the maximum of two numbers.
|
def maximum(a, b):
"""Write a python function to find the maximum of two numbers. """
if a >= b:
return a
|
else:
|
code_infilling
|
python
|
python
|
MBPP/309/L4
|
[] |
[] |
MBPP_Infilling
|
[
[
"5,10",
"10"
],
[
"-1,-2",
"-1"
],
[
"9,7",
"9"
]
] |
maximum
|
[] |
Write a python function to find the maximum of two numbers.
|
def maximum(a, b):
"""Write a python function to find the maximum of two numbers. """
if a >= b:
return a
else:
|
return b
|
|
code_infilling
|
python
|
python
|
MBPP/310/L1
|
[] |
[] |
MBPP_Infilling
|
return result
|
[
[
"\"python 3.0\"",
"('p', 'y', 't', 'h', 'o', 'n', '3', '.', '0')"
],
[
"\"item1\"",
"('i', 't', 'e', 'm', '1')"
],
[
"\"15.10\"",
"('1', '5', '.', '1', '0')"
]
] |
string_to_tuple
|
[] |
Write a function to convert a given string to a tuple of characters.
|
def string_to_tuple(str1):
"""Write a function to convert a given string to a tuple of characters. """
|
result = tuple((x for x in str1 if not x.isspace()))
|
code_infilling
|
python
|
python
|
MBPP/310/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"\"python 3.0\"",
"('p', 'y', 't', 'h', 'o', 'n', '3', '.', '0')"
],
[
"\"item1\"",
"('i', 't', 'e', 'm', '1')"
],
[
"\"15.10\"",
"('1', '5', '.', '1', '0')"
]
] |
string_to_tuple
|
[] |
Write a function to convert a given string to a tuple of characters.
|
def string_to_tuple(str1):
"""Write a function to convert a given string to a tuple of characters. """
result = tuple((x for x in str1 if not x.isspace()))
|
return result
|
|
code_infilling
|
python
|
python
|
MBPP/311/L1
|
[] |
[] |
MBPP_Infilling
|
return n
(pos, temp, count) = (0, n, 0)
while temp:
if not temp & 1:
pos = count
count += 1
temp >>= 1
return n | 1 << pos
|
[
[
"10",
"14"
],
[
"12",
"14"
],
[
"15",
"15"
]
] |
set_left_most_unset_bit
|
[] |
Write a python function to set the left most unset bit.
|
def set_left_most_unset_bit(n):
"""Write a python function to set the left most unset bit. """
|
if not n & n + 1:
|
code_infilling
|
python
|
python
|
MBPP/311/L2
|
[] |
[] |
MBPP_Infilling
|
(pos, temp, count) = (0, n, 0)
while temp:
if not temp & 1:
pos = count
count += 1
temp >>= 1
return n | 1 << pos
|
[
[
"10",
"14"
],
[
"12",
"14"
],
[
"15",
"15"
]
] |
set_left_most_unset_bit
|
[] |
Write a python function to set the left most unset bit.
|
def set_left_most_unset_bit(n):
"""Write a python function to set the left most unset bit. """
if not n & n + 1:
|
return n
|
code_infilling
|
python
|
python
|
MBPP/311/L3
|
[] |
[] |
MBPP_Infilling
|
while temp:
if not temp & 1:
pos = count
count += 1
temp >>= 1
return n | 1 << pos
|
[
[
"10",
"14"
],
[
"12",
"14"
],
[
"15",
"15"
]
] |
set_left_most_unset_bit
|
[] |
Write a python function to set the left most unset bit.
|
def set_left_most_unset_bit(n):
"""Write a python function to set the left most unset bit. """
if not n & n + 1:
return n
|
(pos, temp, count) = (0, n, 0)
|
code_infilling
|
python
|
python
|
MBPP/311/L4
|
[] |
[] |
MBPP_Infilling
|
if not temp & 1:
pos = count
count += 1
temp >>= 1
return n | 1 << pos
|
[
[
"10",
"14"
],
[
"12",
"14"
],
[
"15",
"15"
]
] |
set_left_most_unset_bit
|
[] |
Write a python function to set the left most unset bit.
|
def set_left_most_unset_bit(n):
"""Write a python function to set the left most unset bit. """
if not n & n + 1:
return n
(pos, temp, count) = (0, n, 0)
|
while temp:
|
code_infilling
|
python
|
python
|
MBPP/311/L5
|
[] |
[] |
MBPP_Infilling
|
pos = count
count += 1
temp >>= 1
return n | 1 << pos
|
[
[
"10",
"14"
],
[
"12",
"14"
],
[
"15",
"15"
]
] |
set_left_most_unset_bit
|
[] |
Write a python function to set the left most unset bit.
|
def set_left_most_unset_bit(n):
"""Write a python function to set the left most unset bit. """
if not n & n + 1:
return n
(pos, temp, count) = (0, n, 0)
while temp:
|
if not temp & 1:
|
code_infilling
|
python
|
python
|
MBPP/311/L6
|
[] |
[] |
MBPP_Infilling
|
count += 1
temp >>= 1
return n | 1 << pos
|
[
[
"10",
"14"
],
[
"12",
"14"
],
[
"15",
"15"
]
] |
set_left_most_unset_bit
|
[] |
Write a python function to set the left most unset bit.
|
def set_left_most_unset_bit(n):
"""Write a python function to set the left most unset bit. """
if not n & n + 1:
return n
(pos, temp, count) = (0, n, 0)
while temp:
if not temp & 1:
|
pos = count
|
code_infilling
|
python
|
python
|
MBPP/311/L7
|
[] |
[] |
MBPP_Infilling
|
temp >>= 1
return n | 1 << pos
|
[
[
"10",
"14"
],
[
"12",
"14"
],
[
"15",
"15"
]
] |
set_left_most_unset_bit
|
[] |
Write a python function to set the left most unset bit.
|
def set_left_most_unset_bit(n):
"""Write a python function to set the left most unset bit. """
if not n & n + 1:
return n
(pos, temp, count) = (0, n, 0)
while temp:
if not temp & 1:
pos = count
|
count += 1
|
code_infilling
|
python
|
python
|
MBPP/311/L8
|
[] |
[] |
MBPP_Infilling
|
return n | 1 << pos
|
[
[
"10",
"14"
],
[
"12",
"14"
],
[
"15",
"15"
]
] |
set_left_most_unset_bit
|
[] |
Write a python function to set the left most unset bit.
|
def set_left_most_unset_bit(n):
"""Write a python function to set the left most unset bit. """
if not n & n + 1:
return n
(pos, temp, count) = (0, n, 0)
while temp:
if not temp & 1:
pos = count
count += 1
|
temp >>= 1
|
code_infilling
|
python
|
python
|
MBPP/311/L9
|
[] |
[] |
MBPP_Infilling
|
[
[
"10",
"14"
],
[
"12",
"14"
],
[
"15",
"15"
]
] |
set_left_most_unset_bit
|
[] |
Write a python function to set the left most unset bit.
|
def set_left_most_unset_bit(n):
"""Write a python function to set the left most unset bit. """
if not n & n + 1:
return n
(pos, temp, count) = (0, n, 0)
while temp:
if not temp & 1:
pos = count
count += 1
temp >>= 1
|
return n | 1 << pos
|
|
code_infilling
|
python
|
python
|
MBPP/312/L3
|
[] |
[] |
MBPP_Infilling
|
return volume
|
[] |
volume_cone
|
[
"import math"
] |
Write a function to find the volume of a cone.
|
import math
def volume_cone(r, h):
"""Write a function to find the volume of a cone. """
|
volume = 1.0 / 3 * math.pi * r * r * h
|
code_infilling
|
python
|
python
|
MBPP/312/L4
|
[] |
[] |
MBPP_Infilling
|
[] |
volume_cone
|
[
"import math"
] |
Write a function to find the volume of a cone.
|
import math
def volume_cone(r, h):
"""Write a function to find the volume of a cone. """
volume = 1.0 / 3 * math.pi * r * r * h
|
return volume
|
|
code_infilling
|
python
|
python
|
MBPP/388/L1
|
[] |
[] |
MBPP_Infilling
|
for i in range(n, 0, -1):
if i & i - 1 == 0:
res = i
break
return res
|
[
[
"10",
"8"
],
[
"19",
"16"
],
[
"32",
"32"
]
] |
highest_Power_of_2
|
[] |
Write a python function to find the highest power of 2 that is less than or equal to n.
|
def highest_Power_of_2(n):
"""Write a python function to find the highest power of 2 that is less than or equal to n. """
|
res = 0
|
code_infilling
|
python
|
python
|
MBPP/388/L2
|
[] |
[] |
MBPP_Infilling
|
if i & i - 1 == 0:
res = i
break
return res
|
[
[
"10",
"8"
],
[
"19",
"16"
],
[
"32",
"32"
]
] |
highest_Power_of_2
|
[] |
Write a python function to find the highest power of 2 that is less than or equal to n.
|
def highest_Power_of_2(n):
"""Write a python function to find the highest power of 2 that is less than or equal to n. """
res = 0
|
for i in range(n, 0, -1):
|
code_infilling
|
python
|
python
|
MBPP/388/L3
|
[] |
[] |
MBPP_Infilling
|
res = i
break
return res
|
[
[
"10",
"8"
],
[
"19",
"16"
],
[
"32",
"32"
]
] |
highest_Power_of_2
|
[] |
Write a python function to find the highest power of 2 that is less than or equal to n.
|
def highest_Power_of_2(n):
"""Write a python function to find the highest power of 2 that is less than or equal to n. """
res = 0
for i in range(n, 0, -1):
|
if i & i - 1 == 0:
|
code_infilling
|
python
|
python
|
MBPP/388/L4
|
[] |
[] |
MBPP_Infilling
|
break
return res
|
[
[
"10",
"8"
],
[
"19",
"16"
],
[
"32",
"32"
]
] |
highest_Power_of_2
|
[] |
Write a python function to find the highest power of 2 that is less than or equal to n.
|
def highest_Power_of_2(n):
"""Write a python function to find the highest power of 2 that is less than or equal to n. """
res = 0
for i in range(n, 0, -1):
if i & i - 1 == 0:
|
res = i
|
code_infilling
|
python
|
python
|
MBPP/388/L5
|
[] |
[] |
MBPP_Infilling
|
return res
|
[
[
"10",
"8"
],
[
"19",
"16"
],
[
"32",
"32"
]
] |
highest_Power_of_2
|
[] |
Write a python function to find the highest power of 2 that is less than or equal to n.
|
def highest_Power_of_2(n):
"""Write a python function to find the highest power of 2 that is less than or equal to n. """
res = 0
for i in range(n, 0, -1):
if i & i - 1 == 0:
res = i
|
break
|
code_infilling
|
python
|
python
|
MBPP/388/L6
|
[] |
[] |
MBPP_Infilling
|
[
[
"10",
"8"
],
[
"19",
"16"
],
[
"32",
"32"
]
] |
highest_Power_of_2
|
[] |
Write a python function to find the highest power of 2 that is less than or equal to n.
|
def highest_Power_of_2(n):
"""Write a python function to find the highest power of 2 that is less than or equal to n. """
res = 0
for i in range(n, 0, -1):
if i & i - 1 == 0:
res = i
break
|
return res
|
|
code_infilling
|
python
|
python
|
MBPP/389/L1
|
[] |
[] |
MBPP_Infilling
|
return 2
if n == 1:
return 1
return find_lucas(n - 1) + find_lucas(n - 2)
|
[
[
"9",
"76"
],
[
"4",
"7"
],
[
"3",
"4"
]
] |
find_lucas
|
[] |
Write a function to find the n'th lucas number.
|
def find_lucas(n):
"""Write a function to find the n'th lucas number. """
|
if n == 0:
|
code_infilling
|
python
|
python
|
MBPP/389/L2
|
[] |
[] |
MBPP_Infilling
|
if n == 1:
return 1
return find_lucas(n - 1) + find_lucas(n - 2)
|
[
[
"9",
"76"
],
[
"4",
"7"
],
[
"3",
"4"
]
] |
find_lucas
|
[] |
Write a function to find the n'th lucas number.
|
def find_lucas(n):
"""Write a function to find the n'th lucas number. """
if n == 0:
|
return 2
|
code_infilling
|
python
|
python
|
MBPP/389/L3
|
[] |
[] |
MBPP_Infilling
|
return 1
return find_lucas(n - 1) + find_lucas(n - 2)
|
[
[
"9",
"76"
],
[
"4",
"7"
],
[
"3",
"4"
]
] |
find_lucas
|
[] |
Write a function to find the n'th lucas number.
|
def find_lucas(n):
"""Write a function to find the n'th lucas number. """
if n == 0:
return 2
|
if n == 1:
|
code_infilling
|
python
|
python
|
MBPP/389/L4
|
[] |
[] |
MBPP_Infilling
|
return find_lucas(n - 1) + find_lucas(n - 2)
|
[
[
"9",
"76"
],
[
"4",
"7"
],
[
"3",
"4"
]
] |
find_lucas
|
[] |
Write a function to find the n'th lucas number.
|
def find_lucas(n):
"""Write a function to find the n'th lucas number. """
if n == 0:
return 2
if n == 1:
|
return 1
|
code_infilling
|
python
|
python
|
MBPP/389/L5
|
[] |
[] |
MBPP_Infilling
|
[
[
"9",
"76"
],
[
"4",
"7"
],
[
"3",
"4"
]
] |
find_lucas
|
[] |
Write a function to find the n'th lucas number.
|
def find_lucas(n):
"""Write a function to find the n'th lucas number. """
if n == 0:
return 2
if n == 1:
return 1
|
return find_lucas(n - 1) + find_lucas(n - 2)
|
|
code_infilling
|
python
|
python
|
MBPP/390/L1
|
[] |
[] |
MBPP_Infilling
|
return add_string
|
[
[
"[1,2,3,4],'temp{0}'",
"['temp1', 'temp2', 'temp3', 'temp4']"
],
[
"['a','b','c','d'], 'python{0}'",
"[ 'pythona', 'pythonb', 'pythonc', 'pythond']"
],
[
"[5,6,7,8],'string{0}'",
"['string5', 'string6', 'string7', 'string8']"
]
] |
add_string
|
[] |
Write a function to apply a given format string to all of the elements in a list.
|
def add_string(list_, string):
"""Write a function to apply a given format string to all of the elements in a list. """
|
add_string = [string.format(i) for i in list_]
|
code_infilling
|
python
|
python
|
MBPP/390/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"[1,2,3,4],'temp{0}'",
"['temp1', 'temp2', 'temp3', 'temp4']"
],
[
"['a','b','c','d'], 'python{0}'",
"[ 'pythona', 'pythonb', 'pythonc', 'pythond']"
],
[
"[5,6,7,8],'string{0}'",
"['string5', 'string6', 'string7', 'string8']"
]
] |
add_string
|
[] |
Write a function to apply a given format string to all of the elements in a list.
|
def add_string(list_, string):
"""Write a function to apply a given format string to all of the elements in a list. """
add_string = [string.format(i) for i in list_]
|
return add_string
|
|
code_infilling
|
python
|
python
|
MBPP/391/L1
|
[] |
[] |
MBPP_Infilling
|
return result
|
[
[
"[\"S001\", \"S002\", \"S003\", \"S004\"],[\"Adina Park\", \"Leyton Marsh\", \"Duncan Boyle\", \"Saim Richards\"] ,[85, 98, 89, 92]",
"[{'S001': {'Adina Park': 85}}, {'S002': {'Leyton Marsh': 98}}, {'S003': {'Duncan Boyle': 89}}, {'S004': {'Saim Richards': 92}}]"
],
[
"[\"abc\",\"def\",\"ghi\",\"jkl\"],[\"python\",\"program\",\"language\",\"programs\"],[100,200,300,400]",
"[{'abc':{'python':100}},{'def':{'program':200}},{'ghi':{'language':300}},{'jkl':{'programs':400}}]"
],
[
"[\"A1\",\"A2\",\"A3\",\"A4\"],[\"java\",\"C\",\"C++\",\"DBMS\"],[10,20,30,40]",
"[{'A1':{'java':10}},{'A2':{'C':20}},{'A3':{'C++':30}},{'A4':{'DBMS':40}}]"
]
] |
convert_list_dictionary
|
[] |
Write a function to convert more than one list to nested dictionary.
|
def convert_list_dictionary(l1, l2, l3):
"""Write a function to convert more than one list to nested dictionary. """
|
result = [{x: {y: z}} for (x, y, z) in zip(l1, l2, l3)]
|
code_infilling
|
python
|
python
|
MBPP/391/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"[\"S001\", \"S002\", \"S003\", \"S004\"],[\"Adina Park\", \"Leyton Marsh\", \"Duncan Boyle\", \"Saim Richards\"] ,[85, 98, 89, 92]",
"[{'S001': {'Adina Park': 85}}, {'S002': {'Leyton Marsh': 98}}, {'S003': {'Duncan Boyle': 89}}, {'S004': {'Saim Richards': 92}}]"
],
[
"[\"abc\",\"def\",\"ghi\",\"jkl\"],[\"python\",\"program\",\"language\",\"programs\"],[100,200,300,400]",
"[{'abc':{'python':100}},{'def':{'program':200}},{'ghi':{'language':300}},{'jkl':{'programs':400}}]"
],
[
"[\"A1\",\"A2\",\"A3\",\"A4\"],[\"java\",\"C\",\"C++\",\"DBMS\"],[10,20,30,40]",
"[{'A1':{'java':10}},{'A2':{'C':20}},{'A3':{'C++':30}},{'A4':{'DBMS':40}}]"
]
] |
convert_list_dictionary
|
[] |
Write a function to convert more than one list to nested dictionary.
|
def convert_list_dictionary(l1, l2, l3):
"""Write a function to convert more than one list to nested dictionary. """
result = [{x: {y: z}} for (x, y, z) in zip(l1, l2, l3)]
|
return result
|
|
code_infilling
|
python
|
python
|
MBPP/392/L1
|
[] |
[] |
MBPP_Infilling
|
res.append(0)
res.append(1)
i = 2
while i < n + 1:
res.append(max(i, res[int(i / 2)] + res[int(i / 3)] + res[int(i / 4)] + res[int(i / 5)]))
i = i + 1
return res[n]
|
[
[
"60",
"106"
],
[
"10",
"12"
],
[
"2",
"2"
]
] |
get_max_sum
|
[] |
Write a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n).
|
def get_max_sum(n):
"""Write a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n). """
|
res = list()
|
code_infilling
|
python
|
python
|
MBPP/392/L2
|
[] |
[] |
MBPP_Infilling
|
res.append(1)
i = 2
while i < n + 1:
res.append(max(i, res[int(i / 2)] + res[int(i / 3)] + res[int(i / 4)] + res[int(i / 5)]))
i = i + 1
return res[n]
|
[
[
"60",
"106"
],
[
"10",
"12"
],
[
"2",
"2"
]
] |
get_max_sum
|
[] |
Write a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n).
|
def get_max_sum(n):
"""Write a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n). """
res = list()
|
res.append(0)
|
code_infilling
|
python
|
python
|
MBPP/392/L3
|
[] |
[] |
MBPP_Infilling
|
i = 2
while i < n + 1:
res.append(max(i, res[int(i / 2)] + res[int(i / 3)] + res[int(i / 4)] + res[int(i / 5)]))
i = i + 1
return res[n]
|
[
[
"60",
"106"
],
[
"10",
"12"
],
[
"2",
"2"
]
] |
get_max_sum
|
[] |
Write a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n).
|
def get_max_sum(n):
"""Write a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n). """
res = list()
res.append(0)
|
res.append(1)
|
code_infilling
|
python
|
python
|
MBPP/392/L4
|
[] |
[] |
MBPP_Infilling
|
while i < n + 1:
res.append(max(i, res[int(i / 2)] + res[int(i / 3)] + res[int(i / 4)] + res[int(i / 5)]))
i = i + 1
return res[n]
|
[
[
"60",
"106"
],
[
"10",
"12"
],
[
"2",
"2"
]
] |
get_max_sum
|
[] |
Write a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n).
|
def get_max_sum(n):
"""Write a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n). """
res = list()
res.append(0)
res.append(1)
|
i = 2
|
code_infilling
|
python
|
python
|
MBPP/392/L5
|
[] |
[] |
MBPP_Infilling
|
res.append(max(i, res[int(i / 2)] + res[int(i / 3)] + res[int(i / 4)] + res[int(i / 5)]))
i = i + 1
return res[n]
|
[
[
"60",
"106"
],
[
"10",
"12"
],
[
"2",
"2"
]
] |
get_max_sum
|
[] |
Write a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n).
|
def get_max_sum(n):
"""Write a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n). """
res = list()
res.append(0)
res.append(1)
i = 2
|
while i < n + 1:
|
code_infilling
|
python
|
python
|
MBPP/392/L6
|
[] |
[] |
MBPP_Infilling
|
i = i + 1
return res[n]
|
[
[
"60",
"106"
],
[
"10",
"12"
],
[
"2",
"2"
]
] |
get_max_sum
|
[] |
Write a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n).
|
def get_max_sum(n):
"""Write a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n). """
res = list()
res.append(0)
res.append(1)
i = 2
while i < n + 1:
|
res.append(max(i, res[int(i / 2)] + res[int(i / 3)] + res[int(i / 4)] + res[int(i / 5)]))
|
code_infilling
|
python
|
python
|
MBPP/392/L7
|
[] |
[] |
MBPP_Infilling
|
return res[n]
|
[
[
"60",
"106"
],
[
"10",
"12"
],
[
"2",
"2"
]
] |
get_max_sum
|
[] |
Write a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n).
|
def get_max_sum(n):
"""Write a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n). """
res = list()
res.append(0)
res.append(1)
i = 2
while i < n + 1:
res.append(max(i, res[int(i / 2)] + res[int(i / 3)] + res[int(i / 4)] + res[int(i / 5)]))
|
i = i + 1
|
code_infilling
|
python
|
python
|
MBPP/392/L8
|
[] |
[] |
MBPP_Infilling
|
[
[
"60",
"106"
],
[
"10",
"12"
],
[
"2",
"2"
]
] |
get_max_sum
|
[] |
Write a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n).
|
def get_max_sum(n):
"""Write a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n). """
res = list()
res.append(0)
res.append(1)
i = 2
while i < n + 1:
res.append(max(i, res[int(i / 2)] + res[int(i / 3)] + res[int(i / 4)] + res[int(i / 5)]))
i = i + 1
|
return res[n]
|
|
code_infilling
|
python
|
python
|
MBPP/393/L1
|
[] |
[] |
MBPP_Infilling
|
max_list = max(input_list, key=lambda i: len(i))
return (max_length, max_list)
|
[
[
"[[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]]",
"(3, [13, 15, 17])"
],
[
"[[1,2,3,4,5],[1,2,3,4],[1,2,3],[1,2],[1]]",
"(5,[1,2,3,4,5])"
],
[
"[[3,4,5],[6,7,8,9],[10,11,12]]",
"(4,[6,7,8,9])"
]
] |
max_length_list
|
[] |
Write a function to find the list with maximum length.
|
def max_length_list(input_list):
"""Write a function to find the list with maximum length. """
|
max_length = max((len(x) for x in input_list))
|
code_infilling
|
python
|
python
|
MBPP/393/L2
|
[] |
[] |
MBPP_Infilling
|
return (max_length, max_list)
|
[
[
"[[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]]",
"(3, [13, 15, 17])"
],
[
"[[1,2,3,4,5],[1,2,3,4],[1,2,3],[1,2],[1]]",
"(5,[1,2,3,4,5])"
],
[
"[[3,4,5],[6,7,8,9],[10,11,12]]",
"(4,[6,7,8,9])"
]
] |
max_length_list
|
[] |
Write a function to find the list with maximum length.
|
def max_length_list(input_list):
"""Write a function to find the list with maximum length. """
max_length = max((len(x) for x in input_list))
|
max_list = max(input_list, key=lambda i: len(i))
|
code_infilling
|
python
|
python
|
MBPP/393/L3
|
[] |
[] |
MBPP_Infilling
|
[
[
"[[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]]",
"(3, [13, 15, 17])"
],
[
"[[1,2,3,4,5],[1,2,3,4],[1,2,3],[1,2],[1]]",
"(5,[1,2,3,4,5])"
],
[
"[[3,4,5],[6,7,8,9],[10,11,12]]",
"(4,[6,7,8,9])"
]
] |
max_length_list
|
[] |
Write a function to find the list with maximum length.
|
def max_length_list(input_list):
"""Write a function to find the list with maximum length. """
max_length = max((len(x) for x in input_list))
max_list = max(input_list, key=lambda i: len(i))
|
return (max_length, max_list)
|
|
code_infilling
|
python
|
python
|
MBPP/394/L1
|
[] |
[] |
MBPP_Infilling
|
temp = set()
for ele in test_tup:
if ele in temp:
res = False
break
temp.add(ele)
return res
|
[
[
"(1, 4, 5, 6, 1, 4)",
"False"
],
[
"(1, 4, 5, 6)",
"True"
],
[
"(2, 3, 4, 5, 6)",
"True"
]
] |
check_distinct
|
[] |
Write a function to check if given tuple contains no duplicates.
|
def check_distinct(test_tup):
"""Write a function to check if given tuple contains no duplicates. """
|
res = True
|
code_infilling
|
python
|
python
|
MBPP/394/L2
|
[] |
[] |
MBPP_Infilling
|
for ele in test_tup:
if ele in temp:
res = False
break
temp.add(ele)
return res
|
[
[
"(1, 4, 5, 6, 1, 4)",
"False"
],
[
"(1, 4, 5, 6)",
"True"
],
[
"(2, 3, 4, 5, 6)",
"True"
]
] |
check_distinct
|
[] |
Write a function to check if given tuple contains no duplicates.
|
def check_distinct(test_tup):
"""Write a function to check if given tuple contains no duplicates. """
res = True
|
temp = set()
|
code_infilling
|
python
|
python
|
MBPP/394/L3
|
[] |
[] |
MBPP_Infilling
|
if ele in temp:
res = False
break
temp.add(ele)
return res
|
[
[
"(1, 4, 5, 6, 1, 4)",
"False"
],
[
"(1, 4, 5, 6)",
"True"
],
[
"(2, 3, 4, 5, 6)",
"True"
]
] |
check_distinct
|
[] |
Write a function to check if given tuple contains no duplicates.
|
def check_distinct(test_tup):
"""Write a function to check if given tuple contains no duplicates. """
res = True
temp = set()
|
for ele in test_tup:
|
code_infilling
|
python
|
python
|
MBPP/394/L4
|
[] |
[] |
MBPP_Infilling
|
res = False
break
temp.add(ele)
return res
|
[
[
"(1, 4, 5, 6, 1, 4)",
"False"
],
[
"(1, 4, 5, 6)",
"True"
],
[
"(2, 3, 4, 5, 6)",
"True"
]
] |
check_distinct
|
[] |
Write a function to check if given tuple contains no duplicates.
|
def check_distinct(test_tup):
"""Write a function to check if given tuple contains no duplicates. """
res = True
temp = set()
for ele in test_tup:
|
if ele in temp:
|
code_infilling
|
python
|
python
|
MBPP/394/L5
|
[] |
[] |
MBPP_Infilling
|
break
temp.add(ele)
return res
|
[
[
"(1, 4, 5, 6, 1, 4)",
"False"
],
[
"(1, 4, 5, 6)",
"True"
],
[
"(2, 3, 4, 5, 6)",
"True"
]
] |
check_distinct
|
[] |
Write a function to check if given tuple contains no duplicates.
|
def check_distinct(test_tup):
"""Write a function to check if given tuple contains no duplicates. """
res = True
temp = set()
for ele in test_tup:
if ele in temp:
|
res = False
|
code_infilling
|
python
|
python
|
MBPP/394/L6
|
[] |
[] |
MBPP_Infilling
|
temp.add(ele)
return res
|
[
[
"(1, 4, 5, 6, 1, 4)",
"False"
],
[
"(1, 4, 5, 6)",
"True"
],
[
"(2, 3, 4, 5, 6)",
"True"
]
] |
check_distinct
|
[] |
Write a function to check if given tuple contains no duplicates.
|
def check_distinct(test_tup):
"""Write a function to check if given tuple contains no duplicates. """
res = True
temp = set()
for ele in test_tup:
if ele in temp:
res = False
|
break
|
code_infilling
|
python
|
python
|
MBPP/394/L7
|
[] |
[] |
MBPP_Infilling
|
return res
|
[
[
"(1, 4, 5, 6, 1, 4)",
"False"
],
[
"(1, 4, 5, 6)",
"True"
],
[
"(2, 3, 4, 5, 6)",
"True"
]
] |
check_distinct
|
[] |
Write a function to check if given tuple contains no duplicates.
|
def check_distinct(test_tup):
"""Write a function to check if given tuple contains no duplicates. """
res = True
temp = set()
for ele in test_tup:
if ele in temp:
res = False
break
|
temp.add(ele)
|
code_infilling
|
python
|
python
|
MBPP/394/L8
|
[] |
[] |
MBPP_Infilling
|
[
[
"(1, 4, 5, 6, 1, 4)",
"False"
],
[
"(1, 4, 5, 6)",
"True"
],
[
"(2, 3, 4, 5, 6)",
"True"
]
] |
check_distinct
|
[] |
Write a function to check if given tuple contains no duplicates.
|
def check_distinct(test_tup):
"""Write a function to check if given tuple contains no duplicates. """
res = True
temp = set()
for ele in test_tup:
if ele in temp:
res = False
break
temp.add(ele)
|
return res
|
|
code_infilling
|
python
|
python
|
MBPP/395/L1
|
[] |
[] |
MBPP_Infilling
|
ctr = {}
for c in str1:
if c in ctr:
ctr[c] += 1
else:
ctr[c] = 1
char_order.append(c)
for c in char_order:
if ctr[c] == 1:
return c
return None
|
[
[
"\"abcabc\"",
null
],
[
"\"abc\"",
"\"a\""
],
[
"\"ababc\"",
"\"c\""
]
] |
first_non_repeating_character
|
[] |
Write a python function to find the first non-repeated character in a given string.
|
def first_non_repeating_character(str1):
"""Write a python function to find the first non-repeated character in a given string. """
|
char_order = []
|
code_infilling
|
python
|
python
|
MBPP/395/L2
|
[] |
[] |
MBPP_Infilling
|
for c in str1:
if c in ctr:
ctr[c] += 1
else:
ctr[c] = 1
char_order.append(c)
for c in char_order:
if ctr[c] == 1:
return c
return None
|
[
[
"\"abcabc\"",
null
],
[
"\"abc\"",
"\"a\""
],
[
"\"ababc\"",
"\"c\""
]
] |
first_non_repeating_character
|
[] |
Write a python function to find the first non-repeated character in a given string.
|
def first_non_repeating_character(str1):
"""Write a python function to find the first non-repeated character in a given string. """
char_order = []
|
ctr = {}
|
code_infilling
|
python
|
python
|
MBPP/395/L3
|
[] |
[] |
MBPP_Infilling
|
if c in ctr:
ctr[c] += 1
else:
ctr[c] = 1
char_order.append(c)
for c in char_order:
if ctr[c] == 1:
return c
return None
|
[
[
"\"abcabc\"",
null
],
[
"\"abc\"",
"\"a\""
],
[
"\"ababc\"",
"\"c\""
]
] |
first_non_repeating_character
|
[] |
Write a python function to find the first non-repeated character in a given string.
|
def first_non_repeating_character(str1):
"""Write a python function to find the first non-repeated character in a given string. """
char_order = []
ctr = {}
|
for c in str1:
|
code_infilling
|
python
|
python
|
MBPP/395/L4
|
[] |
[] |
MBPP_Infilling
|
ctr[c] += 1
else:
ctr[c] = 1
char_order.append(c)
for c in char_order:
if ctr[c] == 1:
return c
return None
|
[
[
"\"abcabc\"",
null
],
[
"\"abc\"",
"\"a\""
],
[
"\"ababc\"",
"\"c\""
]
] |
first_non_repeating_character
|
[] |
Write a python function to find the first non-repeated character in a given string.
|
def first_non_repeating_character(str1):
"""Write a python function to find the first non-repeated character in a given string. """
char_order = []
ctr = {}
for c in str1:
|
if c in ctr:
|
code_infilling
|
python
|
python
|
MBPP/395/L5
|
[] |
[] |
MBPP_Infilling
|
else:
ctr[c] = 1
char_order.append(c)
for c in char_order:
if ctr[c] == 1:
return c
return None
|
[
[
"\"abcabc\"",
null
],
[
"\"abc\"",
"\"a\""
],
[
"\"ababc\"",
"\"c\""
]
] |
first_non_repeating_character
|
[] |
Write a python function to find the first non-repeated character in a given string.
|
def first_non_repeating_character(str1):
"""Write a python function to find the first non-repeated character in a given string. """
char_order = []
ctr = {}
for c in str1:
if c in ctr:
|
ctr[c] += 1
|
code_infilling
|
python
|
python
|
MBPP/395/L6
|
[] |
[] |
MBPP_Infilling
|
ctr[c] = 1
char_order.append(c)
for c in char_order:
if ctr[c] == 1:
return c
return None
|
[
[
"\"abcabc\"",
null
],
[
"\"abc\"",
"\"a\""
],
[
"\"ababc\"",
"\"c\""
]
] |
first_non_repeating_character
|
[] |
Write a python function to find the first non-repeated character in a given string.
|
def first_non_repeating_character(str1):
"""Write a python function to find the first non-repeated character in a given string. """
char_order = []
ctr = {}
for c in str1:
if c in ctr:
ctr[c] += 1
|
else:
|
code_infilling
|
python
|
python
|
MBPP/395/L7
|
[] |
[] |
MBPP_Infilling
|
char_order.append(c)
for c in char_order:
if ctr[c] == 1:
return c
return None
|
[
[
"\"abcabc\"",
null
],
[
"\"abc\"",
"\"a\""
],
[
"\"ababc\"",
"\"c\""
]
] |
first_non_repeating_character
|
[] |
Write a python function to find the first non-repeated character in a given string.
|
def first_non_repeating_character(str1):
"""Write a python function to find the first non-repeated character in a given string. """
char_order = []
ctr = {}
for c in str1:
if c in ctr:
ctr[c] += 1
else:
|
ctr[c] = 1
|
code_infilling
|
python
|
python
|
MBPP/395/L8
|
[] |
[] |
MBPP_Infilling
|
for c in char_order:
if ctr[c] == 1:
return c
return None
|
[
[
"\"abcabc\"",
null
],
[
"\"abc\"",
"\"a\""
],
[
"\"ababc\"",
"\"c\""
]
] |
first_non_repeating_character
|
[] |
Write a python function to find the first non-repeated character in a given string.
|
def first_non_repeating_character(str1):
"""Write a python function to find the first non-repeated character in a given string. """
char_order = []
ctr = {}
for c in str1:
if c in ctr:
ctr[c] += 1
else:
ctr[c] = 1
|
char_order.append(c)
|
code_infilling
|
python
|
python
|
MBPP/395/L9
|
[] |
[] |
MBPP_Infilling
|
if ctr[c] == 1:
return c
return None
|
[
[
"\"abcabc\"",
null
],
[
"\"abc\"",
"\"a\""
],
[
"\"ababc\"",
"\"c\""
]
] |
first_non_repeating_character
|
[] |
Write a python function to find the first non-repeated character in a given string.
|
def first_non_repeating_character(str1):
"""Write a python function to find the first non-repeated character in a given string. """
char_order = []
ctr = {}
for c in str1:
if c in ctr:
ctr[c] += 1
else:
ctr[c] = 1
char_order.append(c)
|
for c in char_order:
|
code_infilling
|
python
|
python
|
MBPP/395/L10
|
[] |
[] |
MBPP_Infilling
|
return c
return None
|
[
[
"\"abcabc\"",
null
],
[
"\"abc\"",
"\"a\""
],
[
"\"ababc\"",
"\"c\""
]
] |
first_non_repeating_character
|
[] |
Write a python function to find the first non-repeated character in a given string.
|
def first_non_repeating_character(str1):
"""Write a python function to find the first non-repeated character in a given string. """
char_order = []
ctr = {}
for c in str1:
if c in ctr:
ctr[c] += 1
else:
ctr[c] = 1
char_order.append(c)
for c in char_order:
|
if ctr[c] == 1:
|
code_infilling
|
python
|
python
|
MBPP/395/L11
|
[] |
[] |
MBPP_Infilling
|
return None
|
[
[
"\"abcabc\"",
null
],
[
"\"abc\"",
"\"a\""
],
[
"\"ababc\"",
"\"c\""
]
] |
first_non_repeating_character
|
[] |
Write a python function to find the first non-repeated character in a given string.
|
def first_non_repeating_character(str1):
"""Write a python function to find the first non-repeated character in a given string. """
char_order = []
ctr = {}
for c in str1:
if c in ctr:
ctr[c] += 1
else:
ctr[c] = 1
char_order.append(c)
for c in char_order:
if ctr[c] == 1:
|
return c
|
code_infilling
|
python
|
python
|
MBPP/395/L12
|
[] |
[] |
MBPP_Infilling
|
[
[
"\"abcabc\"",
null
],
[
"\"abc\"",
"\"a\""
],
[
"\"ababc\"",
"\"c\""
]
] |
first_non_repeating_character
|
[] |
Write a python function to find the first non-repeated character in a given string.
|
def first_non_repeating_character(str1):
"""Write a python function to find the first non-repeated character in a given string. """
char_order = []
ctr = {}
for c in str1:
if c in ctr:
ctr[c] += 1
else:
ctr[c] = 1
char_order.append(c)
for c in char_order:
if ctr[c] == 1:
return c
|
return None
|
|
code_infilling
|
python
|
python
|
MBPP/396/L4
|
[] |
[] |
MBPP_Infilling
|
return 'Valid'
else:
return 'Invalid'
|
[
[
"\"abba\"",
"\"Valid\""
],
[
"\"a\"",
"\"Valid\""
],
[
"\"abcd\"",
"\"Invalid\""
]
] |
check_char
|
[
"import re "
] |
Write a function to check whether the given string starts and ends with the same character or not.
|
import re
regex = '^[a-z]$|^([a-z]).*\\1$'
def check_char(string):
"""Write a function to check whether the given string starts and ends with the same character or not. """
|
if re.search(regex, string):
|
code_infilling
|
python
|
python
|
MBPP/396/L5
|
[] |
[] |
MBPP_Infilling
|
else:
return 'Invalid'
|
[
[
"\"abba\"",
"\"Valid\""
],
[
"\"a\"",
"\"Valid\""
],
[
"\"abcd\"",
"\"Invalid\""
]
] |
check_char
|
[
"import re "
] |
Write a function to check whether the given string starts and ends with the same character or not.
|
import re
regex = '^[a-z]$|^([a-z]).*\\1$'
def check_char(string):
"""Write a function to check whether the given string starts and ends with the same character or not. """
if re.search(regex, string):
|
return 'Valid'
|
code_infilling
|
python
|
python
|
MBPP/396/L6
|
[] |
[] |
MBPP_Infilling
|
return 'Invalid'
|
[
[
"\"abba\"",
"\"Valid\""
],
[
"\"a\"",
"\"Valid\""
],
[
"\"abcd\"",
"\"Invalid\""
]
] |
check_char
|
[
"import re "
] |
Write a function to check whether the given string starts and ends with the same character or not.
|
import re
regex = '^[a-z]$|^([a-z]).*\\1$'
def check_char(string):
"""Write a function to check whether the given string starts and ends with the same character or not. """
if re.search(regex, string):
return 'Valid'
|
else:
|
code_infilling
|
python
|
python
|
MBPP/396/L7
|
[] |
[] |
MBPP_Infilling
|
[
[
"\"abba\"",
"\"Valid\""
],
[
"\"a\"",
"\"Valid\""
],
[
"\"abcd\"",
"\"Invalid\""
]
] |
check_char
|
[
"import re "
] |
Write a function to check whether the given string starts and ends with the same character or not.
|
import re
regex = '^[a-z]$|^([a-z]).*\\1$'
def check_char(string):
"""Write a function to check whether the given string starts and ends with the same character or not. """
if re.search(regex, string):
return 'Valid'
else:
|
return 'Invalid'
|
|
code_infilling
|
python
|
python
|
MBPP/397/L1
|
[] |
[] |
MBPP_Infilling
|
if a < c:
median = a
elif b > c:
median = b
else:
median = c
elif a > c:
median = a
elif b < c:
median = b
else:
median = c
return median
|
[
[
"25,55,65",
"55.0"
],
[
"20,10,30",
"20.0"
],
[
"15,45,75",
"45.0"
]
] |
median_numbers
|
[] |
Write a function to find the median of three numbers.
|
def median_numbers(a, b, c):
"""Write a function to find the median of three numbers. """
|
if a > b:
|
code_infilling
|
python
|
python
|
MBPP/397/L2
|
[] |
[] |
MBPP_Infilling
|
median = a
elif b > c:
median = b
else:
median = c
elif a > c:
median = a
elif b < c:
median = b
else:
median = c
return median
|
[
[
"25,55,65",
"55.0"
],
[
"20,10,30",
"20.0"
],
[
"15,45,75",
"45.0"
]
] |
median_numbers
|
[] |
Write a function to find the median of three numbers.
|
def median_numbers(a, b, c):
"""Write a function to find the median of three numbers. """
if a > b:
|
if a < c:
|
code_infilling
|
python
|
python
|
MBPP/397/L3
|
[] |
[] |
MBPP_Infilling
|
elif b > c:
median = b
else:
median = c
elif a > c:
median = a
elif b < c:
median = b
else:
median = c
return median
|
[
[
"25,55,65",
"55.0"
],
[
"20,10,30",
"20.0"
],
[
"15,45,75",
"45.0"
]
] |
median_numbers
|
[] |
Write a function to find the median of three numbers.
|
def median_numbers(a, b, c):
"""Write a function to find the median of three numbers. """
if a > b:
if a < c:
|
median = a
|
code_infilling
|
python
|
python
|
MBPP/397/L4
|
[] |
[] |
MBPP_Infilling
|
median = b
else:
median = c
elif a > c:
median = a
elif b < c:
median = b
else:
median = c
return median
|
[
[
"25,55,65",
"55.0"
],
[
"20,10,30",
"20.0"
],
[
"15,45,75",
"45.0"
]
] |
median_numbers
|
[] |
Write a function to find the median of three numbers.
|
def median_numbers(a, b, c):
"""Write a function to find the median of three numbers. """
if a > b:
if a < c:
median = a
|
elif b > c:
|
code_infilling
|
python
|
python
|
MBPP/397/L5
|
[] |
[] |
MBPP_Infilling
|
else:
median = c
elif a > c:
median = a
elif b < c:
median = b
else:
median = c
return median
|
[
[
"25,55,65",
"55.0"
],
[
"20,10,30",
"20.0"
],
[
"15,45,75",
"45.0"
]
] |
median_numbers
|
[] |
Write a function to find the median of three numbers.
|
def median_numbers(a, b, c):
"""Write a function to find the median of three numbers. """
if a > b:
if a < c:
median = a
elif b > c:
|
median = b
|
code_infilling
|
python
|
python
|
MBPP/397/L6
|
[] |
[] |
MBPP_Infilling
|
median = c
elif a > c:
median = a
elif b < c:
median = b
else:
median = c
return median
|
[
[
"25,55,65",
"55.0"
],
[
"20,10,30",
"20.0"
],
[
"15,45,75",
"45.0"
]
] |
median_numbers
|
[] |
Write a function to find the median of three numbers.
|
def median_numbers(a, b, c):
"""Write a function to find the median of three numbers. """
if a > b:
if a < c:
median = a
elif b > c:
median = b
|
else:
|
code_infilling
|
python
|
python
|
MBPP/397/L7
|
[] |
[] |
MBPP_Infilling
|
elif a > c:
median = a
elif b < c:
median = b
else:
median = c
return median
|
[
[
"25,55,65",
"55.0"
],
[
"20,10,30",
"20.0"
],
[
"15,45,75",
"45.0"
]
] |
median_numbers
|
[] |
Write a function to find the median of three numbers.
|
def median_numbers(a, b, c):
"""Write a function to find the median of three numbers. """
if a > b:
if a < c:
median = a
elif b > c:
median = b
else:
|
median = c
|
code_infilling
|
python
|
python
|
MBPP/397/L8
|
[] |
[] |
MBPP_Infilling
|
median = a
elif b < c:
median = b
else:
median = c
return median
|
[
[
"25,55,65",
"55.0"
],
[
"20,10,30",
"20.0"
],
[
"15,45,75",
"45.0"
]
] |
median_numbers
|
[] |
Write a function to find the median of three numbers.
|
def median_numbers(a, b, c):
"""Write a function to find the median of three numbers. """
if a > b:
if a < c:
median = a
elif b > c:
median = b
else:
median = c
|
elif a > c:
|
code_infilling
|
python
|
python
|
MBPP/397/L9
|
[] |
[] |
MBPP_Infilling
|
elif b < c:
median = b
else:
median = c
return median
|
[
[
"25,55,65",
"55.0"
],
[
"20,10,30",
"20.0"
],
[
"15,45,75",
"45.0"
]
] |
median_numbers
|
[] |
Write a function to find the median of three numbers.
|
def median_numbers(a, b, c):
"""Write a function to find the median of three numbers. """
if a > b:
if a < c:
median = a
elif b > c:
median = b
else:
median = c
elif a > c:
|
median = a
|
code_infilling
|
python
|
python
|
MBPP/397/L10
|
[] |
[] |
MBPP_Infilling
|
median = b
else:
median = c
return median
|
[
[
"25,55,65",
"55.0"
],
[
"20,10,30",
"20.0"
],
[
"15,45,75",
"45.0"
]
] |
median_numbers
|
[] |
Write a function to find the median of three numbers.
|
def median_numbers(a, b, c):
"""Write a function to find the median of three numbers. """
if a > b:
if a < c:
median = a
elif b > c:
median = b
else:
median = c
elif a > c:
median = a
|
elif b < c:
|
code_infilling
|
python
|
python
|
MBPP/397/L11
|
[] |
[] |
MBPP_Infilling
|
else:
median = c
return median
|
[
[
"25,55,65",
"55.0"
],
[
"20,10,30",
"20.0"
],
[
"15,45,75",
"45.0"
]
] |
median_numbers
|
[] |
Write a function to find the median of three numbers.
|
def median_numbers(a, b, c):
"""Write a function to find the median of three numbers. """
if a > b:
if a < c:
median = a
elif b > c:
median = b
else:
median = c
elif a > c:
median = a
elif b < c:
|
median = b
|
code_infilling
|
python
|
python
|
MBPP/397/L12
|
[] |
[] |
MBPP_Infilling
|
median = c
return median
|
[
[
"25,55,65",
"55.0"
],
[
"20,10,30",
"20.0"
],
[
"15,45,75",
"45.0"
]
] |
median_numbers
|
[] |
Write a function to find the median of three numbers.
|
def median_numbers(a, b, c):
"""Write a function to find the median of three numbers. """
if a > b:
if a < c:
median = a
elif b > c:
median = b
else:
median = c
elif a > c:
median = a
elif b < c:
median = b
|
else:
|
code_infilling
|
python
|
python
|
MBPP/397/L13
|
[] |
[] |
MBPP_Infilling
|
return median
|
[
[
"25,55,65",
"55.0"
],
[
"20,10,30",
"20.0"
],
[
"15,45,75",
"45.0"
]
] |
median_numbers
|
[] |
Write a function to find the median of three numbers.
|
def median_numbers(a, b, c):
"""Write a function to find the median of three numbers. """
if a > b:
if a < c:
median = a
elif b > c:
median = b
else:
median = c
elif a > c:
median = a
elif b < c:
median = b
else:
|
median = c
|
code_infilling
|
python
|
python
|
MBPP/397/L14
|
[] |
[] |
MBPP_Infilling
|
[
[
"25,55,65",
"55.0"
],
[
"20,10,30",
"20.0"
],
[
"15,45,75",
"45.0"
]
] |
median_numbers
|
[] |
Write a function to find the median of three numbers.
|
def median_numbers(a, b, c):
"""Write a function to find the median of three numbers. """
if a > b:
if a < c:
median = a
elif b > c:
median = b
else:
median = c
elif a > c:
median = a
elif b < c:
median = b
else:
median = c
|
return median
|
|
code_infilling
|
python
|
python
|
MBPP/398/L1
|
[] |
[] |
MBPP_Infilling
|
[
[
"[10,2,56]",
"14"
],
[
"[[10,20,4,5,'b',70,'a']]",
"19"
],
[
"[10,20,-4,5,-70]",
"19"
]
] |
sum_of_digits
|
[] |
Write a function to compute the sum of digits of each number of a given list.
|
def sum_of_digits(nums):
"""Write a function to compute the sum of digits of each number of a given list. """
|
return sum((int(el) for n in nums for el in str(n) if el.isdigit()))
|
|
code_infilling
|
python
|
python
|
MBPP/399/L1
|
[] |
[] |
MBPP_Infilling
|
return res
|
[
[
"(10, 4, 6, 9), (5, 2, 3, 3)",
"(15, 6, 5, 10)"
],
[
"(11, 5, 7, 10), (6, 3, 4, 4)",
"(13, 6, 3, 14)"
],
[
"(12, 6, 8, 11), (7, 4, 5, 6)",
"(11, 2, 13, 13)"
]
] |
bitwise_xor
|
[] |
Write a function to perform the mathematical bitwise xor operation across the given tuples.
|
def bitwise_xor(test_tup1, test_tup2):
"""Write a function to perform the mathematical bitwise xor operation across the given tuples. """
|
res = tuple((ele1 ^ ele2 for (ele1, ele2) in zip(test_tup1, test_tup2)))
|
code_infilling
|
python
|
python
|
MBPP/399/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"(10, 4, 6, 9), (5, 2, 3, 3)",
"(15, 6, 5, 10)"
],
[
"(11, 5, 7, 10), (6, 3, 4, 4)",
"(13, 6, 3, 14)"
],
[
"(12, 6, 8, 11), (7, 4, 5, 6)",
"(11, 2, 13, 13)"
]
] |
bitwise_xor
|
[] |
Write a function to perform the mathematical bitwise xor operation across the given tuples.
|
def bitwise_xor(test_tup1, test_tup2):
"""Write a function to perform the mathematical bitwise xor operation across the given tuples. """
res = tuple((ele1 ^ ele2 for (ele1, ele2) in zip(test_tup1, test_tup2)))
|
return res
|
|
code_infilling
|
python
|
python
|
MBPP/400/L1
|
[] |
[] |
MBPP_Infilling
|
return res
|
[
[
"[(3, 4), (1, 2), (4, 3), (5, 6)] ",
"3"
],
[
"[(4, 15), (2, 3), (5, 4), (6, 7)] ",
"4"
],
[
"[(5, 16), (2, 3), (6, 5), (6, 9)] ",
"4"
]
] |
extract_freq
|
[] |
Write a function to extract the number of unique tuples in the given list.
|
def extract_freq(test_list):
"""Write a function to extract the number of unique tuples in the given list. """
|
res = len(list(set((tuple(sorted(sub)) for sub in test_list))))
|
code_infilling
|
python
|
python
|
MBPP/400/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"[(3, 4), (1, 2), (4, 3), (5, 6)] ",
"3"
],
[
"[(4, 15), (2, 3), (5, 4), (6, 7)] ",
"4"
],
[
"[(5, 16), (2, 3), (6, 5), (6, 9)] ",
"4"
]
] |
extract_freq
|
[] |
Write a function to extract the number of unique tuples in the given list.
|
def extract_freq(test_list):
"""Write a function to extract the number of unique tuples in the given list. """
res = len(list(set((tuple(sorted(sub)) for sub in test_list))))
|
return res
|
|
code_infilling
|
python
|
python
|
MBPP/401/L1
|
[] |
[] |
MBPP_Infilling
|
return res
|
[
[
"((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))",
"((7, 10), (7, 14), (3, 10), (8, 13))"
],
[
"((2, 4), (5, 6), (3, 10), (2, 11)), ((7, 8), (4, 10), (2, 2), (8, 4))",
"((9, 12), (9, 16), (5, 12), (10, 15))"
],
[
"((3, 5), (6, 7), (4, 11), (3, 12)), ((8, 9), (5, 11), (3, 3), (9, 5))",
"((11, 14), (11, 18), (7, 14), (12, 17))"
]
] |
add_nested_tuples
|
[] |
Write a function to perform index wise addition of tuple elements in the given two nested tuples.
|
def add_nested_tuples(test_tup1, test_tup2):
"""Write a function to perform index wise addition of tuple elements in the given two nested tuples. """
|
res = tuple((tuple((a + b for (a, b) in zip(tup1, tup2))) for (tup1, tup2) in zip(test_tup1, test_tup2)))
|
code_infilling
|
python
|
python
|
MBPP/401/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))",
"((7, 10), (7, 14), (3, 10), (8, 13))"
],
[
"((2, 4), (5, 6), (3, 10), (2, 11)), ((7, 8), (4, 10), (2, 2), (8, 4))",
"((9, 12), (9, 16), (5, 12), (10, 15))"
],
[
"((3, 5), (6, 7), (4, 11), (3, 12)), ((8, 9), (5, 11), (3, 3), (9, 5))",
"((11, 14), (11, 18), (7, 14), (12, 17))"
]
] |
add_nested_tuples
|
[] |
Write a function to perform index wise addition of tuple elements in the given two nested tuples.
|
def add_nested_tuples(test_tup1, test_tup2):
"""Write a function to perform index wise addition of tuple elements in the given two nested tuples. """
res = tuple((tuple((a + b for (a, b) in zip(tup1, tup2))) for (tup1, tup2) in zip(test_tup1, test_tup2)))
|
return res
|
|
code_infilling
|
python
|
python
|
MBPP/404/L1
|
[] |
[] |
MBPP_Infilling
|
return a
else:
return b
|
[
[
"1,2",
"1"
],
[
"-5,-4",
"-5"
],
[
"0,0",
"0"
]
] |
minimum
|
[] |
Write a python function to find the minimum of two numbers.
|
def minimum(a, b):
"""Write a python function to find the minimum of two numbers. """
|
if a <= b:
|
code_infilling
|
python
|
python
|
MBPP/404/L2
|
[] |
[] |
MBPP_Infilling
|
else:
return b
|
[
[
"1,2",
"1"
],
[
"-5,-4",
"-5"
],
[
"0,0",
"0"
]
] |
minimum
|
[] |
Write a python function to find the minimum of two numbers.
|
def minimum(a, b):
"""Write a python function to find the minimum of two numbers. """
if a <= b:
|
return a
|
code_infilling
|
python
|
python
|
MBPP/404/L3
|
[] |
[] |
MBPP_Infilling
|
return b
|
[
[
"1,2",
"1"
],
[
"-5,-4",
"-5"
],
[
"0,0",
"0"
]
] |
minimum
|
[] |
Write a python function to find the minimum of two numbers.
|
def minimum(a, b):
"""Write a python function to find the minimum of two numbers. """
if a <= b:
return a
|
else:
|
code_infilling
|
python
|
python
|
MBPP/404/L4
|
[] |
[] |
MBPP_Infilling
|
[
[
"1,2",
"1"
],
[
"-5,-4",
"-5"
],
[
"0,0",
"0"
]
] |
minimum
|
[] |
Write a python function to find the minimum of two numbers.
|
def minimum(a, b):
"""Write a python function to find the minimum of two numbers. """
if a <= b:
return a
else:
|
return b
|
|
code_infilling
|
python
|
python
|
MBPP/405/L1
|
[] |
[] |
MBPP_Infilling
|
return True
else:
return False
|
[
[
"(\"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:
|
code_infilling
|
python
|
python
|
MBPP/405/L2
|
[] |
[] |
MBPP_Infilling
|
else:
return False
|
[
[
"(\"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
|
code_infilling
|
python
|
python
|
MBPP/405/L3
|
[] |
[] |
MBPP_Infilling
|
return False
|
[
[
"(\"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:
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.