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
714
Write a function to check if the given string starts with a substring using regex.
def mul_consecutive_nums(nums): result = [b*a for a, b in zip(nums[:-1], nums[1:])] return result
[ "assert max_run_uppercase('GeMKSForGERksISBESt') == 5", "assert max_run_uppercase('PrECIOusMOVemENTSYT') == 6", "assert max_run_uppercase('GooGLEFluTTER') == 4" ]
[]
832
Write a function to find the product of it’s kth index in the given tuples.
def min_Num(arr,n): odd = 0 for i in range(n): if (arr[i] % 2): odd += 1 if (odd % 2): return 1 return 2
[ "assert road_rd(\"ravipadu Road\")==('ravipadu Rd.')", "assert road_rd(\"palnadu Road\")==('palnadu Rd.')", "assert road_rd(\"eshwar enclave Road\")==('eshwar enclave Rd.')" ]
[]
695
Write a python function to check whether every odd index contains odd numbers of a given list.
def count_elim(num): count_elim = 0 for n in num: if isinstance(n, tuple): break count_elim += 1 return count_elim
[ "assert is_Two_Alter(\"abab\") == True", "assert is_Two_Alter(\"aaaa\") == False", "assert is_Two_Alter(\"xyz\") == False" ]
[]
789
Write a python function to check whether all the bits are within a given range or not.
def max_sum_list(lists): return max(lists, key=sum)
[ "assert find_First_Missing([0,1,2,3],0,3) == 4", "assert find_First_Missing([0,1,2,6,9],0,4) == 3", "assert find_First_Missing([2,3,5,8,9],0,4) == 0" ]
[]
921
Write a function to move all the numbers in it to the given string.
def factorial(start,end): res = 1 for i in range(start,end + 1): res *= i return res def sum_of_square(n): return int(factorial(n + 1, 2 * n) /factorial(1, n))
[ "assert sum_num((8, 2, 3, 0, 7))==4.0", "assert sum_num((-10,-20,-30))==-20.0", "assert sum_num((19,15,18))==17.333333333333332" ]
[]
833
Write a python function to get the difference between two lists.
def previous_palindrome(num): for x in range(num-1,0,-1): if str(x) == str(x)[::-1]: return x
[ "assert is_polite(7) == 11", "assert is_polite(4) == 7", "assert is_polite(9) == 13" ]
[]
797
Write a function which accepts an arbitrary list and converts it to a heap using heap queue algorithm.
def rombus_perimeter(a): perimeter=4*a return perimeter
[ "assert max_char(\"hello world\")==('l')", "assert max_char(\"hello \")==('l')", "assert max_char(\"python pr\")==('p')" ]
[]
636
Write a function to exchange the position of every n-th value with (n+1)th value and (n+1)th value with n-th value in a given list.
def find_Points(l1,r1,l2,r2): x = min(l1,l2) if (l1 != l2) else -1 y = max(r1,r2) if (r1 != r2) else -1 return (x,y)
[ "assert sector_area(4,45)==6.285714285714286", "assert sector_area(9,45)==31.82142857142857", "assert sector_area(9,360)==None" ]
[]
753
Write a function to find the frequency of each element in the given list.
def div_of_nums(nums,m,n): result = list(filter(lambda x: (x % m == 0 and x % n == 0), nums)) return result
[ "assert find_fixed_point([-10, -1, 0, 3, 10, 11, 30, 50, 100],9) == 3", "assert find_fixed_point([1, 2, 3, 4, 5, 6, 7, 8],8) == -1", "assert find_fixed_point([0, 2, 5, 8, 17],5) == 0" ]
[]
970
Write a function to sort a list in a dictionary.
def is_nonagonal(n): return int(n * (7 * n - 5) / 2)
[ "assert tuple_to_set(('x', 'y', 'z') ) == {'y', 'x', 'z'}", "assert tuple_to_set(('a', 'b', 'c') ) == {'c', 'a', 'b'}", "assert tuple_to_set(('z', 'd', 'e') ) == {'d', 'e', 'z'}" ]
[]
939
Write a python function to check whether the count of divisors is even or odd.
def sample_nam(sample_names): sample_names=list(filter(lambda el:el[0].isupper() and el[1:].islower(),sample_names)) return len(''.join(sample_names))
[ "assert int(lobb_num(5, 3)) == 35", "assert int(lobb_num(3, 2)) == 5", "assert int(lobb_num(4, 2)) == 20" ]
[]
949
Write a python function to find the average of even numbers till a given even 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 new_tuple([\"WEB\", \"is\"], \"best\") == ('WEB', 'is', 'best')", "assert new_tuple([\"We\", \"are\"], \"Developers\") == ('We', 'are', 'Developers')", "assert new_tuple([\"Part\", \"is\"], \"Wrong\") == ('Part', 'is', 'Wrong')" ]
[]
767
Write a function to find a pair with the highest product from a given array of integers.
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 max_of_two(10,20)==20", "assert max_of_two(19,15)==19", "assert max_of_two(-10,-20)==-10" ]
[]
802
Write a python function to check whether the two given strings are isomorphic to each other or not.
def add_list(nums1,nums2): result = map(lambda x, y: x + y, nums1, nums2) return list(result)
[ "assert find_Min_Swaps([1,0,1,0],4) == 3", "assert find_Min_Swaps([0,1,0],3) == 1", "assert find_Min_Swaps([0,0,1,1,0],5) == 2" ]
[]
880
Write a function to multiply two lists using map and lambda function.
def Split(list): ev_li = [] for i in list: if (i % 2 == 0): ev_li.append(i) return ev_li
[ "assert Convert('python program') == ['python','program']", "assert Convert('Data Analysis') ==['Data','Analysis']", "assert Convert('Hadoop Training') == ['Hadoop','Training']" ]
[]
894
Write a function to find the maximum of similar indices in two lists of tuples.
def swap_List(newList): size = len(newList) temp = newList[0] newList[0] = newList[size - 1] newList[size - 1] = temp return newList
[ "assert div_list([4,5,6],[1, 2, 3])==[4.0,2.5,2.0]", "assert div_list([3,2],[1,4])==[3.0, 0.5]", "assert div_list([90,120],[50,70])==[1.8, 1.7142857142857142]" ]
[]
652
Write a function to find a path with the maximum average over all existing paths for the given square matrix of size n*n.
def number_ctr(str): number_ctr= 0 for i in range(len(str)): if str[i] >= '0' and str[i] <= '9': number_ctr += 1 return number_ctr
[ "assert anagram_lambda([\"bcda\", \"abce\", \"cbda\", \"cbea\", \"adcb\"],\"abcd\")==['bcda', 'cbda', 'adcb']", "assert anagram_lambda([\"recitals\",\" python\"], \"articles\" )==[\"recitals\"]", "assert anagram_lambda([\" keep\",\" abcdef\",\" xyz\"],\" peek\")==[\" keep\"]" ]
[]
739
Write a python function to check whether the product of numbers is even or not.
def min_sum_path(A): memo = [None] * len(A) n = len(A) - 1 for i in range(len(A[n])): memo[i] = A[n][i] for i in range(len(A) - 2, -1,-1): for j in range( len(A[i])): memo[j] = A[i][j] + min(memo[j], memo[j + 1]) return memo[0]
[ "assert average_Even(2) == 2", "assert average_Even(4) == 3", "assert average_Even(100) == 51" ]
[]
865
Write a python function to left rotate the string.
def sort_String(str) : str = ''.join(sorted(str)) return (str)
[ "assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],3,4)==[8, 9, 10, 1, 2, 3, 4, 5, 6]", "assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],2,2)==[9, 10, 1, 2, 3, 4, 5, 6, 7, 8]", "assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],5,2)==[6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8]" ]
[]
886
Write a function to count unique keys for each value present in the tuple.
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 mul_even_odd([1,3,5,7,4,1,6,8])==4", "assert mul_even_odd([1,2,3,4,5,6,7,8,9,10])==2", "assert mul_even_odd([1,5,7,9,10])==10" ]
[]
874
Write a function to count the frequency of consecutive duplicate elements in a given list of numbers.
import math def find_Digits(n): if (n < 0): return 0; if (n <= 1): return 1; x = ((n * math.log10(n / math.e) + math.log10(2 * math.pi * n) /2.0)); return math.floor(x) + 1;
[ "assert smallest_multiple(13)==360360", "assert smallest_multiple(2)==2", "assert smallest_multiple(1)==1" ]
[]
962
Write a python function to find sum of all prime divisors of a given number.
from math import tan, pi def perimeter_polygon(s,l): perimeter = s*l return perimeter
[ "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)" ]
[]
658
Write a function to put spaces between words starting with capital letters in a given string by using regex.
from itertools import zip_longest, chain, tee def exchange_elements(lst): lst1, lst2 = tee(iter(lst), 2) return list(chain.from_iterable(zip_longest(lst[1::2], lst[::2])))
[ "assert removals([1, 3, 4, 9, 10,11, 12, 17, 20], 9, 4) == 5", "assert removals([1, 5, 6, 2, 8], 5, 2) == 3", "assert removals([1, 2, 3 ,4, 5, 6], 6, 3) == 2" ]
[]
864
Write a python function to count equal element pairs from the given array.
import math def is_polite(n): n = n + 1 return (int)(n+(math.log((n + math.log(n, 2)), 2)))
[ "assert sum_in_Range(2,5) == 8", "assert sum_in_Range(5,7) == 12", "assert sum_in_Range(7,13) == 40" ]
[]
848
Write a function to remove multiple spaces in a string by using regex.
def increasing_trend(nums): if (sorted(nums)== nums): return True else: return False
[ "assert rombus_area(10,20)==100", "assert rombus_area(10,5)==25", "assert rombus_area(4,2)==4" ]
[]
882
Write a python function to find the length of the last word in a given string.
def min_Swaps(s1,s2) : c0 = 0; c1 = 0; for i in range(len(s1)) : if (s1[i] == '0' and s2[i] == '1') : c0 += 1; elif (s1[i] == '1' and s2[i] == '0') : c1 += 1; result = c0 // 2 + c1 // 2; if (c0 % 2 == 0 and c1 % 2 == 0) : return r...
[ "assert arc_length(9,45)==3.5357142857142856", "assert arc_length(9,480)==None", "assert arc_length(5,270)==11.785714285714285" ]
[]
711
Write a python function to find the kth element in an array containing odd elements first and then even elements.
import math def radian_degree(degree): radian = degree*(math.pi/180) return radian
[ "assert count_Set_Bits(16) == 33", "assert count_Set_Bits(2) == 2", "assert count_Set_Bits(14) == 28" ]
[]
853
Write a function to convert a roman numeral to an integer.
def string_length(str1): count = 0 for char in str1: count += 1 return count
[ "assert max_occurrences([2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,4,6,9,1,2])==2", "assert max_occurrences([1, 3,5, 7,1, 3,13, 15, 17,5, 7,9,1, 11])==1", "assert max_occurrences([1, 2, 3,2, 4, 5,1, 1, 1])==1" ]
[]
619
Write a function to remove everything except alphanumeric characters from the given string by using regex.
def sum_even_odd(list1): first_even = next((el for el in list1 if el%2==0),-1) first_odd = next((el for el in list1 if el%2!=0),-1) return (first_even+first_odd)
[ "assert find_Index(2) == 4", "assert find_Index(3) == 14", "assert find_Index(4) == 45" ]
[]
647
Write a function to split the given string at uppercase letters by using regex.
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 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" ]
[]
968
Write a function to check if each element of the second tuple is greater than its corresponding index in the first tuple.
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 min_sum_path([[ 2 ], [3, 9 ], [1, 6, 7 ]]) == 6", "assert min_sum_path([[ 2 ], [3, 7 ], [8, 5, 6 ]]) == 10 ", "assert min_sum_path([[ 3 ], [6, 4 ], [5, 2, 7 ]]) == 9" ]
[]
673
Write a function to add the given tuple to the given list.
from itertools import groupby def group_element(test_list): res = dict() for key, val in groupby(sorted(test_list, key = lambda ele: ele[1]), key = lambda ele: ele[1]): res[key] = [ele[0] for ele in val] return (res)
[ "assert str_to_tuple(\"1, -5, 4, 6, 7\") == (1, -5, 4, 6, 7)", "assert str_to_tuple(\"1, 2, 3, 4, 5\") == (1, 2, 3, 4, 5)", "assert str_to_tuple(\"4, 6, 9, 11, 13, 14\") == (4, 6, 9, 11, 13, 14)" ]
[]
943
Write a python function to find sum of odd factors of a number.
def sum_Of_Primes(n): prime = [True] * (n + 1) p = 2 while p * p <= n: if prime[p] == True: i = p * 2 while i <= n: prime[i] = False i += p p += 1 sum = 0 for i in range (2,n + 1): if(prime[i]): ...
[ "assert min_of_two(10,20)==10", "assert min_of_two(19,15)==15", "assert min_of_two(-10,-20)==-20" ]
[]
887
Write a function to convert the given tuples into set.
def pair_wise(l1): temp = [] for i in range(len(l1) - 1): current_element, next_element = l1[i], l1[i + 1] x = (current_element, next_element) temp.append(x) return temp
[ "assert even_Power_Sum(2) == 272", "assert even_Power_Sum(3) == 1568", "assert even_Power_Sum(4) == 5664" ]
[]
959
Write a function to generate a square matrix filled with elements from 1 to n raised to the power of 2 in spiral order.
import re def text_match_zero_one(text): patterns = 'ab?' if re.search(patterns, text): return 'Found a match!' else: return('Not matched!')
[ "assert lateralsurface_cone(5,12)==204.20352248333654", "assert lateralsurface_cone(10,15)==566.3586699569488", "assert lateralsurface_cone(19,17)==1521.8090132193388" ]
[]
683
Write a function to count the number of inversions in the given array.
from collections import Counter def add_dict(d1,d2): add_dict = Counter(d1) + Counter(d2) return add_dict
[ "assert find_Digits(7) == 4", "assert find_Digits(5) == 3", "assert find_Digits(4) == 2" ]
[]
718
Write a function to count the number of unique lists within a list.
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 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" ]
[]
900
Write a function to caluclate arc length of an angle.
def tuple_to_set(t): s = set(t) return (s)
[ "assert remove_all_spaces('python program')==('pythonprogram')", "assert remove_all_spaces('python programming language')==('pythonprogramminglanguage')", "assert remove_all_spaces('python program')==('pythonprogram')" ]
[]
838
Write a python function to remove negative numbers from a list.
def rotate_right(list1,m,n): result = list1[-(m):]+list1[:-(n)] 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" ]
[]
776
Write a function to caluclate perimeter of a parallelogram.
import re def text_match(text): patterns = 'ab*?' if re.search(patterns, text): return ('Found a match!') else: return ('Not matched!')
[ "assert parallelogram_perimeter(10,20)==400", "assert parallelogram_perimeter(15,20)==600", "assert parallelogram_perimeter(8,9)==144" ]
[]
612
Write a function to find the occurrence and position of the substrings within a string.
def clear_tuple(test_tup): temp = list(test_tup) temp.clear() test_tup = tuple(temp) return (test_tup)
[ "assert min_jumps([1, 3, 6, 1, 0, 9], 6) == 3", "assert min_jumps([1, 3, 5, 8, 9, 2, 6, 7, 6, 8, 9], 11) == 3", "assert min_jumps([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 11) == 10" ]
[]
730
Write a function to count the same pair in two given lists using map function.
def check_smaller(test_tup1, test_tup2): res = all(x > y for x, y in zip(test_tup1, test_tup2)) return (res)
[ "assert min_Jumps(3,4,11)==3.5", "assert min_Jumps(3,4,0)==0", "assert min_Jumps(11,14,11)==1" ]
[]
669
Write a function that gives profit amount if the given amount has profit else return none.
def check_Even_Parity(x): parity = 0 while (x != 0): x = x & (x - 1) parity += 1 if (parity % 2 == 0): return True else: return False
[ "assert check_subset((10, 4, 5, 6), (5, 10)) == True", "assert check_subset((1, 2, 3, 4), (5, 6)) == False", "assert check_subset((7, 8, 9, 10), (10, 8)) == True" ]
[]
639
Write a python function to convert a list of multiple integers into a single integer.
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 match_num('5-2345861')==True", "assert match_num('6-2345861')==False", "assert match_num('78910')==False" ]
[]
860
Write a python function to choose points from two ranges such that no point lies in both the ranges.
def power_base_sum(base, power): return sum([int(i) for i in str(pow(base, power))])
[ "assert get_ludic(10) == [1, 2, 3, 5, 7]", "assert get_ludic(25) == [1, 2, 3, 5, 7, 11, 13, 17, 23, 25]", "assert get_ludic(45) == [1, 2, 3, 5, 7, 11, 13, 17, 23, 25, 29, 37, 41, 43]" ]
[]
618
Write a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format.
def sort_sublists(list1): list1.sort() list1.sort(key=len) return list1
[ "assert count_alpha_dig_spl(\"abc!@#123\")==(3,3,3)", "assert count_alpha_dig_spl(\"dgsuy@#$%&1255\")==(5,4,5)", "assert count_alpha_dig_spl(\"fjdsif627348#%$^&\")==(6,6,5)" ]
[]
674
Write a python function to calculate the product of all the numbers of a given tuple.
def check(string): if len(set(string).intersection("AEIOUaeiou"))>=5: return ('accepted') else: return ("not accepted")
[ "assert set_Right_most_Unset_Bit(21) == 23", "assert set_Right_most_Unset_Bit(11) == 15", "assert set_Right_most_Unset_Bit(15) == 15" ]
[]
784
Write a python function to check whether the given number can be represented by sum of two squares or not.
def zip_list(list1,list2): result = list(map(list.__add__, list1, list2)) return result
[ "assert previous_palindrome(99)==88", "assert previous_palindrome(1221)==1111", "assert previous_palindrome(120)==111" ]
[]
616
Write a function to find the nth delannoy number.
def last(n): return n[-1] def sort_list_last(tuples): return sorted(tuples, key=last)
[ "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]" ]
[]
815
Write a function to check if the given expression is balanced or not.
import re def extract_quotation(text1): return (re.findall(r'"(.*?)"', text1))
[ "assert odd_Num_Sum(2) == 82", "assert odd_Num_Sum(3) == 707", "assert odd_Num_Sum(4) == 3108" ]
[]
705
Write a python function to find the minimum difference between any two elements in a given array.
from collections import Counter def anagram_lambda(texts,str): result = list(filter(lambda x: (Counter(str) == Counter(x)), texts)) return result
[ "assert first_Digit(5) == 1", "assert first_Digit(10) == 3", "assert first_Digit(7) == 5" ]
[]
691
Write a function to check for the number of jumps required of given length to reach a point of form (d, 0) from origin in a 2d plane.
def sum_column(list1, C): result = sum(row[C] for row in list1) return result
[ "assert remove_duplic_list([\"Python\", \"Exercises\", \"Practice\", \"Solution\", \"Exercises\"])==['Python', 'Exercises', 'Practice', 'Solution']", "assert remove_duplic_list([\"Python\", \"Exercises\", \"Practice\", \"Solution\", \"Exercises\",\"Java\"])==['Python', 'Exercises', 'Practice', 'Solution', 'Java']...
[]
845
Write a function to clear the values of the given tuples.
def is_subset(arr1, m, arr2, n): hashset = set() for i in range(0, m): hashset.add(arr1[i]) for i in range(0, n): if arr2[i] in hashset: continue else: return False return True
[ "assert pack_consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4])==[[0, 0], [1], [2], [3], [4, 4], [5], [6, 6, 6], [7], [8], [9], [4, 4]]", "assert pack_consecutive_duplicates([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10])==[[10, 10], [15], [19], [18, 18], [17], [26, 26], [17], [18], [10]]"...
[]
655
Write a function to extract values between quotation marks of the given string by using regex.
def Check_Solution(a,b,c): if (a == c): return ("Yes"); else: return ("No");
[ "assert find_Min_Diff((1,5,3,19,18,25),6) == 1", "assert find_Min_Diff((4,3,2,6),4) == 1", "assert find_Min_Diff((30,5,20,9),4) == 4" ]
[]
748
Write a python function to find the sum of all odd length subarrays.
def max_similar_indices(test_list1, test_list2): res = [(max(x[0], y[0]), max(x[1], y[1])) for x, y in zip(test_list1, test_list2)] return (res)
[ "assert check_monthnumb(\"February\")==False", "assert check_monthnumb(\"January\")==True", "assert check_monthnumb(\"March\")==True" ]
[]
878
Write a python function to find the sum of non-repeated elements in a given array.
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 tuple_modulo((10, 4, 5, 6), (5, 6, 7, 5)) == (0, 4, 5, 1)", "assert tuple_modulo((11, 5, 6, 7), (6, 7, 8, 6)) == (5, 5, 6, 1)", "assert tuple_modulo((12, 6, 7, 8), (7, 8, 9, 7)) == (5, 6, 7, 1)" ]
[]
831
Write a function to find the maximum number of segments of lengths a, b and c that can be formed from n.
def test_three_equal(x,y,z): result= set([x,y,z]) if len(result)==3: return 0 else: return (4-len(result))
[ "assert find_triplet_array([1, 4, 45, 6, 10, 8], 6, 22) == (4, 10, 8)", "assert find_triplet_array([12, 3, 5, 2, 6, 9], 6, 24) == (12, 3, 9)", "assert find_triplet_array([1, 2, 3, 4, 5], 5, 9) == (1, 3, 5)" ]
[]
672
Write a function to extract unique values from the given dictionary values.
def get_odd_occurence(arr, arr_size): for i in range(0, arr_size): count = 0 for j in range(0, arr_size): if arr[i] == arr[j]: count += 1 if (count % 2 != 0): return arr[i] return -1
[ "assert fibonacci(7) == 13", "assert fibonacci(8) == 21", "assert fibonacci(9) == 34" ]
[]
807
Write a python function to check whether the roots of a quadratic equation are numerically equal but opposite in sign or not.
def super_seq(X, Y, m, n): if (not m): return n if (not n): return m if (X[m - 1] == Y[n - 1]): return 1 + super_seq(X, Y, m - 1, n - 1) return 1 + min(super_seq(X, Y, m - 1, n), super_seq(X, Y, m, n - 1))
[ "assert remove_parenthesis([\"python (chrome)\"])==(\"python\")", "assert remove_parenthesis([\"string(.abc)\"])==(\"string\")", "assert remove_parenthesis([\"alpha(num)\"])==(\"alpha\")" ]
[]
803
Write a python function to find sum of prime numbers between 1 to n.
def palindrome_lambda(texts): result = list(filter(lambda x: (x == "".join(reversed(x))), texts)) return result
[ "assert pair_wise([1,1,2,3,3,4,4,5])==[(1, 1), (1, 2), (2, 3), (3, 3), (3, 4), (4, 4), (4, 5)]", "assert pair_wise([1,5,7,9,10])==[(1, 5), (5, 7), (7, 9), (9, 10)]", "assert pair_wise([1,2,3,4,5,6,7,8,9,10])==[(1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), (8, 9), (9, 10)]" ]
[]
745
Write a function to check whether the given amount has no profit and no loss
import re def remove_char(S): result = re.sub('[\W_]+', '', S) return result
[ "assert decreasing_trend([-4,-3,-2,-1]) == True", "assert decreasing_trend([1,2,3]) == True", "assert decreasing_trend([3,2,1]) == False" ]
[]
786
Write a function to find the number which occurs for odd number of times in the given array.
def count_list(input_list): return len(input_list)
[ "assert freq_element((4, 5, 4, 5, 6, 6, 5, 5, 4) ) == '{4: 3, 5: 4, 6: 2}'", "assert freq_element((7, 8, 8, 9, 4, 7, 6, 5, 4) ) == '{7: 2, 8: 2, 9: 1, 4: 2, 6: 1, 5: 1}'", "assert freq_element((1, 4, 3, 1, 4, 5, 2, 6, 2, 7) ) == '{1: 2, 4: 2, 3: 1, 5: 1, 2: 2, 6: 1, 7: 1}'" ]
[]
787
Write a python function to find the first repeated character in a given string.
import heapq as hq def raw_heap(rawheap): hq.heapify(rawheap) return rawheap
[ "assert harmonic_sum(10)==2.9289682539682538", "assert harmonic_sum(4)==2.083333333333333", "assert harmonic_sum(7)==2.5928571428571425 " ]
[]
684
Write a function to count repeated items of a tuple.
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 div_of_nums([19, 65, 57, 39, 152, 639, 121, 44, 90, 190],19,13)==[19, 65, 57, 39, 152, 190]", "assert div_of_nums([1, 2, 3, 5, 7, 8, 10],2,5)==[2, 5, 8, 10]", "assert div_of_nums([10,15,14,13,18,12,20],10,5)==[10, 15, 20]" ]
[]
780
Write a function to find the perimeter of a rectangle.
def remove_empty(tuple1): #L = [(), (), ('',), ('a', 'b'), ('a', 'b', 'c'), ('d')] tuple1 = [t for t in tuple1 if t] return tuple1
[ "assert extract_unique({'msm' : [5, 6, 7, 8],'is' : [10, 11, 7, 5],'best' : [6, 12, 10, 8],'for' : [1, 2, 5]} ) == [1, 2, 5, 6, 7, 8, 10, 11, 12]", "assert extract_unique({'Built' : [7, 1, 9, 4],'for' : [11, 21, 36, 14, 9],'ISP' : [4, 1, 21, 39, 47],'TV' : [1, 32, 38]} ) == [1, 4, 7, 9, 11, 14, 21, 32, 36, 38, 39...
[]
926
Write a function to round up a number to specific digits.
def check_min_heap(arr, i): if 2 * i + 2 > len(arr): return True left_child = (arr[i] <= arr[2 * i + 1]) and check_min_heap(arr, 2 * i + 1) right_child = (2 * i + 2 == len(arr)) or (arr[i] <= arr[2 * i + 2] and check_min_heap(arr, 2 * i + 2)) return l...
[ "assert is_odd(5) == True", "assert is_odd(6) == False", "assert is_odd(7) == True" ]
[]
716
Write a function to check if a nested list is a subset of another nested list.
from itertools import groupby def pack_consecutive_duplicates(list1): return [list(group) for key, group in groupby(list1)]
[ "assert even_num(13.5)==False", "assert even_num(0)==True", "assert even_num(-9)==False" ]
[]
723
Write a python function to find the last two digits in factorial of a given number.
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 get_median([1, 12, 15, 26, 38], [2, 13, 17, 30, 45], 5) == 16.0", "assert get_median([2, 4, 8, 9], [7, 13, 19, 28], 4) == 8.5", "assert get_median([3, 6, 14, 23, 36, 42], [2, 18, 27, 39, 49, 55], 6) == 25.0" ]
[]
885
Write a function to find out the second most repeated (or frequent) string in the given sequence.
def filter_data(students,h,w): result = {k: s for k, s in students.items() if s[0] >=h and s[1] >=w} return result
[ "assert count_char(\"Python\",'o')==1", "assert count_char(\"little\",'t')==2", "assert count_char(\"assert\",'s')==2" ]
[]
660
Write a python function to count the number of digits in factorial of a given number.
def convert(list): s = [str(i) for i in list] res = int("".join(s)) return (res)
[ "assert get_item((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),3)==('e')", "assert get_item((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),-4)==('u')", "assert get_item((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),-3)==('r')" ]
[]
790
Write a function to find the longest common subsequence for the given three string sequence.
def is_key_present(d,x): if x in d: return True else: return False
[ "assert toggle_middle_bits(9) == 15", "assert toggle_middle_bits(10) == 12", "assert toggle_middle_bits(11) == 13" ]
[]
930
Write a python function to find the largest triangle that can be inscribed in the semicircle.
def find_platform(arr, dep, n): arr.sort() dep.sort() plat_needed = 1 result = 1 i = 1 j = 0 while (i < n and j < n): if (arr[i] <= dep[j]): plat_needed+= 1 i+= 1 elif (arr[i] > dep[j]): plat_needed-= 1...
[ "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" ]
[]
785
Write a function to add a dictionary to the tuple.
from collections import defaultdict def grouping_dictionary(l): d = defaultdict(list) for k, v in l: d[k].append(v) return d
[ "assert test_three_equal(1,1,1) == 3", "assert test_three_equal(-1,-2,-3) == 0", "assert test_three_equal(1,2,2) == 2" ]
[]
740
Write a function to locate the right insertion point for a specified value in sorted order.
def remove_kth_element(list1, L): return list1[:L-1] + list1[L:]
[ "assert get_Pairs_Count([1,1,1,1],4,2) == 6", "assert get_Pairs_Count([1,5,7,-1,5],5,6) == 3", "assert get_Pairs_Count([1,-2,3],3,1) == 1" ]
[]
631
Write a function to check a decimal with a precision of 2.
def check_Concat(str1,str2): N = len(str1) M = len(str2) if (N % M != 0): return False for i in range(N): if (str1[i] != str2[i % M]): return False return True
[ "assert substract_elements(((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))) == ((-5, -4), (1, -4), (1, 8), (-6, 7))", "assert substract_elements(((13, 4), (14, 6), (13, 10), (12, 11)), ((19, 8), (14, 10), (12, 2), (18, 4))) == ((-6, -4), (0, -4), (1, 8), (-6, 7))", "assert substract_elements...
[]
771
Write a function to convert camel case string to snake case string by using regex.
import itertools def remove_duplicate(list1): list.sort(list1) remove_duplicate = list(list1 for list1,_ in itertools.groupby(list1)) return remove_duplicate
[ "assert change_date_format('2026-01-02')=='02-01-2026'", "assert change_date_format('2021-01-04')=='04-01-2021'", "assert change_date_format('2030-06-06')=='06-06-2030'" ]
[]
929
Write a python function to merge the first and last elements separately in a list of lists.
def count_Rotation(arr,n): for i in range (1,n): if (arr[i] < arr[i - 1]): return i return 0
[ "assert string_length('python')==6", "assert string_length('program')==7", "assert string_length('language')==8" ]
[]
715
Write a function to check whether the given month number contains 30 days or not.
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 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]" ]
[]
897
Write a python function to find the sum of an array.
def find_first_occurrence(A, x): (left, right) = (0, len(A) - 1) result = -1 while left <= right: mid = (left + right) // 2 if x == A[mid]: result = mid right = mid - 1 elif x < A[mid]: right = mid - 1 else: left = mi...
[ "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): ...
[]
858
Write a function to extract the maximum numeric value from a string by using regex.
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 average_tuple(((10, 10, 10, 12), (30, 45, 56, 45), (81, 80, 39, 32), (1, 2, 3, 4)))==[30.5, 34.25, 27.0, 23.25]", "assert average_tuple(((1, 1, -5), (30, -15, 56), (81, -60, -39), (-10, 2, 3)))== [25.5, -18.0, 3.75]", "assert average_tuple( ((100, 100, 100, 120), (300, 450, 560, 450), (810, 800, 390, 32...
[]
795
Write a function to check if the given array represents min heap or not.
def access_elements(nums, list_index): result = [nums[i] for i in list_index] return result
[ "assert matrix_to_list([[(4, 5), (7, 8)], [(10, 13), (18, 17)], [(0, 4), (10, 1)]]) == '[(4, 7, 10, 18, 0, 10), (5, 8, 13, 17, 4, 1)]'", "assert matrix_to_list([[(5, 6), (8, 9)], [(11, 14), (19, 18)], [(1, 5), (11, 2)]]) == '[(5, 8, 11, 19, 1, 11), (6, 9, 14, 18, 5, 2)]'", "assert matrix_to_list([[(6, 7), (9, 1...
[]
953
Write a function to find the smallest multiple of the first n numbers.
def is_decimal(num): import re dnumre = re.compile(r"""^[0-9]+(\.[0-9]{1,2})?$""") result = dnumre.search(num) return bool(result)
[ "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',...
[]
750
Write a python function to find the cube sum of first n odd natural numbers.
def is_Product_Even(arr,n): for i in range(0,n): if ((arr[i] & 1) == 0): return True return False
[ "assert extract_date(\"https://www.washingtonpost.com/news/football-insider/wp/2016/09/02/odell-beckhams-fame-rests-on-one-stupid-little-ball-josh-norman-tells-author/\") == [('2016', '09', '02')]", "assert extract_date(\"https://www.indiatoday.in/movies/celebrities/story/wp/2020/11/03/odeof-sushant-singh-rajput-...
[]
747
Write a python function to find the average of a list.
def divisible_by_digits(startnum, endnum): return [n for n in range(startnum, endnum+1) \ if not any(map(lambda x: int(x) == 0 or n%int(x) != 0, str(n)))]
[ "assert check_str(\"annie\") == 'Valid'", "assert check_str(\"dawood\") == 'Invalid'", "assert check_str(\"Else\") == 'Valid'" ]
[]
685
Write a python function to find the smallest missing number from the given array.
import re def replace_specialchar(text): return (re.sub("[ ,.]", ":", text))
[ "assert smallest_Divisor(10) == 2", "assert smallest_Divisor(25) == 5", "assert smallest_Divisor(31) == 31" ]
[]
942
Write a function to return true if the given number is even else return false.
def min_Swaps(str1,str2) : count = 0 for i in range(len(str1)) : if str1[i] != str2[i] : count += 1 if count % 2 == 0 : return (count // 2) else : return ("Not Possible")
[ "assert join_tuples([(5, 6), (5, 7), (6, 8), (6, 10), (7, 13)] ) == [(5, 6, 7), (6, 8, 10), (7, 13)]", "assert join_tuples([(6, 7), (6, 8), (7, 9), (7, 11), (8, 14)] ) == [(6, 7, 8), (7, 9, 11), (8, 14)]", "assert join_tuples([(7, 8), (7, 9), (8, 10), (8, 12), (9, 15)] ) == [(7, 8, 9), (8, 10, 12), (9, 15)]" ]
[]
901
Write a function to count the pairs of reverse strings in the given string list.
import sys def find_closet(A, B, C, p, q, r): diff = sys.maxsize res_i = 0 res_j = 0 res_k = 0 i = 0 j = 0 k = 0 while(i < p and j < q and k < r): minimum = min(A[i], min(B[j], C[k])) maximum = max(A[i], max(B[j], C[k])); if maximum-minimum < diff: res_i = i res_j = j re...
[ "assert get_Number(8,5) == 2", "assert get_Number(7,2) == 3", "assert get_Number(5,2) == 3" ]
[]
777
Write a function to return true if the password is valid.
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 jacobsthal_num(5) == 11", "assert jacobsthal_num(2) == 1", "assert jacobsthal_num(4) == 5" ]
[]
764
Write a python function to accept the strings which contains all vowels.
def Check_Vow(string, vowels): final = [each for each in string if each in vowels] return(len(final))
[ "assert min_Swaps(\"1101\",\"1110\") == 1", "assert min_Swaps(\"1111\",\"0100\") == \"Not Possible\"", "assert min_Swaps(\"1110000\",\"0001101\") == 3" ]
[]
608
Write a function to find the nth jacobsthal number.
def merge(lst): return [list(ele) for ele in list(zip(*lst))]
[ "assert most_common_elem('lkseropewdssafsdfafkpwe',3)==[('s', 4), ('e', 3), ('f', 3)] ", "assert most_common_elem('lkseropewdssafsdfafkpwe',2)==[('s', 4), ('e', 3)]", "assert most_common_elem('lkseropewdssafsdfafkpwe',7)==[('s', 4), ('e', 3), ('f', 3), ('k', 2), ('p', 2), ('w', 2), ('d', 2)]" ]
[]
668
Write a python function to find the minimum number of swaps required to convert one binary string to another.
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 group_element([(6, 5), (2, 7), (2, 5), (8, 7), (9, 8), (3, 7)]) == {5: [6, 2], 7: [2, 8, 3], 8: [9]}", "assert group_element([(7, 6), (3, 8), (3, 6), (9, 8), (10, 9), (4, 8)]) == {6: [7, 3], 8: [3, 9, 4], 9: [10]}", "assert group_element([(8, 7), (4, 9), (4, 7), (10, 9), (11, 10), (5, 9)]) == {7: [8, 4]...
[]
974
Write a python function to count the number of distinct power of prime factor of given number.
def all_Bits_Set_In_The_Given_Range(n,l,r): num = ((1 << r) - 1) ^ ((1 << (l - 1)) - 1) new_num = n & num if (num == new_num): return True return False
[ "assert remove_spaces(\"a b c\") == \"abc\"", "assert remove_spaces(\"1 2 3\") == \"123\"", "assert remove_spaces(\" b c\") == \"bc\"" ]
[]
604
Write a function to sort a list of lists by length and value.
def sum_positivenum(nums): sum_positivenum = list(filter(lambda nums:nums>0,nums)) return sum(sum_positivenum)
[ "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...
[]
607
Write a function to remove an empty tuple from a list of tuples.
def is_Perfect_Square(n) : i = 1 while (i * i<= n): if ((n % i == 0) and (n / i == i)): return True i = i + 1 return False
[ "assert is_Product_Even([1,2,3],3) == True", "assert is_Product_Even([1,2,1,4],4) == True", "assert is_Product_Even([1,1],2) == False" ]
[]
725
Write a python function to check if the string is a concatenation of another string.
def even_num(x): if x%2==0: return True else: return False
[ "assert sum_nums(2,10,11,20)==20", "assert sum_nums(15,17,1,10)==32", "assert sum_nums(10,15,5,30)==20" ]
[]
702
Write a function to check if the given integer is a prime number.
def last_Two_Digits(N): if (N >= 10): return fac = 1 for i in range(1,N + 1): fac = (fac * i) % 100 return (fac)
[ "assert mul_consecutive_nums([1, 1, 3, 4, 4, 5, 6, 7])==[1, 3, 12, 16, 20, 30, 42]", "assert mul_consecutive_nums([4, 5, 8, 9, 6, 10])==[20, 40, 72, 54, 60]", "assert mul_consecutive_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[2, 6, 12, 20, 30, 42, 56, 72, 90]" ]
[]
772
Write a python function to check whether the word is present in a given sentence or not.
def Check_Solution(a,b,c) : if ((b*b) - (4*a*c)) > 0 : return ("2 solutions") elif ((b*b) - (4*a*c)) == 0 : return ("1 solution") else : return ("No solutions")
[ "assert check_IP(\"192.168.0.1\") == 'Valid IP address'", "assert check_IP(\"110.234.52.124\") == 'Valid IP address'", "assert check_IP(\"366.1.2.2\") == 'Invalid IP address'" ]
[]
635
Write a function to find the minimum difference in the tuple pairs of given tuples.
def all_Characters_Same(s) : n = len(s) for i in range(1,n) : if s[i] != s[0] : return False return True
[ "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" ]
[]
841
Write a python function to check whether all the characters are same or not.
def check_none(test_tup): res = any(map(lambda ele: ele is None, test_tup)) return (res)
[ "assert check_K((10, 4, 5, 6, 8), 6) == True", "assert check_K((1, 2, 3, 4, 5, 6), 7) == False", "assert check_K((7, 8, 9, 44, 11, 12), 11) == True" ]
[]
653
Write a function to get dictionary keys as a list.
def even_position(nums): return all(nums[i]%2==i%2 for i in range(len(nums)))
[ "assert lower_ctr('abc') == 3", "assert lower_ctr('string') == 6", "assert lower_ctr('Python') == 5" ]
[]
End of preview. Expand in Data Studio

edition_0705_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
6