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/143/L1
|
[] |
[] |
MBPP_Infilling
|
return 1
else:
return len(Input)
|
[
[
"([1, 2, 3, 4], [5, 6, 7, 8])",
"2"
],
[
"([1, 2], [3, 4], [5, 6])",
"3"
],
[
"([9, 8, 7, 6, 5, 4, 3, 2, 1])",
"1"
]
] |
find_lists
|
[] |
Write a function to find number of lists present in the given tuple.
|
def find_lists(Input):
"""Write a function to find number of lists present in the given tuple. """
|
if isinstance(Input, list):
|
code_infilling
|
python
|
python
|
MBPP/143/L2
|
[] |
[] |
MBPP_Infilling
|
else:
return len(Input)
|
[
[
"([1, 2, 3, 4], [5, 6, 7, 8])",
"2"
],
[
"([1, 2], [3, 4], [5, 6])",
"3"
],
[
"([9, 8, 7, 6, 5, 4, 3, 2, 1])",
"1"
]
] |
find_lists
|
[] |
Write a function to find number of lists present in the given tuple.
|
def find_lists(Input):
"""Write a function to find number of lists present in the given tuple. """
if isinstance(Input, list):
|
return 1
|
code_infilling
|
python
|
python
|
MBPP/143/L3
|
[] |
[] |
MBPP_Infilling
|
return len(Input)
|
[
[
"([1, 2, 3, 4], [5, 6, 7, 8])",
"2"
],
[
"([1, 2], [3, 4], [5, 6])",
"3"
],
[
"([9, 8, 7, 6, 5, 4, 3, 2, 1])",
"1"
]
] |
find_lists
|
[] |
Write a function to find number of lists present in the given tuple.
|
def find_lists(Input):
"""Write a function to find number of lists present in the given tuple. """
if isinstance(Input, list):
return 1
|
else:
|
code_infilling
|
python
|
python
|
MBPP/143/L4
|
[] |
[] |
MBPP_Infilling
|
[
[
"([1, 2, 3, 4], [5, 6, 7, 8])",
"2"
],
[
"([1, 2], [3, 4], [5, 6])",
"3"
],
[
"([9, 8, 7, 6, 5, 4, 3, 2, 1])",
"1"
]
] |
find_lists
|
[] |
Write a function to find number of lists present in the given tuple.
|
def find_lists(Input):
"""Write a function to find number of lists present in the given tuple. """
if isinstance(Input, list):
return 1
else:
|
return len(Input)
|
|
code_infilling
|
python
|
python
|
MBPP/145/L1
|
[] |
[] |
MBPP_Infilling
|
minEle = arr[0]
maxEle = arr[0]
for i in range(1, n):
minEle = min(minEle, arr[i])
maxEle = max(maxEle, arr[i])
return maxEle - minEle
|
[
[
"(2,1,5,3)",
"4"
],
[
"(9,3,2,5,1)",
"8"
],
[
"(3,2,1)",
"2"
]
] |
max_Abs_Diff
|
[] |
Write a python function to find the maximum difference between any two elements in a given array.
|
def max_Abs_Diff(arr):
"""Write a python function to find the maximum difference between any two elements in a given array. """
|
n = len(arr)
|
code_infilling
|
python
|
python
|
MBPP/145/L2
|
[] |
[] |
MBPP_Infilling
|
maxEle = arr[0]
for i in range(1, n):
minEle = min(minEle, arr[i])
maxEle = max(maxEle, arr[i])
return maxEle - minEle
|
[
[
"(2,1,5,3)",
"4"
],
[
"(9,3,2,5,1)",
"8"
],
[
"(3,2,1)",
"2"
]
] |
max_Abs_Diff
|
[] |
Write a python function to find the maximum difference between any two elements in a given array.
|
def max_Abs_Diff(arr):
"""Write a python function to find the maximum difference between any two elements in a given array. """
n = len(arr)
|
minEle = arr[0]
|
code_infilling
|
python
|
python
|
MBPP/145/L3
|
[] |
[] |
MBPP_Infilling
|
for i in range(1, n):
minEle = min(minEle, arr[i])
maxEle = max(maxEle, arr[i])
return maxEle - minEle
|
[
[
"(2,1,5,3)",
"4"
],
[
"(9,3,2,5,1)",
"8"
],
[
"(3,2,1)",
"2"
]
] |
max_Abs_Diff
|
[] |
Write a python function to find the maximum difference between any two elements in a given array.
|
def max_Abs_Diff(arr):
"""Write a python function to find the maximum difference between any two elements in a given array. """
n = len(arr)
minEle = arr[0]
|
maxEle = arr[0]
|
code_infilling
|
python
|
python
|
MBPP/145/L4
|
[] |
[] |
MBPP_Infilling
|
minEle = min(minEle, arr[i])
maxEle = max(maxEle, arr[i])
return maxEle - minEle
|
[
[
"(2,1,5,3)",
"4"
],
[
"(9,3,2,5,1)",
"8"
],
[
"(3,2,1)",
"2"
]
] |
max_Abs_Diff
|
[] |
Write a python function to find the maximum difference between any two elements in a given array.
|
def max_Abs_Diff(arr):
"""Write a python function to find the maximum difference between any two elements in a given array. """
n = len(arr)
minEle = arr[0]
maxEle = arr[0]
|
for i in range(1, n):
|
code_infilling
|
python
|
python
|
MBPP/145/L5
|
[] |
[] |
MBPP_Infilling
|
maxEle = max(maxEle, arr[i])
return maxEle - minEle
|
[
[
"(2,1,5,3)",
"4"
],
[
"(9,3,2,5,1)",
"8"
],
[
"(3,2,1)",
"2"
]
] |
max_Abs_Diff
|
[] |
Write a python function to find the maximum difference between any two elements in a given array.
|
def max_Abs_Diff(arr):
"""Write a python function to find the maximum difference between any two elements in a given array. """
n = len(arr)
minEle = arr[0]
maxEle = arr[0]
for i in range(1, n):
|
minEle = min(minEle, arr[i])
|
code_infilling
|
python
|
python
|
MBPP/145/L6
|
[] |
[] |
MBPP_Infilling
|
return maxEle - minEle
|
[
[
"(2,1,5,3)",
"4"
],
[
"(9,3,2,5,1)",
"8"
],
[
"(3,2,1)",
"2"
]
] |
max_Abs_Diff
|
[] |
Write a python function to find the maximum difference between any two elements in a given array.
|
def max_Abs_Diff(arr):
"""Write a python function to find the maximum difference between any two elements in a given array. """
n = len(arr)
minEle = arr[0]
maxEle = arr[0]
for i in range(1, n):
minEle = min(minEle, arr[i])
|
maxEle = max(maxEle, arr[i])
|
code_infilling
|
python
|
python
|
MBPP/145/L7
|
[] |
[] |
MBPP_Infilling
|
[
[
"(2,1,5,3)",
"4"
],
[
"(9,3,2,5,1)",
"8"
],
[
"(3,2,1)",
"2"
]
] |
max_Abs_Diff
|
[] |
Write a python function to find the maximum difference between any two elements in a given array.
|
def max_Abs_Diff(arr):
"""Write a python function to find the maximum difference between any two elements in a given array. """
n = len(arr)
minEle = arr[0]
maxEle = arr[0]
for i in range(1, n):
minEle = min(minEle, arr[i])
maxEle = max(maxEle, arr[i])
|
return maxEle - minEle
|
|
code_infilling
|
python
|
python
|
MBPP/160/L1
|
[] |
[] |
MBPP_Infilling
|
while i * a <= n:
if (n - i * a) % b == 0:
return (i, (n - i * a) // b)
i = i + 1
return None
|
[
[
"2, 3, 7",
"(2, 1)"
],
[
"4, 2, 7",
null
],
[
"1, 13, 17",
"(4, 1)"
]
] |
find_solution
|
[] |
Write a function that returns integers x and y that satisfy ax + by = n as a tuple, or return None if no solution exists.
|
def find_solution(a, b, n):
"""Write a function that returns integers x and y that satisfy ax + by = n as a tuple, or return None if no solution exists. """
|
i = 0
|
code_infilling
|
python
|
python
|
MBPP/160/L2
|
[] |
[] |
MBPP_Infilling
|
if (n - i * a) % b == 0:
return (i, (n - i * a) // b)
i = i + 1
return None
|
[
[
"2, 3, 7",
"(2, 1)"
],
[
"4, 2, 7",
null
],
[
"1, 13, 17",
"(4, 1)"
]
] |
find_solution
|
[] |
Write a function that returns integers x and y that satisfy ax + by = n as a tuple, or return None if no solution exists.
|
def find_solution(a, b, n):
"""Write a function that returns integers x and y that satisfy ax + by = n as a tuple, or return None if no solution exists. """
i = 0
|
while i * a <= n:
|
code_infilling
|
python
|
python
|
MBPP/160/L3
|
[] |
[] |
MBPP_Infilling
|
return (i, (n - i * a) // b)
i = i + 1
return None
|
[
[
"2, 3, 7",
"(2, 1)"
],
[
"4, 2, 7",
null
],
[
"1, 13, 17",
"(4, 1)"
]
] |
find_solution
|
[] |
Write a function that returns integers x and y that satisfy ax + by = n as a tuple, or return None if no solution exists.
|
def find_solution(a, b, n):
"""Write a function that returns integers x and y that satisfy ax + by = n as a tuple, or return None if no solution exists. """
i = 0
while i * a <= n:
|
if (n - i * a) % b == 0:
|
code_infilling
|
python
|
python
|
MBPP/160/L4
|
[] |
[] |
MBPP_Infilling
|
i = i + 1
return None
|
[
[
"2, 3, 7",
"(2, 1)"
],
[
"4, 2, 7",
null
],
[
"1, 13, 17",
"(4, 1)"
]
] |
find_solution
|
[] |
Write a function that returns integers x and y that satisfy ax + by = n as a tuple, or return None if no solution exists.
|
def find_solution(a, b, n):
"""Write a function that returns integers x and y that satisfy ax + by = n as a tuple, or return None if no solution exists. """
i = 0
while i * a <= n:
if (n - i * a) % b == 0:
|
return (i, (n - i * a) // b)
|
code_infilling
|
python
|
python
|
MBPP/160/L5
|
[] |
[] |
MBPP_Infilling
|
return None
|
[
[
"2, 3, 7",
"(2, 1)"
],
[
"4, 2, 7",
null
],
[
"1, 13, 17",
"(4, 1)"
]
] |
find_solution
|
[] |
Write a function that returns integers x and y that satisfy ax + by = n as a tuple, or return None if no solution exists.
|
def find_solution(a, b, n):
"""Write a function that returns integers x and y that satisfy ax + by = n as a tuple, or return None if no solution exists. """
i = 0
while i * a <= n:
if (n - i * a) % b == 0:
return (i, (n - i * a) // b)
|
i = i + 1
|
code_infilling
|
python
|
python
|
MBPP/160/L6
|
[] |
[] |
MBPP_Infilling
|
[
[
"2, 3, 7",
"(2, 1)"
],
[
"4, 2, 7",
null
],
[
"1, 13, 17",
"(4, 1)"
]
] |
find_solution
|
[] |
Write a function that returns integers x and y that satisfy ax + by = n as a tuple, or return None if no solution exists.
|
def find_solution(a, b, n):
"""Write a function that returns integers x and y that satisfy ax + by = n as a tuple, or return None if no solution exists. """
i = 0
while i * a <= n:
if (n - i * a) % b == 0:
return (i, (n - i * a) // b)
i = i + 1
|
return None
|
|
code_infilling
|
python
|
python
|
MBPP/161/L1
|
[] |
[] |
MBPP_Infilling
|
return result
|
[
[
"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 4, 6, 8]",
"[1, 3, 5, 7, 9, 10]"
],
[
"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 3, 5, 7]",
"[2, 4, 6, 8, 9, 10]"
],
[
"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [5, 7]",
"[1, 2, 3, 4, 6, 8, 9, 10]"
]
] |
remove_elements
|
[] |
Write a function to remove all elements from a given list present in another list.
|
def remove_elements(list1, list2):
"""Write a function to remove all elements from a given list present in another list. """
|
result = [x for x in list1 if x not in list2]
|
code_infilling
|
python
|
python
|
MBPP/161/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 4, 6, 8]",
"[1, 3, 5, 7, 9, 10]"
],
[
"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 3, 5, 7]",
"[2, 4, 6, 8, 9, 10]"
],
[
"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [5, 7]",
"[1, 2, 3, 4, 6, 8, 9, 10]"
]
] |
remove_elements
|
[] |
Write a function to remove all elements from a given list present in another list.
|
def remove_elements(list1, list2):
"""Write a function to remove all elements from a given list present in another list. """
result = [x for x in list1 if x not in list2]
|
return result
|
|
code_infilling
|
python
|
python
|
MBPP/162/L1
|
[] |
[] |
MBPP_Infilling
|
return 0
else:
return n + sum_series(n - 2)
|
[
[
"6",
"12"
],
[
"10",
"30"
],
[
"9",
"25"
]
] |
sum_series
|
[] |
Write a function to calculate the sum (n - 2*i) from i=0 to n // 2, for instance n + (n-2) + (n-4)... (until n-x =< 0).
|
def sum_series(n):
"""Write a function to calculate the sum (n - 2*i) from i=0 to n // 2, for instance n + (n-2) + (n-4)... (until n-x =< 0). """
|
if n < 1:
|
code_infilling
|
python
|
python
|
MBPP/162/L2
|
[] |
[] |
MBPP_Infilling
|
else:
return n + sum_series(n - 2)
|
[
[
"6",
"12"
],
[
"10",
"30"
],
[
"9",
"25"
]
] |
sum_series
|
[] |
Write a function to calculate the sum (n - 2*i) from i=0 to n // 2, for instance n + (n-2) + (n-4)... (until n-x =< 0).
|
def sum_series(n):
"""Write a function to calculate the sum (n - 2*i) from i=0 to n // 2, for instance n + (n-2) + (n-4)... (until n-x =< 0). """
if n < 1:
|
return 0
|
code_infilling
|
python
|
python
|
MBPP/162/L3
|
[] |
[] |
MBPP_Infilling
|
return n + sum_series(n - 2)
|
[
[
"6",
"12"
],
[
"10",
"30"
],
[
"9",
"25"
]
] |
sum_series
|
[] |
Write a function to calculate the sum (n - 2*i) from i=0 to n // 2, for instance n + (n-2) + (n-4)... (until n-x =< 0).
|
def sum_series(n):
"""Write a function to calculate the sum (n - 2*i) from i=0 to n // 2, for instance n + (n-2) + (n-4)... (until n-x =< 0). """
if n < 1:
return 0
|
else:
|
code_infilling
|
python
|
python
|
MBPP/162/L4
|
[] |
[] |
MBPP_Infilling
|
[
[
"6",
"12"
],
[
"10",
"30"
],
[
"9",
"25"
]
] |
sum_series
|
[] |
Write a function to calculate the sum (n - 2*i) from i=0 to n // 2, for instance n + (n-2) + (n-4)... (until n-x =< 0).
|
def sum_series(n):
"""Write a function to calculate the sum (n - 2*i) from i=0 to n // 2, for instance n + (n-2) + (n-4)... (until n-x =< 0). """
if n < 1:
return 0
else:
|
return n + sum_series(n - 2)
|
|
code_infilling
|
python
|
python
|
MBPP/163/L3
|
[] |
[] |
MBPP_Infilling
|
return area
|
[] |
area_polygon
|
[
"from math import tan, pi"
] |
Write a function to calculate the area of a regular polygon given the length and number of its sides.
|
from math import tan, pi
def area_polygon(s, l):
"""Write a function to calculate the area of a regular polygon given the length and number of its sides. """
|
area = s * l ** 2 / (4 * tan(pi / s))
|
code_infilling
|
python
|
python
|
MBPP/163/L4
|
[] |
[] |
MBPP_Infilling
|
[] |
area_polygon
|
[
"from math import tan, pi"
] |
Write a function to calculate the area of a regular polygon given the length and number of its sides.
|
from math import tan, pi
def area_polygon(s, l):
"""Write a function to calculate the area of a regular polygon given the length and number of its sides. """
area = s * l ** 2 / (4 * tan(pi / s))
|
return area
|
|
code_infilling
|
python
|
python
|
MBPP/164/L12
|
[] |
[] |
MBPP_Infilling
|
[
[
"36, 57",
"False"
],
[
"2, 4",
"False"
],
[
"23, 47",
"True"
]
] |
are_equivalent
|
[
"import math "
] |
Write a function to determine if the sum of the divisors of two integers are the same.
|
import math
def div_sum(n):
total = 1
i = 2
while i * i <= n:
if n % i == 0:
total = total + i + math.floor(n / i)
i += 1
return total
def are_equivalent(num1, num2):
"""Write a function to determine if the sum of the divisors of two integers are the same. """
|
return div_sum(num1) == div_sum(num2)
|
|
code_infilling
|
python
|
python
|
MBPP/165/L1
|
[] |
[] |
MBPP_Infilling
|
for i in range(len(str1)):
if i == ord(str1[i]) - ord('A') or i == ord(str1[i]) - ord('a'):
count_chars += 1
return count_chars
|
[
[
"\"xbcefg\"",
"2"
],
[
"\"ABcED\"",
"3"
],
[
"\"AbgdeF\"",
"5"
]
] |
count_char_position
|
[] |
Write a function to count the number of characters in a string that occur at the same position in the string as in the English alphabet (case insensitive).
|
def count_char_position(str1):
"""Write a function to count the number of characters in a string that occur at the same position in the string as in the English alphabet (case insensitive). """
|
count_chars = 0
|
code_infilling
|
python
|
python
|
MBPP/165/L2
|
[] |
[] |
MBPP_Infilling
|
if i == ord(str1[i]) - ord('A') or i == ord(str1[i]) - ord('a'):
count_chars += 1
return count_chars
|
[
[
"\"xbcefg\"",
"2"
],
[
"\"ABcED\"",
"3"
],
[
"\"AbgdeF\"",
"5"
]
] |
count_char_position
|
[] |
Write a function to count the number of characters in a string that occur at the same position in the string as in the English alphabet (case insensitive).
|
def count_char_position(str1):
"""Write a function to count the number of characters in a string that occur at the same position in the string as in the English alphabet (case insensitive). """
count_chars = 0
|
for i in range(len(str1)):
|
code_infilling
|
python
|
python
|
MBPP/165/L3
|
[] |
[] |
MBPP_Infilling
|
count_chars += 1
return count_chars
|
[
[
"\"xbcefg\"",
"2"
],
[
"\"ABcED\"",
"3"
],
[
"\"AbgdeF\"",
"5"
]
] |
count_char_position
|
[] |
Write a function to count the number of characters in a string that occur at the same position in the string as in the English alphabet (case insensitive).
|
def count_char_position(str1):
"""Write a function to count the number of characters in a string that occur at the same position in the string as in the English alphabet (case insensitive). """
count_chars = 0
for i in range(len(str1)):
|
if i == ord(str1[i]) - ord('A') or i == ord(str1[i]) - ord('a'):
|
code_infilling
|
python
|
python
|
MBPP/165/L4
|
[] |
[] |
MBPP_Infilling
|
return count_chars
|
[
[
"\"xbcefg\"",
"2"
],
[
"\"ABcED\"",
"3"
],
[
"\"AbgdeF\"",
"5"
]
] |
count_char_position
|
[] |
Write a function to count the number of characters in a string that occur at the same position in the string as in the English alphabet (case insensitive).
|
def count_char_position(str1):
"""Write a function to count the number of characters in a string that occur at the same position in the string as in the English alphabet (case insensitive). """
count_chars = 0
for i in range(len(str1)):
if i == ord(str1[i]) - ord('A') or i == ord(str1[i]) - ord('a'):
|
count_chars += 1
|
code_infilling
|
python
|
python
|
MBPP/165/L5
|
[] |
[] |
MBPP_Infilling
|
[
[
"\"xbcefg\"",
"2"
],
[
"\"ABcED\"",
"3"
],
[
"\"AbgdeF\"",
"5"
]
] |
count_char_position
|
[] |
Write a function to count the number of characters in a string that occur at the same position in the string as in the English alphabet (case insensitive).
|
def count_char_position(str1):
"""Write a function to count the number of characters in a string that occur at the same position in the string as in the English alphabet (case insensitive). """
count_chars = 0
for i in range(len(str1)):
if i == ord(str1[i]) - ord('A') or i == ord(str1[i]) - ord('a'):
count_chars += 1
|
return count_chars
|
|
code_infilling
|
python
|
python
|
MBPP/166/L1
|
[] |
[] |
MBPP_Infilling
|
for i in range(0, len(A)):
for j in range(i + 1, len(A)):
if (A[i] ^ A[j]) % 2 == 0:
count += 1
return count
|
[
[
"[5, 4, 7, 2, 1]",
"4"
],
[
"[7, 2, 8, 1, 0, 5, 11]",
"9"
],
[
"[1, 2, 3]",
"1"
]
] |
find_even_pair
|
[] |
Write a function that counts the number of pairs of integers in a list that xor to an even number.
|
def find_even_pair(A):
"""Write a function that counts the number of pairs of integers in a list that xor to an even number. """
|
count = 0
|
code_infilling
|
python
|
python
|
MBPP/166/L2
|
[] |
[] |
MBPP_Infilling
|
for j in range(i + 1, len(A)):
if (A[i] ^ A[j]) % 2 == 0:
count += 1
return count
|
[
[
"[5, 4, 7, 2, 1]",
"4"
],
[
"[7, 2, 8, 1, 0, 5, 11]",
"9"
],
[
"[1, 2, 3]",
"1"
]
] |
find_even_pair
|
[] |
Write a function that counts the number of pairs of integers in a list that xor to an even number.
|
def find_even_pair(A):
"""Write a function that counts the number of pairs of integers in a list that xor to an even number. """
count = 0
|
for i in range(0, len(A)):
|
code_infilling
|
python
|
python
|
MBPP/166/L3
|
[] |
[] |
MBPP_Infilling
|
if (A[i] ^ A[j]) % 2 == 0:
count += 1
return count
|
[
[
"[5, 4, 7, 2, 1]",
"4"
],
[
"[7, 2, 8, 1, 0, 5, 11]",
"9"
],
[
"[1, 2, 3]",
"1"
]
] |
find_even_pair
|
[] |
Write a function that counts the number of pairs of integers in a list that xor to an even number.
|
def find_even_pair(A):
"""Write a function that counts the number of pairs of integers in a list that xor to an even number. """
count = 0
for i in range(0, len(A)):
|
for j in range(i + 1, len(A)):
|
code_infilling
|
python
|
python
|
MBPP/166/L4
|
[] |
[] |
MBPP_Infilling
|
count += 1
return count
|
[
[
"[5, 4, 7, 2, 1]",
"4"
],
[
"[7, 2, 8, 1, 0, 5, 11]",
"9"
],
[
"[1, 2, 3]",
"1"
]
] |
find_even_pair
|
[] |
Write a function that counts the number of pairs of integers in a list that xor to an even number.
|
def find_even_pair(A):
"""Write a function that counts the number of pairs of integers in a list that xor to an even number. """
count = 0
for i in range(0, len(A)):
for j in range(i + 1, len(A)):
|
if (A[i] ^ A[j]) % 2 == 0:
|
code_infilling
|
python
|
python
|
MBPP/166/L5
|
[] |
[] |
MBPP_Infilling
|
return count
|
[
[
"[5, 4, 7, 2, 1]",
"4"
],
[
"[7, 2, 8, 1, 0, 5, 11]",
"9"
],
[
"[1, 2, 3]",
"1"
]
] |
find_even_pair
|
[] |
Write a function that counts the number of pairs of integers in a list that xor to an even number.
|
def find_even_pair(A):
"""Write a function that counts the number of pairs of integers in a list that xor to an even number. """
count = 0
for i in range(0, len(A)):
for j in range(i + 1, len(A)):
if (A[i] ^ A[j]) % 2 == 0:
|
count += 1
|
code_infilling
|
python
|
python
|
MBPP/166/L6
|
[] |
[] |
MBPP_Infilling
|
[
[
"[5, 4, 7, 2, 1]",
"4"
],
[
"[7, 2, 8, 1, 0, 5, 11]",
"9"
],
[
"[1, 2, 3]",
"1"
]
] |
find_even_pair
|
[] |
Write a function that counts the number of pairs of integers in a list that xor to an even number.
|
def find_even_pair(A):
"""Write a function that counts the number of pairs of integers in a list that xor to an even number. """
count = 0
for i in range(0, len(A)):
for j in range(i + 1, len(A)):
if (A[i] ^ A[j]) % 2 == 0:
count += 1
|
return count
|
|
code_infilling
|
python
|
python
|
MBPP/167/L1
|
[] |
[] |
MBPP_Infilling
|
return n
count = 0
while n != 0:
n >>= 1
count += 1
return 1 << count
|
[
[
"0",
"1"
],
[
"5",
"8"
],
[
"17",
"32"
]
] |
next_power_of_2
|
[] |
Write a python function to find the smallest power of 2 greater than or equal to n.
|
def next_power_of_2(n):
"""Write a python function to find the smallest power of 2 greater than or equal to n. """
|
if n and (not n & n - 1):
|
code_infilling
|
python
|
python
|
MBPP/167/L2
|
[] |
[] |
MBPP_Infilling
|
count = 0
while n != 0:
n >>= 1
count += 1
return 1 << count
|
[
[
"0",
"1"
],
[
"5",
"8"
],
[
"17",
"32"
]
] |
next_power_of_2
|
[] |
Write a python function to find the smallest power of 2 greater than or equal to n.
|
def next_power_of_2(n):
"""Write a python function to find the smallest power of 2 greater than or equal to n. """
if n and (not n & n - 1):
|
return n
|
code_infilling
|
python
|
python
|
MBPP/167/L3
|
[] |
[] |
MBPP_Infilling
|
while n != 0:
n >>= 1
count += 1
return 1 << count
|
[
[
"0",
"1"
],
[
"5",
"8"
],
[
"17",
"32"
]
] |
next_power_of_2
|
[] |
Write a python function to find the smallest power of 2 greater than or equal to n.
|
def next_power_of_2(n):
"""Write a python function to find the smallest power of 2 greater than or equal to n. """
if n and (not n & n - 1):
return n
|
count = 0
|
code_infilling
|
python
|
python
|
MBPP/167/L4
|
[] |
[] |
MBPP_Infilling
|
n >>= 1
count += 1
return 1 << count
|
[
[
"0",
"1"
],
[
"5",
"8"
],
[
"17",
"32"
]
] |
next_power_of_2
|
[] |
Write a python function to find the smallest power of 2 greater than or equal to n.
|
def next_power_of_2(n):
"""Write a python function to find the smallest power of 2 greater than or equal to n. """
if n and (not n & n - 1):
return n
count = 0
|
while n != 0:
|
code_infilling
|
python
|
python
|
MBPP/167/L5
|
[] |
[] |
MBPP_Infilling
|
count += 1
return 1 << count
|
[
[
"0",
"1"
],
[
"5",
"8"
],
[
"17",
"32"
]
] |
next_power_of_2
|
[] |
Write a python function to find the smallest power of 2 greater than or equal to n.
|
def next_power_of_2(n):
"""Write a python function to find the smallest power of 2 greater than or equal to n. """
if n and (not n & n - 1):
return n
count = 0
while n != 0:
|
n >>= 1
|
code_infilling
|
python
|
python
|
MBPP/167/L6
|
[] |
[] |
MBPP_Infilling
|
return 1 << count
|
[
[
"0",
"1"
],
[
"5",
"8"
],
[
"17",
"32"
]
] |
next_power_of_2
|
[] |
Write a python function to find the smallest power of 2 greater than or equal to n.
|
def next_power_of_2(n):
"""Write a python function to find the smallest power of 2 greater than or equal to n. """
if n and (not n & n - 1):
return n
count = 0
while n != 0:
n >>= 1
|
count += 1
|
code_infilling
|
python
|
python
|
MBPP/167/L7
|
[] |
[] |
MBPP_Infilling
|
[
[
"0",
"1"
],
[
"5",
"8"
],
[
"17",
"32"
]
] |
next_power_of_2
|
[] |
Write a python function to find the smallest power of 2 greater than or equal to n.
|
def next_power_of_2(n):
"""Write a python function to find the smallest power of 2 greater than or equal to n. """
if n and (not n & n - 1):
return n
count = 0
while n != 0:
n >>= 1
count += 1
|
return 1 << count
|
|
code_infilling
|
python
|
python
|
MBPP/168/L1
|
[] |
[] |
MBPP_Infilling
|
for i in a:
if i == x:
count += 1
return count
|
[
[
"[1,2,3], 4",
"0"
],
[
"[1,2,2,3,3,3,4], 3",
"3"
],
[
"[0,1,2,3,1,2], 1",
"2"
]
] |
frequency
|
[] |
Write a function to count the number of occurrences of a number in a given list.
|
def frequency(a, x):
"""Write a function to count the number of occurrences of a number in a given list. """
|
count = 0
|
code_infilling
|
python
|
python
|
MBPP/168/L2
|
[] |
[] |
MBPP_Infilling
|
if i == x:
count += 1
return count
|
[
[
"[1,2,3], 4",
"0"
],
[
"[1,2,2,3,3,3,4], 3",
"3"
],
[
"[0,1,2,3,1,2], 1",
"2"
]
] |
frequency
|
[] |
Write a function to count the number of occurrences of a number in a given list.
|
def frequency(a, x):
"""Write a function to count the number of occurrences of a number in a given list. """
count = 0
|
for i in a:
|
code_infilling
|
python
|
python
|
MBPP/168/L3
|
[] |
[] |
MBPP_Infilling
|
count += 1
return count
|
[
[
"[1,2,3], 4",
"0"
],
[
"[1,2,2,3,3,3,4], 3",
"3"
],
[
"[0,1,2,3,1,2], 1",
"2"
]
] |
frequency
|
[] |
Write a function to count the number of occurrences of a number in a given list.
|
def frequency(a, x):
"""Write a function to count the number of occurrences of a number in a given list. """
count = 0
for i in a:
|
if i == x:
|
code_infilling
|
python
|
python
|
MBPP/168/L4
|
[] |
[] |
MBPP_Infilling
|
return count
|
[
[
"[1,2,3], 4",
"0"
],
[
"[1,2,2,3,3,3,4], 3",
"3"
],
[
"[0,1,2,3,1,2], 1",
"2"
]
] |
frequency
|
[] |
Write a function to count the number of occurrences of a number in a given list.
|
def frequency(a, x):
"""Write a function to count the number of occurrences of a number in a given list. """
count = 0
for i in a:
if i == x:
|
count += 1
|
code_infilling
|
python
|
python
|
MBPP/168/L5
|
[] |
[] |
MBPP_Infilling
|
[
[
"[1,2,3], 4",
"0"
],
[
"[1,2,2,3,3,3,4], 3",
"3"
],
[
"[0,1,2,3,1,2], 1",
"2"
]
] |
frequency
|
[] |
Write a function to count the number of occurrences of a number in a given list.
|
def frequency(a, x):
"""Write a function to count the number of occurrences of a number in a given list. """
count = 0
for i in a:
if i == x:
count += 1
|
return count
|
|
code_infilling
|
python
|
python
|
MBPP/170/L1
|
[] |
[] |
MBPP_Infilling
|
for i in range(m, n + 1, 1):
sum_range += list1[i]
return sum_range
|
[
[
"[2,1,5,6,8,3,4,9,10,11,8,12], 8, 10",
"29"
],
[
"[2,1,5,6,8,3,4,9,10,11,8,12], 5, 7",
"16"
],
[
"[2,1,5,6,8,3,4,9,10,11,8,12], 7, 10",
"38"
]
] |
sum_range_list
|
[] |
Write a function to find the sum of numbers in a list within a range specified by two indices.
|
def sum_range_list(list1, m, n):
"""Write a function to find the sum of numbers in a list within a range specified by two indices. """
|
sum_range = 0
|
code_infilling
|
python
|
python
|
MBPP/170/L2
|
[] |
[] |
MBPP_Infilling
|
sum_range += list1[i]
return sum_range
|
[
[
"[2,1,5,6,8,3,4,9,10,11,8,12], 8, 10",
"29"
],
[
"[2,1,5,6,8,3,4,9,10,11,8,12], 5, 7",
"16"
],
[
"[2,1,5,6,8,3,4,9,10,11,8,12], 7, 10",
"38"
]
] |
sum_range_list
|
[] |
Write a function to find the sum of numbers in a list within a range specified by two indices.
|
def sum_range_list(list1, m, n):
"""Write a function to find the sum of numbers in a list within a range specified by two indices. """
sum_range = 0
|
for i in range(m, n + 1, 1):
|
code_infilling
|
python
|
python
|
MBPP/170/L3
|
[] |
[] |
MBPP_Infilling
|
return sum_range
|
[
[
"[2,1,5,6,8,3,4,9,10,11,8,12], 8, 10",
"29"
],
[
"[2,1,5,6,8,3,4,9,10,11,8,12], 5, 7",
"16"
],
[
"[2,1,5,6,8,3,4,9,10,11,8,12], 7, 10",
"38"
]
] |
sum_range_list
|
[] |
Write a function to find the sum of numbers in a list within a range specified by two indices.
|
def sum_range_list(list1, m, n):
"""Write a function to find the sum of numbers in a list within a range specified by two indices. """
sum_range = 0
for i in range(m, n + 1, 1):
|
sum_range += list1[i]
|
code_infilling
|
python
|
python
|
MBPP/170/L4
|
[] |
[] |
MBPP_Infilling
|
[
[
"[2,1,5,6,8,3,4,9,10,11,8,12], 8, 10",
"29"
],
[
"[2,1,5,6,8,3,4,9,10,11,8,12], 5, 7",
"16"
],
[
"[2,1,5,6,8,3,4,9,10,11,8,12], 7, 10",
"38"
]
] |
sum_range_list
|
[] |
Write a function to find the sum of numbers in a list within a range specified by two indices.
|
def sum_range_list(list1, m, n):
"""Write a function to find the sum of numbers in a list within a range specified by two indices. """
sum_range = 0
for i in range(m, n + 1, 1):
sum_range += list1[i]
|
return sum_range
|
|
code_infilling
|
python
|
python
|
MBPP/171/L3
|
[] |
[] |
MBPP_Infilling
|
return perimeter
|
[
[
"5",
"25"
],
[
"10",
"50"
],
[
"15",
"75"
]
] |
perimeter_pentagon
|
[
"import math"
] |
Write a function to find the perimeter of a regular pentagon from the length of its sides.
|
import math
def perimeter_pentagon(a):
"""Write a function to find the perimeter of a regular pentagon from the length of its sides. """
|
perimeter = 5 * a
|
code_infilling
|
python
|
python
|
MBPP/171/L4
|
[] |
[] |
MBPP_Infilling
|
[
[
"5",
"25"
],
[
"10",
"50"
],
[
"15",
"75"
]
] |
perimeter_pentagon
|
[
"import math"
] |
Write a function to find the perimeter of a regular pentagon from the length of its sides.
|
import math
def perimeter_pentagon(a):
"""Write a function to find the perimeter of a regular pentagon from the length of its sides. """
perimeter = 5 * a
|
return perimeter
|
|
code_infilling
|
python
|
python
|
MBPP/172/L1
|
[] |
[] |
MBPP_Infilling
|
for i in range(len(s) - 2):
if s[i] == 's' and s[i + 1] == 't' and (s[i + 2] == 'd'):
count = count + 1
return count
|
[
[
"\"letstdlenstdporstd\"",
"3"
],
[
"\"truststdsolensporsd\"",
"1"
],
[
"\"makestdsostdworthit\"",
"2"
],
[
"\"stds\"",
"1"
],
[
"\"\"",
"0"
]
] |
count_occurance
|
[] |
Write a function to count the number of occurence of the string 'std' in a given string.
|
def count_occurance(s):
"""Write a function to count the number of occurence of the string 'std' in a given string. """
|
count = 0
|
code_infilling
|
python
|
python
|
MBPP/172/L2
|
[] |
[] |
MBPP_Infilling
|
if s[i] == 's' and s[i + 1] == 't' and (s[i + 2] == 'd'):
count = count + 1
return count
|
[
[
"\"letstdlenstdporstd\"",
"3"
],
[
"\"truststdsolensporsd\"",
"1"
],
[
"\"makestdsostdworthit\"",
"2"
],
[
"\"stds\"",
"1"
],
[
"\"\"",
"0"
]
] |
count_occurance
|
[] |
Write a function to count the number of occurence of the string 'std' in a given string.
|
def count_occurance(s):
"""Write a function to count the number of occurence of the string 'std' in a given string. """
count = 0
|
for i in range(len(s) - 2):
|
code_infilling
|
python
|
python
|
MBPP/172/L3
|
[] |
[] |
MBPP_Infilling
|
count = count + 1
return count
|
[
[
"\"letstdlenstdporstd\"",
"3"
],
[
"\"truststdsolensporsd\"",
"1"
],
[
"\"makestdsostdworthit\"",
"2"
],
[
"\"stds\"",
"1"
],
[
"\"\"",
"0"
]
] |
count_occurance
|
[] |
Write a function to count the number of occurence of the string 'std' in a given string.
|
def count_occurance(s):
"""Write a function to count the number of occurence of the string 'std' in a given string. """
count = 0
for i in range(len(s) - 2):
|
if s[i] == 's' and s[i + 1] == 't' and (s[i + 2] == 'd'):
|
code_infilling
|
python
|
python
|
MBPP/172/L4
|
[] |
[] |
MBPP_Infilling
|
return count
|
[
[
"\"letstdlenstdporstd\"",
"3"
],
[
"\"truststdsolensporsd\"",
"1"
],
[
"\"makestdsostdworthit\"",
"2"
],
[
"\"stds\"",
"1"
],
[
"\"\"",
"0"
]
] |
count_occurance
|
[] |
Write a function to count the number of occurence of the string 'std' in a given string.
|
def count_occurance(s):
"""Write a function to count the number of occurence of the string 'std' in a given string. """
count = 0
for i in range(len(s) - 2):
if s[i] == 's' and s[i + 1] == 't' and (s[i + 2] == 'd'):
|
count = count + 1
|
code_infilling
|
python
|
python
|
MBPP/172/L5
|
[] |
[] |
MBPP_Infilling
|
[
[
"\"letstdlenstdporstd\"",
"3"
],
[
"\"truststdsolensporsd\"",
"1"
],
[
"\"makestdsostdworthit\"",
"2"
],
[
"\"stds\"",
"1"
],
[
"\"\"",
"0"
]
] |
count_occurance
|
[] |
Write a function to count the number of occurence of the string 'std' in a given string.
|
def count_occurance(s):
"""Write a function to count the number of occurence of the string 'std' in a given string. """
count = 0
for i in range(len(s) - 2):
if s[i] == 's' and s[i + 1] == 't' and (s[i + 2] == 'd'):
count = count + 1
|
return count
|
|
code_infilling
|
python
|
python
|
MBPP/222/L1
|
[] |
[] |
MBPP_Infilling
|
for ele in test_tuple:
if not isinstance(ele, type(test_tuple[0])):
res = False
break
return res
|
[
[
"(5, 6, 7, 3, 5, 6) ",
"True"
],
[
"(1, 2, \"4\") ",
"False"
],
[
"(3, 2, 1, 4, 5) ",
"True"
]
] |
check_type
|
[] |
Write a function to check if all the elements in tuple have same data type or not.
|
def check_type(test_tuple):
"""Write a function to check if all the elements in tuple have same data type or not. """
|
res = True
|
code_infilling
|
python
|
python
|
MBPP/222/L2
|
[] |
[] |
MBPP_Infilling
|
if not isinstance(ele, type(test_tuple[0])):
res = False
break
return res
|
[
[
"(5, 6, 7, 3, 5, 6) ",
"True"
],
[
"(1, 2, \"4\") ",
"False"
],
[
"(3, 2, 1, 4, 5) ",
"True"
]
] |
check_type
|
[] |
Write a function to check if all the elements in tuple have same data type or not.
|
def check_type(test_tuple):
"""Write a function to check if all the elements in tuple have same data type or not. """
res = True
|
for ele in test_tuple:
|
code_infilling
|
python
|
python
|
MBPP/222/L3
|
[] |
[] |
MBPP_Infilling
|
res = False
break
return res
|
[
[
"(5, 6, 7, 3, 5, 6) ",
"True"
],
[
"(1, 2, \"4\") ",
"False"
],
[
"(3, 2, 1, 4, 5) ",
"True"
]
] |
check_type
|
[] |
Write a function to check if all the elements in tuple have same data type or not.
|
def check_type(test_tuple):
"""Write a function to check if all the elements in tuple have same data type or not. """
res = True
for ele in test_tuple:
|
if not isinstance(ele, type(test_tuple[0])):
|
code_infilling
|
python
|
python
|
MBPP/222/L4
|
[] |
[] |
MBPP_Infilling
|
break
return res
|
[
[
"(5, 6, 7, 3, 5, 6) ",
"True"
],
[
"(1, 2, \"4\") ",
"False"
],
[
"(3, 2, 1, 4, 5) ",
"True"
]
] |
check_type
|
[] |
Write a function to check if all the elements in tuple have same data type or not.
|
def check_type(test_tuple):
"""Write a function to check if all the elements in tuple have same data type or not. """
res = True
for ele in test_tuple:
if not isinstance(ele, type(test_tuple[0])):
|
res = False
|
code_infilling
|
python
|
python
|
MBPP/222/L5
|
[] |
[] |
MBPP_Infilling
|
return res
|
[
[
"(5, 6, 7, 3, 5, 6) ",
"True"
],
[
"(1, 2, \"4\") ",
"False"
],
[
"(3, 2, 1, 4, 5) ",
"True"
]
] |
check_type
|
[] |
Write a function to check if all the elements in tuple have same data type or not.
|
def check_type(test_tuple):
"""Write a function to check if all the elements in tuple have same data type or not. """
res = True
for ele in test_tuple:
if not isinstance(ele, type(test_tuple[0])):
res = False
|
break
|
code_infilling
|
python
|
python
|
MBPP/222/L6
|
[] |
[] |
MBPP_Infilling
|
[
[
"(5, 6, 7, 3, 5, 6) ",
"True"
],
[
"(1, 2, \"4\") ",
"False"
],
[
"(3, 2, 1, 4, 5) ",
"True"
]
] |
check_type
|
[] |
Write a function to check if all the elements in tuple have same data type or not.
|
def check_type(test_tuple):
"""Write a function to check if all the elements in tuple have same data type or not. """
res = True
for ele in test_tuple:
if not isinstance(ele, type(test_tuple[0])):
res = False
break
|
return res
|
|
code_infilling
|
python
|
python
|
MBPP/223/L1
|
[] |
[] |
MBPP_Infilling
|
if i == -1:
return False
if i + n // 2 <= n - 1 and arr[i + n // 2] == x:
return True
else:
return False
def binary_search(arr, low, high, x):
if high >= low:
mid = (low + high) // 2
if (mid == 0 or x > arr[mid - 1]) and arr[mid] == x:
return mid
elif x > arr[mid]:
return binary_search(arr, mid + 1, high, x)
else:
return binary_search(arr, low, mid - 1, x)
return -1
|
[
[
"[1, 2, 3, 3, 3, 3, 10], 7, 3",
"True"
],
[
"[1, 1, 2, 4, 4, 4, 6, 6], 8, 4",
"False"
],
[
"[1, 1, 1, 2, 2], 5, 1",
"True"
],
[
"[1, 1, 2, 2], 5, 1",
"False"
]
] |
is_majority
|
[] |
Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.)
|
def is_majority(arr, n, x):
"""Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.) """
|
i = binary_search(arr, 0, n - 1, x)
|
code_infilling
|
python
|
python
|
MBPP/223/L2
|
[] |
[] |
MBPP_Infilling
|
return False
if i + n // 2 <= n - 1 and arr[i + n // 2] == x:
return True
else:
return False
def binary_search(arr, low, high, x):
if high >= low:
mid = (low + high) // 2
if (mid == 0 or x > arr[mid - 1]) and arr[mid] == x:
return mid
elif x > arr[mid]:
return binary_search(arr, mid + 1, high, x)
else:
return binary_search(arr, low, mid - 1, x)
return -1
|
[
[
"[1, 2, 3, 3, 3, 3, 10], 7, 3",
"True"
],
[
"[1, 1, 2, 4, 4, 4, 6, 6], 8, 4",
"False"
],
[
"[1, 1, 1, 2, 2], 5, 1",
"True"
],
[
"[1, 1, 2, 2], 5, 1",
"False"
]
] |
is_majority
|
[] |
Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.)
|
def is_majority(arr, n, x):
"""Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.) """
i = binary_search(arr, 0, n - 1, x)
|
if i == -1:
|
code_infilling
|
python
|
python
|
MBPP/223/L3
|
[] |
[] |
MBPP_Infilling
|
if i + n // 2 <= n - 1 and arr[i + n // 2] == x:
return True
else:
return False
def binary_search(arr, low, high, x):
if high >= low:
mid = (low + high) // 2
if (mid == 0 or x > arr[mid - 1]) and arr[mid] == x:
return mid
elif x > arr[mid]:
return binary_search(arr, mid + 1, high, x)
else:
return binary_search(arr, low, mid - 1, x)
return -1
|
[
[
"[1, 2, 3, 3, 3, 3, 10], 7, 3",
"True"
],
[
"[1, 1, 2, 4, 4, 4, 6, 6], 8, 4",
"False"
],
[
"[1, 1, 1, 2, 2], 5, 1",
"True"
],
[
"[1, 1, 2, 2], 5, 1",
"False"
]
] |
is_majority
|
[] |
Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.)
|
def is_majority(arr, n, x):
"""Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.) """
i = binary_search(arr, 0, n - 1, x)
if i == -1:
|
return False
|
code_infilling
|
python
|
python
|
MBPP/223/L4
|
[] |
[] |
MBPP_Infilling
|
return True
else:
return False
def binary_search(arr, low, high, x):
if high >= low:
mid = (low + high) // 2
if (mid == 0 or x > arr[mid - 1]) and arr[mid] == x:
return mid
elif x > arr[mid]:
return binary_search(arr, mid + 1, high, x)
else:
return binary_search(arr, low, mid - 1, x)
return -1
|
[
[
"[1, 2, 3, 3, 3, 3, 10], 7, 3",
"True"
],
[
"[1, 1, 2, 4, 4, 4, 6, 6], 8, 4",
"False"
],
[
"[1, 1, 1, 2, 2], 5, 1",
"True"
],
[
"[1, 1, 2, 2], 5, 1",
"False"
]
] |
is_majority
|
[] |
Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.)
|
def is_majority(arr, n, x):
"""Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.) """
i = binary_search(arr, 0, n - 1, x)
if i == -1:
return False
|
if i + n // 2 <= n - 1 and arr[i + n // 2] == x:
|
code_infilling
|
python
|
python
|
MBPP/223/L5
|
[] |
[] |
MBPP_Infilling
|
else:
return False
def binary_search(arr, low, high, x):
if high >= low:
mid = (low + high) // 2
if (mid == 0 or x > arr[mid - 1]) and arr[mid] == x:
return mid
elif x > arr[mid]:
return binary_search(arr, mid + 1, high, x)
else:
return binary_search(arr, low, mid - 1, x)
return -1
|
[
[
"[1, 2, 3, 3, 3, 3, 10], 7, 3",
"True"
],
[
"[1, 1, 2, 4, 4, 4, 6, 6], 8, 4",
"False"
],
[
"[1, 1, 1, 2, 2], 5, 1",
"True"
],
[
"[1, 1, 2, 2], 5, 1",
"False"
]
] |
is_majority
|
[] |
Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.)
|
def is_majority(arr, n, x):
"""Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.) """
i = binary_search(arr, 0, n - 1, x)
if i == -1:
return False
if i + n // 2 <= n - 1 and arr[i + n // 2] == x:
|
return True
|
code_infilling
|
python
|
python
|
MBPP/223/L6
|
[] |
[] |
MBPP_Infilling
|
return False
def binary_search(arr, low, high, x):
if high >= low:
mid = (low + high) // 2
if (mid == 0 or x > arr[mid - 1]) and arr[mid] == x:
return mid
elif x > arr[mid]:
return binary_search(arr, mid + 1, high, x)
else:
return binary_search(arr, low, mid - 1, x)
return -1
|
[
[
"[1, 2, 3, 3, 3, 3, 10], 7, 3",
"True"
],
[
"[1, 1, 2, 4, 4, 4, 6, 6], 8, 4",
"False"
],
[
"[1, 1, 1, 2, 2], 5, 1",
"True"
],
[
"[1, 1, 2, 2], 5, 1",
"False"
]
] |
is_majority
|
[] |
Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.)
|
def is_majority(arr, n, x):
"""Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.) """
i = binary_search(arr, 0, n - 1, x)
if i == -1:
return False
if i + n // 2 <= n - 1 and arr[i + n // 2] == x:
return True
|
else:
|
code_infilling
|
python
|
python
|
MBPP/223/L7
|
[] |
[] |
MBPP_Infilling
|
def binary_search(arr, low, high, x):
if high >= low:
mid = (low + high) // 2
if (mid == 0 or x > arr[mid - 1]) and arr[mid] == x:
return mid
elif x > arr[mid]:
return binary_search(arr, mid + 1, high, x)
else:
return binary_search(arr, low, mid - 1, x)
return -1
|
[
[
"[1, 2, 3, 3, 3, 3, 10], 7, 3",
"True"
],
[
"[1, 1, 2, 4, 4, 4, 6, 6], 8, 4",
"False"
],
[
"[1, 1, 1, 2, 2], 5, 1",
"True"
],
[
"[1, 1, 2, 2], 5, 1",
"False"
]
] |
is_majority
|
[] |
Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.)
|
def is_majority(arr, n, x):
"""Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.) """
i = binary_search(arr, 0, n - 1, x)
if i == -1:
return False
if i + n // 2 <= n - 1 and arr[i + n // 2] == x:
return True
else:
|
return False
|
code_infilling
|
python
|
python
|
MBPP/223/L9
|
[] |
[] |
MBPP_Infilling
|
if high >= low:
mid = (low + high) // 2
if (mid == 0 or x > arr[mid - 1]) and arr[mid] == x:
return mid
elif x > arr[mid]:
return binary_search(arr, mid + 1, high, x)
else:
return binary_search(arr, low, mid - 1, x)
return -1
|
[
[
"[1, 2, 3, 3, 3, 3, 10], 7, 3",
"True"
],
[
"[1, 1, 2, 4, 4, 4, 6, 6], 8, 4",
"False"
],
[
"[1, 1, 1, 2, 2], 5, 1",
"True"
],
[
"[1, 1, 2, 2], 5, 1",
"False"
]
] |
is_majority
|
[] |
Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.)
|
def is_majority(arr, n, x):
"""Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.) """
i = binary_search(arr, 0, n - 1, x)
if i == -1:
return False
if i + n // 2 <= n - 1 and arr[i + n // 2] == x:
return True
else:
return False
|
def binary_search(arr, low, high, x):
|
code_infilling
|
python
|
python
|
MBPP/223/L10
|
[] |
[] |
MBPP_Infilling
|
mid = (low + high) // 2
if (mid == 0 or x > arr[mid - 1]) and arr[mid] == x:
return mid
elif x > arr[mid]:
return binary_search(arr, mid + 1, high, x)
else:
return binary_search(arr, low, mid - 1, x)
return -1
|
[
[
"[1, 2, 3, 3, 3, 3, 10], 7, 3",
"True"
],
[
"[1, 1, 2, 4, 4, 4, 6, 6], 8, 4",
"False"
],
[
"[1, 1, 1, 2, 2], 5, 1",
"True"
],
[
"[1, 1, 2, 2], 5, 1",
"False"
]
] |
is_majority
|
[] |
Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.)
|
def is_majority(arr, n, x):
"""Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.) """
i = binary_search(arr, 0, n - 1, x)
if i == -1:
return False
if i + n // 2 <= n - 1 and arr[i + n // 2] == x:
return True
else:
return False
def binary_search(arr, low, high, x):
|
if high >= low:
|
code_infilling
|
python
|
python
|
MBPP/223/L11
|
[] |
[] |
MBPP_Infilling
|
if (mid == 0 or x > arr[mid - 1]) and arr[mid] == x:
return mid
elif x > arr[mid]:
return binary_search(arr, mid + 1, high, x)
else:
return binary_search(arr, low, mid - 1, x)
return -1
|
[
[
"[1, 2, 3, 3, 3, 3, 10], 7, 3",
"True"
],
[
"[1, 1, 2, 4, 4, 4, 6, 6], 8, 4",
"False"
],
[
"[1, 1, 1, 2, 2], 5, 1",
"True"
],
[
"[1, 1, 2, 2], 5, 1",
"False"
]
] |
is_majority
|
[] |
Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.)
|
def is_majority(arr, n, x):
"""Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.) """
i = binary_search(arr, 0, n - 1, x)
if i == -1:
return False
if i + n // 2 <= n - 1 and arr[i + n // 2] == x:
return True
else:
return False
def binary_search(arr, low, high, x):
if high >= low:
|
mid = (low + high) // 2
|
code_infilling
|
python
|
python
|
MBPP/223/L12
|
[] |
[] |
MBPP_Infilling
|
return mid
elif x > arr[mid]:
return binary_search(arr, mid + 1, high, x)
else:
return binary_search(arr, low, mid - 1, x)
return -1
|
[
[
"[1, 2, 3, 3, 3, 3, 10], 7, 3",
"True"
],
[
"[1, 1, 2, 4, 4, 4, 6, 6], 8, 4",
"False"
],
[
"[1, 1, 1, 2, 2], 5, 1",
"True"
],
[
"[1, 1, 2, 2], 5, 1",
"False"
]
] |
is_majority
|
[] |
Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.)
|
def is_majority(arr, n, x):
"""Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.) """
i = binary_search(arr, 0, n - 1, x)
if i == -1:
return False
if i + n // 2 <= n - 1 and arr[i + n // 2] == x:
return True
else:
return False
def binary_search(arr, low, high, x):
if high >= low:
mid = (low + high) // 2
|
if (mid == 0 or x > arr[mid - 1]) and arr[mid] == x:
|
code_infilling
|
python
|
python
|
MBPP/223/L13
|
[] |
[] |
MBPP_Infilling
|
elif x > arr[mid]:
return binary_search(arr, mid + 1, high, x)
else:
return binary_search(arr, low, mid - 1, x)
return -1
|
[
[
"[1, 2, 3, 3, 3, 3, 10], 7, 3",
"True"
],
[
"[1, 1, 2, 4, 4, 4, 6, 6], 8, 4",
"False"
],
[
"[1, 1, 1, 2, 2], 5, 1",
"True"
],
[
"[1, 1, 2, 2], 5, 1",
"False"
]
] |
is_majority
|
[] |
Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.)
|
def is_majority(arr, n, x):
"""Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.) """
i = binary_search(arr, 0, n - 1, x)
if i == -1:
return False
if i + n // 2 <= n - 1 and arr[i + n // 2] == x:
return True
else:
return False
def binary_search(arr, low, high, x):
if high >= low:
mid = (low + high) // 2
if (mid == 0 or x > arr[mid - 1]) and arr[mid] == x:
|
return mid
|
code_infilling
|
python
|
python
|
MBPP/223/L14
|
[] |
[] |
MBPP_Infilling
|
return binary_search(arr, mid + 1, high, x)
else:
return binary_search(arr, low, mid - 1, x)
return -1
|
[
[
"[1, 2, 3, 3, 3, 3, 10], 7, 3",
"True"
],
[
"[1, 1, 2, 4, 4, 4, 6, 6], 8, 4",
"False"
],
[
"[1, 1, 1, 2, 2], 5, 1",
"True"
],
[
"[1, 1, 2, 2], 5, 1",
"False"
]
] |
is_majority
|
[] |
Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.)
|
def is_majority(arr, n, x):
"""Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.) """
i = binary_search(arr, 0, n - 1, x)
if i == -1:
return False
if i + n // 2 <= n - 1 and arr[i + n // 2] == x:
return True
else:
return False
def binary_search(arr, low, high, x):
if high >= low:
mid = (low + high) // 2
if (mid == 0 or x > arr[mid - 1]) and arr[mid] == x:
return mid
|
elif x > arr[mid]:
|
code_infilling
|
python
|
python
|
MBPP/223/L15
|
[] |
[] |
MBPP_Infilling
|
else:
return binary_search(arr, low, mid - 1, x)
return -1
|
[
[
"[1, 2, 3, 3, 3, 3, 10], 7, 3",
"True"
],
[
"[1, 1, 2, 4, 4, 4, 6, 6], 8, 4",
"False"
],
[
"[1, 1, 1, 2, 2], 5, 1",
"True"
],
[
"[1, 1, 2, 2], 5, 1",
"False"
]
] |
is_majority
|
[] |
Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.)
|
def is_majority(arr, n, x):
"""Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.) """
i = binary_search(arr, 0, n - 1, x)
if i == -1:
return False
if i + n // 2 <= n - 1 and arr[i + n // 2] == x:
return True
else:
return False
def binary_search(arr, low, high, x):
if high >= low:
mid = (low + high) // 2
if (mid == 0 or x > arr[mid - 1]) and arr[mid] == x:
return mid
elif x > arr[mid]:
|
return binary_search(arr, mid + 1, high, x)
|
code_infilling
|
python
|
python
|
MBPP/223/L16
|
[] |
[] |
MBPP_Infilling
|
return binary_search(arr, low, mid - 1, x)
return -1
|
[
[
"[1, 2, 3, 3, 3, 3, 10], 7, 3",
"True"
],
[
"[1, 1, 2, 4, 4, 4, 6, 6], 8, 4",
"False"
],
[
"[1, 1, 1, 2, 2], 5, 1",
"True"
],
[
"[1, 1, 2, 2], 5, 1",
"False"
]
] |
is_majority
|
[] |
Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.)
|
def is_majority(arr, n, x):
"""Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.) """
i = binary_search(arr, 0, n - 1, x)
if i == -1:
return False
if i + n // 2 <= n - 1 and arr[i + n // 2] == x:
return True
else:
return False
def binary_search(arr, low, high, x):
if high >= low:
mid = (low + high) // 2
if (mid == 0 or x > arr[mid - 1]) and arr[mid] == x:
return mid
elif x > arr[mid]:
return binary_search(arr, mid + 1, high, x)
|
else:
|
code_infilling
|
python
|
python
|
MBPP/223/L17
|
[] |
[] |
MBPP_Infilling
|
return -1
|
[
[
"[1, 2, 3, 3, 3, 3, 10], 7, 3",
"True"
],
[
"[1, 1, 2, 4, 4, 4, 6, 6], 8, 4",
"False"
],
[
"[1, 1, 1, 2, 2], 5, 1",
"True"
],
[
"[1, 1, 2, 2], 5, 1",
"False"
]
] |
is_majority
|
[] |
Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.)
|
def is_majority(arr, n, x):
"""Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.) """
i = binary_search(arr, 0, n - 1, x)
if i == -1:
return False
if i + n // 2 <= n - 1 and arr[i + n // 2] == x:
return True
else:
return False
def binary_search(arr, low, high, x):
if high >= low:
mid = (low + high) // 2
if (mid == 0 or x > arr[mid - 1]) and arr[mid] == x:
return mid
elif x > arr[mid]:
return binary_search(arr, mid + 1, high, x)
else:
|
return binary_search(arr, low, mid - 1, x)
|
code_infilling
|
python
|
python
|
MBPP/223/L18
|
[] |
[] |
MBPP_Infilling
|
[
[
"[1, 2, 3, 3, 3, 3, 10], 7, 3",
"True"
],
[
"[1, 1, 2, 4, 4, 4, 6, 6], 8, 4",
"False"
],
[
"[1, 1, 1, 2, 2], 5, 1",
"True"
],
[
"[1, 1, 2, 2], 5, 1",
"False"
]
] |
is_majority
|
[] |
Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.)
|
def is_majority(arr, n, x):
"""Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.) """
i = binary_search(arr, 0, n - 1, x)
if i == -1:
return False
if i + n // 2 <= n - 1 and arr[i + n // 2] == x:
return True
else:
return False
def binary_search(arr, low, high, x):
if high >= low:
mid = (low + high) // 2
if (mid == 0 or x > arr[mid - 1]) and arr[mid] == x:
return mid
elif x > arr[mid]:
return binary_search(arr, mid + 1, high, x)
else:
return binary_search(arr, low, mid - 1, x)
|
return -1
|
|
code_infilling
|
python
|
python
|
MBPP/224/L1
|
[] |
[] |
MBPP_Infilling
|
while n:
count += n & 1
n >>= 1
return count
|
[
[
"2",
"1"
],
[
"4",
"1"
],
[
"6",
"2"
]
] |
count_Set_Bits
|
[] |
Write a python function to count the number of set bits (binary digits with value 1) in a given number.
|
def count_Set_Bits(n):
"""Write a python function to count the number of set bits (binary digits with value 1) in a given number. """
|
count = 0
|
code_infilling
|
python
|
python
|
MBPP/224/L2
|
[] |
[] |
MBPP_Infilling
|
count += n & 1
n >>= 1
return count
|
[
[
"2",
"1"
],
[
"4",
"1"
],
[
"6",
"2"
]
] |
count_Set_Bits
|
[] |
Write a python function to count the number of set bits (binary digits with value 1) in a given number.
|
def count_Set_Bits(n):
"""Write a python function to count the number of set bits (binary digits with value 1) in a given number. """
count = 0
|
while n:
|
code_infilling
|
python
|
python
|
MBPP/224/L3
|
[] |
[] |
MBPP_Infilling
|
n >>= 1
return count
|
[
[
"2",
"1"
],
[
"4",
"1"
],
[
"6",
"2"
]
] |
count_Set_Bits
|
[] |
Write a python function to count the number of set bits (binary digits with value 1) in a given number.
|
def count_Set_Bits(n):
"""Write a python function to count the number of set bits (binary digits with value 1) in a given number. """
count = 0
while n:
|
count += n & 1
|
code_infilling
|
python
|
python
|
MBPP/224/L4
|
[] |
[] |
MBPP_Infilling
|
return count
|
[
[
"2",
"1"
],
[
"4",
"1"
],
[
"6",
"2"
]
] |
count_Set_Bits
|
[] |
Write a python function to count the number of set bits (binary digits with value 1) in a given number.
|
def count_Set_Bits(n):
"""Write a python function to count the number of set bits (binary digits with value 1) in a given number. """
count = 0
while n:
count += n & 1
|
n >>= 1
|
code_infilling
|
python
|
python
|
MBPP/224/L5
|
[] |
[] |
MBPP_Infilling
|
[
[
"2",
"1"
],
[
"4",
"1"
],
[
"6",
"2"
]
] |
count_Set_Bits
|
[] |
Write a python function to count the number of set bits (binary digits with value 1) in a given number.
|
def count_Set_Bits(n):
"""Write a python function to count the number of set bits (binary digits with value 1) in a given number. """
count = 0
while n:
count += n & 1
n >>= 1
|
return count
|
|
code_infilling
|
python
|
python
|
MBPP/226/L1
|
[] |
[] |
MBPP_Infilling
|
for i in range(len(str)):
if i % 2 == 0:
result = result + str[i]
return result
|
[
[
"'abcdef'",
"'ace'"
],
[
"'python'",
"'pto'"
],
[
"'data'",
"'dt'"
],
[
"'lambs'",
"'lms'"
]
] |
odd_values_string
|
[] |
Write a python function to remove the characters which have odd index values of a given string.
|
def odd_values_string(str):
"""Write a python function to remove the characters which have odd index values of a given string. """
|
result = ''
|
code_infilling
|
python
|
python
|
MBPP/226/L2
|
[] |
[] |
MBPP_Infilling
|
if i % 2 == 0:
result = result + str[i]
return result
|
[
[
"'abcdef'",
"'ace'"
],
[
"'python'",
"'pto'"
],
[
"'data'",
"'dt'"
],
[
"'lambs'",
"'lms'"
]
] |
odd_values_string
|
[] |
Write a python function to remove the characters which have odd index values of a given string.
|
def odd_values_string(str):
"""Write a python function to remove the characters which have odd index values of a given string. """
result = ''
|
for i in range(len(str)):
|
code_infilling
|
python
|
python
|
MBPP/226/L3
|
[] |
[] |
MBPP_Infilling
|
result = result + str[i]
return result
|
[
[
"'abcdef'",
"'ace'"
],
[
"'python'",
"'pto'"
],
[
"'data'",
"'dt'"
],
[
"'lambs'",
"'lms'"
]
] |
odd_values_string
|
[] |
Write a python function to remove the characters which have odd index values of a given string.
|
def odd_values_string(str):
"""Write a python function to remove the characters which have odd index values of a given string. """
result = ''
for i in range(len(str)):
|
if i % 2 == 0:
|
code_infilling
|
python
|
python
|
MBPP/226/L4
|
[] |
[] |
MBPP_Infilling
|
return result
|
[
[
"'abcdef'",
"'ace'"
],
[
"'python'",
"'pto'"
],
[
"'data'",
"'dt'"
],
[
"'lambs'",
"'lms'"
]
] |
odd_values_string
|
[] |
Write a python function to remove the characters which have odd index values of a given string.
|
def odd_values_string(str):
"""Write a python function to remove the characters which have odd index values of a given string. """
result = ''
for i in range(len(str)):
if i % 2 == 0:
|
result = result + str[i]
|
code_infilling
|
python
|
python
|
MBPP/226/L5
|
[] |
[] |
MBPP_Infilling
|
[
[
"'abcdef'",
"'ace'"
],
[
"'python'",
"'pto'"
],
[
"'data'",
"'dt'"
],
[
"'lambs'",
"'lms'"
]
] |
odd_values_string
|
[] |
Write a python function to remove the characters which have odd index values of a given string.
|
def odd_values_string(str):
"""Write a python function to remove the characters which have odd index values of a given string. """
result = ''
for i in range(len(str)):
if i % 2 == 0:
result = result + str[i]
|
return result
|
|
code_infilling
|
python
|
python
|
MBPP/227/L1
|
[] |
[] |
MBPP_Infilling
|
smallest = a
elif b <= a and b <= c:
smallest = b
else:
smallest = c
return smallest
|
[
[
"10,20,0",
"0"
],
[
"19,15,18",
"15"
],
[
"-10,-20,-30",
"-30"
]
] |
min_of_three
|
[] |
Write a function to find minimum of three numbers.
|
def min_of_three(a, b, c):
"""Write a function to find minimum of three numbers. """
|
if a <= b and a <= c:
|
code_infilling
|
python
|
python
|
MBPP/227/L2
|
[] |
[] |
MBPP_Infilling
|
elif b <= a and b <= c:
smallest = b
else:
smallest = c
return smallest
|
[
[
"10,20,0",
"0"
],
[
"19,15,18",
"15"
],
[
"-10,-20,-30",
"-30"
]
] |
min_of_three
|
[] |
Write a function to find minimum of three numbers.
|
def min_of_three(a, b, c):
"""Write a function to find minimum of three numbers. """
if a <= b and a <= c:
|
smallest = a
|
code_infilling
|
python
|
python
|
MBPP/227/L3
|
[] |
[] |
MBPP_Infilling
|
smallest = b
else:
smallest = c
return smallest
|
[
[
"10,20,0",
"0"
],
[
"19,15,18",
"15"
],
[
"-10,-20,-30",
"-30"
]
] |
min_of_three
|
[] |
Write a function to find minimum of three numbers.
|
def min_of_three(a, b, c):
"""Write a function to find minimum of three numbers. """
if a <= b and a <= c:
smallest = a
|
elif b <= a and b <= c:
|
code_infilling
|
python
|
python
|
MBPP/227/L4
|
[] |
[] |
MBPP_Infilling
|
else:
smallest = c
return smallest
|
[
[
"10,20,0",
"0"
],
[
"19,15,18",
"15"
],
[
"-10,-20,-30",
"-30"
]
] |
min_of_three
|
[] |
Write a function to find minimum of three numbers.
|
def min_of_three(a, b, c):
"""Write a function to find minimum of three numbers. """
if a <= b and a <= c:
smallest = a
elif b <= a and b <= c:
|
smallest = b
|
code_infilling
|
python
|
python
|
MBPP/227/L5
|
[] |
[] |
MBPP_Infilling
|
smallest = c
return smallest
|
[
[
"10,20,0",
"0"
],
[
"19,15,18",
"15"
],
[
"-10,-20,-30",
"-30"
]
] |
min_of_three
|
[] |
Write a function to find minimum of three numbers.
|
def min_of_three(a, b, c):
"""Write a function to find minimum of three numbers. """
if a <= b and a <= c:
smallest = a
elif b <= a and b <= c:
smallest = b
|
else:
|
code_infilling
|
python
|
python
|
MBPP/227/L6
|
[] |
[] |
MBPP_Infilling
|
return smallest
|
[
[
"10,20,0",
"0"
],
[
"19,15,18",
"15"
],
[
"-10,-20,-30",
"-30"
]
] |
min_of_three
|
[] |
Write a function to find minimum of three numbers.
|
def min_of_three(a, b, c):
"""Write a function to find minimum of three numbers. """
if a <= b and a <= c:
smallest = a
elif b <= a and b <= c:
smallest = b
else:
|
smallest = c
|
code_infilling
|
python
|
python
|
MBPP/227/L7
|
[] |
[] |
MBPP_Infilling
|
[
[
"10,20,0",
"0"
],
[
"19,15,18",
"15"
],
[
"-10,-20,-30",
"-30"
]
] |
min_of_three
|
[] |
Write a function to find minimum of three numbers.
|
def min_of_three(a, b, c):
"""Write a function to find minimum of three numbers. """
if a <= b and a <= c:
smallest = a
elif b <= a and b <= c:
smallest = b
else:
smallest = c
|
return smallest
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.