task_id stringlengths 6 8 | text stringlengths 368 1.62k |
|---|---|
Mbpp/2 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find the shared elements from the given two lists
assert set(similar_elements((3, 4, 5, 6),(5, 7, 4, 10))) == set((4, 5))
```
### Answer:
Below is a Python script with a self-contained funct... |
Mbpp/3 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to identify non-prime numbers
assert is_not_prime(2) == False
```
### Answer:
Below is a Python script with a self-contained function that solves the problem and passes corresponding tes... |
Mbpp/4 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find the n largest integers from a given list of numbers, returned in descending order
assert heap_queue_largest( [25, 35, 22, 85, 14, 65, 75, 22, 58],3)==[85, 75, 65]
```
### Answer:
Below ... |
Mbpp/6 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to check whether the two numbers differ at one bit position only or not
assert differ_At_One_Bit_Pos(13,9) == True
```
### Answer:
Below is a Python script with a self-contained function... |
Mbpp/7 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find all words which are at least 4 characters long in a string
assert set(find_char_long('Please move back to stream')) == set(['Please', 'move', 'back', 'stream'])
```
### Answer:
Below is... |
Mbpp/8 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find squares of individual elements in a list
assert square_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
```
### Answer:
Below is a Python script with a self... |
Mbpp/9 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to find the minimum number of rotations (greater than 0) required to get the same string
assert find_Rotations("aaaa") == 1
```
### Answer:
Below is a Python script with a self-contained... |
Mbpp/11 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to remove first and last occurrence of a given character from the string
assert remove_Occ("hello","l") == "heo"
```
### Answer:
Below is a Python script with a self-contained function t... |
Mbpp/12 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to sort a given matrix in ascending order according to the sum of its rows
assert sort_matrix([[1, 2, 3], [2, 4, 5], [1, 1, 1]])==[[1, 1, 1], [1, 2, 3], [2, 4, 5]]
```
### Answer:
Below is a Py... |
Mbpp/14 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to find the volume of a triangular prism
assert find_Volume(10,8,6) == 240
```
### Answer:
Below is a Python script with a self-contained function that solves the problem and passes corr... |
Mbpp/16 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to that returns true if the input string contains sequences of lowercase letters joined with an underscore and false otherwise
assert text_lowercase_underscore("aab_cbbbc")==(True)
```
### Answ... |
Mbpp/17 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function that returns the perimeter of a square given its side length as input
assert square_perimeter(10)==40
```
### Answer:
Below is a Python script with a self-contained function that solves the pro... |
Mbpp/18 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to remove characters from the first string which are present in the second string
assert remove_dirty_chars("probasscurve", "pros") == 'bacuve'
```
### Answer:
Below is a Python script with a s... |
Mbpp/19 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find whether a given array of integers contains any duplicate element
assert test_duplicate(([1,2,3,4,5]))==False
```
### Answer:
Below is a Python script with a self-contained function that... |
Mbpp/20 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to check if the given number is woodball or not
assert is_woodall(383) == True
```
### Answer:
Below is a Python script with a self-contained function that solves the problem and passes corresp... |
Mbpp/56 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to check if a given number is one less than twice its reverse
assert check(70) == False
```
### Answer:
Below is a Python script with a self-contained function that solves the problem an... |
Mbpp/57 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to find the largest number that can be formed with the given list of digits
assert find_Max_Num([1,2,3]) == 321
```
### Answer:
Below is a Python script with a self-contained function th... |
Mbpp/58 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to check whether the given two integers have opposite sign or not
assert opposite_Signs(1,-2) == True
```
### Answer:
Below is a Python script with a self-contained function that solves ... |
Mbpp/59 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find the nth octagonal number
assert is_octagonal(5) == 65
```
### Answer:
Below is a Python script with a self-contained function that solves the problem and passes corresponding tests:
```... |
Mbpp/61 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to count the number of substrings with the sum of digits equal to their length
assert count_Substrings('112112') == 6
```
### Answer:
Below is a Python script with a self-contained funct... |
Mbpp/62 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to find smallest number in a list
assert smallest_num([10, 20, 1, 45, 99]) == 1
```
### Answer:
Below is a Python script with a self-contained function that solves the problem and passes... |
Mbpp/63 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find the maximum difference between available pairs in the given tuple list
assert max_difference([(3, 5), (1, 7), (10, 3), (1, 2)]) == 7
```
### Answer:
Below is a Python script with a self... |
Mbpp/64 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to sort a list of tuples using the second value of each tuple
assert subject_marks([('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)])==[('Social sciences', 82), ('Engli... |
Mbpp/65 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to flatten a list and sum all of its elements
assert recursive_list_sum(([1, 2, [3,4],[5,6]]))==21
```
### Answer:
Below is a Python script with a self-contained function that solves the proble... |
Mbpp/66 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to count the number of positive numbers in a list
assert pos_count([1,-2,3,-4]) == 2
```
### Answer:
Below is a Python script with a self-contained function that solves the problem and p... |
Mbpp/67 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find the number of ways to partition a set of Bell numbers
assert bell_number(2)==2
```
### Answer:
Below is a Python script with a self-contained function that solves the problem and passes... |
Mbpp/68 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to check whether the given array is monotonic or not
assert is_Monotonic([6, 5, 4, 4]) == True
```
### Answer:
Below is a Python script with a self-contained function that solves the pro... |
Mbpp/69 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to check whether a list contains the given sublist or not
assert is_sublist([2,4,3,5,7],[3,7])==False
```
### Answer:
Below is a Python script with a self-contained function that solves the pro... |
Mbpp/70 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find whether all the given tuples have equal length or not
assert get_equal([(11, 22, 33), (44, 55, 66)]) == True
```
### Answer:
Below is a Python script with a self-contained function that... |
Mbpp/71 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to sort a list of elements
assert comb_sort([5, 15, 37, 25, 79]) == [5, 15, 25, 37, 79]
```
### Answer:
Below is a Python script with a self-contained function that solves the problem and passe... |
Mbpp/72 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to check whether the given number can be represented as the difference of two squares or not
assert dif_Square(5) == True
```
### Answer:
Below is a Python script with a self-contained f... |
Mbpp/74 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to check whether it follows the sequence given in the patterns array
assert is_samepatterns(["red","green","green"], ["a", "b", "b"])==True
```
### Answer:
Below is a Python script with a self-... |
Mbpp/75 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find tuples which have all elements divisible by k from the given list of tuples
assert find_tuples([(6, 24, 12), (7, 9, 6), (12, 18, 21)], 6) == [(6, 24, 12)]
```
### Answer:
Below is a Pyt... |
Mbpp/77 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to find whether a number is divisible by 11
assert is_Diff (12345) == False
```
### Answer:
Below is a Python script with a self-contained function that solves the problem and passes cor... |
Mbpp/79 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to check whether the length of the word is odd or not
assert word_len("Hadoop") == False
```
### Answer:
Below is a Python script with a self-contained function that solves the problem a... |
Mbpp/80 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find the nth tetrahedral number
assert tetrahedral_number(5) == 35
```
### Answer:
Below is a Python script with a self-contained function that solves the problem and passes corresponding te... |
Mbpp/82 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find the volume of a sphere
assert math.isclose(volume_sphere(10), 4188.790204786391, rel_tol=0.001)
```
### Answer:
Below is a Python script with a self-contained function that solves the p... |
Mbpp/84 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find the nth number in the newman conway sequence
assert sequence(10) == 6
```
### Answer:
Below is a Python script with a self-contained function that solves the problem and passes correspo... |
Mbpp/85 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find the surface area of a sphere
assert math.isclose(surfacearea_sphere(10), 1256.6370614359173, rel_tol=0.001)
```
### Answer:
Below is a Python script with a self-contained function that ... |
Mbpp/86 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find nth centered hexagonal number
assert centered_hexagonal_number(10) == 271
```
### Answer:
Below is a Python script with a self-contained function that solves the problem and passes corr... |
Mbpp/87 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to merge three dictionaries into a single dictionary
assert merge_dictionaries_three({ "R": "Red", "B": "Black", "P": "Pink" }, { "G": "Green", "W": "White" },{ "O": "Orange", "W": "White", "B"... |
Mbpp/88 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to get the frequency of all the elements in a list, returned as a dictionary
assert freq_count([10,10,10,10,20,20,20,20,40,40,50,50,30])==({10: 4, 20: 4, 40: 2, 50: 2, 30: 1})
```
### Answer:
B... |
Mbpp/89 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find the closest smaller number than n
assert closest_num(11) == 10
```
### Answer:
Below is a Python script with a self-contained function that solves the problem and passes corresponding t... |
Mbpp/90 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to find the length of the longest word
assert len_log(["python","PHP","bigdata"]) == 7
```
### Answer:
Below is a Python script with a self-contained function that solves the problem and... |
Mbpp/91 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to check if a string is present as a substring in a given list of string values
assert find_substring(["red", "black", "white", "green", "orange"],"ack")==True
```
### Answer:
Below is a Python... |
Mbpp/92 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to check whether the given number is undulating or not
assert is_undulating(1212121) == True
```
### Answer:
Below is a Python script with a self-contained function that solves the problem and ... |
Mbpp/93 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to calculate the value of 'a' to the power 'b'
assert power(3,4) == 81
```
### Answer:
Below is a Python script with a self-contained function that solves the problem and passes corresponding t... |
Mbpp/94 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Given a list of tuples, write a function that returns the first value of the tuple with the smallest second value
assert index_minimum([('Rash', 143), ('Manjeet', 200), ('Varsha', 100)]) == 'Varsha'
```
### Ans... |
Mbpp/95 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to find the length of the smallest list in a list of lists
assert Find_Min_Length([[1],[1,2]]) == 1
```
### Answer:
Below is a Python script with a self-contained function that solves th... |
Mbpp/96 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to find the number of divisors of a given integer
assert divisor(15) == 4
```
### Answer:
Below is a Python script with a self-contained function that solves the problem and passes corre... |
Mbpp/97 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary
assert frequency_lists([[1, 2, 3, 2], [4, 5, 6, 2], [7, 8, 9, 5]])=={1: 1, 2: 3, 3: 1, 4: 1, 5: 2, 6: 1,... |
Mbpp/98 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to multiply all the numbers in a list and divide with the length of the list
assert math.isclose(multiply_num((8, 2, 3, -1, 7)), -67.2, rel_tol=0.001)
```
### Answer:
Below is a Python script w... |
Mbpp/99 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to convert the given decimal number to its binary equivalent, represented as a string with no leading zeros
assert decimal_to_binary(8) == '1000'
```
### Answer:
Below is a Python script with a... |
Mbpp/100 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find the next smallest palindrome of a specified integer, returned as an integer
assert next_smallest_palindrome(99)==101
```
### Answer:
Below is a Python script with a self-contained funct... |
Mbpp/101 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find the kth element in the given array using 1-based indexing
assert kth_element([12,3,5,7,19], 2) == 3
```
### Answer:
Below is a Python script with a self-contained function that solves t... |
Mbpp/102 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to convert a snake case string to camel case string
assert snake_to_camel('python_program')=='PythonProgram'
```
### Answer:
Below is a Python script with a self-contained function that solves ... |
Mbpp/103 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find the Eulerian number a(n, m)
assert eulerian_num(3, 1) == 4
```
### Answer:
Below is a Python script with a self-contained function that solves the problem and passes corresponding tests... |
Mbpp/104 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to sort each sublist of strings in a given list of lists
assert sort_sublists((["green", "orange"], ["black", "white"], ["white", "black", "orange"]))==[['green', 'orange'], ['black', 'white'],... |
Mbpp/105 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to count true booleans in the given list
assert count([True,False,True]) == 2
```
### Answer:
Below is a Python script with a self-contained function that solves the problem and passes c... |
Mbpp/106 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to append the given list to the given tuples
assert add_lists([5, 6, 7], (9, 10)) == (9, 10, 5, 6, 7)
```
### Answer:
Below is a Python script with a self-contained function that solves the pro... |
Mbpp/108 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to merge three lists into a single sorted list
assert merge_sorted_list([25, 24, 15, 4, 5, 29, 110],[19, 20, 11, 56, 25, 233, 154],[24, 26, 54, 48])==[4, 5, 11, 15, 19, 20, 24, 24, 25, 25, 26, ... |
Mbpp/109 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to find the number of numbers with an odd value when rotating a binary string the given number of times
assert odd_Equivalent("011001",6) == 3
```
### Answer:
Below is a Python script wi... |
Mbpp/111 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find the common elements in given nested lists
assert set(common_in_nested_lists([[12, 18, 23, 25, 45], [7, 12, 18, 24, 28], [1, 5, 8, 12, 15, 16, 18]]))==set([18, 12])
```
### Answer:
Below... |
Mbpp/113 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to check if a string represents an integer or not
assert check_integer("python")==False
```
### Answer:
Below is a Python script with a self-contained function that solves the problem and passe... |
Mbpp/116 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to convert a given tuple of positive integers into a single integer
assert tuple_to_int((1,2,3))==123
```
### Answer:
Below is a Python script with a self-contained function that solves the pro... |
Mbpp/118 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to convert a string to a list of strings split on the space character
assert string_to_list("python programming")==['python','programming']
```
### Answer:
Below is a Python script with a self-... |
Mbpp/119 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to find the element that appears only once in a sorted array
assert search([1,1,2,2,3]) == 3
```
### Answer:
Below is a Python script with a self-contained function that solves the probl... |
Mbpp/120 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find the maximum absolute product between numbers in pairs of tuples within a given list
assert max_product_tuple([(2, 7), (2, 6), (1, 8), (4, 9)] )==36
```
### Answer:
Below is a Python scr... |
Mbpp/123 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to sum all amicable numbers from 1 to a specified number
assert amicable_numbers_sum(999)==504
```
### Answer:
Below is a Python script with a self-contained function that solves the problem an... |
Mbpp/124 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to get the angle of a complex number
assert math.isclose(angle_complex(0,1j), 1.5707963267948966, rel_tol=0.001)
```
### Answer:
Below is a Python script with a self-contained function that sol... |
Mbpp/125 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string
assert find_length("11000010001") == 6
```
### Answer:
Below is a Python sc... |
Mbpp/126 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to find the sum of common divisors of two given numbers
assert sum(10,15) == 6
```
### Answer:
Below is a Python script with a self-contained function that solves the problem and passes ... |
Mbpp/127 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to multiply two integers
assert multiply_int(10,20)==200
```
### Answer:
Below is a Python script with a self-contained function that solves the problem and passes corresponding tests:
```pytho... |
Mbpp/128 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find words that are longer than n characters from a given list of words
assert long_words(3,"python is a programming language")==['python','programming','language']
```
### Answer:
Below is ... |
Mbpp/129 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to calculate whether the matrix is a magic square
assert magic_square_test([[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]])==True
```
### Answer:
Below is a Python script with a... |
Mbpp/130 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find the item with maximum frequency in a given list
assert max_occurrences([2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,2,4,6,9,1,2])==2
```
### Answer:
Below is a Python script with a self-contained fun... |
Mbpp/131 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to reverse only the vowels of a given string (where y is not a vowel)
assert reverse_vowels("Python") == "Python"
```
### Answer:
Below is a Python script with a self-contained function ... |
Mbpp/132 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to convert a tuple to a string
assert tup_string(('e', 'x', 'e', 'r', 'c', 'i', 's', 'e', 's'))==("exercises")
```
### Answer:
Below is a Python script with a self-contained function that solve... |
Mbpp/133 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to calculate the sum of the negative numbers of a given list of numbers
assert sum_negativenum([2, 4, -6, -9, 11, -12, 14, -5, 17])==-32
```
### Answer:
Below is a Python script with a self-con... |
Mbpp/135 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find the nth hexagonal number
assert hexagonal_num(10) == 190
```
### Answer:
Below is a Python script with a self-contained function that solves the problem and passes corresponding tests:
... |
Mbpp/137 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find the ratio of zeroes to non-zeroes in an array of integers
assert math.isclose(zero_count([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8]), 0.181818, rel_tol=0.001)
```
### Answer:
Below is ... |
Mbpp/138 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to check whether the given number can be represented as sum of non-zero powers of 2 or not
assert is_Sum_Of_Powers_Of_Two(10) == True
```
### Answer:
Below is a Python script with a self... |
Mbpp/139 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find the circumference of a circle
assert math.isclose(circle_circumference(10), 62.830000000000005, rel_tol=0.001)
```
### Answer:
Below is a Python script with a self-contained function th... |
Mbpp/140 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to flatten the list of lists into a single set of numbers
assert set(extract_singly([(3, 4, 5), (4, 5, 7), (1, 4)])) == set([3, 4, 5, 7, 1])
```
### Answer:
Below is a Python script with a self... |
Mbpp/141 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to sort a list of elements
assert comb_sort([5, 15, 37, 25, 79]) == [5, 15, 25, 37, 79]
```
### Answer:
Below is a Python script with a self-contained function that solves the problem and passe... |
Mbpp/142 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to count number items that are identical in the same position of three given lists
assert count_samepair([1,2,3,4,5,6,7,8],[2,2,3,1,2,6,7,9],[2,1,3,1,2,6,7,9])==3
```
### Answer:
Below is a Pyt... |
Mbpp/145 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to find the maximum difference between any two elements in a given array
assert max_Abs_Diff((2,1,5,3)) == 4
```
### Answer:
Below is a Python script with a self-contained function that ... |
Mbpp/160 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function that returns integers x and y that satisfy ax + by = n as a tuple, or return None if no solution exists
assert find_solution(2, 3, 7) == (2, 1)
```
### Answer:
Below is a Python script with a s... |
Mbpp/161 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to remove all elements from a given list present in another list
assert remove_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 4, 6, 8]) == [1, 3, 5, 7, 9, 10]
```
### Answer:
Below is a Python s... |
Mbpp/162 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to calculate the sum (n - 2*i) from i=0 to n // 2, for instance n + (n-2) + (n-4)
assert sum_series(6) == 12
```
### Answer:
Below is a Python script with a self-contained function that solves ... |
Mbpp/165 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to count the number of characters in a string that occur at the same position in the string as in the English alphabet (case insensitive)
assert count_char_position("xbcefg") == 2
```
### Answe... |
Mbpp/166 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function that counts the number of pairs of integers in a list that xor to an even number
assert find_even_pair([5, 4, 7, 2, 1]) == 4
```
### Answer:
Below is a Python script with a self-contained funct... |
Mbpp/167 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to find the smallest power of 2 greater than or equal to n
assert next_power_of_2(0) == 1
```
### Answer:
Below is a Python script with a self-contained function that solves the problem ... |
Mbpp/168 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to count the number of occurrences of a number in a given list
assert frequency([1,2,3], 4) == 0
```
### Answer:
Below is a Python script with a self-contained function that solves the problem ... |
Mbpp/170 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find the sum of numbers in a list within a range specified by two indices
assert sum_range_list([2,1,5,6,8,3,4,9,10,11,8,12], 8, 10) == 29
```
### Answer:
Below is a Python script with a sel... |
Mbpp/171 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to find the perimeter of a regular pentagon from the length of its sides
assert perimeter_pentagon(5) == 25
```
### Answer:
Below is a Python script with a self-contained function that solves t... |
Mbpp/172 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to count the number of occurence of the string 'std' in a given string
assert count_occurance("letstdlenstdporstd") == 3
```
### Answer:
Below is a Python script with a self-contained function ... |
Mbpp/222 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function to check if all the elements in tuple have same data type or not
assert check_type((5, 6, 7, 3, 5, 6) ) == True
```
### Answer:
Below is a Python script with a self-contained function that solv... |
Mbpp/223 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array
assert is_majority([1, 2, 3, 3, 3, 3, 10], 7, 3) =... |
Mbpp/224 | Please provide a self-contained Python script that solves the following problem in a markdown code block:
```
Write a python function to count the number of set bits (binary digits with value 1) in a given number
assert count_Set_Bits(2) == 1
```
### Answer:
Below is a Python script with a self-contained function that ... |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 3