task_id
int64
text
string
code
string
test_list
list
test_setup_code
string
challenge_test_list
list
context
string
context_id
string
context_length_tokens
int64
code_length_chars
int64
389
Write a function to find the n'th lucas number.
def find_lucas(n): if (n == 0): return 2 if (n == 1): return 1 return find_lucas(n - 1) + find_lucas(n - 2)
[ "assert find_lucas(9) == 76", "assert find_lucas(4) == 7", "assert find_lucas(3) == 4" ]
[]
Sandra journeyed to the kitchen. Sandra went back to the bedroom. Daniel went back to the garden. Daniel travelled to the bathroom. John moved to the bathroom. Mary went to the bedroom. Mary travelled to the office. Mary journeyed to the hallway. John went to the bedroom. Daniel moved to the garden. Daniel grabbed the apple there. John travelled to the kitchen. Daniel travelled to the bedroom. John picked up the milk there. Mary moved to the bathroom. John grabbed the football there. Sandra journeyed to the hallway. Sandra journeyed to the kitchen. Daniel went to the hallway. Daniel journeyed to the kitchen. John journeyed to the bathroom. John left the football. John dropped the milk. Mary grabbed the football there. Sandra moved to the bathroom. John grabbed the milk there. John discarded the milk. John went back to the office.
babilong_0k_qa2_sample_57
177
123
419
Write a function to round every number of a given list of numbers and print the total sum multiplied by the length of the list.
def round_and_sum(list1): lenght=len(list1) round_and_sum=sum(list(map(round,list1))* lenght) return round_and_sum
[ "assert round_and_sum([22.4, 4.0, -16.22, -9.10, 11.00, -12.22, 14.20, -5.20, 17.50])==243", "assert round_and_sum([5,2,9,24.3,29])==345", "assert round_and_sum([25.0,56.7,89.2])==513" ]
[]
Mary grabbed the milk there. John picked up the apple there. Mary went to the bathroom. Daniel moved to the garden. John put down the apple. Mary left the milk.
babilong_0k_qa2_sample_38
37
123
75
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): res = [sub for sub in test_list if all(ele % K == 0 for ele in sub)] return (str(res))
[ "assert find_tuples([(6, 24, 12), (7, 9, 6), (12, 18, 21)], 6) == '[(6, 24, 12)]'", "assert find_tuples([(5, 25, 30), (4, 2, 3), (7, 8, 9)], 5) == '[(5, 25, 30)]'", "assert find_tuples([(7, 9, 16), (8, 16, 4), (19, 17, 18)], 4) == '[(8, 16, 4)]'" ]
[]
Mary moved to the hallway. Daniel travelled to the office. John went back to the hallway. John moved to the office. Sandra journeyed to the kitchen. Mary moved to the bedroom. John went back to the kitchen. Sandra went to the bedroom. Sandra travelled to the hallway. Daniel went to the bedroom.
babilong_0k_qa1_sample_20
64
124
84
Write a function to find the n-th number in newman conway sequence.
def sequence(n): if n == 1 or n == 2: return 1 else: return sequence(sequence(n-1)) + sequence(n-sequence(n-1))
[ "assert sequence(10) == 6", "assert sequence(2) == 1", "assert sequence(3) == 2" ]
[]
Sandra journeyed to the hallway. John went back to the garden. Daniel journeyed to the office. Mary journeyed to the bathroom. John went to the kitchen. Mary journeyed to the office.
babilong_0k_qa1_sample_73
43
124
273
Write a function to substract the contents of one tuple with corresponding index of other tuple.
def substract_elements(test_tup1, test_tup2): res = tuple(map(lambda i, j: i - j, test_tup1, test_tup2)) return (res)
[ "assert substract_elements((10, 4, 5), (2, 5, 18)) == (8, -1, -13)", "assert substract_elements((11, 2, 3), (24, 45 ,16)) == (-13, -43, -13)", "assert substract_elements((7, 18, 9), (10, 11, 12)) == (-3, 7, -3)" ]
[]
Daniel journeyed to the office. Daniel moved to the garden. Daniel got the apple there. Daniel discarded the apple. Mary went back to the hallway. John travelled to the bedroom. Mary got the milk. Mary put down the milk there. John moved to the hallway. Mary picked up the milk. Mary moved to the bedroom. Mary took the football. Mary put down the football. Daniel picked up the apple. Mary grabbed the football. Sandra travelled to the kitchen. Mary travelled to the bathroom. Daniel discarded the apple. Daniel picked up the apple there. Sandra went back to the bedroom. Daniel dropped the apple there. John went to the office. Mary moved to the hallway. Mary discarded the football. Mary took the football. Daniel took the apple. John went to the kitchen. Mary dropped the football. Mary put down the milk there. John went to the bathroom. Sandra journeyed to the office. Mary got the milk. Mary picked up the football there. Daniel discarded the apple. Daniel journeyed to the kitchen. Mary went back to the kitchen. Mary dropped the milk. Daniel took the milk. John travelled to the office. Daniel discarded the milk. Mary grabbed the milk. Sandra went back to the bathroom. John went to the bedroom. Mary put down the football there. Daniel took the football. Sandra journeyed to the garden. Daniel journeyed to the hallway. Mary discarded the milk there. Sandra got the apple. Mary picked up the milk. Daniel left the football. Sandra travelled to the bedroom. Daniel grabbed the football. Sandra left the apple. John travelled to the kitchen. Sandra got the apple. Daniel discarded the football. Mary discarded the milk. Mary went to the garden. Daniel moved to the garden. Sandra moved to the garden. Mary moved to the kitchen. Sandra moved to the kitchen. John moved to the bathroom. Mary got the milk. Sandra journeyed to the office. Sandra dropped the apple. John journeyed to the kitchen. Sandra picked up the apple there. Mary went to the bathroom. Mary dropped the milk. Daniel went back to the office. Mary took the milk there. Mary dropped the milk there. Daniel moved to the hallway. Daniel went to the bathroom. Sandra put down the apple. Sandra picked up the apple there. Daniel travelled to the bedroom. John went to the hallway. John journeyed to the bedroom. Daniel went to the bathroom. Daniel travelled to the bedroom. Mary got the milk. Daniel moved to the office. Mary went to the garden. Mary went back to the office. Sandra discarded the apple.
babilong_0k_qa3_sample_18
522
124
157
Write a function to reflect the run-length encoding from a list.
from itertools import groupby def encode_list(list1): return [[len(list(group)), key] for key, group in groupby(list1)]
[ "assert encode_list([1,1,2,3,4,4.3,5,1])==[[2, 1], [1, 2], [1, 3], [1, 4], [1, 4.3], [1, 5], [1, 1]]", "assert encode_list('automatically')==[[1, 'a'], [1, 'u'], [1, 't'], [1, 'o'], [1, 'm'], [1, 'a'], [1, 't'], [1, 'i'], [1, 'c'], [1, 'a'], [2, 'l'], [1, 'y']]", "assert encode_list('python')==[[1, 'p'], [1, 'y'], [1, 't'], [1, 'h'], [1, 'o'], [1, 'n']]" ]
[]
Jeff went to the office. Mary took the apple there. Bill went to the bathroom. Mary left the apple. Bill went back to the kitchen. Mary travelled to the bedroom. Mary journeyed to the hallway. Bill journeyed to the bathroom. Bill travelled to the kitchen. Fred went back to the bathroom. Bill travelled to the office. Jeff journeyed to the hallway. Fred journeyed to the kitchen. Fred journeyed to the hallway. Fred went to the kitchen. Jeff travelled to the kitchen. Jeff travelled to the bathroom. Jeff went to the kitchen. Bill went to the bathroom. Fred went back to the bathroom. Fred grabbed the milk there. Fred passed the milk to Bill. Bill dropped the milk. Fred travelled to the bedroom.
babilong_0k_qa5_sample_75
152
125
142
Write a function to count the same pair in three given lists.
def count_samepair(list1,list2,list3): result = sum(m == n == o for m, n, o in zip(list1,list2,list3)) return result
[ "assert count_samepair([1,2,3,4,5,6,7,8],[2,2,3,1,2,6,7,9],[2,1,3,1,2,6,7,9])==3", "assert count_samepair([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", "assert count_samepair([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" ]
[]
Sandra journeyed to the bedroom. John moved to the kitchen. John went to the hallway. Sandra went to the bathroom. John went back to the kitchen. Daniel went to the hallway. Sandra got the football. Sandra travelled to the garden. Daniel journeyed to the garden. Daniel journeyed to the kitchen. Daniel went back to the office. Daniel travelled to the bedroom. John went back to the bedroom. Sandra went to the bedroom. Sandra went to the hallway. Sandra travelled to the office. Sandra went back to the bedroom. Sandra moved to the office. Sandra journeyed to the kitchen. Sandra travelled to the garden. John went back to the bathroom. Daniel moved to the office. John grabbed the apple. Daniel got the milk there. Daniel left the milk. Mary travelled to the bedroom. Mary moved to the kitchen. Daniel grabbed the milk. Daniel left the milk. Sandra left the football there. John travelled to the office. Mary went back to the bedroom. John went back to the bathroom. Mary journeyed to the kitchen.
babilong_0k_qa3_sample_28
213
126
429
Write a function to extract the elementwise and tuples from the given two tuples.
def and_tuples(test_tup1, test_tup2): res = tuple(ele1 & ele2 for ele1, ele2 in zip(test_tup1, test_tup2)) return (res)
[ "assert and_tuples((10, 4, 6, 9), (5, 2, 3, 3)) == (0, 0, 2, 1)", "assert and_tuples((1, 2, 3, 4), (5, 6, 7, 8)) == (1, 2, 3, 0)", "assert and_tuples((8, 9, 11, 12), (7, 13, 14, 17)) == (0, 9, 10, 0)" ]
[]
The bathroom is west of the garden. The office is east of the garden.
babilong_0k_qa4_sample_30
17
126
90
Write a python function to find the length of the longest word.
def len_log(list1): max=len(list1[0]) for i in list1: if len(i)>max: max=len(i) return max
[ "assert len_log([\"python\",\"PHP\",\"bigdata\"]) == 7", "assert len_log([\"a\",\"ab\",\"abc\"]) == 3", "assert len_log([\"small\",\"big\",\"tall\"]) == 5" ]
[]
The bedroom is south of the office. The office is south of the hallway.
babilong_0k_qa4_sample_47
17
127
399
Write a function to perform the mathematical bitwise xor operation across the given tuples.
def bitwise_xor(test_tup1, test_tup2): res = tuple(ele1 ^ ele2 for ele1, ele2 in zip(test_tup1, test_tup2)) return (res)
[ "assert bitwise_xor((10, 4, 6, 9), (5, 2, 3, 3)) == (15, 6, 5, 10)", "assert bitwise_xor((11, 5, 7, 10), (6, 3, 4, 4)) == (13, 6, 3, 14)", "assert bitwise_xor((12, 6, 8, 11), (7, 4, 5, 6)) == (11, 2, 13, 13)" ]
[]
Sandra went back to the hallway. John travelled to the kitchen. John grabbed the apple. Daniel travelled to the hallway. John dropped the apple. Daniel went to the kitchen. John travelled to the office. Mary took the milk. Sandra journeyed to the kitchen. Mary discarded the milk. Daniel grabbed the apple. Daniel dropped the apple there. Daniel moved to the garden. Sandra went back to the bathroom. Daniel picked up the football. Mary travelled to the office. Sandra went to the garden. John went back to the garden. John travelled to the kitchen. Sandra went to the bathroom. Mary travelled to the bathroom. Daniel dropped the football there. Daniel picked up the football. Sandra got the milk. John got the apple. John moved to the hallway. Daniel discarded the football. Daniel grabbed the football. Daniel discarded the football. Daniel took the football. Mary moved to the hallway. Daniel moved to the office. Sandra travelled to the office. Sandra left the milk. John went back to the kitchen. Mary went back to the bedroom. Mary went back to the kitchen. Daniel travelled to the hallway. Sandra got the milk. Daniel discarded the football.
babilong_0k_qa3_sample_5
235
127
440
Write a function to find all adverbs and their positions in a given sentence.
import re def find_adverb_position(text): for m in re.finditer(r"\w+ly", text): return (m.start(), m.end(), m.group(0))
[ "assert find_adverb_position(\"clearly!! we can see the sky\")==(0, 7, 'clearly')", "assert find_adverb_position(\"seriously!! there are many roses\")==(0, 9, 'seriously')", "assert find_adverb_position(\"unfortunately!! sita is going to home\")==(0, 13, 'unfortunately')" ]
[]
The bathroom is south of the office. The hallway is south of the bathroom.
babilong_0k_qa4_sample_49
17
127
94
Write a function to extract the index minimum value record from the given tuples.
from operator import itemgetter def index_minimum(test_list): res = min(test_list, key = itemgetter(1))[0] return (res)
[ "assert index_minimum([('Rash', 143), ('Manjeet', 200), ('Varsha', 100)]) == 'Varsha'", "assert index_minimum([('Yash', 185), ('Dawood', 125), ('Sanya', 175)]) == 'Dawood'", "assert index_minimum([('Sai', 345), ('Salman', 145), ('Ayesha', 96)]) == 'Ayesha'" ]
[]
Jeff went back to the office. Jeff went to the bedroom. Mary journeyed to the garden. Fred got the apple there. Bill travelled to the office. Mary travelled to the hallway. Mary went to the bedroom. Bill journeyed to the hallway. Fred went back to the kitchen. Fred got the milk there. Fred moved to the office. Fred went to the kitchen. Fred travelled to the office. Bill went back to the kitchen. Mary journeyed to the hallway. Fred left the apple. Fred grabbed the apple there. Mary journeyed to the bathroom. Fred put down the apple. Fred picked up the football there. Jeff journeyed to the kitchen. Fred took the apple there. Mary went to the garden. Jeff travelled to the bathroom. Mary went to the bedroom. Fred discarded the football. Bill went back to the hallway. Fred dropped the milk. Fred moved to the bedroom. Bill journeyed to the garden. Fred gave the apple to Mary. Mary handed the apple to Fred. Jeff went to the kitchen. Bill travelled to the bathroom.
babilong_0k_qa5_sample_28
215
128
301
Write a function to find the depth of a dictionary.
def dict_depth(d): if isinstance(d, dict): return 1 + (max(map(dict_depth, d.values())) if d else 0) return 0
[ "assert dict_depth({'a':1, 'b': {'c': {'d': {}}}})==4", "assert dict_depth({'a':1, 'b': {'c':'python'}})==2", "assert dict_depth({1: 'Sun', 2: {3: {4:'Mon'}}})==3" ]
[]
Jeff travelled to the bedroom. Bill picked up the football there. Fred moved to the garden. Mary went back to the garden. Mary went back to the hallway. Jeff picked up the milk there. Bill travelled to the bathroom. Bill grabbed the apple there. Jeff moved to the bathroom. Mary went back to the bedroom. Bill gave the apple to Jeff. Mary went to the garden. Jeff passed the apple to Bill. Bill left the football there.
babilong_0k_qa5_sample_69
92
128
484
Write a function to remove the matching tuples from the given two tuples.
def remove_matching_tuple(test_list1, test_list2): res = [sub for sub in test_list1 if sub not in test_list2] return (res)
[ "assert remove_matching_tuple([('Hello', 'dude'), ('How', 'are'), ('you', '?')], [('Hello', 'dude'), ('How', 'are')]) == [('you', '?')]", "assert remove_matching_tuple([('Part', 'of'), ('the', 'journey'), ('is ', 'end')], [('Journey', 'the'), ('is', 'end')]) == [('Part', 'of'), ('the', 'journey'), ('is ', 'end')]", "assert remove_matching_tuple([('Its', 'been'), ('a', 'long'), ('day', 'without')], [('a', 'long'), ('my', 'friend')]) == [('Its', 'been'), ('day', 'without')]" ]
[]
John went to the office. Sandra went to the kitchen. John went back to the kitchen. Mary moved to the garden. Mary went to the kitchen. Sandra moved to the bedroom. Sandra moved to the hallway. John went back to the hallway. Sandra travelled to the bedroom. Daniel moved to the office.
babilong_0k_qa1_sample_48
63
129
218
Write a python function to find the minimum operations required to make two numbers equal.
import math def min_Operations(A,B): if (A > B): swap(A,B) B = B // math.gcd(A,B); return B - 1
[ "assert min_Operations(2,4) == 1", "assert min_Operations(4,10) == 4", "assert min_Operations(1,4) == 3" ]
[]
John moved to the hallway. John got the football. John got the apple. Mary travelled to the garden. John left the apple. Daniel journeyed to the garden. John picked up the apple. Daniel went back to the bedroom. Daniel journeyed to the office. John discarded the apple. Sandra journeyed to the kitchen. John took the apple there. Mary travelled to the bathroom. Daniel went back to the hallway. Mary journeyed to the office. Mary went to the bathroom. John went back to the bathroom. Mary travelled to the kitchen. Mary moved to the office. Daniel went to the bathroom. Sandra moved to the office. Sandra picked up the milk. Sandra moved to the bathroom. Sandra went to the kitchen. Sandra went back to the bathroom. John travelled to the garden.
babilong_0k_qa3_sample_64
161
130
249
Write a function to find the intersection of two arrays using lambda function.
def intersection_array(array_nums1,array_nums2): result = list(filter(lambda x: x in array_nums1, array_nums2)) return result
[ "assert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[1, 2, 4, 8, 9])==[1, 2, 8, 9]", "assert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[3,5,7,9])==[3,5,7,9]", "assert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[10,20,30,40])==[10]" ]
[]
The kitchen is north of the bathroom. The kitchen is south of the office.
babilong_0k_qa4_sample_83
17
130
308
Write a function to find the specified number of largest products from two given lists.
def large_product(nums1, nums2, N): result = sorted([x*y for x in nums1 for y in nums2], reverse=True)[:N] return result
[ "assert large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],3)==[60, 54, 50]", "assert large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],4)==[60, 54, 50, 48]", "assert large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],5)==[60, 54, 50, 48, 45]" ]
[]
Daniel journeyed to the office. John moved to the garden. Daniel travelled to the hallway. Mary went back to the bedroom. Mary journeyed to the office. Sandra travelled to the bedroom. Mary travelled to the kitchen. Mary took the football. Mary left the football. Mary journeyed to the bedroom. John journeyed to the kitchen. Mary went back to the garden. Mary journeyed to the bedroom. John travelled to the bathroom. Mary travelled to the garden. John grabbed the milk. John travelled to the bedroom. Mary journeyed to the kitchen. Mary travelled to the bathroom. Daniel went back to the bedroom. Daniel went back to the office. John moved to the hallway. Daniel went to the kitchen. Daniel grabbed the football there. Daniel grabbed the apple. John put down the milk. Sandra journeyed to the hallway. Sandra journeyed to the office. Daniel went back to the office. John journeyed to the garden. John travelled to the kitchen. Daniel left the football. Daniel put down the apple there. Sandra grabbed the football. Mary travelled to the office. Sandra put down the football. Mary picked up the football there. Daniel went back to the hallway. Sandra travelled to the kitchen. Daniel travelled to the office. Mary grabbed the apple. Daniel went to the bedroom. Sandra went back to the bedroom. Mary moved to the bathroom. Daniel journeyed to the garden. Daniel travelled to the bedroom. Mary put down the football there. John went to the office. Daniel went to the kitchen. Mary discarded the apple there. Daniel went back to the hallway. Sandra went back to the bathroom. Mary went to the office. Mary went back to the bedroom. John went to the hallway. Sandra went to the garden. John moved to the office. Daniel got the milk. John moved to the bedroom. Mary went to the hallway. Mary journeyed to the garden. Mary travelled to the kitchen. Sandra journeyed to the kitchen. Sandra journeyed to the office. Daniel moved to the kitchen. John travelled to the bathroom. John took the football. John journeyed to the hallway. John put down the football. Sandra went back to the bedroom. Daniel travelled to the bedroom. John took the football. Daniel went back to the hallway. John dropped the football there. John grabbed the football. Mary journeyed to the hallway. Mary travelled to the bedroom. John went back to the bathroom. Daniel went to the kitchen. John took the apple. John travelled to the hallway. Daniel journeyed to the bedroom. John discarded the football there. John took the football. Mary went back to the garden. John left the football. John picked up the football. Daniel left the milk.
babilong_0k_qa3_sample_85
547
130
443
Write a python function to find the largest negative number from the given list.
def largest_neg(list1): max = list1[0] for x in list1: if x < max : max = x return max
[ "assert largest_neg([1,2,3,-4,-6]) == -6", "assert largest_neg([1,2,3,-8,-9]) == -9", "assert largest_neg([1,2,3,4,-1]) == -1" ]
[]
The kitchen is east of the hallway. The bedroom is west of the hallway.
babilong_0k_qa4_sample_54
17
130
144
Write a python function to find the sum of absolute differences in all pairs of the given array.
def sum_Pairs(arr,n): sum = 0 for i in range(n - 1,-1,-1): sum += i*arr[i] - (n-1-i) * arr[i] return sum
[ "assert sum_Pairs([1,8,9,15,16],5) == 74", "assert sum_Pairs([1,2,3,4],4) == 10", "assert sum_Pairs([1,2,3,4,5,7,9,11,14],9) == 188" ]
[]
John travelled to the garden. Daniel journeyed to the bathroom. Daniel moved to the bedroom. Sandra grabbed the milk. Mary travelled to the bedroom. Mary travelled to the garden. Daniel went back to the bathroom. Daniel travelled to the hallway. Daniel travelled to the office. John journeyed to the kitchen. Daniel picked up the football there. Daniel moved to the hallway. Sandra travelled to the bathroom. Daniel left the football. Daniel moved to the garden. Mary went to the hallway. Mary journeyed to the office. Mary moved to the kitchen. John moved to the hallway. John grabbed the football. John journeyed to the garden. Sandra moved to the hallway. John went back to the hallway. John journeyed to the garden.
babilong_0k_qa3_sample_96
150
131
212
Write a python function to find the sum of fourth power of n natural numbers.
import math def fourth_Power_Sum(n): sum = 0 for i in range(1,n+1) : sum = sum + (i*i*i*i) return sum
[ "assert fourth_Power_Sum(2) == 17", "assert fourth_Power_Sum(4) == 354", "assert fourth_Power_Sum(6) == 2275" ]
[]
John picked up the football. Sandra journeyed to the kitchen. Mary took the apple. John dropped the football there. John moved to the garden. Mary left the apple. Sandra went back to the bathroom. Daniel journeyed to the garden. Daniel moved to the bathroom. Mary got the apple. Sandra journeyed to the hallway. Mary dropped the apple. Sandra went back to the garden. Sandra went back to the bedroom. John took the milk. Mary got the apple there. Daniel journeyed to the kitchen. Mary went back to the office. Mary discarded the apple there. Sandra travelled to the office. John left the milk. Sandra picked up the football there. John picked up the milk there. Mary went to the garden. Mary went back to the hallway. Sandra left the football. Daniel travelled to the bathroom. John discarded the milk. John moved to the kitchen. Sandra travelled to the kitchen. Mary moved to the bathroom. Sandra moved to the hallway. Mary went back to the bedroom. Daniel travelled to the bedroom. Daniel travelled to the hallway. Sandra travelled to the office. Daniel went back to the garden. Sandra journeyed to the hallway. John went to the hallway. John went to the kitchen. John travelled to the hallway. Mary journeyed to the office. Mary took the football there. Sandra moved to the bathroom. Mary discarded the football. Daniel went to the hallway. Daniel journeyed to the bathroom. Daniel journeyed to the office. Mary took the apple there. Mary journeyed to the bathroom. Daniel got the football. Daniel dropped the football. Mary left the apple there. Sandra moved to the kitchen. Mary moved to the bedroom. Daniel grabbed the football. Daniel put down the football. Daniel took the football. Mary went to the garden. Mary took the milk there. Daniel left the football there. Sandra moved to the office. Sandra moved to the garden. John went back to the garden. Sandra travelled to the hallway. Daniel went to the kitchen. Sandra journeyed to the office. Sandra got the football. Mary discarded the milk. Sandra left the football. John travelled to the bathroom. John travelled to the bedroom. Sandra got the football. Mary went back to the hallway. Mary journeyed to the kitchen. John journeyed to the bathroom. Sandra left the football there. Sandra grabbed the football. Mary journeyed to the hallway. Sandra left the football there. Daniel went to the bedroom. John took the apple there. John went back to the garden. Sandra moved to the garden. Sandra went back to the kitchen. Mary went back to the bedroom. John travelled to the office. John put down the apple. Mary went back to the bathroom. John picked up the apple there. Sandra went back to the bedroom. John took the football. John dropped the apple. Daniel travelled to the garden. Mary went to the kitchen. John put down the football. Daniel picked up the milk. Sandra moved to the kitchen. Sandra journeyed to the bedroom. Mary journeyed to the hallway. Daniel dropped the milk. John got the apple. Sandra journeyed to the office. Daniel travelled to the kitchen. Mary went to the kitchen. Sandra took the football. John dropped the apple. Sandra left the football there. John picked up the apple. Sandra went to the hallway. John grabbed the football. Mary moved to the bedroom. John dropped the apple. John journeyed to the hallway. John went back to the kitchen. Mary went to the bathroom. Daniel journeyed to the bathroom. John journeyed to the bathroom. Daniel travelled to the garden. John moved to the garden. John travelled to the bathroom. John left the football. John moved to the office. Mary took the football. Mary went to the hallway. Mary journeyed to the bedroom. Sandra journeyed to the bedroom. Sandra travelled to the hallway.
babilong_0k_qa3_sample_34
780
131
475
Write a function to sort counter by value.
from collections import Counter def sort_counter(dict1): x = Counter(dict1) sort_counter=x.most_common() return sort_counter
[ "assert sort_counter({'Math':81, 'Physics':83, 'Chemistry':87})==[('Chemistry', 87), ('Physics', 83), ('Math', 81)]", "assert sort_counter({'Math':400, 'Physics':300, 'Chemistry':250})==[('Math', 400), ('Physics', 300), ('Chemistry', 250)]", "assert sort_counter({'Math':900, 'Physics':1000, 'Chemistry':1250})==[('Chemistry', 1250), ('Physics', 1000), ('Math', 900)]" ]
[]
Mary travelled to the hallway. Bill went back to the garden. Fred moved to the bedroom. Fred got the football there. Fred dropped the football. Fred went to the garden. Mary journeyed to the kitchen. Bill went to the office. Mary went back to the office. Bill journeyed to the bedroom. Mary went back to the bedroom. Jeff grabbed the milk there. Jeff went to the office. Jeff went to the bathroom. Mary got the football there. Mary put down the football there. Bill journeyed to the garden. Fred went back to the bathroom. Jeff put down the milk. Bill moved to the office. Fred went to the office. Mary grabbed the football there. Jeff travelled to the office. Mary dropped the football. Fred moved to the kitchen. Bill journeyed to the kitchen. Bill took the apple there. Bill went back to the hallway. Fred moved to the office. Mary picked up the football there. Fred journeyed to the bedroom. Mary gave the football to Fred.
babilong_0k_qa5_sample_78
204
131
204
Write a python function to count the occurrence of a given character in a string.
def count(s,c) : res = 0 for i in range(len(s)) : if (s[i] == c): res = res + 1 return res
[ "assert count(\"abcc\",\"c\") == 2", "assert count(\"ababca\",\"a\") == 3", "assert count(\"mnmm0pm\",\"m\") == 4" ]
[]
Daniel went to the bedroom. Sandra went to the kitchen. Daniel moved to the kitchen. John went back to the bedroom. Daniel journeyed to the bedroom. Daniel travelled to the kitchen. Sandra went back to the bathroom. Sandra went to the kitchen.
babilong_0k_qa1_sample_16
52
132
197
Write a function to perform the exponentiation of the given two tuples.
def find_exponentio(test_tup1, test_tup2): res = tuple(ele1 ** ele2 for ele1, ele2 in zip(test_tup1, test_tup2)) return (res)
[ "assert find_exponentio((10, 4, 5, 6), (5, 6, 7, 5)) == (100000, 4096, 78125, 7776)", "assert find_exponentio((11, 5, 6, 7), (6, 7, 8, 6)) == (1771561, 78125, 1679616, 117649)", "assert find_exponentio((12, 6, 7, 8), (7, 8, 9, 7)) == (35831808, 1679616, 40353607, 2097152)" ]
[]
The kitchen is south of the hallway. The bedroom is north of the hallway.
babilong_0k_qa4_sample_98
17
133
250
Write a python function to count the occcurences of an element in a tuple.
def count_X(tup, x): count = 0 for ele in tup: if (ele == x): count = count + 1 return count
[ "assert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),4) == 0", "assert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),10) == 3", "assert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),8) == 4" ]
[]
John moved to the bedroom. Sandra journeyed to the office. Sandra moved to the kitchen. Daniel travelled to the bedroom. John went back to the office. Mary travelled to the garden. Sandra moved to the hallway. Sandra went to the garden. John went back to the kitchen. Daniel went to the office. Sandra moved to the hallway. Daniel picked up the apple there. Mary went to the bedroom. Daniel went back to the garden. Daniel left the apple. Daniel grabbed the apple there. Sandra took the football there. Daniel discarded the apple. Mary journeyed to the kitchen. Sandra journeyed to the kitchen. Daniel travelled to the bedroom. Sandra went to the bedroom. Daniel went back to the hallway. John went to the hallway. John went to the office. John moved to the kitchen. Sandra dropped the football. Daniel went to the garden.
babilong_0k_qa2_sample_16
174
133
253
Write a python function to count integers from a given list.
def count_integer(list1): ctr = 0 for i in list1: if isinstance(i, int): ctr = ctr + 1 return ctr
[ "assert count_integer([1,2,'abc',1.2]) == 2", "assert count_integer([1,2,3]) == 3", "assert count_integer([1,1.2,4,5.1]) == 2" ]
[]
Jeff went back to the office. Fred went back to the hallway. Bill picked up the milk there. Mary journeyed to the kitchen. Bill journeyed to the hallway. Bill passed the milk to Fred. Fred discarded the milk. Bill grabbed the milk there. Bill passed the milk to Fred. Bill travelled to the bedroom.
babilong_0k_qa5_sample_70
67
134
261
Write a function to perform mathematical division operation across the given tuples.
def division_elements(test_tup1, test_tup2): res = tuple(ele1 // ele2 for ele1, ele2 in zip(test_tup1, test_tup2)) return (res)
[ "assert division_elements((10, 4, 6, 9),(5, 2, 3, 3)) == (2, 2, 2, 3)", "assert division_elements((12, 6, 8, 16),(6, 3, 4, 4)) == (2, 2, 2, 4)", "assert division_elements((20, 14, 36, 18),(5, 7, 6, 9)) == (4, 2, 6, 2)" ]
[]
Daniel grabbed the apple there. Daniel went back to the bathroom. John journeyed to the garden. Daniel went back to the hallway. Mary moved to the bedroom. Daniel left the apple. Sandra took the football there. Sandra discarded the football there.
babilong_0k_qa2_sample_29
51
134
346
Write a function to find entringer number e(n, k).
def zigzag(n, k): if (n == 0 and k == 0): return 1 if (k == 0): return 0 return zigzag(n, k - 1) + zigzag(n - 1, n - k)
[ "assert zigzag(4, 3) == 5", "assert zigzag(4, 2) == 4", "assert zigzag(3, 1) == 1" ]
[]
Mary went back to the kitchen. Daniel journeyed to the hallway.
babilong_0k_qa1_sample_8
15
134
422
Write a python function to find the average of cubes of first n natural numbers.
def find_Average_Of_Cube(n): sum = 0 for i in range(1, n + 1): sum += i * i * i return round(sum / n, 6)
[ "assert find_Average_Of_Cube(2) == 4.5", "assert find_Average_Of_Cube(3) == 12", "assert find_Average_Of_Cube(1) == 1" ]
[]
Daniel got the football there. Mary travelled to the garden. Mary moved to the bedroom. Daniel moved to the office. Daniel travelled to the hallway. Daniel left the football.
babilong_0k_qa2_sample_73
36
134
213
Write a function to perform the concatenation of two string tuples.
def concatenate_strings(test_tup1, test_tup2): res = tuple(ele1 + ele2 for ele1, ele2 in zip(test_tup1, test_tup2)) return (res)
[ "assert concatenate_strings((\"Manjeet\", \"Nikhil\", \"Akshat\"), (\" Singh\", \" Meherwal\", \" Garg\")) == ('Manjeet Singh', 'Nikhil Meherwal', 'Akshat Garg')", "assert concatenate_strings((\"Shaik\", \"Ayesha\", \"Sanya\"), (\" Dawood\", \" Begum\", \" Singh\")) == ('Shaik Dawood', 'Ayesha Begum', 'Sanya Singh')", "assert concatenate_strings((\"Harpreet\", \"Priyanka\", \"Muskan\"), (\"Kour\", \" Agarwal\", \"Sethi\")) == ('HarpreetKour', 'Priyanka Agarwal', 'MuskanSethi')" ]
[]
Mary went back to the garden. Fred went to the hallway. Jeff got the milk there. Mary went back to the hallway. Fred moved to the bedroom. Bill moved to the bathroom. Fred took the football there. Jeff moved to the hallway. Jeff handed the milk to Mary. Mary gave the milk to Jeff. Bill moved to the bedroom. Mary journeyed to the bedroom. Jeff discarded the milk there. Fred handed the football to Mary. Mary handed the football to Fred. Fred gave the football to Mary. Jeff journeyed to the office. Jeff journeyed to the bedroom.
babilong_0k_qa5_sample_57
119
135
255
Write a function to choose specified number of colours from three different colours and generate all the combinations with repetitions.
from itertools import combinations_with_replacement def combinations_colors(l, n): return list(combinations_with_replacement(l,n))
[ "assert combinations_colors( [\"Red\",\"Green\",\"Blue\"],1)==[('Red',), ('Green',), ('Blue',)]", "assert combinations_colors( [\"Red\",\"Green\",\"Blue\"],2)==[('Red', 'Red'), ('Red', 'Green'), ('Red', 'Blue'), ('Green', 'Green'), ('Green', 'Blue'), ('Blue', 'Blue')]", "assert combinations_colors( [\"Red\",\"Green\",\"Blue\"],3)==[('Red', 'Red', 'Red'), ('Red', 'Red', 'Green'), ('Red', 'Red', 'Blue'), ('Red', 'Green', 'Green'), ('Red', 'Green', 'Blue'), ('Red', 'Blue', 'Blue'), ('Green', 'Green', 'Green'), ('Green', 'Green', 'Blue'), ('Green', 'Blue', 'Blue'), ('Blue', 'Blue', 'Blue')]" ]
[]
Sandra travelled to the kitchen. Daniel moved to the hallway. Mary travelled to the kitchen. Mary journeyed to the bedroom. Daniel moved to the bedroom. Sandra journeyed to the bedroom. Daniel moved to the kitchen. Daniel went to the office. John journeyed to the office. John moved to the garden. Daniel grabbed the milk there. John moved to the kitchen. John moved to the garden. Daniel took the football there. Mary went back to the kitchen. Mary went back to the office. Daniel left the football. Mary got the apple there. John travelled to the bedroom. John moved to the hallway.
babilong_0k_qa2_sample_72
126
138
471
Write a python function to find remainder of array multiplication divided by n.
def find_remainder(arr, lens, n): mul = 1 for i in range(lens): mul = (mul * (arr[i] % n)) % n return mul % n
[ "assert find_remainder([ 100, 10, 5, 25, 35, 14 ],6,11) ==9", "assert find_remainder([1,1,1],3,1) == 0", "assert find_remainder([1,2,1],3,2) == 0" ]
[]
The bedroom is west of the kitchen. The kitchen is west of the hallway.
babilong_0k_qa4_sample_80
17
138
169
Write a function to calculate the nth pell number.
def get_pell(n): if (n <= 2): return n a = 1 b = 2 for i in range(3, n+1): c = 2 * b + a a = b b = c return b
[ "assert get_pell(4) == 12", "assert get_pell(7) == 169", "assert get_pell(8) == 408" ]
[]
Sandra went to the hallway. Daniel moved to the garden. Daniel went back to the bathroom. Mary went to the bedroom.
babilong_0k_qa1_sample_85
27
139
271
Write a python function to find the sum of fifth power of first n even natural numbers.
def even_Power_Sum(n): sum = 0; for i in range(1,n+1): j = 2*i; sum = sum + (j*j*j*j*j); return sum;
[ "assert even_Power_Sum(2) == 1056", "assert even_Power_Sum(3) == 8832", "assert even_Power_Sum(1) == 32" ]
[]
Jeff moved to the garden. Jeff journeyed to the bedroom. Bill went to the office. Bill got the milk there. Bill discarded the milk. Bill went back to the kitchen. Fred journeyed to the bathroom. Jeff took the football there. Fred went back to the garden. Jeff put down the football. Fred got the apple there. Fred left the apple there. Jeff travelled to the bathroom. Fred took the apple there. Mary went back to the garden. Jeff moved to the office. Bill moved to the bathroom. Fred dropped the apple. Bill went back to the bedroom. Fred took the apple there. Jeff took the milk there. Fred went to the bedroom. Jeff went back to the kitchen. Fred dropped the apple. Bill travelled to the bathroom. Mary moved to the bathroom. Fred travelled to the hallway. Jeff went to the bedroom. Fred moved to the bathroom. Jeff got the football there. Fred journeyed to the office. Jeff picked up the apple there. Jeff dropped the football. Mary travelled to the kitchen. Bill went to the garden. Fred went back to the garden. Jeff put down the apple. Bill travelled to the office. Jeff left the milk. Jeff grabbed the apple there. Jeff discarded the apple there. Jeff took the football there. Jeff grabbed the apple there. Mary went to the bathroom. Fred went back to the office. Jeff went to the office. Jeff handed the apple to Fred. Jeff discarded the football. Jeff took the football there. Fred discarded the apple.
babilong_0k_qa5_sample_61
306
139
437
Write a function to remove odd characters in a string.
def remove_odd(str1): str2 = '' for i in range(1, len(str1) + 1): if(i % 2 == 0): str2 = str2 + str1[i - 1] return str2
[ "assert remove_odd(\"python\")==(\"yhn\")", "assert remove_odd(\"program\")==(\"rga\")", "assert remove_odd(\"language\")==(\"agae\")" ]
[]
Sandra travelled to the bathroom. Mary journeyed to the bedroom. John travelled to the bathroom. John got the football there. Sandra got the milk there. Sandra left the milk. John discarded the football. Sandra went to the garden. John travelled to the garden. Sandra journeyed to the office. John journeyed to the bedroom. Mary travelled to the office. John moved to the office. Mary travelled to the bathroom. John moved to the bedroom. Mary journeyed to the hallway. Mary got the apple there. Sandra went back to the garden. Sandra went to the kitchen. Mary dropped the apple.
babilong_0k_qa2_sample_46
124
139
200
Write a function to find all index positions of the maximum values in a given list.
def position_max(list1): max_val = max(list1) max_result = [i for i, j in enumerate(list1) if j == max_val] return max_result
[ "assert position_max([12,33,23,10,67,89,45,667,23,12,11,10,54])==[7]", "assert position_max([1,2,2,2,4,4,4,5,5,5,5])==[7,8,9,10]", "assert position_max([2,1,5,6,8,3,4,9,10,11,8,12])==[11]" ]
[]
Mary travelled to the office. Jeff went back to the garden. Fred travelled to the bathroom. Jeff took the football there. Mary went to the bedroom. Jeff picked up the milk there. Jeff travelled to the office. Mary journeyed to the garden. Mary went to the kitchen. Jeff went back to the bedroom. Jeff moved to the office. Bill moved to the garden. Mary travelled to the bathroom. Jeff left the milk. Jeff went back to the hallway. Jeff took the apple there. Bill journeyed to the bedroom. Mary journeyed to the hallway. Jeff went back to the garden. Jeff travelled to the kitchen. Bill went back to the kitchen. Jeff gave the apple to Bill.
babilong_0k_qa5_sample_66
142
140
202
Write a function to remove even characters in a string.
def remove_even(str1): str2 = '' for i in range(1, len(str1) + 1): if(i % 2 != 0): str2 = str2 + str1[i - 1] return str2
[ "assert remove_even(\"python\")==(\"pto\")", "assert remove_even(\"program\")==(\"porm\")", "assert remove_even(\"language\")==(\"lnug\")" ]
[]
Sandra took the apple there. Daniel went back to the bedroom. Daniel travelled to the bathroom. John went to the bathroom. Mary journeyed to the bedroom. Daniel moved to the bedroom. Sandra moved to the bedroom. Daniel got the milk there. Daniel dropped the milk. Sandra picked up the milk there. Sandra put down the apple there. Mary picked up the apple there. Mary travelled to the bathroom. Sandra discarded the milk. Daniel took the milk there. John moved to the kitchen.
babilong_0k_qa2_sample_61
101
140
322
Write a function to find all index positions of the minimum values in a given list.
def position_min(list1): min_val = min(list1) min_result = [i for i, j in enumerate(list1) if j == min_val] return min_result
[ "assert position_min([12,33,23,10,67,89,45,667,23,12,11,10,54])==[3,11]", "assert position_min([1,2,2,2,4,4,4,5,5,5,5])==[0]", "assert position_min([2,1,5,6,8,3,4,9,10,11,8,12])==[1]" ]
[]
Sandra journeyed to the office. Sandra travelled to the bathroom. Daniel moved to the bedroom. Daniel went to the garden. Mary journeyed to the hallway. Sandra went to the office.
babilong_0k_qa1_sample_27
40
140
482
Write a function to find sequences of one upper case letter followed by lower case letters in the given string by using regex.
import re def match(text): pattern = '[A-Z]+[a-z]+$' if re.search(pattern, text): return('Yes') else: return('No')
[ "assert match(\"Geeks\") == 'Yes'", "assert match(\"geeksforGeeks\") == 'Yes'", "assert match(\"geeks\") == 'No'" ]
[]
Mary moved to the bathroom. Jeff journeyed to the kitchen. Jeff picked up the milk there. Jeff picked up the football there. Jeff put down the football there. Jeff journeyed to the office. Jeff picked up the apple there. Mary moved to the office. Bill travelled to the hallway. Jeff gave the apple to Mary. Bill went to the office. Mary gave the apple to Bill.
babilong_0k_qa5_sample_37
81
140
226
Write a python function to remove the characters which have odd index values of a given string.
def odd_values_string(str): result = "" for i in range(len(str)): if i % 2 == 0: result = result + str[i] return result
[ "assert odd_values_string('abcdef') == 'ace'", "assert odd_values_string('python') == 'pto'", "assert odd_values_string('data') == 'dt'" ]
[]
Daniel moved to the bedroom. Daniel took the milk there. Daniel left the milk. John went to the bedroom. John grabbed the apple there. Sandra went back to the garden. Mary journeyed to the garden. John got the milk there. John travelled to the hallway. Daniel journeyed to the kitchen. John journeyed to the office. Mary went to the bedroom.
babilong_0k_qa2_sample_54
76
141
264
Write a function to calculate a dog's age in dog's years.
def dog_age(h_age): if h_age < 0: exit() elif h_age <= 2: d_age = h_age * 10.5 else: d_age = 21 + (h_age - 2)*4 return d_age
[ "assert dog_age(12)==61", "assert dog_age(15)==73", "assert dog_age(24)==109" ]
[]
Bill went to the bathroom. Mary went back to the garden. Mary went back to the bathroom. Jeff went to the hallway. Mary travelled to the kitchen. Fred went to the bedroom. Fred went back to the garden. Fred took the football there. Mary travelled to the bedroom. Fred picked up the milk there. Fred dropped the football. Jeff travelled to the bedroom. Fred moved to the kitchen. Mary went to the office. Fred dropped the milk. Fred went to the garden. Fred grabbed the football there. Fred went back to the kitchen. Fred got the milk there. Fred went back to the hallway. Fred discarded the football. Mary went to the garden. Mary moved to the office. Fred dropped the milk. Mary took the apple there. Fred grabbed the milk there. Mary dropped the apple there. Bill went back to the office. Fred put down the milk there. Jeff moved to the hallway. Bill travelled to the bathroom. Mary moved to the garden. Bill journeyed to the office. Bill took the apple there. Fred picked up the milk there. Fred gave the milk to Jeff. Mary went back to the hallway. Fred went back to the garden.
babilong_0k_qa5_sample_2
238
141
278
Write a function to find the element count that occurs before the record in the given tuple.
def count_first_elements(test_tup): for count, ele in enumerate(test_tup): if isinstance(ele, tuple): break return (count)
[ "assert count_first_elements((1, 5, 7, (4, 6), 10) ) == 3", "assert count_first_elements((2, 9, (5, 7), 11) ) == 2", "assert count_first_elements((11, 15, 5, 8, (2, 3), 8) ) == 4" ]
[]
Sandra moved to the kitchen. Sandra went back to the bathroom. Mary journeyed to the bedroom. John journeyed to the bathroom. Sandra moved to the bedroom. Sandra travelled to the hallway. Sandra travelled to the garden. Sandra travelled to the bathroom. Daniel journeyed to the kitchen. John journeyed to the office.
babilong_0k_qa1_sample_14
67
141
305
Write a function to match two words from a list of words starting with letter 'p'.
import re def start_withp(words): for w in words: m = re.match("(P\w+)\W(P\w+)", w) if m: return m.groups()
[ "assert start_withp([\"Python PHP\", \"Java JavaScript\", \"c c++\"])==('Python', 'PHP')", "assert start_withp([\"Python Programming\",\"Java Programming\"])==('Python','Programming')", "assert start_withp([\"Pqrst Pqr\",\"qrstuv\"])==('Pqrst','Pqr')" ]
[]
John took the football there. John moved to the bedroom. John discarded the football. Sandra went to the bedroom. John took the football there. John dropped the football. Sandra took the football there. Sandra left the football.
babilong_0k_qa2_sample_93
46
141
478
Write a function to remove lowercase substrings from a given string.
import re def remove_lowercase(str1): remove_lower = lambda text: re.sub('[a-z]', '', text) result = remove_lower(str1) return result
[ "assert remove_lowercase(\"PYTHon\")==('PYTH')", "assert remove_lowercase(\"FInD\")==('FID')", "assert remove_lowercase(\"STRinG\")==('STRG')" ]
[]
Fred journeyed to the bedroom. Fred got the milk there. Fred went back to the kitchen. Bill picked up the football there. Fred handed the milk to Mary. Mary moved to the garden. Bill dropped the football. Mary gave the milk to Bill. Bill handed the milk to Mary. Mary passed the milk to Bill. Jeff went to the garden. Jeff journeyed to the kitchen.
babilong_0k_qa5_sample_1
80
141
109
Write a python function to find the count of rotations of a binary string with odd value.
def odd_Equivalent(s,n): count=0 for i in range(0,n): if (s[i] == '1'): count = count + 1 return count
[ "assert odd_Equivalent(\"011001\",6) == 3", "assert odd_Equivalent(\"11011\",5) == 4", "assert odd_Equivalent(\"1010\",4) == 2" ]
[]
Mary journeyed to the kitchen. Mary went to the bedroom. Mary moved to the bathroom. Mary grabbed the football there. Mary moved to the garden. Mary dropped the football. Fred went back to the kitchen. Jeff went back to the office. Jeff went to the bathroom. Bill took the apple there. Mary picked up the milk there. Mary picked up the football there. Bill went back to the kitchen. Bill went back to the hallway. Fred journeyed to the office. Bill discarded the apple. Mary journeyed to the kitchen. Fred journeyed to the garden. Mary went to the hallway. Mary gave the football to Bill. Bill passed the football to Mary. Bill took the apple there. Bill gave the apple to Mary. Jeff travelled to the kitchen.
babilong_0k_qa5_sample_33
156
143
126
Write a python function to find the sum of common divisors of two given numbers.
def sum(a,b): sum = 0 for i in range (1,min(a,b)): if (a % i == 0 and b % i == 0): sum += i return sum
[ "assert sum(10,15) == 6", "assert sum(100,150) == 93", "assert sum(4,6) == 3" ]
[]
Mary moved to the garden. Daniel grabbed the football there. Mary journeyed to the kitchen. Mary went to the hallway. Mary journeyed to the garden. John travelled to the office. Daniel journeyed to the garden. Mary got the milk there. Daniel discarded the football. Daniel went back to the office. Daniel grabbed the apple. Mary took the football there. Daniel left the apple. John took the apple. John went to the bathroom. Daniel travelled to the bathroom. Mary travelled to the hallway. Sandra travelled to the hallway. John discarded the apple. John went back to the garden. Mary moved to the bedroom. Sandra travelled to the office. John went to the hallway. Mary travelled to the kitchen. Sandra went back to the garden. Sandra journeyed to the bedroom. Mary went back to the hallway. Mary travelled to the kitchen. John went back to the bathroom. John grabbed the apple. Daniel moved to the hallway. Mary discarded the football there. Daniel journeyed to the bedroom. Mary journeyed to the office.
babilong_0k_qa3_sample_62
210
143
300
Write a function to find the count of all binary sequences of length 2n such that sum of first n bits is same as sum of last n bits.
def count_binary_seq(n): nCr = 1 res = 1 for r in range(1, n + 1): nCr = (nCr * (n + 1 - r)) / r res += nCr * nCr return res
[ "assert count_binary_seq(1) == 2.0", "assert count_binary_seq(2) == 6.0", "assert count_binary_seq(3) == 20.0" ]
[]
Sandra took the milk there. Sandra journeyed to the garden.
babilong_0k_qa2_sample_18
15
143
307
Write a function to get a colon of a tuple.
from copy import deepcopy def colon_tuplex(tuplex,m,n): tuplex_colon = deepcopy(tuplex) tuplex_colon[m].append(n) return tuplex_colon
[ "assert colon_tuplex((\"HELLO\", 5, [], True) ,2,50)==(\"HELLO\", 5, [50], True) ", "assert colon_tuplex((\"HELLO\", 5, [], True) ,2,100)==((\"HELLO\", 5, [100],True))", "assert colon_tuplex((\"HELLO\", 5, [], True) ,2,500)==(\"HELLO\", 5, [500], True)" ]
[]
Mary travelled to the garden. John went to the hallway. Sandra went to the kitchen. Mary went to the office. Daniel picked up the milk there. Daniel travelled to the bathroom. Sandra moved to the office. Daniel went to the hallway. Daniel dropped the milk. John got the milk. John dropped the milk. Daniel picked up the milk. John went to the bathroom. Daniel went back to the bedroom. Sandra picked up the apple. Sandra travelled to the garden. Sandra went to the office. Mary moved to the garden. Sandra moved to the hallway. Sandra travelled to the bathroom. Sandra put down the apple there. Daniel went to the bathroom. Sandra went back to the garden. Daniel moved to the office.
babilong_0k_qa3_sample_54
146
143
347
Write a python function to count the number of squares in a rectangle.
def count_Squares(m,n): if (n < m): temp = m m = n n = temp return n * (n + 1) * (3 * m - n + 1) // 6
[ "assert count_Squares(4,3) == 20", "assert count_Squares(1,2) == 2", "assert count_Squares(2,2) == 5" ]
[]
Sandra moved to the bedroom. Mary went back to the kitchen.
babilong_0k_qa1_sample_4
15
143
372
Write a function to sort a given list of elements in ascending order using heap queue algorithm.
import heapq as hq def heap_assending(nums): hq.heapify(nums) s_result = [hq.heappop(nums) for i in range(len(nums))] return s_result
[ "assert heap_assending([18, 14, 10, 9, 8, 7, 9, 3, 2, 4, 1])==[1, 2, 3, 4, 7, 8, 9, 9, 10, 14, 18]", "assert heap_assending([25, 35, 22, 85, 14, 65, 75, 25, 58])==[14, 22, 25, 25, 35, 58, 65, 75, 85]", "assert heap_assending([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]" ]
[]
Mary journeyed to the bedroom. Sandra grabbed the apple. Sandra put down the apple. Sandra picked up the apple. John went back to the kitchen. Daniel went to the bathroom. Sandra journeyed to the hallway. Sandra discarded the apple. Daniel journeyed to the garden. John moved to the bathroom. John got the milk there. Sandra moved to the bathroom. Sandra went to the bedroom. Daniel journeyed to the bathroom. John dropped the milk. Daniel went back to the kitchen. Sandra went to the kitchen. John moved to the office. Sandra journeyed to the bathroom. Daniel went to the garden. Sandra picked up the milk. Mary journeyed to the office. John went back to the garden. John moved to the bathroom. John travelled to the garden. John moved to the bathroom. Mary went to the bathroom. Daniel journeyed to the hallway. Daniel travelled to the kitchen. John moved to the kitchen. Sandra moved to the hallway. Sandra took the football. Daniel went back to the bathroom. Sandra grabbed the apple. Daniel moved to the hallway. Daniel moved to the bathroom. Mary moved to the hallway. Daniel went to the garden. Mary went to the bedroom. Daniel travelled to the kitchen. Sandra dropped the football. Sandra discarded the apple. Sandra grabbed the football. Sandra went to the office. Mary travelled to the garden. John went back to the hallway. John travelled to the bathroom. Daniel travelled to the bathroom. Sandra travelled to the bathroom. John went to the garden. John went back to the office. Sandra discarded the milk.
babilong_0k_qa3_sample_36
317
143
208
Write a function to check the given decimal with a precision of 2 by using regex.
import re def is_decimal(num): num_fetch = re.compile(r"""^[0-9]+(\.[0-9]{1,2})?$""") result = num_fetch.search(num) return bool(result)
[ "assert is_decimal('123.11') == True", "assert is_decimal('0.21') == True", "assert is_decimal('123.1214') == False" ]
[]
The garden is west of the office. The bedroom is east of the office.
babilong_0k_qa4_sample_70
17
146
459
Write a function to remove uppercase substrings from a given string by using regex.
import re def remove_uppercase(str1): remove_upper = lambda text: re.sub('[A-Z]', '', text) result = remove_upper(str1) return (result)
[ "assert remove_uppercase('cAstyoUrFavoRitETVshoWs') == 'cstyoravoitshos'", "assert remove_uppercase('wAtchTheinTernEtrAdIo') == 'wtchheinerntrdo'", "assert remove_uppercase('VoicESeaRchAndreComMendaTionS') == 'oiceachndreomendaion'" ]
[]
John picked up the apple there. Sandra took the milk. Mary journeyed to the hallway. John put down the apple. Daniel moved to the bathroom. Sandra put down the milk. John journeyed to the bedroom. Sandra got the milk there. John went to the hallway. Sandra put down the milk. John moved to the kitchen. Daniel went to the office. John took the milk. John travelled to the office. Mary moved to the office. John got the apple. Sandra went back to the hallway. Sandra journeyed to the office. John travelled to the bedroom. Sandra journeyed to the hallway. Daniel went to the hallway. Sandra went back to the garden. Daniel went back to the garden. Sandra travelled to the bedroom. John discarded the apple. Sandra moved to the kitchen. John grabbed the apple. Daniel went back to the bathroom. Daniel went back to the hallway. Mary went back to the bedroom. John dropped the apple. Mary went to the hallway. Sandra went to the office. Sandra went to the hallway. John travelled to the hallway. John dropped the milk. Mary got the milk there. Mary discarded the milk. Mary grabbed the milk. John journeyed to the bathroom. Daniel travelled to the kitchen. Mary dropped the milk there. John went to the garden. Daniel travelled to the office. Sandra took the milk. Sandra went back to the bedroom. Sandra journeyed to the garden. Sandra put down the milk.
babilong_0k_qa3_sample_33
293
146
495
Write a function to remove lowercase substrings from a given string by using regex.
import re def remove_lowercase(str1): remove_lower = lambda text: re.sub('[a-z]', '', text) result = remove_lower(str1) return (result)
[ "assert remove_lowercase('KDeoALOklOOHserfLoAJSIskdsf') == 'KDALOOOHLAJSI'", "assert remove_lowercase('ProducTnamEstreAmIngMediAplAYer') == 'PTEAIMAAY'", "assert remove_lowercase('maNufacTuredbYSheZenTechNolOGIes') == 'NTYSZTNOGI'" ]
[]
Daniel went back to the office. John went to the bedroom.
babilong_0k_qa1_sample_72
14
146
92
Write a function to check whether the given number is undulating or not.
def is_undulating(n): if (len(n) <= 2): return False for i in range(2, len(n)): if (n[i - 2] != n[i]): return False return True
[ "assert is_undulating(\"1212121\") == True", "assert is_undulating(\"1991\") == False", "assert is_undulating(\"121\") == True" ]
[]
Mary went back to the bedroom. John took the football. John travelled to the hallway. Mary went to the kitchen. Sandra went back to the hallway. John put down the football. Daniel travelled to the bedroom. Mary went to the bedroom. John took the milk. Daniel moved to the bathroom. Sandra took the football. Daniel went to the kitchen. Sandra travelled to the kitchen. Daniel travelled to the office. John went to the bedroom. Sandra discarded the football. John put down the milk. John took the milk. John travelled to the office. Sandra went to the garden. Sandra went back to the kitchen. Daniel went back to the bedroom. John went back to the bedroom. Sandra moved to the bedroom. John dropped the milk. John went back to the kitchen. John moved to the garden. Sandra went back to the bathroom. Mary moved to the garden. Daniel took the milk. Sandra went back to the hallway. Sandra journeyed to the garden. Daniel left the milk. Mary went to the bathroom. John went back to the hallway. Sandra went to the hallway. Daniel journeyed to the office. Sandra went to the bedroom. Sandra went to the garden. Sandra went back to the kitchen. Mary journeyed to the bedroom. Daniel moved to the bathroom. Daniel journeyed to the hallway. Mary got the milk. Sandra took the apple. Mary discarded the milk. Sandra put down the apple there. Mary took the milk. Mary moved to the hallway. Mary discarded the milk there. Daniel got the milk. John travelled to the garden. Sandra travelled to the bathroom. John moved to the office. John journeyed to the hallway. John went back to the bedroom. Daniel left the milk there. Sandra journeyed to the kitchen. Mary went to the kitchen. Mary went back to the bathroom. Daniel grabbed the milk. Mary journeyed to the hallway. Daniel moved to the office. Sandra went back to the office. Daniel put down the milk there. John went back to the bathroom. Mary moved to the kitchen. Mary went back to the garden. John went back to the kitchen. Sandra travelled to the bathroom. Daniel journeyed to the bathroom. John went to the office. Daniel moved to the hallway. John took the milk there. Mary journeyed to the office. John discarded the milk. Daniel moved to the garden. Mary moved to the bedroom. Sandra moved to the office. Mary moved to the kitchen. Daniel travelled to the kitchen. John journeyed to the bathroom. Sandra took the milk. Sandra went back to the hallway. Sandra discarded the milk. Sandra travelled to the kitchen. Daniel took the apple. Sandra picked up the football. Sandra dropped the football. Sandra went to the office. Daniel discarded the apple. John moved to the kitchen. Mary journeyed to the office. Mary journeyed to the bedroom. Mary went to the kitchen. Mary picked up the football. Sandra travelled to the garden. Sandra went to the office. John took the apple. Daniel moved to the office. Mary went to the hallway. John dropped the apple. Sandra travelled to the kitchen. Sandra journeyed to the garden. John went to the bedroom. Sandra went back to the office. Mary travelled to the bathroom. Mary went back to the hallway. John went back to the bathroom. Daniel journeyed to the bathroom. John went back to the garden. Sandra went back to the hallway. John went back to the bedroom. Mary took the milk. John travelled to the garden. Sandra went to the bathroom. Mary discarded the football. Mary left the milk there. John travelled to the office. Sandra went back to the bedroom.
babilong_0k_qa3_sample_90
737
147
290
Write a function to find the list of lists with maximum length.
def max_length(list1): max_length = max(len(x) for x in list1 ) max_list = max((x) for x in list1) return(max_length, max_list)
[ "assert max_length([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==(3, [13, 15, 17])", "assert max_length([[1], [5, 7], [10, 12, 14,15]])==(4, [10, 12, 14,15])", "assert max_length([[5], [15,20,25]])==(3, [15,20,25])" ]
[]
The hallway is south of the bedroom. The kitchen is north of the bedroom.
babilong_0k_qa4_sample_99
17
147
334
Write a python function to check whether the triangle is valid or not if sides are given.
def check_Validity(a,b,c): if (a + b <= c) or (a + c <= b) or (b + c <= a) : return False else: return True
[ "assert check_Validity(1,2,3) == False", "assert check_Validity(2,3,5) == False", "assert check_Validity(7,10,5) == True" ]
[]
Sandra moved to the garden. Sandra picked up the apple there. John journeyed to the office. Daniel travelled to the hallway. Mary took the football there. Mary discarded the football. Mary grabbed the football there. John got the milk there. Mary left the football there. Daniel moved to the bedroom. John travelled to the garden. Daniel went to the hallway. Mary picked up the football there. Sandra left the apple. Mary left the football there. Mary took the football there. Daniel went to the kitchen. John got the apple there. Mary discarded the football. Sandra moved to the bathroom. Mary got the football there. Sandra travelled to the bedroom. Mary left the football. John went back to the office. Sandra travelled to the hallway. John travelled to the garden. John discarded the apple. Mary picked up the football there. John got the apple there. John put down the milk there.
babilong_0k_qa2_sample_70
183
147
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,30,80,90]])==({30: 3, 80: 2, 90: 2, 15: 1, 20: 1, 40: 1, 100: 1, 110: 1})" ]
[]
Fred went to the bedroom. Fred took the football there. Fred put down the football. Jeff grabbed the milk there. Bill journeyed to the garden. Fred travelled to the garden. Jeff journeyed to the bathroom. Bill went to the office. Bill went back to the garden. Jeff discarded the milk. Mary went back to the bedroom. Mary picked up the football there. Fred travelled to the kitchen. Bill went to the bathroom. Fred went to the office. Bill journeyed to the garden. Mary travelled to the office. Mary handed the football to Fred. Mary travelled to the kitchen. Fred put down the football. Fred journeyed to the bedroom. Bill journeyed to the kitchen. Fred travelled to the hallway. Jeff journeyed to the office. Jeff grabbed the football there. Fred moved to the office. Bill went back to the bedroom. Jeff dropped the football. Mary journeyed to the hallway. Fred went back to the kitchen. Jeff got the football there. Bill moved to the bathroom. Bill travelled to the kitchen. Mary went to the bathroom. Jeff discarded the football. Bill travelled to the bathroom. Mary took the apple there. Mary journeyed to the bedroom. Bill grabbed the milk there. Bill discarded the milk. Bill went to the kitchen. Mary went to the bathroom. Mary took the milk there. Bill travelled to the garden. Fred went back to the bathroom. Jeff picked up the football there. Mary gave the apple to Fred. Fred handed the apple to Mary. Mary discarded the milk. Bill moved to the office.
babilong_0k_qa5_sample_32
314
149
114
Write a function to assign frequency to each tuple in the given tuple list.
from collections import Counter def assign_freq(test_list): res = [(*key, val) for key, val in Counter(test_list).items()] return (str(res))
[ "assert assign_freq([(6, 5, 8), (2, 7), (6, 5, 8), (6, 5, 8), (9, ), (2, 7)] ) == '[(6, 5, 8, 3), (2, 7, 2), (9, 1)]'", "assert assign_freq([(4, 2, 4), (7, 1), (4, 8), (4, 2, 4), (9, 2), (7, 1)] ) == '[(4, 2, 4, 2), (7, 1, 2), (4, 8, 1), (9, 2, 1)]'", "assert assign_freq([(11, 13, 10), (17, 21), (4, 2, 3), (17, 21), (9, 2), (4, 2, 3)] ) == '[(11, 13, 10, 1), (17, 21, 2), (4, 2, 3, 2), (9, 2, 1)]'" ]
[]
Daniel took the milk there. John journeyed to the garden. Daniel went back to the hallway. Daniel journeyed to the bathroom. Daniel dropped the milk. Daniel took the milk there. John grabbed the apple there. Sandra journeyed to the kitchen. John went to the hallway. Sandra went back to the garden.
babilong_0k_qa2_sample_5
65
149
68
Write a python function to check whether the given array is monotonic or not.
def is_Monotonic(A): 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)))
[ "assert is_Monotonic([6, 5, 4, 4]) == True", "assert is_Monotonic([1, 2, 2, 3]) == True", "assert is_Monotonic([1, 3, 2]) == False" ]
[]
The garden is south of the bedroom. The bedroom is south of the hallway.
babilong_0k_qa4_sample_10
17
150
444
Write a function to trim each tuple by k in the given tuple list.
def trim_tuple(test_list, K): res = [] for ele in test_list: N = len(ele) res.append(tuple(list(ele)[K: N - K])) return (str(res))
[ "assert trim_tuple([(5, 3, 2, 1, 4), (3, 4, 9, 2, 1),(9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 2) == '[(2,), (9,), (2,), (2,)]'", "assert trim_tuple([(5, 3, 2, 1, 4), (3, 4, 9, 2, 1), (9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 1) == '[(3, 2, 1), (4, 9, 2), (1, 2, 3), (8, 2, 1)]'", "assert trim_tuple([(7, 8, 4, 9), (11, 8, 12, 4),(4, 1, 7, 8), (3, 6, 9, 7)], 1) == '[(8, 4), (8, 12), (1, 7), (6, 9)]'" ]
[]
The bedroom is east of the hallway. The bedroom is west of the kitchen.
babilong_0k_qa4_sample_73
17
150
343
Write a function to calculate the number of digits and letters in a string.
def dig_let(s): d=l=0 for c in s: if c.isdigit(): d=d+1 elif c.isalpha(): l=l+1 else: pass return (l,d)
[ "assert dig_let(\"python\")==(6,0)", "assert dig_let(\"program\")==(7,0)", "assert dig_let(\"python3.0\")==(6,2)" ]
[]
Mary journeyed to the hallway. Fred travelled to the garden. Jeff took the apple there. Fred travelled to the kitchen. Jeff left the apple. Bill grabbed the football there. Bill put down the football. Jeff moved to the bedroom. Jeff moved to the hallway. Fred journeyed to the garden. Jeff travelled to the kitchen. Bill grabbed the football there. Bill discarded the football. Fred moved to the bathroom. Mary went back to the office. Bill picked up the football there. Jeff travelled to the hallway. Bill dropped the football. Bill got the football there. Mary moved to the garden. Bill passed the football to Mary. Jeff went to the office. Fred went to the garden. Mary gave the football to Fred.
babilong_0k_qa5_sample_58
148
151
490
Write a function to extract all the pairs which are symmetric in the given tuple list.
def extract_symmetric(test_list): temp = set(test_list) & {(b, a) for a, b in test_list} res = {(a, b) for a, b in temp if a < b} return (res)
[ "assert extract_symmetric([(6, 7), (2, 3), (7, 6), (9, 8), (10, 2), (8, 9)] ) == {(8, 9), (6, 7)}", "assert extract_symmetric([(7, 8), (3, 4), (8, 7), (10, 9), (11, 3), (9, 10)] ) == {(9, 10), (7, 8)}", "assert extract_symmetric([(8, 9), (4, 5), (9, 8), (11, 10), (12, 4), (10, 11)] ) == {(8, 9), (10, 11)}" ]
[]
John moved to the hallway. Daniel went to the office. Daniel moved to the hallway. Sandra journeyed to the hallway. Sandra journeyed to the garden. Sandra moved to the hallway. John moved to the office. Daniel went back to the kitchen. John journeyed to the bedroom. Sandra went back to the bedroom. Sandra travelled to the hallway. John went back to the office. Sandra travelled to the bedroom. Sandra grabbed the football there. Sandra left the football. Mary moved to the hallway. Mary went to the kitchen. Sandra moved to the hallway. Sandra travelled to the office. Mary went to the bedroom. John journeyed to the garden. Mary journeyed to the kitchen. Mary journeyed to the bathroom. Mary journeyed to the hallway. Daniel went back to the office. Sandra moved to the bathroom. Daniel went back to the hallway. Sandra grabbed the milk. Sandra moved to the hallway. Daniel travelled to the garden. Sandra discarded the milk. Sandra grabbed the milk. Mary went back to the garden. Daniel journeyed to the bedroom. Mary went to the bedroom. John went to the office. Daniel took the apple there. Sandra dropped the milk. Daniel put down the apple. Sandra picked up the milk. Sandra moved to the garden. Mary got the apple. Mary left the apple. Sandra journeyed to the bedroom. Sandra journeyed to the garden. Daniel grabbed the apple. Daniel dropped the apple there. Sandra put down the milk. Mary took the apple. Sandra went back to the bedroom. Mary left the apple. Mary grabbed the football there. John journeyed to the bathroom. Daniel took the apple. John went back to the kitchen. Mary travelled to the bathroom. John moved to the hallway. Mary discarded the football. Daniel dropped the apple. Daniel went back to the office. Sandra moved to the bathroom. Daniel went to the bedroom. Mary took the football there. Mary moved to the office. Mary put down the football. Daniel grabbed the apple there. John travelled to the bathroom. Daniel went to the garden. Mary went to the kitchen. Sandra went to the kitchen. Sandra moved to the hallway. Daniel discarded the apple. Daniel grabbed the apple. Daniel dropped the apple. Sandra journeyed to the bathroom. Daniel went back to the bathroom. Sandra travelled to the garden. Mary went back to the office. John moved to the garden. Mary took the football. John grabbed the apple. Mary went to the hallway. John left the apple. Sandra took the apple. John moved to the kitchen. Sandra moved to the bedroom. Sandra left the apple. Mary left the football. Mary moved to the office. Sandra moved to the garden. Sandra journeyed to the hallway. Daniel travelled to the hallway. Sandra went back to the garden. Sandra got the milk there. Daniel took the football. Sandra went to the office. Daniel left the football. Sandra dropped the milk there. Sandra took the milk. Sandra travelled to the kitchen. Daniel grabbed the football. Mary moved to the bedroom. Sandra put down the milk there. Mary went back to the hallway. Daniel went to the garden. Mary went back to the bedroom. Sandra went to the office. Mary travelled to the bathroom. Daniel moved to the bathroom. John grabbed the milk. Mary journeyed to the office. John journeyed to the bedroom. John put down the milk there. Daniel moved to the bedroom. Daniel dropped the football. John grabbed the milk.
babilong_0k_qa3_sample_19
699
152
507
Write a function to remove specific words from a given list.
def remove_words(list1, removewords): for word in list(list1): if word in removewords: list1.remove(word) return list1
[ "assert remove_words(['red', 'green', 'blue', 'white', 'black', 'orange'],['white', 'orange'])==['red', 'green', 'blue', 'black']", "assert remove_words(['red', 'green', 'blue', 'white', 'black', 'orange'],['black', 'orange'])==['red', 'green', 'blue', 'white']", "assert remove_words(['red', 'green', 'blue', 'white', 'black', 'orange'],['blue', 'white'])==['red', 'green', 'black', 'orange']" ]
[]
The bathroom is west of the bedroom. The garden is west of the bathroom.
babilong_0k_qa4_sample_97
17
152
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)]", "assert count_common(['one', 'two', 'three', 'four', 'five', 'one', 'two', 'one', 'three', 'one']) == [('one', 4), ('two', 2), ('three', 2), ('four', 1)]", "assert count_common(['Facebook', 'Apple', 'Amazon', 'Netflix', 'Google', 'Apple', 'Netflix', 'Amazon']) == [('Apple', 2), ('Amazon', 2), ('Netflix', 2), ('Facebook', 1)]" ]
[]
The hallway is south of the kitchen. The bathroom is north of the kitchen.
babilong_0k_qa4_sample_71
17
153
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" ]
[ "assert check_k_elements([(4, 4), (4, 4, 4), (4, 4), (4, 4, 6, 4), (4, )], 4) == False" ]
The hallway is north of the office. The kitchen is north of the hallway.
babilong_0k_qa4_sample_58
17
153
36
Write a python function to find the nth digit in the proper fraction of two given numbers.
def find_Nth_Digit(p,q,N) : while (N > 0) : N -= 1; p *= 10; res = p // q; p %= q; return res;
[ "assert find_Nth_Digit(1,2,1) == 5", "assert find_Nth_Digit(3,5,1) == 6", "assert find_Nth_Digit(5,6,5) == 3" ]
[]
Mary grabbed the football there. Sandra travelled to the office. Sandra picked up the apple there. Sandra journeyed to the bedroom. Sandra journeyed to the kitchen. Mary travelled to the garden. John moved to the bathroom. Daniel went to the bathroom. Mary left the football. Daniel took the milk there. Mary picked up the football there. John went to the garden. Mary put down the football there. Daniel put down the milk there. Daniel grabbed the milk there. Daniel went to the kitchen.
babilong_0k_qa2_sample_26
102
153
203
Write a python function to find the hamming distance between given two integers.
def hamming_Distance(n1,n2) : x = n1 ^ n2 setBits = 0 while (x > 0) : setBits += x & 1 x >>= 1 return setBits
[ "assert hamming_Distance(4,8) == 2", "assert hamming_Distance(2,4) == 2", "assert hamming_Distance(1,2) == 2" ]
[]
Bill went to the bedroom. Jeff went to the bedroom. Mary took the milk there. Mary moved to the garden. Mary dropped the milk. Fred went back to the hallway. Mary got the milk there. Mary left the milk. Mary picked up the milk there. Mary went back to the kitchen. Bill moved to the garden. Jeff moved to the kitchen. Fred travelled to the kitchen. Jeff went back to the garden. Mary handed the milk to Fred. Fred handed the milk to Mary. Jeff went to the office. Mary left the milk. Fred grabbed the milk there. Jeff journeyed to the hallway. Fred passed the milk to Mary. Mary handed the milk to Fred. Bill moved to the office. Fred handed the milk to Mary.
babilong_0k_qa5_sample_97
152
153
237
Write a function to check the occurrences of records which occur similar times in the given tuples.
from collections import Counter def check_occurences(test_list): res = dict(Counter(tuple(ele) for ele in map(sorted, test_list))) return (res)
[ "assert check_occurences([(3, 1), (1, 3), (2, 5), (5, 2), (6, 3)] ) == {(1, 3): 2, (2, 5): 2, (3, 6): 1}", "assert check_occurences([(4, 2), (2, 4), (3, 6), (6, 3), (7, 4)] ) == {(2, 4): 2, (3, 6): 2, (4, 7): 1}", "assert check_occurences([(13, 2), (11, 23), (12, 25), (25, 12), (16, 23)] ) == {(2, 13): 1, (11, 23): 1, (12, 25): 2, (16, 23): 1}" ]
[]
Daniel travelled to the bedroom. Sandra moved to the bathroom. John went back to the bedroom. Sandra travelled to the kitchen. Sandra went back to the office. Sandra moved to the garden. Daniel went to the kitchen. John travelled to the bathroom.
babilong_0k_qa1_sample_34
51
153
396
Write a function to check whether the given string starts and ends with the same character or not using regex.
import re regex = r'^[a-z]$|^([a-z]).*\1$' def check_char(string): if(re.search(regex, string)): return "Valid" else: return "Invalid"
[ "assert check_char(\"abba\") == \"Valid\"", "assert check_char(\"a\") == \"Valid\"", "assert check_char(\"abcd\") == \"Invalid\"" ]
[]
John travelled to the office. Mary journeyed to the kitchen.
babilong_0k_qa1_sample_2
14
153
57
Write a python function to find the largest number that can be formed with the given digits.
def find_Max_Num(arr,n) : arr.sort(reverse = True) num = arr[0] for i in range(1,n) : num = num * 10 + arr[i] return num
[ "assert find_Max_Num([1,2,3],3) == 321", "assert find_Max_Num([4,5,6,1],4) == 6541", "assert find_Max_Num([1,2,3,9],4) == 9321" ]
[]
John got the milk there. Sandra journeyed to the hallway. Daniel went back to the bedroom. John left the milk. Daniel got the apple there. Sandra picked up the milk there. Sandra went to the bathroom. John went to the bathroom. Sandra journeyed to the bedroom. John travelled to the office. Mary travelled to the kitchen. Sandra moved to the bathroom. Mary went back to the hallway. Sandra dropped the milk.
babilong_0k_qa2_sample_63
88
155
150
Write a python function to find whether the given number is present in the infinite sequence or not.
def does_Contain_B(a,b,c): if (a == b): return True if ((b - a) * c > 0 and (b - a) % c == 0): return True return False
[ "assert does_Contain_B(1,7,3) == True", "assert does_Contain_B(1,-3,5) == False", "assert does_Contain_B(3,2,5) == False" ]
[]
John journeyed to the garden. Sandra went to the office. Sandra moved to the hallway. Mary went to the office. Sandra picked up the milk there. Sandra dropped the milk there. Mary journeyed to the bedroom. Sandra got the milk there. John moved to the office. Sandra travelled to the garden. Mary journeyed to the kitchen. Mary took the football there. Sandra discarded the milk. Daniel moved to the hallway. Mary discarded the football. Mary travelled to the garden.
babilong_0k_qa2_sample_48
99
155
381
Write a function to sort a list of lists by a given index of the inner list.
from operator import itemgetter def index_on_inner_list(list_data, index_no): result = sorted(list_data, key=itemgetter(index_no)) return result
[ "assert index_on_inner_list([('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,0)==[('Beau Turnbull', 94, 98), ('Brady Kent', 97, 96), ('Greyson Fulton', 98, 99), ('Wyatt Knott', 91, 94)]", "assert index_on_inner_list([('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,1)==[('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98), ('Brady Kent', 97, 96), ('Greyson Fulton', 98, 99)]", "assert index_on_inner_list([('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,2)==[('Wyatt Knott', 91, 94), ('Brady Kent', 97, 96), ('Beau Turnbull', 94, 98), ('Greyson Fulton', 98, 99)]" ]
[]
The hallway is west of the office. The office is west of the kitchen.
babilong_0k_qa4_sample_69
17
155
81
Write a function to zip the two given tuples.
def zip_tuples(test_tup1, test_tup2): res = [] for i, j in enumerate(test_tup1): res.append((j, test_tup2[i % len(test_tup2)])) return (res)
[ "assert zip_tuples((7, 8, 4, 5, 9, 10),(1, 5, 6) ) == [(7, 1), (8, 5), (4, 6), (5, 1), (9, 5), (10, 6)]", "assert zip_tuples((8, 9, 5, 6, 10, 11),(2, 6, 7) ) == [(8, 2), (9, 6), (5, 7), (6, 2), (10, 6), (11, 7)]", "assert zip_tuples((9, 10, 6, 7, 11, 12),(3, 7, 8) ) == [(9, 3), (10, 7), (6, 8), (7, 3), (11, 7), (12, 8)]" ]
[]
Fred moved to the kitchen. Jeff grabbed the football there. Jeff left the football. Jeff moved to the bathroom. Jeff went back to the hallway. Fred went to the office. Fred journeyed to the bedroom. Jeff went to the office. Fred moved to the hallway. Fred went to the garden. Jeff went to the bathroom. Jeff travelled to the garden. Bill journeyed to the office. Bill got the apple there. Fred went back to the hallway. Bill dropped the apple. Fred got the football there. Jeff travelled to the bedroom. Fred journeyed to the bathroom. Fred dropped the football. Bill picked up the apple there. Jeff journeyed to the hallway. Bill dropped the apple. Bill picked up the apple there. Fred picked up the football there. Fred moved to the hallway. Jeff moved to the garden. Bill moved to the garden. Fred went to the office. Bill passed the apple to Mary. Mary left the apple. Fred dropped the football. Bill grabbed the apple there. Bill gave the apple to Mary. Mary gave the apple to Bill. Bill handed the apple to Mary.
babilong_0k_qa5_sample_76
224
156
172
Write a function to find the occurence of characters 'std' in the given string 1. list item 1. list item 1. list item 2. list item 2. list item 2. list item
def count_occurance(s): count=0 for i in range(len(s)): if (s[i]== 's' and s[i+1]=='t' and s[i+2]== 'd'): count = count + 1 return count
[ "assert count_occurance(\"letstdlenstdporstd\") == 3", "assert count_occurance(\"truststdsolensporsd\") == 1", "assert count_occurance(\"makestdsostdworthit\") == 2" ]
[]
Jeff journeyed to the garden. Fred went to the office. Fred went to the hallway. Fred got the apple there. Fred moved to the office. Fred went to the kitchen. Fred put down the apple. Fred took the apple there. Mary went back to the garden. Fred travelled to the bathroom. Jeff grabbed the milk there. Bill went to the office. Jeff journeyed to the bathroom. Jeff put down the milk there. Fred picked up the milk there. Fred passed the apple to Jeff. Jeff handed the apple to Fred. Fred handed the apple to Jeff. Jeff put down the apple. Fred gave the milk to Jeff. Jeff left the milk. Bill picked up the football there.
babilong_0k_qa5_sample_72
142
157
385
Write a function to find the n'th perrin number using recursion.
def get_perrin(n): if (n == 0): return 3 if (n == 1): return 0 if (n == 2): return 2 return get_perrin(n - 2) + get_perrin(n - 3)
[ "assert get_perrin(9) == 12", "assert get_perrin(4) == 2", "assert get_perrin(6) == 5" ]
[]
Jeff went back to the hallway. Bill picked up the milk there. Bill gave the milk to Mary. Mary handed the milk to Bill.
babilong_0k_qa5_sample_29
29
157
87
Write a function to merge three dictionaries into a single expression.
import collections as ct def merge_dictionaries_three(dict1,dict2, dict3): merged_dict = dict(ct.ChainMap({},dict1,dict2,dict3)) return merged_dict
[ "assert merge_dictionaries_three({ \"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'}", "assert merge_dictionaries_three({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" },{\"L\":\"lavender\",\"B\":\"Blue\"})=={'W': 'White', 'P': 'Pink', 'B': 'Black', 'R': 'Red', 'G': 'Green', 'L': 'lavender'}", "assert merge_dictionaries_three({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" },{\"L\":\"lavender\",\"B\":\"Blue\"},{ \"G\": \"Green\", \"W\": \"White\" })=={'B': 'Black', 'P': 'Pink', 'R': 'Red', 'G': 'Green', 'L': 'lavender', 'W': 'White'}" ]
[]
The garden is north of the kitchen. The bathroom is north of the garden.
babilong_0k_qa4_sample_38
17
158
295
Write a function to return the sum of all divisors of a number.
def sum_div(number): divisors = [1] for i in range(2, number): if (number % i)==0: divisors.append(i) return sum(divisors)
[ "assert sum_div(8)==7", "assert sum_div(12)==16", "assert sum_div(7)==1" ]
[]
Sandra picked up the milk. John took the apple. Mary got the football. Sandra travelled to the garden. Mary travelled to the office. John discarded the apple. Mary moved to the kitchen. John got the apple there. John left the apple. Sandra journeyed to the hallway. John picked up the apple. Sandra dropped the milk there. Sandra journeyed to the kitchen. Daniel journeyed to the kitchen. John went to the hallway. Mary moved to the hallway.
babilong_0k_qa3_sample_84
97
159
376
Write a function to remove tuple elements that occur more than once and replace the duplicates with some custom value.
def remove_replica(test_tup): temp = set() res = tuple(ele if ele not in temp and not temp.add(ele) else 'MSP' for ele in test_tup) return (res)
[ "assert remove_replica((1, 1, 4, 4, 4, 5, 5, 6, 7, 7)) == (1, 'MSP', 4, 'MSP', 'MSP', 5, 'MSP', 6, 7, 'MSP')", "assert remove_replica((2, 3, 4, 4, 5, 6, 6, 7, 8, 9, 9)) == (2, 3, 4, 'MSP', 5, 6, 'MSP', 7, 8, 9, 'MSP')", "assert remove_replica((2, 2, 5, 4, 5, 7, 5, 6, 7, 7)) == (2, 'MSP', 5, 4, 'MSP', 7, 'MSP', 6, 'MSP', 'MSP')" ]
[]
The garden is north of the bedroom. The hallway is north of the garden.
babilong_0k_qa4_sample_93
17
159
425
Write a function to count the number of sublists containing a particular element.
def count_element_in_list(list1, x): ctr = 0 for i in range(len(list1)): if x in list1[i]: ctr+= 1 return ctr
[ "assert count_element_in_list([[1, 3], [5, 7], [1, 11], [1, 15, 7]],1)==3", "assert count_element_in_list([['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'A')==3", "assert count_element_in_list([['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'E')==1" ]
[]
John got the apple. Sandra moved to the bedroom. Daniel grabbed the milk. Daniel journeyed to the office. Daniel went back to the hallway. John discarded the apple. John got the apple. Daniel left the milk there. Mary got the milk. Mary dropped the milk there. John put down the apple. John went to the office. Daniel took the milk. Daniel travelled to the kitchen. Daniel moved to the garden. Daniel dropped the milk. Mary travelled to the bathroom. John went to the bathroom.
babilong_0k_qa3_sample_31
104
159
461
Write a python function to count the upper case characters in a given string.
def upper_ctr(str): upper_ctr = 0 for i in range(len(str)): if str[i] >= 'A' and str[i] <= 'Z': upper_ctr += 1 return upper_ctr
[ "assert upper_ctr('PYthon') == 1", "assert upper_ctr('BigData') == 1", "assert upper_ctr('program') == 0" ]
[]
Mary went back to the bedroom. Mary moved to the office. Mary went back to the bathroom. Sandra moved to the hallway. Mary went to the garden. Sandra went to the kitchen.
babilong_0k_qa1_sample_6
39
159
210
Write a function to check that the given string contains only a certain set of characters(in this case a-z, a-z and 0-9) by using regex.
import re def is_allowed_specific_char(string): get_char = re.compile(r'[^a-zA-Z0-9.]') string = get_char.search(string) return not bool(string)
[ "assert is_allowed_specific_char(\"ABCDEFabcdef123450\") == True", "assert is_allowed_specific_char(\"*&%@#!}{\") == False", "assert is_allowed_specific_char(\"HELLOhowareyou98765\") == True" ]
[]
Bill went to the kitchen. Jeff went back to the bedroom. Fred went back to the hallway. Fred journeyed to the garden. Bill travelled to the bedroom. Fred picked up the milk there. Fred went to the office. Jeff went back to the hallway. Jeff travelled to the kitchen. Bill went back to the kitchen. Fred journeyed to the hallway. Bill moved to the hallway. Jeff travelled to the bedroom. Jeff journeyed to the bathroom. Fred gave the milk to Mary. Mary handed the milk to Fred. Bill moved to the kitchen. Fred gave the milk to Mary. Mary passed the milk to Fred. Bill went back to the bathroom.
babilong_0k_qa5_sample_83
134
160
79
Write a python function to check whether the length of the word is odd 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(\"Hadoop\") == False", "assert word_len(\"great\") == True", "assert word_len(\"structure\") == True" ]
[]
Sandra journeyed to the kitchen. Daniel journeyed to the bathroom.
babilong_0k_qa1_sample_41
16
161
198
Write a function to find the largest triangle that can be inscribed in an ellipse.
import math def largest_triangle(a,b): if (a < 0 or b < 0): return -1 area = (3 * math.sqrt(3) * pow(a, 2)) / (4 * b); return area
[ "assert largest_triangle(4,2)==10.392304845413264", "assert largest_triangle(5,7)==4.639421805988064", "assert largest_triangle(9,1)==105.2220865598093" ]
[]
The kitchen is south of the office. The garden is south of the kitchen.
babilong_0k_qa4_sample_1
17
161
321
Write a function to find the demlo number for the given number.
def find_demlo(s): l = len(s) res = "" for i in range(1,l+1): res = res + str(i) for i in range(l-1,0,-1): res = res + str(i) return res
[ "assert find_demlo(\"111111\") == '12345654321'", "assert find_demlo(\"1111\") == '1234321'", "assert find_demlo(\"13333122222\") == '123456789101110987654321'" ]
[]
John grabbed the milk there. John left the milk. Sandra took the milk there. Sandra moved to the kitchen. Sandra put down the milk. John journeyed to the office.
babilong_0k_qa2_sample_44
37
161
452
Write a function that gives loss amount if the given amount has loss else return none.
def loss_amount(actual_cost,sale_amount): if(sale_amount > actual_cost): amount = sale_amount - actual_cost return amount else: return None
[ "assert loss_amount(1500,1200)==None", "assert loss_amount(100,200)==100", "assert loss_amount(2000,5000)==3000" ]
[]
Daniel went to the garden. Daniel journeyed to the bathroom. Mary journeyed to the garden. Sandra went back to the garden. Mary went back to the bedroom. Daniel went back to the kitchen.
babilong_0k_qa1_sample_71
42
161
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" ]
[ "assert binomial_Coeff(14,6) == 3003" ]
Mary went to the garden. Daniel journeyed to the kitchen. John moved to the kitchen. John travelled to the bathroom.
babilong_0k_qa1_sample_84
26
164
76
Write a python function to count the number of squares in a rectangle.
def count_Squares(m,n): if(n < m): temp = m m = n n = temp return ((m * (m + 1) * (2 * m + 1) / 6 + (n - m) * m * (m + 1) / 2))
[ "assert count_Squares(4,3) == 20", "assert count_Squares(2,2) == 5", "assert count_Squares(1,1) == 1" ]
[]
Mary travelled to the bathroom. Sandra journeyed to the hallway. Mary went to the kitchen. Daniel moved to the office. Daniel journeyed to the bedroom. Mary travelled to the bedroom. Sandra moved to the office. Sandra went back to the bathroom. John went back to the bathroom. John moved to the office.
babilong_0k_qa1_sample_58
65
164
217
Write a python function to find the first repeated character in a given string.
def first_Repeated_Char(str): h = {} for ch in str: if ch in h: return ch; else: h[ch] = 0 return '\0'
[ "assert first_Repeated_Char(\"Google\") == \"o\"", "assert first_Repeated_Char(\"data\") == \"a\"", "assert first_Repeated_Char(\"python\") == '\\0'" ]
[]
Sandra took the football there. Mary travelled to the kitchen. John went to the office. Daniel travelled to the bedroom. Daniel journeyed to the bathroom. Mary went back to the bedroom. Sandra travelled to the kitchen. Mary went to the bathroom. Sandra went back to the bathroom. Sandra discarded the football. Mary journeyed to the bedroom. Sandra picked up the football there. Mary grabbed the milk there. Mary discarded the milk. Daniel moved to the bedroom. Mary picked up the milk there. Mary got the apple there. Sandra went back to the kitchen. Mary discarded the apple there. Daniel took the apple there. Mary put down the milk there. Daniel travelled to the bathroom. Mary journeyed to the hallway. Daniel went to the kitchen. Daniel went back to the bathroom. Daniel dropped the apple.
babilong_0k_qa2_sample_12
165
164
449
Write a python function to check whether the triangle is valid or not if 3 points are given.
def check_Triangle(x1,y1,x2,y2,x3,y3): a = (x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2)) if a == 0: return ('No') else: return ('Yes')
[ "assert check_Triangle(1,5,2,5,4,6) == 'Yes'", "assert check_Triangle(1,1,1,4,1,5) == 'No'", "assert check_Triangle(1,1,1,1,1,1) == 'No'" ]
[]
The garden is west of the bathroom. The bathroom is west of the bedroom.
babilong_0k_qa4_sample_81
17
164
128
Write a function to shortlist words that are longer than n from a given list of words.
def long_words(n, str): word_len = [] txt = str.split(" ") for x in txt: if len(x) > n: word_len.append(x) return word_len
[ "assert long_words(3,\"python is a programming language\")==['python','programming','language']", "assert long_words(2,\"writing a program\")==['writing','program']", "assert long_words(5,\"sorting list\")==['sorting']" ]
[]
The kitchen is west of the bathroom. The bathroom is west of the bedroom.
babilong_0k_qa4_sample_16
17
165
222
Write a function to check if all the elements in tuple have same data type or not.
def check_type(test_tuple): res = True for ele in test_tuple: if not isinstance(ele, type(test_tuple[0])): res = False break return (res)
[ "assert check_type((5, 6, 7, 3, 5, 6) ) == True", "assert check_type((1, 2, \"4\") ) == False", "assert check_type((3, 2, 1, 4, 5) ) == True" ]
[]
The bedroom is east of the garden. The garden is east of the hallway.
babilong_0k_qa4_sample_72
17
166
401
Write a function to perform index wise addition of tuple elements in the given two nested tuples.
def add_nested_tuples(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 add_nested_tuples(((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))) == ((7, 10), (7, 14), (3, 10), (8, 13))", "assert add_nested_tuples(((2, 4), (5, 6), (3, 10), (2, 11)), ((7, 8), (4, 10), (2, 2), (8, 4))) == ((9, 12), (9, 16), (5, 12), (10, 15))", "assert add_nested_tuples(((3, 5), (6, 7), (4, 11), (3, 12)), ((8, 9), (5, 11), (3, 3), (9, 5))) == ((11, 14), (11, 18), (7, 14), (12, 17))" ]
[]
Mary journeyed to the hallway. Mary travelled to the bathroom. Jeff journeyed to the office. Bill moved to the bathroom. Mary journeyed to the hallway. Mary went back to the garden. Bill travelled to the garden. Bill journeyed to the hallway. Bill went back to the kitchen. Jeff got the milk there. Mary journeyed to the bedroom. Jeff travelled to the hallway. Bill moved to the hallway. Jeff journeyed to the bedroom. Bill journeyed to the bathroom. Jeff dropped the milk. Mary got the milk there. Mary passed the milk to Jeff. Jeff dropped the milk. Jeff took the milk there.
babilong_0k_qa5_sample_31
129
166
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!'" ]
[ "assert text_match(\"aab-cbbbc\") == 'Not matched!'" ]
Daniel journeyed to the hallway. Daniel journeyed to the garden. Mary went back to the kitchen. Daniel went back to the office. Mary journeyed to the bathroom. John moved to the hallway. Daniel grabbed the football there. Daniel went to the kitchen. Daniel discarded the football. John went to the bathroom. Daniel took the football there. John travelled to the kitchen. Mary travelled to the office. John travelled to the hallway. John went back to the office. Daniel journeyed to the bedroom. Daniel got the milk there. Daniel discarded the milk. Sandra went to the bathroom. Mary went back to the bedroom.
babilong_0k_qa2_sample_8
127
167
100
Write a function to find the next smallest palindrome of a specified number.
import sys def next_smallest_palindrome(num): numstr = str(num) for i in range(num+1,sys.maxsize): if str(i) == str(i)[::-1]: return i
[ "assert next_smallest_palindrome(99)==101", "assert next_smallest_palindrome(1221)==1331", "assert next_smallest_palindrome(120)==121" ]
[]
Fred went back to the hallway. Bill journeyed to the bedroom. Jeff travelled to the bathroom. Fred got the football there. Fred journeyed to the bathroom. Mary got the apple there. Mary left the apple. Mary got the apple there. Fred dropped the football there. Bill went back to the office. Fred took the football there. Fred dropped the football. Fred grabbed the football there. Mary gave the apple to Fred. Fred went back to the bedroom. Fred went to the bathroom. Bill went back to the bedroom. Mary went back to the bedroom. Fred gave the apple to Jeff. Jeff handed the apple to Fred. Fred dropped the apple there. Fred took the apple there.
babilong_0k_qa5_sample_90
141
167
270
Write a python function to find the sum of even numbers at even positions.
def sum_even_and_even_index(arr,n): i = 0 sum = 0 for i in range(0,n,2): if (arr[i] % 2 == 0) : sum += arr[i] return sum
[ "assert sum_even_and_even_index([5, 6, 12, 1, 18, 8],6) == 30", "assert sum_even_and_even_index([3, 20, 17, 9, 2, 10, 18, 13, 6, 18],10) == 26", "assert sum_even_and_even_index([5, 6, 12, 1],4) == 12" ]
[]
Fred travelled to the bedroom. Jeff travelled to the office. Fred went to the hallway. Bill moved to the office. Mary travelled to the bedroom. Bill journeyed to the bedroom. Jeff went back to the kitchen. Bill picked up the apple there. Bill handed the apple to Mary. Jeff grabbed the milk there. Jeff went to the garden. Bill went back to the office. Jeff moved to the hallway. Jeff gave the milk to Fred.
babilong_0k_qa5_sample_53
91
168
331
Write a python function to count unset bits of a given number.
def count_unset_bits(n): count = 0 x = 1 while(x < n + 1): if ((x & n) == 0): count += 1 x = x << 1 return count
[ "assert count_unset_bits(2) == 1", "assert count_unset_bits(4) == 2", "assert count_unset_bits(6) == 1" ]
[]
Sandra went back to the kitchen. John picked up the milk there. John left the milk. Sandra went to the garden. Mary went to the bathroom. Daniel journeyed to the garden. Sandra took the football there. Daniel moved to the kitchen. John took the milk there. John put down the milk there. John went to the bathroom. Sandra put down the football.
babilong_0k_qa2_sample_31
77
168
505
Write a function to move all zeroes to the end of the given array.
def re_order(A): k = 0 for i in A: if i: A[k] = i k = k + 1 for i in range(k, len(A)): A[i] = 0 return A
[ "assert re_order([6, 0, 8, 2, 3, 0, 4, 0, 1]) == [6, 8, 2, 3, 4, 1, 0, 0, 0]", "assert re_order([4, 0, 2, 7, 0, 9, 0, 12, 0]) == [4, 2, 7, 9, 12, 0, 0, 0, 0]", "assert re_order([3, 11, 0, 74, 14, 0, 1, 0, 2]) == [3, 11, 74, 14, 1, 2, 0, 0, 0]" ]
[]
John journeyed to the bedroom. Sandra journeyed to the garden. Daniel went back to the hallway. Mary went to the hallway. Daniel travelled to the kitchen. Daniel went to the office. Daniel travelled to the bedroom. Sandra went to the office.
babilong_0k_qa1_sample_76
52
168
349
Write a python function to check whether the given string is a binary string or not.
def check(string) : p = set(string) s = {'0', '1'} if s == p or p == {'0'} or p == {'1'}: return ("Yes") else : return ("No")
[ "assert check(\"01010101010\") == \"Yes\"", "assert check(\"name0\") == \"No\"", "assert check(\"101\") == \"Yes\"" ]
[]
John picked up the football. Daniel travelled to the hallway. John left the football. Sandra picked up the football. Daniel journeyed to the kitchen. Sandra put down the football. Sandra travelled to the office. Sandra grabbed the milk. Sandra journeyed to the hallway. John travelled to the office. Sandra left the milk. Sandra grabbed the milk. Mary grabbed the football. Sandra went back to the bathroom. Sandra dropped the milk there. Mary moved to the bathroom. Sandra got the milk. Sandra journeyed to the hallway. Sandra dropped the milk. Sandra went to the office. John travelled to the bedroom. Mary discarded the football. Mary went back to the hallway. Sandra moved to the kitchen. John took the apple. Daniel went back to the garden. John went back to the kitchen. Mary travelled to the bathroom. John moved to the bedroom. John put down the apple there. Sandra travelled to the garden. John went back to the kitchen.
babilong_0k_qa3_sample_29
193
169
445
Write a function to perform index wise multiplication of tuple elements in the given two tuples.
def index_multiplication(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 index_multiplication(((1, 3), (4, 5), (2, 9), (1, 10)),((6, 7), (3, 9), (1, 1), (7, 3)) ) == ((6, 21), (12, 45), (2, 9), (7, 30))", "assert index_multiplication(((2, 4), (5, 6), (3, 10), (2, 11)),((7, 8), (4, 10), (2, 2), (8, 4)) ) == ((14, 32), (20, 60), (6, 20), (16, 44))", "assert index_multiplication(((3, 5), (6, 7), (4, 11), (3, 12)),((8, 9), (5, 11), (3, 3), (9, 5)) ) == ((24, 45), (30, 77), (12, 33), (27, 60))" ]
[]
Sandra moved to the office. John went back to the garden. Mary went to the office. Daniel travelled to the bedroom. Sandra travelled to the garden. Daniel travelled to the hallway. John travelled to the bedroom. John went to the hallway.
babilong_0k_qa1_sample_57
51
169
259
Write a function to maximize the given two tuples.
def maximize_elements(test_tup1, test_tup2): res = tuple(tuple(max(a, b) for a, b in zip(tup1, tup2)) for tup1, tup2 in zip(test_tup1, test_tup2)) return (res)
[ "assert maximize_elements(((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))) == ((6, 7), (4, 9), (2, 9), (7, 10))", "assert maximize_elements(((2, 4), (5, 6), (3, 10), (2, 11)), ((7, 8), (4, 10), (2, 2), (8, 4))) == ((7, 8), (5, 10), (3, 10), (8, 11))", "assert maximize_elements(((3, 5), (6, 7), (4, 11), (3, 12)), ((8, 9), (5, 11), (3, 3), (9, 5))) == ((8, 9), (6, 11), (4, 11), (9, 12))" ]
[]
Sandra travelled to the bedroom. John travelled to the garden. Mary went to the hallway. Mary went back to the bedroom. Sandra went to the kitchen. Sandra journeyed to the garden.
babilong_0k_qa1_sample_38
40
170
473
Write a function to find the tuple intersection of elements in the given tuple list irrespective of their order.
def tuple_intersection(test_list1, test_list2): res = set([tuple(sorted(ele)) for ele in test_list1]) & set([tuple(sorted(ele)) for ele in test_list2]) return (res)
[ "assert tuple_intersection([(3, 4), (5, 6), (9, 10), (4, 5)] , [(5, 4), (3, 4), (6, 5), (9, 11)]) == {(4, 5), (3, 4), (5, 6)}", "assert tuple_intersection([(4, 1), (7, 4), (11, 13), (17, 14)] , [(1, 4), (7, 4), (16, 12), (10, 13)]) == {(4, 7), (1, 4)}", "assert tuple_intersection([(2, 1), (3, 2), (1, 3), (1, 4)] , [(11, 2), (2, 3), (6, 2), (1, 3)]) == {(1, 3), (2, 3)}" ]
[]
Jeff went back to the garden. Mary journeyed to the garden. Jeff took the football there. Bill journeyed to the garden. Mary took the milk there. Jeff handed the football to Mary. Mary handed the football to Bill. Bill put down the football. Fred went back to the bathroom. Mary got the apple there. Mary gave the apple to Bill. Bill handed the apple to Mary. Mary handed the apple to Bill. Bill took the football there.
babilong_0k_qa5_sample_27
94
170