id string | task_id int64 | prompt string | entry_point string | test_imports list | test_list list | test string |
|---|---|---|---|---|---|---|
Mbpp/641 | 641 | Write a function to find the nth nonagonal number. | is_nonagonal | [] | [
"assert is_nonagonal(10) == 325",
"assert is_nonagonal(15) == 750",
"assert is_nonagonal(18) == 1089"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/643 | 643 | Write a function that checks if a strings contains 'z', except at the start and end of the word. | text_match_wordz_middle | [] | [
"assert text_match_wordz_middle(\"pythonzabc.\")==True",
"assert text_match_wordz_middle(\"zxyabc.\")==False",
"assert text_match_wordz_middle(\" lang .\")==False"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/644 | 644 | Write a python function to reverse an array upto a given position. | reverse_Array_Upto_K | [] | [
"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]"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/720 | 720 | Write a function to add a dictionary to the tuple. The output should be a tuple. | add_dict_to_tuple | [] | [
"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... | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/721 | 721 | 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 pa... | maxAverageOfPath | [] | [
"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"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/722 | 722 | 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. | filter_data | [] | [
"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 ... | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/723 | 723 | The input is defined as two lists of the same length. Write a function to count indices where the lists have the same values. | count_same_pair | [] | [
"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",
"... | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/724 | 724 | Write a function that takes base and power as arguments and calculate the sum of all digits of the base to the specified power. | power_base_sum | [] | [
"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"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/725 | 725 | Write a function to extract values between quotation marks " " of the given string. | extract_quotation | [] | [
"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') ... | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/726 | 726 | 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}. | multiply_elements | [] | [
"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,)) == ()"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/728 | 728 | 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]. | sum_list | [] | [
"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]"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/730 | 730 | Write a function to remove consecutive duplicates of a given list. | consecutive_duplicates | [] | [
"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... | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/731 | 731 | Write a function to find the lateral surface area of a cone given radius r and the height h. | lateralsurface_cone | [] | [
"assert lateralsurface_cone(5,12)==204.20352248333654",
"assert lateralsurface_cone(10,15)==566.3586699569488",
"assert lateralsurface_cone(19,17)==1521.8090132193388"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/732 | 732 | Write a function to replace all occurrences of spaces, commas, or dots with a colon. | replace_specialchar | [] | [
"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')"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/733 | 733 | Write a function to find the index of the first occurrence of a given number in a sorted array. | find_first_occurrence | [] | [
"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"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/734 | 734 | 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/ | sum_Of_Subarray_Prod | [] | [
"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"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/735 | 735 | 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/ | toggle_middle_bits | [] | [
"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"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/736 | 736 | 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 | left_insertion | [] | [
"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"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/737 | 737 | Write a function to check whether the given string is starting with a vowel or not using regex. | check_str | [] | [
"assert check_str(\"annie\")",
"assert not check_str(\"dawood\")",
"assert check_str(\"Else\")"
] | import numpy as np
from math import inf
def assertion(out, exp, atol):
if isinstance(out, bool):
exact_match = out == exp
else:
exact_match = exp == (out is not None)
inputs = [['annie'], ['dawood'], ['Else'], ['H3llo'], ['_Eelse'], ['Anna18'], ['__Danielle'], ['_aBbbb'], ['!Uuiouy'], ['1Abb'... |
Mbpp/739 | 739 | 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/ | find_Index | [] | [
"assert find_Index(2) == 4",
"assert find_Index(3) == 14",
"assert find_Index(4) == 45"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/740 | 740 | 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/ | tuple_to_dict | [] | [
"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}"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/741 | 741 | Write a python function to check whether all the characters are same or not. | all_Characters_Same | [] | [
"assert all_Characters_Same(\"python\") == False",
"assert all_Characters_Same(\"aaa\") == True",
"assert all_Characters_Same(\"data\") == False"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/742 | 742 | Write a function to caluclate the area of a tetrahedron. | area_tetrahedron | [] | [
"assert area_tetrahedron(3)==15.588457268119894",
"assert area_tetrahedron(20)==692.8203230275509",
"assert area_tetrahedron(10)==173.20508075688772"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/743 | 743 | 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/ | rotate_right | [] | [
"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]"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/744 | 744 | Write a function to check if the given tuple has any none value or not. | check_none | [] | [
"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"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/745 | 745 | 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 | divisible_by_digits | [] | [
"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]"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/748 | 748 | Write a function to put spaces between words starting with capital letters in a given string. | capital_words_spaces | [] | [
"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'"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/749 | 749 | Write a function to sort a given list of strings of numbers numerically. https://www.geeksforgeeks.org/python-sort-numeric-strings-in-a-list/ | sort_numeric_strings | [] | [
"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_n... | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/750 | 750 | Write a function to add the given tuple to the given list. | add_tuple | [] | [
"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]"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/751 | 751 | 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/ | check_min_heap_helper | [] | [
"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"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/752 | 752 | 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, ... | jacobsthal_num | [] | [
"assert jacobsthal_num(5) == 11",
"assert jacobsthal_num(2) == 1",
"assert jacobsthal_num(4) == 5",
"assert jacobsthal_num(13) == 2731"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/753 | 753 | 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 | min_k | [] | [
"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)... | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/754 | 754 | 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. | extract_index_list | [] | [
"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]",
... | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/755 | 755 | Write a function to find the second smallest number in a list. | second_smallest | [] | [
"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"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/757 | 757 | 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/ | count_reverse_pairs | [] | [
"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"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/758 | 758 | 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. | unique_sublists | [] | [
"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... | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/759 | 759 | Write a function to check whether a given string is a decimal number with a precision of 2. | is_decimal | [] | [
"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"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/760 | 760 | Write a python function to check whether a list of numbers contains only one distinct element or not. | unique_Element | [] | [
"assert unique_Element([1,1,1]) == True",
"assert unique_Element([1,2,1,2]) == False",
"assert unique_Element([1,2,3,4,5]) == False"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/762 | 762 | Write a function to check whether the given month number contains 30 days or not. Months are given as number from 1 to 12. | check_monthnumber_number | [] | [
"assert check_monthnumber_number(6)==True",
"assert check_monthnumber_number(2)==False",
"assert check_monthnumber_number(12)==False"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/763 | 763 | 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/ | find_min_diff | [] | [
"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"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/764 | 764 | Write a python function to count number of digits in a given string. | number_ctr | [] | [
"assert number_ctr('program2bedone') == 1",
"assert number_ctr('3wonders') == 1",
"assert number_ctr('123') == 3",
"assert number_ctr('3wond-1ers2') == 3"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/765 | 765 | Write a function to find nth polite number. geeksforgeeks.org/n-th-polite-number/ | is_polite | [] | [
"assert is_polite(7) == 11",
"assert is_polite(4) == 7",
"assert is_polite(9) == 13"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/766 | 766 | Write a function to return a list of all pairs of consecutive items in a given list. | pair_wise | [] | [
"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),... | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/767 | 767 | 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, | get_pairs_count | [] | [
"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"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/769 | 769 | Write a python function to get the difference between two lists. | Diff | [] | [
"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]"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/770 | 770 | Write a python function to find the sum of fourth power of first n odd natural numbers. | odd_num_sum | [] | [
"assert odd_num_sum(2) == 82",
"assert odd_num_sum(3) == 707",
"assert odd_num_sum(4) == 3108"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/771 | 771 | Write a function to check if the given expression is balanced or not. https://www.geeksforgeeks.org/check-for-balanced-parentheses-in-an-expression/ | check_expression | [] | [
"assert check_expression(\"{()}[{}]\") == True",
"assert check_expression(\"{()}[{]\") == False",
"assert check_expression(\"{()}[{}][]({})\") == True"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/772 | 772 | Write a function to remove all the words with k length in the given string. | remove_length | [] | [
"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'"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/773 | 773 | Write a function to find the occurrence and position of the substrings within a string. Return None if there is no match. | occurance_substring | [] | [
"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)",... | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/775 | 775 | Write a python function to check whether every odd index contains odd numbers of a given list. | odd_position | [] | [
"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"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/777 | 777 | Write a python function to find the sum of non-repeated elements in a given list. | find_sum | [] | [
"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"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/778 | 778 | Write a function to pack consecutive duplicates of a given list elements into sublists. | pack_consecutive_duplicates | [] | [
"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]]"... | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/780 | 780 | 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/ | find_combinations | [] | [
"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)]) == [... | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/781 | 781 | 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 | count_divisors | [] | [
"assert count_divisors(10)",
"assert not count_divisors(100)",
"assert count_divisors(125)"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/782 | 782 | Write a python function to find the sum of all odd length subarrays. https://www.geeksforgeeks.org/sum-of-all-odd-length-subarrays/ | odd_length_sum | [] | [
"assert odd_length_sum([1,2,4]) == 14",
"assert odd_length_sum([1,2,1,2]) == 15",
"assert odd_length_sum([1,7]) == 8"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/784 | 784 | Write a function to find the product of first even and odd number of a given list. | mul_even_odd | [] | [
"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"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/785 | 785 | Write a function to convert tuple string to integer tuple. | tuple_str_int | [] | [
"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)"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/786 | 786 | Write a function to locate the right insertion point for a specified value in sorted order. | right_insertion | [] | [
"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"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/787 | 787 | Write a function that matches a string that has an a followed by three 'b'. | text_match_three | [] | [
"assert not text_match_three(\"ac\")",
"assert not text_match_three(\"dc\")",
"assert text_match_three(\"abbbba\")",
"assert text_match_three(\"caacabbbba\")"
] | import numpy as np
from math import inf
def assertion(out, exp, atol):
if isinstance(out, bool):
exact_match = out == exp
else:
exact_match = exp == (out is not None)
inputs = [['ac'], ['dc'], ['abbbba'], ['caacabbbba'], [''], ['gHZZiSWmTL'], ['gHZZiSWmgHZZiSWmTLL'], ['gHZZiSWmgHZZiSWgmTLL'],... |
Mbpp/788 | 788 | Write a function to create a new tuple from the given string and list. | new_tuple | [] | [
"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')"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/790 | 790 | Write a python function to check whether every even index contains even numbers of a given list. | even_position | [] | [
"assert even_position([3,2,1]) == False",
"assert even_position([1,2,3]) == False",
"assert even_position([2,1,4]) == True"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/791 | 791 | Write a function to remove tuples from the given tuple. | remove_nested | [] | [
"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)"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/792 | 792 | Write a python function to count the number of lists in a given number of lists. | count_list | [] | [
"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"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/793 | 793 | Write a python function to find the last position of an element in a sorted array. | last | [] | [
"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"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/794 | 794 | Write a function that matches a string that has an 'a' followed by anything, ending in 'b'. | text_starta_endb | [] | [
"assert text_starta_endb(\"aabbbb\")",
"assert not text_starta_endb(\"aabAbbbc\")",
"assert not text_starta_endb(\"accddbbjjj\")"
] | import numpy as np
from math import inf
def assertion(out, exp, atol):
if isinstance(out, bool):
exact_match = out == exp
else:
exact_match = exp == (out is not None)
inputs = [['aabbbb'], ['aabAbbbc'], ['accddbbjjj'], [''], ['xyz123'], ['ab'], ['aabb'], ['xaabbyz123'], ['xaabbyz1323'], ['axy... |
Mbpp/796 | 796 | Write function to find the sum of all items in the given dictionary. | return_sum | [] | [
"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"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/797 | 797 | Write a python function to find the sum of all odd natural numbers within the range l and r. | sum_odd | [] | [
"assert sum_in_range(2,5) == 8",
"assert sum_in_range(5,7) == 12",
"assert sum_in_range(7,13) == 40"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/798 | 798 | Write a python function to find the sum of an array. | _sum | [] | [
"assert _sum([1, 2, 3]) == 6",
"assert _sum([15, 12, 13, 10]) == 50",
"assert _sum([0, 1, 2]) == 3"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/799 | 799 | Write a function to that rotate left bits by d bits a given number. We assume that the number is 32 bit. | left_rotate | [] | [
"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"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/800 | 800 | Write a function to remove all whitespaces from a string. | remove_all_spaces | [] | [
"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... | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/801 | 801 | Write a python function to count the number of equal numbers from three given integers. | test_three_equal | [] | [
"assert test_three_equal(1,1,1) == 3",
"assert test_three_equal(-1,-2,-3) == 0",
"assert test_three_equal(1,2,2) == 2"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/803 | 803 | 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/ | is_perfect_square | [] | [
"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)"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/804 | 804 | Write a function to check whether the product of numbers in a list is even or not. | is_product_even | [] | [
"assert is_product_even([1,2,3])",
"assert is_product_even([1,2,1,4])",
"assert not is_product_even([1,1])"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/805 | 805 | Write a function that returns the list in a list of lists whose sum of elements is the highest. | max_sum_list | [] | [
"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]"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/806 | 806 | Write a function to find maximum run of uppercase characters in the given string. | max_run_uppercase | [] | [
"assert max_run_uppercase('GeMKSForGERksISBESt') == 5",
"assert max_run_uppercase('PrECIOusMOVemENTSYT') == 6",
"assert max_run_uppercase('GooGLEFluTTER') == 4"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/807 | 807 | Write a python function to find the first odd number in a given list of numbers. | first_odd | [] | [
"assert first_odd([1,3,5]) == 1",
"assert first_odd([2,4,1,3]) == 1",
"assert first_odd ([8,9,1]) == 9"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/808 | 808 | Write a function to check if the given tuples contain the k or not. | check_K | [] | [
"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"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Mbpp/809 | 809 | Write a function to check if each element of second tuple is smaller than its corresponding element in the first tuple. | check_smaller | [] | [
"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"
] | import numpy as np
from math import inf
def is_floats(x) -> bool:
# check if it is float; List[float]; Tuple[float]
if isinstance(x, float):
return True
if isinstance(x, (list, tuple)):
return all(isinstance(i, float) for i in x)
if isinstance(x, np.ndarray):
return x.dtype == n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.