Dataset Viewer
Auto-converted to Parquet Duplicate
task_id
int64
601
974
text
stringlengths
38
249
code
stringlengths
30
908
test_list
listlengths
3
3
test_setup_code
stringclasses
2 values
challenge_test_list
listlengths
0
0
855
Write a python function to find minimum possible value for the given periodic function.
import re def replace(string, char): pattern = char + '{2,}' string = re.sub(pattern, char, string) return string
[ "assert listify_list(['Red', 'Blue', 'Black', 'White', 'Pink'])==[['R', 'e', 'd'], ['B', 'l', 'u', 'e'], ['B', 'l', 'a', 'c', 'k'], ['W', 'h', 'i', 't', 'e'], ['P', 'i', 'n', 'k']]", "assert listify_list(['python'])==[['p', 'y', 't', 'h', 'o', 'n']]", "assert listify_list([' red ', 'green',' black', 'blue ',' o...
[]
729
Write a function to replace all occurrences of spaces, commas, or dots with a colon.
def Odd_Length_Sum(arr): Sum = 0 l = len(arr) for i in range(l): Sum += ((((i + 1) *(l - i) + 1) // 2) * arr[i]) return Sum
[ "assert sort_dict_item({(5, 6) : 3, (2, 3) : 9, (8, 4): 10, (6, 4): 12} ) == {(2, 3): 9, (6, 4): 12, (5, 6): 3, (8, 4): 10}", "assert sort_dict_item({(6, 7) : 4, (3, 4) : 10, (9, 5): 11, (7, 5): 13} ) == {(3, 4): 10, (7, 5): 13, (6, 7): 4, (9, 5): 11}", "assert sort_dict_item({(7, 8) : 5, (4, 5) : 11, (10, 6): ...
[]
677
Write a python function to copy a list from a singleton tuple.
def count_Rotation(arr,n): for i in range (1,n): if (arr[i] < arr[i - 1]): return i return 0
[ "assert unique_Element([1,1,1],3) == 'YES'", "assert unique_Element([1,2,1,2],4) == 'NO'", "assert unique_Element([1,2,3,4,5],5) == 'NO'" ]
[]
738
Write a function to remove sublists from a given list of lists, which are outside a given range.
def zip_list(list1,list2): result = list(map(list.__add__, list1, list2)) return result
[ "assert occurance_substring('python programming, python language','python')==('python', 0, 6)", "assert occurance_substring('python programming,programming language','programming')==('programming', 7, 18)", "assert occurance_substring('python programming,programming language','language')==('language', 31, 39)" ...
[]
942
Write a function to calculate wind chill index.
def is_odd(n) : if (n^1 == n-1) : return True; else : return False;
[ "assert heap_sort([12, 2, 4, 5, 2, 3]) == [2, 2, 3, 4, 5, 12]", "assert heap_sort([32, 14, 5, 6, 7, 19]) == [5, 6, 7, 14, 19, 32]", "assert heap_sort([21, 15, 29, 78, 65]) == [15, 21, 29, 65, 78]" ]
[]
623
Write a function to divide two lists using map and lambda function.
def average_tuple(nums): result = [sum(x) / len(x) for x in zip(*nums)] return result
[ "assert maximum_segments(7, 5, 2, 5) == 2", "assert maximum_segments(17, 2, 1, 3) == 17", "assert maximum_segments(18, 16, 3, 6) == 6" ]
[]
903
Write a python function to accept the strings which contains all vowels.
def is_upper(string): return (string.upper())
[ "assert len_log([\"win\",\"lose\",\"great\"]) == 3", "assert len_log([\"a\",\"ab\",\"abc\"]) == 1", "assert len_log([\"12\",\"12\",\"1234\"]) == 2" ]
[]
666
Write a function to find the longest chain which can be formed from the given set of pairs.
import math def radian_degree(degree): radian = degree*(math.pi/180) return radian
[ "assert multiply_elements((1, 5, 7, 8, 10)) == (5, 35, 56, 80)", "assert multiply_elements((2, 4, 5, 6, 7)) == (8, 20, 30, 42)", "assert multiply_elements((12, 13, 14, 9, 15)) == (156, 182, 126, 135)" ]
[]
782
Write a python function to find the sum of an array.
def check_monthnumb(monthname2): if(monthname2=="January" or monthname2=="March"or monthname2=="May" or monthname2=="July" or monthname2=="Augest" or monthname2=="October" or monthname2=="December"): return True else: return False
[ "assert maximum_value([('key1', [3, 4, 5]), ('key2', [1, 4, 2]), ('key3', [9, 3])]) == [('key1', 5), ('key2', 4), ('key3', 9)]", "assert maximum_value([('key1', [4, 5, 6]), ('key2', [2, 5, 3]), ('key3', [10, 4])]) == [('key1', 6), ('key2', 5), ('key3', 10)]", "assert maximum_value([('key1', [5, 6, 7]), ('key2',...
[]
613
Write a function to check if the given array represents min heap or not.
import heapq as hq def heap_sort(iterable): h = [] for value in iterable: hq.heappush(h, value) return [hq.heappop(h) for i in range(len(h))]
[ "assert reverse_words(\"python program\")==(\"program python\")", "assert reverse_words(\"java language\")==(\"language java\")", "assert reverse_words(\"indian man\")==(\"man indian\")" ]
[]
784
Write a python function to find sum of all prime divisors of a given number.
def max_of_three(num1,num2,num3): if (num1 >= num2) and (num1 >= num3): lnum = num1 elif (num2 >= num1) and (num2 >= num3): lnum = num2 else: lnum = num3 return lnum
[ "assert profit_amount(1500,1200)==300", "assert profit_amount(100,200)==None", "assert profit_amount(2000,5000)==None" ]
[]
868
Write a function to zip two given lists of lists.
def nth_nums(nums,n): nth_nums = list(map(lambda x: x ** n, nums)) return nth_nums
[ "assert swap_List([1,2,3]) == [3,2,1]", "assert swap_List([1,2,3,4,4]) == [4,2,3,4,1]", "assert swap_List([4,5,6]) == [6,5,4]" ]
[]
961
Write a function to add two integers. however, if the sum is between the given range it will return 20.
import datetime def check_date(m, d, y): try: m, d, y = map(int, (m, d, y)) datetime.date(y, m, d) return True except ValueError: return False
[ "assert area_trapezium(6,9,4)==30", "assert area_trapezium(10,20,30)==450", "assert area_trapezium(15,25,35)==700" ]
[]
860
Write a function to sum a specific column of a list in a given list of lists.
def add_list(nums1,nums2): result = map(lambda x, y: x + y, nums1, nums2) return list(result)
[ "assert is_nonagonal(10) == 325", "assert is_nonagonal(15) == 750", "assert is_nonagonal(18) == 1089" ]
[]
670
Write a python function to find the type of triangle from the given sides.
def check_subset(list1,list2): return all(map(list1.__contains__,list2))
[ "assert mul_list([1, 2, 3],[4,5,6])==[4,10,18]", "assert mul_list([1,2],[3,4])==[3,8]", "assert mul_list([90,120],[50,70])==[4500,8400]" ]
[]
963
Write a function to iterate over elements repeating each as many times as its count.
def mul_list(nums1,nums2): result = map(lambda x, y: x * y, nums1, nums2) return list(result)
[ "assert palindrome_lambda([\"php\", \"res\", \"Python\", \"abcd\", \"Java\", \"aaa\"])==['php', 'aaa']", "assert palindrome_lambda([\"abcd\", \"Python\", \"abba\", \"aba\"])==['abba', 'aba']", "assert palindrome_lambda([\"abcd\", \"abbccbba\", \"abba\", \"aba\"])==['abbccbba', 'abba', 'aba']" ]
[]
896
Write a function to calculate the height of the given binary tree.
def check_greater(test_tup1, test_tup2): res = all(x < y for x, y in zip(test_tup1, test_tup2)) return (res)
[ "assert find_longest_conseq_subseq([1, 2, 2, 3], 4) == 3", "assert find_longest_conseq_subseq([1, 9, 3, 10, 4, 20, 2], 7) == 4", "assert find_longest_conseq_subseq([36, 41, 56, 35, 44, 33, 34, 92, 43, 32, 42], 11) == 5" ]
[]
895
Write a python function to count number of cubes of size k in a cube of size n.
def camel_to_snake(text): import re str1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', text) return re.sub('([a-z0-9])([A-Z])', r'\1_\2', str1).lower()
[ "assert max_sum_of_three_consecutive([100, 1000, 100, 1000, 1], 5) == 2101", "assert max_sum_of_three_consecutive([3000, 2000, 1000, 3, 10], 5) == 5013", "assert max_sum_of_three_consecutive([1, 2, 3, 4, 5, 6, 7, 8], 8) == 27" ]
[]
658
Write a function to convert degrees to radians.
def sum_positivenum(nums): sum_positivenum = list(filter(lambda nums:nums>0,nums)) return sum(sum_positivenum)
[ "assert remove_length('The person is most value tet', 3) == 'person is most value'", "assert remove_length('If you told me about this ok', 4) == 'If you me about ok'", "assert remove_length('Forces of darkeness is come into the play', 4) == 'Forces of darkeness is the'" ]
[]
834
Write a python function to check whether the length of the word is even or not.
def alternate_elements(list1): result=[] for item in list1[::2]: result.append(item) return result
[ "assert remove_spaces(\"a b c\") == \"abc\"", "assert remove_spaces(\"1 2 3\") == \"123\"", "assert remove_spaces(\" b c\") == \"bc\"" ]
[]
660
Write a python function to find the average of a list.
def triangle_area(r) : if r < 0 : return -1 return r * r
[ "assert area_tetrahedron(3)==15.588457268119894", "assert area_tetrahedron(20)==692.8203230275509", "assert area_tetrahedron(10)==173.20508075688772" ]
[]
880
Write a function to check whether the given month number contains 30 days or not.
import re def road_rd(street): return (re.sub('Road$', 'Rd.', street))
[ "assert max_sum_list([[1,2,3], [4,5,6], [10,11,12], [7,8,9]])==[10, 11, 12] ", "assert max_sum_list([[3,2,1], [6,5,4], [12,11,10]])==[12,11,10] ", "assert max_sum_list([[2,3,1]])==[2,3,1] " ]
[]
771
Write a function to find the fixed point in the given array.
import re def match_num(string): text = re.compile(r"^5") if text.match(string): return True else: return False
[ "assert last([1,2,3],1,3) == 0", "assert last([1,1,1,2,3,4],1,6) == 2", "assert last([2,3,2,3,6,8,9],3,8) == 3" ]
[]
922
Write a python function to reverse an array upto a given position.
def arc_length(d,a): pi=22/7 if a >= 360: return None arclength = (pi*d) * (a/360) return arclength
[ "assert sort_String(\"cba\") == \"abc\"", "assert sort_String(\"data\") == \"aadt\"", "assert sort_String(\"zxy\") == \"xyz\"" ]
[]
604
Write a python function to count the number of lists in a given number of lists.
def sum_Natural(n): sum = (n * (n + 1)) return int(sum) def sum_Even(l,r): return (sum_Natural(int(r / 2)) - sum_Natural(int((l - 1) / 2)))
[ "assert left_rotate(\"python\",2) == \"thonpy\" ", "assert left_rotate(\"bigdata\",3 ) == \"databig\" ", "assert left_rotate(\"hadoop\",1 ) == \"adooph\" " ]
[]
718
Write a function to find the area of a trapezium.
def sum_Odd(n): terms = (n + 1)//2 sum1 = terms * terms return sum1 def sum_in_Range(l,r): return sum_Odd(r) - sum_Odd(l - 1)
[ "assert sum_nums(2,10,11,20)==20", "assert sum_nums(15,17,1,10)==32", "assert sum_nums(10,15,5,30)==20" ]
[]
825
Write a function to remove all characters except letters and numbers using regex
def find_First_Missing(array,start,end): if (start > end): return end + 1 if (start != array[start]): return start; mid = int((start + end) / 2) if (array[mid] == mid): return find_First_Missing(array,mid+1,end) return find_First_Missing(array,start,mid)
[ "assert all_Bits_Set_In_The_Given_Range(10,2,1) == True ", "assert all_Bits_Set_In_The_Given_Range(5,2,4) == False", "assert all_Bits_Set_In_The_Given_Range(22,2,3) == True " ]
[]
905
Write a python function to count the number of pairs whose sum is equal to ‘sum’.
import re def replace_specialchar(text): return (re.sub("[ ,.]", ":", text))
[ "assert sub_lists([10, 20, 30, 40])==[[], [10], [20], [30], [40], [10, 20], [10, 30], [10, 40], [20, 30], [20, 40], [30, 40], [10, 20, 30], [10, 20, 40], [10, 30, 40], [20, 30, 40], [10, 20, 30, 40]]", "assert sub_lists(['X', 'Y', 'Z'])==[[], ['X'], ['Y'], ['Z'], ['X', 'Y'], ['X', 'Z'], ['Y', 'Z'], ['X', 'Y', 'Z'...
[]
891
Write a python function to calculate the product of all the numbers of a given tuple.
def find_triplet_array(A, arr_size, sum): for i in range( 0, arr_size-2): for j in range(i + 1, arr_size-1): for k in range(j + 1, arr_size): if A[i] + A[j] + A[k] == sum: return A[i],A[j],A[k] return True return False
[ "assert match_num('5-2345861')==True", "assert match_num('6-2345861')==False", "assert match_num('78910')==False" ]
[]
714
Write a function to sort a list of lists by length and value.
def return_sum(dict): sum = 0 for i in dict.values(): sum = sum + i return sum
[ "assert rectangle_perimeter(10,20)==60", "assert rectangle_perimeter(10,5)==30", "assert rectangle_perimeter(4,2)==12" ]
[]
810
Write a function to check if the given expression is balanced or not.
def sum_Of_Subarray_Prod(arr,n): ans = 0 res = 0 i = n - 1 while (i >= 0): incr = arr[i]*(1 + res) ans += incr res = incr i -= 1 return (ans)
[ "assert sum_of_square(4) == 70", "assert sum_of_square(5) == 252", "assert sum_of_square(2) == 6" ]
[]
872
Write a function to check if each element of second tuple is smaller than its corresponding index in first tuple.
class Pair(object): def __init__(self, a, b): self.a = a self.b = b def max_chain_length(arr, n): max = 0 mcl = [1 for i in range(n)] for i in range(1, n): for j in range(0, i): if (arr[i].a > arr[j].b and mcl[i] < mcl[j] + 1): mcl[i] = mcl[j] + 1 for i in range(n): if (ma...
[ "assert camel_to_snake('GoogleAssistant') == 'google_assistant'", "assert camel_to_snake('ChromeCast') == 'chrome_cast'", "assert camel_to_snake('QuadCore') == 'quad_core'" ]
[]
889
Write a function to find the equilibrium index of the given array.
def odd_Num_Sum(n) : j = 0 sm = 0 for i in range(1,n + 1) : j = (2*i-1) sm = sm + (j*j*j*j) return sm
[ "assert get_odd_occurence([2, 3, 5, 4, 5, 2, 4, 3, 5, 2, 4, 4, 2], 13) == 5", "assert get_odd_occurence([1, 2, 3, 2, 3, 1, 3], 7) == 3", "assert get_odd_occurence([5, 7, 2, 7, 5, 2, 5], 7) == 5" ]
[]
616
Write a function to remove consecutive duplicates of a given list.
def sum_Square(n) : i = 1 while i*i <= n : j = 1 while (j*j <= n) : if (i*i+j*j == n) : return True j = j+1 i = i+1 return False
[ "assert max_product([1, 2, 3, 4, 7, 0, 8, 4])==(7, 8)", "assert max_product([0, -1, -2, -4, 5, 0, -6])==(-4, -6)", "assert max_product([1, 3, 5, 6, 8, 9])==(8,9)" ]
[]
788
Write a function to find the maximum sum of subsequences of given array with no adjacent elements.
def tuple_to_set(t): s = set(t) return (s)
[ "assert combine_lists([1, 3, 5, 7, 9, 11],[0, 2, 4, 6, 8, 10])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]", "assert combine_lists([1, 3, 5, 6, 8, 9], [2, 5, 7, 11])==[1,2,3,5,5,6,7,8,9,11]", "assert combine_lists([1,3,7],[2,4,6])==[1,2,3,4,6,7]" ]
[]
893
Write a function to get an item of a tuple.
def reverse_words(s): return ' '.join(reversed(s.split()))
[ "assert Check_Solution(2,5,2) == \"2 solutions\"", "assert Check_Solution(1,1,1) == \"No solutions\"", "assert Check_Solution(1,2,1) == \"1 solution\"" ]
[]
664
Write a python function to check whether all the characters are same or not.
def unique_sublists(list1): result ={} for l in list1: result.setdefault(tuple(l), list()).append(1) for a, b in result.items(): result[a] = sum(b) return result
[ "assert remove_parenthesis([\"python (chrome)\"])==(\"python\")", "assert remove_parenthesis([\"string(.abc)\"])==(\"string\")", "assert remove_parenthesis([\"alpha(num)\"])==(\"alpha\")" ]
[]
815
Write a function to iterate over all pairs of consecutive items in a given list.
import re def end_num(string): text = re.compile(r".*[0-9]$") if text.match(string): return True else: return False
[ "assert sum_column( [[1,2,3,2],[4,5,6,2],[7,8,9,5],],0)==12", "assert sum_column( [[1,2,3,2],[4,5,6,2],[7,8,9,5],],1)==15", "assert sum_column( [[1,2,3,2],[4,5,6,2],[7,8,9,5],],3)==9" ]
[]
870
Write a python function to find the average of even numbers till a given even number.
def mul_even_odd(list1): first_even = next((el for el in list1 if el%2==0),-1) first_odd = next((el for el in list1 if el%2!=0),-1) return (first_even*first_odd)
[ "assert remove_list_range([[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7], [9, 11], [13, 14, 15, 17]],13,17)==[[13, 14, 15, 17]]", "assert remove_list_range([[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7], [9, 11], [13, 14, 15, 17]],1,3)==[[2], [1, 2, 3]]", "assert remove_list_range([[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7], ...
[]
924
Write a function to remove duplicates from a list of lists.
def slope(x1,y1,x2,y2): return (float)(y2-y1)/(x2-x1)
[ "assert check(\"SEEquoiaL\") == 'accepted'", "assert check('program') == \"not accepted\"", "assert check('fine') == \"not accepted\"" ]
[]
923
Write a function to clear the values of the given tuples.
def find_ind(key, i, n, k, arr): ind = -1 start = i + 1 end = n - 1; while (start < end): mid = int(start + (end - start) / 2) if (arr[mid] - key <= k): ind = mid start = mid + 1 else: end = mid return ind def removals(arr, n, k): ans = n - 1 arr.sort() for i in range(0, ...
[ "assert maximum_product( [12, 74, 9, 50, 61, 41])==225700", "assert maximum_product([25, 35, 22, 85, 14, 65, 75, 25, 58])==414375", "assert maximum_product([18, 14, 10, 9, 8, 7, 9, 3, 2, 4, 1])==2520" ]
[]
647
Write a function to check a decimal with a precision of 2.
def remove_similar_row(test_list): res = set(sorted([tuple(sorted(set(sub))) for sub in test_list])) return (res)
[ "assert count_same_pair([1, 2, 3, 4, 5, 6, 7, 8],[2, 2, 3, 1, 2, 6, 7, 9])==4", "assert count_same_pair([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8],[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==11", "assert count_same_pair([2, 4, -6, -9, 11, -12, 14, -5, 17],[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==1" ]
[]
832
Write a function to access dictionary key’s element by index.
def is_decimal(num): import re dnumre = re.compile(r"""^[0-9]+(\.[0-9]{1,2})?$""") result = dnumre.search(num) return bool(result)
[ "assert find_Points(5,10,1,5) == (1,10)", "assert find_Points(3,5,7,9) == (3,9)", "assert find_Points(1,5,2,8) == (1,8)" ]
[]
752
Write a function to compute the value of ncr mod p.
def swap_List(newList): size = len(newList) temp = newList[0] newList[0] = newList[size - 1] newList[size - 1] = temp return newList
[ "assert count_Pairs([1,1,1,1],4) == 6", "assert count_Pairs([1,5,1],3) == 1", "assert count_Pairs([3,2,1,7,8,9],6) == 0" ]
[]
641
Write a python function to find the smallest missing number from the given array.
def sum_num(numbers): total = 0 for x in numbers: total += x return total/len(numbers)
[ "assert remove_char(\"123abcjw:, .@! eiw\") == '123abcjweiw'", "assert remove_char(\"Hello1234:, ! Howare33u\") == 'Hello1234Howare33u'", "assert remove_char(\"Cool543Triks@:, Make@987Trips\") == 'Cool543TriksMake987Trips' " ]
[]
822
Write a function to find the sequences of one upper case letter followed by lower case letters.
import re regex = '[a-zA-z0-9]$' def check_alphanumeric(string): if(re.search(regex, string)): return ("Accept") else: return ("Discard")
[ "assert min_of_two(10,20)==10", "assert min_of_two(19,15)==15", "assert min_of_two(-10,-20)==-20" ]
[]
667
Write a function to count occurrence of a character in a string.
def matrix_to_list(test_list): temp = [ele for sub in test_list for ele in sub] res = list(zip(*temp)) return (str(res))
[ "assert decreasing_trend([-4,-3,-2,-1]) == True", "assert decreasing_trend([1,2,3]) == True", "assert decreasing_trend([3,2,1]) == False" ]
[]
741
Write a function to add two lists using map and lambda function.
def check_Odd_Parity(x): parity = 0 while (x != 0): x = x & (x - 1) parity += 1 if (parity % 2 == 1): return True else: return False
[ "assert extract_max('100klh564abc365bg') == 564", "assert extract_max('hello300how546mer231') == 546", "assert extract_max('its233beenalong343journey234') == 343" ]
[]
871
Write a function to find n-th rencontres number.
def set_middle_bits(n): n |= n >> 1; n |= n >> 2; n |= n >> 4; n |= n >> 8; n |= n >> 16; return (n >> 1) ^ 1 def toggle_middle_bits(n): if (n == 1): return 1 return n ^ set_middle_bits(n)
[ "assert sort_list_last([(2, 5), (1, 2), (4, 4), (2, 3), (2, 1)])==[(2, 1), (1, 2), (2, 3), (4, 4), (2, 5)] ", "assert sort_list_last([(9,8), (4, 7), (3,5), (7,9), (1,2)])==[(1,2), (3,5), (4,7), (9,8), (7,9)] ", "assert sort_list_last([(20,50), (10,20), (40,40)])==[(10,20),(40,40),(20,50)] " ]
[]
814
Write a python function to choose points from two ranges such that no point lies in both the ranges.
def sum_Range_list(nums, m, n): sum_range = 0 ...
[ "assert is_Word_Present(\"machine learning\",\"machine\") == True", "assert is_Word_Present(\"easy\",\"fun\") == False", "assert is_Word_Present(\"python language\",\"code\") == False" ]
[]
968
Write a function to check for a number at the end of a string.
def div_list(nums1,nums2): result = map(lambda x, y: x / y, nums1, nums2) return list(result)
[ "assert left_insertion([1,2,4,5],6)==4", "assert left_insertion([1,2,4,5],3)==2", "assert left_insertion([1,2,4,5],7)==4" ]
[]
631
Write a function to add a dictionary to the tuple.
def rgb_to_hsv(r, g, b): r, g, b = r/255.0, g/255.0, b/255.0 mx = max(r, g, b) mn = min(r, g, b) df = mx-mn if mx == mn: h = 0 elif mx == r: h = (60 * ((g-b)/df) + 360) % 360 elif mx == g: h = (60 * ((b-r)/df) + 120) % 360 elif mx == b: h = (60...
[ "assert all_Characters_Same(\"python\") == False", "assert all_Characters_Same(\"aaa\") == True", "assert all_Characters_Same(\"data\") == False" ]
[]
773
Write a function to count the pairs of reverse strings in the given string list.
def div_of_nums(nums,m,n): result = list(filter(lambda x: (x % m == 0 or x % n == 0), nums)) return result
[ "assert max_of_three(10,20,30)==30", "assert max_of_three(55,47,39)==55", "assert max_of_three(10,49,30)==49" ]
[]
902
Write a function to find the length of the longest sub-sequence such that elements in the subsequences are consecutive integers.
def remove_empty(tuple1): #L = [(), (), ('',), ('a', 'b'), ('a', 'b', 'c'), ('d')] tuple1 = [t for t in tuple1 if t] return tuple1
[ "assert replace_spaces(\"My Name is Dawood\") == 'My%20Name%20is%20Dawood'", "assert replace_spaces(\"I am a Programmer\") == 'I%20am%20a%20Programmer'", "assert replace_spaces(\"I love Coding\") == 'I%20love%20Coding'" ]
[]
737
Write a function to extract all the adjacent coordinates of the given coordinate tuple.
import re def text_match_zero_one(text): patterns = 'ab?' if re.search(patterns, text): return 'Found a match!' else: return('Not matched!')
[ "assert count_variable(4,2,0,-2)==['p', 'p', 'p', 'p', 'q', 'q'] ", "assert count_variable(0,1,2,3)==['q', 'r', 'r', 's', 's', 's'] ", "assert count_variable(11,15,12,23)==['p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'r', 'r',...
[]
716
Write a python function to convert a list of multiple integers into a single integer.
def count_alpha_dig_spl(string): alphabets=digits = special = 0 for i in range(len(string)): if(string[i].isalpha()): alphabets = alphabets + 1 elif(string[i].isdigit()): digits = digits + 1 else: special = special + 1 return (alphabets,digits,special)
[ "assert check_expression(\"{()}[{}]\") == True", "assert check_expression(\"{()}[{]\") == False", "assert check_expression(\"{()}[{}][]({})\") == True" ]
[]
811
Write a python function to find sum of inverse of divisors.
def parallelogram_perimeter(b,h): perimeter=2*(b*h) return perimeter
[ "assert text_match_zero_one(\"ac\")==('Found a match!')", "assert text_match_zero_one(\"dc\")==('Not matched!')", "assert text_match_zero_one(\"abbbba\")==('Found a match!')" ]
[]
876
Write a function to check whether the given string is ending with only alphanumeric characters or not using regex.
def sort_String(str) : str = ''.join(sorted(str)) return (str)
[ "assert add_list([1, 2, 3],[4,5,6])==[5, 7, 9]", "assert add_list([1,2],[3,4])==[4,6]", "assert add_list([10,20],[50,70])==[60,90]" ]
[]
733
Write a function to remove duplicate words from a given string using collections module.
def average_Even(n) : if (n% 2!= 0) : return ("Invalid Input") return -1 sm = 0 count = 0 while (n>= 2) : count = count+1 sm = sm+n n = n-2 return sm // count
[ "assert add_dict_to_tuple((4, 5, 6), {\"MSAM\" : 1, \"is\" : 2, \"best\" : 3} ) == (4, 5, 6, {'MSAM': 1, 'is': 2, 'best': 3})", "assert add_dict_to_tuple((1, 2, 3), {\"UTS\" : 2, \"is\" : 3, \"Worst\" : 4} ) == (1, 2, 3, {'UTS': 2, 'is': 3, 'Worst': 4})", "assert add_dict_to_tuple((8, 9, 10), {\"POS\" : 3, \"is...
[]
790
Write a function to remove similar rows from the given tuple matrix.
def access_elements(nums, list_index): result = [nums[i] for i in list_index] return result
[ "assert parallelogram_perimeter(10,20)==400", "assert parallelogram_perimeter(15,20)==600", "assert parallelogram_perimeter(8,9)==144" ]
[]
743
Write a python function to find the sum of fourth power of first n even natural numbers.
def rotate_right(list1,m,n): result = list1[-(m):]+list1[:-(n)] return result
[ "assert check_identical([(10, 4), (2, 5)], [(10, 4), (2, 5)]) == True", "assert check_identical([(1, 2), (3, 7)], [(12, 14), (12, 45)]) == False", "assert check_identical([(2, 14), (12, 25)], [(2, 14), (12, 25)]) == True" ]
[]
796
Write a function to find the perimeter of a rectangle.
def remove_nested(test_tup): res = tuple() for count, ele in enumerate(test_tup): if not isinstance(ele, tuple): res = res + (ele, ) return (res)
[ "assert front_and_rear((10, 4, 5, 6, 7)) == (10, 7)", "assert front_and_rear((1, 2, 3, 4, 5)) == (1, 5)", "assert front_and_rear((6, 7, 8, 9, 10)) == (6, 10)" ]
[]
938
Write a function to replace whitespaces with an underscore and vice versa in a given string by using regex.
def sorted_models(models): sorted_models = sorted(models, key = lambda x: x['color']) return sorted_models
[ "assert count_even([1, 2, 3, 5, 7, 8, 9, 10])==3", "assert count_even([10,15,14,13,-18,12,-20])==5", "assert count_even([1, 2, 4, 8, 9])==3" ]
[]
954
Write a python function to find the last position of an element in a sorted array.
def Convert(string): li = list(string.split(" ")) return li
[ "assert increment_numerics([\"MSM\", \"234\", \"is\", \"98\", \"123\", \"best\", \"4\"] , 6) == ['MSM', '240', 'is', '104', '129', 'best', '10']", "assert increment_numerics([\"Dart\", \"356\", \"is\", \"88\", \"169\", \"Super\", \"6\"] , 12) == ['Dart', '368', 'is', '100', '181', 'Super', '18']", "assert incre...
[]
806
Write a python function to find the length of the last word in a given string.
def join_tuples(test_list): res = [] for sub in test_list: if res and res[-1][0] == sub[0]: res[-1].extend(sub[1:]) else: res.append([ele for ele in sub]) res = list(map(tuple, res)) return (res)
[ "assert count_duplic([1,2,2,2,4,4,4,5,5,5,5])==([1, 2, 4, 5], [1, 3, 3, 4])", "assert count_duplic([2,2,3,1,2,6,7,9])==([2, 3, 1, 2, 6, 7, 9], [2, 1, 1, 1, 1, 1, 1])", "assert count_duplic([2,1,5,6,8,3,4,9,10,11,8,12])==([2, 1, 5, 6, 8, 3, 4, 9, 10, 11, 8, 12], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])" ]
[]
697
Write a function to rotate a given list by specified number of items to the right direction.
def reverse_Array_Upto_K(input, k): return (input[k-1::-1] + input[k:])
[ "assert end_num('abcdef')==False", "assert end_num('abcdef7')==True", "assert end_num('abc')==False" ]
[]
703
Write a function to find the maximum value in record list as tuple attribute in the given tuple list.
def are_Equal(arr1,arr2,n,m): if (n != m): return False arr1.sort() arr2.sort() for i in range(0,n - 1): if (arr1[i] != arr2[i]): return False return True
[ "assert extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[1, 7]", "assert extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 6, 5],[0, 1, 2, 3, 4, 6, 7])==[1, 6]", "assert extract_index_list([1, 1, 3, 4, 6, 5, 6],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[1, 5]" ]
[]
606
Write a function to find all anagrams of a string in a given list of strings using lambda function.
def extract_index_list(l1, l2, l3): result = [] for m, n, o in zip(l1, l2, l3): if (m == n == o): result.append(m) return result
[ "assert noprofit_noloss(1500,1200)==False", "assert noprofit_noloss(100,100)==True", "assert noprofit_noloss(2000,5000)==False" ]
[]
931
Write a python function to toggle bits of the number except the first and the last bit.
def remove_duplic_list(l): temp = [] for x in l: if x not in temp: temp.append(x) return temp
[ "assert remove_all_spaces('python program')==('pythonprogram')", "assert remove_all_spaces('python programming language')==('pythonprogramminglanguage')", "assert remove_all_spaces('python program')==('pythonprogram')" ]
[]
659
Write a function to check whether the given ip address is valid or not using regex.
def count_vowels(test_str): res = 0 vow_list = ['a', 'e', 'i', 'o', 'u'] for idx in range(1, len(test_str) - 1): if test_str[idx] not in vow_list and (test_str[idx - 1] in vow_list or test_str[idx + 1] in vow_list): res += 1 if test_str[0] not in vow_list and test_str[1] in vow_list: res +=...
[ "assert second_smallest([1, 2, -8, -2, 0, -2])==-2", "assert second_smallest([1, 1, -0.5, 0, 2, -2, -2])==-0.5", "assert second_smallest([2,2])==None" ]
[]
833
Write a function to find the maximum of similar indices in two lists of tuples.
def Repeat(x): _size = len(x) repeated = [] for i in range(_size): k = i + 1 for j in range(k, _size): if x[i] == x[j] and x[i] not in repeated: repeated.append(x[i]) return repeated
[ "assert cheap_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}],1)==[{'name': 'Item-1', 'price': 101.1}]", "assert cheap_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}],2)==[{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}]", "ass...
[]
869
Write a python function to find maximum possible value for the given periodic function.
def Check_Solution(a,b,c): if b == 0: return ("Yes") else: return ("No")
[ "assert sum_in_Range(2,5) == 8", "assert sum_in_Range(5,7) == 12", "assert sum_in_Range(7,13) == 40" ]
[]
786
Write a function to count those characters which have vowels as their neighbors in the given string.
def get_inv_count(arr, n): inv_count = 0 for i in range(n): for j in range(i + 1, n): if (arr[i] > arr[j]): inv_count += 1 return inv_count
[ "assert min_Swaps(\"1101\",\"1110\") == 1", "assert min_Swaps(\"1111\",\"0100\") == \"Not Possible\"", "assert min_Swaps(\"1110000\",\"0001101\") == 3" ]
[]
632
Write a python function to find nth bell number.
import re def text_match_wordz_middle(text): patterns = '\Bz\B' if re.search(patterns, text): return 'Found a match!' else: return('Not matched!')
[ "assert nth_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],2)==[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]", "assert nth_nums([10,20,30],3)==([1000, 8000, 27000])", "assert nth_nums([12,15],5)==([248832, 759375])" ]
[]
835
Write a function to convert an integer into a roman numeral.
def move_last(num_list): a = [num_list[0] for i in range(num_list.count(num_list[0]))] x = [ i for i in num_list if i != num_list[0]] x.extend(a) return (x)
[ "assert len_complex(3,4)==5.0", "assert len_complex(9,10)==13.45362404707371", "assert len_complex(7,9)==11.40175425099138" ]
[]
960
Write a function to find the product of first even and odd number of a given list.
def jacobsthal_num(n): dp = [0] * (n + 1) dp[0] = 0 dp[1] = 1 for i in range(2, n+1): dp[i] = dp[i - 1] + 2 * dp[i - 2] return dp[n]
[ "assert get_First_Set_Bit_Pos(12) == 3", "assert get_First_Set_Bit_Pos(18) == 2", "assert get_First_Set_Bit_Pos(16) == 5" ]
[]
837
Write a python function to check whether a sequence of numbers has a decreasing trend or not.
def get_noOfways(n): if (n == 0): return 0; if (n == 1): return 1; return get_noOfways(n - 1) + get_noOfways(n - 2);
[ "assert sd_calc([4, 2, 5, 8, 6])== 2.23606797749979", "assert sd_calc([1,2,3,4,5,6,7])==2.160246899469287", "assert sd_calc([5,9,10,15,6,4])==4.070217029430577" ]
[]
762
Write a function to extract values between quotation marks of the given string by using regex.
def max_occurrences(list1): max_val = 0 result = list1[0] for i in list1: occu = list1.count(i) if occu > max_val: max_val = occu result = i return result
[ "assert pass_validity(\"password\")==False", "assert pass_validity(\"Password@10\")==True", "assert pass_validity(\"password@10\")==False" ]
[]
614
Write a function to find maximum of two numbers.
from collections import Counter def second_frequent(input): dict = Counter(input) value = sorted(dict.values(), reverse=True) second_large = value[1] for (key, val) in dict.items(): if val == second_large: return (key)
[ "assert right_insertion([1,2,4,5],6)==4", "assert right_insertion([1,2,4,5],3)==2", "assert right_insertion([1,2,4,5],7)==4" ]
[]
955
Write a function to count the same pair in two given lists using map function.
def remove_tuple(test_list): res = [sub for sub in test_list if not all(ele == None for ele in sub)] return (str(res))
[ "assert check_subset([[1, 3], [5, 7], [9, 11], [13, 15, 17]] ,[[1, 3],[13,15,17]])==True", "assert check_subset([[1, 2], [2, 3], [3, 4], [5, 6]],[[3, 4], [5, 6]])==True", "assert check_subset([[[1, 2], [2, 3]], [[3, 4], [5, 7]]],[[[3, 4], [5, 6]]])==False" ]
[]
856
Write a function to find the index of the first occurrence of a given number in a sorted array.
def Sum_of_Inverse_Divisors(N,Sum): ans = float(Sum)*1.0 /float(N); return round(ans,2);
[ "assert lcm(4,6) == 12", "assert lcm(15,17) == 255", "assert lcm(2,6) == 6" ]
[]
830
Write a function to find the combinations of sums with tuples in the given tuple list.
def Sum(N): SumOfPrimeDivisors = [0]*(N + 1) for i in range(2,N + 1) : if (SumOfPrimeDivisors[i] == 0) : for j in range(i,N + 1,i) : SumOfPrimeDivisors[j] += i return SumOfPrimeDivisors[N]
[ "assert alternate_elements([\"red\", \"black\", \"white\", \"green\", \"orange\"])==['red', 'white', 'orange']", "assert alternate_elements([2, 0, 3, 4, 0, 2, 8, 3, 4, 2])==[2, 3, 0, 8, 4]", "assert alternate_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1,3,5,7,9]" ]
[]
932
Write a python function to calculate the sum of the numbers in a list between the indices of a specified range.
def count_Pairs(arr,n): cnt = 0; for i in range(n): for j in range(i + 1,n): if (arr[i] == arr[j]): cnt += 1; return cnt;
[ "assert check_email(\"ankitrai326@gmail.com\") == 'Valid Email'", "assert check_email(\"my.ownsite@ourearth.org\") == 'Valid Email'", "assert check_email(\"ankitaoie326.com\") == 'Invalid Email'" ]
[]
826
Write a function to concatenate the given two tuples to a nested tuple.
def increasing_trend(nums): if (sorted(nums)== nums): return True else: return False
[ "assert (max_height(root)) == 3", "assert (max_height(root1)) == 5 ", "assert (max_height(root2)) == 4" ]
[]
663
Write a function to find the minimum difference in the tuple pairs of given tuples.
import re def num_position(text): for m in re.finditer("\d+", text): return m.start()
[ "assert count_elim([10,20,30,(10,20),40])==3", "assert count_elim([10,(20,30),(10,20),40])==1", "assert count_elim([(10,(20,30,(10,20),40))])==0" ]
[]
908
Write a function to rearrange positive and negative numbers in a given array using lambda function.
def word_len(s): s = s.split(' ') for word in s: if len(word)%2==0: return True else: return False
[ "assert radian_degree(90)==1.5707963267948966", "assert radian_degree(60)==1.0471975511965976", "assert radian_degree(120)==2.0943951023931953" ]
[]
959
Write a python function to check whether every even index contains even numbers of a given list.
def sum_column(list1, C): result = sum(row[C] for row in list1) return result
[ "assert Sum(60) == 10", "assert Sum(39) == 16", "assert Sum(40) == 7" ]
[]
831
Write a function to find numbers divisible by m or n from a list of numbers using lambda function.
def remove_negs(num_list): for item in num_list: if item < 0: num_list.remove(item) return num_list
[ "assert is_odd(5) == True", "assert is_odd(6) == False", "assert is_odd(7) == True" ]
[]
798
Write a python function to count the total set bits from 1 to n.
def get_median(arr1, arr2, n): i = 0 j = 0 m1 = -1 m2 = -1 count = 0 while count < n + 1: count += 1 if i == n: m1 = m2 m2 = arr2[0] break elif j == n: m1 = m2 m2 = arr1[0] break if arr1[i] <= arr2[j]: m1 = m2 m2 = arr1[i] ...
[ "assert prime_num(13)==True", "assert prime_num(7)==True", "assert prime_num(-1010)==False" ]
[]
793
Write a python function to check if roots of a quadratic equation are reciprocal of each other or not.
import math def get_First_Set_Bit_Pos(n): return math.log2(n&-n)+1
[ "assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},6.0,70)=={'Cierra Vega': (6.2, 70)}", "assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},5.9,67)=={'Cierra ...
[]
940
Write a function to move all the numbers in it to the given string.
import re text = 'Python Exercises' def replace_spaces(text): text =text.replace (" ", "_") return (text) text =text.replace ("_", " ") return (text)
[ "assert Sum_of_Inverse_Divisors(6,12) == 2", "assert Sum_of_Inverse_Divisors(9,13) == 1.44", "assert Sum_of_Inverse_Divisors(1,4) == 4" ]
[]
972
Write a function to find the smallest multiple of the first n numbers.
def min_jumps(arr, n): jumps = [0 for i in range(n)] if (n == 0) or (arr[0] == 0): return float('inf') jumps[0] = 0 for i in range(1, n): jumps[i] = float('inf') for j in range(i): if (i <= j + arr[j]) and (jumps[j] != float('inf')): jumps[i] = min(jumps[i], jumps[j] + 1) break return j...
[ "assert div_of_nums([19, 65, 57, 39, 152, 639, 121, 44, 90, 190],2,4)==[ 152,44]", "assert div_of_nums([1, 2, 3, 5, 7, 8, 10],2,5)==[10]", "assert div_of_nums([10,15,14,13,18,12,20],10,5)==[10,20]" ]
[]
884
Write a function to round up a number to specific digits.
def last(n): return n[-1] def sort_list_last(tuples): return sorted(tuples, key=last)
[ "assert series_sum(6)==91", "assert series_sum(7)==140", "assert series_sum(12)==650" ]
[]
956
Write a function to calculate the sum of the positive numbers of a given list of numbers using lambda function.
def noprofit_noloss(actual_cost,sale_amount): if(sale_amount == actual_cost): return True else: return False
[ "assert max_sum_subseq([1, 2, 9, 4, 5, 0, 4, 11, 6]) == 26", "assert max_sum_subseq([1, 2, 9, 5, 6, 0, 5, 12, 7]) == 28", "assert max_sum_subseq([1, 3, 10, 5, 6, 0, 6, 14, 21]) == 44" ]
[]
610
Write a function to calculate the perimeter of a regular polygon.
def binomial_coeff(n, k): C = [[0 for j in range(k + 1)] for i in range(n + 1)] for i in range(0, n + 1): for j in range(0, min(i, k) + 1): if (j == 0 or j == i): C[i][j] = 1 else: C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) return C[n][k] def lobb_num(n, m): return ((...
[ "assert count_Set_Bits(16) == 33", "assert count_Set_Bits(2) == 2", "assert count_Set_Bits(14) == 28" ]
[]
625
Write a function to push all values into a heap and then pop off the smallest values one at a time.
def tuple_modulo(test_tup1, test_tup2): res = tuple(ele1 % ele2 for ele1, ele2 in zip(test_tup1, test_tup2)) return (res)
[ "assert count_Divisors(10) == \"Even\"", "assert count_Divisors(100) == \"Odd\"", "assert count_Divisors(125) == \"Even\"" ]
[]
774
Write a function to find the second smallest number in a list.
def last(arr,x,n): low = 0 high = n - 1 res = -1 while (low <= high): mid = (low + high) // 2 if arr[mid] > x: high = mid - 1 elif arr[mid] < x: low = mid + 1 else: res = mid low = mid + 1 return res
[ "assert round_up(123.01247,0)==124", "assert round_up(123.01247,1)==123.1", "assert round_up(123.01247,2)==123.02" ]
[]
736
Write a python function to check whether a sequence of numbers has an increasing trend or not.
def multiply_elements(test_tup): res = tuple(i * j for i, j in zip(test_tup, test_tup[1:])) return (res)
[ "assert check_valid((True, True, True, True) ) == True", "assert check_valid((True, False, True, True) ) == False", "assert check_valid((True, True, True, True) ) == True" ]
[]
734
Write a python function to check whether an array can be sorted or not by picking only the corner elements.
def is_Isomorphic(str1,str2): dict_str1 = {} dict_str2 = {} for i, value in enumerate(str1): dict_str1[value] = dict_str1.get(value,[]) + [i] for j, value in enumerate(str2): dict_str2[value] = dict_str2.get(value,[]) + [j] if sorted(dict_str1.values()) == so...
[ "assert split_upperstring(\"PythonProgramLanguage\")==['Python','Program','Language']", "assert split_upperstring(\"PythonProgram\")==['Python','Program']", "assert split_upperstring(\"ProgrammingLanguage\")==['Programming','Language']" ]
[]
693
Write a function to count alphabets,digits and special charactes in a given string.
def coin_change(S, m, n): table = [[0 for x in range(m)] for x in range(n+1)] for i in range(m): table[0][i] = 1 for i in range(1, n+1): for j in range(m): x = table[i - S[j]][j] if i-S[j] >= 0 else 0 y = table[i][j-1] if j >= 1 else 0 table[...
[ "assert unique_sublists([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]] )=={(1, 3): 2, (5, 7): 2, (13, 15, 17): 1, (9, 11): 1}", "assert unique_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])=={('green', 'orange'): 2, ('black',): 1, ('white',): 1}", "assert unique_sublists([[1...
[]
End of preview. Expand in Data Studio

edition_0682_google-research-datasets-mbpp-readymade

A Readymade by TheFactoryX

Original Dataset

google-research-datasets/mbpp

Process

This dataset is a "readymade" - inspired by Marcel Duchamp's concept of taking everyday objects and recontextualizing them as art.

What we did:

  1. Selected the original dataset from Hugging Face
  2. Shuffled each column independently
  3. Destroyed all row-wise relationships
  4. Preserved structure, removed meaning

The result: Same data. Wrong order. New meaning. No meaning.

Purpose

This is art. This is not useful. This is the point.

Column relationships have been completely destroyed. The data maintains its types and values, but all semantic meaning has been removed.


Part of the Readymades project by TheFactoryX.

"I am a machine." — Andy Warhol

Downloads last month
5