task_id int32 1 973 | text stringlengths 37 249 | code stringlengths 30 910 | test_list listlengths 3 3 | ast stringlengths 64 1.86k | cfg stringlengths 34 324 |
|---|---|---|---|---|---|
871 | Write a python function to check whether the given strings are rotations of each other or not. | def are_Rotations(string1,string2):
size1 = len(string1)
size2 = len(string2)
temp = ''
if size1 != size2:
return False
temp = string1 + string1
if (temp.count(string2)> 0):
return True
else:
return False | [
"assert are_Rotations(\"abc\",\"cba\") == False",
"assert are_Rotations(\"abcd\",\"cdba\") == False",
"assert are_Rotations(\"abacd\",\"cdaba\") == True"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ASSIGN_NAME_STORE_CALL_NAME_LOAD_NAME_LOAD_ASSIGN_NAME_STORE_CALL_NAME_LOAD_NAME_LOAD_ASSIGN_NAME_STORE_CONSTANT_IF_COMPARE_NAME_LOAD_NOTEQ_NAME_LOAD_RETURN_CONSTANT_ASSIGN_NAME_STORE_BINOP_NAME_LOAD_ADD_NAME_LOAD_IF_COMPARE_CALL_ATTRIBUTE_NAME_LOAD_LOAD_NAME_LOAD_GT_CONSTANT_RETURN... | [2][SEP1][If][Return][If][Return][Return][SEP2][1,2][][3,4][][][SEP3][2][0][1][0][0] |
872 | Write a function to check if a nested list is a subset of another nested list. | def check_subset(list1,list2):
return all(map(list1.__contains__,list2)) | [
"assert check_subset([[1, 3], [5, 7], [9, 11], [13, 15, 17]] ,[[1, 3],[13,15,17]])==True",
"assert check_subset([[1, 2], [2, 3], [3, 4], [5, 6]],[[3, 4], [5, 6]])==True",
"assert check_subset([[[1, 2], [2, 3]], [[3, 4], [5, 7]]],[[[3, 4], [5, 6]]])==False"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_RETURN_CALL_NAME_LOAD_CALL_NAME_LOAD_ATTRIBUTE_NAME_LOAD_LOAD_NAME_LOAD | [2][SEP1][Return][SEP2][][SEP3][2] |
873 | Write a function to solve the fibonacci sequence using recursion. | def fibonacci(n):
if n == 1 or n == 2:
return 1
else:
return (fibonacci(n - 1) + (fibonacci(n - 2))) | [
"assert fibonacci(7) == 13",
"assert fibonacci(8) == 21",
"assert fibonacci(9) == 34"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_IF_BOOLOP_OR_COMPARE_NAME_LOAD_EQ_CONSTANT_COMPARE_NAME_LOAD_EQ_CONSTANT_RETURN_CONSTANT_RETURN_BINOP_CALL_NAME_LOAD_BINOP_NAME_LOAD_SUB_CONSTANT_ADD_CALL_NAME_LOAD_BINOP_NAME_LOAD_SUB_CONSTANT | [1][SEP1][If][Return][Return][SEP2][1,2][][][SEP3][0][0][2] |
874 | Write a python function to check if the string is a concatenation of another string. | def check_Concat(str1,str2):
N = len(str1)
M = len(str2)
if (N % M != 0):
return False
for i in range(N):
if (str1[i] != str2[i % M]):
return False
return True | [
"assert check_Concat(\"abcabcabc\",\"abc\") == True",
"assert check_Concat(\"abcab\",\"abc\") == False",
"assert check_Concat(\"aba\",\"ab\") == False"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ASSIGN_NAME_STORE_CALL_NAME_LOAD_NAME_LOAD_ASSIGN_NAME_STORE_CALL_NAME_LOAD_NAME_LOAD_IF_COMPARE_BINOP_NAME_LOAD_MOD_NAME_LOAD_NOTEQ_CONSTANT_RETURN_CONSTANT_FOR_NAME_STORE_CALL_NAME_LOAD_NAME_LOAD_IF_COMPARE_SUBSCRIPT_NAME_LOAD_NAME_LOAD_LOAD_NOTEQ_SUBSCRIPT_NAME_LOAD_BINOP_NAME_LO... | [2][SEP1][If][Return][For][If][Return][Return][SEP2][1,2][][3,4][5,2][][][SEP3][2][0][1][0][0][0] |
875 | Write a function to find the minimum difference in the tuple pairs of given tuples. | def min_difference(test_list):
temp = [abs(b - a) for a, b in test_list]
res = min(temp)
return (res) | [
"assert min_difference([(3, 5), (1, 7), (10, 3), (1, 2)]) == 1",
"assert min_difference([(4, 6), (12, 8), (11, 4), (2, 13)]) == 2",
"assert min_difference([(5, 17), (3, 9), (12, 5), (3, 24)]) == 6"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_LISTCOMP_CALL_NAME_LOAD_BINOP_NAME_LOAD_SUB_NAME_LOAD_COMPREHENSION_TUPLE_NAME_STORE_NAME_STORE_STORE_NAME_LOAD_ASSIGN_NAME_STORE_CALL_NAME_LOAD_NAME_LOAD_RETURN_NAME_LOAD | [1][SEP1][Return][SEP2][][SEP3][2] |
876 | Write a python function to find lcm of two positive integers. | def lcm(x, y):
if x > y:
z = x
else:
z = y
while(True):
if((z % x == 0) and (z % y == 0)):
lcm = z
break
z += 1
return lcm | [
"assert lcm(4,6) == 12",
"assert lcm(15,17) == 255",
"assert lcm(2,6) == 6"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_IF_COMPARE_NAME_LOAD_GT_NAME_LOAD_ASSIGN_NAME_STORE_NAME_LOAD_ASSIGN_NAME_STORE_NAME_LOAD_WHILE_CONSTANT_IF_BOOLOP_AND_COMPARE_BINOP_NAME_LOAD_MOD_NAME_LOAD_EQ_CONSTANT_COMPARE_BINOP_NAME_LOAD_MOD_NAME_LOAD_EQ_CONSTANT_ASSIGN_NAME_STORE_NAME_LOAD_BREAK_AUGASSIGN_NAME_STORE_ADD_CONST... | [2][SEP1][If][None][None][While][If][None][None][Return][SEP2][1,2][3][3][4][5,6][7][3][][SEP3][0][0][0][0][0][0][0][0] |
877 | Write a python function to sort the given string. | def sort_String(str) :
str = ''.join(sorted(str))
return (str) | [
"assert sort_String(\"cba\") == \"abc\"",
"assert sort_String(\"data\") == \"aadt\"",
"assert sort_String(\"zxy\") == \"xyz\""
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CALL_ATTRIBUTE_CONSTANT_LOAD_CALL_NAME_LOAD_NAME_LOAD_RETURN_NAME_LOAD | [1][SEP1][Return][SEP2][][SEP3][2] |
878 | Write a function to check if the given tuple contains only k elements. | def check_tuples(test_tuple, K):
res = all(ele in K for ele in test_tuple)
return (res) | [
"assert check_tuples((3, 5, 6, 5, 3, 6),[3, 6, 5]) == True",
"assert check_tuples((4, 5, 6, 4, 6, 5),[4, 5, 6]) == True",
"assert check_tuples((9, 8, 7, 6, 8, 9),[9, 8, 1]) == False"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ASSIGN_NAME_STORE_CALL_NAME_LOAD_GENERATOREXP_COMPARE_NAME_LOAD_IN_NAME_LOAD_COMPREHENSION_NAME_STORE_NAME_LOAD_RETURN_NAME_LOAD | [2][SEP1][Return][SEP2][][SEP3][1] |
881 | Write a function to find the sum of first even and odd number of a given list. | def sum_even_odd(list1):
first_even = next((el for el in list1 if el%2==0),-1)
first_odd = next((el for el in list1 if el%2!=0),-1)
return (first_even+first_odd) | [
"assert sum_even_odd([1,3,5,7,4,1,6,8])==5",
"assert sum_even_odd([1,2,3,4,5,6,7,8,9,10])==3",
"assert sum_even_odd([1,5,7,9,10])==11"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CALL_NAME_LOAD_GENERATOREXP_NAME_LOAD_COMPREHENSION_NAME_STORE_NAME_LOAD_COMPARE_BINOP_NAME_LOAD_MOD_CONSTANT_EQ_CONSTANT_UNARYOP_USUB_CONSTANT_ASSIGN_NAME_STORE_CALL_NAME_LOAD_GENERATOREXP_NAME_LOAD_COMPREHENSION_NAME_STORE_NAME_LOAD_COMPARE_BINOP_NAME_LOAD_MOD_CONSTA... | [1][SEP1][Return][SEP2][][SEP3][2] |
883 | Write a function to find numbers divisible by m and n from a list of numbers using lambda function. | def div_of_nums(nums,m,n):
result = list(filter(lambda x: (x % m == 0 and x % n == 0), nums))
return result | [
"assert div_of_nums([19, 65, 57, 39, 152, 639, 121, 44, 90, 190],2,4)==[ 152,44]",
"assert div_of_nums([1, 2, 3, 5, 7, 8, 10],2,5)==[10]",
"assert div_of_nums([10,15,14,13,18,12,20],10,5)==[10,20]"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ARG_ASSIGN_NAME_STORE_CALL_NAME_LOAD_CALL_NAME_LOAD_LAMBDA_ARGUMENTS_ARG_BOOLOP_AND_COMPARE_BINOP_NAME_LOAD_MOD_NAME_LOAD_EQ_CONSTANT_COMPARE_BINOP_NAME_LOAD_MOD_NAME_LOAD_EQ_CONSTANT_NAME_LOAD_RETURN_NAME_LOAD | [3][SEP1][Return][SEP2][][SEP3][2] |
884 | Write a python function to check whether all the bits are within a given range or not. | def all_Bits_Set_In_The_Given_Range(n,l,r):
num = ((1 << r) - 1) ^ ((1 << (l - 1)) - 1)
new_num = n & num
if (num == new_num):
return True
return False | [
"assert all_Bits_Set_In_The_Given_Range(10,2,1) == True ",
"assert all_Bits_Set_In_The_Given_Range(5,2,4) == False",
"assert all_Bits_Set_In_The_Given_Range(22,2,3) == True "
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ARG_ASSIGN_NAME_STORE_BINOP_BINOP_BINOP_CONSTANT_LSHIFT_NAME_LOAD_SUB_CONSTANT_BITXOR_BINOP_BINOP_CONSTANT_LSHIFT_BINOP_NAME_LOAD_SUB_CONSTANT_SUB_CONSTANT_ASSIGN_NAME_STORE_BINOP_NAME_LOAD_BITAND_NAME_LOAD_IF_COMPARE_NAME_LOAD_EQ_NAME_LOAD_RETURN_CONSTANT_RETURN_CONSTANT | [3][SEP1][If][Return][Return][SEP2][1,2][][][SEP3][0][0][0] |
885 | Write a python function to check whether the two given strings are isomorphic to each other or not. | def is_Isomorphic(str1,str2):
dict_str1 = {}
dict_str2 = {}
for i, value in enumerate(str1):
dict_str1[value] = dict_str1.get(value,[]) + [i]
for j, value in enumerate(str2):
dict_str2[value] = dict_str2.get(value,[]) + [j]
if sorted(dict_str1.values()) == so... | [
"assert is_Isomorphic(\"paper\",\"title\") == True",
"assert is_Isomorphic(\"ab\",\"ba\") == True",
"assert is_Isomorphic(\"ab\",\"aa\") == False"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ASSIGN_NAME_STORE_DICT_ASSIGN_NAME_STORE_DICT_FOR_TUPLE_NAME_STORE_NAME_STORE_STORE_CALL_NAME_LOAD_NAME_LOAD_ASSIGN_SUBSCRIPT_NAME_LOAD_NAME_LOAD_STORE_BINOP_CALL_ATTRIBUTE_NAME_LOAD_LOAD_NAME_LOAD_LIST_LOAD_ADD_LIST_NAME_LOAD_LOAD_FOR_TUPLE_NAME_STORE_NAME_STORE_STORE_CALL_NAME_LOA... | [2][SEP1][None][For][None][For][None][If][Return][Return][SEP2][1][2,3][1][4,5][3][6,7][][][SEP3][0][1][1][1][1][4][0][0] |
886 | Write a function to add all the numbers in a list and divide it with the length of the list. | def sum_num(numbers):
total = 0
for x in numbers:
total += x
return total/len(numbers) | [
"assert sum_num((8, 2, 3, 0, 7))==4.0",
"assert sum_num((-10,-20,-30))==-20.0",
"assert sum_num((19,15,18))==17.333333333333332"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CONSTANT_FOR_NAME_STORE_NAME_LOAD_AUGASSIGN_NAME_STORE_ADD_NAME_LOAD_RETURN_BINOP_NAME_LOAD_DIV_CALL_NAME_LOAD_NAME_LOAD | [1][SEP1][None][For][None][Return][SEP2][1][2,3][1][][SEP3][0][0][0][1] |
887 | Write a python function to check whether the given number is odd or not using bitwise operator. | def is_odd(n) :
if (n^1 == n-1) :
return True;
else :
return False; | [
"assert is_odd(5) == True",
"assert is_odd(6) == False",
"assert is_odd(7) == True"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_IF_COMPARE_BINOP_NAME_LOAD_BITXOR_CONSTANT_EQ_BINOP_NAME_LOAD_SUB_CONSTANT_RETURN_CONSTANT_RETURN_CONSTANT | [1][SEP1][If][Return][Return][SEP2][1,2][][][SEP3][0][0][0] |
888 | Write a function to substract the elements of the given nested tuples. | def substract_elements(test_tup1, test_tup2):
res = tuple(tuple(a - b for a, b in zip(tup1, tup2))
for tup1, tup2 in zip(test_tup1, test_tup2))
return (res) | [
"assert substract_elements(((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))) == ((-5, -4), (1, -4), (1, 8), (-6, 7))",
"assert substract_elements(((13, 4), (14, 6), (13, 10), (12, 11)), ((19, 8), (14, 10), (12, 2), (18, 4))) == ((-6, -4), (0, -4), (1, 8), (-6, 7))",
"assert substract_elements... | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ASSIGN_NAME_STORE_CALL_NAME_LOAD_GENERATOREXP_CALL_NAME_LOAD_GENERATOREXP_BINOP_NAME_LOAD_SUB_NAME_LOAD_COMPREHENSION_TUPLE_NAME_STORE_NAME_STORE_STORE_CALL_NAME_LOAD_NAME_LOAD_NAME_LOAD_COMPREHENSION_TUPLE_NAME_STORE_NAME_STORE_STORE_CALL_NAME_LOAD_NAME_LOAD_NAME_LOAD_RETURN_NAME_L... | [2][SEP1][Return][SEP2][][SEP3][4] |
889 | Write a function to reverse each list in a given list of lists. | def reverse_list_lists(lists):
for l in lists:
l.sort(reverse = True)
return lists | [
"assert reverse_list_lists([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]])==[[4, 3, 2, 1], [8, 7, 6, 5], [12, 11, 10, 9], [16, 15, 14, 13]]",
"assert reverse_list_lists([[1,2],[2,3],[3,4]])==[[2,1],[3,2],[4,3]]",
"assert reverse_list_lists([[10,20],[30,40]])==[[20,10],[40,30]]"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_FOR_NAME_STORE_NAME_LOAD_EXPR_CALL_ATTRIBUTE_NAME_LOAD_LOAD_KEYWORD_CONSTANT_RETURN_NAME_LOAD | [1][SEP1][For][None][Return][SEP2][1,2][0][][SEP3][0][1][0] |
890 | Write a python function to find the index of an extra element present in one sorted array. | def find_Extra(arr1,arr2,n) :
for i in range(0, n) :
if (arr1[i] != arr2[i]) :
return i
return n | [
"assert find_Extra([1,2,3,4],[1,2,3],3) == 3",
"assert find_Extra([2,4,6,8,10],[2,4,6,8],4) == 4",
"assert find_Extra([1,3,5,7,9,11],[1,3,5,7,9],5) == 5"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ARG_FOR_NAME_STORE_CALL_NAME_LOAD_CONSTANT_NAME_LOAD_IF_COMPARE_SUBSCRIPT_NAME_LOAD_NAME_LOAD_LOAD_NOTEQ_SUBSCRIPT_NAME_LOAD_NAME_LOAD_LOAD_RETURN_NAME_LOAD_RETURN_NAME_LOAD | [3][SEP1][For][If][Return][Return][SEP2][1,2][3,0][][][SEP3][1][0][0][0] |
891 | Write a python function to check whether the given two numbers have same number of digits or not. | def same_Length(A,B):
while (A > 0 and B > 0):
A = A / 10;
B = B / 10;
if (A == 0 and B == 0):
return True;
return False; | [
"assert same_Length(12,1) == False",
"assert same_Length(2,2) == True",
"assert same_Length(10,20) == True"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_WHILE_BOOLOP_AND_COMPARE_NAME_LOAD_GT_CONSTANT_COMPARE_NAME_LOAD_GT_CONSTANT_ASSIGN_NAME_STORE_BINOP_NAME_LOAD_DIV_CONSTANT_ASSIGN_NAME_STORE_BINOP_NAME_LOAD_DIV_CONSTANT_IF_BOOLOP_AND_COMPARE_NAME_LOAD_EQ_CONSTANT_COMPARE_NAME_LOAD_EQ_CONSTANT_RETURN_CONSTANT_RETURN_CONSTANT | [2][SEP1][While][None][If][Return][Return][SEP2][1,2][0][3,4][][][SEP3][0][0][0][0][0] |
892 | Write a function to remove multiple spaces in a string. | import re
def remove_spaces(text):
return (re.sub(' +',' ',text)) | [
"assert remove_spaces('python program')==('python program')",
"assert remove_spaces('python programming language')==('python programming language')",
"assert remove_spaces('python program')==('python program')"
] | MODULE_IMPORT_ALIAS_FUNCTIONDEF_ARGUMENTS_ARG_RETURN_CALL_ATTRIBUTE_NAME_LOAD_LOAD_CONSTANT_CONSTANT_NAME_LOAD | [1][SEP1][Return][SEP2][][SEP3][1] |
893 | Write a python function to get the last element of each sublist. | def Extract(lst):
return [item[-1] for item in lst] | [
"assert Extract([[1, 2, 3], [4, 5], [6, 7, 8, 9]]) == [3, 5, 9]",
"assert Extract([['x', 'y', 'z'], ['m'], ['a', 'b'], ['u', 'v']]) == ['z', 'm', 'b', 'v']",
"assert Extract([[1, 2, 3], [4, 5]]) == [3, 5]"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_RETURN_LISTCOMP_SUBSCRIPT_NAME_LOAD_UNARYOP_USUB_CONSTANT_LOAD_COMPREHENSION_NAME_STORE_NAME_LOAD | [1][SEP1][Return][SEP2][][SEP3][0] |
894 | Write a function to convert the given string of float type into tuple. | def float_to_tuple(test_str):
res = tuple(map(float, test_str.split(', ')))
return (res) | [
"assert float_to_tuple(\"1.2, 1.3, 2.3, 2.4, 6.5\") == (1.2, 1.3, 2.3, 2.4, 6.5)",
"assert float_to_tuple(\"2.3, 2.4, 5.6, 5.4, 8.9\") == (2.3, 2.4, 5.6, 5.4, 8.9)",
"assert float_to_tuple(\"0.3, 0.5, 7.8, 9.4\") == (0.3, 0.5, 7.8, 9.4)"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CALL_NAME_LOAD_CALL_NAME_LOAD_NAME_LOAD_CALL_ATTRIBUTE_NAME_LOAD_LOAD_CONSTANT_RETURN_NAME_LOAD | [1][SEP1][Return][SEP2][][SEP3][3] |
897 | Write a python function to check whether the word is present in a given sentence or not. | def is_Word_Present(sentence,word):
s = sentence.split(" ")
for i in s:
if (i == word):
return True
return False | [
"assert is_Word_Present(\"machine learning\",\"machine\") == True",
"assert is_Word_Present(\"easy\",\"fun\") == False",
"assert is_Word_Present(\"python language\",\"code\") == False"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ASSIGN_NAME_STORE_CALL_ATTRIBUTE_NAME_LOAD_LOAD_CONSTANT_FOR_NAME_STORE_NAME_LOAD_IF_COMPARE_NAME_LOAD_EQ_NAME_LOAD_RETURN_CONSTANT_RETURN_CONSTANT | [2][SEP1][None][For][If][Return][Return][SEP2][1][2,3][4,1][][][SEP3][1][0][0][0][0] |
898 | Write a function to extract specified number of elements from a given list, which follow each other continuously. | from itertools import groupby
def extract_elements(numbers, n):
result = [i for i, j in groupby(numbers) if len(list(j)) == n]
return result | [
"assert extract_elements([1, 1, 3, 4, 4, 5, 6, 7],2)==[1, 4]",
"assert extract_elements([0, 1, 2, 3, 4, 4, 4, 4, 5, 7],4)==[4]",
"assert extract_elements([0,0,0,0,0],5)==[0]"
] | MODULE_IMPORTFROM_ALIAS_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ASSIGN_NAME_STORE_LISTCOMP_NAME_LOAD_COMPREHENSION_TUPLE_NAME_STORE_NAME_STORE_STORE_CALL_NAME_LOAD_NAME_LOAD_COMPARE_CALL_NAME_LOAD_CALL_NAME_LOAD_NAME_LOAD_EQ_NAME_LOAD_RETURN_NAME_LOAD | [2][SEP1][Return][SEP2][][SEP3][3] |
899 | Write a python function to check whether an array can be sorted or not by picking only the corner elements. | def check(arr,n):
g = 0
for i in range(1,n):
if (arr[i] - arr[i - 1] > 0 and g == 1):
return False
if (arr[i] - arr[i] < 0):
g = 1
return True | [
"assert check([3,2,1,2,3,4],6) == True",
"assert check([2,1,4,5,1],5) == True",
"assert check([1,2,2,1,2,3],6) == True"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ASSIGN_NAME_STORE_CONSTANT_FOR_NAME_STORE_CALL_NAME_LOAD_CONSTANT_NAME_LOAD_IF_BOOLOP_AND_COMPARE_BINOP_SUBSCRIPT_NAME_LOAD_NAME_LOAD_LOAD_SUB_SUBSCRIPT_NAME_LOAD_BINOP_NAME_LOAD_SUB_CONSTANT_LOAD_GT_CONSTANT_COMPARE_NAME_LOAD_EQ_CONSTANT_RETURN_CONSTANT_IF_COMPARE_BINOP_SUBSCRIPT_N... | [2][SEP1][None][For][If][Return][Return][If][None][SEP2][1][2,3][4,5][][][6,1][1][SEP3][0][1][0][0][0][0][0] |
900 | Write a function where a string will start with a specific number. | import re
def match_num(string):
text = re.compile(r"^5")
if text.match(string):
return True
else:
return False | [
"assert match_num('5-2345861')==True",
"assert match_num('6-2345861')==False",
"assert match_num('78910')==False"
] | MODULE_IMPORT_ALIAS_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CALL_ATTRIBUTE_NAME_LOAD_LOAD_CONSTANT_IF_CALL_ATTRIBUTE_NAME_LOAD_LOAD_NAME_LOAD_RETURN_CONSTANT_RETURN_CONSTANT | [1][SEP1][If][Return][Return][SEP2][1,2][][][SEP3][2][0][0] |
902 | Write a function to combine two dictionaries by adding values for common keys. | from collections import Counter
def add_dict(d1,d2):
add_dict = Counter(d1) + Counter(d2)
return add_dict | [
"assert add_dict({'a': 100, 'b': 200, 'c':300},{'a': 300, 'b': 200, 'd':400})==({'b': 400, 'd': 400, 'a': 400, 'c': 300}) ",
"assert add_dict({'a': 500, 'b': 700, 'c':900},{'a': 500, 'b': 600, 'd':900})==({'b': 1300, 'd': 900, 'a': 1000, 'c': 900}) ",
"assert add_dict({'a':900,'b':900,'d':900},{'a':900,'b':900,... | MODULE_IMPORTFROM_ALIAS_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ASSIGN_NAME_STORE_BINOP_CALL_NAME_LOAD_NAME_LOAD_ADD_CALL_NAME_LOAD_NAME_LOAD_RETURN_NAME_LOAD | [2][SEP1][Return][SEP2][][SEP3][2] |
903 | Write a python function to count the total unset bits from 1 to n. | def count_Unset_Bits(n) :
cnt = 0;
for i in range(1,n + 1) :
temp = i;
while (temp) :
if (temp % 2 == 0) :
cnt += 1;
temp = temp // 2;
return cnt; | [
"assert count_Unset_Bits(2) == 1",
"assert count_Unset_Bits(5) == 4",
"assert count_Unset_Bits(14) == 17"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CONSTANT_FOR_NAME_STORE_CALL_NAME_LOAD_CONSTANT_BINOP_NAME_LOAD_ADD_CONSTANT_ASSIGN_NAME_STORE_NAME_LOAD_WHILE_NAME_LOAD_IF_COMPARE_BINOP_NAME_LOAD_MOD_CONSTANT_EQ_CONSTANT_AUGASSIGN_NAME_STORE_ADD_CONSTANT_ASSIGN_NAME_STORE_BINOP_NAME_LOAD_FLOORDIV_CONSTANT_RETURN_NAM... | [1][SEP1][None][For][None][Return][While][If][None][None][SEP2][1][2,3][4][][5,1][6,7][7][4][SEP3][0][1][0][0][0][0][0][0] |
904 | Write a function to return true if the given number is even else return false. | def even_num(x):
if x%2==0:
return True
else:
return False | [
"assert even_num(13.5)==False",
"assert even_num(0)==True",
"assert even_num(-9)==False"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_IF_COMPARE_BINOP_NAME_LOAD_MOD_CONSTANT_EQ_CONSTANT_RETURN_CONSTANT_RETURN_CONSTANT | [1][SEP1][If][Return][Return][SEP2][1,2][][][SEP3][0][0][0] |
906 | Write a function to extract year, month and date from a url by using regex. | import re
def extract_date(url):
return re.findall(r'/(\d{4})/(\d{1,2})/(\d{1,2})/', url) | [
"assert extract_date(\"https://www.washingtonpost.com/news/football-insider/wp/2016/09/02/odell-beckhams-fame-rests-on-one-stupid-little-ball-josh-norman-tells-author/\") == [('2016', '09', '02')]",
"assert extract_date(\"https://www.indiatoday.in/movies/celebrities/story/wp/2020/11/03/odeof-sushant-singh-rajput-... | MODULE_IMPORT_ALIAS_FUNCTIONDEF_ARGUMENTS_ARG_RETURN_CALL_ATTRIBUTE_NAME_LOAD_LOAD_CONSTANT_NAME_LOAD | [1][SEP1][Return][SEP2][][SEP3][1] |
908 | Write a function to find the fixed point in the given array. | def find_fixed_point(arr, n):
for i in range(n):
if arr[i] is i:
return i
return -1 | [
"assert find_fixed_point([-10, -1, 0, 3, 10, 11, 30, 50, 100],9) == 3",
"assert find_fixed_point([1, 2, 3, 4, 5, 6, 7, 8],8) == -1",
"assert find_fixed_point([0, 2, 5, 8, 17],5) == 0"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_FOR_NAME_STORE_CALL_NAME_LOAD_NAME_LOAD_IF_COMPARE_SUBSCRIPT_NAME_LOAD_NAME_LOAD_LOAD_IS_NAME_LOAD_RETURN_NAME_LOAD_RETURN_UNARYOP_USUB_CONSTANT | [2][SEP1][For][If][Return][Return][SEP2][1,2][3,0][][][SEP3][1][0][0][0] |
909 | Write a function to find the previous palindrome of a specified number. | def previous_palindrome(num):
for x in range(num-1,0,-1):
if str(x) == str(x)[::-1]:
return x | [
"assert previous_palindrome(99)==88",
"assert previous_palindrome(1221)==1111",
"assert previous_palindrome(120)==111"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_FOR_NAME_STORE_CALL_NAME_LOAD_BINOP_NAME_LOAD_SUB_CONSTANT_CONSTANT_UNARYOP_USUB_CONSTANT_IF_COMPARE_CALL_NAME_LOAD_NAME_LOAD_EQ_SUBSCRIPT_CALL_NAME_LOAD_NAME_LOAD_SLICE_UNARYOP_USUB_CONSTANT_LOAD_RETURN_NAME_LOAD | [1][SEP1][For][If][Return][SEP2][1][2,0][][SEP3][1][2][0] |
910 | Write a function to validate a gregorian date. | import datetime
def check_date(m, d, y):
try:
m, d, y = map(int, (m, d, y))
datetime.date(y, m, d)
return True
except ValueError:
return False | [
"assert check_date(11,11,2002)==True",
"assert check_date(13,11,2002)==False",
"assert check_date('11','11','2002')==True"
] | MODULE_IMPORT_ALIAS_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ARG_TRY_ASSIGN_TUPLE_NAME_STORE_NAME_STORE_NAME_STORE_STORE_CALL_NAME_LOAD_NAME_LOAD_TUPLE_NAME_LOAD_NAME_LOAD_NAME_LOAD_LOAD_EXPR_CALL_ATTRIBUTE_NAME_LOAD_LOAD_NAME_LOAD_NAME_LOAD_NAME_LOAD_RETURN_CONSTANT_EXCEPTHANDLER_NAME_LOAD_RETURN_CONSTANT | [3][SEP1][Try][Return][Return][SEP2][1,2][][][SEP3][0][2][0] |
914 | Write a python function to check whether the given string is made up of two alternating characters or not. | def is_Two_Alter(s):
for i in range (len( s) - 2) :
if (s[i] != s[i + 2]) :
return False
if (s[0] == s[1]):
return False
return True | [
"assert is_Two_Alter(\"abab\") == True",
"assert is_Two_Alter(\"aaaa\") == False",
"assert is_Two_Alter(\"xyz\") == False"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_FOR_NAME_STORE_CALL_NAME_LOAD_BINOP_CALL_NAME_LOAD_NAME_LOAD_SUB_CONSTANT_IF_COMPARE_SUBSCRIPT_NAME_LOAD_NAME_LOAD_LOAD_NOTEQ_SUBSCRIPT_NAME_LOAD_BINOP_NAME_LOAD_ADD_CONSTANT_LOAD_RETURN_CONSTANT_IF_COMPARE_SUBSCRIPT_NAME_LOAD_CONSTANT_LOAD_EQ_SUBSCRIPT_NAME_LOAD_CONSTANT_LOAD_RETURN_CO... | [1][SEP1][For][If][If][Return][Return][Return][SEP2][1,2][3,0][4,5][][][][SEP3][2][0][0][0][0][0] |
915 | Write a function to rearrange positive and negative numbers in a given array using lambda function. | def rearrange_numbs(array_nums):
result = sorted(array_nums, key = lambda i: 0 if i == 0 else -1 / i)
return result | [
"assert rearrange_numbs([-1, 2, -3, 5, 7, 8, 9, -10])==[2, 5, 7, 8, 9, -10, -3, -1]",
"assert rearrange_numbs([10,15,14,13,-18,12,-20])==[10, 12, 13, 14, 15, -20, -18]",
"assert rearrange_numbs([-20,20,-10,10,-30,30])==[10, 20, 30, -30, -20, -10]"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CALL_NAME_LOAD_NAME_LOAD_KEYWORD_LAMBDA_ARGUMENTS_ARG_IFEXP_COMPARE_NAME_LOAD_EQ_CONSTANT_CONSTANT_BINOP_UNARYOP_USUB_CONSTANT_DIV_NAME_LOAD_RETURN_NAME_LOAD | [1][SEP1][Return][SEP2][][SEP3][1] |
916 | Write a function to find if there is a triplet in the array whose sum is equal to a given value. | def find_triplet_array(A, arr_size, sum):
for i in range( 0, arr_size-2):
for j in range(i + 1, arr_size-1):
for k in range(j + 1, arr_size):
if A[i] + A[j] + A[k] == sum:
return A[i],A[j],A[k]
return True
return False | [
"assert find_triplet_array([1, 4, 45, 6, 10, 8], 6, 22) == (4, 10, 8)",
"assert find_triplet_array([12, 3, 5, 2, 6, 9], 6, 24) == (12, 3, 9)",
"assert find_triplet_array([1, 2, 3, 4, 5], 5, 9) == (1, 3, 5)"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ARG_FOR_NAME_STORE_CALL_NAME_LOAD_CONSTANT_BINOP_NAME_LOAD_SUB_CONSTANT_FOR_NAME_STORE_CALL_NAME_LOAD_BINOP_NAME_LOAD_ADD_CONSTANT_BINOP_NAME_LOAD_SUB_CONSTANT_FOR_NAME_STORE_CALL_NAME_LOAD_BINOP_NAME_LOAD_ADD_CONSTANT_NAME_LOAD_IF_COMPARE_BINOP_BINOP_SUBSCRIPT_NAME_LOAD_NAME_LOAD_L... | [3][SEP1][For][For][Return][For][If][Return][SEP2][1,2][3,0][][4,1][5,3][][SEP3][1][1][0][1][0][0] |
917 | Write a function to find the sequences of one upper case letter followed by lower case letters. | import re
def text_uppercase_lowercase(text):
patterns = '[A-Z]+[a-z]+$'
if re.search(patterns, text):
return 'Found a match!'
else:
return ('Not matched!') | [
"assert text_uppercase_lowercase(\"AaBbGg\")==('Found a match!')",
"assert text_uppercase_lowercase(\"aA\")==('Not matched!')",
"assert text_uppercase_lowercase(\"PYTHON\")==('Not matched!')"
] | MODULE_IMPORT_ALIAS_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CONSTANT_IF_CALL_ATTRIBUTE_NAME_LOAD_LOAD_NAME_LOAD_NAME_LOAD_RETURN_CONSTANT_RETURN_CONSTANT | [1][SEP1][If][Return][Return][SEP2][1,2][][][SEP3][1][0][0] |
918 | Write a function to count coin change. | def coin_change(S, m, n):
table = [[0 for x in range(m)] for x in range(n+1)]
for i in range(m):
table[0][i] = 1
for i in range(1, n+1):
for j in range(m):
x = table[i - S[j]][j] if i-S[j] >= 0 else 0
y = table[i][j-1] if j >= 1 else 0
table[... | [
"assert coin_change([1, 2, 3],3,4)==4",
"assert coin_change([4,5,6,7,8,9],6,9)==2",
"assert coin_change([4,5,6,7,8,9],6,4)==1"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ARG_ASSIGN_NAME_STORE_LISTCOMP_LISTCOMP_CONSTANT_COMPREHENSION_NAME_STORE_CALL_NAME_LOAD_NAME_LOAD_COMPREHENSION_NAME_STORE_CALL_NAME_LOAD_BINOP_NAME_LOAD_ADD_CONSTANT_FOR_NAME_STORE_CALL_NAME_LOAD_NAME_LOAD_ASSIGN_SUBSCRIPT_SUBSCRIPT_NAME_LOAD_CONSTANT_LOAD_NAME_LOAD_STORE_CONSTANT... | [3][SEP1][None][For][None][For][For][Return][None][SEP2][1][2,3][1][4,5][6,3][][4][SEP3][2][1][0][1][1][0][0] |
920 | Write a function to remove all tuples with all none values in the given tuple list. | def remove_tuple(test_list):
res = [sub for sub in test_list if not all(ele == None for ele in sub)]
return (str(res)) | [
"assert remove_tuple([(None, 2), (None, None), (3, 4), (12, 3), (None, )] ) == '[(None, 2), (3, 4), (12, 3)]'",
"assert remove_tuple([(None, None), (None, None), (3, 6), (17, 3), (None,1 )] ) == '[(3, 6), (17, 3), (None, 1)]'",
"assert remove_tuple([(1, 2), (2, None), (3, None), (24, 3), (None, None )] ) == '[(... | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_LISTCOMP_NAME_LOAD_COMPREHENSION_NAME_STORE_NAME_LOAD_UNARYOP_NOT_CALL_NAME_LOAD_GENERATOREXP_COMPARE_NAME_LOAD_EQ_CONSTANT_COMPREHENSION_NAME_STORE_NAME_LOAD_RETURN_CALL_NAME_LOAD_NAME_LOAD | [1][SEP1][Return][SEP2][][SEP3][2] |
921 | Write a function to perform chunking of tuples each of size n. | def chunk_tuples(test_tup, N):
res = [test_tup[i : i + N] for i in range(0, len(test_tup), N)]
return (res) | [
"assert chunk_tuples((10, 4, 5, 6, 7, 6, 8, 3, 4), 3) == [(10, 4, 5), (6, 7, 6), (8, 3, 4)]",
"assert chunk_tuples((1, 2, 3, 4, 5, 6, 7, 8, 9), 2) == [(1, 2), (3, 4), (5, 6), (7, 8), (9,)]",
"assert chunk_tuples((11, 14, 16, 17, 19, 21, 22, 25), 4) == [(11, 14, 16, 17), (19, 21, 22, 25)]"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ASSIGN_NAME_STORE_LISTCOMP_SUBSCRIPT_NAME_LOAD_SLICE_NAME_LOAD_BINOP_NAME_LOAD_ADD_NAME_LOAD_LOAD_COMPREHENSION_NAME_STORE_CALL_NAME_LOAD_CONSTANT_CALL_NAME_LOAD_NAME_LOAD_NAME_LOAD_RETURN_NAME_LOAD | [2][SEP1][Return][SEP2][][SEP3][2] |
923 | Write a function to find the length of the shortest string that has both str1 and str2 as subsequences. | def super_seq(X, Y, m, n):
if (not m):
return n
if (not n):
return m
if (X[m - 1] == Y[n - 1]):
return 1 + super_seq(X, Y, m - 1, n - 1)
return 1 + min(super_seq(X, Y, m - 1, n), super_seq(X, Y, m, n - 1)) | [
"assert super_seq(\"AGGTAB\", \"GXTXAYB\", 6, 7) == 9",
"assert super_seq(\"feek\", \"eke\", 4, 3) == 5",
"assert super_seq(\"PARRT\", \"RTA\", 5, 3) == 6"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ARG_ARG_IF_UNARYOP_NOT_NAME_LOAD_RETURN_NAME_LOAD_IF_UNARYOP_NOT_NAME_LOAD_RETURN_NAME_LOAD_IF_COMPARE_SUBSCRIPT_NAME_LOAD_BINOP_NAME_LOAD_SUB_CONSTANT_LOAD_EQ_SUBSCRIPT_NAME_LOAD_BINOP_NAME_LOAD_SUB_CONSTANT_LOAD_RETURN_BINOP_CONSTANT_ADD_CALL_NAME_LOAD_NAME_LOAD_NAME_LOAD_BINOP_NA... | [4][SEP1][If][Return][If][Return][If][Return][Return][SEP2][1,2][][3,4][][5,6][][][SEP3][0][0][0][0][0][1][3] |
924 | Write a function to find maximum of two numbers. | def max_of_two( x, y ):
if x > y:
return x
return y | [
"assert max_of_two(10,20)==20",
"assert max_of_two(19,15)==19",
"assert max_of_two(-10,-20)==-10"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_IF_COMPARE_NAME_LOAD_GT_NAME_LOAD_RETURN_NAME_LOAD_RETURN_NAME_LOAD | [2][SEP1][If][Return][Return][SEP2][1,2][][][SEP3][0][0][0] |
928 | Write a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format. | import re
def change_date_format(dt):
return re.sub(r'(\d{4})-(\d{1,2})-(\d{1,2})', '\\3-\\2-\\1', dt)
return change_date_format(dt) | [
"assert change_date_format('2026-01-02')=='02-01-2026'",
"assert change_date_format('2021-01-04')=='04-01-2021'",
"assert change_date_format('2030-06-06')=='06-06-2030'"
] | MODULE_IMPORT_ALIAS_FUNCTIONDEF_ARGUMENTS_ARG_RETURN_CALL_ATTRIBUTE_NAME_LOAD_LOAD_CONSTANT_CONSTANT_NAME_LOAD_RETURN_CALL_NAME_LOAD_NAME_LOAD | [1][SEP1][Return][SEP2][][SEP3][1] |
929 | Write a function to count repeated items of a tuple. | def count_tuplex(tuplex,value):
count = tuplex.count(value)
return count | [
"assert count_tuplex((2, 4, 5, 6, 2, 3, 4, 4, 7),4)==3",
"assert count_tuplex((2, 4, 5, 6, 2, 3, 4, 4, 7),2)==2",
"assert count_tuplex((2, 4, 7, 7, 7, 3, 4, 4, 7),7)==4"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ASSIGN_NAME_STORE_CALL_ATTRIBUTE_NAME_LOAD_LOAD_NAME_LOAD_RETURN_NAME_LOAD | [2][SEP1][Return][SEP2][][SEP3][1] |
932 | Write a function to remove duplicate words from a given list of strings. | def remove_duplic_list(l):
temp = []
for x in l:
if x not in temp:
temp.append(x)
return temp | [
"assert remove_duplic_list([\"Python\", \"Exercises\", \"Practice\", \"Solution\", \"Exercises\"])==['Python', 'Exercises', 'Practice', 'Solution']",
"assert remove_duplic_list([\"Python\", \"Exercises\", \"Practice\", \"Solution\", \"Exercises\",\"Java\"])==['Python', 'Exercises', 'Practice', 'Solution', 'Java']... | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_LIST_LOAD_FOR_NAME_STORE_NAME_LOAD_IF_COMPARE_NAME_LOAD_NOTIN_NAME_LOAD_EXPR_CALL_ATTRIBUTE_NAME_LOAD_LOAD_NAME_LOAD_RETURN_NAME_LOAD | [1][SEP1][None][For][If][Return][None][SEP2][1][2,3][4,1][][1][SEP3][0][0][0][0][1] |
933 | Write a function to convert camel case string to snake case string by using regex. | import re
def camel_to_snake(text):
str1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', text)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', str1).lower() | [
"assert camel_to_snake('GoogleAssistant') == 'google_assistant'",
"assert camel_to_snake('ChromeCast') == 'chrome_cast'",
"assert camel_to_snake('QuadCore') == 'quad_core'"
] | MODULE_IMPORT_ALIAS_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CALL_ATTRIBUTE_NAME_LOAD_LOAD_CONSTANT_CONSTANT_NAME_LOAD_RETURN_CALL_ATTRIBUTE_CALL_ATTRIBUTE_NAME_LOAD_LOAD_CONSTANT_CONSTANT_NAME_LOAD_LOAD | [1][SEP1][Return][SEP2][][SEP3][3] |
934 | Write a function to find the nth delannoy number. | def dealnnoy_num(n, m):
if (m == 0 or n == 0) :
return 1
return dealnnoy_num(m - 1, n) + dealnnoy_num(m - 1, n - 1) + dealnnoy_num(m, n - 1) | [
"assert dealnnoy_num(3, 4) == 129",
"assert dealnnoy_num(3, 3) == 63",
"assert dealnnoy_num(4, 5) == 681"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_IF_BOOLOP_OR_COMPARE_NAME_LOAD_EQ_CONSTANT_COMPARE_NAME_LOAD_EQ_CONSTANT_RETURN_CONSTANT_RETURN_BINOP_BINOP_CALL_NAME_LOAD_BINOP_NAME_LOAD_SUB_CONSTANT_NAME_LOAD_ADD_CALL_NAME_LOAD_BINOP_NAME_LOAD_SUB_CONSTANT_BINOP_NAME_LOAD_SUB_CONSTANT_ADD_CALL_NAME_LOAD_NAME_LOAD_BINOP_NAME_LOAD... | [2][SEP1][If][Return][Return][SEP2][1,2][][][SEP3][0][0][3] |
936 | Write a function to re-arrange the given tuples based on the given ordered list. | def re_arrange_tuples(test_list, ord_list):
temp = dict(test_list)
res = [(key, temp[key]) for key in ord_list]
return (res) | [
"assert re_arrange_tuples([(4, 3), (1, 9), (2, 10), (3, 2)], [1, 4, 2, 3]) == [(1, 9), (4, 3), (2, 10), (3, 2)]",
"assert re_arrange_tuples([(5, 4), (2, 10), (3, 11), (4, 3)], [3, 4, 2, 3]) == [(3, 11), (4, 3), (2, 10), (3, 11)]",
"assert re_arrange_tuples([(6, 3), (3, 8), (5, 7), (2, 4)], [2, 5, 3, 6]) == [... | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ASSIGN_NAME_STORE_CALL_NAME_LOAD_NAME_LOAD_ASSIGN_NAME_STORE_LISTCOMP_TUPLE_NAME_LOAD_SUBSCRIPT_NAME_LOAD_NAME_LOAD_LOAD_LOAD_COMPREHENSION_NAME_STORE_NAME_LOAD_RETURN_NAME_LOAD | [2][SEP1][Return][SEP2][][SEP3][1] |
937 | Write a function to count the most common character in a given string. | from collections import Counter
def max_char(str1):
temp = Counter(str1)
max_char = max(temp, key = temp.get)
return max_char | [
"assert max_char(\"hello world\")==('l')",
"assert max_char(\"hello \")==('l')",
"assert max_char(\"python pr\")==('p')"
] | MODULE_IMPORTFROM_ALIAS_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CALL_NAME_LOAD_NAME_LOAD_ASSIGN_NAME_STORE_CALL_NAME_LOAD_NAME_LOAD_KEYWORD_ATTRIBUTE_NAME_LOAD_LOAD_RETURN_NAME_LOAD | [1][SEP1][Return][SEP2][][SEP3][2] |
938 | Write a function to find three closest elements from three sorted arrays. | import sys
def find_closet(A, B, C, p, q, r):
diff = sys.maxsize
res_i = 0
res_j = 0
res_k = 0
i = 0
j = 0
k = 0
while(i < p and j < q and k < r):
minimum = min(A[i], min(B[j], C[k]))
maximum = max(A[i], max(B[j], C[k]));
if maximum-minimum < diff:
res_i = i
res_j = j
re... | [
"assert find_closet([1, 4, 10],[2, 15, 20],[10, 12],3,3,2) == (10, 15, 10)",
"assert find_closet([20, 24, 100],[2, 19, 22, 79, 800],[10, 12, 23, 24, 119],3,5,5) == (24, 22, 23)",
"assert find_closet([2, 5, 11],[3, 16, 21],[11, 13],3,3,2) == (11, 16, 11)"
] | MODULE_IMPORT_ALIAS_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ARG_ARG_ARG_ARG_ASSIGN_NAME_STORE_ATTRIBUTE_NAME_LOAD_LOAD_ASSIGN_NAME_STORE_CONSTANT_ASSIGN_NAME_STORE_CONSTANT_ASSIGN_NAME_STORE_CONSTANT_ASSIGN_NAME_STORE_CONSTANT_ASSIGN_NAME_STORE_CONSTANT_ASSIGN_NAME_STORE_CONSTANT_WHILE_BOOLOP_AND_COMPARE_NAME_LOAD_LT_NAME_LOAD_C... | [6][SEP1][None][While][If][Return][None][If][If][None][If][None][None][SEP2][1][2,3][4,5][][5][6,3][7,8][1][9,10][1][1][SEP3][0][0][4][0][0][0][0][0][0][0][0] |
939 | Write a function to sort a list of dictionaries using lambda function. | def sorted_models(models):
sorted_models = sorted(models, key = lambda x: x['color'])
return sorted_models | [
"assert sorted_models([{'make':'Nokia', 'model':216, 'color':'Black'}, {'make':'Mi Max', 'model':2, 'color':'Gold'}, {'make':'Samsung', 'model': 7, 'color':'Blue'}])==[{'make': 'Nokia', 'model': 216, 'color': 'Black'}, {'make': 'Samsung', 'model': 7, 'color': 'Blue'}, {'make': 'Mi Max', 'model': 2, 'color': 'Gold'}... | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CALL_NAME_LOAD_NAME_LOAD_KEYWORD_LAMBDA_ARGUMENTS_ARG_SUBSCRIPT_NAME_LOAD_CONSTANT_LOAD_RETURN_NAME_LOAD | [1][SEP1][Return][SEP2][][SEP3][1] |
941 | Write a function to count the elements in a list until an element is a tuple. | def count_elim(num):
count_elim = 0
for n in num:
if isinstance(n, tuple):
break
count_elim += 1
return count_elim | [
"assert count_elim([10,20,30,(10,20),40])==3",
"assert count_elim([10,(20,30),(10,20),40])==1",
"assert count_elim([(10,(20,30,(10,20),40))])==0"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CONSTANT_FOR_NAME_STORE_NAME_LOAD_IF_CALL_NAME_LOAD_NAME_LOAD_NAME_LOAD_BREAK_AUGASSIGN_NAME_STORE_ADD_CONSTANT_RETURN_NAME_LOAD | [1][SEP1][None][For][If][Return][None][SEP2][1][2,3][4,3][][1][SEP3][0][0][1][0][0] |
942 | Write a function to check if any list element is present in the given list. | def check_element(test_tup, check_list):
res = False
for ele in check_list:
if ele in test_tup:
res = True
break
return (res) | [
"assert check_element((4, 5, 7, 9, 3), [6, 7, 10, 11]) == True",
"assert check_element((1, 2, 3, 4), [4, 6, 7, 8, 9]) == True",
"assert check_element((3, 2, 1, 4, 5), [9, 8, 7, 6]) == False"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ASSIGN_NAME_STORE_CONSTANT_FOR_NAME_STORE_NAME_LOAD_IF_COMPARE_NAME_LOAD_IN_NAME_LOAD_ASSIGN_NAME_STORE_CONSTANT_BREAK_RETURN_NAME_LOAD | [2][SEP1][None][For][If][Return][None][SEP2][1][2,3][4,1][][3][SEP3][0][0][0][0][0] |
943 | Write a function to combine two given sorted lists using heapq module. | from heapq import merge
def combine_lists(num1,num2):
combine_lists=list(merge(num1, num2))
return combine_lists | [
"assert combine_lists([1, 3, 5, 7, 9, 11],[0, 2, 4, 6, 8, 10])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]",
"assert combine_lists([1, 3, 5, 6, 8, 9], [2, 5, 7, 11])==[1,2,3,5,5,6,7,8,9,11]",
"assert combine_lists([1,3,7],[2,4,6])==[1,2,3,4,6,7]"
] | MODULE_IMPORTFROM_ALIAS_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ASSIGN_NAME_STORE_CALL_NAME_LOAD_CALL_NAME_LOAD_NAME_LOAD_NAME_LOAD_RETURN_NAME_LOAD | [2][SEP1][Return][SEP2][][SEP3][2] |
944 | Write a function to separate and print the numbers and their position of a given string. | import re
def num_position(text):
for m in re.finditer("\d+", text):
return m.start() | [
"assert num_position(\"there are 70 flats in this apartment\")==10",
"assert num_position(\"every adult have 32 teeth\")==17",
"assert num_position(\"isha has 79 chocolates in her bag\")==9"
] | MODULE_IMPORT_ALIAS_FUNCTIONDEF_ARGUMENTS_ARG_FOR_NAME_STORE_CALL_ATTRIBUTE_NAME_LOAD_LOAD_CONSTANT_NAME_LOAD_RETURN_CALL_ATTRIBUTE_NAME_LOAD_LOAD | [1][SEP1][For][Return][SEP2][1][][SEP3][1][1] |
945 | Write a function to convert the given tuples into set. | def tuple_to_set(t):
s = set(t)
return (s) | [
"assert tuple_to_set(('x', 'y', 'z') ) == {'y', 'x', 'z'}",
"assert tuple_to_set(('a', 'b', 'c') ) == {'c', 'a', 'b'}",
"assert tuple_to_set(('z', 'd', 'e') ) == {'d', 'e', 'z'}"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CALL_NAME_LOAD_NAME_LOAD_RETURN_NAME_LOAD | [1][SEP1][Return][SEP2][][SEP3][1] |
946 | Write a function to find the most common elements and their counts of a specified text. | from collections import Counter
def most_common_elem(s,a):
most_common_elem=Counter(s).most_common(a)
return most_common_elem | [
"assert most_common_elem('lkseropewdssafsdfafkpwe',3)==[('s', 4), ('e', 3), ('f', 3)] ",
"assert most_common_elem('lkseropewdssafsdfafkpwe',2)==[('s', 4), ('e', 3)]",
"assert most_common_elem('lkseropewdssafsdfafkpwe',7)==[('s', 4), ('e', 3), ('f', 3), ('k', 2), ('p', 2), ('w', 2), ('d', 2)]"
] | MODULE_IMPORTFROM_ALIAS_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ASSIGN_NAME_STORE_CALL_ATTRIBUTE_CALL_NAME_LOAD_NAME_LOAD_LOAD_NAME_LOAD_RETURN_NAME_LOAD | [2][SEP1][Return][SEP2][][SEP3][2] |
947 | Write a python function to find the length of the shortest word. | def len_log(list1):
min=len(list1[0])
for i in list1:
if len(i)<min:
min=len(i)
return min | [
"assert len_log([\"win\",\"lose\",\"great\"]) == 3",
"assert len_log([\"a\",\"ab\",\"abc\"]) == 1",
"assert len_log([\"12\",\"12\",\"1234\"]) == 2"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CALL_NAME_LOAD_SUBSCRIPT_NAME_LOAD_CONSTANT_LOAD_FOR_NAME_STORE_NAME_LOAD_IF_COMPARE_CALL_NAME_LOAD_NAME_LOAD_LT_NAME_LOAD_ASSIGN_NAME_STORE_CALL_NAME_LOAD_NAME_LOAD_RETURN_NAME_LOAD | [1][SEP1][None][For][If][Return][None][SEP2][1][2,3][4,1][][1][SEP3][1][0][1][0][1] |
948 | Write a function to get an item of a tuple. | def get_item(tup1,index):
item = tup1[index]
return item | [
"assert get_item((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),3)==('e')",
"assert get_item((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),-4)==('u')",
"assert get_item((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),-3)==('r')"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ASSIGN_NAME_STORE_SUBSCRIPT_NAME_LOAD_NAME_LOAD_LOAD_RETURN_NAME_LOAD | [2][SEP1][Return][SEP2][][SEP3][0] |
950 | Write a function to display sign of the chinese zodiac for given year. | def chinese_zodiac(year):
if (year - 2000) % 12 == 0:
sign = 'Dragon'
elif (year - 2000) % 12 == 1:
sign = 'Snake'
elif (year - 2000) % 12 == 2:
sign = 'Horse'
elif (year - 2000) % 12 == 3:
sign = 'sheep'
elif (year - 2000) % 12 == 4:
sign = 'Monkey'
elif (year - 2000) % 12 == ... | [
"assert chinese_zodiac(1997)==('Ox')",
"assert chinese_zodiac(1998)==('Tiger')",
"assert chinese_zodiac(1994)==('Dog')"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_IF_COMPARE_BINOP_BINOP_NAME_LOAD_SUB_CONSTANT_MOD_CONSTANT_EQ_CONSTANT_ASSIGN_NAME_STORE_CONSTANT_IF_COMPARE_BINOP_BINOP_NAME_LOAD_SUB_CONSTANT_MOD_CONSTANT_EQ_CONSTANT_ASSIGN_NAME_STORE_CONSTANT_IF_COMPARE_BINOP_BINOP_NAME_LOAD_SUB_CONSTANT_MOD_CONSTANT_EQ_CONSTANT_ASSIGN_NAME_STORE_CO... | [1][SEP1][If][None][If][Return][None][If][None][If][None][If][None][If][None][If][None][If][None][If][None][If][None][If][None][None][SEP2][1,2][3][4,5][][3][6,7][3][8,9][3][10,11][3][12,13][3][14,15][3][16,17][3][18,19][3][20,21][3][22,23][3][3][SEP3][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0... |
951 | Write a function to find the maximum of similar indices in two lists of tuples. | def max_similar_indices(test_list1, test_list2):
res = [(max(x[0], y[0]), max(x[1], y[1]))
for x, y in zip(test_list1, test_list2)]
return (res) | [
"assert max_similar_indices([(2, 4), (6, 7), (5, 1)],[(5, 4), (8, 10), (8, 14)]) == [(5, 4), (8, 10), (8, 14)]",
"assert max_similar_indices([(3, 5), (7, 8), (6, 2)],[(6, 5), (9, 11), (9, 15)]) == [(6, 5), (9, 11), (9, 15)]",
"assert max_similar_indices([(4, 6), (8, 9), (7, 3)],[(7, 6), (10, 12), (10, 16)]) == ... | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ASSIGN_NAME_STORE_LISTCOMP_TUPLE_CALL_NAME_LOAD_SUBSCRIPT_NAME_LOAD_CONSTANT_LOAD_SUBSCRIPT_NAME_LOAD_CONSTANT_LOAD_CALL_NAME_LOAD_SUBSCRIPT_NAME_LOAD_CONSTANT_LOAD_SUBSCRIPT_NAME_LOAD_CONSTANT_LOAD_LOAD_COMPREHENSION_TUPLE_NAME_STORE_NAME_STORE_STORE_CALL_NAME_LOAD_NAME_LOAD_NAME_L... | [2][SEP1][Return][SEP2][][SEP3][3] |
952 | Write a function to compute the value of ncr mod p. | def nCr_mod_p(n, r, p):
if (r > n- r):
r = n - r
C = [0 for i in range(r + 1)]
C[0] = 1
for i in range(1, n + 1):
for j in range(min(i, r), 0, -1):
C[j] = (C[j] + C[j-1]) % p
return C[r] | [
"assert nCr_mod_p(10, 2, 13) == 6",
"assert nCr_mod_p(11, 3, 14) == 11",
"assert nCr_mod_p(18, 14, 19) == 1"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ARG_IF_COMPARE_NAME_LOAD_GT_BINOP_NAME_LOAD_SUB_NAME_LOAD_ASSIGN_NAME_STORE_BINOP_NAME_LOAD_SUB_NAME_LOAD_ASSIGN_NAME_STORE_LISTCOMP_CONSTANT_COMPREHENSION_NAME_STORE_CALL_NAME_LOAD_BINOP_NAME_LOAD_ADD_CONSTANT_ASSIGN_SUBSCRIPT_NAME_LOAD_CONSTANT_STORE_CONSTANT_FOR_NAME_STORE_CALL_N... | [3][SEP1][If][None][None][For][For][Return][None][SEP2][1,2][2][3][4,5][6,3][][4][SEP3][0][0][1][1][2][0][0] |
953 | Write a python function to find the minimun number of subsets with distinct elements. | def subset(ar, n):
res = 0
ar.sort()
for i in range(0, n) :
count = 1
for i in range(n - 1):
if ar[i] == ar[i + 1]:
count+=1
else:
break
res = max(res, count)
return res | [
"assert subset([1, 2, 3, 4],4) == 1",
"assert subset([5, 6, 9, 3, 4, 3, 4],7) == 2",
"assert subset([1, 2, 3 ],3) == 1"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ASSIGN_NAME_STORE_CONSTANT_EXPR_CALL_ATTRIBUTE_NAME_LOAD_LOAD_FOR_NAME_STORE_CALL_NAME_LOAD_CONSTANT_NAME_LOAD_ASSIGN_NAME_STORE_CONSTANT_FOR_NAME_STORE_CALL_NAME_LOAD_BINOP_NAME_LOAD_SUB_CONSTANT_IF_COMPARE_SUBSCRIPT_NAME_LOAD_NAME_LOAD_LOAD_EQ_SUBSCRIPT_NAME_LOAD_BINOP_NAME_LOAD_A... | [2][SEP1][None][For][None][Return][For][If][None][None][SEP2][1][2,3][4][][5,6][7,6][1][4][SEP3][1][3][0][0][1][0][1][0] |
954 | Write a function that gives profit amount if the given amount has profit else return none. | def profit_amount(actual_cost,sale_amount):
if(actual_cost > sale_amount):
amount = actual_cost - sale_amount
return amount
else:
return None | [
"assert profit_amount(1500,1200)==300",
"assert profit_amount(100,200)==None",
"assert profit_amount(2000,5000)==None"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_IF_COMPARE_NAME_LOAD_GT_NAME_LOAD_ASSIGN_NAME_STORE_BINOP_NAME_LOAD_SUB_NAME_LOAD_RETURN_NAME_LOAD_RETURN_CONSTANT | [2][SEP1][If][Return][Return][SEP2][1,2][][][SEP3][0][0][0] |
955 | Write a function to find out, if the given number is abundant. | def is_abundant(n):
fctrsum = sum([fctr for fctr in range(1, n) if n % fctr == 0])
return fctrsum > n | [
"assert is_abundant(12)==True",
"assert is_abundant(13)==False",
"assert is_abundant(9)==False"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CALL_NAME_LOAD_LISTCOMP_NAME_LOAD_COMPREHENSION_NAME_STORE_CALL_NAME_LOAD_CONSTANT_NAME_LOAD_COMPARE_BINOP_NAME_LOAD_MOD_NAME_LOAD_EQ_CONSTANT_RETURN_COMPARE_NAME_LOAD_GT_NAME_LOAD | [1][SEP1][Return][SEP2][][SEP3][2] |
957 | Write a python function to get the position of rightmost set bit. | import math
def get_First_Set_Bit_Pos(n):
return math.log2(n&-n)+1 | [
"assert get_First_Set_Bit_Pos(12) == 3",
"assert get_First_Set_Bit_Pos(18) == 2",
"assert get_First_Set_Bit_Pos(16) == 5"
] | MODULE_IMPORT_ALIAS_FUNCTIONDEF_ARGUMENTS_ARG_RETURN_BINOP_CALL_ATTRIBUTE_NAME_LOAD_LOAD_BINOP_NAME_LOAD_BITAND_UNARYOP_USUB_NAME_LOAD_ADD_CONSTANT | [1][SEP1][Return][SEP2][][SEP3][1] |
958 | Write a function to convert an integer into a roman numeral. | def int_to_roman( num):
val = [1000, 900, 500, 400,100, 90, 50, 40,10, 9, 5, 4,1]
syb = ["M", "CM", "D", "CD","C", "XC", "L", "XL","X", "IX", "V", "IV","I"]
roman_num = ''
i = 0
while num > 0:
for _ in range(num // val[i]):
roman_num += syb[i]
... | [
"assert int_to_roman(1)==(\"I\")",
"assert int_to_roman(50)==(\"L\")",
"assert int_to_roman(4)==(\"IV\")"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_LIST_CONSTANT_CONSTANT_CONSTANT_CONSTANT_CONSTANT_CONSTANT_CONSTANT_CONSTANT_CONSTANT_CONSTANT_CONSTANT_CONSTANT_CONSTANT_LOAD_ASSIGN_NAME_STORE_LIST_CONSTANT_CONSTANT_CONSTANT_CONSTANT_CONSTANT_CONSTANT_CONSTANT_CONSTANT_CONSTANT_CONSTANT_CONSTANT_CONSTANT_CONSTANT_LO... | [1][SEP1][None][While][For][Return][None][None][SEP2][1][2,3][4,5][][2][1][SEP3][0][0][1][0][0][0] |
959 | Write a python function to find the average of a list. | def Average(lst):
return sum(lst) / len(lst) | [
"assert Average([15, 9, 55, 41, 35, 20, 62, 49]) == 35.75",
"assert Average([4, 5, 1, 2, 9, 7, 10, 8]) == 5.75",
"assert Average([1,2,3]) == 2"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_RETURN_BINOP_CALL_NAME_LOAD_NAME_LOAD_DIV_CALL_NAME_LOAD_NAME_LOAD | [1][SEP1][Return][SEP2][][SEP3][2] |
960 | Write a function to solve tiling problem. | def get_noOfways(n):
if (n == 0):
return 0;
if (n == 1):
return 1;
return get_noOfways(n - 1) + get_noOfways(n - 2); | [
"assert get_noOfways(4)==3",
"assert get_noOfways(3)==2",
"assert get_noOfways(5)==5"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_IF_COMPARE_NAME_LOAD_EQ_CONSTANT_RETURN_CONSTANT_IF_COMPARE_NAME_LOAD_EQ_CONSTANT_RETURN_CONSTANT_RETURN_BINOP_CALL_NAME_LOAD_BINOP_NAME_LOAD_SUB_CONSTANT_ADD_CALL_NAME_LOAD_BINOP_NAME_LOAD_SUB_CONSTANT | [1][SEP1][If][Return][If][Return][Return][SEP2][1,2][][3,4][][][SEP3][0][0][0][0][2] |
964 | Write a python function to check whether the length of the word is even or not. | def word_len(s):
s = s.split(' ')
for word in s:
if len(word)%2==0:
return True
else:
return False | [
"assert word_len(\"program\") == False",
"assert word_len(\"solution\") == True",
"assert word_len(\"data\") == True"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CALL_ATTRIBUTE_NAME_LOAD_LOAD_CONSTANT_FOR_NAME_STORE_NAME_LOAD_IF_COMPARE_BINOP_CALL_NAME_LOAD_NAME_LOAD_MOD_CONSTANT_EQ_CONSTANT_RETURN_CONSTANT_RETURN_CONSTANT | [1][SEP1][None][For][If][Return][Return][SEP2][1][2][3,4][][][SEP3][1][0][1][0][0] |
965 | Write a function to convert camel case string to snake case string. | def camel_to_snake(text):
import re
str1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', text)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', str1).lower() | [
"assert camel_to_snake('PythonProgram')==('python_program')",
"assert camel_to_snake('pythonLanguage')==('python_language')",
"assert camel_to_snake('ProgrammingLanguage')==('programming_language')"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_IMPORT_ALIAS_ASSIGN_NAME_STORE_CALL_ATTRIBUTE_NAME_LOAD_LOAD_CONSTANT_CONSTANT_NAME_LOAD_RETURN_CALL_ATTRIBUTE_CALL_ATTRIBUTE_NAME_LOAD_LOAD_CONSTANT_CONSTANT_NAME_LOAD_LOAD | [1][SEP1][Return][SEP2][][SEP3][3] |
966 | Write a function to remove an empty tuple from a list of tuples. | def remove_empty(tuple1): #L = [(), (), ('',), ('a', 'b'), ('a', 'b', 'c'), ('d')]
tuple1 = [t for t in tuple1 if t]
return tuple1 | [
"assert remove_empty([(), (), ('',), ('a', 'b'), ('a', 'b', 'c'), ('d')])==[('',), ('a', 'b'), ('a', 'b', 'c'), 'd'] ",
"assert remove_empty([(), (), ('',), (\"python\"), (\"program\")])==[('',), (\"python\"), (\"program\")] ",
"assert remove_empty([(), (), ('',), (\"java\")])==[('',),(\"java\") ] "
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_LISTCOMP_NAME_LOAD_COMPREHENSION_NAME_STORE_NAME_LOAD_NAME_LOAD_RETURN_NAME_LOAD | [1][SEP1][Return][SEP2][][SEP3][0] |
967 | Write a python function to accept the strings which contains all vowels. | def check(string):
if len(set(string).intersection("AEIOUaeiou"))>=5:
return ('accepted')
else:
return ("not accepted") | [
"assert check(\"SEEquoiaL\") == 'accepted'",
"assert check('program') == \"not accepted\"",
"assert check('fine') == \"not accepted\""
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_IF_COMPARE_CALL_NAME_LOAD_CALL_ATTRIBUTE_CALL_NAME_LOAD_NAME_LOAD_LOAD_CONSTANT_GTE_CONSTANT_RETURN_CONSTANT_RETURN_CONSTANT | [1][SEP1][If][Return][Return][SEP2][1,2][][][SEP3][3][0][0] |
969 | Write a function to join the tuples if they have similar initial elements. | def join_tuples(test_list):
res = []
for sub in test_list:
if res and res[-1][0] == sub[0]:
res[-1].extend(sub[1:])
else:
res.append([ele for ele in sub])
res = list(map(tuple, res))
return (res) | [
"assert join_tuples([(5, 6), (5, 7), (6, 8), (6, 10), (7, 13)] ) == [(5, 6, 7), (6, 8, 10), (7, 13)]",
"assert join_tuples([(6, 7), (6, 8), (7, 9), (7, 11), (8, 14)] ) == [(6, 7, 8), (7, 9, 11), (8, 14)]",
"assert join_tuples([(7, 8), (7, 9), (8, 10), (8, 12), (9, 15)] ) == [(7, 8, 9), (8, 10, 12), (9, 15)]"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_LIST_LOAD_FOR_NAME_STORE_NAME_LOAD_IF_BOOLOP_AND_NAME_LOAD_COMPARE_SUBSCRIPT_SUBSCRIPT_NAME_LOAD_UNARYOP_USUB_CONSTANT_LOAD_CONSTANT_LOAD_EQ_SUBSCRIPT_NAME_LOAD_CONSTANT_LOAD_EXPR_CALL_ATTRIBUTE_SUBSCRIPT_NAME_LOAD_UNARYOP_USUB_CONSTANT_LOAD_LOAD_SUBSCRIPT_NAME_LOAD_SL... | [1][SEP1][None][For][If][Return][None][None][SEP2][1][2,3][4,5][][1][1][SEP3][0][0][0][2][1][1] |
970 | Write a function to find minimum of two numbers. | def min_of_two( x, y ):
if x < y:
return x
return y | [
"assert min_of_two(10,20)==10",
"assert min_of_two(19,15)==15",
"assert min_of_two(-10,-20)==-20"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_IF_COMPARE_NAME_LOAD_LT_NAME_LOAD_RETURN_NAME_LOAD_RETURN_NAME_LOAD | [2][SEP1][If][Return][Return][SEP2][1,2][][][SEP3][0][0][0] |
972 | Write a function to concatenate the given two tuples to a nested tuple. | def concatenate_nested(test_tup1, test_tup2):
res = test_tup1 + test_tup2
return (res) | [
"assert concatenate_nested((3, 4), (5, 6)) == (3, 4, 5, 6)",
"assert concatenate_nested((1, 2), (3, 4)) == (1, 2, 3, 4)",
"assert concatenate_nested((4, 5), (6, 8)) == (4, 5, 6, 8)"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ASSIGN_NAME_STORE_BINOP_NAME_LOAD_ADD_NAME_LOAD_RETURN_NAME_LOAD | [2][SEP1][Return][SEP2][][SEP3][0] |
973 | Write a python function to left rotate the string. | def left_rotate(s,d):
tmp = s[d : ] + s[0 : d]
return tmp | [
"assert left_rotate(\"python\",2) == \"thonpy\" ",
"assert left_rotate(\"bigdata\",3 ) == \"databig\" ",
"assert left_rotate(\"hadoop\",1 ) == \"adooph\" "
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ASSIGN_NAME_STORE_BINOP_SUBSCRIPT_NAME_LOAD_SLICE_NAME_LOAD_LOAD_ADD_SUBSCRIPT_NAME_LOAD_SLICE_CONSTANT_NAME_LOAD_LOAD_RETURN_NAME_LOAD | [2][SEP1][Return][SEP2][][SEP3][0] |
11 | Write a python function to remove first and last occurrence of a given character from the string. | def remove_Occ(s,ch):
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):
s = s[0 : i] + s[i + 1:]
break
return s | [
"assert remove_Occ(\"hello\",\"l\") == \"heo\"",
"assert remove_Occ(\"abcda\",\"a\") == \"bcd\"",
"assert remove_Occ(\"PHP\",\"P\") == \"H\""
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_FOR_NAME_STORE_CALL_NAME_LOAD_CALL_NAME_LOAD_NAME_LOAD_IF_COMPARE_SUBSCRIPT_NAME_LOAD_NAME_LOAD_LOAD_EQ_NAME_LOAD_ASSIGN_NAME_STORE_BINOP_SUBSCRIPT_NAME_LOAD_SLICE_CONSTANT_NAME_LOAD_LOAD_ADD_SUBSCRIPT_NAME_LOAD_SLICE_BINOP_NAME_LOAD_ADD_CONSTANT_LOAD_BREAK_FOR_NAME_STORE_CALL_NAME_... | [2][SEP1][For][If][For][None][If][Return][None][SEP2][1,2][3,0][4,5][2][6,2][][5][SEP3][2][0][2][0][0][0][0] |
12 | Write a function to sort a given matrix in ascending order according to the sum of its rows. | def sort_matrix(M):
result = sorted(M, key=sum)
return result | [
"assert sort_matrix([[1, 2, 3], [2, 4, 5], [1, 1, 1]])==[[1, 1, 1], [1, 2, 3], [2, 4, 5]]",
"assert sort_matrix([[1, 2, 3], [-2, 4, -5], [1, -1, 1]])==[[-2, 4, -5], [1, -1, 1], [1, 2, 3]]",
"assert sort_matrix([[5,8,9],[6,4,3],[2,1,4]])==[[2, 1, 4], [6, 4, 3], [5, 8, 9]]"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CALL_NAME_LOAD_NAME_LOAD_KEYWORD_NAME_LOAD_RETURN_NAME_LOAD | [1][SEP1][Return][SEP2][][SEP3][1] |
13 | Write a function to count the most common words in a dictionary. | from collections import Counter
def count_common(words):
word_counts = Counter(words)
top_four = word_counts.most_common(4)
return (top_four)
| [
"assert count_common(['red','green','black','pink','black','white','black','eyes','white','black','orange','pink','pink','red','red','white','orange','white',\"black\",'pink','green','green','pink','green','pink','white','orange',\"orange\",'red']) == [('pink', 6), ('black', 5), ('white', 5), ('red', 4)]",
"asser... | MODULE_IMPORTFROM_ALIAS_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CALL_NAME_LOAD_NAME_LOAD_ASSIGN_NAME_STORE_CALL_ATTRIBUTE_NAME_LOAD_LOAD_CONSTANT_RETURN_NAME_LOAD | [1][SEP1][Return][SEP2][][SEP3][2] |
16 | Write a function to find sequences of lowercase letters joined with an underscore. | import re
def text_lowercase_underscore(text):
patterns = '^[a-z]+_[a-z]+$'
if re.search(patterns, text):
return 'Found a match!'
else:
return('Not matched!') | [
"assert text_lowercase_underscore(\"aab_cbbbc\")==('Found a match!')",
"assert text_lowercase_underscore(\"aab_Abbbc\")==('Not matched!')",
"assert text_lowercase_underscore(\"Aaab_abbbc\")==('Not matched!')"
] | MODULE_IMPORT_ALIAS_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CONSTANT_IF_CALL_ATTRIBUTE_NAME_LOAD_LOAD_NAME_LOAD_NAME_LOAD_RETURN_CONSTANT_RETURN_CONSTANT | [1][SEP1][If][Return][Return][SEP2][1,2][][][SEP3][1][0][0] |
19 | Write a function to find whether a given array of integers contains any duplicate element. | def test_duplicate(arraynums):
nums_set = set(arraynums)
return len(arraynums) != len(nums_set) | [
"assert test_duplicate(([1,2,3,4,5]))==False",
"assert test_duplicate(([1,2,3,4, 4]))==True",
"assert test_duplicate([1,1,2,2,3,3,4,4,5])==True"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CALL_NAME_LOAD_NAME_LOAD_RETURN_COMPARE_CALL_NAME_LOAD_NAME_LOAD_NOTEQ_CALL_NAME_LOAD_NAME_LOAD | [1][SEP1][Return][SEP2][][SEP3][3] |
20 | Write a function to check if the given number is woodball or not. | def is_woodall(x):
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 False | [
"assert is_woodall(383) == True",
"assert is_woodall(254) == False",
"assert is_woodall(200) == False"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_IF_COMPARE_BINOP_NAME_LOAD_MOD_CONSTANT_EQ_CONSTANT_RETURN_CONSTANT_IF_COMPARE_NAME_LOAD_EQ_CONSTANT_RETURN_CONSTANT_ASSIGN_NAME_STORE_BINOP_NAME_LOAD_ADD_CONSTANT_ASSIGN_NAME_STORE_CONSTANT_WHILE_COMPARE_BINOP_NAME_LOAD_MOD_CONSTANT_EQ_CONSTANT_ASSIGN_NAME_STORE_BINOP_NAME_LOAD_DIV_CON... | [1][SEP1][If][Return][If][Return][None][While][If][Return][Return][SEP2][1,2][][3,4][][5][6,7][8,5][][][SEP3][0][0][0][0][0][0][0][0][0] |
22 | Write a function to find the first duplicate element in a given array of integers. | def find_first_duplicate(nums):
num_set = set()
no_duplicate = -1
for i in range(len(nums)):
if nums[i] in num_set:
return nums[i]
else:
num_set.add(nums[i])
return no_duplicate | [
"assert find_first_duplicate(([1, 2, 3, 4, 4, 5]))==4",
"assert find_first_duplicate([1, 2, 3, 4])==-1",
"assert find_first_duplicate([1, 1, 2, 3, 3, 2, 2])==1"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CALL_NAME_LOAD_ASSIGN_NAME_STORE_UNARYOP_USUB_CONSTANT_FOR_NAME_STORE_CALL_NAME_LOAD_CALL_NAME_LOAD_NAME_LOAD_IF_COMPARE_SUBSCRIPT_NAME_LOAD_NAME_LOAD_LOAD_IN_NAME_LOAD_RETURN_SUBSCRIPT_NAME_LOAD_NAME_LOAD_LOAD_EXPR_CALL_ATTRIBUTE_NAME_LOAD_LOAD_SUBSCRIPT_NAME_LOAD_NAM... | [1][SEP1][None][For][If][Return][Return][None][SEP2][1][2,3][4,5][][][1][SEP3][1][2][0][0][0][1] |
23 | Write a python function to find the maximum sum of elements of list in a list of lists. | def maximum_Sum(list1):
maxi = -100000
for x in list1:
sum = 0
for y in x:
sum+= y
maxi = max(sum,maxi)
return maxi | [
"assert maximum_Sum([[1,2,3],[4,5,6],[10,11,12],[7,8,9]]) == 33",
"assert maximum_Sum([[0,1,1],[1,1,2],[3,2,1]]) == 6",
"assert maximum_Sum([[0,1,3],[1,2,1],[9,8,2],[0,1,0],[6,4,8]]) == 19"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_UNARYOP_USUB_CONSTANT_FOR_NAME_STORE_NAME_LOAD_ASSIGN_NAME_STORE_CONSTANT_FOR_NAME_STORE_NAME_LOAD_AUGASSIGN_NAME_STORE_ADD_NAME_LOAD_ASSIGN_NAME_STORE_CALL_NAME_LOAD_NAME_LOAD_NAME_LOAD_RETURN_NAME_LOAD | [1][SEP1][None][For][None][Return][For][None][None][SEP2][1][2,3][4][][5,6][4][1][SEP3][0][1][0][0][0][0][1] |
26 | Write a function to check if the given tuple list has all k elements. | def check_k_elements(test_list, K):
res = True
for tup in test_list:
for ele in tup:
if ele != K:
res = False
return (res) | [
"assert check_k_elements([(4, 4), (4, 4, 4), (4, 4), (4, 4, 4, 4), (4, )], 4) == True",
"assert check_k_elements([(7, 7, 7), (7, 7)], 7) == True",
"assert check_k_elements([(9, 9), (9, 9, 9, 9)], 7) == False"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ASSIGN_NAME_STORE_CONSTANT_FOR_NAME_STORE_NAME_LOAD_FOR_NAME_STORE_NAME_LOAD_IF_COMPARE_NAME_LOAD_NOTEQ_NAME_LOAD_ASSIGN_NAME_STORE_CONSTANT_RETURN_NAME_LOAD | [2][SEP1][None][For][For][Return][If][None][SEP2][1][2,3][4,1][][5,2][2][SEP3][0][0][0][0][0][0] |
27 | Write a python function to remove all digits from a list of strings. | import re
def remove(list):
pattern = '[0-9]'
list = [re.sub(pattern, '', i) for i in list]
return list | [
"assert remove(['4words', '3letters', '4digits']) == ['words', 'letters', 'digits']",
"assert remove(['28Jan','12Jan','11Jan']) == ['Jan','Jan','Jan']",
"assert remove(['wonder1','wonder2','wonder3']) == ['wonder','wonder','wonder']"
] | MODULE_IMPORT_ALIAS_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CONSTANT_ASSIGN_NAME_STORE_LISTCOMP_CALL_ATTRIBUTE_NAME_LOAD_LOAD_NAME_LOAD_CONSTANT_NAME_LOAD_COMPREHENSION_NAME_STORE_NAME_LOAD_RETURN_NAME_LOAD | [1][SEP1][Return][SEP2][][SEP3][1] |
28 | Write a python function to find binomial co-efficient. | def binomial_Coeff(n,k):
if k > n :
return 0
if k==0 or k ==n :
return 1
return binomial_Coeff(n-1,k-1) + binomial_Coeff(n-1,k) | [
"assert binomial_Coeff(5,2) == 10",
"assert binomial_Coeff(4,3) == 4",
"assert binomial_Coeff(3,2) == 3"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_IF_COMPARE_NAME_LOAD_GT_NAME_LOAD_RETURN_CONSTANT_IF_BOOLOP_OR_COMPARE_NAME_LOAD_EQ_CONSTANT_COMPARE_NAME_LOAD_EQ_NAME_LOAD_RETURN_CONSTANT_RETURN_BINOP_CALL_NAME_LOAD_BINOP_NAME_LOAD_SUB_CONSTANT_BINOP_NAME_LOAD_SUB_CONSTANT_ADD_CALL_NAME_LOAD_BINOP_NAME_LOAD_SUB_CONSTANT_NAME_LOAD | [2][SEP1][If][Return][If][Return][Return][SEP2][1,2][][3,4][][][SEP3][0][0][0][0][2] |
29 | Write a python function to find the element occurring odd number of times. | def get_Odd_Occurrence(arr,arr_size):
for i in range(0,arr_size):
count = 0
for j in range(0,arr_size):
if arr[i] == arr[j]:
count+=1
if (count % 2 != 0):
return arr[i]
return -1 | [
"assert get_Odd_Occurrence([1,2,3,1,2,3,1],7) == 1",
"assert get_Odd_Occurrence([1,2,3,2,3,1,3],7) == 3",
"assert get_Odd_Occurrence([2,3,5,4,5,2,4,3,5,2,4,4,2],13) == 5"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_FOR_NAME_STORE_CALL_NAME_LOAD_CONSTANT_NAME_LOAD_ASSIGN_NAME_STORE_CONSTANT_FOR_NAME_STORE_CALL_NAME_LOAD_CONSTANT_NAME_LOAD_IF_COMPARE_SUBSCRIPT_NAME_LOAD_NAME_LOAD_LOAD_EQ_SUBSCRIPT_NAME_LOAD_NAME_LOAD_LOAD_AUGASSIGN_NAME_STORE_ADD_CONSTANT_IF_COMPARE_BINOP_NAME_LOAD_MOD_CONSTANT_... | [2][SEP1][For][None][Return][For][If][If][None][Return][SEP2][1,2][3][][4,5][6,3][7,0][3][][SEP3][2][0][0][1][0][0][0][0] |
31 | Write a function to find the top k integers that occur most frequently from given lists of sorted and distinct integers using heap queue algorithm. | def func(nums, k):
import collections
d = collections.defaultdict(int)
for row in nums:
for i in row:
d[i] += 1
temp = []
import heapq
for key, v in d.items():
if len(temp) < k:
temp.append((v, key))
if len(temp) == k:
... | [
"assert func([[1, 2, 6], [1, 3, 4, 5, 7, 8], [1, 3, 5, 6, 8, 9], [2, 5, 7, 11], [1, 4, 7, 8, 12]],3)==[5, 7, 1]",
"assert func([[1, 2, 6], [1, 3, 4, 5, 7, 8], [1, 3, 5, 6, 8, 9], [2, 5, 7, 11], [1, 4, 7, 8, 12]],1)==[1]",
"assert func([[1, 2, 6], [1, 3, 4, 5, 7, 8], [1, 3, 5, 6, 8, 9], [2, 5, 7, 11], [1, 4, 7, ... | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_IMPORT_ALIAS_ASSIGN_NAME_STORE_CALL_ATTRIBUTE_NAME_LOAD_LOAD_NAME_LOAD_FOR_NAME_STORE_NAME_LOAD_FOR_NAME_STORE_NAME_LOAD_AUGASSIGN_SUBSCRIPT_NAME_LOAD_NAME_LOAD_STORE_ADD_CONSTANT_ASSIGN_NAME_STORE_LIST_LOAD_IMPORT_ALIAS_FOR_TUPLE_NAME_STORE_NAME_STORE_STORE_CALL_ATTRIBUTE_NAME_LOAD... | [2][SEP1][None][For][For][None][None][For][If][None][If][If][While][None][None][None][Return][SEP2][1][2,3][4,1][5][2][6,7][8,9][10][11,5][12,5][13,14][5][5][10][][SEP3][1][0][0][0][0][1][1][0][2][0][0][1][2][2][0] |
32 | Write a python function to find the largest prime factor of a given number. | import math
def max_Prime_Factors (n):
maxPrime = -1
while n%2 == 0:
maxPrime = 2
n >>= 1
for i in range(3,int(math.sqrt(n))+1,2):
while n % i == 0:
maxPrime = i
n = n / i
if n > 2:
maxPrime = n
return int(maxPrime) | [
"assert max_Prime_Factors(15) == 5",
"assert max_Prime_Factors(6) == 3",
"assert max_Prime_Factors(2) == 2"
] | MODULE_IMPORT_ALIAS_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_UNARYOP_USUB_CONSTANT_WHILE_COMPARE_BINOP_NAME_LOAD_MOD_CONSTANT_EQ_CONSTANT_ASSIGN_NAME_STORE_CONSTANT_AUGASSIGN_NAME_STORE_RSHIFT_CONSTANT_FOR_NAME_STORE_CALL_NAME_LOAD_CONSTANT_BINOP_CALL_NAME_LOAD_CALL_ATTRIBUTE_NAME_LOAD_LOAD_NAME_LOAD_ADD_CONSTANT_CO... | [1][SEP1][None][While][None][For][While][If][None][None][Return][SEP2][1][2,3][1][4,5][6,3][7,8][4][8][][SEP3][0][0][0][3][0][0][0][0][1] |
34 | Write a python function to find the missing number in a sorted array. | def find_missing(ar,N):
l = 0
r = N - 1
while (l <= r):
mid = (l + r) / 2
mid= int (mid)
if (ar[mid] != mid + 1 and ar[mid - 1] == mid):
return (mid + 1)
elif (ar[mid] != mid + 1):
r = mid - 1
else:
l = mid + 1
... | [
"assert find_missing([1,2,3,5],4) == 4",
"assert find_missing([1,3,4,5],4) == 2",
"assert find_missing([1,2,3,5,6,7],5) == 4"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_ASSIGN_NAME_STORE_CONSTANT_ASSIGN_NAME_STORE_BINOP_NAME_LOAD_SUB_CONSTANT_WHILE_COMPARE_NAME_LOAD_LTE_NAME_LOAD_ASSIGN_NAME_STORE_BINOP_BINOP_NAME_LOAD_ADD_NAME_LOAD_DIV_CONSTANT_ASSIGN_NAME_STORE_CALL_NAME_LOAD_NAME_LOAD_IF_BOOLOP_AND_COMPARE_SUBSCRIPT_NAME_LOAD_NAME_LOAD_LOAD_NOTE... | [2][SEP1][None][While][If][Return][Return][If][None][None][SEP2][1][2,3][4,5][][][6,7][1][1][SEP3][0][0][1][0][0][0][0][0] |
37 | Write a function to sort a given mixed list of integers and strings. | def sort_mixed_list(mixed_list):
int_part = sorted([i for i in mixed_list if type(i) is int])
str_part = sorted([i for i in mixed_list if type(i) is str])
return int_part + str_part | [
"assert sort_mixed_list([19,'red',12,'green','blue', 10,'white','green',1])==[1, 10, 12, 19, 'blue', 'green', 'green', 'red', 'white']",
"assert sort_mixed_list([19,'red',12,'green','blue', 10,'white','green',1])==[1, 10, 12, 19, 'blue', 'green', 'green', 'red', 'white']",
"assert sort_mixed_list([19,'red',12,'... | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CALL_NAME_LOAD_LISTCOMP_NAME_LOAD_COMPREHENSION_NAME_STORE_NAME_LOAD_COMPARE_CALL_NAME_LOAD_NAME_LOAD_IS_NAME_LOAD_ASSIGN_NAME_STORE_CALL_NAME_LOAD_LISTCOMP_NAME_LOAD_COMPREHENSION_NAME_STORE_NAME_LOAD_COMPARE_CALL_NAME_LOAD_NAME_LOAD_IS_NAME_LOAD_RETURN_BINOP_NAME_LOA... | [1][SEP1][Return][SEP2][][SEP3][4] |
38 | Write a function to find the division of first even and odd number of a given list. | def div_even_odd(list1):
first_even = next((el for el in list1 if el%2==0),-1)
first_odd = next((el for el in list1 if el%2!=0),-1)
return (first_even/first_odd) | [
"assert div_even_odd([1,3,5,7,4,1,6,8])==4",
"assert div_even_odd([1,2,3,4,5,6,7,8,9,10])==2",
"assert div_even_odd([1,5,7,9,10])==10"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CALL_NAME_LOAD_GENERATOREXP_NAME_LOAD_COMPREHENSION_NAME_STORE_NAME_LOAD_COMPARE_BINOP_NAME_LOAD_MOD_CONSTANT_EQ_CONSTANT_UNARYOP_USUB_CONSTANT_ASSIGN_NAME_STORE_CALL_NAME_LOAD_GENERATOREXP_NAME_LOAD_COMPREHENSION_NAME_STORE_NAME_LOAD_COMPARE_BINOP_NAME_LOAD_MOD_CONSTA... | [1][SEP1][Return][SEP2][][SEP3][2] |
40 | Write a function to find frequency of the elements in a given list of lists using collections module. | from collections import Counter
from itertools import chain
def freq_element(nums):
result = Counter(chain.from_iterable(nums))
return result | [
"assert freq_element([[1, 2, 3, 2], [4, 5, 6, 2], [7, 1, 9, 5]])==({2: 3, 1: 2, 5: 2, 3: 1, 4: 1, 6: 1, 7: 1, 9: 1})",
"assert freq_element([[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})",
"assert freq_element([[15,20,30,40],[80,90,100,110],[30... | MODULE_IMPORTFROM_ALIAS_IMPORTFROM_ALIAS_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CALL_NAME_LOAD_CALL_ATTRIBUTE_NAME_LOAD_LOAD_NAME_LOAD_RETURN_NAME_LOAD | [1][SEP1][Return][SEP2][][SEP3][2] |
41 | Write a function to filter even numbers using lambda function. | def filter_evennumbers(nums):
even_nums = list(filter(lambda x: x%2 == 0, nums))
return even_nums | [
"assert filter_evennumbers([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[2, 4, 6, 8, 10]",
"assert filter_evennumbers([10,20,45,67,84,93])==[10,20,84]",
"assert filter_evennumbers([5,7,9,8,6,4,3])==[8,6,4]"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CALL_NAME_LOAD_CALL_NAME_LOAD_LAMBDA_ARGUMENTS_ARG_COMPARE_BINOP_NAME_LOAD_MOD_CONSTANT_EQ_CONSTANT_NAME_LOAD_RETURN_NAME_LOAD | [1][SEP1][Return][SEP2][][SEP3][2] |
42 | Write a python function to find the sum of repeated elements in a given array. | def find_Sum(arr,n):
return sum([x for x in arr if arr.count(x) > 1]) | [
"assert find_Sum([1,2,3,1,1,4,5,6],8) == 3",
"assert find_Sum([1,2,3,1,1],5) == 3",
"assert find_Sum([1,1,2],3) == 2"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ARG_RETURN_CALL_NAME_LOAD_LISTCOMP_NAME_LOAD_COMPREHENSION_NAME_STORE_NAME_LOAD_COMPARE_CALL_ATTRIBUTE_NAME_LOAD_LOAD_NAME_LOAD_GT_CONSTANT | [2][SEP1][Return][SEP2][][SEP3][2] |
43 | Write a function to find sequences of lowercase letters joined with an underscore using regex. | import re
def text_match(text):
patterns = '^[a-z]+_[a-z]+$'
if re.search(patterns, text):
return ('Found a match!')
else:
return ('Not matched!') | [
"assert text_match(\"aab_cbbbc\") == 'Found a match!'",
"assert text_match(\"aab_Abbbc\") == 'Not matched!'",
"assert text_match(\"Aaab_abbbc\") == 'Not matched!'"
] | MODULE_IMPORT_ALIAS_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CONSTANT_IF_CALL_ATTRIBUTE_NAME_LOAD_LOAD_NAME_LOAD_NAME_LOAD_RETURN_CONSTANT_RETURN_CONSTANT | [1][SEP1][If][Return][Return][SEP2][1,2][][][SEP3][1][0][0] |
44 | Write a function that matches a word at the beginning of a string. | import re
def text_match_string(text):
patterns = '^\w+'
if re.search(patterns, text):
return 'Found a match!'
else:
return 'Not matched!' | [
"assert text_match_string(\" python\")==('Not matched!')",
"assert text_match_string(\"python\")==('Found a match!')",
"assert text_match_string(\" lang\")==('Not matched!')"
] | MODULE_IMPORT_ALIAS_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CONSTANT_IF_CALL_ATTRIBUTE_NAME_LOAD_LOAD_NAME_LOAD_NAME_LOAD_RETURN_CONSTANT_RETURN_CONSTANT | [1][SEP1][If][Return][Return][SEP2][1,2][][][SEP3][1][0][0] |
46 | Write a python function to determine whether all the numbers are different from each other are not. | def test_distinct(data):
if len(data) == len(set(data)):
return True
else:
return False; | [
"assert test_distinct([1,5,7,9]) == True",
"assert test_distinct([2,4,5,5,7,9]) == False",
"assert test_distinct([1,2,3]) == True"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_IF_COMPARE_CALL_NAME_LOAD_NAME_LOAD_EQ_CALL_NAME_LOAD_CALL_NAME_LOAD_NAME_LOAD_RETURN_CONSTANT_RETURN_CONSTANT | [1][SEP1][If][Return][Return][SEP2][1,2][][][SEP3][3][0][0] |
48 | Write a python function to set all odd bits of a given number. | def odd_bit_set_number(n):
count = 0;res = 0;temp = n
while temp > 0:
if count % 2 == 0:
res |= (1 << count)
count += 1
temp >>= 1
return (n | res) | [
"assert odd_bit_set_number(10) == 15",
"assert odd_bit_set_number(20) == 21",
"assert odd_bit_set_number(30) == 31"
] | MODULE_FUNCTIONDEF_ARGUMENTS_ARG_ASSIGN_NAME_STORE_CONSTANT_ASSIGN_NAME_STORE_CONSTANT_ASSIGN_NAME_STORE_NAME_LOAD_WHILE_COMPARE_NAME_LOAD_GT_CONSTANT_IF_COMPARE_BINOP_NAME_LOAD_MOD_CONSTANT_EQ_CONSTANT_AUGASSIGN_NAME_STORE_BITOR_BINOP_CONSTANT_LSHIFT_NAME_LOAD_AUGASSIGN_NAME_STORE_ADD_CONSTANT_AUGASSIGN_NAME_STORE_RSH... | [1][SEP1][None][While][If][Return][None][None][SEP2][1][2,3][4,5][][5][1][SEP3][0][0][0][0][0][0] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.