dataset_name
string
data_id
int64
src_lang
null
tgt_lang
string
task_name
string
doc_string
string
prefix
string
suffix
string
solution
string
demos
list
compare_func
string
test_cases
list
import_str
list
entry_func
string
type
dict
MBPP_sanitized
11
null
python
code_generation
def remove_Occ(s, ch): """ Write a python function to remove first and last occurrence of a given character from the string. """
def remove_Occ(s, ch): """ Write a python function to remove first and last occurrence of a given character from the string. """ for i in range(len(s)): if s[i] == ch: s = s[0:i] + s[i + 1:] break for i in range(len(s) - 1, -1, -1): if s[i] == ch: ...
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "\"hello\",\"l\"", "\"heo\"" ], [ "\"abcda\",\"a\"", "\"bcd\"" ], [ "\"PHP\",\"P\"", "\"H\"" ] ]
[]
remove_Occ
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
12
null
python
code_generation
def sort_matrix(M): """ Write a function to sort a given matrix in ascending order according to the sum of its rows. """
def sort_matrix(M): """ Write a function to sort a given matrix in ascending order according to the sum of its rows. """ result = sorted(M, key=sum) return result
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[[1, 2, 3], [2, 4, 5], [1, 1, 1]]", "[[1, 1, 1], [1, 2, 3], [2, 4, 5]]" ], [ "[[1, 2, 3], [-2, 4, -5], [1, -1, 1]]", "[[-2, 4, -5], [1, -1, 1], [1, 2, 3]]" ], [ "[[5,8,9],[6,4,3],[2,1,4]]", "[[2, 1, 4], [6, 4, 3], [5, 8, 9]]" ] ]
[]
sort_matrix
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": [ "list" ], "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": nul...
MBPP_sanitized
14
null
python
code_generation
def find_Volume(l, b, h): """ Write a python function to find the volume of a triangular prism. """
def find_Volume(l, b, h): """ Write a python function to find the volume of a triangular prism. """ return l * b * h / 2
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "10,8,6", "240" ], [ "3,2,2", "6" ], [ "1,2,1", "1" ] ]
[]
find_Volume
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": [ "int" ], "base1": null, "base2": null...
MBPP_sanitized
16
null
python
code_generation
import re def text_lowercase_underscore(text): """ Write a function to that returns true if the input string contains sequences of lowercase letters joined with an underscore and false otherwise. """
import re def text_lowercase_underscore(text): """ Write a function to that returns true if the input string contains sequences of lowercase letters joined with an underscore and false otherwise. """ patterns = '^[a-z]+_[a-z]+$' if re.search(patterns, text): return True else: ret...
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "\"aab_cbbbc\"", "(True)" ], [ "\"aab_Abbbc\"", "(False)" ], [ "\"Aaab_abbbc\"", "(False)" ] ]
[ "import re" ]
text_lowercase_underscore
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
17
null
python
code_generation
def square_perimeter(a): """ Write a function that returns the perimeter of a square given its side length as input. """
def square_perimeter(a): """ Write a function that returns the perimeter of a square given its side length as input. """ perimeter = 4 * a return perimeter
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "10", "40" ], [ "5", "20" ], [ "4", "16" ] ]
[]
square_perimeter
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": [ "int" ], "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null...
MBPP_sanitized
18
null
python
code_generation
NO_OF_CHARS = 256 def str_to_list(string): temp = [] for x in string: temp.append(x) return temp def lst_to_string(List): return ''.join(List) def get_char_count_array(string): count = [0] * NO_OF_CHARS for i in string: count[ord(i)] += 1 return count def remove_dirty_chars(s...
NO_OF_CHARS = 256 def str_to_list(string): temp = [] for x in string: temp.append(x) return temp def lst_to_string(List): return ''.join(List) def get_char_count_array(string): count = [0] * NO_OF_CHARS for i in string: count[ord(i)] += 1 return count def remove_dirty_chars(s...
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "\"probasscurve\", \"pros\"", "'bacuve'" ], [ "\"digitalindia\", \"talent\"", "'digiidi'" ], [ "\"exoticmiles\", \"toxic\"", "'emles'" ] ]
[]
remove_dirty_chars
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
19
null
python
code_generation
def test_duplicate(arraynums): """ Write a function to find whether a given array of integers contains any duplicate element. """
def test_duplicate(arraynums): """ Write a function to find whether a given array of integers contains any duplicate element. """ nums_set = set(arraynums) return len(arraynums) != len(nums_set)
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "([1,2,3,4,5])", "False" ], [ "([1,2,3,4, 4])", "True" ], [ "[1,1,2,2,3,3,4,4,5]", "True" ] ]
[]
test_duplicate
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": [ "list" ], "b": null, "base1": null, "base2": nul...
MBPP_sanitized
20
null
python
code_generation
def is_woodall(x): """ Write a function to check if the given number is woodball or not. """
def is_woodall(x): """ Write a function to check if the given number is woodball or not. """ if x % 2 == 0: return False if x == 1: return True x = x + 1 p = 0 while x % 2 == 0: x = x / 2 p = p + 1 if p == x: return True return Fals...
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "383", "True" ], [ "254", "False" ], [ "200", "False" ] ]
[]
is_woodall
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
56
null
python
code_generation
def rev(num): rev_num = 0 while num > 0: rev_num = rev_num * 10 + num % 10 num = num // 10 return rev_num def check(n): """ Write a python function to check if a given number is one less than twice its reverse. """
def rev(num): rev_num = 0 while num > 0: rev_num = rev_num * 10 + num % 10 num = num // 10 return rev_num def check(n): """ Write a python function to check if a given number is one less than twice its reverse. """ return 2 * rev(n) == n + 1
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "70", "False" ], [ "23", "False" ], [ "73", "True" ] ]
[]
check
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
57
null
python
code_generation
def find_Max_Num(arr): """ Write a python function to find the largest number that can be formed with the given list of digits. """
def find_Max_Num(arr): """ Write a python function to find the largest number that can be formed with the given list of digits. """ n = len(arr) arr.sort(reverse=True) num = arr[0] for i in range(1, n): num = num * 10 + arr[i] return num
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[1,2,3]", "321" ], [ "[4,5,6,1]", "6541" ], [ "[1,2,3,9]", "9321" ] ]
[]
find_Max_Num
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": [ "list" ], "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": nul...
MBPP_sanitized
58
null
python
code_generation
def opposite_Signs(x, y): """ Write a python function to check whether the given two integers have opposite sign or not. """
def opposite_Signs(x, y): """ Write a python function to check whether the given two integers have opposite sign or not. """ return x ^ y < 0
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "1,-2", "True" ], [ "3,2", "False" ], [ "-10,-10", "False" ], [ "-2,2", "True" ] ]
[]
opposite_Signs
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
59
null
python
code_generation
def is_octagonal(n): """ Write a function to find the nth octagonal number. """
def is_octagonal(n): """ Write a function to find the nth octagonal number. """ return 3 * n * n - 2 * n
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "5", "65" ], [ "10", "280" ], [ "15", "645" ] ]
[]
is_octagonal
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
61
null
python
code_generation
from collections import defaultdict def count_Substrings(s): """ Write a python function to count the number of substrings with the sum of digits equal to their length. """
from collections import defaultdict def count_Substrings(s): """ Write a python function to count the number of substrings with the sum of digits equal to their length. """ n = len(s) (count, sum) = (0, 0) mp = defaultdict(lambda : 0) mp[0] += 1 for i in range(n): sum += ord(s[i]...
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "'112112'", "6" ], [ "'111'", "6" ], [ "'1101112'", "12" ] ]
[ "from collections import defaultdict" ]
count_Substrings
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
62
null
python
code_generation
def smallest_num(xs): """ Write a python function to find smallest number in a list. """
def smallest_num(xs): """ Write a python function to find smallest number in a list. """ return min(xs)
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[10, 20, 1, 45, 99]", "1" ], [ "[1, 2, 3]", "1" ], [ "[45, 46, 50, 60]", "45" ] ]
[]
smallest_num
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
63
null
python
code_generation
def max_difference(test_list): """ Write a function to find the maximum difference between available pairs in the given tuple list. """
def max_difference(test_list): """ Write a function to find the maximum difference between available pairs in the given tuple list. """ temp = [abs(b - a) for (a, b) in test_list] res = max(temp) return res
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[(3, 5), (1, 7), (10, 3), (1, 2)]", "7" ], [ "[(4, 6), (2, 17), (9, 13), (11, 12)]", "15" ], [ "[(12, 35), (21, 27), (13, 23), (41, 22)]", "23" ] ]
[]
max_difference
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
64
null
python
code_generation
def subject_marks(subjectmarks): """ Write a function to sort a list of tuples using the second value of each tuple. """
def subject_marks(subjectmarks): """ Write a function to sort a list of tuples using the second value of each tuple. """ subjectmarks.sort(key=lambda x: x[1]) return subjectmarks
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)]", "[('Social sciences', 82), ('English', 88), ('Science', 90), ('Maths', 97)]" ], [ "[('Telugu',49),('Hindhi',54),('Social',33)]", "([('Social',33),('Telugu',49),('Hindhi',54)])" ], [ "[('Physics',96),('Chemist...
[]
subject_marks
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
65
null
python
code_generation
def recursive_list_sum(data_list): """ Write a function to flatten a list and sum all of its elements. """
def recursive_list_sum(data_list): """ Write a function to flatten a list and sum all of its elements. """ total = 0 for element in data_list: if type(element) == type([]): total = total + recursive_list_sum(element) else: total = total + element return to...
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "([1, 2, [3,4],[5,6]])", "21" ], [ "([7, 10, [15,14],[19,41]])", "106" ], [ "([10, 20, [30,40],[50,60]])", "210" ] ]
[]
recursive_list_sum
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
66
null
python
code_generation
def pos_count(list): """ Write a python function to count the number of positive numbers in a list. """
def pos_count(list): """ Write a python function to count the number of positive numbers in a list. """ pos_count = 0 for num in list: if num >= 0: pos_count += 1 return pos_count
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[1,-2,3,-4]", "2" ], [ "[3,4,5,-1]", "3" ], [ "[1,2,3,4]", "4" ] ]
[]
pos_count
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
67
null
python
code_generation
def bell_number(n): """ Write a function to find the number of ways to partition a set of Bell numbers. """
def bell_number(n): """ Write a function to find the number of ways to partition a set of Bell numbers. """ bell = [[0 for i in range(n + 1)] for j in range(n + 1)] bell[0][0] = 1 for i in range(1, n + 1): bell[i][0] = bell[i - 1][i - 1] for j in range(1, i + 1): bell...
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "2", "2" ], [ "10", "115975" ], [ "56", "6775685320645824322581483068371419745979053216268760300" ] ]
[]
bell_number
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
68
null
python
code_generation
def is_Monotonic(A): """ Write a python function to check whether the given array is monotonic or not. """
def is_Monotonic(A): """ Write a python function to check whether the given array is monotonic or not. """ return all((A[i] <= A[i + 1] for i in range(len(A) - 1))) or all((A[i] >= A[i + 1] for i in range(len(A) - 1)))
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[6, 5, 4, 4]", "True" ], [ "[1, 2, 2, 3]", "True" ], [ "[1, 3, 2]", "False" ] ]
[]
is_Monotonic
{ "input": { "A": [ "list" ], "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": nul...
MBPP_sanitized
69
null
python
code_generation
def is_sublist(l, s): """ Write a function to check whether a list contains the given sublist or not. """
def is_sublist(l, s): """ Write a function to check whether a list contains the given sublist or not. """ sub_set = False if s == []: sub_set = True elif s == l: sub_set = True elif len(s) > len(l): sub_set = False else: for i in range(len(l)): ...
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[2,4,3,5,7],[3,7]", "False" ], [ "[2,4,3,5,7],[4,3]", "True" ], [ "[2,4,3,5,7],[1,6]", "False" ] ]
[]
is_sublist
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
70
null
python
code_generation
def find_equal_tuple(Input): k = 0 if not Input else len(Input[0]) flag = 1 for tuple in Input: if len(tuple) != k: flag = 0 break return flag def get_equal(Input): """ Write a function to find whether all the given tuples have equal length or not. """
def find_equal_tuple(Input): k = 0 if not Input else len(Input[0]) flag = 1 for tuple in Input: if len(tuple) != k: flag = 0 break return flag def get_equal(Input): """ Write a function to find whether all the given tuples have equal length or not. """ ret...
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[(11, 22, 33), (44, 55, 66)]", "True" ], [ "[(1, 2, 3), (4, 5, 6, 7)]", "False" ], [ "[(1, 2), (3, 4)]", "True" ] ]
[]
get_equal
{ "input": { "A": null, "Input": [ "list" ], "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": nul...
MBPP_sanitized
71
null
python
code_generation
def comb_sort(nums): """ Write a function to sort a list of elements. """
def comb_sort(nums): """ Write a function to sort a list of elements. """ shrink_fact = 1.3 gaps = len(nums) swapped = True i = 0 while gaps > 1 or swapped: gaps = int(float(gaps) / shrink_fact) swapped = False i = 0 while gaps + i < len(nums): ...
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[5, 15, 37, 25, 79]", "[5, 15, 25, 37, 79]" ], [ "[41, 32, 15, 19, 22]", "[15, 19, 22, 32, 41]" ], [ "[99, 15, 13, 47]", "[13, 15, 47, 99]" ] ]
[]
comb_sort
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
72
null
python
code_generation
def dif_Square(n): """ Write a python function to check whether the given number can be represented as the difference of two squares or not. """
def dif_Square(n): """ Write a python function to check whether the given number can be represented as the difference of two squares or not. """ if n % 4 != 2: return True return False
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "5", "True" ], [ "10", "False" ], [ "15", "True" ] ]
[]
dif_Square
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
74
null
python
code_generation
def is_samepatterns(colors, patterns): """ Write a function to check whether it follows the sequence given in the patterns array. """
def is_samepatterns(colors, patterns): """ Write a function to check whether it follows the sequence given in the patterns array. """ if len(colors) != len(patterns): return False sdict = {} pset = set() sset = set() for i in range(len(patterns)): pset.add(patterns[i]) ...
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"]", "True" ], [ "[\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"]", "False" ], [ "[\"red\",\"green\",\"greenn\"], [\"a\",\"b\"]", "False" ] ]
[]
is_samepatterns
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
75
null
python
code_generation
def find_tuples(test_list, K): """ Write a function to find tuples which have all elements divisible by k from the given list of tuples. """
def find_tuples(test_list, K): """ Write a function to find tuples which have all elements divisible by k from the given list of tuples. """ res = [sub for sub in test_list if all((ele % K == 0 for ele in sub))] return res
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[(6, 24, 12), (7, 9, 6), (12, 18, 21)], 6", "[(6, 24, 12)]" ], [ "[(5, 25, 30), (4, 2, 3), (7, 8, 9)], 5", "[(5, 25, 30)]" ], [ "[(7, 9, 16), (8, 16, 4), (19, 17, 18)], 4", "[(8, 16, 4)]" ] ]
[]
find_tuples
{ "input": { "A": null, "Input": null, "K": [ "int" ], "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null...
MBPP_sanitized
77
null
python
code_generation
def is_Diff(n): """ Write a python function to find whether a number is divisible by 11. """
def is_Diff(n): """ Write a python function to find whether a number is divisible by 11. """ return n % 11 == 0
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "1212112", "True" ], [ "1212", "False" ] ]
[]
is_Diff
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
79
null
python
code_generation
def word_len(s): """ Write a python function to check whether the length of the word is odd or not. """
def word_len(s): """ Write a python function to check whether the length of the word is odd or not. """ s = s.split(' ') for word in s: if len(word) % 2 != 0: return True else: return False
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "\"Hadoop\"", "False" ], [ "\"great\"", "True" ], [ "\"structure\"", "True" ] ]
[]
word_len
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
80
null
python
code_generation
def tetrahedral_number(n): """ Write a function to find the nth tetrahedral number. """
def tetrahedral_number(n): """ Write a function to find the nth tetrahedral number. """ return n * (n + 1) * (n + 2) / 6
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "5", "35" ], [ "6", "56" ], [ "7", "84" ] ]
[]
tetrahedral_number
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
82
null
python
code_generation
import math def volume_sphere(r): """ Write a function to find the volume of a sphere. """
import math def volume_sphere(r): """ Write a function to find the volume of a sphere. """ volume = 4 / 3 * math.pi * r * r * r return volume
[]
import math inputs = {input_list} results = {output_list} candidate = {func_entry} for i, (inp, exp) in enumerate(zip(inputs, results)): assert math.isclose(candidate(*inp), exp, rel_tol=0.001)
[ [ "10", "4188.790204786391" ], [ "25", "65449.84694978735" ], [ "20", "33510.32163829113" ] ]
[ "import math" ]
volume_sphere
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
83
null
python
code_generation
def get_Char(strr): """ Write a python function to find the character made by adding the ASCII value of all the characters of the given string modulo 26. """
def get_Char(strr): """ Write a python function to find the character made by adding the ASCII value of all the characters of the given string modulo 26. """ summ = 0 for i in range(len(strr)): summ += ord(strr[i]) - ord('a') + 1 if summ % 26 == 0: return ord('z') else: ...
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "\"abc\"", "\"f\"" ], [ "\"gfg\"", "\"t\"" ], [ "\"ab\"", "\"c\"" ] ]
[]
get_Char
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
84
null
python
code_generation
def sequence(n): """ Write a function to find the nth number in the newman conway sequence. """
def sequence(n): """ Write a function to find the nth number in the newman conway sequence. """ if n == 1 or n == 2: return 1 else: return sequence(sequence(n - 1)) + sequence(n - sequence(n - 1))
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "10", "6" ], [ "2", "1" ], [ "3", "2" ] ]
[]
sequence
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
85
null
python
code_generation
import math def surfacearea_sphere(r): """ Write a function to find the surface area of a sphere. """
import math def surfacearea_sphere(r): """ Write a function to find the surface area of a sphere. """ surfacearea = 4 * math.pi * r * r return surfacearea
[]
import math inputs = {input_list} results = {output_list} candidate = {func_entry} for i, (inp, exp) in enumerate(zip(inputs, results)): assert math.isclose(candidate(*inp), exp, rel_tol=0.001)
[ [ "10", "1256.6370614359173" ], [ "15", "2827.4333882308138" ], [ "20", "5026.548245743669" ] ]
[ "import math" ]
surfacearea_sphere
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
86
null
python
code_generation
def centered_hexagonal_number(n): """ Write a function to find nth centered hexagonal number. """
def centered_hexagonal_number(n): """ Write a function to find nth centered hexagonal number. """ return 3 * n * (n - 1) + 1
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "10", "271" ], [ "2", "7" ], [ "9", "217" ] ]
[]
centered_hexagonal_number
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
87
null
python
code_generation
import collections as ct def merge_dictionaries_three(dict1, dict2, dict3): """ Write a function to merge three dictionaries into a single dictionary. """
import collections as ct def merge_dictionaries_three(dict1, dict2, dict3): """ Write a function to merge three dictionaries into a single dictionary. """ merged_dict = dict(ct.ChainMap({}, dict1, dict2, dict3)) return merged_dict
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "{ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" },{ \"O\": \"Orange\", \"W\": \"White\", \"B\": \"Black\" }", "{'B': 'Black', 'R': 'Red', 'P': 'Pink', 'G': 'Green', 'W': 'White', 'O': 'Orange'}" ], [ "{ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" ...
[ "import collections as ct" ]
merge_dictionaries_three
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
88
null
python
code_generation
import collections def freq_count(list1): """ Write a function to get the frequency of all the elements in a list, returned as a dictionary. """
import collections def freq_count(list1): """ Write a function to get the frequency of all the elements in a list, returned as a dictionary. """ freq_count = collections.Counter(list1) return freq_count
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[10,10,10,10,20,20,20,20,40,40,50,50,30]", "({10: 4, 20: 4, 40: 2, 50: 2, 30: 1})" ], [ "[1,2,3,4,3,2,4,1,3,1,4]", "({1:3, 2:2,3:3,4:3})" ], [ "[5,6,7,4,9,10,4,5,6,7,9,5]", "({10:1,5:3,6:2,7:2,4:2,9:2})" ] ]
[ "import collections" ]
freq_count
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
89
null
python
code_generation
def closest_num(N): """ Write a function to find the closest smaller number than n. """
def closest_num(N): """ Write a function to find the closest smaller number than n. """ return N - 1
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "11", "10" ], [ "7", "6" ], [ "12", "11" ] ]
[]
closest_num
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": [ "int" ], "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null...
MBPP_sanitized
90
null
python
code_generation
def len_log(list1): """ Write a python function to find the length of the longest word. """
def len_log(list1): """ Write a python function to find the length of the longest word. """ max = len(list1[0]) for i in list1: if len(i) > max: max = len(i) return max
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[\"python\",\"PHP\",\"bigdata\"]", "7" ], [ "[\"a\",\"ab\",\"abc\"]", "3" ], [ "[\"small\",\"big\",\"tall\"]", "5" ] ]
[]
len_log
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
91
null
python
code_generation
def find_substring(str1, sub_str): """ Write a function to check if a string is present as a substring in a given list of string values. """
def find_substring(str1, sub_str): """ Write a function to check if a string is present as a substring in a given list of string values. """ if any((sub_str in s for s in str1)): return True return False
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[\"red\", \"black\", \"white\", \"green\", \"orange\"],\"ack\"", "True" ], [ "[\"red\", \"black\", \"white\", \"green\", \"orange\"],\"abc\"", "False" ], [ "[\"red\", \"black\", \"white\", \"green\", \"orange\"],\"ange\"", "True" ] ]
[]
find_substring
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
92
null
python
code_generation
def is_undulating(n): """ Write a function to check whether the given number is undulating or not. """
def is_undulating(n): """ Write a function to check whether the given number is undulating or not. """ n = str(n) if len(n) <= 2: return False for i in range(2, len(n)): if n[i - 2] != n[i]: return False return True
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "1212121", "True" ], [ "1991", "False" ], [ "121", "True" ] ]
[]
is_undulating
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
93
null
python
code_generation
def power(a, b): """ Write a function to calculate the value of 'a' to the power 'b'. """
def power(a, b): """ Write a function to calculate the value of 'a' to the power 'b'. """ if b == 0: return 1 elif a == 0: return 0 elif b == 1: return a else: return a * power(a, b - 1)
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "3,4", "81" ], [ "2,3", "8" ], [ "5,5", "3125" ] ]
[]
power
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": [ "int" ], "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": [ "int" ], "base1": null, ...
MBPP_sanitized
94
null
python
code_generation
from operator import itemgetter def index_minimum(test_list): """ Given a list of tuples, write a function that returns the first value of the tuple with the smallest second value. """
from operator import itemgetter def index_minimum(test_list): """ Given a list of tuples, write a function that returns the first value of the tuple with the smallest second value. """ res = min(test_list, key=itemgetter(1))[0] return res
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[('Rash', 143), ('Manjeet', 200), ('Varsha', 100)]", "'Varsha'" ], [ "[('Yash', 185), ('Dawood', 125), ('Sanya', 175)]", "'Dawood'" ], [ "[('Sai', 345), ('Salman', 145), ('Ayesha', 96)]", "'Ayesha'" ] ]
[ "from operator import itemgetter " ]
index_minimum
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
95
null
python
code_generation
def Find_Min_Length(lst): """ Write a python function to find the length of the smallest list in a list of lists. """
def Find_Min_Length(lst): """ Write a python function to find the length of the smallest list in a list of lists. """ minLength = min((len(x) for x in lst)) return minLength
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[[1],[1,2]]", "1" ], [ "[[1,2],[1,2,3],[1,2,3,4]]", "2" ], [ "[[3,3,3],[4,4,4,4]]", "3" ] ]
[]
Find_Min_Length
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
96
null
python
code_generation
def divisor(n): """ Write a python function to find the number of divisors of a given integer. """
def divisor(n): """ Write a python function to find the number of divisors of a given integer. """ for i in range(n): x = len([i for i in range(1, n + 1) if not n % i]) return x
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "15", "4" ], [ "12", "6" ], [ "9", "3" ] ]
[]
divisor
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
97
null
python
code_generation
def frequency_lists(list1): """ Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary. """
def frequency_lists(list1): """ Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary. """ list1 = [item for sublist in list1 for item in sublist] dic_data = {} for num in list1: if num in dic_data.keys(): dic_data[num] += 1...
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[[1, 2, 3, 2], [4, 5, 6, 2], [7, 8, 9, 5]]", "{1: 1, 2: 3, 3: 1, 4: 1, 5: 2, 6: 1, 7: 1, 8: 1, 9: 1}" ], [ "[[1,2,3,4],[5,6,7,8],[9,10,11,12]]", "{1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1,10:1,11:1,12:1}" ], [ "[[20,30,40,17],[18,16,14,13],[10,20,30,40]]", "{20:2,30:2,...
[]
frequency_lists
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
98
null
python
code_generation
def multiply_num(numbers): """ Write a function to multiply all the numbers in a list and divide with the length of the list. """
def multiply_num(numbers): """ Write a function to multiply all the numbers in a list and divide with the length of the list. """ total = 1 for x in numbers: total *= x return total / len(numbers)
[]
import math inputs = {input_list} results = {output_list} candidate = {func_entry} for i, (inp, exp) in enumerate(zip(inputs, results)): assert math.isclose(candidate(*inp), exp, rel_tol=0.001)
[ [ "(8, 2, 3, -1, 7)", "-67.2" ], [ "(-10,-20,-30)", "-2000.0" ], [ "(19,15,18)", "1710.0" ] ]
[]
multiply_num
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
99
null
python
code_generation
def decimal_to_binary(n): """ Write a function to convert the given decimal number to its binary equivalent, represented as a string with no leading zeros. """
def decimal_to_binary(n): """ Write a function to convert the given decimal number to its binary equivalent, represented as a string with no leading zeros. """ return bin(n).replace('0b', '')
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "8", "'1000'" ], [ "18", "'10010'" ], [ "7", "'111'" ] ]
[]
decimal_to_binary
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
100
null
python
code_generation
import sys def next_smallest_palindrome(num): """ Write a function to find the next smallest palindrome of a specified integer, returned as an integer. """
import sys def next_smallest_palindrome(num): """ Write a function to find the next smallest palindrome of a specified integer, returned as an integer. """ numstr = str(num) for i in range(num + 1, sys.maxsize): if str(i) == str(i)[::-1]: return i
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "99", "101" ], [ "1221", "1331" ], [ "120", "121" ] ]
[ "import sys" ]
next_smallest_palindrome
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
101
null
python
code_generation
def kth_element(arr, k): """ Write a function to find the kth element in the given array using 1-based indexing. """
def kth_element(arr, k): """ Write a function to find the kth element in the given array using 1-based indexing. """ n = len(arr) for i in range(n): for j in range(0, n - i - 1): if arr[j] > arr[j + 1]: (arr[j], arr[j + 1] == arr[j + 1], arr[j]) return arr[k -...
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[12,3,5,7,19], 2", "3" ], [ "[17,24,8,23], 3", "8" ], [ "[16,21,25,36,4], 4", "36" ] ]
[]
kth_element
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": [ "list" ], "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": nul...
MBPP_sanitized
102
null
python
code_generation
def snake_to_camel(word): """ Write a function to convert a snake case string to camel case string. """
def snake_to_camel(word): """ Write a function to convert a snake case string to camel case string. """ import re return ''.join((x.capitalize() or '_' for x in word.split('_')))
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "'python_program'", "'PythonProgram'" ], [ "'python_language'", "('PythonLanguage')" ], [ "'programming_language'", "('ProgrammingLanguage')" ] ]
[ "import re" ]
snake_to_camel
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
103
null
python
code_generation
def eulerian_num(n, m): """ Write a function to find the Eulerian number a(n, m). """
def eulerian_num(n, m): """ Write a function to find the Eulerian number a(n, m). """ if m >= n or n == 0: return 0 if m == 0: return 1 return (n - m) * eulerian_num(n - 1, m - 1) + (m + 1) * eulerian_num(n - 1, m)
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "3, 1", "4" ], [ "4, 1", "11" ], [ "5, 3", "26" ] ]
[]
eulerian_num
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
104
null
python
code_generation
def sort_sublists(input_list): """ Write a function to sort each sublist of strings in a given list of lists. """
def sort_sublists(input_list): """ Write a function to sort each sublist of strings in a given list of lists. """ result = [sorted(x, key=lambda x: x[0]) for x in input_list] return result
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "([\"green\", \"orange\"], [\"black\", \"white\"], [\"white\", \"black\", \"orange\"])", "[['green', 'orange'], ['black', 'white'], ['black', 'orange', 'white']]" ], [ "([\" red \",\"green\" ],[\"blue \",\" black\"],[\" orange\",\"brown\"])", "[[' red ', 'green'], [' black', 'blue '], [' orang...
[]
sort_sublists
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
105
null
python
code_generation
def count(lst): """ Write a python function to count true booleans in the given list. """
def count(lst): """ Write a python function to count true booleans in the given list. """ return sum(lst)
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[True,False,True]", "2" ], [ "[False,False]", "0" ], [ "[True,True,True]", "3" ] ]
[]
count
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
106
null
python
code_generation
def add_lists(test_list, test_tup): """ Write a function to append the given list to the given tuples. """
def add_lists(test_list, test_tup): """ Write a function to append the given list to the given tuples. """ res = tuple(list(test_tup) + test_list) return res
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[5, 6, 7], (9, 10)", "(9, 10, 5, 6, 7)" ], [ "[6, 7, 8], (10, 11)", "(10, 11, 6, 7, 8)" ], [ "[7, 8, 9], (11, 12)", "(11, 12, 7, 8, 9)" ] ]
[]
add_lists
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
108
null
python
code_generation
import heapq def merge_sorted_list(num1, num2, num3): """ Write a function to merge three lists into a single sorted list. """
import heapq def merge_sorted_list(num1, num2, num3): """ Write a function to merge three lists into a single sorted list. """ num1 = sorted(num1) num2 = sorted(num2) num3 = sorted(num3) result = heapq.merge(num1, num2, num3) return list(result)
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[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, 29, 48, 54, 56, 110, 154, 233]" ], [ "[1, 3, 5, 6, 8, 9], [2, 5, 7, 11], [1, 4, 7, 8, 12]", "[1, 1, 2, 3, 4, 5, 5, 6, 7, 7, 8, 8, 9, 11, 12]" ], [ "[18, 14, 10, 9,...
[ "import heapq" ]
merge_sorted_list
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
109
null
python
code_generation
def odd_Equivalent(s, n): """ Write a python function to find the number of numbers with an odd value when rotating a binary string the given number of times. """
def odd_Equivalent(s, n): """ Write a python function to find the number of numbers with an odd value when rotating a binary string the given number of times. """ count = 0 for i in range(0, n): if s[i] == '1': count = count + 1 return count
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "\"011001\",6", "3" ], [ "\"11011\",5", "4" ], [ "\"1010\",4", "2" ] ]
[]
odd_Equivalent
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
111
null
python
code_generation
def common_in_nested_lists(nestedlist): """ Write a function to find the common elements in given nested lists. """
def common_in_nested_lists(nestedlist): """ Write a function to find the common elements in given nested lists. """ result = list(set.intersection(*map(set, nestedlist))) return result
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[[12, 18, 23, 25, 45], [7, 12, 18, 24, 28], [1, 5, 8, 12, 15, 16, 18]]", "[18, 12]" ], [ "[[12, 5, 23, 25, 45], [7, 11, 5, 23, 28], [1, 5, 8, 18, 23, 16]]", "[5,23]" ], [ "[[2, 3,4, 1], [4, 5], [6,4, 8],[4, 5], [6, 8,4]]", "[4]" ] ]
[]
common_in_nested_lists
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
113
null
python
code_generation
def check_integer(text): """ Write a function to check if a string represents an integer or not. """
def check_integer(text): """ Write a function to check if a string represents an integer or not. """ text = text.strip() if len(text) < 1: return None elif all((text[i] in '0123456789' for i in range(len(text)))): return True elif text[0] in '+-' and all((text[i] in '01234567...
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "\"python\"", "False" ], [ "\"1\"", "True" ], [ "\"12345\"", "True" ] ]
[]
check_integer
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
115
null
python
code_generation
def empty_dit(list1): """ Write a function to check whether all dictionaries in a list are empty or not. """
def empty_dit(list1): """ Write a function to check whether all dictionaries in a list are empty or not. """ empty_dit = all((not d for d in list1)) return empty_dit
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[{},{},{}]", "True" ], [ "[{1,2},{},{}]", "False" ], [ "{}", "True" ] ]
[]
empty_dit
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
116
null
python
code_generation
def tuple_to_int(nums): """ Write a function to convert a given tuple of positive integers into a single integer. """
def tuple_to_int(nums): """ Write a function to convert a given tuple of positive integers into a single integer. """ result = int(''.join(map(str, nums))) return result
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "(1,2,3)", "123" ], [ "(4,5,6)", "456" ], [ "(5,6,7)", "567" ] ]
[]
tuple_to_int
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
117
null
python
code_generation
def list_to_float(test_list): """ Write a function to convert all possible convertible elements in a list of lists to floats. """
def list_to_float(test_list): """ Write a function to convert all possible convertible elements in a list of lists to floats. """ res = [] for tup in test_list: temp = [] for ele in tup: if ele.isalpha(): temp.append(ele) else: ...
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ " [(\"3\", \"4\"), (\"1\", \"26.45\"), (\"7.32\", \"8\"), (\"4\", \"8\")] ", "[(3.0, 4.0), (1.0, 26.45), (7.32, 8.0), (4.0, 8.0)]" ], [ " [(\"4\", \"4\"), (\"2\", \"27\"), (\"4.12\", \"9\"), (\"7\", \"11\")] ", "[(4.0, 4.0), (2.0, 27.0), (4.12, 9.0), (7.0, 11.0)]" ], [ " [(\"6\", \"78\...
[]
list_to_float
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
118
null
python
code_generation
def string_to_list(string): """ Write a function to convert a string to a list of strings split on the space character. """
def string_to_list(string): """ Write a function to convert a string to a list of strings split on the space character. """ lst = list(string.split(' ')) return lst
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "\"python programming\"", "['python','programming']" ], [ "\"lists tuples strings\"", "['lists','tuples','strings']" ], [ "\"write a program\"", "['write','a','program']" ] ]
[]
string_to_list
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
119
null
python
code_generation
def search(arr): """ Write a python function to find the element that appears only once in a sorted array. """
def search(arr): """ Write a python function to find the element that appears only once in a sorted array. """ n = len(arr) XOR = 0 for i in range(n): XOR = XOR ^ arr[i] return XOR
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[1,1,2,2,3]", "3" ], [ "[1,1,3,3,4,4,5,5,7,7,8]", "8" ], [ "[1,2,2,3,3,4,4]", "1" ] ]
[]
search
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": [ "list" ], "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": nul...
MBPP_sanitized
120
null
python
code_generation
def max_product_tuple(list1): """ Write a function to find the maximum absolute product between numbers in pairs of tuples within a given list. """
def max_product_tuple(list1): """ Write a function to find the maximum absolute product between numbers in pairs of tuples within a given list. """ result_max = max([abs(x * y) for (x, y) in list1]) return result_max
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[(2, 7), (2, 6), (1, 8), (4, 9)] ", "36" ], [ "[(10,20), (15,2), (5,10)] ", "200" ], [ "[(11,44), (10,15), (20,5), (12, 9)] ", "484" ] ]
[]
max_product_tuple
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
123
null
python
code_generation
def amicable_numbers_sum(limit): """ Write a function to sum all amicable numbers from 1 to a specified number. """
def amicable_numbers_sum(limit): """ Write a function to sum all amicable numbers from 1 to a specified number. """ if not isinstance(limit, int): return 'Input is not an integer!' if limit < 1: return 'Input must be bigger than 0!' amicables = set() for num in range(2, limit...
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "999", "504" ], [ "9999", "31626" ], [ "99", "0" ] ]
[]
amicable_numbers_sum
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
124
null
python
code_generation
import cmath def angle_complex(a, b): """ Write a function to get the angle of a complex number. """
import cmath def angle_complex(a, b): """ Write a function to get the angle of a complex number. """ cn = complex(a, b) angle = cmath.phase(a + b) return angle
[]
import math inputs = {input_list} results = {output_list} candidate = {func_entry} for i, (inp, exp) in enumerate(zip(inputs, results)): assert math.isclose(candidate(*inp), exp, rel_tol=0.001)
[ [ "0,1j", "1.5707963267948966" ], [ "2,1j", "0.4636476090008061" ], [ "0,2j", "1.5707963267948966" ] ]
[ "import cmath" ]
angle_complex
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": [ "int" ], "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": [ "complex" ], "base1": null...
MBPP_sanitized
125
null
python
code_generation
def find_length(string): """ Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string. """
def find_length(string): """ Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string. """ n = len(string) current_sum = 0 max_sum = 0 for i in range(n): current_sum += 1 if string[i] == '0' else -1 ...
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "\"11000010001\"", "6" ], [ "\"10111\"", "1" ], [ "\"11011101100101\"", "2" ] ]
[]
find_length
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
126
null
python
code_generation
def sum(a, b): """ Write a python function to find the sum of common divisors of two given numbers. """
def sum(a, b): """ Write a python function to find the sum of common divisors of two given numbers. """ sum = 0 for i in range(1, min(a, b)): if a % i == 0 and b % i == 0: sum += i return sum
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "10,15", "6" ], [ "100,150", "93" ], [ "4,6", "3" ] ]
[]
sum
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": [ "int" ], "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": [ "int" ], "base1": null, ...
MBPP_sanitized
127
null
python
code_generation
def multiply_int(x, y): """ Write a function to multiply two integers. """
def multiply_int(x, y): """ Write a function to multiply two integers. """ if y < 0: return -multiply_int(x, -y) elif y == 0: return 0 elif y == 1: return x else: return x + multiply_int(x, y - 1)
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "10,20", "200" ], [ "5,10", "50" ], [ "4,8", "32" ] ]
[]
multiply_int
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
128
null
python
code_generation
def long_words(n, str): """ Write a function to find words that are longer than n characters from a given list of words. """
def long_words(n, str): """ Write a function to find words that are longer than n characters from a given list of words. """ word_len = [] txt = str.split(' ') for x in txt: if len(x) > n: word_len.append(x) return word_len
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "3,\"python is a programming language\"", "['python','programming','language']" ], [ "2,\"writing a program\"", "['writing','program']" ], [ "5,\"sorting list\"", "['sorting']" ] ]
[]
long_words
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
129
null
python
code_generation
def magic_square_test(my_matrix): """ Write a function to calculate whether the matrix is a magic square. """
def magic_square_test(my_matrix): """ Write a function to calculate whether the matrix is a magic square. """ iSize = len(my_matrix[0]) sum_list = [] sum_list.extend([sum(lines) for lines in my_matrix]) for col in range(iSize): sum_list.append(sum((row[col] for row in my_matrix))) ...
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]]", "True" ], [ "[[2, 7, 6], [9, 5, 1], [4, 3, 8]]", "True" ], [ "[[2, 7, 6], [9, 5, 1], [4, 3, 7]]", "False" ] ]
[]
magic_square_test
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
130
null
python
code_generation
from collections import defaultdict def max_occurrences(nums): """ Write a function to find the item with maximum frequency in a given list. """
from collections import defaultdict def max_occurrences(nums): """ Write a function to find the item with maximum frequency in a given list. """ dict = defaultdict(int) for i in nums: dict[i] += 1 result = max(dict.items(), key=lambda x: x[1]) return result[0]
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,2,4,6,9,1,2]", "2" ], [ "[2,3,8,4,7,9,8,7,9,15,14,10,12,13,16,18]", "8" ], [ "[10,20,20,30,40,90,80,50,30,20,50,10]", "20" ] ]
[ "from collections import defaultdict" ]
max_occurrences
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
131
null
python
code_generation
def reverse_vowels(str1): """ Write a python function to reverse only the vowels of a given string (where y is not a vowel). """
def reverse_vowels(str1): """ Write a python function to reverse only the vowels of a given string (where y is not a vowel). """ vowels = '' for char in str1: if char in 'aeiouAEIOU': vowels += char result_string = '' for char in str1: if char in 'aeiouAEIOU': ...
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "\"Python\"", "\"Python\"" ], [ "\"USA\"", "\"ASU\"" ], [ "\"ab\"", "\"ab\"" ] ]
[]
reverse_vowels
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
132
null
python
code_generation
def tup_string(tup1): """ Write a function to convert a tuple to a string. """
def tup_string(tup1): """ Write a function to convert a tuple to a string. """ str = ''.join(tup1) return str
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "('e', 'x', 'e', 'r', 'c', 'i', 's', 'e', 's')", "(\"exercises\")" ], [ "('p','y','t','h','o','n')", "(\"python\")" ], [ "('p','r','o','g','r','a','m')", "(\"program\")" ] ]
[]
tup_string
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
133
null
python
code_generation
def sum_negativenum(nums): """ Write a function to calculate the sum of the negative numbers of a given list of numbers. """
def sum_negativenum(nums): """ Write a function to calculate the sum of the negative numbers of a given list of numbers. """ sum_negativenum = list(filter(lambda nums: nums < 0, nums)) return sum(sum_negativenum)
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[2, 4, -6, -9, 11, -12, 14, -5, 17]", "-32" ], [ "[10,15,-14,13,-18,12,-20]", "-52" ], [ "[19, -65, 57, 39, 152,-639, 121, 44, 90, -190]", "-894" ] ]
[]
sum_negativenum
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
135
null
python
code_generation
def hexagonal_num(n): """ Write a function to find the nth hexagonal number. """
def hexagonal_num(n): """ Write a function to find the nth hexagonal number. """ return n * (2 * n - 1)
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "10", "190" ], [ "5", "45" ], [ "7", "91" ] ]
[]
hexagonal_num
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
137
null
python
code_generation
from array import array def zero_count(nums): """ Write a function to find the ratio of zeroes to non-zeroes in an array of integers. """
from array import array def zero_count(nums): """ Write a function to find the ratio of zeroes to non-zeroes in an array of integers. """ n = len(nums) n1 = 0 for x in nums: if x == 0: n1 += 1 else: None return n1 / (n - n1)
[]
import math inputs = {input_list} results = {output_list} candidate = {func_entry} for i, (inp, exp) in enumerate(zip(inputs, results)): assert math.isclose(candidate(*inp), exp, rel_tol=0.001)
[ [ "[0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8]", "0.181818" ], [ "[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8]", "0.00" ], [ "[2, 4, -6, -9, 11, -12, 14, -5, 17]", "0.00" ] ]
[ "from array import array" ]
zero_count
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
138
null
python
code_generation
def is_Sum_Of_Powers_Of_Two(n): """ Write a python function to check whether the given number can be represented as sum of non-zero powers of 2 or not. """
def is_Sum_Of_Powers_Of_Two(n): """ Write a python function to check whether the given number can be represented as sum of non-zero powers of 2 or not. """ if n % 2 == 1: return False else: return True
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "10", "True" ], [ "7", "False" ], [ "14", "True" ] ]
[]
is_Sum_Of_Powers_Of_Two
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
139
null
python
code_generation
def circle_circumference(r): """ Write a function to find the circumference of a circle. """
def circle_circumference(r): """ Write a function to find the circumference of a circle. """ perimeter = 2 * 3.1415 * r return perimeter
[]
import math inputs = {input_list} results = {output_list} candidate = {func_entry} for i, (inp, exp) in enumerate(zip(inputs, results)): assert math.isclose(candidate(*inp), exp, rel_tol=0.001)
[ [ "10", "62.830000000000005" ], [ "5", "31.415000000000003" ], [ "4", "25.132" ] ]
[]
circle_circumference
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
140
null
python
code_generation
def extract_singly(test_list): """ Write a function to flatten the list of lists into a single set of numbers. """
def extract_singly(test_list): """ Write a function to flatten the list of lists into a single set of numbers. """ res = [] temp = set() for inner in test_list: for ele in inner: if not ele in temp: temp.add(ele) res.append(ele) return res
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[(3, 4, 5), (4, 5, 7), (1, 4)]", "[3, 4, 5, 7, 1]" ], [ "[(1, 2, 3), (4, 2, 3), (7, 8)]", "[1, 2, 3, 4, 7, 8]" ], [ "[(7, 8, 9), (10, 11, 12), (10, 11)]", "[7, 8, 9, 10, 11, 12]" ] ]
[]
extract_singly
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
141
null
python
code_generation
def pancake_sort(nums): """ Write a function to sort a list of elements. """
def pancake_sort(nums): """ Write a function to sort a list of elements. """ arr_len = len(nums) while arr_len > 1: mi = nums.index(max(nums[0:arr_len])) nums = nums[mi::-1] + nums[mi + 1:len(nums)] nums = nums[arr_len - 1::-1] + nums[arr_len:len(nums)] arr_len -= 1 ...
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[15, 79, 25, 38, 69]", "[15, 25, 38, 69, 79]" ], [ "[98, 12, 54, 36, 85]", "[12, 36, 54, 85, 98]" ], [ "[41, 42, 32, 12, 23]", "[12, 23, 32, 41, 42]" ] ]
[]
pancake_sort
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
142
null
python
code_generation
def count_samepair(list1, list2, list3): """ Write a function to count number items that are identical in the same position of three given lists. """
def count_samepair(list1, list2, list3): """ Write a function to count number items that are identical in the same position of three given lists. """ result = sum((m == n == o for (m, n, o) in zip(list1, list2, list3))) return result
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[1,2,3,4,5,6,7,8],[2,2,3,1,2,6,7,9],[2,1,3,1,2,6,7,9]", "3" ], [ "[1,2,3,4,5,6,7,8],[2,2,3,1,2,6,7,8],[2,1,3,1,2,6,7,8]", "4" ], [ "[1,2,3,4,2,6,7,8],[2,2,3,1,2,6,7,8],[2,1,3,1,2,6,7,8]", "5" ] ]
[]
count_samepair
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
143
null
python
code_generation
def find_lists(Input): """ Write a function to find number of lists present in the given tuple. """
def find_lists(Input): """ Write a function to find number of lists present in the given tuple. """ if isinstance(Input, list): return 1 else: return len(Input)
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "([1, 2, 3, 4], [5, 6, 7, 8])", "2" ], [ "([1, 2], [3, 4], [5, 6])", "3" ], [ "([9, 8, 7, 6, 5, 4, 3, 2, 1])", "1" ] ]
[]
find_lists
{ "input": { "A": null, "Input": [ "list" ], "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": nul...
MBPP_sanitized
145
null
python
code_generation
def max_Abs_Diff(arr): """ Write a python function to find the maximum difference between any two elements in a given array. """
def max_Abs_Diff(arr): """ Write a python function to find the maximum difference between any two elements in a given array. """ n = len(arr) minEle = arr[0] maxEle = arr[0] for i in range(1, n): minEle = min(minEle, arr[i]) maxEle = max(maxEle, arr[i]) return maxEle - mi...
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "(2,1,5,3)", "4" ], [ "(9,3,2,5,1)", "8" ], [ "(3,2,1)", "2" ] ]
[]
max_Abs_Diff
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": [ "int" ], "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null...
MBPP_sanitized
160
null
python
code_generation
def find_solution(a, b, n): """ Write a function that returns integers x and y that satisfy ax + by = n as a tuple, or return None if no solution exists. """
def find_solution(a, b, n): """ Write a function that returns integers x and y that satisfy ax + by = n as a tuple, or return None if no solution exists. """ i = 0 while i * a <= n: if (n - i * a) % b == 0: return (i, (n - i * a) // b) i = i + 1 return None
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "2, 3, 7", "(2, 1)" ], [ "4, 2, 7", null ], [ "1, 13, 17", "(4, 1)" ] ]
[]
find_solution
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": [ "int" ], "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": [ "int" ], "base1": null, ...
MBPP_sanitized
161
null
python
code_generation
def remove_elements(list1, list2): """ Write a function to remove all elements from a given list present in another list. """
def remove_elements(list1, list2): """ Write a function to remove all elements from a given list present in another list. """ result = [x for x in list1 if x not in list2] return result
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 4, 6, 8]", "[1, 3, 5, 7, 9, 10]" ], [ "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 3, 5, 7]", "[2, 4, 6, 8, 9, 10]" ], [ "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [5, 7]", "[1, 2, 3, 4, 6, 8, 9, 10]" ] ]
[]
remove_elements
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
162
null
python
code_generation
def sum_series(n): """ Write a function to calculate the sum (n - 2*i) from i=0 to n // 2, for instance n + (n-2) + (n-4)... (until n-x =< 0). """
def sum_series(n): """ Write a function to calculate the sum (n - 2*i) from i=0 to n // 2, for instance n + (n-2) + (n-4)... (until n-x =< 0). """ if n < 1: return 0 else: return n + sum_series(n - 2)
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "6", "12" ], [ "10", "30" ], [ "9", "25" ] ]
[]
sum_series
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
163
null
python
code_generation
from math import tan, pi def area_polygon(s, l): """ Write a function to calculate the area of a regular polygon given the length and number of its sides. """
from math import tan, pi def area_polygon(s, l): """ Write a function to calculate the area of a regular polygon given the length and number of its sides. """ area = s * l ** 2 / (4 * tan(pi / s)) return area
[]
import math inputs = {input_list} results = {output_list} candidate = {func_entry} for i, (inp, exp) in enumerate(zip(inputs, results)): assert math.isclose(candidate(*inp), exp, rel_tol=0.001)
[ [ "4, 20", "400." ], [ "10, 15", "1731.197" ], [ "9, 7", "302.909" ] ]
[ "from math import tan, pi" ]
area_polygon
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
164
null
python
code_generation
import math def div_sum(n): total = 1 i = 2 while i * i <= n: if n % i == 0: total = total + i + math.floor(n / i) i += 1 return total def are_equivalent(num1, num2): """ Write a function to determine if the sum of the divisors of two integers are the same. """
import math def div_sum(n): total = 1 i = 2 while i * i <= n: if n % i == 0: total = total + i + math.floor(n / i) i += 1 return total def are_equivalent(num1, num2): """ Write a function to determine if the sum of the divisors of two integers are the same. """ ...
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "36, 57", "False" ], [ "2, 4", "False" ], [ "23, 47", "True" ] ]
[ "import math " ]
are_equivalent
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
165
null
python
code_generation
def count_char_position(str1): """ 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). """
def count_char_position(str1): """ 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). """ count_chars = 0 for i in range(len(str1)): if i == ord(str1[i]) - ord('A') or i == ord(str1[i]) -...
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "\"xbcefg\"", "2" ], [ "\"ABcED\"", "3" ], [ "\"AbgdeF\"", "5" ] ]
[]
count_char_position
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
166
null
python
code_generation
def find_even_pair(A): """ Write a function that counts the number of pairs of integers in a list that xor to an even number. """
def find_even_pair(A): """ Write a function that counts the number of pairs of integers in a list that xor to an even number. """ count = 0 for i in range(0, len(A)): for j in range(i + 1, len(A)): if (A[i] ^ A[j]) % 2 == 0: count += 1 return count
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[5, 4, 7, 2, 1]", "4" ], [ "[7, 2, 8, 1, 0, 5, 11]", "9" ], [ "[1, 2, 3]", "1" ] ]
[]
find_even_pair
{ "input": { "A": [ "list" ], "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": nul...
MBPP_sanitized
167
null
python
code_generation
def next_power_of_2(n): """ Write a python function to find the smallest power of 2 greater than or equal to n. """
def next_power_of_2(n): """ Write a python function to find the smallest power of 2 greater than or equal to n. """ if n and (not n & n - 1): return n count = 0 while n != 0: n >>= 1 count += 1 return 1 << count
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "0", "1" ], [ "5", "8" ], [ "17", "32" ] ]
[]
next_power_of_2
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
168
null
python
code_generation
def frequency(a, x): """ Write a function to count the number of occurrences of a number in a given list. """
def frequency(a, x): """ Write a function to count the number of occurrences of a number in a given list. """ count = 0 for i in a: if i == x: count += 1 return count
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[1,2,3], 4", "0" ], [ "[1,2,2,3,3,3,4], 3", "3" ], [ "[0,1,2,3,1,2], 1", "2" ] ]
[]
frequency
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": [ "list" ], "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": nul...
MBPP_sanitized
170
null
python
code_generation
def sum_range_list(list1, m, n): """ Write a function to find the sum of numbers in a list within a range specified by two indices. """
def sum_range_list(list1, m, n): """ Write a function to find the sum of numbers in a list within a range specified by two indices. """ sum_range = 0 for i in range(m, n + 1, 1): sum_range += list1[i] return sum_range
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[2,1,5,6,8,3,4,9,10,11,8,12], 8, 10", "29" ], [ "[2,1,5,6,8,3,4,9,10,11,8,12], 5, 7", "16" ], [ "[2,1,5,6,8,3,4,9,10,11,8,12], 7, 10", "38" ] ]
[]
sum_range_list
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
171
null
python
code_generation
import math def perimeter_pentagon(a): """ Write a function to find the perimeter of a regular pentagon from the length of its sides. """
import math def perimeter_pentagon(a): """ Write a function to find the perimeter of a regular pentagon from the length of its sides. """ perimeter = 5 * a return perimeter
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "5", "25" ], [ "10", "50" ], [ "15", "75" ] ]
[ "import math" ]
perimeter_pentagon
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": [ "int" ], "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null...
MBPP_sanitized
172
null
python
code_generation
def count_occurance(s): """ Write a function to count the number of occurence of the string 'std' in a given string. """
def count_occurance(s): """ Write a function to count the number of occurence of the string 'std' in a given string. """ count = 0 for i in range(len(s) - 2): if s[i] == 's' and s[i + 1] == 't' and (s[i + 2] == 'd'): count = count + 1 return count
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "\"letstdlenstdporstd\"", "3" ], [ "\"truststdsolensporsd\"", "1" ], [ "\"makestdsostdworthit\"", "2" ], [ "\"stds\"", "1" ], [ "\"\"", "0" ] ]
[]
count_occurance
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
222
null
python
code_generation
def check_type(test_tuple): """ Write a function to check if all the elements in tuple have same data type or not. """
def check_type(test_tuple): """ Write a function to check if all the elements in tuple have same data type or not. """ res = True for ele in test_tuple: if not isinstance(ele, type(test_tuple[0])): res = False break return res
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "(5, 6, 7, 3, 5, 6) ", "True" ], [ "(1, 2, \"4\") ", "False" ], [ "(3, 2, 1, 4, 5) ", "True" ] ]
[]
check_type
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
223
null
python
code_generation
def binary_search(arr, low, high, x): if high >= low: mid = (low + high) // 2 if (mid == 0 or x > arr[mid - 1]) and arr[mid] == x: return mid elif x > arr[mid]: return binary_search(arr, mid + 1, high, x) else: return binary_search(arr, low, mid - ...
def binary_search(arr, low, high, x): if high >= low: mid = (low + high) // 2 if (mid == 0 or x > arr[mid - 1]) and arr[mid] == x: return mid elif x > arr[mid]: return binary_search(arr, mid + 1, high, x) else: return binary_search(arr, low, mid - ...
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "[1, 2, 3, 3, 3, 3, 10], 7, 3", "True" ], [ "[1, 1, 2, 4, 4, 4, 6, 6], 8, 4", "False" ], [ "[1, 1, 1, 2, 2], 5, 1", "True" ], [ "[1, 1, 2, 2], 5, 1", "False" ] ]
[]
is_majority
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": [ "list" ], "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": nul...
MBPP_sanitized
224
null
python
code_generation
def count_Set_Bits(n): """ Write a python function to count the number of set bits (binary digits with value 1) in a given number. """
def count_Set_Bits(n): """ Write a python function to count the number of set bits (binary digits with value 1) in a given number. """ count = 0 while n: count += n & 1 n >>= 1 return count
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "2", "1" ], [ "4", "1" ], [ "6", "2" ] ]
[]
count_Set_Bits
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...
MBPP_sanitized
226
null
python
code_generation
def odd_values_string(str): """ Write a python function to remove the characters which have odd index values of a given string. """
def odd_values_string(str): """ Write a python function to remove the characters which have odd index values of a given string. """ result = '' for i in range(len(str)): if i % 2 == 0: result = result + str[i] return result
[]
import numpy as np 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 == np.float64 or x.dtype ...
[ [ "'abcdef'", "'ace'" ], [ "'python'", "'pto'" ], [ "'data'", "'dt'" ], [ "'lambs'", "'lms'" ] ]
[]
odd_values_string
{ "input": { "A": null, "Input": null, "K": null, "L": null, "M": null, "N": null, "S": null, "a": null, "actual_cost": null, "arr": null, "array_nums1": null, "array_nums2": null, "arraynums": null, "b": null, "base1": null, "base2": null, "c": null...