INSTRUCTION
stringlengths
85
1.13k
RESPONSE
stringlengths
98
2.66k
SOURCE
stringclasses
2 values
Write a unit test case for a Python function with description: Write a function to sort the given list.
def check(candidate): assert heap_sort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] assert heap_sort([25, 35, 22, 85, 14, 65, 75, 25, 58])==[14, 22, 25, 25, 35, 58, 65, 75, 85] assert heap_sort( [7, 1, 9, 5])==[1,5,7,9]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to check whether the given amount has no profit and no loss
def check(candidate): assert noprofit_noloss(1500,1200)==False assert noprofit_noloss(100,100)==True assert noprofit_noloss(2000,5000)==False
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to calculate the wind chill index rounded to the next integer given the wind velocity in km/h and a temperature in celsius.
def check(candidate): assert wind_chill(120,35)==40 assert wind_chill(40,20)==19 assert wind_chill(10,8)==6
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to sum the length of the names of a given list of names after removing the names that start with a lowercase letter.
def check(candidate): assert sample_nam(['sally', 'Dylan', 'rebecca', 'Diana', 'Joanne', 'keith'])==16 assert sample_nam(["php", "res", "Python", "abcd", "Java", "aaa"])==10 assert sample_nam(["abcd", "Python", "abba", "aba"])==6
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to remove the parenthesis and what is inbetween them from a string.
def check(candidate): assert remove_parenthesis(["python (chrome)"])==("python") assert remove_parenthesis(["string(.abc)"])==("string") assert remove_parenthesis(["alpha(num)"])==("alpha")
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find the nth nonagonal number.
def check(candidate): assert is_nonagonal(10) == 325 assert is_nonagonal(15) == 750 assert is_nonagonal(18) == 1089
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function that checks if a strings contains 'z', except at the start and end of the word.
def check(candidate): assert text_match_wordz_middle("pythonzabc.")==True assert text_match_wordz_middle("zxyabc.")==False assert text_match_wordz_middle(" lang .")==False
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to reverse an array upto a given position.
def check(candidate): assert reverse_Array_Upto_K([1, 2, 3, 4, 5, 6],4) == [4, 3, 2, 1, 5, 6] assert reverse_Array_Upto_K([4, 5, 6, 7], 2) == [5, 4, 6, 7] assert reverse_Array_Upto_K([9, 8, 7, 6, 5],3) == [7, 8, 9, 6, 5]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to add a dictionary to the tuple. The output should be a tuple.
def check(candidate): assert add_dict_to_tuple((4, 5, 6), {"MSAM" : 1, "is" : 2, "best" : 3} ) == (4, 5, 6, {'MSAM': 1, 'is': 2, 'best': 3}) assert add_dict_to_tuple((1, 2, 3), {"UTS" : 2, "is" : 3, "Worst" : 4} ) == (1, 2, 3, {'UTS': 2, 'is': 3, 'Worst': 4}) assert add_dict_to_tuple((8, 9, 10), {"POS" : 3, "is" : 4, "Okay" : 5} ) == (8, 9, 10, {'POS': 3, 'is': 4, 'Okay': 5})
mbpp_sanitized
Write a unit test case for a Python function with description: Given a square matrix of size N*N given as a list of lists, where each cell is associated with a specific cost. A path is defined as a specific sequence of cells that starts from the top-left cell move only right or down and ends on bottom right cell. We want to find a path with the maximum average over all existing paths. Average is computed as total cost divided by the number of cells visited in the path.
def check(candidate): assert maxAverageOfPath([[1, 2, 3], [6, 5, 4], [7, 3, 9]]) == 5.2 assert maxAverageOfPath([[2, 3, 4], [7, 6, 5], [8, 4, 10]]) == 6.2 assert maxAverageOfPath([[3, 4, 5], [8, 7, 6], [9, 5, 11]]) == 7.2 assert maxAverageOfPath([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 5.8
mbpp_sanitized
Write a unit test case for a Python function with description: The input is given as - a dictionary with a student name as a key and a tuple of float (student_height, student_weight) as a value, - minimal height, - minimal weight. Write a function to filter students that have height and weight above the minimum.
def check(candidate): assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},6.0,70)=={'Cierra Vega': (6.2, 70)} assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},5.9,67)=={'Cierra Vega': (6.2, 70),'Kierra Gentry': (6.0, 68)} assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},5.7,64)=={'Cierra Vega': (6.2, 70),'Alden Cantrell': (5.9, 65),'Kierra Gentry': (6.0, 68),'Pierre Cox': (5.8, 66)}
mbpp_sanitized
Write a unit test case for a Python function with description: The input is defined as two lists of the same length. Write a function to count indices where the lists have the same values.
def check(candidate): assert count_same_pair([1, 2, 3, 4, 5, 6, 7, 8],[2, 2, 3, 1, 2, 6, 7, 9])==4 assert count_same_pair([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8],[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==11 assert count_same_pair([2, 4, -6, -9, 11, -12, 14, -5, 17],[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==1 assert count_same_pair([0, 1, 1, 2],[0, 1, 2, 2])==3
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function that takes base and power as arguments and calculate the sum of all digits of the base to the specified power.
def check(candidate): assert power_base_sum(2,100)==115 assert power_base_sum(8,10)==37 assert power_base_sum(8,15)==62 assert power_base_sum(3,3)==9
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to extract values between quotation marks " " of the given string.
def check(candidate): assert extract_quotation('Cortex "A53" Based "multi" tasking "Processor"') == ['A53', 'multi', 'Processor'] assert extract_quotation('Cast your "favorite" entertainment "apps"') == ['favorite', 'apps'] assert extract_quotation('Watch content "4k Ultra HD" resolution with "HDR 10" Support') == ['4k Ultra HD', 'HDR 10'] assert extract_quotation("Watch content '4k Ultra HD' resolution with 'HDR 10' Support") == []
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function that takes as input a tuple of numbers (t_1,...,t_{N+1}) and returns a tuple of length N where the i-th element of the tuple is equal to t_i * t_{i+1}.
def check(candidate): assert multiply_elements((1, 5, 7, 8, 10)) == (5, 35, 56, 80) assert multiply_elements((2, 4, 5, 6, 7)) == (8, 20, 30, 42) assert multiply_elements((12, 13, 14, 9, 15)) == (156, 182, 126, 135) assert multiply_elements((12,)) == ()
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function takes as input two lists [a_1,...,a_n], [b_1,...,b_n] and returns [a_1+b_1,...,a_n+b_n].
def check(candidate): assert sum_list([10,20,30],[15,25,35])==[25,45,65] assert sum_list([1,2,3],[5,6,7])==[6,8,10] assert sum_list([15,20,30],[15,45,75])==[30,65,105]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to remove consecutive duplicates of a given list.
def check(candidate): assert consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4 ])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4] assert consecutive_duplicates([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10])==[10, 15, 19, 18, 17, 26, 17, 18, 10] assert consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd'])==['a', 'b', 'c', 'd'] assert consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd', 'a', 'a'])==['a', 'b', 'c', 'd', 'a']
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find the lateral surface area of a cone given radius r and the height h.
def check(candidate): assert lateralsurface_cone(5,12)==204.20352248333654 assert lateralsurface_cone(10,15)==566.3586699569488 assert lateralsurface_cone(19,17)==1521.8090132193388
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to replace all occurrences of spaces, commas, or dots with a colon.
def check(candidate): assert replace_specialchar('Python language, Programming language.')==('Python:language::Programming:language:') assert replace_specialchar('a b c,d e f')==('a:b:c:d:e:f') assert replace_specialchar('ram reshma,ram rahim')==('ram:reshma:ram:rahim')
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find the index of the first occurrence of a given number in a sorted array.
def check(candidate): assert find_first_occurrence([2, 5, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 1 assert find_first_occurrence([2, 3, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 2 assert find_first_occurrence([2, 4, 1, 5, 6, 6, 8, 9, 9, 9], 6) == 4
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find sum of products of all possible sublists of a given list. https://www.geeksforgeeks.org/sum-of-products-of-all-possible-subarrays/
def check(candidate): assert sum_Of_Subarray_Prod([1,2,3]) == 20 assert sum_Of_Subarray_Prod([1,2]) == 5 assert sum_Of_Subarray_Prod([1,2,3,4]) == 84
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to toggle bits of the number except the first and the last bit. https://www.geeksforgeeks.org/toggle-bits-number-expect-first-last-bits/
def check(candidate): assert toggle_middle_bits(9) == 15 assert toggle_middle_bits(10) == 12 assert toggle_middle_bits(11) == 13 assert toggle_middle_bits(0b1000001) == 0b1111111 assert toggle_middle_bits(0b1001101) == 0b1110011
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to locate the left insertion point for a specified value in sorted order. https://www.w3resource.com/python-exercises/data-structures-and-algorithms/python-data-structure-exercise-24.php
def check(candidate): assert left_insertion([1,2,4,5],6)==4 assert left_insertion([1,2,4,5],3)==2 assert left_insertion([1,2,4,5],7)==4
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to check whether the given string is starting with a vowel or not using regex.
def check(candidate): assert check_str("annie") assert not check_str("dawood") assert check_str("Else")
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to calculate the geometric sum of n-1. https://www.w3resource.com/python-exercises/data-structures-and-algorithms/python-recursion-exercise-9.php
def check(candidate): assert geometric_sum(7) == 1.9921875 assert geometric_sum(4) == 1.9375 assert geometric_sum(8) == 1.99609375
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find the index of smallest triangular number with n digits. https://www.geeksforgeeks.org/index-of-smallest-triangular-number-with-n-digits/
def check(candidate): assert find_Index(2) == 4 assert find_Index(3) == 14 assert find_Index(4) == 45
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to convert the given tuple to a key-value dictionary using adjacent elements. https://www.geeksforgeeks.org/python-convert-tuple-to-adjacent-pair-dictionary/
def check(candidate): assert tuple_to_dict((1, 5, 7, 10, 13, 5)) == {1: 5, 7: 10, 13: 5} assert tuple_to_dict((1, 2, 3, 4, 5, 6)) == {1: 2, 3: 4, 5: 6} assert tuple_to_dict((7, 8, 9, 10, 11, 12)) == {7: 8, 9: 10, 11: 12}
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to check whether all the characters are same or not.
def check(candidate): assert all_Characters_Same("python") == False assert all_Characters_Same("aaa") == True assert all_Characters_Same("data") == False
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to caluclate the area of a tetrahedron.
def check(candidate): assert area_tetrahedron(3)==15.588457268119894 assert area_tetrahedron(20)==692.8203230275509 assert area_tetrahedron(10)==173.20508075688772
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to rotate a given list by specified number of items to the right direction. https://www.geeksforgeeks.org/python-program-right-rotate-list-n/
def check(candidate): assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],3)==[8, 9, 10, 1, 2, 3, 4, 5, 6, 7] assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],2)==[9, 10, 1, 2, 3, 4, 5, 6, 7, 8] assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],5)==[6, 7, 8, 9, 10, 1, 2, 3, 4, 5]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to check if the given tuple has any none value or not.
def check(candidate): assert check_none((10, 4, 5, 6, None)) == True assert check_none((7, 8, 9, 11, 14)) == False assert check_none((1, 2, 3, 4, None)) == True
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find numbers within a given range from startnum ti endnum where every number is divisible by every digit it contains. https://www.w3resource.com/python-exercises/lambda/python-lambda-exercise-24.php
def check(candidate): assert divisible_by_digits(1,22)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22] assert divisible_by_digits(1,15)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15] assert divisible_by_digits(20,25)==[22, 24]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find area of a sector. The function takes the radius and angle as inputs. Function should return None if the angle is larger than 360 degrees.
def check(candidate): assert sector_area(4,45)==6.283185307179586 assert sector_area(9,45)==31.808625617596654 assert sector_area(9,361)==None
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find the longest common subsequence for the given three string sequence. https://www.geeksforgeeks.org/lcs-longest-common-subsequence-three-strings/
def check(candidate): assert lcs_of_three('AGGT12', '12TXAYB', '12XBA') == 2 assert lcs_of_three('Reels', 'Reelsfor', 'ReelsforReels') == 5 assert lcs_of_three('abcd1e2', 'bc12ea', 'bd1ea') == 3
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to put spaces between words starting with capital letters in a given string.
def check(candidate): assert capital_words_spaces("Python") == 'Python' assert capital_words_spaces("PythonProgrammingExamples") == 'Python Programming Examples' assert capital_words_spaces("GetReadyToBeCodingFreak") == 'Get Ready To Be Coding Freak'
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to sort a given list of strings of numbers numerically. https://www.geeksforgeeks.org/python-sort-numeric-strings-in-a-list/
def check(candidate): assert sort_numeric_strings( ['4','12','45','7','0','100','200','-12','-500'])==[-500, -12, 0, 4, 7, 12, 45, 100, 200] assert sort_numeric_strings(['2','3','8','4','7','9','8','2','6','5','1','6','1','2','3','4','6','9','1','2'])==[1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8, 9, 9] assert sort_numeric_strings(['1','3','5','7','1', '3','13', '15', '17','5', '7 ','9','1', '11'])==[1, 1, 1, 3, 3, 5, 5, 7, 7, 9, 11, 13, 15, 17]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to add the given tuple to the given list.
def check(candidate): assert add_tuple([5, 6, 7], (9, 10)) == [5, 6, 7, 9, 10] assert add_tuple([6, 7, 8], (10, 11)) == [6, 7, 8, 10, 11] assert add_tuple([7, 8, 9], (11, 12)) == [7, 8, 9, 11, 12]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to check if the given array represents min heap or not. https://www.geeksforgeeks.org/how-to-check-if-a-given-array-represents-a-binary-heap/
def check(candidate): assert check_min_heap([1, 2, 3, 4, 5, 6]) == True assert check_min_heap([2, 3, 4, 5, 10, 15]) == True assert check_min_heap([2, 10, 4, 5, 3, 15]) == False
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find the nth jacobsthal number. https://www.geeksforgeeks.org/jacobsthal-and-jacobsthal-lucas-numbers/ 0, 1, 1, 3, 5, 11, 21, 43, 85, 171, 341, 683, 1365, 2731, ...
def check(candidate): assert jacobsthal_num(5) == 11 assert jacobsthal_num(2) == 1 assert jacobsthal_num(4) == 5 assert jacobsthal_num(13) == 2731
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find minimum k records from tuple list. https://www.geeksforgeeks.org/python-find-minimum-k-records-from-tuple-list/ - in this case a verbatim copy of test cases
def check(candidate): assert min_k([('Manjeet', 10), ('Akshat', 4), ('Akash', 2), ('Nikhil', 8)], 2) == [('Akash', 2), ('Akshat', 4)] assert min_k([('Sanjeev', 11), ('Angat', 5), ('Akash', 3), ('Nepin', 9)], 3) == [('Akash', 3), ('Angat', 5), ('Nepin', 9)] assert min_k([('tanmay', 14), ('Amer', 11), ('Ayesha', 9), ('SKD', 16)], 1) == [('Ayesha', 9)]
mbpp_sanitized
Write a unit test case for a Python function with description: We say that an element is common for lists l1, l2, l3 if it appears in all three lists under the same index. Write a function to find common elements from three lists. The function should return a list.
def check(candidate): assert extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[1, 7] assert extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 6, 5],[0, 1, 2, 3, 4, 6, 7])==[1, 6] assert extract_index_list([1, 1, 3, 4, 6, 5, 6],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[1, 5] assert extract_index_list([1, 2, 3, 4, 6, 6, 6],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find the second smallest number in a list.
def check(candidate): assert second_smallest([1, 2, -8, -2, 0, -2])==-2 assert second_smallest([1, 1, -0.5, 0, 2, -2, -2])==-0.5 assert second_smallest([2,2])==None assert second_smallest([2,2,2])==None
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function that matches a string that has an 'a' followed by one or more 'b's. https://www.w3resource.com/python-exercises/re/python-re-exercise-3.php
def check(candidate): assert text_match_zero_one("ac")==False assert text_match_zero_one("dc")==False assert text_match_zero_one("abbbba")==True assert text_match_zero_one("dsabbbba")==True assert text_match_zero_one("asbbbba")==False assert text_match_zero_one("abaaa")==True
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to count the pairs of reverse strings in the given string list. https://www.geeksforgeeks.org/python-program-to-count-the-pairs-of-reverse-strings/
def check(candidate): assert count_reverse_pairs(["julia", "best", "tseb", "for", "ailuj"])== 2 assert count_reverse_pairs(["geeks", "best", "for", "skeeg"]) == 1 assert count_reverse_pairs(["makes", "best", "sekam", "for", "rof"]) == 2
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to count lists within a list. The function should return a dictionary where every list is converted to a tuple and the value of such tuple is the number of its occurencies in the original list.
def check(candidate): assert unique_sublists([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]] )=={(1, 3): 2, (5, 7): 2, (13, 15, 17): 1, (9, 11): 1} assert unique_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])=={('green', 'orange'): 2, ('black',): 1, ('white',): 1} assert unique_sublists([[10, 20, 30, 40], [60, 70, 50, 50], [90, 100, 200]])=={(10, 20, 30, 40): 1, (60, 70, 50, 50): 1, (90, 100, 200): 1} assert unique_sublists([['john']])=={('john',): 1}
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to check whether a given string is a decimal number with a precision of 2.
def check(candidate): assert is_decimal('123.11')==True assert is_decimal('e666.86')==False assert is_decimal('3.124587')==False assert is_decimal('1.11')==True assert is_decimal('1.1.11')==False
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to check whether a list of numbers contains only one distinct element or not.
def check(candidate): assert unique_Element([1,1,1]) == True assert unique_Element([1,2,1,2]) == False assert unique_Element([1,2,3,4,5]) == False
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to check whether the given month number contains 30 days or not. Months are given as number from 1 to 12.
def check(candidate): assert check_monthnumber_number(6)==True assert check_monthnumber_number(2)==False assert check_monthnumber_number(12)==False
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find the minimum difference between any two elements in a given array. https://www.geeksforgeeks.org/find-minimum-difference-pair/
def check(candidate): assert find_min_diff((1,5,3,19,18,25),6) == 1 assert find_min_diff((4,3,2,6),4) == 1 assert find_min_diff((30,5,20,9),4) == 4
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to count number of digits in a given string.
def check(candidate): assert number_ctr('program2bedone') == 1 assert number_ctr('3wonders') == 1 assert number_ctr('123') == 3 assert number_ctr('3wond-1ers2') == 3
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find nth polite number. geeksforgeeks.org/n-th-polite-number/
def check(candidate): assert is_polite(7) == 11 assert is_polite(4) == 7 assert is_polite(9) == 13
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to return a list of all pairs of consecutive items in a given list.
def check(candidate): assert pair_wise([1,1,2,3,3,4,4,5])==[(1, 1), (1, 2), (2, 3), (3, 3), (3, 4), (4, 4), (4, 5)] assert pair_wise([1,5,7,9,10])==[(1, 5), (5, 7), (7, 9), (9, 10)] assert pair_wise([5,1,9,7,10])==[(5, 1), (1, 9), (9, 7), (7, 10)] assert pair_wise([1,2,3,4,5,6,7,8,9,10])==[(1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), (8, 9), (9, 10)]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to count the number of pairs whose sum is equal to ‘sum’. The funtion gets as input a list of numbers and the sum,
def check(candidate): assert get_pairs_count([1,1,1,1],2) == 6 assert get_pairs_count([1,5,7,-1,5],6) == 3 assert get_pairs_count([1,-2,3],1) == 1 assert get_pairs_count([-1,-2,3],-3) == 1
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to get the difference between two lists.
def check(candidate): assert (Diff([10, 15, 20, 25, 30, 35, 40], [25, 40, 35])) == [10, 20, 30, 15] assert (Diff([1,2,3,4,5], [6,7,1])) == [2,3,4,5,6,7] assert (Diff([1,2,3], [6,7,1])) == [2,3,6,7]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find the sum of fourth power of first n odd natural numbers.
def check(candidate): assert odd_num_sum(2) == 82 assert odd_num_sum(3) == 707 assert odd_num_sum(4) == 3108
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to check if the given expression is balanced or not. https://www.geeksforgeeks.org/check-for-balanced-parentheses-in-an-expression/
def check(candidate): assert check_expression("{()}[{}]") == True assert check_expression("{()}[{]") == False assert check_expression("{()}[{}][]({})") == True
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to remove all the words with k length in the given string.
def check(candidate): assert remove_length('The person is most value tet', 3) == 'person is most value' assert remove_length('If you told me about this ok', 4) == 'If you me about ok' assert remove_length('Forces of darkeness is come into the play', 4) == 'Forces of darkeness is the'
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find the occurrence and position of the substrings within a string. Return None if there is no match.
def check(candidate): assert occurance_substring('python programming, python language','python')==('python', 0, 6) assert occurance_substring('python programming,programming language','programming')==('programming', 7, 18) assert occurance_substring('python programming,programming language','language')==('language', 31, 39) assert occurance_substring('c++ programming, c++ language','python')==None
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to check whether every odd index contains odd numbers of a given list.
def check(candidate): assert odd_position([2,1,4,3,6,7,6,3]) == True assert odd_position([4,1,2]) == True assert odd_position([1,2,3]) == False
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to count those characters which have vowels as their neighbors in the given string.
def check(candidate): assert count_vowels('bestinstareels') == 7 assert count_vowels('partofthejourneyistheend') == 12 assert count_vowels('amazonprime') == 5
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find the sum of non-repeated elements in a given list.
def check(candidate): assert find_sum([1,2,3,1,1,4,5,6]) == 21 assert find_sum([1,10,9,4,2,10,10,45,4]) == 71 assert find_sum([12,10,9,45,2,10,10,45,10]) == 78
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to pack consecutive duplicates of a given list elements into sublists.
def check(candidate): assert pack_consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4])==[[0, 0], [1], [2], [3], [4, 4], [5], [6, 6, 6], [7], [8], [9], [4, 4]] assert pack_consecutive_duplicates([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10])==[[10, 10], [15], [19], [18, 18], [17], [26, 26], [17], [18], [10]] assert pack_consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd'])==[['a', 'a'], ['b'], ['c'], ['d', 'd']]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to count the number of lists within a list. The function should return a dictionary, where every list is turned to a tuple, and the value of the tuple is the number of its occurrences.
def check(candidate): assert unique_sublists([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]])=={(1, 3): 2, (5, 7): 2, (13, 15, 17): 1, (9, 11): 1} assert unique_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])=={('green', 'orange'): 2, ('black',): 1, ('white',): 1} assert unique_sublists([[1, 2], [3, 4], [4, 5], [6, 7]])=={(1, 2): 1, (3, 4): 1, (4, 5): 1, (6, 7): 1}
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find the combinations of sums with tuples in the given tuple list. https://www.geeksforgeeks.org/python-combinations-of-sum-with-tuples-in-tuple-list/
def check(candidate): assert find_combinations([(2, 4), (6, 7), (5, 1), (6, 10)]) == [(8, 11), (7, 5), (8, 14), (11, 8), (12, 17), (11, 11)] assert find_combinations([(3, 5), (7, 8), (6, 2), (7, 11)]) == [(10, 13), (9, 7), (10, 16), (13, 10), (14, 19), (13, 13)] assert find_combinations([(4, 6), (8, 9), (7, 3), (8, 12)]) == [(12, 15), (11, 9), (12, 18), (15, 12), (16, 21), (15, 15)]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to check whether the count of divisors is even. https://www.w3resource.com/python-exercises/basic/python-basic-1-exercise-24.php
def check(candidate): assert count_divisors(10) assert not count_divisors(100) assert count_divisors(125)
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find the sum of all odd length subarrays. https://www.geeksforgeeks.org/sum-of-all-odd-length-subarrays/
def check(candidate): assert odd_length_sum([1,2,4]) == 14 assert odd_length_sum([1,2,1,2]) == 15 assert odd_length_sum([1,7]) == 8
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to convert rgb color to hsv color. https://www.geeksforgeeks.org/program-change-rgb-color-model-hsv-color-model/
def check(candidate): assert rgb_to_hsv(255, 255, 255)==(0, 0.0, 100.0) assert rgb_to_hsv(0, 215, 0)==(120.0, 100.0, 84.31372549019608) assert rgb_to_hsv(10, 215, 110)==(149.26829268292684, 95.34883720930233, 84.31372549019608)
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find the product of first even and odd number of a given list.
def check(candidate): assert mul_even_odd([1,3,5,7,4,1,6,8])==4 assert mul_even_odd([1,2,3,4,5,6,7,8,9,10])==2 assert mul_even_odd([1,5,7,9,10])==10
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to convert tuple string to integer tuple.
def check(candidate): assert tuple_str_int("(7, 8, 9)") == (7, 8, 9) assert tuple_str_int("(1, 2, 3)") == (1, 2, 3) assert tuple_str_int("(4, 5, 6)") == (4, 5, 6) assert tuple_str_int("(7, 81, 19)") == (7, 81, 19)
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to locate the right insertion point for a specified value in sorted order.
def check(candidate): assert right_insertion([1,2,4,5],6)==4 assert right_insertion([1,2,4,5],3)==2 assert right_insertion([1,2,4,5],7)==4
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function that matches a string that has an a followed by three 'b'.
def check(candidate): assert not text_match_three("ac") assert not text_match_three("dc") assert text_match_three("abbbba") assert text_match_three("caacabbbba")
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to create a new tuple from the given string and list.
def check(candidate): assert new_tuple(["WEB", "is"], "best") == ('WEB', 'is', 'best') assert new_tuple(["We", "are"], "Developers") == ('We', 'are', 'Developers') assert new_tuple(["Part", "is"], "Wrong") == ('Part', 'is', 'Wrong')
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to check whether every even index contains even numbers of a given list.
def check(candidate): assert even_position([3,2,1]) == False assert even_position([1,2,3]) == False assert even_position([2,1,4]) == True
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to remove tuples from the given tuple.
def check(candidate): assert remove_nested((1, 5, 7, (4, 6), 10)) == (1, 5, 7, 10) assert remove_nested((2, 6, 8, (5, 7), 11)) == (2, 6, 8, 11) assert remove_nested((3, 7, 9, (6, 8), 12)) == (3, 7, 9, 12) assert remove_nested((3, 7, 9, (6, 8), (5,12), 12)) == (3, 7, 9, 12)
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to count the number of lists in a given number of lists.
def check(candidate): assert count_list([[1, 3], [5, 7], [9, 11], [13, 15, 17]]) == 4 assert count_list([[1,2],[2,3],[4,5]]) == 3 assert count_list([[1,0],[2,0]]) == 2
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find the last position of an element in a sorted array.
def check(candidate): assert last([1,2,3],1) == 0 assert last([1,1,1,2,3,4],1) == 2 assert last([2,3,2,3,6,8,9],3) == 3
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function that matches a string that has an 'a' followed by anything, ending in 'b'.
def check(candidate): assert text_starta_endb("aabbbb") assert not text_starta_endb("aabAbbbc") assert not text_starta_endb("accddbbjjj")
mbpp_sanitized
Write a unit test case for a Python function with description: Write function to find the sum of all items in the given dictionary.
def check(candidate): assert return_sum({'a': 100, 'b':200, 'c':300}) == 600 assert return_sum({'a': 25, 'b':18, 'c':45}) == 88 assert return_sum({'a': 36, 'b':39, 'c':49}) == 124
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find the sum of all odd natural numbers within the range l and r.
def check(candidate): assert sum_in_range(2,5) == 8 assert sum_in_range(5,7) == 12 assert sum_in_range(7,13) == 40
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find the sum of an array.
def check(candidate): assert _sum([1, 2, 3]) == 6 assert _sum([15, 12, 13, 10]) == 50 assert _sum([0, 1, 2]) == 3
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to that rotate left bits by d bits a given number. We assume that the number is 32 bit.
def check(candidate): assert left_rotate(16,2) == 64 assert left_rotate(10,2) == 40 assert left_rotate(99,3) == 792 assert left_rotate(99,3) == 792 assert left_rotate(0b0001,3) == 0b1000 assert left_rotate(0b0101,3) == 0b101000 assert left_rotate(0b11101,3) == 0b11101000
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to remove all whitespaces from a string.
def check(candidate): assert remove_all_spaces('python program')==('pythonprogram') assert remove_all_spaces('python programming language')==('pythonprogramminglanguage') assert remove_all_spaces('python program')==('pythonprogram') assert remove_all_spaces(' python program')=='pythonprogram'
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to count the number of equal numbers from three given integers.
def check(candidate): assert test_three_equal(1,1,1) == 3 assert test_three_equal(-1,-2,-3) == 0 assert test_three_equal(1,2,2) == 2
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to count the number of rotations required to generate a sorted array. https://www.geeksforgeeks.org/count-of-rotations-required-to-generate-a-sorted-array/
def check(candidate): assert count_rotation([3,2,1]) == 1 assert count_rotation([4,5,1,2,3]) == 2 assert count_rotation([7,8,9,1,2,3]) == 3 assert count_rotation([1,2,3]) == 0 assert count_rotation([1,3,2]) == 2
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to check whether the given number is a perfect square or not. https://www.geeksforgeeks.org/check-if-given-number-is-perfect-square-in-cpp/
def check(candidate): assert not is_perfect_square(10) assert is_perfect_square(36) assert not is_perfect_square(14) assert is_perfect_square(14*14) assert not is_perfect_square(125) assert is_perfect_square(125*125)
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to check whether the product of numbers in a list is even or not.
def check(candidate): assert is_product_even([1,2,3]) assert is_product_even([1,2,1,4]) assert not is_product_even([1,1])
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function that returns the list in a list of lists whose sum of elements is the highest.
def check(candidate): assert max_sum_list([[1,2,3], [4,5,6], [10,11,12], [7,8,9]])==[10, 11, 12] assert max_sum_list([[3,2,1], [6,5,4], [12,11,10]])==[12,11,10] assert max_sum_list([[2,3,1]])==[2,3,1]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find maximum run of uppercase characters in the given string.
def check(candidate): assert max_run_uppercase('GeMKSForGERksISBESt') == 5 assert max_run_uppercase('PrECIOusMOVemENTSYT') == 6 assert max_run_uppercase('GooGLEFluTTER') == 4
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find the first odd number in a given list of numbers.
def check(candidate): assert first_odd([1,3,5]) == 1 assert first_odd([2,4,1,3]) == 1 assert first_odd ([8,9,1]) == 9
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to check if the given tuples contain the k or not.
def check(candidate): assert check_K((10, 4, 5, 6, 8), 6) == True assert check_K((1, 2, 3, 4, 5, 6), 7) == False assert check_K((7, 8, 9, 44, 11, 12), 11) == True
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to check if each element of second tuple is smaller than its corresponding element in the first tuple.
def check(candidate): assert check_smaller((1, 2, 3), (2, 3, 4)) == False assert check_smaller((4, 5, 6), (3, 4, 5)) == True assert check_smaller((11, 12, 13), (10, 11, 12)) == True
mbpp_sanitized