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/124/L3
|
[] |
[] |
MBPP_Infilling
|
angle = cmath.phase(a + b)
return angle
|
[] |
angle_complex
|
[
"import cmath"
] |
Write a function to get the angle of a complex number.
|
import cmath
def angle_complex(a, b):
"""Write a function to get the angle of a complex number. """
|
cn = complex(a, b)
|
code_infilling
|
python
|
python
|
MBPP/124/L4
|
[] |
[] |
MBPP_Infilling
|
return angle
|
[] |
angle_complex
|
[
"import cmath"
] |
Write a function to get the angle of a complex number.
|
import cmath
def angle_complex(a, b):
"""Write a function to get the angle of a complex number. """
cn = complex(a, b)
|
angle = cmath.phase(a + b)
|
code_infilling
|
python
|
python
|
MBPP/124/L5
|
[] |
[] |
MBPP_Infilling
|
[] |
angle_complex
|
[
"import cmath"
] |
Write a function to get the angle of a complex number.
|
import cmath
def angle_complex(a, b):
"""Write a function to get the angle of a complex number. """
cn = complex(a, b)
angle = cmath.phase(a + b)
|
return angle
|
|
code_infilling
|
python
|
python
|
MBPP/125/L1
|
[] |
[] |
MBPP_Infilling
|
current_sum = 0
max_sum = 0
for i in range(n):
current_sum += 1 if string[i] == '0' else -1
if current_sum < 0:
current_sum = 0
max_sum = max(current_sum, max_sum)
return max_sum if max_sum else 0
|
[
[
"\"11000010001\"",
"6"
],
[
"\"10111\"",
"1"
],
[
"\"11011101100101\"",
"2"
]
] |
find_length
|
[] |
Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string.
|
def find_length(string):
"""Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string. """
|
n = len(string)
|
code_infilling
|
python
|
python
|
MBPP/125/L2
|
[] |
[] |
MBPP_Infilling
|
max_sum = 0
for i in range(n):
current_sum += 1 if string[i] == '0' else -1
if current_sum < 0:
current_sum = 0
max_sum = max(current_sum, max_sum)
return max_sum if max_sum else 0
|
[
[
"\"11000010001\"",
"6"
],
[
"\"10111\"",
"1"
],
[
"\"11011101100101\"",
"2"
]
] |
find_length
|
[] |
Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string.
|
def find_length(string):
"""Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string. """
n = len(string)
|
current_sum = 0
|
code_infilling
|
python
|
python
|
MBPP/125/L3
|
[] |
[] |
MBPP_Infilling
|
for i in range(n):
current_sum += 1 if string[i] == '0' else -1
if current_sum < 0:
current_sum = 0
max_sum = max(current_sum, max_sum)
return max_sum if max_sum else 0
|
[
[
"\"11000010001\"",
"6"
],
[
"\"10111\"",
"1"
],
[
"\"11011101100101\"",
"2"
]
] |
find_length
|
[] |
Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string.
|
def find_length(string):
"""Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string. """
n = len(string)
current_sum = 0
|
max_sum = 0
|
code_infilling
|
python
|
python
|
MBPP/125/L4
|
[] |
[] |
MBPP_Infilling
|
current_sum += 1 if string[i] == '0' else -1
if current_sum < 0:
current_sum = 0
max_sum = max(current_sum, max_sum)
return max_sum if max_sum else 0
|
[
[
"\"11000010001\"",
"6"
],
[
"\"10111\"",
"1"
],
[
"\"11011101100101\"",
"2"
]
] |
find_length
|
[] |
Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string.
|
def find_length(string):
"""Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string. """
n = len(string)
current_sum = 0
max_sum = 0
|
for i in range(n):
|
code_infilling
|
python
|
python
|
MBPP/125/L5
|
[] |
[] |
MBPP_Infilling
|
if current_sum < 0:
current_sum = 0
max_sum = max(current_sum, max_sum)
return max_sum if max_sum else 0
|
[
[
"\"11000010001\"",
"6"
],
[
"\"10111\"",
"1"
],
[
"\"11011101100101\"",
"2"
]
] |
find_length
|
[] |
Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string.
|
def find_length(string):
"""Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string. """
n = len(string)
current_sum = 0
max_sum = 0
for i in range(n):
|
current_sum += 1 if string[i] == '0' else -1
|
code_infilling
|
python
|
python
|
MBPP/125/L6
|
[] |
[] |
MBPP_Infilling
|
current_sum = 0
max_sum = max(current_sum, max_sum)
return max_sum if max_sum else 0
|
[
[
"\"11000010001\"",
"6"
],
[
"\"10111\"",
"1"
],
[
"\"11011101100101\"",
"2"
]
] |
find_length
|
[] |
Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string.
|
def find_length(string):
"""Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string. """
n = len(string)
current_sum = 0
max_sum = 0
for i in range(n):
current_sum += 1 if string[i] == '0' else -1
|
if current_sum < 0:
|
code_infilling
|
python
|
python
|
MBPP/125/L7
|
[] |
[] |
MBPP_Infilling
|
max_sum = max(current_sum, max_sum)
return max_sum if max_sum else 0
|
[
[
"\"11000010001\"",
"6"
],
[
"\"10111\"",
"1"
],
[
"\"11011101100101\"",
"2"
]
] |
find_length
|
[] |
Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string.
|
def find_length(string):
"""Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string. """
n = len(string)
current_sum = 0
max_sum = 0
for i in range(n):
current_sum += 1 if string[i] == '0' else -1
if current_sum < 0:
|
current_sum = 0
|
code_infilling
|
python
|
python
|
MBPP/125/L8
|
[] |
[] |
MBPP_Infilling
|
return max_sum if max_sum else 0
|
[
[
"\"11000010001\"",
"6"
],
[
"\"10111\"",
"1"
],
[
"\"11011101100101\"",
"2"
]
] |
find_length
|
[] |
Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string.
|
def find_length(string):
"""Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string. """
n = len(string)
current_sum = 0
max_sum = 0
for i in range(n):
current_sum += 1 if string[i] == '0' else -1
if current_sum < 0:
current_sum = 0
|
max_sum = max(current_sum, max_sum)
|
code_infilling
|
python
|
python
|
MBPP/125/L9
|
[] |
[] |
MBPP_Infilling
|
[
[
"\"11000010001\"",
"6"
],
[
"\"10111\"",
"1"
],
[
"\"11011101100101\"",
"2"
]
] |
find_length
|
[] |
Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string.
|
def find_length(string):
"""Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string. """
n = len(string)
current_sum = 0
max_sum = 0
for i in range(n):
current_sum += 1 if string[i] == '0' else -1
if current_sum < 0:
current_sum = 0
max_sum = max(current_sum, max_sum)
|
return max_sum if max_sum else 0
|
|
code_infilling
|
python
|
python
|
MBPP/126/L1
|
[] |
[] |
MBPP_Infilling
|
for i in range(1, min(a, b)):
if a % i == 0 and b % i == 0:
sum += i
return sum
|
[
[
"10,15",
"6"
],
[
"100,150",
"93"
],
[
"4,6",
"3"
]
] |
sum
|
[] |
Write a python function to find the sum of common divisors of two given numbers.
|
def sum(a, b):
"""Write a python function to find the sum of common divisors of two given numbers. """
|
sum = 0
|
code_infilling
|
python
|
python
|
MBPP/126/L2
|
[] |
[] |
MBPP_Infilling
|
if a % i == 0 and b % i == 0:
sum += i
return sum
|
[
[
"10,15",
"6"
],
[
"100,150",
"93"
],
[
"4,6",
"3"
]
] |
sum
|
[] |
Write a python function to find the sum of common divisors of two given numbers.
|
def sum(a, b):
"""Write a python function to find the sum of common divisors of two given numbers. """
sum = 0
|
for i in range(1, min(a, b)):
|
code_infilling
|
python
|
python
|
MBPP/126/L3
|
[] |
[] |
MBPP_Infilling
|
sum += i
return sum
|
[
[
"10,15",
"6"
],
[
"100,150",
"93"
],
[
"4,6",
"3"
]
] |
sum
|
[] |
Write a python function to find the sum of common divisors of two given numbers.
|
def sum(a, b):
"""Write a python function to find the sum of common divisors of two given numbers. """
sum = 0
for i in range(1, min(a, b)):
|
if a % i == 0 and b % i == 0:
|
code_infilling
|
python
|
python
|
MBPP/126/L4
|
[] |
[] |
MBPP_Infilling
|
return sum
|
[
[
"10,15",
"6"
],
[
"100,150",
"93"
],
[
"4,6",
"3"
]
] |
sum
|
[] |
Write a python function to find the sum of common divisors of two given numbers.
|
def sum(a, b):
"""Write a python function to find the sum of common divisors of two given numbers. """
sum = 0
for i in range(1, min(a, b)):
if a % i == 0 and b % i == 0:
|
sum += i
|
code_infilling
|
python
|
python
|
MBPP/126/L5
|
[] |
[] |
MBPP_Infilling
|
[
[
"10,15",
"6"
],
[
"100,150",
"93"
],
[
"4,6",
"3"
]
] |
sum
|
[] |
Write a python function to find the sum of common divisors of two given numbers.
|
def sum(a, b):
"""Write a python function to find the sum of common divisors of two given numbers. """
sum = 0
for i in range(1, min(a, b)):
if a % i == 0 and b % i == 0:
sum += i
|
return sum
|
|
code_infilling
|
python
|
python
|
MBPP/127/L1
|
[] |
[] |
MBPP_Infilling
|
return -multiply_int(x, -y)
elif y == 0:
return 0
elif y == 1:
return x
else:
return x + multiply_int(x, y - 1)
|
[
[
"10,20",
"200"
],
[
"5,10",
"50"
],
[
"4,8",
"32"
]
] |
multiply_int
|
[] |
Write a function to multiply two integers.
|
def multiply_int(x, y):
"""Write a function to multiply two integers. """
|
if y < 0:
|
code_infilling
|
python
|
python
|
MBPP/127/L2
|
[] |
[] |
MBPP_Infilling
|
elif y == 0:
return 0
elif y == 1:
return x
else:
return x + multiply_int(x, y - 1)
|
[
[
"10,20",
"200"
],
[
"5,10",
"50"
],
[
"4,8",
"32"
]
] |
multiply_int
|
[] |
Write a function to multiply two integers.
|
def multiply_int(x, y):
"""Write a function to multiply two integers. """
if y < 0:
|
return -multiply_int(x, -y)
|
code_infilling
|
python
|
python
|
MBPP/127/L3
|
[] |
[] |
MBPP_Infilling
|
return 0
elif y == 1:
return x
else:
return x + multiply_int(x, y - 1)
|
[
[
"10,20",
"200"
],
[
"5,10",
"50"
],
[
"4,8",
"32"
]
] |
multiply_int
|
[] |
Write a function to multiply two integers.
|
def multiply_int(x, y):
"""Write a function to multiply two integers. """
if y < 0:
return -multiply_int(x, -y)
|
elif y == 0:
|
code_infilling
|
python
|
python
|
MBPP/127/L4
|
[] |
[] |
MBPP_Infilling
|
elif y == 1:
return x
else:
return x + multiply_int(x, y - 1)
|
[
[
"10,20",
"200"
],
[
"5,10",
"50"
],
[
"4,8",
"32"
]
] |
multiply_int
|
[] |
Write a function to multiply two integers.
|
def multiply_int(x, y):
"""Write a function to multiply two integers. """
if y < 0:
return -multiply_int(x, -y)
elif y == 0:
|
return 0
|
code_infilling
|
python
|
python
|
MBPP/127/L5
|
[] |
[] |
MBPP_Infilling
|
return x
else:
return x + multiply_int(x, y - 1)
|
[
[
"10,20",
"200"
],
[
"5,10",
"50"
],
[
"4,8",
"32"
]
] |
multiply_int
|
[] |
Write a function to multiply two integers.
|
def multiply_int(x, y):
"""Write a function to multiply two integers. """
if y < 0:
return -multiply_int(x, -y)
elif y == 0:
return 0
|
elif y == 1:
|
code_infilling
|
python
|
python
|
MBPP/127/L6
|
[] |
[] |
MBPP_Infilling
|
else:
return x + multiply_int(x, y - 1)
|
[
[
"10,20",
"200"
],
[
"5,10",
"50"
],
[
"4,8",
"32"
]
] |
multiply_int
|
[] |
Write a function to multiply two integers.
|
def multiply_int(x, y):
"""Write a function to multiply two integers. """
if y < 0:
return -multiply_int(x, -y)
elif y == 0:
return 0
elif y == 1:
|
return x
|
code_infilling
|
python
|
python
|
MBPP/127/L7
|
[] |
[] |
MBPP_Infilling
|
return x + multiply_int(x, y - 1)
|
[
[
"10,20",
"200"
],
[
"5,10",
"50"
],
[
"4,8",
"32"
]
] |
multiply_int
|
[] |
Write a function to multiply two integers.
|
def multiply_int(x, y):
"""Write a function to multiply two integers. """
if y < 0:
return -multiply_int(x, -y)
elif y == 0:
return 0
elif y == 1:
return x
|
else:
|
code_infilling
|
python
|
python
|
MBPP/127/L8
|
[] |
[] |
MBPP_Infilling
|
[
[
"10,20",
"200"
],
[
"5,10",
"50"
],
[
"4,8",
"32"
]
] |
multiply_int
|
[] |
Write a function to multiply two integers.
|
def multiply_int(x, y):
"""Write a function to multiply two integers. """
if y < 0:
return -multiply_int(x, -y)
elif y == 0:
return 0
elif y == 1:
return x
else:
|
return x + multiply_int(x, y - 1)
|
|
code_infilling
|
python
|
python
|
MBPP/128/L1
|
[] |
[] |
MBPP_Infilling
|
txt = str.split(' ')
for x in txt:
if len(x) > n:
word_len.append(x)
return word_len
|
[
[
"3,\"python is a programming language\"",
"['python','programming','language']"
],
[
"2,\"writing a program\"",
"['writing','program']"
],
[
"5,\"sorting list\"",
"['sorting']"
]
] |
long_words
|
[] |
Write a function to find words that are longer than n characters from a given list of words.
|
def long_words(n, str):
"""Write a function to find words that are longer than n characters from a given list of words. """
|
word_len = []
|
code_infilling
|
python
|
python
|
MBPP/128/L2
|
[] |
[] |
MBPP_Infilling
|
for x in txt:
if len(x) > n:
word_len.append(x)
return word_len
|
[
[
"3,\"python is a programming language\"",
"['python','programming','language']"
],
[
"2,\"writing a program\"",
"['writing','program']"
],
[
"5,\"sorting list\"",
"['sorting']"
]
] |
long_words
|
[] |
Write a function to find words that are longer than n characters from a given list of words.
|
def long_words(n, str):
"""Write a function to find words that are longer than n characters from a given list of words. """
word_len = []
|
txt = str.split(' ')
|
code_infilling
|
python
|
python
|
MBPP/128/L3
|
[] |
[] |
MBPP_Infilling
|
if len(x) > n:
word_len.append(x)
return word_len
|
[
[
"3,\"python is a programming language\"",
"['python','programming','language']"
],
[
"2,\"writing a program\"",
"['writing','program']"
],
[
"5,\"sorting list\"",
"['sorting']"
]
] |
long_words
|
[] |
Write a function to find words that are longer than n characters from a given list of words.
|
def long_words(n, str):
"""Write a function to find words that are longer than n characters from a given list of words. """
word_len = []
txt = str.split(' ')
|
for x in txt:
|
code_infilling
|
python
|
python
|
MBPP/128/L4
|
[] |
[] |
MBPP_Infilling
|
word_len.append(x)
return word_len
|
[
[
"3,\"python is a programming language\"",
"['python','programming','language']"
],
[
"2,\"writing a program\"",
"['writing','program']"
],
[
"5,\"sorting list\"",
"['sorting']"
]
] |
long_words
|
[] |
Write a function to find words that are longer than n characters from a given list of words.
|
def long_words(n, str):
"""Write a function to find words that are longer than n characters from a given list of words. """
word_len = []
txt = str.split(' ')
for x in txt:
|
if len(x) > n:
|
code_infilling
|
python
|
python
|
MBPP/128/L5
|
[] |
[] |
MBPP_Infilling
|
return word_len
|
[
[
"3,\"python is a programming language\"",
"['python','programming','language']"
],
[
"2,\"writing a program\"",
"['writing','program']"
],
[
"5,\"sorting list\"",
"['sorting']"
]
] |
long_words
|
[] |
Write a function to find words that are longer than n characters from a given list of words.
|
def long_words(n, str):
"""Write a function to find words that are longer than n characters from a given list of words. """
word_len = []
txt = str.split(' ')
for x in txt:
if len(x) > n:
|
word_len.append(x)
|
code_infilling
|
python
|
python
|
MBPP/128/L6
|
[] |
[] |
MBPP_Infilling
|
[
[
"3,\"python is a programming language\"",
"['python','programming','language']"
],
[
"2,\"writing a program\"",
"['writing','program']"
],
[
"5,\"sorting list\"",
"['sorting']"
]
] |
long_words
|
[] |
Write a function to find words that are longer than n characters from a given list of words.
|
def long_words(n, str):
"""Write a function to find words that are longer than n characters from a given list of words. """
word_len = []
txt = str.split(' ')
for x in txt:
if len(x) > n:
word_len.append(x)
|
return word_len
|
|
code_infilling
|
python
|
python
|
MBPP/129/L1
|
[] |
[] |
MBPP_Infilling
|
sum_list = []
sum_list.extend([sum(lines) for lines in my_matrix])
for col in range(iSize):
sum_list.append(sum((row[col] for row in my_matrix)))
result1 = 0
for i in range(0, iSize):
result1 += my_matrix[i][i]
sum_list.append(result1)
result2 = 0
for i in range(iSize - 1, -1, -1):
result2 += my_matrix[i][i]
sum_list.append(result2)
if len(set(sum_list)) > 1:
return False
return True
|
[
[
"[[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 8]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 7]]",
"False"
]
] |
magic_square_test
|
[] |
Write a function to calculate whether the matrix is a magic square.
|
def magic_square_test(my_matrix):
"""Write a function to calculate whether the matrix is a magic square. """
|
iSize = len(my_matrix[0])
|
code_infilling
|
python
|
python
|
MBPP/129/L2
|
[] |
[] |
MBPP_Infilling
|
sum_list.extend([sum(lines) for lines in my_matrix])
for col in range(iSize):
sum_list.append(sum((row[col] for row in my_matrix)))
result1 = 0
for i in range(0, iSize):
result1 += my_matrix[i][i]
sum_list.append(result1)
result2 = 0
for i in range(iSize - 1, -1, -1):
result2 += my_matrix[i][i]
sum_list.append(result2)
if len(set(sum_list)) > 1:
return False
return True
|
[
[
"[[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 8]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 7]]",
"False"
]
] |
magic_square_test
|
[] |
Write a function to calculate whether the matrix is a magic square.
|
def magic_square_test(my_matrix):
"""Write a function to calculate whether the matrix is a magic square. """
iSize = len(my_matrix[0])
|
sum_list = []
|
code_infilling
|
python
|
python
|
MBPP/129/L3
|
[] |
[] |
MBPP_Infilling
|
for col in range(iSize):
sum_list.append(sum((row[col] for row in my_matrix)))
result1 = 0
for i in range(0, iSize):
result1 += my_matrix[i][i]
sum_list.append(result1)
result2 = 0
for i in range(iSize - 1, -1, -1):
result2 += my_matrix[i][i]
sum_list.append(result2)
if len(set(sum_list)) > 1:
return False
return True
|
[
[
"[[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 8]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 7]]",
"False"
]
] |
magic_square_test
|
[] |
Write a function to calculate whether the matrix is a magic square.
|
def magic_square_test(my_matrix):
"""Write a function to calculate whether the matrix is a magic square. """
iSize = len(my_matrix[0])
sum_list = []
|
sum_list.extend([sum(lines) for lines in my_matrix])
|
code_infilling
|
python
|
python
|
MBPP/129/L4
|
[] |
[] |
MBPP_Infilling
|
sum_list.append(sum((row[col] for row in my_matrix)))
result1 = 0
for i in range(0, iSize):
result1 += my_matrix[i][i]
sum_list.append(result1)
result2 = 0
for i in range(iSize - 1, -1, -1):
result2 += my_matrix[i][i]
sum_list.append(result2)
if len(set(sum_list)) > 1:
return False
return True
|
[
[
"[[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 8]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 7]]",
"False"
]
] |
magic_square_test
|
[] |
Write a function to calculate whether the matrix is a magic square.
|
def magic_square_test(my_matrix):
"""Write a function to calculate whether the matrix is a magic square. """
iSize = len(my_matrix[0])
sum_list = []
sum_list.extend([sum(lines) for lines in my_matrix])
|
for col in range(iSize):
|
code_infilling
|
python
|
python
|
MBPP/129/L5
|
[] |
[] |
MBPP_Infilling
|
result1 = 0
for i in range(0, iSize):
result1 += my_matrix[i][i]
sum_list.append(result1)
result2 = 0
for i in range(iSize - 1, -1, -1):
result2 += my_matrix[i][i]
sum_list.append(result2)
if len(set(sum_list)) > 1:
return False
return True
|
[
[
"[[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 8]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 7]]",
"False"
]
] |
magic_square_test
|
[] |
Write a function to calculate whether the matrix is a magic square.
|
def magic_square_test(my_matrix):
"""Write a function to calculate whether the matrix is a magic square. """
iSize = len(my_matrix[0])
sum_list = []
sum_list.extend([sum(lines) for lines in my_matrix])
for col in range(iSize):
|
sum_list.append(sum((row[col] for row in my_matrix)))
|
code_infilling
|
python
|
python
|
MBPP/129/L6
|
[] |
[] |
MBPP_Infilling
|
for i in range(0, iSize):
result1 += my_matrix[i][i]
sum_list.append(result1)
result2 = 0
for i in range(iSize - 1, -1, -1):
result2 += my_matrix[i][i]
sum_list.append(result2)
if len(set(sum_list)) > 1:
return False
return True
|
[
[
"[[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 8]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 7]]",
"False"
]
] |
magic_square_test
|
[] |
Write a function to calculate whether the matrix is a magic square.
|
def magic_square_test(my_matrix):
"""Write a function to calculate whether the matrix is a magic square. """
iSize = len(my_matrix[0])
sum_list = []
sum_list.extend([sum(lines) for lines in my_matrix])
for col in range(iSize):
sum_list.append(sum((row[col] for row in my_matrix)))
|
result1 = 0
|
code_infilling
|
python
|
python
|
MBPP/129/L7
|
[] |
[] |
MBPP_Infilling
|
result1 += my_matrix[i][i]
sum_list.append(result1)
result2 = 0
for i in range(iSize - 1, -1, -1):
result2 += my_matrix[i][i]
sum_list.append(result2)
if len(set(sum_list)) > 1:
return False
return True
|
[
[
"[[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 8]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 7]]",
"False"
]
] |
magic_square_test
|
[] |
Write a function to calculate whether the matrix is a magic square.
|
def magic_square_test(my_matrix):
"""Write a function to calculate whether the matrix is a magic square. """
iSize = len(my_matrix[0])
sum_list = []
sum_list.extend([sum(lines) for lines in my_matrix])
for col in range(iSize):
sum_list.append(sum((row[col] for row in my_matrix)))
result1 = 0
|
for i in range(0, iSize):
|
code_infilling
|
python
|
python
|
MBPP/129/L8
|
[] |
[] |
MBPP_Infilling
|
sum_list.append(result1)
result2 = 0
for i in range(iSize - 1, -1, -1):
result2 += my_matrix[i][i]
sum_list.append(result2)
if len(set(sum_list)) > 1:
return False
return True
|
[
[
"[[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 8]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 7]]",
"False"
]
] |
magic_square_test
|
[] |
Write a function to calculate whether the matrix is a magic square.
|
def magic_square_test(my_matrix):
"""Write a function to calculate whether the matrix is a magic square. """
iSize = len(my_matrix[0])
sum_list = []
sum_list.extend([sum(lines) for lines in my_matrix])
for col in range(iSize):
sum_list.append(sum((row[col] for row in my_matrix)))
result1 = 0
for i in range(0, iSize):
|
result1 += my_matrix[i][i]
|
code_infilling
|
python
|
python
|
MBPP/129/L9
|
[] |
[] |
MBPP_Infilling
|
result2 = 0
for i in range(iSize - 1, -1, -1):
result2 += my_matrix[i][i]
sum_list.append(result2)
if len(set(sum_list)) > 1:
return False
return True
|
[
[
"[[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 8]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 7]]",
"False"
]
] |
magic_square_test
|
[] |
Write a function to calculate whether the matrix is a magic square.
|
def magic_square_test(my_matrix):
"""Write a function to calculate whether the matrix is a magic square. """
iSize = len(my_matrix[0])
sum_list = []
sum_list.extend([sum(lines) for lines in my_matrix])
for col in range(iSize):
sum_list.append(sum((row[col] for row in my_matrix)))
result1 = 0
for i in range(0, iSize):
result1 += my_matrix[i][i]
|
sum_list.append(result1)
|
code_infilling
|
python
|
python
|
MBPP/129/L10
|
[] |
[] |
MBPP_Infilling
|
for i in range(iSize - 1, -1, -1):
result2 += my_matrix[i][i]
sum_list.append(result2)
if len(set(sum_list)) > 1:
return False
return True
|
[
[
"[[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 8]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 7]]",
"False"
]
] |
magic_square_test
|
[] |
Write a function to calculate whether the matrix is a magic square.
|
def magic_square_test(my_matrix):
"""Write a function to calculate whether the matrix is a magic square. """
iSize = len(my_matrix[0])
sum_list = []
sum_list.extend([sum(lines) for lines in my_matrix])
for col in range(iSize):
sum_list.append(sum((row[col] for row in my_matrix)))
result1 = 0
for i in range(0, iSize):
result1 += my_matrix[i][i]
sum_list.append(result1)
|
result2 = 0
|
code_infilling
|
python
|
python
|
MBPP/129/L11
|
[] |
[] |
MBPP_Infilling
|
result2 += my_matrix[i][i]
sum_list.append(result2)
if len(set(sum_list)) > 1:
return False
return True
|
[
[
"[[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 8]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 7]]",
"False"
]
] |
magic_square_test
|
[] |
Write a function to calculate whether the matrix is a magic square.
|
def magic_square_test(my_matrix):
"""Write a function to calculate whether the matrix is a magic square. """
iSize = len(my_matrix[0])
sum_list = []
sum_list.extend([sum(lines) for lines in my_matrix])
for col in range(iSize):
sum_list.append(sum((row[col] for row in my_matrix)))
result1 = 0
for i in range(0, iSize):
result1 += my_matrix[i][i]
sum_list.append(result1)
result2 = 0
|
for i in range(iSize - 1, -1, -1):
|
code_infilling
|
python
|
python
|
MBPP/129/L12
|
[] |
[] |
MBPP_Infilling
|
sum_list.append(result2)
if len(set(sum_list)) > 1:
return False
return True
|
[
[
"[[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 8]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 7]]",
"False"
]
] |
magic_square_test
|
[] |
Write a function to calculate whether the matrix is a magic square.
|
def magic_square_test(my_matrix):
"""Write a function to calculate whether the matrix is a magic square. """
iSize = len(my_matrix[0])
sum_list = []
sum_list.extend([sum(lines) for lines in my_matrix])
for col in range(iSize):
sum_list.append(sum((row[col] for row in my_matrix)))
result1 = 0
for i in range(0, iSize):
result1 += my_matrix[i][i]
sum_list.append(result1)
result2 = 0
for i in range(iSize - 1, -1, -1):
|
result2 += my_matrix[i][i]
|
code_infilling
|
python
|
python
|
MBPP/129/L13
|
[] |
[] |
MBPP_Infilling
|
if len(set(sum_list)) > 1:
return False
return True
|
[
[
"[[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 8]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 7]]",
"False"
]
] |
magic_square_test
|
[] |
Write a function to calculate whether the matrix is a magic square.
|
def magic_square_test(my_matrix):
"""Write a function to calculate whether the matrix is a magic square. """
iSize = len(my_matrix[0])
sum_list = []
sum_list.extend([sum(lines) for lines in my_matrix])
for col in range(iSize):
sum_list.append(sum((row[col] for row in my_matrix)))
result1 = 0
for i in range(0, iSize):
result1 += my_matrix[i][i]
sum_list.append(result1)
result2 = 0
for i in range(iSize - 1, -1, -1):
result2 += my_matrix[i][i]
|
sum_list.append(result2)
|
code_infilling
|
python
|
python
|
MBPP/129/L14
|
[] |
[] |
MBPP_Infilling
|
return False
return True
|
[
[
"[[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 8]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 7]]",
"False"
]
] |
magic_square_test
|
[] |
Write a function to calculate whether the matrix is a magic square.
|
def magic_square_test(my_matrix):
"""Write a function to calculate whether the matrix is a magic square. """
iSize = len(my_matrix[0])
sum_list = []
sum_list.extend([sum(lines) for lines in my_matrix])
for col in range(iSize):
sum_list.append(sum((row[col] for row in my_matrix)))
result1 = 0
for i in range(0, iSize):
result1 += my_matrix[i][i]
sum_list.append(result1)
result2 = 0
for i in range(iSize - 1, -1, -1):
result2 += my_matrix[i][i]
sum_list.append(result2)
|
if len(set(sum_list)) > 1:
|
code_infilling
|
python
|
python
|
MBPP/129/L15
|
[] |
[] |
MBPP_Infilling
|
return True
|
[
[
"[[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 8]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 7]]",
"False"
]
] |
magic_square_test
|
[] |
Write a function to calculate whether the matrix is a magic square.
|
def magic_square_test(my_matrix):
"""Write a function to calculate whether the matrix is a magic square. """
iSize = len(my_matrix[0])
sum_list = []
sum_list.extend([sum(lines) for lines in my_matrix])
for col in range(iSize):
sum_list.append(sum((row[col] for row in my_matrix)))
result1 = 0
for i in range(0, iSize):
result1 += my_matrix[i][i]
sum_list.append(result1)
result2 = 0
for i in range(iSize - 1, -1, -1):
result2 += my_matrix[i][i]
sum_list.append(result2)
if len(set(sum_list)) > 1:
|
return False
|
code_infilling
|
python
|
python
|
MBPP/129/L16
|
[] |
[] |
MBPP_Infilling
|
[
[
"[[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 8]]",
"True"
],
[
"[[2, 7, 6], [9, 5, 1], [4, 3, 7]]",
"False"
]
] |
magic_square_test
|
[] |
Write a function to calculate whether the matrix is a magic square.
|
def magic_square_test(my_matrix):
"""Write a function to calculate whether the matrix is a magic square. """
iSize = len(my_matrix[0])
sum_list = []
sum_list.extend([sum(lines) for lines in my_matrix])
for col in range(iSize):
sum_list.append(sum((row[col] for row in my_matrix)))
result1 = 0
for i in range(0, iSize):
result1 += my_matrix[i][i]
sum_list.append(result1)
result2 = 0
for i in range(iSize - 1, -1, -1):
result2 += my_matrix[i][i]
sum_list.append(result2)
if len(set(sum_list)) > 1:
return False
|
return True
|
|
code_infilling
|
python
|
python
|
MBPP/130/L3
|
[] |
[] |
MBPP_Infilling
|
for i in nums:
dict[i] += 1
result = max(dict.items(), key=lambda x: x[1])
return result[0]
|
[
[
"[2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,2,4,6,9,1,2]",
"2"
],
[
"[2,3,8,4,7,9,8,7,9,15,14,10,12,13,16,18]",
"8"
],
[
"[10,20,20,30,40,90,80,50,30,20,50,10]",
"20"
]
] |
max_occurrences
|
[
"from collections import defaultdict"
] |
Write a function to find the item with maximum frequency in a given list.
|
from collections import defaultdict
def max_occurrences(nums):
"""Write a function to find the item with maximum frequency in a given list. """
|
dict = defaultdict(int)
|
code_infilling
|
python
|
python
|
MBPP/130/L4
|
[] |
[] |
MBPP_Infilling
|
dict[i] += 1
result = max(dict.items(), key=lambda x: x[1])
return result[0]
|
[
[
"[2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,2,4,6,9,1,2]",
"2"
],
[
"[2,3,8,4,7,9,8,7,9,15,14,10,12,13,16,18]",
"8"
],
[
"[10,20,20,30,40,90,80,50,30,20,50,10]",
"20"
]
] |
max_occurrences
|
[
"from collections import defaultdict"
] |
Write a function to find the item with maximum frequency in a given list.
|
from collections import defaultdict
def max_occurrences(nums):
"""Write a function to find the item with maximum frequency in a given list. """
dict = defaultdict(int)
|
for i in nums:
|
code_infilling
|
python
|
python
|
MBPP/130/L5
|
[] |
[] |
MBPP_Infilling
|
result = max(dict.items(), key=lambda x: x[1])
return result[0]
|
[
[
"[2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,2,4,6,9,1,2]",
"2"
],
[
"[2,3,8,4,7,9,8,7,9,15,14,10,12,13,16,18]",
"8"
],
[
"[10,20,20,30,40,90,80,50,30,20,50,10]",
"20"
]
] |
max_occurrences
|
[
"from collections import defaultdict"
] |
Write a function to find the item with maximum frequency in a given list.
|
from collections import defaultdict
def max_occurrences(nums):
"""Write a function to find the item with maximum frequency in a given list. """
dict = defaultdict(int)
for i in nums:
|
dict[i] += 1
|
code_infilling
|
python
|
python
|
MBPP/130/L6
|
[] |
[] |
MBPP_Infilling
|
return result[0]
|
[
[
"[2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,2,4,6,9,1,2]",
"2"
],
[
"[2,3,8,4,7,9,8,7,9,15,14,10,12,13,16,18]",
"8"
],
[
"[10,20,20,30,40,90,80,50,30,20,50,10]",
"20"
]
] |
max_occurrences
|
[
"from collections import defaultdict"
] |
Write a function to find the item with maximum frequency in a given list.
|
from collections import defaultdict
def max_occurrences(nums):
"""Write a function to find the item with maximum frequency in a given list. """
dict = defaultdict(int)
for i in nums:
dict[i] += 1
|
result = max(dict.items(), key=lambda x: x[1])
|
code_infilling
|
python
|
python
|
MBPP/130/L7
|
[] |
[] |
MBPP_Infilling
|
[
[
"[2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,2,4,6,9,1,2]",
"2"
],
[
"[2,3,8,4,7,9,8,7,9,15,14,10,12,13,16,18]",
"8"
],
[
"[10,20,20,30,40,90,80,50,30,20,50,10]",
"20"
]
] |
max_occurrences
|
[
"from collections import defaultdict"
] |
Write a function to find the item with maximum frequency in a given list.
|
from collections import defaultdict
def max_occurrences(nums):
"""Write a function to find the item with maximum frequency in a given list. """
dict = defaultdict(int)
for i in nums:
dict[i] += 1
result = max(dict.items(), key=lambda x: x[1])
|
return result[0]
|
|
code_infilling
|
python
|
python
|
MBPP/131/L1
|
[] |
[] |
MBPP_Infilling
|
for char in str1:
if char in 'aeiouAEIOU':
vowels += char
result_string = ''
for char in str1:
if char in 'aeiouAEIOU':
result_string += vowels[-1]
vowels = vowels[:-1]
else:
result_string += char
return result_string
|
[
[
"\"Python\"",
"\"Python\""
],
[
"\"USA\"",
"\"ASU\""
],
[
"\"ab\"",
"\"ab\""
]
] |
reverse_vowels
|
[] |
Write a python function to reverse only the vowels of a given string (where y is not a vowel).
|
def reverse_vowels(str1):
"""Write a python function to reverse only the vowels of a given string (where y is not a vowel). """
|
vowels = ''
|
code_infilling
|
python
|
python
|
MBPP/131/L2
|
[] |
[] |
MBPP_Infilling
|
if char in 'aeiouAEIOU':
vowels += char
result_string = ''
for char in str1:
if char in 'aeiouAEIOU':
result_string += vowels[-1]
vowels = vowels[:-1]
else:
result_string += char
return result_string
|
[
[
"\"Python\"",
"\"Python\""
],
[
"\"USA\"",
"\"ASU\""
],
[
"\"ab\"",
"\"ab\""
]
] |
reverse_vowels
|
[] |
Write a python function to reverse only the vowels of a given string (where y is not a vowel).
|
def reverse_vowels(str1):
"""Write a python function to reverse only the vowels of a given string (where y is not a vowel). """
vowels = ''
|
for char in str1:
|
code_infilling
|
python
|
python
|
MBPP/131/L3
|
[] |
[] |
MBPP_Infilling
|
vowels += char
result_string = ''
for char in str1:
if char in 'aeiouAEIOU':
result_string += vowels[-1]
vowels = vowels[:-1]
else:
result_string += char
return result_string
|
[
[
"\"Python\"",
"\"Python\""
],
[
"\"USA\"",
"\"ASU\""
],
[
"\"ab\"",
"\"ab\""
]
] |
reverse_vowels
|
[] |
Write a python function to reverse only the vowels of a given string (where y is not a vowel).
|
def reverse_vowels(str1):
"""Write a python function to reverse only the vowels of a given string (where y is not a vowel). """
vowels = ''
for char in str1:
|
if char in 'aeiouAEIOU':
|
code_infilling
|
python
|
python
|
MBPP/131/L4
|
[] |
[] |
MBPP_Infilling
|
result_string = ''
for char in str1:
if char in 'aeiouAEIOU':
result_string += vowels[-1]
vowels = vowels[:-1]
else:
result_string += char
return result_string
|
[
[
"\"Python\"",
"\"Python\""
],
[
"\"USA\"",
"\"ASU\""
],
[
"\"ab\"",
"\"ab\""
]
] |
reverse_vowels
|
[] |
Write a python function to reverse only the vowels of a given string (where y is not a vowel).
|
def reverse_vowels(str1):
"""Write a python function to reverse only the vowels of a given string (where y is not a vowel). """
vowels = ''
for char in str1:
if char in 'aeiouAEIOU':
|
vowels += char
|
code_infilling
|
python
|
python
|
MBPP/131/L5
|
[] |
[] |
MBPP_Infilling
|
for char in str1:
if char in 'aeiouAEIOU':
result_string += vowels[-1]
vowels = vowels[:-1]
else:
result_string += char
return result_string
|
[
[
"\"Python\"",
"\"Python\""
],
[
"\"USA\"",
"\"ASU\""
],
[
"\"ab\"",
"\"ab\""
]
] |
reverse_vowels
|
[] |
Write a python function to reverse only the vowels of a given string (where y is not a vowel).
|
def reverse_vowels(str1):
"""Write a python function to reverse only the vowels of a given string (where y is not a vowel). """
vowels = ''
for char in str1:
if char in 'aeiouAEIOU':
vowels += char
|
result_string = ''
|
code_infilling
|
python
|
python
|
MBPP/131/L6
|
[] |
[] |
MBPP_Infilling
|
if char in 'aeiouAEIOU':
result_string += vowels[-1]
vowels = vowels[:-1]
else:
result_string += char
return result_string
|
[
[
"\"Python\"",
"\"Python\""
],
[
"\"USA\"",
"\"ASU\""
],
[
"\"ab\"",
"\"ab\""
]
] |
reverse_vowels
|
[] |
Write a python function to reverse only the vowels of a given string (where y is not a vowel).
|
def reverse_vowels(str1):
"""Write a python function to reverse only the vowels of a given string (where y is not a vowel). """
vowels = ''
for char in str1:
if char in 'aeiouAEIOU':
vowels += char
result_string = ''
|
for char in str1:
|
code_infilling
|
python
|
python
|
MBPP/131/L7
|
[] |
[] |
MBPP_Infilling
|
result_string += vowels[-1]
vowels = vowels[:-1]
else:
result_string += char
return result_string
|
[
[
"\"Python\"",
"\"Python\""
],
[
"\"USA\"",
"\"ASU\""
],
[
"\"ab\"",
"\"ab\""
]
] |
reverse_vowels
|
[] |
Write a python function to reverse only the vowels of a given string (where y is not a vowel).
|
def reverse_vowels(str1):
"""Write a python function to reverse only the vowels of a given string (where y is not a vowel). """
vowels = ''
for char in str1:
if char in 'aeiouAEIOU':
vowels += char
result_string = ''
for char in str1:
|
if char in 'aeiouAEIOU':
|
code_infilling
|
python
|
python
|
MBPP/131/L8
|
[] |
[] |
MBPP_Infilling
|
vowels = vowels[:-1]
else:
result_string += char
return result_string
|
[
[
"\"Python\"",
"\"Python\""
],
[
"\"USA\"",
"\"ASU\""
],
[
"\"ab\"",
"\"ab\""
]
] |
reverse_vowels
|
[] |
Write a python function to reverse only the vowels of a given string (where y is not a vowel).
|
def reverse_vowels(str1):
"""Write a python function to reverse only the vowels of a given string (where y is not a vowel). """
vowels = ''
for char in str1:
if char in 'aeiouAEIOU':
vowels += char
result_string = ''
for char in str1:
if char in 'aeiouAEIOU':
|
result_string += vowels[-1]
|
code_infilling
|
python
|
python
|
MBPP/131/L9
|
[] |
[] |
MBPP_Infilling
|
else:
result_string += char
return result_string
|
[
[
"\"Python\"",
"\"Python\""
],
[
"\"USA\"",
"\"ASU\""
],
[
"\"ab\"",
"\"ab\""
]
] |
reverse_vowels
|
[] |
Write a python function to reverse only the vowels of a given string (where y is not a vowel).
|
def reverse_vowels(str1):
"""Write a python function to reverse only the vowels of a given string (where y is not a vowel). """
vowels = ''
for char in str1:
if char in 'aeiouAEIOU':
vowels += char
result_string = ''
for char in str1:
if char in 'aeiouAEIOU':
result_string += vowels[-1]
|
vowels = vowels[:-1]
|
code_infilling
|
python
|
python
|
MBPP/131/L10
|
[] |
[] |
MBPP_Infilling
|
result_string += char
return result_string
|
[
[
"\"Python\"",
"\"Python\""
],
[
"\"USA\"",
"\"ASU\""
],
[
"\"ab\"",
"\"ab\""
]
] |
reverse_vowels
|
[] |
Write a python function to reverse only the vowels of a given string (where y is not a vowel).
|
def reverse_vowels(str1):
"""Write a python function to reverse only the vowels of a given string (where y is not a vowel). """
vowels = ''
for char in str1:
if char in 'aeiouAEIOU':
vowels += char
result_string = ''
for char in str1:
if char in 'aeiouAEIOU':
result_string += vowels[-1]
vowels = vowels[:-1]
|
else:
|
code_infilling
|
python
|
python
|
MBPP/131/L11
|
[] |
[] |
MBPP_Infilling
|
return result_string
|
[
[
"\"Python\"",
"\"Python\""
],
[
"\"USA\"",
"\"ASU\""
],
[
"\"ab\"",
"\"ab\""
]
] |
reverse_vowels
|
[] |
Write a python function to reverse only the vowels of a given string (where y is not a vowel).
|
def reverse_vowels(str1):
"""Write a python function to reverse only the vowels of a given string (where y is not a vowel). """
vowels = ''
for char in str1:
if char in 'aeiouAEIOU':
vowels += char
result_string = ''
for char in str1:
if char in 'aeiouAEIOU':
result_string += vowels[-1]
vowels = vowels[:-1]
else:
|
result_string += char
|
code_infilling
|
python
|
python
|
MBPP/131/L12
|
[] |
[] |
MBPP_Infilling
|
[
[
"\"Python\"",
"\"Python\""
],
[
"\"USA\"",
"\"ASU\""
],
[
"\"ab\"",
"\"ab\""
]
] |
reverse_vowels
|
[] |
Write a python function to reverse only the vowels of a given string (where y is not a vowel).
|
def reverse_vowels(str1):
"""Write a python function to reverse only the vowels of a given string (where y is not a vowel). """
vowels = ''
for char in str1:
if char in 'aeiouAEIOU':
vowels += char
result_string = ''
for char in str1:
if char in 'aeiouAEIOU':
result_string += vowels[-1]
vowels = vowels[:-1]
else:
result_string += char
|
return result_string
|
|
code_infilling
|
python
|
python
|
MBPP/132/L1
|
[] |
[] |
MBPP_Infilling
|
return str
|
[
[
"('e', 'x', 'e', 'r', 'c', 'i', 's', 'e', 's')",
"(\"exercises\")"
],
[
"('p','y','t','h','o','n')",
"(\"python\")"
],
[
"('p','r','o','g','r','a','m')",
"(\"program\")"
]
] |
tup_string
|
[] |
Write a function to convert a tuple to a string.
|
def tup_string(tup1):
"""Write a function to convert a tuple to a string. """
|
str = ''.join(tup1)
|
code_infilling
|
python
|
python
|
MBPP/132/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"('e', 'x', 'e', 'r', 'c', 'i', 's', 'e', 's')",
"(\"exercises\")"
],
[
"('p','y','t','h','o','n')",
"(\"python\")"
],
[
"('p','r','o','g','r','a','m')",
"(\"program\")"
]
] |
tup_string
|
[] |
Write a function to convert a tuple to a string.
|
def tup_string(tup1):
"""Write a function to convert a tuple to a string. """
str = ''.join(tup1)
|
return str
|
|
code_infilling
|
python
|
python
|
MBPP/133/L1
|
[] |
[] |
MBPP_Infilling
|
return sum(sum_negativenum)
|
[
[
"[2, 4, -6, -9, 11, -12, 14, -5, 17]",
"-32"
],
[
"[10,15,-14,13,-18,12,-20]",
"-52"
],
[
"[19, -65, 57, 39, 152,-639, 121, 44, 90, -190]",
"-894"
]
] |
sum_negativenum
|
[] |
Write a function to calculate the sum of the negative numbers of a given list of numbers.
|
def sum_negativenum(nums):
"""Write a function to calculate the sum of the negative numbers of a given list of numbers. """
|
sum_negativenum = list(filter(lambda nums: nums < 0, nums))
|
code_infilling
|
python
|
python
|
MBPP/133/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"[2, 4, -6, -9, 11, -12, 14, -5, 17]",
"-32"
],
[
"[10,15,-14,13,-18,12,-20]",
"-52"
],
[
"[19, -65, 57, 39, 152,-639, 121, 44, 90, -190]",
"-894"
]
] |
sum_negativenum
|
[] |
Write a function to calculate the sum of the negative numbers of a given list of numbers.
|
def sum_negativenum(nums):
"""Write a function to calculate the sum of the negative numbers of a given list of numbers. """
sum_negativenum = list(filter(lambda nums: nums < 0, nums))
|
return sum(sum_negativenum)
|
|
code_infilling
|
python
|
python
|
MBPP/135/L1
|
[] |
[] |
MBPP_Infilling
|
[
[
"10",
"190"
],
[
"5",
"45"
],
[
"7",
"91"
]
] |
hexagonal_num
|
[] |
Write a function to find the nth hexagonal number.
|
def hexagonal_num(n):
"""Write a function to find the nth hexagonal number. """
|
return n * (2 * n - 1)
|
|
code_infilling
|
python
|
python
|
MBPP/137/L3
|
[] |
[] |
MBPP_Infilling
|
n1 = 0
for x in nums:
if x == 0:
n1 += 1
else:
None
return n1 / (n - n1)
|
[] |
zero_count
|
[
"from array import array"
] |
Write a function to find the ratio of zeroes to non-zeroes in an array of integers.
|
from array import array
def zero_count(nums):
"""Write a function to find the ratio of zeroes to non-zeroes in an array of integers. """
|
n = len(nums)
|
code_infilling
|
python
|
python
|
MBPP/137/L4
|
[] |
[] |
MBPP_Infilling
|
for x in nums:
if x == 0:
n1 += 1
else:
None
return n1 / (n - n1)
|
[] |
zero_count
|
[
"from array import array"
] |
Write a function to find the ratio of zeroes to non-zeroes in an array of integers.
|
from array import array
def zero_count(nums):
"""Write a function to find the ratio of zeroes to non-zeroes in an array of integers. """
n = len(nums)
|
n1 = 0
|
code_infilling
|
python
|
python
|
MBPP/137/L5
|
[] |
[] |
MBPP_Infilling
|
if x == 0:
n1 += 1
else:
None
return n1 / (n - n1)
|
[] |
zero_count
|
[
"from array import array"
] |
Write a function to find the ratio of zeroes to non-zeroes in an array of integers.
|
from array import array
def zero_count(nums):
"""Write a function to find the ratio of zeroes to non-zeroes in an array of integers. """
n = len(nums)
n1 = 0
|
for x in nums:
|
code_infilling
|
python
|
python
|
MBPP/137/L6
|
[] |
[] |
MBPP_Infilling
|
n1 += 1
else:
None
return n1 / (n - n1)
|
[] |
zero_count
|
[
"from array import array"
] |
Write a function to find the ratio of zeroes to non-zeroes in an array of integers.
|
from array import array
def zero_count(nums):
"""Write a function to find the ratio of zeroes to non-zeroes in an array of integers. """
n = len(nums)
n1 = 0
for x in nums:
|
if x == 0:
|
code_infilling
|
python
|
python
|
MBPP/137/L7
|
[] |
[] |
MBPP_Infilling
|
else:
None
return n1 / (n - n1)
|
[] |
zero_count
|
[
"from array import array"
] |
Write a function to find the ratio of zeroes to non-zeroes in an array of integers.
|
from array import array
def zero_count(nums):
"""Write a function to find the ratio of zeroes to non-zeroes in an array of integers. """
n = len(nums)
n1 = 0
for x in nums:
if x == 0:
|
n1 += 1
|
code_infilling
|
python
|
python
|
MBPP/137/L8
|
[] |
[] |
MBPP_Infilling
|
None
return n1 / (n - n1)
|
[] |
zero_count
|
[
"from array import array"
] |
Write a function to find the ratio of zeroes to non-zeroes in an array of integers.
|
from array import array
def zero_count(nums):
"""Write a function to find the ratio of zeroes to non-zeroes in an array of integers. """
n = len(nums)
n1 = 0
for x in nums:
if x == 0:
n1 += 1
|
else:
|
code_infilling
|
python
|
python
|
MBPP/137/L9
|
[] |
[] |
MBPP_Infilling
|
return n1 / (n - n1)
|
[] |
zero_count
|
[
"from array import array"
] |
Write a function to find the ratio of zeroes to non-zeroes in an array of integers.
|
from array import array
def zero_count(nums):
"""Write a function to find the ratio of zeroes to non-zeroes in an array of integers. """
n = len(nums)
n1 = 0
for x in nums:
if x == 0:
n1 += 1
else:
|
None
|
code_infilling
|
python
|
python
|
MBPP/137/L10
|
[] |
[] |
MBPP_Infilling
|
[] |
zero_count
|
[
"from array import array"
] |
Write a function to find the ratio of zeroes to non-zeroes in an array of integers.
|
from array import array
def zero_count(nums):
"""Write a function to find the ratio of zeroes to non-zeroes in an array of integers. """
n = len(nums)
n1 = 0
for x in nums:
if x == 0:
n1 += 1
else:
None
|
return n1 / (n - n1)
|
|
code_infilling
|
python
|
python
|
MBPP/138/L1
|
[] |
[] |
MBPP_Infilling
|
return False
else:
return True
|
[
[
"10",
"True"
],
[
"7",
"False"
],
[
"14",
"True"
]
] |
is_Sum_Of_Powers_Of_Two
|
[] |
Write a python function to check whether the given number can be represented as sum of non-zero powers of 2 or not.
|
def is_Sum_Of_Powers_Of_Two(n):
"""Write a python function to check whether the given number can be represented as sum of non-zero powers of 2 or not. """
|
if n % 2 == 1:
|
code_infilling
|
python
|
python
|
MBPP/138/L2
|
[] |
[] |
MBPP_Infilling
|
else:
return True
|
[
[
"10",
"True"
],
[
"7",
"False"
],
[
"14",
"True"
]
] |
is_Sum_Of_Powers_Of_Two
|
[] |
Write a python function to check whether the given number can be represented as sum of non-zero powers of 2 or not.
|
def is_Sum_Of_Powers_Of_Two(n):
"""Write a python function to check whether the given number can be represented as sum of non-zero powers of 2 or not. """
if n % 2 == 1:
|
return False
|
code_infilling
|
python
|
python
|
MBPP/138/L3
|
[] |
[] |
MBPP_Infilling
|
return True
|
[
[
"10",
"True"
],
[
"7",
"False"
],
[
"14",
"True"
]
] |
is_Sum_Of_Powers_Of_Two
|
[] |
Write a python function to check whether the given number can be represented as sum of non-zero powers of 2 or not.
|
def is_Sum_Of_Powers_Of_Two(n):
"""Write a python function to check whether the given number can be represented as sum of non-zero powers of 2 or not. """
if n % 2 == 1:
return False
|
else:
|
code_infilling
|
python
|
python
|
MBPP/138/L4
|
[] |
[] |
MBPP_Infilling
|
[
[
"10",
"True"
],
[
"7",
"False"
],
[
"14",
"True"
]
] |
is_Sum_Of_Powers_Of_Two
|
[] |
Write a python function to check whether the given number can be represented as sum of non-zero powers of 2 or not.
|
def is_Sum_Of_Powers_Of_Two(n):
"""Write a python function to check whether the given number can be represented as sum of non-zero powers of 2 or not. """
if n % 2 == 1:
return False
else:
|
return True
|
|
code_infilling
|
python
|
python
|
MBPP/139/L1
|
[] |
[] |
MBPP_Infilling
|
return perimeter
|
[] |
circle_circumference
|
[] |
Write a function to find the circumference of a circle.
|
def circle_circumference(r):
"""Write a function to find the circumference of a circle. """
|
perimeter = 2 * 3.1415 * r
|
code_infilling
|
python
|
python
|
MBPP/139/L2
|
[] |
[] |
MBPP_Infilling
|
[] |
circle_circumference
|
[] |
Write a function to find the circumference of a circle.
|
def circle_circumference(r):
"""Write a function to find the circumference of a circle. """
perimeter = 2 * 3.1415 * r
|
return perimeter
|
|
code_infilling
|
python
|
python
|
MBPP/140/L1
|
[] |
[] |
MBPP_Infilling
|
temp = set()
for inner in test_list:
for ele in inner:
if not ele in temp:
temp.add(ele)
res.append(ele)
return res
|
[
[
"[(3, 4, 5), (4, 5, 7), (1, 4)]",
"set([3, 4, 5, 7, 1])"
],
[
"[(1, 2, 3), (4, 2, 3), (7, 8)]",
"set([1, 2, 3, 4, 7, 8])"
],
[
"[(7, 8, 9), (10, 11, 12), (10, 11)]",
"set([7, 8, 9, 10, 11, 12])"
]
] |
extract_singly
|
[] |
Write a function to flatten the list of lists into a single set of numbers.
|
def extract_singly(test_list):
"""Write a function to flatten the list of lists into a single set of numbers. """
|
res = []
|
code_infilling
|
python
|
python
|
MBPP/140/L2
|
[] |
[] |
MBPP_Infilling
|
for inner in test_list:
for ele in inner:
if not ele in temp:
temp.add(ele)
res.append(ele)
return res
|
[
[
"[(3, 4, 5), (4, 5, 7), (1, 4)]",
"set([3, 4, 5, 7, 1])"
],
[
"[(1, 2, 3), (4, 2, 3), (7, 8)]",
"set([1, 2, 3, 4, 7, 8])"
],
[
"[(7, 8, 9), (10, 11, 12), (10, 11)]",
"set([7, 8, 9, 10, 11, 12])"
]
] |
extract_singly
|
[] |
Write a function to flatten the list of lists into a single set of numbers.
|
def extract_singly(test_list):
"""Write a function to flatten the list of lists into a single set of numbers. """
res = []
|
temp = set()
|
code_infilling
|
python
|
python
|
MBPP/140/L3
|
[] |
[] |
MBPP_Infilling
|
for ele in inner:
if not ele in temp:
temp.add(ele)
res.append(ele)
return res
|
[
[
"[(3, 4, 5), (4, 5, 7), (1, 4)]",
"set([3, 4, 5, 7, 1])"
],
[
"[(1, 2, 3), (4, 2, 3), (7, 8)]",
"set([1, 2, 3, 4, 7, 8])"
],
[
"[(7, 8, 9), (10, 11, 12), (10, 11)]",
"set([7, 8, 9, 10, 11, 12])"
]
] |
extract_singly
|
[] |
Write a function to flatten the list of lists into a single set of numbers.
|
def extract_singly(test_list):
"""Write a function to flatten the list of lists into a single set of numbers. """
res = []
temp = set()
|
for inner in test_list:
|
code_infilling
|
python
|
python
|
MBPP/140/L4
|
[] |
[] |
MBPP_Infilling
|
if not ele in temp:
temp.add(ele)
res.append(ele)
return res
|
[
[
"[(3, 4, 5), (4, 5, 7), (1, 4)]",
"set([3, 4, 5, 7, 1])"
],
[
"[(1, 2, 3), (4, 2, 3), (7, 8)]",
"set([1, 2, 3, 4, 7, 8])"
],
[
"[(7, 8, 9), (10, 11, 12), (10, 11)]",
"set([7, 8, 9, 10, 11, 12])"
]
] |
extract_singly
|
[] |
Write a function to flatten the list of lists into a single set of numbers.
|
def extract_singly(test_list):
"""Write a function to flatten the list of lists into a single set of numbers. """
res = []
temp = set()
for inner in test_list:
|
for ele in inner:
|
code_infilling
|
python
|
python
|
MBPP/140/L5
|
[] |
[] |
MBPP_Infilling
|
temp.add(ele)
res.append(ele)
return res
|
[
[
"[(3, 4, 5), (4, 5, 7), (1, 4)]",
"set([3, 4, 5, 7, 1])"
],
[
"[(1, 2, 3), (4, 2, 3), (7, 8)]",
"set([1, 2, 3, 4, 7, 8])"
],
[
"[(7, 8, 9), (10, 11, 12), (10, 11)]",
"set([7, 8, 9, 10, 11, 12])"
]
] |
extract_singly
|
[] |
Write a function to flatten the list of lists into a single set of numbers.
|
def extract_singly(test_list):
"""Write a function to flatten the list of lists into a single set of numbers. """
res = []
temp = set()
for inner in test_list:
for ele in inner:
|
if not ele in temp:
|
code_infilling
|
python
|
python
|
MBPP/140/L6
|
[] |
[] |
MBPP_Infilling
|
res.append(ele)
return res
|
[
[
"[(3, 4, 5), (4, 5, 7), (1, 4)]",
"set([3, 4, 5, 7, 1])"
],
[
"[(1, 2, 3), (4, 2, 3), (7, 8)]",
"set([1, 2, 3, 4, 7, 8])"
],
[
"[(7, 8, 9), (10, 11, 12), (10, 11)]",
"set([7, 8, 9, 10, 11, 12])"
]
] |
extract_singly
|
[] |
Write a function to flatten the list of lists into a single set of numbers.
|
def extract_singly(test_list):
"""Write a function to flatten the list of lists into a single set of numbers. """
res = []
temp = set()
for inner in test_list:
for ele in inner:
if not ele in temp:
|
temp.add(ele)
|
code_infilling
|
python
|
python
|
MBPP/140/L7
|
[] |
[] |
MBPP_Infilling
|
return res
|
[
[
"[(3, 4, 5), (4, 5, 7), (1, 4)]",
"set([3, 4, 5, 7, 1])"
],
[
"[(1, 2, 3), (4, 2, 3), (7, 8)]",
"set([1, 2, 3, 4, 7, 8])"
],
[
"[(7, 8, 9), (10, 11, 12), (10, 11)]",
"set([7, 8, 9, 10, 11, 12])"
]
] |
extract_singly
|
[] |
Write a function to flatten the list of lists into a single set of numbers.
|
def extract_singly(test_list):
"""Write a function to flatten the list of lists into a single set of numbers. """
res = []
temp = set()
for inner in test_list:
for ele in inner:
if not ele in temp:
temp.add(ele)
|
res.append(ele)
|
code_infilling
|
python
|
python
|
MBPP/140/L8
|
[] |
[] |
MBPP_Infilling
|
[
[
"[(3, 4, 5), (4, 5, 7), (1, 4)]",
"set([3, 4, 5, 7, 1])"
],
[
"[(1, 2, 3), (4, 2, 3), (7, 8)]",
"set([1, 2, 3, 4, 7, 8])"
],
[
"[(7, 8, 9), (10, 11, 12), (10, 11)]",
"set([7, 8, 9, 10, 11, 12])"
]
] |
extract_singly
|
[] |
Write a function to flatten the list of lists into a single set of numbers.
|
def extract_singly(test_list):
"""Write a function to flatten the list of lists into a single set of numbers. """
res = []
temp = set()
for inner in test_list:
for ele in inner:
if not ele in temp:
temp.add(ele)
res.append(ele)
|
return res
|
|
code_infilling
|
python
|
python
|
MBPP/141/L1
|
[] |
[] |
MBPP_Infilling
|
while arr_len > 1:
mi = nums.index(max(nums[0:arr_len]))
nums = nums[mi::-1] + nums[mi + 1:len(nums)]
nums = nums[arr_len - 1::-1] + nums[arr_len:len(nums)]
arr_len -= 1
return nums
|
[
[
"[15, 79, 25, 38, 69]",
"[15, 25, 38, 69, 79]"
],
[
"[98, 12, 54, 36, 85]",
"[12, 36, 54, 85, 98]"
],
[
"[41, 42, 32, 12, 23]",
"[12, 23, 32, 41, 42]"
]
] |
pancake_sort
|
[] |
Write a function to sort a list of elements.
|
def pancake_sort(nums):
"""Write a function to sort a list of elements. """
|
arr_len = len(nums)
|
code_infilling
|
python
|
python
|
MBPP/141/L2
|
[] |
[] |
MBPP_Infilling
|
mi = nums.index(max(nums[0:arr_len]))
nums = nums[mi::-1] + nums[mi + 1:len(nums)]
nums = nums[arr_len - 1::-1] + nums[arr_len:len(nums)]
arr_len -= 1
return nums
|
[
[
"[15, 79, 25, 38, 69]",
"[15, 25, 38, 69, 79]"
],
[
"[98, 12, 54, 36, 85]",
"[12, 36, 54, 85, 98]"
],
[
"[41, 42, 32, 12, 23]",
"[12, 23, 32, 41, 42]"
]
] |
pancake_sort
|
[] |
Write a function to sort a list of elements.
|
def pancake_sort(nums):
"""Write a function to sort a list of elements. """
arr_len = len(nums)
|
while arr_len > 1:
|
code_infilling
|
python
|
python
|
MBPP/141/L3
|
[] |
[] |
MBPP_Infilling
|
nums = nums[mi::-1] + nums[mi + 1:len(nums)]
nums = nums[arr_len - 1::-1] + nums[arr_len:len(nums)]
arr_len -= 1
return nums
|
[
[
"[15, 79, 25, 38, 69]",
"[15, 25, 38, 69, 79]"
],
[
"[98, 12, 54, 36, 85]",
"[12, 36, 54, 85, 98]"
],
[
"[41, 42, 32, 12, 23]",
"[12, 23, 32, 41, 42]"
]
] |
pancake_sort
|
[] |
Write a function to sort a list of elements.
|
def pancake_sort(nums):
"""Write a function to sort a list of elements. """
arr_len = len(nums)
while arr_len > 1:
|
mi = nums.index(max(nums[0:arr_len]))
|
code_infilling
|
python
|
python
|
MBPP/141/L4
|
[] |
[] |
MBPP_Infilling
|
nums = nums[arr_len - 1::-1] + nums[arr_len:len(nums)]
arr_len -= 1
return nums
|
[
[
"[15, 79, 25, 38, 69]",
"[15, 25, 38, 69, 79]"
],
[
"[98, 12, 54, 36, 85]",
"[12, 36, 54, 85, 98]"
],
[
"[41, 42, 32, 12, 23]",
"[12, 23, 32, 41, 42]"
]
] |
pancake_sort
|
[] |
Write a function to sort a list of elements.
|
def pancake_sort(nums):
"""Write a function to sort a list of elements. """
arr_len = len(nums)
while arr_len > 1:
mi = nums.index(max(nums[0:arr_len]))
|
nums = nums[mi::-1] + nums[mi + 1:len(nums)]
|
code_infilling
|
python
|
python
|
MBPP/141/L5
|
[] |
[] |
MBPP_Infilling
|
arr_len -= 1
return nums
|
[
[
"[15, 79, 25, 38, 69]",
"[15, 25, 38, 69, 79]"
],
[
"[98, 12, 54, 36, 85]",
"[12, 36, 54, 85, 98]"
],
[
"[41, 42, 32, 12, 23]",
"[12, 23, 32, 41, 42]"
]
] |
pancake_sort
|
[] |
Write a function to sort a list of elements.
|
def pancake_sort(nums):
"""Write a function to sort a list of elements. """
arr_len = len(nums)
while arr_len > 1:
mi = nums.index(max(nums[0:arr_len]))
nums = nums[mi::-1] + nums[mi + 1:len(nums)]
|
nums = nums[arr_len - 1::-1] + nums[arr_len:len(nums)]
|
code_infilling
|
python
|
python
|
MBPP/141/L6
|
[] |
[] |
MBPP_Infilling
|
return nums
|
[
[
"[15, 79, 25, 38, 69]",
"[15, 25, 38, 69, 79]"
],
[
"[98, 12, 54, 36, 85]",
"[12, 36, 54, 85, 98]"
],
[
"[41, 42, 32, 12, 23]",
"[12, 23, 32, 41, 42]"
]
] |
pancake_sort
|
[] |
Write a function to sort a list of elements.
|
def pancake_sort(nums):
"""Write a function to sort a list of elements. """
arr_len = len(nums)
while arr_len > 1:
mi = nums.index(max(nums[0:arr_len]))
nums = nums[mi::-1] + nums[mi + 1:len(nums)]
nums = nums[arr_len - 1::-1] + nums[arr_len:len(nums)]
|
arr_len -= 1
|
code_infilling
|
python
|
python
|
MBPP/141/L7
|
[] |
[] |
MBPP_Infilling
|
[
[
"[15, 79, 25, 38, 69]",
"[15, 25, 38, 69, 79]"
],
[
"[98, 12, 54, 36, 85]",
"[12, 36, 54, 85, 98]"
],
[
"[41, 42, 32, 12, 23]",
"[12, 23, 32, 41, 42]"
]
] |
pancake_sort
|
[] |
Write a function to sort a list of elements.
|
def pancake_sort(nums):
"""Write a function to sort a list of elements. """
arr_len = len(nums)
while arr_len > 1:
mi = nums.index(max(nums[0:arr_len]))
nums = nums[mi::-1] + nums[mi + 1:len(nums)]
nums = nums[arr_len - 1::-1] + nums[arr_len:len(nums)]
arr_len -= 1
|
return nums
|
|
code_infilling
|
python
|
python
|
MBPP/142/L1
|
[] |
[] |
MBPP_Infilling
|
return result
|
[
[
"[1,2,3,4,5,6,7,8],[2,2,3,1,2,6,7,9],[2,1,3,1,2,6,7,9]",
"3"
],
[
"[1,2,3,4,5,6,7,8],[2,2,3,1,2,6,7,8],[2,1,3,1,2,6,7,8]",
"4"
],
[
"[1,2,3,4,2,6,7,8],[2,2,3,1,2,6,7,8],[2,1,3,1,2,6,7,8]",
"5"
]
] |
count_samepair
|
[] |
Write a function to count number items that are identical in the same position of three given lists.
|
def count_samepair(list1, list2, list3):
"""Write a function to count number items that are identical in the same position of three given lists. """
|
result = sum((m == n == o for (m, n, o) in zip(list1, list2, list3)))
|
code_infilling
|
python
|
python
|
MBPP/142/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"[1,2,3,4,5,6,7,8],[2,2,3,1,2,6,7,9],[2,1,3,1,2,6,7,9]",
"3"
],
[
"[1,2,3,4,5,6,7,8],[2,2,3,1,2,6,7,8],[2,1,3,1,2,6,7,8]",
"4"
],
[
"[1,2,3,4,2,6,7,8],[2,2,3,1,2,6,7,8],[2,1,3,1,2,6,7,8]",
"5"
]
] |
count_samepair
|
[] |
Write a function to count number items that are identical in the same position of three given lists.
|
def count_samepair(list1, list2, list3):
"""Write a function to count number items that are identical in the same position of three given lists. """
result = sum((m == n == o for (m, n, o) in zip(list1, list2, list3)))
|
return result
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.