source_file
stringclasses 4
values | task_id
int64 0
256
| prompt
stringlengths 39
252
| code
stringlengths 36
906
| test_imports
sequencelengths 0
0
| test_list
sequencelengths 3
5
| exe_method
stringclasses 1
value | test_time_limit
int64 1
1
| solutions
null | dataset
stringclasses 1
value | test_input
sequencelengths 3
5
| test_output
sequencelengths 3
5
| example_input
sequencelengths 2
2
| example_output
sequencelengths 2
2
| question
stringlengths 752
4.29k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Benchmark Questions Verification V2.ipynb | 118 | Write a function to find the intersection of two arrays. | def intersection_array(array_nums1,array_nums2):
result = list(filter(lambda x: x in array_nums1, array_nums2))
return result | [] | [
"assert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[1, 2, 4, 8, 9])==[1, 2, 8, 9]",
"assert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[3,5,7,9])==[3,5,7,9]",
"assert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[10,20,30,40])==[10]"
] | stdin | 1 | null | MBPP | [
"1 2 3 5 7 8 9 10\n1 2 4 8 9\n",
"1 2 3 5 7 8 9 10\n3 5 7 9\n",
"1 2 3 5 7 8 9 10\n10 20 30 40\n"
] | [
"1 2 8 9\n",
"3 5 7 9\n",
"10\n"
] | [
"1 2 3 5 7 8 9 10\n1 2 4 8 9\n",
"1 2 3 5 7 8 9 10\n3 5 7 9\n"
] | [
"1 2 8 9\n",
"3 5 7 9\n"
] | Original problem description:
Write a function to find the intersection of two arrays.
We have its functional test sample:
assert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[1, 2, 4, 8, 9])==[1, 2, 8, 9]
assert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[3,5,7,9])==[3,5,7,9]
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
1 2 3 5 7 8 9 10
1 2 4 8 9
Output:
1 2 8 9
Example 2:
Input:
1 2 3 5 7 8 9 10
3 5 7 9
Output:
3 5 7 9
|
Benchmark Questions Verification V2.ipynb | 119 | Write a python function that takes in a tuple and an element and counts the occcurences of the element in the tuple. | def count_X(tup, x):
count = 0
for ele in tup:
if (ele == x):
count = count + 1
return count | [] | [
"assert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),4) == 0",
"assert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),10) == 3",
"assert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),8) == 4"
] | stdin | 1 | null | MBPP | [
"10 8 5 2 10 15 10 8 5 8 8 2\n4\n",
"10 8 5 2 10 15 10 8 5 8 8 2\n10\n",
"10 8 5 2 10 15 10 8 5 8 8 2\n8\n"
] | [
"0\n",
"3\n",
"4\n"
] | [
"10 8 5 2 10 15 10 8 5 8 8 2\n4\n",
"10 8 5 2 10 15 10 8 5 8 8 2\n10\n"
] | [
"0\n",
"3\n"
] | Original problem description:
Write a python function that takes in a tuple and an element and counts the occcurences of the element in the tuple.
We have its functional test sample:
assert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),4) == 0
assert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),10) == 3
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
10 8 5 2 10 15 10 8 5 8 8 2
4
Output:
0
Example 2:
Input:
10 8 5 2 10 15 10 8 5 8 8 2
10
Output:
3
|
Benchmark Questions Verification V2.ipynb | 120 | Write a function that takes in a list and an element and inserts the element before each element in the list, and returns the resulting list. | def insert_element(list,element):
list = [v for elt in list for v in (element, elt)]
return list | [] | [
"assert insert_element(['Red', 'Green', 'Black'] ,'c')==['c', 'Red', 'c', 'Green', 'c', 'Black']",
"assert insert_element(['python', 'java'] ,'program')==['program', 'python', 'program', 'java']",
"assert insert_element(['happy', 'sad'] ,'laugh')==['laugh', 'happy', 'laugh', 'sad']"
] | stdin | 1 | null | MBPP | [
"Red Green Black\nc\n",
"python java\nprogram\n",
"happy sad\nlaugh\n"
] | [
"c Red c Green c Black\n",
"program python program java\n",
"laugh happy laugh sad\n"
] | [
"Red Green Black\nc\n",
"python java\nprogram\n"
] | [
"c Red c Green c Black\n",
"program python program java\n"
] | Original problem description:
Write a function that takes in a list and an element and inserts the element before each element in the list, and returns the resulting list.
We have its functional test sample:
assert insert_element(['Red', 'Green', 'Black'] ,'c')==['c', 'Red', 'c', 'Green', 'c', 'Black']
assert insert_element(['python', 'java'] ,'program')==['program', 'python', 'program', 'java']
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
Red Green Black
c
Output:
c Red c Green c Black
Example 2:
Input:
python java
program
Output:
program python program java
|
Benchmark Questions Verification V2.ipynb | 121 | Write a python function to convert complex numbers to polar coordinates. | import cmath
def convert(numbers):
num = cmath.polar(numbers)
return (num) | [] | [
"assert convert(1) == (1.0, 0.0)",
"assert convert(4) == (4.0,0.0)",
"assert convert(5) == (5.0,0.0)"
] | stdin | 1 | null | MBPP | [
"1\n",
"4\n",
"5\n"
] | [
"1.0 0.0\n",
"4.0 0.0\n",
"5.0 0.0\n"
] | [
"1\n",
"4\n"
] | [
"1.0 0.0\n",
"4.0 0.0\n"
] | Original problem description:
Write a python function to convert complex numbers to polar coordinates.
We have its functional test sample:
assert convert(1) == (1.0, 0.0)
assert convert(4) == (4.0,0.0)
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
1
Output:
1.0 0.0
Example 2:
Input:
4
Output:
4.0 0.0
|
Benchmark Questions Verification V2.ipynb | 122 | Write a python function that returns the number of integer elements in a given list. | def count_integer(list1):
ctr = 0
for i in list1:
if isinstance(i, int):
ctr = ctr + 1
return ctr | [] | [
"assert count_integer([1,2,'abc',1.2]) == 2",
"assert count_integer([1,2,3]) == 3",
"assert count_integer([1,1.2,4,5.1]) == 2"
] | stdin | 1 | null | MBPP | [
"1 2 abc 1.2\n",
"1 2 3\n",
"1 1.2 4 5.1\n"
] | [
"2\n",
"3\n",
"2\n"
] | [
"1 2 abc 1.2\n",
"1 2 3\n"
] | [
"2\n",
"3\n"
] | Original problem description:
Write a python function that returns the number of integer elements in a given list.
We have its functional test sample:
assert count_integer([1,2,'abc',1.2]) == 2
assert count_integer([1,2,3]) == 3
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
1 2 abc 1.2
Output:
2
Example 2:
Input:
1 2 3
Output:
3
|
Benchmark Questions Verification V2.ipynb | 123 | Write a function that takes in a list and length n, and generates all combinations (with repetition) of the elements of the list and returns a list with a tuple for each combination. | from itertools import combinations_with_replacement
def combinations_colors(l, n):
return list(combinations_with_replacement(l,n))
| [] | [
"assert combinations_colors( [\"Red\",\"Green\",\"Blue\"],1)==[('Red',), ('Green',), ('Blue',)]",
"assert combinations_colors( [\"Red\",\"Green\",\"Blue\"],2)==[('Red', 'Red'), ('Red', 'Green'), ('Red', 'Blue'), ('Green', 'Green'), ('Green', 'Blue'), ('Blue', 'Blue')]",
"assert combinations_colors( [\"Red\",\"Green\",\"Blue\"],3)==[('Red', 'Red', 'Red'), ('Red', 'Red', 'Green'), ('Red', 'Red', 'Blue'), ('Red', 'Green', 'Green'), ('Red', 'Green', 'Blue'), ('Red', 'Blue', 'Blue'), ('Green', 'Green', 'Green'), ('Green', 'Green', 'Blue'), ('Green', 'Blue', 'Blue'), ('Blue', 'Blue', 'Blue')]"
] | stdin | 1 | null | MBPP | [
"Red Green Blue\n1\n",
"Red Green Blue\n2\n",
"Red Green Blue\n3\n"
] | [
"Red\nGreen\nBlue\n",
"Red Red\nRed Green\nRed Blue\nGreen Green\nGreen Blue\nBlue Blue\n",
"Red Red Red\nRed Red Green\nRed Red Blue\nRed Green Green\nRed Green Blue\nRed Blue Blue\nGreen Green Green\nGreen Green Blue\nGreen Blue Blue\nBlue Blue Blue\n"
] | [
"Red Green Blue\n1\n",
"Red Green Blue\n2\n"
] | [
"Red\nGreen\nBlue\n",
"Red Red\nRed Green\nRed Blue\nGreen Green\nGreen Blue\nBlue Blue\n"
] | Original problem description:
Write a function that takes in a list and length n, and generates all combinations (with repetition) of the elements of the list and returns a list with a tuple for each combination.
We have its functional test sample:
assert combinations_colors( ["Red","Green","Blue"],1)==[('Red',), ('Green',), ('Blue',)]
assert combinations_colors( ["Red","Green","Blue"],2)==[('Red', 'Red'), ('Red', 'Green'), ('Red', 'Blue'), ('Green', 'Green'), ('Green', 'Blue'), ('Blue', 'Blue')]
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
Red Green Blue
1
Output:
Red
Green
Blue
Example 2:
Input:
Red Green Blue
2
Output:
Red Red
Red Green
Red Blue
Green Green
Green Blue
Blue Blue
|
Benchmark Questions Verification V2.ipynb | 124 | Write a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number. | def count_Primes_nums(n):
ctr = 0
for num in range(n):
if num <= 1:
continue
for i in range(2,num):
if (num % i) == 0:
break
else:
ctr += 1
return ctr | [] | [
"assert count_Primes_nums(5) == 2",
"assert count_Primes_nums(10) == 4",
"assert count_Primes_nums(100) == 25"
] | stdin | 1 | null | MBPP | [
"5\n",
"10\n",
"100\n"
] | [
"2\n",
"4\n",
"25\n"
] | [
"5\n",
"10\n"
] | [
"2\n",
"4\n"
] | Original problem description:
Write a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number.
We have its functional test sample:
assert count_Primes_nums(5) == 2
assert count_Primes_nums(10) == 4
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
5
Output:
2
Example 2:
Input:
10
Output:
4
|
Benchmark Questions Verification V2.ipynb | 125 | Write a function that takes in two numbers and returns a tuple with the second number and then the first number. | def swap_numbers(a,b):
temp = a
a = b
b = temp
return (a,b) | [] | [
"assert swap_numbers(10,20)==(20,10)",
"assert swap_numbers(15,17)==(17,15)",
"assert swap_numbers(100,200)==(200,100)"
] | stdin | 1 | null | MBPP | [
"10\n20\n",
"15\n17\n",
"100\n200\n"
] | [
"20 10\n",
"17 15\n",
"200 100\n"
] | [
"10\n20\n",
"15\n17\n"
] | [
"20 10\n",
"17 15\n"
] | Original problem description:
Write a function that takes in two numbers and returns a tuple with the second number and then the first number.
We have its functional test sample:
assert swap_numbers(10,20)==(20,10)
assert swap_numbers(15,17)==(17,15)
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
10
20
Output:
20 10
Example 2:
Input:
15
17
Output:
17 15
|
Benchmark Questions Verification V2.ipynb | 127 | Write a function to find the nth newman–shanks–williams prime number. | def newman_prime(n):
if n == 0 or n == 1:
return 1
return 2 * newman_prime(n - 1) + newman_prime(n - 2) | [] | [
"assert newman_prime(3) == 7",
"assert newman_prime(4) == 17",
"assert newman_prime(5) == 41"
] | stdin | 1 | null | MBPP | [
"3\n",
"4\n",
"5\n"
] | [
"7\n",
"17\n",
"41\n"
] | [
"3\n",
"4\n"
] | [
"7\n",
"17\n"
] | Original problem description:
Write a function to find the nth newman–shanks–williams prime number.
We have its functional test sample:
assert newman_prime(3) == 7
assert newman_prime(4) == 17
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
3
Output:
7
Example 2:
Input:
4
Output:
17
|
Benchmark Questions Verification V2.ipynb | 128 | Write a function that takes in two tuples and performs mathematical division operation element-wise across the given tuples. | def division_elements(test_tup1, test_tup2):
res = tuple(ele1 // ele2 for ele1, ele2 in zip(test_tup1, test_tup2))
return (res) | [] | [
"assert division_elements((10, 4, 6, 9),(5, 2, 3, 3)) == (2, 2, 2, 3)",
"assert division_elements((12, 6, 8, 16),(6, 3, 4, 4)) == (2, 2, 2, 4)",
"assert division_elements((20, 14, 36, 18),(5, 7, 6, 9)) == (4, 2, 6, 2)"
] | stdin | 1 | null | MBPP | [
"10 4 6 9\n5 2 3 3\n",
"12 6 8 16\n6 3 4 4\n",
"20 14 36 18\n5 7 6 9\n"
] | [
"2 2 2 3\n",
"2 2 2 4\n",
"4 2 6 2\n"
] | [
"10 4 6 9\n5 2 3 3\n",
"12 6 8 16\n6 3 4 4\n"
] | [
"2 2 2 3\n",
"2 2 2 4\n"
] | Original problem description:
Write a function that takes in two tuples and performs mathematical division operation element-wise across the given tuples.
We have its functional test sample:
assert division_elements((10, 4, 6, 9),(5, 2, 3, 3)) == (2, 2, 2, 3)
assert division_elements((12, 6, 8, 16),(6, 3, 4, 4)) == (2, 2, 2, 4)
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
10 4 6 9
5 2 3 3
Output:
2 2 2 3
Example 2:
Input:
12 6 8 16
6 3 4 4
Output:
2 2 2 4
|
Benchmark Questions Verification V2.ipynb | 130 | Write a function to calculate a dog's age in dog's years. | def dog_age(h_age):
if h_age < 0:
exit()
elif h_age <= 2:
d_age = h_age * 10.5
else:
d_age = 21 + (h_age - 2)*4
return d_age | [] | [
"assert dog_age(12)==61",
"assert dog_age(15)==73",
"assert dog_age(24)==109"
] | stdin | 1 | null | MBPP | [
"12\n",
"15\n",
"24\n"
] | [
"61\n",
"73\n",
"109\n"
] | [
"12\n",
"15\n"
] | [
"61\n",
"73\n"
] | Original problem description:
Write a function to calculate a dog's age in dog's years.
We have its functional test sample:
assert dog_age(12)==61
assert dog_age(15)==73
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
12
Output:
61
Example 2:
Input:
15
Output:
73
|
Benchmark Questions Verification V2.ipynb | 131 | Write a function that takes in a list and an integer n and splits a list for every nth element, returning a list of the resulting lists. | def list_split(S, step):
return [S[i::step] for i in range(step)] | [] | [
"assert list_split(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'],3)==[['a', 'd', 'g', 'j', 'm'], ['b', 'e', 'h', 'k', 'n'], ['c', 'f', 'i', 'l']]",
"assert list_split([1,2,3,4,5,6,7,8,9,10,11,12,13,14],3)==[[1,4,7,10,13], [2,5,8,11,14], [3,6,9,12]]",
"assert list_split(['python','java','C','C++','DBMS','SQL'],2)==[['python', 'C', 'DBMS'], ['java', 'C++', 'SQL']]"
] | stdin | 1 | null | MBPP | [
"a b c d e f g h i j k l m n\n3\n",
"1 2 3 4 5 6 7 8 9 10 11 12 13 14\n3\n",
"python java C C++ DBMS SQL\n2\n"
] | [
"a d g j m\nb e h k n\nc f i l\n",
"1 4 7 10 13\n2 5 8 11 14\n3 6 9 12\n",
"python C DBMS\njava C++ SQL\n"
] | [
"a b c d e f g h i j k l m n\n3\n",
"1 2 3 4 5 6 7 8 9 10 11 12 13 14\n3\n"
] | [
"a d g j m\nb e h k n\nc f i l\n",
"1 4 7 10 13\n2 5 8 11 14\n3 6 9 12\n"
] | Original problem description:
Write a function that takes in a list and an integer n and splits a list for every nth element, returning a list of the resulting lists.
We have its functional test sample:
assert list_split(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'],3)==[['a', 'd', 'g', 'j', 'm'], ['b', 'e', 'h', 'k', 'n'], ['c', 'f', 'i', 'l']]
assert list_split([1,2,3,4,5,6,7,8,9,10,11,12,13,14],3)==[[1,4,7,10,13], [2,5,8,11,14], [3,6,9,12]]
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
a b c d e f g h i j k l m n
3
Output:
a d g j m
b e h k n
c f i l
Example 2:
Input:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
3
Output:
1 4 7 10 13
2 5 8 11 14
3 6 9 12
|
Benchmark Questions Verification V2.ipynb | 132 | Write a function to find the lateral surface area of a cube given its side length. | def lateralsurface_cube(l):
LSA = 4 * (l * l)
return LSA | [] | [
"assert lateralsurface_cube(5)==100",
"assert lateralsurface_cube(9)==324",
"assert lateralsurface_cube(10)==400"
] | stdin | 1 | null | MBPP | [
"5\n",
"9\n",
"10\n"
] | [
"100\n",
"324\n",
"400\n"
] | [
"5\n",
"9\n"
] | [
"100\n",
"324\n"
] | Original problem description:
Write a function to find the lateral surface area of a cube given its side length.
We have its functional test sample:
assert lateralsurface_cube(5)==100
assert lateralsurface_cube(9)==324
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
5
Output:
100
Example 2:
Input:
9
Output:
324
|
Benchmark Questions Verification V2.ipynb | 133 | Write a python function that takes in an integer n and returns the sum of the squares of the first n odd natural numbers. | def square_Sum(n):
return int(n*(4*n*n-1)/3) | [] | [
"assert square_Sum(2) == 10",
"assert square_Sum(3) == 35",
"assert square_Sum(4) == 84"
] | stdin | 1 | null | MBPP | [
"2\n",
"3\n",
"4\n"
] | [
"10\n",
"35\n",
"84\n"
] | [
"2\n",
"3\n"
] | [
"10\n",
"35\n"
] | Original problem description:
Write a python function that takes in an integer n and returns the sum of the squares of the first n odd natural numbers.
We have its functional test sample:
assert square_Sum(2) == 10
assert square_Sum(3) == 35
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
2
Output:
10
Example 2:
Input:
3
Output:
35
|
Benchmark Questions Verification V2.ipynb | 134 | Write a function to find the n'th star number. | def find_star_num(n):
return (6 * n * (n - 1) + 1) | [] | [
"assert find_star_num(3) == 37",
"assert find_star_num(4) == 73",
"assert find_star_num(5) == 121"
] | stdin | 1 | null | MBPP | [
"3\n",
"4\n",
"5\n"
] | [
"37\n",
"73\n",
"121\n"
] | [
"3\n",
"4\n"
] | [
"37\n",
"73\n"
] | Original problem description:
Write a function to find the n'th star number.
We have its functional test sample:
assert find_star_num(3) == 37
assert find_star_num(4) == 73
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
3
Output:
37
Example 2:
Input:
4
Output:
73
|
Benchmark Questions Verification V2.ipynb | 135 | Write a function to find the ascii value of a character. | def ascii_value(k):
ch=k
return ord(ch) | [] | [
"assert ascii_value('A')==65",
"assert ascii_value('R')==82",
"assert ascii_value('S')==83"
] | stdin | 1 | null | MBPP | [
"A\n",
"R\n",
"S\n"
] | [
"65\n",
"82\n",
"83\n"
] | [
"A\n",
"R\n"
] | [
"65\n",
"82\n"
] | Original problem description:
Write a function to find the ascii value of a character.
We have its functional test sample:
assert ascii_value('A')==65
assert ascii_value('R')==82
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
A
Output:
65
Example 2:
Input:
R
Output:
82
|
Benchmark Questions Verification V2.ipynb | 136 | Write a python function to find the sum of even numbers at even positions of a list. | def sum_even_and_even_index(arr):
i = 0
sum = 0
for i in range(0, len(arr),2):
if (arr[i] % 2 == 0) :
sum += arr[i]
return sum | [] | [
"assert sum_even_and_even_index([5, 6, 12, 1, 18, 8]) == 30",
"assert sum_even_and_even_index([3, 20, 17, 9, 2, 10, 18, 13, 6, 18]) == 26",
"assert sum_even_and_even_index([5, 6, 12, 1]) == 12"
] | stdin | 1 | null | MBPP | [
"5 6 12 1 18 8\n",
"3 20 17 9 2 10 18 13 6 18\n",
"5 6 12 1\n"
] | [
"30\n",
"26\n",
"12\n"
] | [
"5 6 12 1 18 8\n",
"3 20 17 9 2 10 18 13 6 18\n"
] | [
"30\n",
"26\n"
] | Original problem description:
Write a python function to find the sum of even numbers at even positions of a list.
We have its functional test sample:
assert sum_even_and_even_index([5, 6, 12, 1, 18, 8]) == 30
assert sum_even_and_even_index([3, 20, 17, 9, 2, 10, 18, 13, 6, 18]) == 26
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
5 6 12 1 18 8
Output:
30
Example 2:
Input:
3 20 17 9 2 10 18 13 6 18
Output:
26
|
Benchmark Questions Verification V2.ipynb | 137 | Write a python function that takes in an integer n and finds the sum of the first n even natural numbers that are raised to the fifth power. | def even_Power_Sum(n):
sum = 0;
for i in range(1,n+1):
j = 2*i;
sum = sum + (j*j*j*j*j);
return sum; | [] | [
"assert even_Power_Sum(2) == 1056",
"assert even_Power_Sum(3) == 8832",
"assert even_Power_Sum(1) == 32"
] | stdin | 1 | null | MBPP | [
"2\n",
"3\n",
"1\n"
] | [
"1056\n",
"8832\n",
"32\n"
] | [
"2\n",
"3\n"
] | [
"1056\n",
"8832\n"
] | Original problem description:
Write a python function that takes in an integer n and finds the sum of the first n even natural numbers that are raised to the fifth power.
We have its functional test sample:
assert even_Power_Sum(2) == 1056
assert even_Power_Sum(3) == 8832
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
2
Output:
1056
Example 2:
Input:
3
Output:
8832
|
Benchmark Questions Verification V2.ipynb | 138 | Write a function that takes in a list of tuples and returns a list containing the rear element of each tuple. | def rear_extract(test_list):
res = [lis[-1] for lis in test_list]
return (res) | [] | [
"assert rear_extract([(1, 'Rash', 21), (2, 'Varsha', 20), (3, 'Kil', 19)]) == [21, 20, 19]",
"assert rear_extract([(1, 'Sai', 36), (2, 'Ayesha', 25), (3, 'Salman', 45)]) == [36, 25, 45]",
"assert rear_extract([(1, 'Sudeep', 14), (2, 'Vandana', 36), (3, 'Dawood', 56)]) == [14, 36, 56]"
] | stdin | 1 | null | MBPP | [
"1 Rash 21\n2 Varsha 20\n3 Kil 19\n",
"1 Sai 36\n2 Ayesha 25\n3 Salman 45\n",
"1 Sudeep 14\n2 Vandana 36\n3 Dawood 56\n"
] | [
"21 20 19\n",
"36 25 45\n",
"14 36 56\n"
] | [
"1 Rash 21\n2 Varsha 20\n3 Kil 19\n",
"1 Sai 36\n2 Ayesha 25\n3 Salman 45\n"
] | [
"21 20 19\n",
"36 25 45\n"
] | Original problem description:
Write a function that takes in a list of tuples and returns a list containing the rear element of each tuple.
We have its functional test sample:
assert rear_extract([(1, 'Rash', 21), (2, 'Varsha', 20), (3, 'Kil', 19)]) == [21, 20, 19]
assert rear_extract([(1, 'Sai', 36), (2, 'Ayesha', 25), (3, 'Salman', 45)]) == [36, 25, 45]
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
1 Rash 21
2 Varsha 20
3 Kil 19
Output:
21 20 19
Example 2:
Input:
1 Sai 36
2 Ayesha 25
3 Salman 45
Output:
36 25 45
|
Benchmark Questions Verification V2.ipynb | 139 | Write a function that takes in two tuples and subtracts the elements of the first tuple by the elements of the second tuple with the same index. | def substract_elements(test_tup1, test_tup2):
res = tuple(map(lambda i, j: i - j, test_tup1, test_tup2))
return (res) | [] | [
"assert substract_elements((10, 4, 5), (2, 5, 18)) == (8, -1, -13)",
"assert substract_elements((11, 2, 3), (24, 45 ,16)) == (-13, -43, -13)",
"assert substract_elements((7, 18, 9), (10, 11, 12)) == (-3, 7, -3)"
] | stdin | 1 | null | MBPP | [
"10 4 5\n2 5 18\n",
"11 2 3\n24 45 16\n",
"7 18 9\n10 11 12\n"
] | [
"8 -1 -13\n",
"-13 -43 -13\n",
"-3 7 -3\n"
] | [
"10 4 5\n2 5 18\n",
"11 2 3\n24 45 16\n"
] | [
"8 -1 -13\n",
"-13 -43 -13\n"
] | Original problem description:
Write a function that takes in two tuples and subtracts the elements of the first tuple by the elements of the second tuple with the same index.
We have its functional test sample:
assert substract_elements((10, 4, 5), (2, 5, 18)) == (8, -1, -13)
assert substract_elements((11, 2, 3), (24, 45 ,16)) == (-13, -43, -13)
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
10 4 5
2 5 18
Output:
8 -1 -13
Example 2:
Input:
11 2 3
24 45 16
Output:
-13 -43 -13
|
Benchmark Questions Verification V2.ipynb | 140 | Write a python function that takes in a positive integer n and finds the sum of even index binomial coefficients. | import math
def even_binomial_Coeff_Sum( n):
return (1 << (n - 1)) | [] | [
"assert even_binomial_Coeff_Sum(4) == 8",
"assert even_binomial_Coeff_Sum(6) == 32",
"assert even_binomial_Coeff_Sum(2) == 2"
] | stdin | 1 | null | MBPP | [
"4\n",
"6\n",
"2\n"
] | [
"8\n",
"32\n",
"2\n"
] | [
"4\n",
"6\n"
] | [
"8\n",
"32\n"
] | Original problem description:
Write a python function that takes in a positive integer n and finds the sum of even index binomial coefficients.
We have its functional test sample:
assert even_binomial_Coeff_Sum(4) == 8
assert even_binomial_Coeff_Sum(6) == 32
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
4
Output:
8
Example 2:
Input:
6
Output:
32
|
Benchmark Questions Verification V2.ipynb | 142 | Write a function that takes in a dictionary and integer n and filters the dictionary to only include entries with values greater than or equal to n. | def dict_filter(dict,n):
result = {key:value for (key, value) in dict.items() if value >=n}
return result | [] | [
"assert dict_filter({'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},170)=={'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190}",
"assert dict_filter({'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},180)=={ 'Alden Cantrell': 180, 'Pierre Cox': 190}",
"assert dict_filter({'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},190)=={ 'Pierre Cox': 190}"
] | stdin | 1 | null | MBPP | [
"{'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190}\n170\n",
"{'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190}\n180\n",
"{'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190}\n190\n"
] | [
"{'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190}\n",
"{'Alden Cantrell': 180, 'Pierre Cox': 190}\n",
"{'Pierre Cox': 190}\n"
] | [
"{'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190}\n170\n",
"{'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190}\n180\n"
] | [
"{'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190}\n",
"{'Alden Cantrell': 180, 'Pierre Cox': 190}\n"
] | Original problem description:
Write a function that takes in a dictionary and integer n and filters the dictionary to only include entries with values greater than or equal to n.
We have its functional test sample:
assert dict_filter({'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},170)=={'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190}
assert dict_filter({'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},180)=={ 'Alden Cantrell': 180, 'Pierre Cox': 190}
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
{'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190}
170
Output:
{'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190}
Example 2:
Input:
{'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190}
180
Output:
{'Alden Cantrell': 180, 'Pierre Cox': 190}
|
Benchmark Questions Verification V2.ipynb | 143 | Write a function to find the number of elements that occurs before the tuple element in the given tuple. | def count_first_elements(test_tup):
for count, ele in enumerate(test_tup):
if isinstance(ele, tuple):
break
return (count) | [] | [
"assert count_first_elements((1, 5, 7, (4, 6), 10) ) == 3",
"assert count_first_elements((2, 9, (5, 7), 11) ) == 2",
"assert count_first_elements((11, 15, 5, 8, (2, 3), 8) ) == 4"
] | stdin | 1 | null | MBPP | [
"1\n5\n7\n4 6\n10\n",
"2\n9\n5 7\n11\n",
"11\n15\n5\n8\n2 3\n8\n"
] | [
"3\n",
"2\n",
"4\n"
] | [
"1\n5\n7\n4 6\n10\n",
"2\n9\n5 7\n11\n"
] | [
"3\n",
"2\n"
] | Original problem description:
Write a function to find the number of elements that occurs before the tuple element in the given tuple.
We have its functional test sample:
assert count_first_elements((1, 5, 7, (4, 6), 10) ) == 3
assert count_first_elements((2, 9, (5, 7), 11) ) == 2
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
1
5
7
4 6
10
Output:
3
Example 2:
Input:
2
9
5 7
11
Output:
2
|
Benchmark Questions Verification V2.ipynb | 144 | Write a function to find the nth decagonal number. | def is_num_decagonal(n):
return 4 * n * n - 3 * n | [] | [
"assert is_num_decagonal(3) == 27",
"assert is_num_decagonal(7) == 175",
"assert is_num_decagonal(10) == 370"
] | stdin | 1 | null | MBPP | [
"3\n",
"7\n",
"10\n"
] | [
"27\n",
"175\n",
"370\n"
] | [
"3\n",
"7\n"
] | [
"27\n",
"175\n"
] | Original problem description:
Write a function to find the nth decagonal number.
We have its functional test sample:
assert is_num_decagonal(3) == 27
assert is_num_decagonal(7) == 175
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
3
Output:
27
Example 2:
Input:
7
Output:
175
|
Benchmark Questions Verification V2.ipynb | 145 | Write a function that takes in an array and element and returns a tuple containing a boolean that indicates if the element is in the array and the index position of the element (or -1 if the element is not found). | def sequential_search(dlist, item):
pos = 0
found = False
while pos < len(dlist) and not found:
if dlist[pos] == item:
found = True
else:
pos = pos + 1
return found, pos | [] | [
"assert sequential_search([11,23,58,31,56,77,43,12,65,19],31) == (True, 3)",
"assert sequential_search([12, 32, 45, 62, 35, 47, 44, 61],61) == (True, 7)",
"assert sequential_search([9, 10, 17, 19, 22, 39, 48, 56],48) == (True, 6)"
] | stdin | 1 | null | MBPP | [
"11 23 58 31 56 77 43 12 65 19\n31\n",
"12 32 45 62 35 47 44 61\n61\n",
"9 10 17 19 22 39 48 56\n48\n"
] | [
"True 3\n",
"True 7\n",
"True 6\n"
] | [
"11 23 58 31 56 77 43 12 65 19\n31\n",
"12 32 45 62 35 47 44 61\n61\n"
] | [
"True 3\n",
"True 7\n"
] | Original problem description:
Write a function that takes in an array and element and returns a tuple containing a boolean that indicates if the element is in the array and the index position of the element (or -1 if the element is not found).
We have its functional test sample:
assert sequential_search([11,23,58,31,56,77,43,12,65,19],31) == (True, 3)
assert sequential_search([12, 32, 45, 62, 35, 47, 44, 61],61) == (True, 7)
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
11 23 58 31 56 77 43 12 65 19
31
Output:
True 3
Example 2:
Input:
12 32 45 62 35 47 44 61
61
Output:
True 7
|
Benchmark Questions Verification V2.ipynb | 146 | Write a python function to check if the elements of a given list are unique or not. | def all_unique(test_list):
if len(test_list) > len(set(test_list)):
return False
return True | [] | [
"assert all_unique([1,2,3]) == True",
"assert all_unique([1,2,1,2]) == False",
"assert all_unique([1,2,3,4,5]) == True"
] | stdin | 1 | null | MBPP | [
"1 2 3\n",
"1 2 1 2\n",
"1 2 3 4 5\n"
] | [
"True\n",
"False\n",
"True\n"
] | [
"1 2 3\n",
"1 2 1 2\n"
] | [
"True\n",
"False\n"
] | Original problem description:
Write a python function to check if the elements of a given list are unique or not.
We have its functional test sample:
assert all_unique([1,2,3]) == True
assert all_unique([1,2,1,2]) == False
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
1 2 3
Output:
True
Example 2:
Input:
1 2 1 2
Output:
False
|
Benchmark Questions Verification V2.ipynb | 147 | Write a function to subtract two lists element-wise. | def sub_list(nums1,nums2):
result = map(lambda x, y: x - y, nums1, nums2)
return list(result) | [] | [
"assert sub_list([1, 2, 3],[4,5,6])==[-3,-3,-3]",
"assert sub_list([1,2],[3,4])==[-2,-2]",
"assert sub_list([90,120],[50,70])==[40,50]"
] | stdin | 1 | null | MBPP | [
"1 2 3\n4 5 6\n",
"1 2\n3 4\n",
"90 120\n50 70\n"
] | [
"-3 -3 -3\n",
"-2 -2\n",
"40 50\n"
] | [
"1 2 3\n4 5 6\n",
"1 2\n3 4\n"
] | [
"-3 -3 -3\n",
"-2 -2\n"
] | Original problem description:
Write a function to subtract two lists element-wise.
We have its functional test sample:
assert sub_list([1, 2, 3],[4,5,6])==[-3,-3,-3]
assert sub_list([1,2],[3,4])==[-2,-2]
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
1 2 3
4 5 6
Output:
-3 -3 -3
Example 2:
Input:
1 2
3 4
Output:
-2 -2
|
Benchmark Questions Verification V2.ipynb | 148 | Write a python function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself. | def validate(n):
for i in range(10):
temp = n;
count = 0;
while (temp):
if (temp % 10 == i):
count+=1;
if (count > i):
return False
temp //= 10;
return True | [] | [
"assert validate(1234) == True",
"assert validate(51241) == False",
"assert validate(321) == True"
] | stdin | 1 | null | MBPP | [
"1234\n",
"51241\n",
"321\n"
] | [
"True\n",
"False\n",
"True\n"
] | [
"1234\n",
"51241\n"
] | [
"True\n",
"False\n"
] | Original problem description:
Write a python function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself.
We have its functional test sample:
assert validate(1234) == True
assert validate(51241) == False
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
1234
Output:
True
Example 2:
Input:
51241
Output:
False
|
Benchmark Questions Verification V2.ipynb | 149 | Write a function that takes in a list and element and checks whether all items in the list are equal to the given element. | def check_element(list,element):
check_element=all(v== element for v in list)
return check_element | [] | [
"assert check_element([\"green\", \"orange\", \"black\", \"white\"],'blue')==False",
"assert check_element([1,2,3,4],7)==False",
"assert check_element([\"green\", \"green\", \"green\", \"green\"],'green')==True"
] | stdin | 1 | null | MBPP | [
"green orange black white\nblue\n",
"1 2 3 4\n7\n",
"green green green green\ngreen\n"
] | [
"False\n",
"False\n",
"True\n"
] | [
"green orange black white\nblue\n",
"1 2 3 4\n7\n"
] | [
"False\n",
"False\n"
] | Original problem description:
Write a function that takes in a list and element and checks whether all items in the list are equal to the given element.
We have its functional test sample:
assert check_element(["green", "orange", "black", "white"],'blue')==False
assert check_element([1,2,3,4],7)==False
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
green orange black white
blue
Output:
False
Example 2:
Input:
1 2 3 4
7
Output:
False
|
Benchmark Questions Verification V2.ipynb | 150 | Write a function that checks whether a string contains the 'a' character followed by two or three 'b' characters. | import re
def text_match_two_three(text):
patterns = 'ab{2,3}'
if re.search(patterns, text):
return True
else:
return False | [] | [
"assert text_match_two_three(\"ac\")==(False)",
"assert text_match_two_three(\"dc\")==(False)",
"assert text_match_two_three(\"abbbba\")==(True)"
] | stdin | 1 | null | MBPP | [
"ac\n",
"dc\n",
"abbbba\n"
] | [
"False\n",
"False\n",
"True\n"
] | [
"ac\n",
"dc\n"
] | [
"False\n",
"False\n"
] | Original problem description:
Write a function that checks whether a string contains the 'a' character followed by two or three 'b' characters.
We have its functional test sample:
assert text_match_two_three("ac")==(False)
assert text_match_two_three("dc")==(False)
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
ac
Output:
False
Example 2:
Input:
dc
Output:
False
|
Benchmark Questions Verification V2.ipynb | 151 | Write a function to find the largest sum of a contiguous array in the modified array which is formed by repeating the given array k times. | def max_sub_array_sum_repeated(a, n, k):
max_so_far = -2147483648
max_ending_here = 0
for i in range(n*k):
max_ending_here = max_ending_here + a[i%n]
if (max_so_far < max_ending_here):
max_so_far = max_ending_here
if (max_ending_here < 0):
max_ending_here = 0
return max_so_far | [] | [
"assert max_sub_array_sum_repeated([10, 20, -30, -1], 4, 3) == 30",
"assert max_sub_array_sum_repeated([-1, 10, 20], 3, 2) == 59",
"assert max_sub_array_sum_repeated([-1, -2, -3], 3, 3) == -1"
] | stdin | 1 | null | MBPP | [
"10 20 -30 -1\n4\n3\n",
"-1 10 20\n3\n2\n",
"-1 -2 -3\n3\n3\n"
] | [
"30\n",
"59\n",
"-1\n"
] | [
"10 20 -30 -1\n4\n3\n",
"-1 10 20\n3\n2\n"
] | [
"30\n",
"59\n"
] | Original problem description:
Write a function to find the largest sum of a contiguous array in the modified array which is formed by repeating the given array k times.
We have its functional test sample:
assert max_sub_array_sum_repeated([10, 20, -30, -1], 4, 3) == 30
assert max_sub_array_sum_repeated([-1, 10, 20], 3, 2) == 59
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
10 20 -30 -1
4
3
Output:
30
Example 2:
Input:
-1 10 20
3
2
Output:
59
|
Benchmark Questions Verification V2.ipynb | 152 | Write a python function takes in an integer n and returns the sum of squares of first n even natural numbers. | def square_Sum(n):
return int(2*n*(n+1)*(2*n+1)/3) | [] | [
"assert square_Sum(2) == 20",
"assert square_Sum(3) == 56",
"assert square_Sum(4) == 120"
] | stdin | 1 | null | MBPP | [
"2\n",
"3\n",
"4\n"
] | [
"20\n",
"56\n",
"120\n"
] | [
"2\n",
"3\n"
] | [
"20\n",
"56\n"
] | Original problem description:
Write a python function takes in an integer n and returns the sum of squares of first n even natural numbers.
We have its functional test sample:
assert square_Sum(2) == 20
assert square_Sum(3) == 56
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
2
Output:
20
Example 2:
Input:
3
Output:
56
|
Ellen's Copy of Benchmark Questions Verification V2.ipynb | 154 | Write a function to find out the number of ways of painting the fence such that at most 2 adjacent posts have the same color for the given fence with n posts and k colors. | def count_no_of_ways(n, k):
dp = [0] * (n + 1)
total = k
mod = 1000000007
dp[1] = k
dp[2] = k * k
for i in range(3,n+1):
dp[i] = ((k - 1) * (dp[i - 1] + dp[i - 2])) % mod
return dp[n] | [] | [
"assert count_no_of_ways(2, 4) == 16",
"assert count_no_of_ways(3, 2) == 6",
"assert count_no_of_ways(4, 4) == 228"
] | stdin | 1 | null | MBPP | [
"2\n4\n",
"3\n2\n",
"4\n4\n"
] | [
"16\n",
"6\n",
"228\n"
] | [
"2\n4\n",
"3\n2\n"
] | [
"16\n",
"6\n"
] | Original problem description:
Write a function to find out the number of ways of painting the fence such that at most 2 adjacent posts have the same color for the given fence with n posts and k colors.
We have its functional test sample:
assert count_no_of_ways(2, 4) == 16
assert count_no_of_ways(3, 2) == 6
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
2
4
Output:
16
Example 2:
Input:
3
2
Output:
6
|
Ellen's Copy of Benchmark Questions Verification V2.ipynb | 155 | Write a python function to find quotient of two numbers (rounded down to the nearest integer). | def find(n,m):
q = n//m
return (q) | [] | [
"assert find(10,3) == 3",
"assert find(4,2) == 2",
"assert find(20,5) == 4"
] | stdin | 1 | null | MBPP | [
"10\n3\n",
"4\n2\n",
"20\n5\n"
] | [
"3\n",
"2\n",
"4\n"
] | [
"10\n3\n",
"4\n2\n"
] | [
"3\n",
"2\n"
] | Original problem description:
Write a python function to find quotient of two numbers (rounded down to the nearest integer).
We have its functional test sample:
assert find(10,3) == 3
assert find(4,2) == 2
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
10
3
Output:
3
Example 2:
Input:
4
2
Output:
2
|
Ellen's Copy of Benchmark Questions Verification V2.ipynb | 157 | Write a function to find the maximum value in a given heterogeneous list. | def max_val(listval):
max_val = max(i for i in listval if isinstance(i, int))
return(max_val) | [] | [
"assert max_val(['Python', 3, 2, 4, 5, 'version'])==5",
"assert max_val(['Python', 15, 20, 25])==25",
"assert max_val(['Python', 30, 20, 40, 50, 'version'])==50"
] | stdin | 1 | null | MBPP | [
"Python 3 2 4 5 version\n",
"Python 15 20 25\n",
"Python 30 20 40 50 version\n"
] | [
"5\n",
"25\n",
"50\n"
] | [
"Python 3 2 4 5 version\n",
"Python 15 20 25\n"
] | [
"5\n",
"25\n"
] | Original problem description:
Write a function to find the maximum value in a given heterogeneous list.
We have its functional test sample:
assert max_val(['Python', 3, 2, 4, 5, 'version'])==5
assert max_val(['Python', 15, 20, 25])==25
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
Python 3 2 4 5 version
Output:
5
Example 2:
Input:
Python 15 20 25
Output:
25
|
Ellen's Copy of Benchmark Questions Verification V2.ipynb | 158 | Write a function to return the sum of all divisors of a number. | def sum_div(number):
divisors = [1]
for i in range(2, number):
if (number % i)==0:
divisors.append(i)
return sum(divisors) | [] | [
"assert sum_div(8)==7",
"assert sum_div(12)==16",
"assert sum_div(7)==1"
] | stdin | 1 | null | MBPP | [
"8\n",
"12\n",
"7\n"
] | [
"7\n",
"16\n",
"1\n"
] | [
"8\n",
"12\n"
] | [
"7\n",
"16\n"
] | Original problem description:
Write a function to return the sum of all divisors of a number.
We have its functional test sample:
assert sum_div(8)==7
assert sum_div(12)==16
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
8
Output:
7
Example 2:
Input:
12
Output:
16
|
Ellen's Copy of Benchmark Questions Verification V2.ipynb | 159 | Write a python function to count inversions in an array. | def get_Inv_Count(arr):
inv_count = 0
for i in range(len(arr)):
for j in range(i + 1, len(arr)):
if (arr[i] > arr[j]):
inv_count += 1
return inv_count | [] | [
"assert get_Inv_Count([1,20,6,4,5]) == 5",
"assert get_Inv_Count([1,2,1]) == 1",
"assert get_Inv_Count([1,2,5,6,1]) == 3"
] | stdin | 1 | null | MBPP | [
"1 20 6 4 5\n",
"1 2 1\n",
"1 2 5 6 1\n"
] | [
"5\n",
"1\n",
"3\n"
] | [
"1 20 6 4 5\n",
"1 2 1\n"
] | [
"5\n",
"1\n"
] | Original problem description:
Write a python function to count inversions in an array.
We have its functional test sample:
assert get_Inv_Count([1,20,6,4,5]) == 5
assert get_Inv_Count([1,2,1]) == 1
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
1 20 6 4 5
Output:
5
Example 2:
Input:
1 2 1
Output:
1
|
Ellen's Copy of Benchmark Questions Verification V2.ipynb | 161 | Write a function to calculate the maximum aggregate from the list of tuples. | from collections import defaultdict
def max_aggregate(stdata):
temp = defaultdict(int)
for name, marks in stdata:
temp[name] += marks
return max(temp.items(), key=lambda x: x[1]) | [] | [
"assert max_aggregate([('Juan Whelan',90),('Sabah Colley',88),('Peter Nichols',7),('Juan Whelan',122),('Sabah Colley',84)])==('Juan Whelan', 212)",
"assert max_aggregate([('Juan Whelan',50),('Sabah Colley',48),('Peter Nichols',37),('Juan Whelan',22),('Sabah Colley',14)])==('Juan Whelan', 72)",
"assert max_aggregate([('Juan Whelan',10),('Sabah Colley',20),('Peter Nichols',30),('Juan Whelan',40),('Sabah Colley',50)])==('Sabah Colley', 70)"
] | stdin | 1 | null | MBPP | [
"Juan Whelan 90\nSabah Colley 88\nPeter Nichols 7\nJuan Whelan 122\nSabah Colley 84\n",
"Juan Whelan 50\nSabah Colley 48\nPeter Nichols 37\nJuan Whelan 22\nSabah Colley 14\n",
"Juan Whelan 10\nSabah Colley 20\nPeter Nichols 30\nJuan Whelan 40\nSabah Colley 50\n"
] | [
"Juan Whelan 212\n",
"Juan Whelan 72\n",
"Sabah Colley 70\n"
] | [
"Juan Whelan 90\nSabah Colley 88\nPeter Nichols 7\nJuan Whelan 122\nSabah Colley 84\n",
"Juan Whelan 50\nSabah Colley 48\nPeter Nichols 37\nJuan Whelan 22\nSabah Colley 14\n"
] | [
"Juan Whelan 212\n",
"Juan Whelan 72\n"
] | Original problem description:
Write a function to calculate the maximum aggregate from the list of tuples.
We have its functional test sample:
assert max_aggregate([('Juan Whelan',90),('Sabah Colley',88),('Peter Nichols',7),('Juan Whelan',122),('Sabah Colley',84)])==('Juan Whelan', 212)
assert max_aggregate([('Juan Whelan',50),('Sabah Colley',48),('Peter Nichols',37),('Juan Whelan',22),('Sabah Colley',14)])==('Juan Whelan', 72)
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
Juan Whelan 90
Sabah Colley 88
Peter Nichols 7
Juan Whelan 122
Sabah Colley 84
Output:
Juan Whelan 212
Example 2:
Input:
Juan Whelan 50
Sabah Colley 48
Peter Nichols 37
Juan Whelan 22
Sabah Colley 14
Output:
Juan Whelan 72
|
Ellen's Copy of Benchmark Questions Verification V2.ipynb | 165 | Write a function to return two words from a list of words starting with letter 'p'. | import re
def start_withp(words):
for w in words:
m = re.match("(P\w+)\W(P\w+)", w)
if m:
return m.groups() | [] | [
"assert start_withp([\"Python PHP\", \"Java JavaScript\", \"c c++\"])==('Python', 'PHP')",
"assert start_withp([\"Python Programming\",\"Java Programming\"])==('Python','Programming')",
"assert start_withp([\"Pqrst Pqr\",\"qrstuv\"])==('Pqrst','Pqr')"
] | stdin | 1 | null | MBPP | [
"Python PHP Java JavaScript c c++\n",
"Python Programming Java Programming\n",
"Pqrst Pqr qrstuv\n"
] | [
"Python PHP\n",
"Python Programming\n",
"Pqrst Pqr\n"
] | [
"Python PHP Java JavaScript c c++\n",
"Python Programming Java Programming\n"
] | [
"Python PHP\n",
"Python Programming\n"
] | Original problem description:
Write a function to return two words from a list of words starting with letter 'p'.
We have its functional test sample:
assert start_withp(["Python PHP", "Java JavaScript", "c c++"])==('Python', 'PHP')
assert start_withp(["Python Programming","Java Programming"])==('Python','Programming')
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
Python PHP Java JavaScript c c++
Output:
Python PHP
Example 2:
Input:
Python Programming Java Programming
Output:
Python Programming
|
Ellen's Copy of Benchmark Questions Verification V2.ipynb | 166 | Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i . | def max_sum_increasing_subseq(a, n, index, k):
dp = [[0 for i in range(n)]
for i in range(n)]
for i in range(n):
if a[i] > a[0]:
dp[0][i] = a[i] + a[0]
else:
dp[0][i] = a[i]
for i in range(1, n):
for j in range(n):
if a[j] > a[i] and j > i:
if dp[i - 1][i] + a[j] > dp[i - 1][j]:
dp[i][j] = dp[i - 1][i] + a[j]
else:
dp[i][j] = dp[i - 1][j]
else:
dp[i][j] = dp[i - 1][j]
return dp[index][k] | [] | [
"assert max_sum_increasing_subseq([1, 101, 2, 3, 100, 4, 5 ], 7, 4, 6) == 11",
"assert max_sum_increasing_subseq([1, 101, 2, 3, 100, 4, 5 ], 7, 2, 5) == 7",
"assert max_sum_increasing_subseq([11, 15, 19, 21, 26, 28, 31], 7, 2, 4) == 71"
] | stdin | 1 | null | MBPP | [
"1 101 2 3 100 4 5\n7\n4\n6\n",
"1 101 2 3 100 4 5\n7\n2\n5\n",
"11 15 19 21 26 28 31\n7\n2\n4\n"
] | [
"11\n",
"7\n",
"71\n"
] | [
"1 101 2 3 100 4 5\n7\n4\n6\n",
"1 101 2 3 100 4 5\n7\n2\n5\n"
] | [
"11\n",
"7\n"
] | Original problem description:
Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i .
We have its functional test sample:
assert max_sum_increasing_subseq([1, 101, 2, 3, 100, 4, 5 ], 7, 4, 6) == 11
assert max_sum_increasing_subseq([1, 101, 2, 3, 100, 4, 5 ], 7, 2, 5) == 7
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
1 101 2 3 100 4 5
7
4
6
Output:
11
Example 2:
Input:
1 101 2 3 100 4 5
7
2
5
Output:
7
|
Ellen's Copy of Benchmark Questions Verification V2.ipynb | 168 | Write a function to find the specified number of largest products from two given lists, selecting one factor from each list. | def large_product(nums1, nums2, N):
result = sorted([x*y for x in nums1 for y in nums2], reverse=True)[:N]
return result | [] | [
"assert large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],3)==[60, 54, 50]",
"assert large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],4)==[60, 54, 50, 48]",
"assert large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],5)==[60, 54, 50, 48, 45]"
] | stdin | 1 | null | MBPP | [
"1 2 3 4 5 6\n3 6 8 9 10 6\n3\n",
"1 2 3 4 5 6\n3 6 8 9 10 6\n4\n",
"1 2 3 4 5 6\n3 6 8 9 10 6\n5\n"
] | [
"60 54 50\n",
"60 54 50 48\n",
"60 54 50 48 45\n"
] | [
"1 2 3 4 5 6\n3 6 8 9 10 6\n3\n",
"1 2 3 4 5 6\n3 6 8 9 10 6\n4\n"
] | [
"60 54 50\n",
"60 54 50 48\n"
] | Original problem description:
Write a function to find the specified number of largest products from two given lists, selecting one factor from each list.
We have its functional test sample:
assert large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],3)==[60, 54, 50]
assert large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],4)==[60, 54, 50, 48]
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
1 2 3 4 5 6
3 6 8 9 10 6
3
Output:
60 54 50
Example 2:
Input:
1 2 3 4 5 6
3 6 8 9 10 6
4
Output:
60 54 50 48
|
Ellen's Copy of Benchmark Questions Verification V2.ipynb | 169 | Write a python function to find the maximum of two numbers. | def maximum(a,b):
if a >= b:
return a
else:
return b | [] | [
"assert maximum(5,10) == 10",
"assert maximum(-1,-2) == -1",
"assert maximum(9,7) == 9"
] | stdin | 1 | null | MBPP | [
"5\n10\n",
"-1\n-2\n",
"9\n7\n"
] | [
"10\n",
"-1\n",
"9\n"
] | [
"5\n10\n",
"-1\n-2\n"
] | [
"10\n",
"-1\n"
] | Original problem description:
Write a python function to find the maximum of two numbers.
We have its functional test sample:
assert maximum(5,10) == 10
assert maximum(-1,-2) == -1
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
5
10
Output:
10
Example 2:
Input:
-1
-2
Output:
-1
|
Ellen's Copy of Benchmark Questions Verification V2.ipynb | 170 | Write a function to convert a given string to a tuple of characters. | def string_to_tuple(str1):
result = tuple(x for x in str1 if not x.isspace())
return result | [] | [
"assert string_to_tuple(\"python 3.0\")==('p', 'y', 't', 'h', 'o', 'n', '3', '.', '0')",
"assert string_to_tuple(\"item1\")==('i', 't', 'e', 'm', '1')",
"assert string_to_tuple(\"15.10\")==('1', '5', '.', '1', '0')"
] | stdin | 1 | null | MBPP | [
"python 3.0\n",
"item1\n",
"15.10\n"
] | [
"p y t h o n 3 . 0\n",
"i t e m 1\n",
"1 5 . 1 0\n"
] | [
"python 3.0\n",
"item1\n"
] | [
"p y t h o n 3 . 0\n",
"i t e m 1\n"
] | Original problem description:
Write a function to convert a given string to a tuple of characters.
We have its functional test sample:
assert string_to_tuple("python 3.0")==('p', 'y', 't', 'h', 'o', 'n', '3', '.', '0')
assert string_to_tuple("item1")==('i', 't', 'e', 'm', '1')
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
python 3.0
Output:
p y t h o n 3 . 0
Example 2:
Input:
item1
Output:
i t e m 1
|
Ellen's Copy of Benchmark Questions Verification V2.ipynb | 171 | Write a python function to set the left most unset bit. | def set_left_most_unset_bit(n):
if not (n & (n + 1)):
return n
pos, temp, count = 0, n, 0
while temp:
if not (temp & 1):
pos = count
count += 1; temp>>=1
return (n | (1 << (pos))) | [] | [
"assert set_left_most_unset_bit(10) == 14",
"assert set_left_most_unset_bit(12) == 14",
"assert set_left_most_unset_bit(15) == 15"
] | stdin | 1 | null | MBPP | [
"10\n",
"12\n",
"15\n"
] | [
"14\n",
"14\n",
"15\n"
] | [
"10\n",
"12\n"
] | [
"14\n",
"14\n"
] | Original problem description:
Write a python function to set the left most unset bit.
We have its functional test sample:
assert set_left_most_unset_bit(10) == 14
assert set_left_most_unset_bit(12) == 14
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
10
Output:
14
Example 2:
Input:
12
Output:
14
|
Benchmark Questions Verification V2.ipynb | 173 | Write a python function to find the highest power of 2 that is less than or equal to n. | def highest_Power_of_2(n):
res = 0
for i in range(n, 0, -1):
if ((i & (i - 1)) == 0):
res = i
break
return res | [] | [
"assert highest_Power_of_2(10) == 8",
"assert highest_Power_of_2(19) == 16",
"assert highest_Power_of_2(32) == 32"
] | stdin | 1 | null | MBPP | [
"10\n",
"19\n",
"32\n"
] | [
"8\n",
"16\n",
"32\n"
] | [
"10\n",
"19\n"
] | [
"8\n",
"16\n"
] | Original problem description:
Write a python function to find the highest power of 2 that is less than or equal to n.
We have its functional test sample:
assert highest_Power_of_2(10) == 8
assert highest_Power_of_2(19) == 16
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
10
Output:
8
Example 2:
Input:
19
Output:
16
|
Benchmark Questions Verification V2.ipynb | 174 | Write a function to find the n'th lucas number. | def find_lucas(n):
if (n == 0):
return 2
if (n == 1):
return 1
return find_lucas(n - 1) + find_lucas(n - 2) | [] | [
"assert find_lucas(9) == 76",
"assert find_lucas(4) == 7",
"assert find_lucas(3) == 4"
] | stdin | 1 | null | MBPP | [
"9\n",
"4\n",
"3\n"
] | [
"76\n",
"7\n",
"4\n"
] | [
"9\n",
"4\n"
] | [
"76\n",
"7\n"
] | Original problem description:
Write a function to find the n'th lucas number.
We have its functional test sample:
assert find_lucas(9) == 76
assert find_lucas(4) == 7
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
9
Output:
76
Example 2:
Input:
4
Output:
7
|
Benchmark Questions Verification V2.ipynb | 175 | Write a function to apply a given format string to all of the elements in a list. | def add_string(list_, string):
add_string=[string.format(i) for i in list_]
return add_string | [] | [
"assert add_string([1,2,3,4],'temp{0}')==['temp1', 'temp2', 'temp3', 'temp4']",
"assert add_string(['a','b','c','d'], 'python{0}')==[ 'pythona', 'pythonb', 'pythonc', 'pythond']",
"assert add_string([5,6,7,8],'string{0}')==['string5', 'string6', 'string7', 'string8']"
] | stdin | 1 | null | MBPP | [
"1 2 3 4\ntemp{0}\n",
"a b c d\npython{0}\n",
"5 6 7 8\nstring{0}\n"
] | [
"temp1 temp2 temp3 temp4\n",
"pythona pythonb pythonc pythond\n",
"string5 string6 string7 string8\n"
] | [
"1 2 3 4\ntemp{0}\n",
"a b c d\npython{0}\n"
] | [
"temp1 temp2 temp3 temp4\n",
"pythona pythonb pythonc pythond\n"
] | Original problem description:
Write a function to apply a given format string to all of the elements in a list.
We have its functional test sample:
assert add_string([1,2,3,4],'temp{0}')==['temp1', 'temp2', 'temp3', 'temp4']
assert add_string(['a','b','c','d'], 'python{0}')==[ 'pythona', 'pythonb', 'pythonc', 'pythond']
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
1 2 3 4
temp{0}
Output:
temp1 temp2 temp3 temp4
Example 2:
Input:
a b c d
python{0}
Output:
pythona pythonb pythonc pythond
|
Benchmark Questions Verification V2.ipynb | 177 | Write a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n). | def get_max_sum (n):
res = list()
res.append(0)
res.append(1)
i = 2
while i<n + 1:
res.append(max(i, (res[int(i / 2)]
+ res[int(i / 3)] +
res[int(i / 4)]
+ res[int(i / 5)])))
i = i + 1
return res[n] | [] | [
"assert get_max_sum(60) == 106",
"assert get_max_sum(10) == 12",
"assert get_max_sum(2) == 2"
] | stdin | 1 | null | MBPP | [
"60\n",
"10\n",
"2\n"
] | [
"106\n",
"12\n",
"2\n"
] | [
"60\n",
"10\n"
] | [
"106\n",
"12\n"
] | Original problem description:
Write a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n).
We have its functional test sample:
assert get_max_sum(60) == 106
assert get_max_sum(10) == 12
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
60
Output:
106
Example 2:
Input:
10
Output:
12
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 178 | Write a function to find the list with maximum length. | def max_length_list(input_list):
max_length = max(len(x) for x in input_list )
max_list = max(input_list, key = lambda i: len(i))
return(max_length, max_list) | [] | [
"assert max_length_list([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==(3, [13, 15, 17])",
"assert max_length_list([[1,2,3,4,5],[1,2,3,4],[1,2,3],[1,2],[1]])==(5,[1,2,3,4,5])",
"assert max_length_list([[3,4,5],[6,7,8,9],[10,11,12]])==(4,[6,7,8,9])"
] | stdin | 1 | null | MBPP | [
"0\n1 3\n5 7\n9 11\n13 15 17\n",
"1 2 3 4 5\n1 2 3 4\n1 2 3\n1 2\n1\n",
"3 4 5\n6 7 8 9\n10 11 12\n"
] | [
"3 [13, 15, 17]\n",
"5 [1, 2, 3, 4, 5]\n",
"4 [6, 7, 8, 9]\n"
] | [
"0\n1 3\n5 7\n9 11\n13 15 17\n",
"1 2 3 4 5\n1 2 3 4\n1 2 3\n1 2\n1\n"
] | [
"3 [13, 15, 17]\n",
"5 [1, 2, 3, 4, 5]\n"
] | Original problem description:
Write a function to find the list with maximum length.
We have its functional test sample:
assert max_length_list([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==(3, [13, 15, 17])
assert max_length_list([[1,2,3,4,5],[1,2,3,4],[1,2,3],[1,2],[1]])==(5,[1,2,3,4,5])
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
0
1 3
5 7
9 11
13 15 17
Output:
3 [13, 15, 17]
Example 2:
Input:
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Output:
5 [1, 2, 3, 4, 5]
|
Benchmark Questions Verification V2.ipynb | 179 | Write a function to check if given tuple contains no duplicates. | def check_distinct(test_tup):
res = True
temp = set()
for ele in test_tup:
if ele in temp:
res = False
break
temp.add(ele)
return res | [] | [
"assert check_distinct((1, 4, 5, 6, 1, 4)) == False",
"assert check_distinct((1, 4, 5, 6)) == True",
"assert check_distinct((2, 3, 4, 5, 6)) == True"
] | stdin | 1 | null | MBPP | [
"1\n4\n5\n6\n1\n4\n",
"1\n4\n5\n6\n",
"2\n3\n4\n5\n6\n"
] | [
"False\n",
"True\n",
"True\n"
] | [
"1\n4\n5\n6\n1\n4\n",
"1\n4\n5\n6\n"
] | [
"False\n",
"True\n"
] | Original problem description:
Write a function to check if given tuple contains no duplicates.
We have its functional test sample:
assert check_distinct((1, 4, 5, 6, 1, 4)) == False
assert check_distinct((1, 4, 5, 6)) == True
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
1
4
5
6
1
4
Output:
False
Example 2:
Input:
1
4
5
6
Output:
True
|
Benchmark Questions Verification V2.ipynb | 180 | Write a python function to find the first non-repeated character in a given string. | def first_non_repeating_character(str1):
char_order = []
ctr = {}
for c in str1:
if c in ctr:
ctr[c] += 1
else:
ctr[c] = 1
char_order.append(c)
for c in char_order:
if ctr[c] == 1:
return c
return None | [] | [
"assert first_non_repeating_character(\"abcabc\") == None",
"assert first_non_repeating_character(\"abc\") == \"a\"",
"assert first_non_repeating_character(\"ababc\") == \"c\""
] | stdin | 1 | null | MBPP | [
"abcabc\n",
"abc\n",
"ababc\n"
] | [
"None\n",
"a\n",
"c\n"
] | [
"abcabc\n",
"abc\n"
] | [
"None\n",
"a\n"
] | Original problem description:
Write a python function to find the first non-repeated character in a given string.
We have its functional test sample:
assert first_non_repeating_character("abcabc") == None
assert first_non_repeating_character("abc") == "a"
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
abcabc
Output:
None
Example 2:
Input:
abc
Output:
a
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 181 | Write a function to check whether the given string starts and ends with the same character or not. | import re
regex = r'^[a-z]$|^([a-z]).*\1$'
def check_char(string):
if(re.search(regex, string)):
return "Valid"
else:
return "Invalid" | [] | [
"assert check_char(\"abba\") == \"Valid\"",
"assert check_char(\"a\") == \"Valid\"",
"assert check_char(\"abcd\") == \"Invalid\""
] | stdin | 1 | null | MBPP | [
"abba\n",
"a\n",
"abcd\n"
] | [
"Valid\n",
"Valid\n",
"Invalid\n"
] | [
"abba\n",
"a\n"
] | [
"Valid\n",
"Valid\n"
] | Original problem description:
Write a function to check whether the given string starts and ends with the same character or not.
We have its functional test sample:
assert check_char("abba") == "Valid"
assert check_char("a") == "Valid"
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
abba
Output:
Valid
Example 2:
Input:
a
Output:
Valid
|
Benchmark Questions Verification V2.ipynb | 182 | Write a function to find the median of three numbers. | def median_numbers(a,b,c):
if a > b:
if a < c:
median = a
elif b > c:
median = b
else:
median = c
else:
if a > c:
median = a
elif b < c:
median = b
else:
median = c
return median | [] | [
"assert median_numbers(25,55,65)==55.0",
"assert median_numbers(20,10,30)==20.0",
"assert median_numbers(15,45,75)==45.0"
] | stdin | 1 | null | MBPP | [
"25\n55\n65\n",
"20\n10\n30\n",
"15\n45\n75\n"
] | [
"55.0\n",
"20.0\n",
"45.0\n"
] | [
"25\n55\n65\n",
"20\n10\n30\n"
] | [
"55.0\n",
"20.0\n"
] | Original problem description:
Write a function to find the median of three numbers.
We have its functional test sample:
assert median_numbers(25,55,65)==55.0
assert median_numbers(20,10,30)==20.0
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
25
55
65
Output:
55.0
Example 2:
Input:
20
10
30
Output:
20.0
|
Benchmark Questions Verification V2.ipynb | 183 | Write a function to compute the sum of digits of each number of a given list. | def sum_of_digits(nums):
return sum(int(el) for n in nums for el in str(n) if el.isdigit()) | [] | [
"assert sum_of_digits([10,2,56])==14",
"assert sum_of_digits([[10,20,4,5,'b',70,'a']])==19",
"assert sum_of_digits([10,20,-4,5,-70])==19"
] | stdin | 1 | null | MBPP | [
"10 2 56\n",
"10 20 4 5 b 70 a\n",
"10 20 -4 5 -70\n"
] | [
"14\n",
"19\n",
"19\n"
] | [
"10 2 56\n",
"10 20 4 5 b 70 a\n"
] | [
"14\n",
"19\n"
] | Original problem description:
Write a function to compute the sum of digits of each number of a given list.
We have its functional test sample:
assert sum_of_digits([10,2,56])==14
assert sum_of_digits([[10,20,4,5,'b',70,'a']])==19
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
10 2 56
Output:
14
Example 2:
Input:
10 20 4 5 b 70 a
Output:
19
|
Benchmark Questions Verification V2.ipynb | 184 | Write a function to perform the mathematical bitwise xor operation across the given tuples. | def bitwise_xor(test_tup1, test_tup2):
res = tuple(ele1 ^ ele2 for ele1, ele2 in zip(test_tup1, test_tup2))
return (res) | [] | [
"assert bitwise_xor((10, 4, 6, 9), (5, 2, 3, 3)) == (15, 6, 5, 10)",
"assert bitwise_xor((11, 5, 7, 10), (6, 3, 4, 4)) == (13, 6, 3, 14)",
"assert bitwise_xor((12, 6, 8, 11), (7, 4, 5, 6)) == (11, 2, 13, 13)"
] | stdin | 1 | null | MBPP | [
"10 4 6 9\n5 2 3 3\n",
"11 5 7 10\n6 3 4 4\n",
"12 6 8 11\n7 4 5 6\n"
] | [
"15 6 5 10\n",
"13 6 3 14\n",
"11 2 13 13\n"
] | [
"10 4 6 9\n5 2 3 3\n",
"11 5 7 10\n6 3 4 4\n"
] | [
"15 6 5 10\n",
"13 6 3 14\n"
] | Original problem description:
Write a function to perform the mathematical bitwise xor operation across the given tuples.
We have its functional test sample:
assert bitwise_xor((10, 4, 6, 9), (5, 2, 3, 3)) == (15, 6, 5, 10)
assert bitwise_xor((11, 5, 7, 10), (6, 3, 4, 4)) == (13, 6, 3, 14)
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
10 4 6 9
5 2 3 3
Output:
15 6 5 10
Example 2:
Input:
11 5 7 10
6 3 4 4
Output:
13 6 3 14
|
Benchmark Questions Verification V2.ipynb | 185 | Write a function to extract the number of unique tuples in the given list. | def extract_freq(test_list):
res = len(list(set(tuple(sorted(sub)) for sub in test_list)))
return (res) | [] | [
"assert extract_freq([(3, 4), (1, 2), (4, 3), (5, 6)] ) == 3",
"assert extract_freq([(4, 15), (2, 3), (5, 4), (6, 7)] ) == 4",
"assert extract_freq([(5, 16), (2, 3), (6, 5), (6, 9)] ) == 4"
] | stdin | 1 | null | MBPP | [
"3 4\n1 2\n4 3\n5 6\n",
"4 15\n2 3\n5 4\n6 7\n",
"5 16\n2 3\n6 5\n6 9\n"
] | [
"3\n",
"4\n",
"4\n"
] | [
"3 4\n1 2\n4 3\n5 6\n",
"4 15\n2 3\n5 4\n6 7\n"
] | [
"3\n",
"4\n"
] | Original problem description:
Write a function to extract the number of unique tuples in the given list.
We have its functional test sample:
assert extract_freq([(3, 4), (1, 2), (4, 3), (5, 6)] ) == 3
assert extract_freq([(4, 15), (2, 3), (5, 4), (6, 7)] ) == 4
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
3 4
1 2
4 3
5 6
Output:
3
Example 2:
Input:
4 15
2 3
5 4
6 7
Output:
4
|
Benchmark Questions Verification V2.ipynb | 187 | Write a python function to find the minimum of two numbers. | def minimum(a,b):
if a <= b:
return a
else:
return b | [] | [
"assert minimum(1,2) == 1",
"assert minimum(-5,-4) == -5",
"assert minimum(0,0) == 0"
] | stdin | 1 | null | MBPP | [
"1\n2\n",
"-5\n-4\n",
"0\n0\n"
] | [
"1\n",
"-5\n",
"0\n"
] | [
"1\n2\n",
"-5\n-4\n"
] | [
"1\n",
"-5\n"
] | Original problem description:
Write a python function to find the minimum of two numbers.
We have its functional test sample:
assert minimum(1,2) == 1
assert minimum(-5,-4) == -5
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
1
2
Output:
1
Example 2:
Input:
-5
-4
Output:
-5
|
Benchmark Questions Verification V2.ipynb | 188 | Write a function to check whether an element exists within a tuple. | def check_tuplex(tuplex,tuple1):
if tuple1 in tuplex:
return True
else:
return False | [] | [
"assert check_tuplex((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),'r')==True",
"assert check_tuplex((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),'5')==False",
"assert check_tuplex((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\",\"e\"),3)==True"
] | stdin | 1 | null | MBPP | [
"w 3 r e s o u r c e\nr\n",
"w 3 r e s o u r c e\n5\n",
"w 3 r e s o u r c e\n3\n"
] | [
"True\n",
"False\n",
"True\n"
] | [
"w 3 r e s o u r c e\nr\n",
"w 3 r e s o u r c e\n5\n"
] | [
"True\n",
"False\n"
] | Original problem description:
Write a function to check whether an element exists within a tuple.
We have its functional test sample:
assert check_tuplex(("w", 3, "r", "e", "s", "o", "u", "r", "c", "e"),'r')==True
assert check_tuplex(("w", 3, "r", "e", "s", "o", "u", "r", "c", "e"),'5')==False
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
w 3 r e s o u r c e
r
Output:
True
Example 2:
Input:
w 3 r e s o u r c e
5
Output:
False
|
Benchmark Questions Verification V2.ipynb | 189 | Write a python function to find whether the parity of a given number is odd. | def find_Parity(x):
y = x ^ (x >> 1);
y = y ^ (y >> 2);
y = y ^ (y >> 4);
y = y ^ (y >> 8);
y = y ^ (y >> 16);
if (y & 1):
return True
return False | [] | [
"assert find_Parity(12) == False",
"assert find_Parity(7) == True",
"assert find_Parity(10) == False"
] | stdin | 1 | null | MBPP | [
"12\n",
"7\n",
"10\n"
] | [
"False\n",
"True\n",
"False\n"
] | [
"12\n",
"7\n"
] | [
"False\n",
"True\n"
] | Original problem description:
Write a python function to find whether the parity of a given number is odd.
We have its functional test sample:
assert find_Parity(12) == False
assert find_Parity(7) == True
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
12
Output:
False
Example 2:
Input:
7
Output:
True
|
Benchmark Questions Verification V2.ipynb | 190 | Write a function to create the next bigger number by rearranging the digits of a given number. | def rearrange_bigger(n):
nums = list(str(n))
for i in range(len(nums)-2,-1,-1):
if nums[i] < nums[i+1]:
z = nums[i:]
y = min(filter(lambda x: x > z[0], z))
z.remove(y)
z.sort()
nums[i:] = [y] + z
return int("".join(nums))
return False | [] | [
"assert rearrange_bigger(12)==21",
"assert rearrange_bigger(10)==False",
"assert rearrange_bigger(102)==120"
] | stdin | 1 | null | MBPP | [
"12\n",
"10\n",
"102\n"
] | [
"21\n",
"False\n",
"120\n"
] | [
"12\n",
"10\n"
] | [
"21\n",
"False\n"
] | Original problem description:
Write a function to create the next bigger number by rearranging the digits of a given number.
We have its functional test sample:
assert rearrange_bigger(12)==21
assert rearrange_bigger(10)==False
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
12
Output:
21
Example 2:
Input:
10
Output:
False
|
Benchmark Questions Verification V2.ipynb | 191 | Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array. | import heapq
def k_smallest_pairs(nums1, nums2, k):
queue = []
def push(i, j):
if i < len(nums1) and j < len(nums2):
heapq.heappush(queue, [nums1[i] + nums2[j], i, j])
push(0, 0)
pairs = []
while queue and len(pairs) < k:
_, i, j = heapq.heappop(queue)
pairs.append([nums1[i], nums2[j]])
push(i, j + 1)
if j == 0:
push(i + 1, 0)
return pairs | [] | [
"assert k_smallest_pairs([1,3,7],[2,4,6],2)==[[1, 2], [1, 4]]",
"assert k_smallest_pairs([1,3,7],[2,4,6],1)==[[1, 2]]",
"assert k_smallest_pairs([1,3,7],[2,4,6],7)==[[1, 2], [1, 4], [3, 2], [1, 6], [3, 4], [3, 6], [7, 2]]"
] | stdin | 1 | null | MBPP | [
"1 3 7\n2 4 6\n2\n",
"1 3 7\n2 4 6\n1\n",
"1 3 7\n2 4 6\n7\n"
] | [
"1 2\n1 4\n",
"1 2\n",
"1 2\n1 4\n3 2\n1 6\n3 4\n3 6\n7 2\n"
] | [
"1 3 7\n2 4 6\n2\n",
"1 3 7\n2 4 6\n1\n"
] | [
"1 2\n1 4\n",
"1 2\n"
] | Original problem description:
Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array.
We have its functional test sample:
assert k_smallest_pairs([1,3,7],[2,4,6],2)==[[1, 2], [1, 4]]
assert k_smallest_pairs([1,3,7],[2,4,6],1)==[[1, 2]]
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
1 3 7
2 4 6
2
Output:
1 2
1 4
Example 2:
Input:
1 3 7
2 4 6
1
Output:
1 2
|
Benchmark Questions Verification V2.ipynb | 192 | Write a function to find the minimum product from the pairs of tuples within a given list. | def min_product_tuple(list1):
result_min = min([abs(x * y) for x, y in list1] )
return result_min | [] | [
"assert min_product_tuple([(2, 7), (2, 6), (1, 8), (4, 9)] )==8",
"assert min_product_tuple([(10,20), (15,2), (5,10)] )==30",
"assert min_product_tuple([(11,44), (10,15), (20,5), (12, 9)] )==100"
] | stdin | 1 | null | MBPP | [
"2 7\n2 6\n1 8\n4 9\n",
"10 20\n15 2\n5 10\n",
"11 44\n10 15\n20 5\n12 9\n"
] | [
"8\n",
"30\n",
"100\n"
] | [
"2 7\n2 6\n1 8\n4 9\n",
"10 20\n15 2\n5 10\n"
] | [
"8\n",
"30\n"
] | Original problem description:
Write a function to find the minimum product from the pairs of tuples within a given list.
We have its functional test sample:
assert min_product_tuple([(2, 7), (2, 6), (1, 8), (4, 9)] )==8
assert min_product_tuple([(10,20), (15,2), (5,10)] )==30
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
2 7
2 6
1 8
4 9
Output:
8
Example 2:
Input:
10 20
15 2
5 10
Output:
30
|
Benchmark Questions Verification V2.ipynb | 193 | Write a function to find the minimum value in a given heterogeneous list. | def min_val(listval):
min_val = min(i for i in listval if isinstance(i, int))
return min_val | [] | [
"assert min_val(['Python', 3, 2, 4, 5, 'version'])==2",
"assert min_val(['Python', 15, 20, 25])==15",
"assert min_val(['Python', 30, 20, 40, 50, 'version'])==20"
] | stdin | 1 | null | MBPP | [
"Python 3 2 4 5 version\n",
"Python 15 20 25\n",
"Python 30 20 40 50 version\n"
] | [
"2\n",
"15\n",
"20\n"
] | [
"Python 3 2 4 5 version\n",
"Python 15 20 25\n"
] | [
"2\n",
"15\n"
] | Original problem description:
Write a function to find the minimum value in a given heterogeneous list.
We have its functional test sample:
assert min_val(['Python', 3, 2, 4, 5, 'version'])==2
assert min_val(['Python', 15, 20, 25])==15
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
Python 3 2 4 5 version
Output:
2
Example 2:
Input:
Python 15 20 25
Output:
15
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 194 | Write a function to convert the given snake case string to camel case string. | import re
def snake_to_camel(word):
return ''.join(x.capitalize() or '_' for x in word.split('_')) | [] | [
"assert snake_to_camel('android_tv') == 'AndroidTv'",
"assert snake_to_camel('google_pixel') == 'GooglePixel'",
"assert snake_to_camel('apple_watch') == 'AppleWatch'"
] | stdin | 1 | null | MBPP | [
"android_tv\n",
"google_pixel\n",
"apple_watch\n"
] | [
"AndroidTv\n",
"GooglePixel\n",
"AppleWatch\n"
] | [
"android_tv\n",
"google_pixel\n"
] | [
"AndroidTv\n",
"GooglePixel\n"
] | Original problem description:
Write a function to convert the given snake case string to camel case string.
We have its functional test sample:
assert snake_to_camel('android_tv') == 'AndroidTv'
assert snake_to_camel('google_pixel') == 'GooglePixel'
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
android_tv
Output:
AndroidTv
Example 2:
Input:
google_pixel
Output:
GooglePixel
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 195 | Write a python function to remove odd numbers from a given list. | def remove_odd(l):
for i in l:
if i % 2 != 0:
l.remove(i)
return l | [] | [
"assert remove_odd([1,2,3]) == [2]",
"assert remove_odd([2,4,6]) == [2,4,6]",
"assert remove_odd([10,20,3]) == [10,20]"
] | stdin | 1 | null | MBPP | [
"1 2 3\n",
"2 4 6\n",
"10 20 3\n"
] | [
"2\n",
"2 4 6\n",
"10 20\n"
] | [
"1 2 3\n",
"2 4 6\n"
] | [
"2\n",
"2 4 6\n"
] | Original problem description:
Write a python function to remove odd numbers from a given list.
We have its functional test sample:
assert remove_odd([1,2,3]) == [2]
assert remove_odd([2,4,6]) == [2,4,6]
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
1 2 3
Output:
2
Example 2:
Input:
2 4 6
Output:
2 4 6
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 197 | Write a python function to check whether any value in a sequence exists in a sequence or not. | def overlapping(list1,list2):
for i in range(len(list1)):
for j in range(len(list2)):
if(list1[i]==list2[j]):
return True
return False | [] | [
"assert overlapping([1,2,3,4,5],[6,7,8,9]) == False",
"assert overlapping([1,2,3],[4,5,6]) == False",
"assert overlapping([1,4,5],[1,4,5]) == True"
] | stdin | 1 | null | MBPP | [
"1 2 3 4 5\n6 7 8 9\n",
"1 2 3\n4 5 6\n",
"1 4 5\n1 4 5\n"
] | [
"False\n",
"False\n",
"True\n"
] | [
"1 2 3 4 5\n6 7 8 9\n",
"1 2 3\n4 5 6\n"
] | [
"False\n",
"False\n"
] | Original problem description:
Write a python function to check whether any value in a sequence exists in a sequence or not.
We have its functional test sample:
assert overlapping([1,2,3,4,5],[6,7,8,9]) == False
assert overlapping([1,2,3],[4,5,6]) == False
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
1 2 3 4 5
6 7 8 9
Output:
False
Example 2:
Input:
1 2 3
4 5 6
Output:
False
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 198 | Write a python function to find a pair with highest product from a given array of integers. | def max_Product(arr):
arr_len = len(arr)
if (arr_len < 2):
return ("No pairs exists")
x = arr[0]; y = arr[1]
for i in range(0,arr_len):
for j in range(i + 1,arr_len):
if (arr[i] * arr[j] > x * y):
x = arr[i]; y = arr[j]
return x,y | [] | [
"assert max_Product([1,2,3,4,7,0,8,4]) == (7,8)",
"assert max_Product([0,-1,-2,-4,5,0,-6]) == (-4,-6)",
"assert max_Product([1,2,3]) == (2,3)"
] | stdin | 1 | null | MBPP | [
"1 2 3 4 7 0 8 4\n",
"0 -1 -2 -4 5 0 -6\n",
"1 2 3\n"
] | [
"7 8\n",
"-4 -6\n",
"2 3\n"
] | [
"1 2 3 4 7 0 8 4\n",
"0 -1 -2 -4 5 0 -6\n"
] | [
"7 8\n",
"-4 -6\n"
] | Original problem description:
Write a python function to find a pair with highest product from a given array of integers.
We have its functional test sample:
assert max_Product([1,2,3,4,7,0,8,4]) == (7,8)
assert max_Product([0,-1,-2,-4,5,0,-6]) == (-4,-6)
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
1 2 3 4 7 0 8 4
Output:
7 8
Example 2:
Input:
0 -1 -2 -4 5 0 -6
Output:
-4 -6
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 199 | Write a function to find common first element in given list of tuple. | def group_tuples(Input):
out = {}
for elem in Input:
try:
out[elem[0]].extend(elem[1:])
except KeyError:
out[elem[0]] = list(elem)
return [tuple(values) for values in out.values()] | [] | [
"assert group_tuples([('x', 'y'), ('x', 'z'), ('w', 't')]) == [('x', 'y', 'z'), ('w', 't')]",
"assert group_tuples([('a', 'b'), ('a', 'c'), ('d', 'e')]) == [('a', 'b', 'c'), ('d', 'e')]",
"assert group_tuples([('f', 'g'), ('f', 'g'), ('h', 'i')]) == [('f', 'g', 'g'), ('h', 'i')]"
] | stdin | 1 | null | MBPP | [
"x y\nx z\nw t\n",
"a b\na c\nd e\n",
"f g\nf g\nh i\n"
] | [
"x y z\nw t\n",
"a b c\nd e\n",
"f g g\nh i\n"
] | [
"x y\nx z\nw t\n",
"a b\na c\nd e\n"
] | [
"x y z\nw t\n",
"a b c\nd e\n"
] | Original problem description:
Write a function to find common first element in given list of tuple.
We have its functional test sample:
assert group_tuples([('x', 'y'), ('x', 'z'), ('w', 't')]) == [('x', 'y', 'z'), ('w', 't')]
assert group_tuples([('a', 'b'), ('a', 'c'), ('d', 'e')]) == [('a', 'b', 'c'), ('d', 'e')]
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
x y
x z
w t
Output:
x y z
w t
Example 2:
Input:
a b
a c
d e
Output:
a b c
d e
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 200 | Write a python function to find the element of a list having maximum length. | def Find_Max(lst):
maxList = max((x) for x in lst)
return maxList | [] | [
"assert Find_Max([['A'],['A','B'],['A','B','C']]) == ['A','B','C']",
"assert Find_Max([[1],[1,2],[1,2,3]]) == [1,2,3]",
"assert Find_Max([[1,1],[1,2,3],[1,5,6,1]]) == [1,5,6,1]"
] | stdin | 1 | null | MBPP | [
"A\nA B\nA B C\n",
"1\n1 2\n1 2 3\n",
"1 1\n1 2 3\n1 5 6 1\n"
] | [
"A B C\n",
"1 2 3\n",
"1 5 6 1\n"
] | [
"A\nA B\nA B C\n",
"1\n1 2\n1 2 3\n"
] | [
"A B C\n",
"1 2 3\n"
] | Original problem description:
Write a python function to find the element of a list having maximum length.
We have its functional test sample:
assert Find_Max([['A'],['A','B'],['A','B','C']]) == ['A','B','C']
assert Find_Max([[1],[1,2],[1,2,3]]) == [1,2,3]
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
A
A B
A B C
Output:
A B C
Example 2:
Input:
1
1 2
1 2 3
Output:
1 2 3
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 201 | Write a function to round every number of a given list of numbers and print the total sum multiplied by the length of the list. | def round_and_sum(list1):
lenght=len(list1)
round_and_sum=sum(list(map(round,list1))* lenght)
return round_and_sum | [] | [
"assert round_and_sum([22.4, 4.0, -16.22, -9.10, 11.00, -12.22, 14.20, -5.20, 17.50])==243",
"assert round_and_sum([5,2,9,24.3,29])==345",
"assert round_and_sum([25.0,56.7,89.2])==513"
] | stdin | 1 | null | MBPP | [
"22.4 4.0 -16.22 -9.1 11.0 -12.22 14.2 -5.2 17.5\n",
"5 2 9 24.3 29\n",
"25.0 56.7 89.2\n"
] | [
"243\n",
"345\n",
"513\n"
] | [
"22.4 4.0 -16.22 -9.1 11.0 -12.22 14.2 -5.2 17.5\n",
"5 2 9 24.3 29\n"
] | [
"243\n",
"345\n"
] | Original problem description:
Write a function to round every number of a given list of numbers and print the total sum multiplied by the length of the list.
We have its functional test sample:
assert round_and_sum([22.4, 4.0, -16.22, -9.10, 11.00, -12.22, 14.20, -5.20, 17.50])==243
assert round_and_sum([5,2,9,24.3,29])==345
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
22.4 4.0 -16.22 -9.1 11.0 -12.22 14.2 -5.2 17.5
Output:
243
Example 2:
Input:
5 2 9 24.3 29
Output:
345
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 202 | Write a python function to find the cube sum of first n even natural numbers. | def cube_Sum(n):
sum = 0
for i in range(1,n + 1):
sum += (2*i)*(2*i)*(2*i)
return sum | [] | [
"assert cube_Sum(2) == 72",
"assert cube_Sum(3) == 288",
"assert cube_Sum(4) == 800"
] | stdin | 1 | null | MBPP | [
"2\n",
"3\n",
"4\n"
] | [
"72\n",
"288\n",
"800\n"
] | [
"2\n",
"3\n"
] | [
"72\n",
"288\n"
] | Original problem description:
Write a python function to find the cube sum of first n even natural numbers.
We have its functional test sample:
assert cube_Sum(2) == 72
assert cube_Sum(3) == 288
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
2
Output:
72
Example 2:
Input:
3
Output:
288
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 203 | Write a function to concatenate each element of tuple by the delimiter. | def concatenate_tuple(test_tup):
delim = "-"
res = ''.join([str(ele) + delim for ele in test_tup])
res = res[ : len(res) - len(delim)]
return (str(res)) | [] | [
"assert concatenate_tuple((\"ID\", \"is\", 4, \"UTS\") ) == 'ID-is-4-UTS'",
"assert concatenate_tuple((\"QWE\", \"is\", 4, \"RTY\") ) == 'QWE-is-4-RTY'",
"assert concatenate_tuple((\"ZEN\", \"is\", 4, \"OP\") ) == 'ZEN-is-4-OP'"
] | stdin | 1 | null | MBPP | [
"ID\nis\n4\nUTS\n",
"QWE\nis\n4\nRTY\n",
"ZEN\nis\n4\nOP\n"
] | [
"ID-is-4-UTS\n",
"QWE-is-4-RTY\n",
"ZEN-is-4-OP\n"
] | [
"ID\nis\n4\nUTS\n",
"QWE\nis\n4\nRTY\n"
] | [
"ID-is-4-UTS\n",
"QWE-is-4-RTY\n"
] | Original problem description:
Write a function to concatenate each element of tuple by the delimiter.
We have its functional test sample:
assert concatenate_tuple(("ID", "is", 4, "UTS") ) == 'ID-is-4-UTS'
assert concatenate_tuple(("QWE", "is", 4, "RTY") ) == 'QWE-is-4-RTY'
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
ID
is
4
UTS
Output:
ID-is-4-UTS
Example 2:
Input:
QWE
is
4
RTY
Output:
QWE-is-4-RTY
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 204 | Write a python function to find the average of cubes of first n natural numbers. | def find_Average_Of_Cube(n):
sum = 0
for i in range(1, n + 1):
sum += i * i * i
return round(sum / n, 6) | [] | [
"assert find_Average_Of_Cube(2) == 4.5",
"assert find_Average_Of_Cube(3) == 12",
"assert find_Average_Of_Cube(1) == 1"
] | stdin | 1 | null | MBPP | [
"2\n",
"3\n",
"1\n"
] | [
"4.5\n",
"12\n",
"1\n"
] | [
"2\n",
"3\n"
] | [
"4.5\n",
"12\n"
] | Original problem description:
Write a python function to find the average of cubes of first n natural numbers.
We have its functional test sample:
assert find_Average_Of_Cube(2) == 4.5
assert find_Average_Of_Cube(3) == 12
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
2
Output:
4.5
Example 2:
Input:
3
Output:
12
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 205 | Write a function to extract only the rear index element of each string in the given tuple. | def extract_rear(test_tuple):
res = list(sub[len(sub) - 1] for sub in test_tuple)
return (res) | [] | [
"assert extract_rear(('Mers', 'for', 'Vers') ) == ['s', 'r', 's']",
"assert extract_rear(('Avenge', 'for', 'People') ) == ['e', 'r', 'e']",
"assert extract_rear(('Gotta', 'get', 'go') ) == ['a', 't', 'o']"
] | stdin | 1 | null | MBPP | [
"Mers\nfor\nVers\n",
"Avenge\nfor\nPeople\n",
"Gotta\nget\ngo\n"
] | [
"s r s\n",
"e r e\n",
"a t o\n"
] | [
"Mers\nfor\nVers\n",
"Avenge\nfor\nPeople\n"
] | [
"s r s\n",
"e r e\n"
] | Original problem description:
Write a function to extract only the rear index element of each string in the given tuple.
We have its functional test sample:
assert extract_rear(('Mers', 'for', 'Vers') ) == ['s', 'r', 's']
assert extract_rear(('Avenge', 'for', 'People') ) == ['e', 'r', 'e']
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
Mers
for
Vers
Output:
s r s
Example 2:
Input:
Avenge
for
People
Output:
e r e
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 207 | Write a function to filter odd numbers. | def filter_oddnumbers(nums):
odd_nums = list(filter(lambda x: x%2 != 0, nums))
return odd_nums | [] | [
"assert filter_oddnumbers([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1,3,5,7,9]",
"assert filter_oddnumbers([10,20,45,67,84,93])==[45,67,93]",
"assert filter_oddnumbers([5,7,9,8,6,4,3])==[5,7,9,3]"
] | stdin | 1 | null | MBPP | [
"1 2 3 4 5 6 7 8 9 10\n",
"10 20 45 67 84 93\n",
"5 7 9 8 6 4 3\n"
] | [
"1 3 5 7 9\n",
"45 67 93\n",
"5 7 9 3\n"
] | [
"1 2 3 4 5 6 7 8 9 10\n",
"10 20 45 67 84 93\n"
] | [
"1 3 5 7 9\n",
"45 67 93\n"
] | Original problem description:
Write a function to filter odd numbers.
We have its functional test sample:
assert filter_oddnumbers([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1,3,5,7,9]
assert filter_oddnumbers([10,20,45,67,84,93])==[45,67,93]
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
1 2 3 4 5 6 7 8 9 10
Output:
1 3 5 7 9
Example 2:
Input:
10 20 45 67 84 93
Output:
45 67 93
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 208 | Write a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format. | import re
def change_date_format(dt):
return re.sub(r'(\d{4})-(\d{1,2})-(\d{1,2})', '\\3-\\2-\\1', dt) | [] | [
"assert change_date_format(\"2026-01-02\") == '02-01-2026'",
"assert change_date_format(\"2020-11-13\") == '13-11-2020'",
"assert change_date_format(\"2021-04-26\") == '26-04-2021'"
] | stdin | 1 | null | MBPP | [
"2026-01-02\n",
"2020-11-13\n",
"2021-04-26\n"
] | [
"02-01-2026\n",
"13-11-2020\n",
"26-04-2021\n"
] | [
"2026-01-02\n",
"2020-11-13\n"
] | [
"02-01-2026\n",
"13-11-2020\n"
] | Original problem description:
Write a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format.
We have its functional test sample:
assert change_date_format("2026-01-02") == '02-01-2026'
assert change_date_format("2020-11-13") == '13-11-2020'
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
2026-01-02
Output:
02-01-2026
Example 2:
Input:
2020-11-13
Output:
13-11-2020
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 209 | Write a function to sort the given array by using shell sort. | def shell_sort(my_list):
gap = len(my_list) // 2
while gap > 0:
for i in range(gap, len(my_list)):
current_item = my_list[i]
j = i
while j >= gap and my_list[j - gap] > current_item:
my_list[j] = my_list[j - gap]
j -= gap
my_list[j] = current_item
gap //= 2
return my_list | [] | [
"assert shell_sort([12, 23, 4, 5, 3, 2, 12, 81, 56, 95]) == [2, 3, 4, 5, 12, 12, 23, 56, 81, 95]",
"assert shell_sort([24, 22, 39, 34, 87, 73, 68]) == [22, 24, 34, 39, 68, 73, 87]",
"assert shell_sort([32, 30, 16, 96, 82, 83, 74]) == [16, 30, 32, 74, 82, 83, 96]"
] | stdin | 1 | null | MBPP | [
"12 23 4 5 3 2 12 81 56 95\n",
"24 22 39 34 87 73 68\n",
"32 30 16 96 82 83 74\n"
] | [
"2 3 4 5 12 12 23 56 81 95\n",
"22 24 34 39 68 73 87\n",
"16 30 32 74 82 83 96\n"
] | [
"12 23 4 5 3 2 12 81 56 95\n",
"24 22 39 34 87 73 68\n"
] | [
"2 3 4 5 12 12 23 56 81 95\n",
"22 24 34 39 68 73 87\n"
] | Original problem description:
Write a function to sort the given array by using shell sort.
We have its functional test sample:
assert shell_sort([12, 23, 4, 5, 3, 2, 12, 81, 56, 95]) == [2, 3, 4, 5, 12, 12, 23, 56, 81, 95]
assert shell_sort([24, 22, 39, 34, 87, 73, 68]) == [22, 24, 34, 39, 68, 73, 87]
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
12 23 4 5 3 2 12 81 56 95
Output:
2 3 4 5 12 12 23 56 81 95
Example 2:
Input:
24 22 39 34 87 73 68
Output:
22 24 34 39 68 73 87
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 210 | Write a function to extract the elementwise and tuples from the given two tuples. | def and_tuples(test_tup1, test_tup2):
res = tuple(ele1 & ele2 for ele1, ele2 in zip(test_tup1, test_tup2))
return (res) | [] | [
"assert and_tuples((10, 4, 6, 9), (5, 2, 3, 3)) == (0, 0, 2, 1)",
"assert and_tuples((1, 2, 3, 4), (5, 6, 7, 8)) == (1, 2, 3, 0)",
"assert and_tuples((8, 9, 11, 12), (7, 13, 14, 17)) == (0, 9, 10, 0)"
] | stdin | 1 | null | MBPP | [
"10 4 6 9\n5 2 3 3\n",
"1 2 3 4\n5 6 7 8\n",
"8 9 11 12\n7 13 14 17\n"
] | [
"0 0 2 1\n",
"1 2 3 0\n",
"0 9 10 0\n"
] | [
"10 4 6 9\n5 2 3 3\n",
"1 2 3 4\n5 6 7 8\n"
] | [
"0 0 2 1\n",
"1 2 3 0\n"
] | Original problem description:
Write a function to extract the elementwise and tuples from the given two tuples.
We have its functional test sample:
assert and_tuples((10, 4, 6, 9), (5, 2, 3, 3)) == (0, 0, 2, 1)
assert and_tuples((1, 2, 3, 4), (5, 6, 7, 8)) == (1, 2, 3, 0)
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
10 4 6 9
5 2 3 3
Output:
0 0 2 1
Example 2:
Input:
1 2 3 4
5 6 7 8
Output:
1 2 3 0
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 211 | Write a function to find the directrix of a parabola. | def parabola_directrix(a, b, c):
directrix=((int)(c - ((b * b) + 1) * 4 * a ))
return directrix | [] | [
"assert parabola_directrix(5,3,2)==-198",
"assert parabola_directrix(9,8,4)==-2336",
"assert parabola_directrix(2,4,6)==-130"
] | stdin | 1 | null | MBPP | [
"5\n3\n2\n",
"9\n8\n4\n",
"2\n4\n6\n"
] | [
"-198\n",
"-2336\n",
"-130\n"
] | [
"5\n3\n2\n",
"9\n8\n4\n"
] | [
"-198\n",
"-2336\n"
] | Original problem description:
Write a function to find the directrix of a parabola.
We have its functional test sample:
assert parabola_directrix(5,3,2)==-198
assert parabola_directrix(9,8,4)==-2336
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
5
3
2
Output:
-198
Example 2:
Input:
9
8
4
Output:
-2336
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 212 | Write a function that takes two lists and returns true if they have at least one common element. | def common_element(list1, list2):
result = False
for x in list1:
for y in list2:
if x == y:
result = True
return result | [] | [
"assert common_element([1,2,3,4,5], [5,6,7,8,9])==True",
"assert common_element([1,2,3,4,5], [6,7,8,9])==None",
"assert common_element(['a','b','c'], ['d','b','e'])==True"
] | stdin | 1 | null | MBPP | [
"1 2 3 4 5\n5 6 7 8 9\n",
"1 2 3 4 5\n6 7 8 9\n",
"a b c\nd b e\n"
] | [
"True\n",
"None\n",
"True\n"
] | [
"1 2 3 4 5\n5 6 7 8 9\n",
"1 2 3 4 5\n6 7 8 9\n"
] | [
"True\n",
"None\n"
] | Original problem description:
Write a function that takes two lists and returns true if they have at least one common element.
We have its functional test sample:
assert common_element([1,2,3,4,5], [5,6,7,8,9])==True
assert common_element([1,2,3,4,5], [6,7,8,9])==None
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
1 2 3 4 5
5 6 7 8 9
Output:
True
Example 2:
Input:
1 2 3 4 5
6 7 8 9
Output:
None
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 213 | Write a function to find the median length of a trapezium. | def median_trapezium(base1,base2,height):
median = 0.5 * (base1+ base2)
return median | [] | [
"assert median_trapezium(15,25,35)==20",
"assert median_trapezium(10,20,30)==15",
"assert median_trapezium(6,9,4)==7.5"
] | stdin | 1 | null | MBPP | [
"15\n25\n35\n",
"10\n20\n30\n",
"6\n9\n4\n"
] | [
"20\n",
"15\n",
"7.5\n"
] | [
"15\n25\n35\n",
"10\n20\n30\n"
] | [
"20\n",
"15\n"
] | Original problem description:
Write a function to find the median length of a trapezium.
We have its functional test sample:
assert median_trapezium(15,25,35)==20
assert median_trapezium(10,20,30)==15
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
15
25
35
Output:
20
Example 2:
Input:
10
20
30
Output:
15
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 214 | Write a function to check whether the entered number is greater than the elements of the given array. | def check_greater(arr, number):
arr.sort()
return number > arr[-1] | [] | [
"assert check_greater([1, 2, 3, 4, 5], 4) == False",
"assert check_greater([2, 3, 4, 5, 6], 8) == True",
"assert check_greater([9, 7, 4, 8, 6, 1], 11) == True"
] | stdin | 1 | null | MBPP | [
"1 2 3 4 5\n4\n",
"2 3 4 5 6\n8\n",
"9 7 4 8 6 1\n11\n"
] | [
"False\n",
"True\n",
"True\n"
] | [
"1 2 3 4 5\n4\n",
"2 3 4 5 6\n8\n"
] | [
"False\n",
"True\n"
] | Original problem description:
Write a function to check whether the entered number is greater than the elements of the given array.
We have its functional test sample:
assert check_greater([1, 2, 3, 4, 5], 4) == False
assert check_greater([2, 3, 4, 5, 6], 8) == True
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
1 2 3 4 5
4
Output:
False
Example 2:
Input:
2 3 4 5 6
8
Output:
True
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 215 | Write a function that matches a string that has an a followed by one or more b's. | import re
def text_match_one(text):
patterns = 'ab+?'
if re.search(patterns, text):
return True
else:
return False
| [] | [
"assert text_match_one(\"ac\")==False",
"assert text_match_one(\"dc\")==False",
"assert text_match_one(\"abba\")==True"
] | stdin | 1 | null | MBPP | [
"ac\n",
"dc\n",
"abba\n"
] | [
"False\n",
"False\n",
"True\n"
] | [
"ac\n",
"dc\n"
] | [
"False\n",
"False\n"
] | Original problem description:
Write a function that matches a string that has an a followed by one or more b's.
We have its functional test sample:
assert text_match_one("ac")==False
assert text_match_one("dc")==False
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
ac
Output:
False
Example 2:
Input:
dc
Output:
False
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 216 | Write a python function to find the last digit of a given number. | def last_Digit(n) :
return (n % 10) | [] | [
"assert last_Digit(123) == 3",
"assert last_Digit(25) == 5",
"assert last_Digit(30) == 0"
] | stdin | 1 | null | MBPP | [
"123\n",
"25\n",
"30\n"
] | [
"3\n",
"5\n",
"0\n"
] | [
"123\n",
"25\n"
] | [
"3\n",
"5\n"
] | Original problem description:
Write a python function to find the last digit of a given number.
We have its functional test sample:
assert last_Digit(123) == 3
assert last_Digit(25) == 5
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
123
Output:
3
Example 2:
Input:
25
Output:
5
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 217 | Write a python function to return the negative numbers in a list. | def neg_nos(list1):
out = []
for num in list1:
if num < 0:
out.append(num)
return out | [] | [
"assert neg_nos([-1,4,5,-6]) == [-1,-6]",
"assert neg_nos([-1,-2,3,4]) == [-1,-2]",
"assert neg_nos([-7,-6,8,9]) == [-7,-6]"
] | stdin | 1 | null | MBPP | [
"-1 4 5 -6\n",
"-1 -2 3 4\n",
"-7 -6 8 9\n"
] | [
"-1 -6\n",
"-1 -2\n",
"-7 -6\n"
] | [
"-1 4 5 -6\n",
"-1 -2 3 4\n"
] | [
"-1 -6\n",
"-1 -2\n"
] | Original problem description:
Write a python function to return the negative numbers in a list.
We have its functional test sample:
assert neg_nos([-1,4,5,-6]) == [-1,-6]
assert neg_nos([-1,-2,3,4]) == [-1,-2]
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
-1 4 5 -6
Output:
-1 -6
Example 2:
Input:
-1 -2 3 4
Output:
-1 -2
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 218 | Write a function to remove odd characters in a string. | def remove_odd(str1):
str2 = ''
for i in range(1, len(str1) + 1):
if(i % 2 == 0):
str2 = str2 + str1[i - 1]
return str2 | [] | [
"assert remove_odd(\"python\")==(\"yhn\")",
"assert remove_odd(\"program\")==(\"rga\")",
"assert remove_odd(\"language\")==(\"agae\")"
] | stdin | 1 | null | MBPP | [
"python\n",
"program\n",
"language\n"
] | [
"yhn\n",
"rga\n",
"agae\n"
] | [
"python\n",
"program\n"
] | [
"yhn\n",
"rga\n"
] | Original problem description:
Write a function to remove odd characters in a string.
We have its functional test sample:
assert remove_odd("python")==("yhn")
assert remove_odd("program")==("rga")
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
python
Output:
yhn
Example 2:
Input:
program
Output:
rga
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 219 | Write a function to count bidirectional tuple pairs. | def count_bidirectional(test_list):
res = 0
for idx in range(0, len(test_list)):
for iidx in range(idx + 1, len(test_list)):
if test_list[iidx][0] == test_list[idx][1] and test_list[idx][1] == test_list[iidx][0]:
res += 1
return res | [] | [
"assert count_bidirectional([(5, 6), (1, 2), (6, 5), (9, 1), (6, 5), (2, 1)] ) == 3",
"assert count_bidirectional([(5, 6), (1, 3), (6, 5), (9, 1), (6, 5), (2, 1)] ) == 2",
"assert count_bidirectional([(5, 6), (1, 2), (6, 5), (9, 2), (6, 5), (2, 1)] ) == 4"
] | stdin | 1 | null | MBPP | [
"5 6\n1 2\n6 5\n9 1\n6 5\n2 1\n",
"5 6\n1 3\n6 5\n9 1\n6 5\n2 1\n",
"5 6\n1 2\n6 5\n9 2\n6 5\n2 1\n"
] | [
"3\n",
"2\n",
"4\n"
] | [
"5 6\n1 2\n6 5\n9 1\n6 5\n2 1\n",
"5 6\n1 3\n6 5\n9 1\n6 5\n2 1\n"
] | [
"3\n",
"2\n"
] | Original problem description:
Write a function to count bidirectional tuple pairs.
We have its functional test sample:
assert count_bidirectional([(5, 6), (1, 2), (6, 5), (9, 1), (6, 5), (2, 1)] ) == 3
assert count_bidirectional([(5, 6), (1, 3), (6, 5), (9, 1), (6, 5), (2, 1)] ) == 2
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
5 6
1 2
6 5
9 1
6 5
2 1
Output:
3
Example 2:
Input:
5 6
1 3
6 5
9 1
6 5
2 1
Output:
2
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 220 | Write a function to join a list of multiple integers into a single integer. | def multiple_to_single(L):
x = int("".join(map(str, L)))
return x | [] | [
"assert multiple_to_single([11, 33, 50])==113350",
"assert multiple_to_single([-1,2,3,4,5,6])==-123456",
"assert multiple_to_single([10,15,20,25])==10152025"
] | stdin | 1 | null | MBPP | [
"11 33 50\n",
"-1 2 3 4 5 6\n",
"10 15 20 25\n"
] | [
"113350\n",
"-123456\n",
"10152025\n"
] | [
"11 33 50\n",
"-1 2 3 4 5 6\n"
] | [
"113350\n",
"-123456\n"
] | Original problem description:
Write a function to join a list of multiple integers into a single integer.
We have its functional test sample:
assert multiple_to_single([11, 33, 50])==113350
assert multiple_to_single([-1,2,3,4,5,6])==-123456
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
11 33 50
Output:
113350
Example 2:
Input:
-1 2 3 4 5 6
Output:
-123456
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 221 | Write a function to find the first adverb and their positions in a given sentence. | import re
def find_adverb_position(text):
for m in re.finditer(r"\w+ly", text):
return (m.start(), m.end(), m.group(0)) | [] | [
"assert find_adverb_position(\"clearly!! we can see the sky\")==(0, 7, 'clearly')",
"assert find_adverb_position(\"seriously!! there are many roses\")==(0, 9, 'seriously')",
"assert find_adverb_position(\"unfortunately!! sita is going to home\")==(0, 13, 'unfortunately')"
] | stdin | 1 | null | MBPP | [
"clearly!! we can see the sky\n",
"seriously!! there are many roses\n",
"unfortunately!! sita is going to home\n"
] | [
"0 7 clearly\n",
"0 9 seriously\n",
"0 13 unfortunately\n"
] | [
"clearly!! we can see the sky\n",
"seriously!! there are many roses\n"
] | [
"0 7 clearly\n",
"0 9 seriously\n"
] | Original problem description:
Write a function to find the first adverb and their positions in a given sentence.
We have its functional test sample:
assert find_adverb_position("clearly!! we can see the sky")==(0, 7, 'clearly')
assert find_adverb_position("seriously!! there are many roses")==(0, 9, 'seriously')
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
clearly!! we can see the sky
Output:
0 7 clearly
Example 2:
Input:
seriously!! there are many roses
Output:
0 9 seriously
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 222 | Write a function to find the surface area of a cube of a given size. | def surfacearea_cube(l):
surfacearea= 6*l*l
return surfacearea | [] | [
"assert surfacearea_cube(5)==150",
"assert surfacearea_cube(3)==54",
"assert surfacearea_cube(10)==600"
] | stdin | 1 | null | MBPP | [
"5\n",
"3\n",
"10\n"
] | [
"150\n",
"54\n",
"600\n"
] | [
"5\n",
"3\n"
] | [
"150\n",
"54\n"
] | Original problem description:
Write a function to find the surface area of a cube of a given size.
We have its functional test sample:
assert surfacearea_cube(5)==150
assert surfacearea_cube(3)==54
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
5
Output:
150
Example 2:
Input:
3
Output:
54
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 223 | Write a function to find the ration of positive numbers in an array of integers. | from array import array
def positive_count(nums):
n = len(nums)
n1 = 0
for x in nums:
if x > 0:
n1 += 1
else:
None
return round(n1/n,2) | [] | [
"assert positive_count([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8])==0.54",
"assert positive_count([2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==0.69",
"assert positive_count([2, 4, -6, -9, 11, -12, 14, -5, 17])==0.56"
] | stdin | 1 | null | MBPP | [
"0 1 2 -1 -5 6 0 -3 -2 3 4 6 8\n",
"2 1 2 -1 -5 6 4 -3 -2 3 4 6 8\n",
"2 4 -6 -9 11 -12 14 -5 17\n"
] | [
"0.54\n",
"0.69\n",
"0.56\n"
] | [
"0 1 2 -1 -5 6 0 -3 -2 3 4 6 8\n",
"2 1 2 -1 -5 6 4 -3 -2 3 4 6 8\n"
] | [
"0.54\n",
"0.69\n"
] | Original problem description:
Write a function to find the ration of positive numbers in an array of integers.
We have its functional test sample:
assert positive_count([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8])==0.54
assert positive_count([2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==0.69
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
0 1 2 -1 -5 6 0 -3 -2 3 4 6 8
Output:
0.54
Example 2:
Input:
2 1 2 -1 -5 6 4 -3 -2 3 4 6 8
Output:
0.69
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 224 | Write a python function to find the largest negative number from the given list. | def largest_neg(list1):
max = list1[0]
for x in list1:
if x < max :
max = x
return max | [] | [
"assert largest_neg([1,2,3,-4,-6]) == -6",
"assert largest_neg([1,2,3,-8,-9]) == -9",
"assert largest_neg([1,2,3,4,-1]) == -1"
] | stdin | 1 | null | MBPP | [
"1 2 3 -4 -6\n",
"1 2 3 -8 -9\n",
"1 2 3 4 -1\n"
] | [
"-6\n",
"-9\n",
"-1\n"
] | [
"1 2 3 -4 -6\n",
"1 2 3 -8 -9\n"
] | [
"-6\n",
"-9\n"
] | Original problem description:
Write a python function to find the largest negative number from the given list.
We have its functional test sample:
assert largest_neg([1,2,3,-4,-6]) == -6
assert largest_neg([1,2,3,-8,-9]) == -9
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
1 2 3 -4 -6
Output:
-6
Example 2:
Input:
1 2 3 -8 -9
Output:
-9
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 227 | Write a python function to count the occurence of all elements of list in a tuple. | from collections import Counter
def count_Occurrence(tup, lst):
count = 0
for item in tup:
if item in lst:
count+= 1
return count | [] | [
"assert count_Occurrence(('a', 'a', 'c', 'b', 'd'),['a', 'b'] ) == 3",
"assert count_Occurrence((1, 2, 3, 1, 4, 6, 7, 1, 4),[1, 4, 7]) == 6",
"assert count_Occurrence((1,2,3,4,5,6),[1,2]) == 2"
] | stdin | 1 | null | MBPP | [
"a a c b d\na b\n",
"1 2 3 1 4 6 7 1 4\n1 4 7\n",
"1 2 3 4 5 6\n1 2\n"
] | [
"3\n",
"6\n",
"2\n"
] | [
"a a c b d\na b\n",
"1 2 3 1 4 6 7 1 4\n1 4 7\n"
] | [
"3\n",
"6\n"
] | Original problem description:
Write a python function to count the occurence of all elements of list in a tuple.
We have its functional test sample:
assert count_Occurrence(('a', 'a', 'c', 'b', 'd'),['a', 'b'] ) == 3
assert count_Occurrence((1, 2, 3, 1, 4, 6, 7, 1, 4),[1, 4, 7]) == 6
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
a a c b d
a b
Output:
3
Example 2:
Input:
1 2 3 1 4 6 7 1 4
1 4 7
Output:
6
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 228 | Write a function to find cubes of individual elements in a list. | def cube_nums(nums):
cube_nums = list(map(lambda x: x ** 3, nums))
return cube_nums | [] | [
"assert cube_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]",
"assert cube_nums([10,20,30])==([1000, 8000, 27000])",
"assert cube_nums([12,15])==([1728, 3375])"
] | stdin | 1 | null | MBPP | [
"1 2 3 4 5 6 7 8 9 10\n",
"10 20 30\n",
"12 15\n"
] | [
"1 8 27 64 125 216 343 512 729 1000\n",
"1000 8000 27000\n",
"1728 3375\n"
] | [
"1 2 3 4 5 6 7 8 9 10\n",
"10 20 30\n"
] | [
"1 8 27 64 125 216 343 512 729 1000\n",
"1000 8000 27000\n"
] | Original problem description:
Write a function to find cubes of individual elements in a list.
We have its functional test sample:
assert cube_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]
assert cube_nums([10,20,30])==([1000, 8000, 27000])
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
1 2 3 4 5 6 7 8 9 10
Output:
1 8 27 64 125 216 343 512 729 1000
Example 2:
Input:
10 20 30
Output:
1000 8000 27000
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 229 | Write a function to calculate the sum of perrin numbers. | def cal_sum(n):
a = 3
b = 0
c = 2
if (n == 0):
return 3
if (n == 1):
return 3
if (n == 2):
return 5
sum = 5
while (n > 2):
d = a + b
sum = sum + d
a = b
b = c
c = d
n = n-1
return sum | [] | [
"assert cal_sum(9) == 49",
"assert cal_sum(10) == 66",
"assert cal_sum(11) == 88"
] | stdin | 1 | null | MBPP | [
"9\n",
"10\n",
"11\n"
] | [
"49\n",
"66\n",
"88\n"
] | [
"9\n",
"10\n"
] | [
"49\n",
"66\n"
] | Original problem description:
Write a function to calculate the sum of perrin numbers.
We have its functional test sample:
assert cal_sum(9) == 49
assert cal_sum(10) == 66
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
9
Output:
49
Example 2:
Input:
10
Output:
66
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 230 | Write a function to extract specified size of strings from a given list of string values. | def extract_string(str, l):
result = [e for e in str if len(e) == l]
return result | [] | [
"assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,8)==['practice', 'solution']",
"assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,6)==['Python']",
"assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,9)==['exercises']"
] | stdin | 1 | null | MBPP | [
"Python list exercises practice solution\n8\n",
"Python list exercises practice solution\n6\n",
"Python list exercises practice solution\n9\n"
] | [
"practice solution\n",
"Python\n",
"exercises\n"
] | [
"Python list exercises practice solution\n8\n",
"Python list exercises practice solution\n6\n"
] | [
"practice solution\n",
"Python\n"
] | Original problem description:
Write a function to extract specified size of strings from a given list of string values.
We have its functional test sample:
assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,8)==['practice', 'solution']
assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,6)==['Python']
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
Python list exercises practice solution
8
Output:
practice solution
Example 2:
Input:
Python list exercises practice solution
6
Output:
Python
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 231 | Write a function to remove all whitespaces from the given string. | import re
def remove_whitespaces(text1):
return (re.sub(r'\s+', '',text1)) | [] | [
"assert remove_whitespaces(' Google Flutter ') == 'GoogleFlutter'",
"assert remove_whitespaces(' Google Dart ') == 'GoogleDart'",
"assert remove_whitespaces(' iOS Swift ') == 'iOSSwift'"
] | stdin | 1 | null | MBPP | [
"Google Flutter\n",
"Google Dart\n",
"iOS Swift\n"
] | [
"GoogleFlutter\n",
"GoogleDart\n",
"iOSSwift\n"
] | [
"Google Flutter\n",
"Google Dart\n"
] | [
"GoogleFlutter\n",
"GoogleDart\n"
] | Original problem description:
Write a function to remove all whitespaces from the given string.
We have its functional test sample:
assert remove_whitespaces(' Google Flutter ') == 'GoogleFlutter'
assert remove_whitespaces(' Google Dart ') == 'GoogleDart'
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
Google Flutter
Output:
GoogleFlutter
Example 2:
Input:
Google Dart
Output:
GoogleDart
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 232 | Write a function that gives loss amount on a sale if the given amount has loss else return 0. | def loss_amount(actual_cost,sale_amount):
if(sale_amount > actual_cost):
amount = sale_amount - actual_cost
return amount
else:
return 0 | [] | [
"assert loss_amount(1500,1200)==0",
"assert loss_amount(100,200)==100",
"assert loss_amount(2000,5000)==3000"
] | stdin | 1 | null | MBPP | [
"1500\n1200\n",
"100\n200\n",
"2000\n5000\n"
] | [
"0\n",
"100\n",
"3000\n"
] | [
"1500\n1200\n",
"100\n200\n"
] | [
"0\n",
"100\n"
] | Original problem description:
Write a function that gives loss amount on a sale if the given amount has loss else return 0.
We have its functional test sample:
assert loss_amount(1500,1200)==0
assert loss_amount(100,200)==100
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
1500
1200
Output:
0
Example 2:
Input:
100
200
Output:
100
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 233 | Write a python function to find the sum of even factors of a number. | import math
def sumofFactors(n) :
if (n % 2 != 0) :
return 0
res = 1
for i in range(2, (int)(math.sqrt(n)) + 1) :
count = 0
curr_sum = 1
curr_term = 1
while (n % i == 0) :
count= count + 1
n = n // i
if (i == 2 and count == 1) :
curr_sum = 0
curr_term = curr_term * i
curr_sum = curr_sum + curr_term
res = res * curr_sum
if (n >= 2) :
res = res * (1 + n)
return res | [] | [
"assert sumofFactors(18) == 26",
"assert sumofFactors(30) == 48",
"assert sumofFactors(6) == 8"
] | stdin | 1 | null | MBPP | [
"18\n",
"30\n",
"6\n"
] | [
"26\n",
"48\n",
"8\n"
] | [
"18\n",
"30\n"
] | [
"26\n",
"48\n"
] | Original problem description:
Write a python function to find the sum of even factors of a number.
We have its functional test sample:
assert sumofFactors(18) == 26
assert sumofFactors(30) == 48
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
18
Output:
26
Example 2:
Input:
30
Output:
48
|
charlessutton@: Benchmark Questions Verification V2.ipynb | 234 | Write a function that matches a word containing 'z'. | import re
def text_match_wordz(text):
patterns = '\w*z.\w*'
if re.search(patterns, text):
return True
else:
return False | [] | [
"assert text_match_wordz(\"pythonz.\")==True",
"assert text_match_wordz(\"xyz.\")==True",
"assert text_match_wordz(\" lang .\")==False"
] | stdin | 1 | null | MBPP | [
"pythonz.\n",
"xyz.\n",
"lang .\n"
] | [
"True\n",
"True\n",
"False\n"
] | [
"pythonz.\n",
"xyz.\n"
] | [
"True\n",
"True\n"
] | Original problem description:
Write a function that matches a word containing 'z'.
We have its functional test sample:
assert text_match_wordz("pythonz.")==True
assert text_match_wordz("xyz.")==True
However, the functional I/O tests have been converted to a standard stdin/stdout format for this task. The followings are some input and output examples. Please read from stdin and write to stdout exactly as shown below.
Your solution must strictly follow these formats. For instance, many raw functional test cases contain a list like [a1, a2, a3, ...]. After conversion, these may appear as a single line of input: "a1 a2 a3 ...". You should read this line directly, without first reading the length of the list.
Example 1:
Input:
pythonz.
Output:
True
Example 2:
Input:
xyz.
Output:
True
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.