Dataset Viewer
Auto-converted to Parquet Duplicate
task_id
int64
601
974
text
large_stringlengths
38
249
code
large_stringlengths
30
908
test_list
listlengths
3
3
test_setup_code
large_stringclasses
2 values
challenge_test_list
listlengths
0
0
734
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 add_list(nums1,nums2): result = map(lambda x, y: x + y, nums1, nums2) return list(result)
[ "assert sample_nam(['sally', 'Dylan', 'rebecca', 'Diana', 'Joanne', 'keith'])==16", "assert sample_nam([\"php\", \"res\", \"Python\", \"abcd\", \"Java\", \"aaa\"])==10", "assert sample_nam([\"abcd\", \"Python\", \"abba\", \"aba\"])==6" ]
[]
784
Write a function that matches a string that has an a followed by three 'b'.
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 sort_list([(3, 4, 6, 723), (1, 2), (12345,), (134, 234, 34)] ) == '[(1, 2), (12345,), (3, 4, 6, 723), (134, 234, 34)]'", "assert sort_list([(3, 4, 8), (1, 2), (1234335,), (1345, 234, 334)] ) == '[(1, 2), (3, 4, 8), (1234335,), (1345, 234, 334)]'", "assert sort_list([(34, 4, 61, 723), (1, 2), (145,), (13...
[]
855
Write a function to count the pairs of reverse strings in the given string list.
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 rectangle_perimeter(10,20)==60", "assert rectangle_perimeter(10,5)==30", "assert rectangle_perimeter(4,2)==12" ]
[]
878
Write a function to sort dictionary items by tuple product of keys for the given dictionary with tuple keys.
def get_product(val) : res = 1 for ele in val: res *= ele return res def find_k_product(test_list, K): res = get_product([sub[K] for sub in test_list]) return (res)
[ "assert number_ctr('program2bedone') == 1", "assert number_ctr('3wonders') ==1", "assert number_ctr('123') == 3" ]
[]
920
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_starta_endb(text): patterns = 'a.*?b$' if re.search(patterns, text): return 'Found a match!' else: return('Not matched!')
[ "assert lucky_num(10)==[1, 3, 7, 9, 13, 15, 21, 25, 31, 33] ", "assert lucky_num(5)==[1, 3, 7, 9, 13]", "assert lucky_num(8)==[1, 3, 7, 9, 13, 15, 21, 25]" ]
[]
801
Write a function that gives profit amount if the given amount has profit else return none.
def even_Power_Sum(n): sum = 0; for i in range(1,n + 1): j = 2*i; sum = sum + (j*j*j*j); return sum;
[ "assert (Diff([10, 15, 20, 25, 30, 35, 40], [25, 40, 35])) == [10, 20, 30, 15]", "assert (Diff([1,2,3,4,5], [6,7,1])) == [2,3,4,5,6,7]", "assert (Diff([1,2,3], [6,7,1])) == [2,3,6,7]" ]
[]
632
Write a python function to find the index of an extra element present in one sorted array.
def check_subset(test_tup1, test_tup2): res = set(test_tup2).issubset(test_tup1) return (res)
[ "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]" ]
[]
634
Write a python function to left rotate the bits of a given number.
import re def split_upperstring(text): return (re.findall('[A-Z][^A-Z]*', text))
[ "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]" ]
[]
934
Write a function to convert degrees to radians.
def reverse_list_lists(lists): for l in lists: l.sort(reverse = True) return lists
[ "assert Sum(60) == 10", "assert Sum(39) == 16", "assert Sum(40) == 7" ]
[]
810
## write a function to find the minimum number of jumps to reach the end of the array for the given array of integers where each element represents the max number of steps that can be made forward from that element. > indented block > indented block
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 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]" ]
[]
680
Write a function to locate the right insertion point for a specified value in sorted order.
def tuple_to_set(t): s = set(t) return (s)
[ "assert increasing_trend([1,2,3,4]) == True", "assert increasing_trend([4,3,2,1]) == False", "assert increasing_trend([0,1,4,9]) == True" ]
[]
609
Write a python function to check for even parity of a given number.
def max_of_two( x, y ): if x > y: return x return y
[ "assert Split([1,2,3,4,5]) == [2,4]", "assert Split([4,5,6,7,8,0,1]) == [4,6,8,0]", "assert Split ([8,12,15,19]) == [8,12]" ]
[]
665
Write a function to find the smallest multiple of the first n numbers.
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 same_Length(12,1) == False", "assert same_Length(2,2) == True", "assert same_Length(10,20) == True" ]
[]
883
Write a python function to find the index of smallest triangular number with n digits.
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 subset([1, 2, 3, 4],4) == 1", "assert subset([5, 6, 9, 3, 4, 3, 4],7) == 2", "assert subset([1, 2, 3 ],3) == 1" ]
[]
944
Write a python function to find sum of prime numbers between 1 to n.
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 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" ]
[]
813
Write a python function to remove even numbers from a given list.
def Check_Solution(a,b,c): if b == 0: return ("Yes") else: return ("No")
[ "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" ]
[]
965
Write a python function to find the type of triangle from the given sides.
def lcopy(xs): return xs[:]
[ "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'}" ]
[]
668
Write a python function to find the slope of a line.
import bisect def left_insertion(a, x): i = bisect.bisect_left(a, x) return i
[ "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'" ]
[]
682
Write a function to extract values between quotation marks of the given string by using regex.
def Average(lst): return sum(lst) / len(lst)
[ "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" ]
[]
679
Write a function to solve the fibonacci sequence using recursion.
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 all_Characters_Same(\"python\") == False", "assert all_Characters_Same(\"aaa\") == True", "assert all_Characters_Same(\"data\") == False" ]
[]
756
Write a function to check whether the given string is starting with a vowel or not using regex.
def Check_Vow(string, vowels): final = [each for each in string if each in vowels] return(len(final))
[ "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...
[]
684
Write a python function to check if roots of a quadratic equation are reciprocal of each other or not.
def zip_list(list1,list2): result = list(map(list.__add__, list1, list2)) return result
[ "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" ]
[]
751
Write a function to find the maximum sum of subsequences of given array with no adjacent elements.
def get_key(dict): list = [] for key in dict.keys(): list.append(key) return list
[ "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" ]
[]
688
Write a function to find nth polite number.
M = 100 def maxAverageOfPath(cost, N): dp = [[0 for i in range(N + 1)] for j in range(N + 1)] dp[0][0] = cost[0][0] for i in range(1, N): dp[i][0] = dp[i - 1][0] + cost[i][0] for j in range(1, N): dp[0][j] = dp[0][j - 1] + cost[0][j] for i in range(1, N): for j in range(1, N): dp[i][j] ...
[ "assert get_First_Set_Bit_Pos(12) == 3", "assert get_First_Set_Bit_Pos(18) == 2", "assert get_First_Set_Bit_Pos(16) == 5" ]
[]
761
Write a function to calculate the standard deviation.
import re regex = '''^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.( 25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.( 25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.( 25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$''' def check_IP(Ip): if(re.search(regex, Ip)): return ("Valid IP address") else: return ("Invalid I...
[ "assert first_repeated_char(\"abcabc\") == \"a\"", "assert first_repeated_char(\"abc\") == \"None\"", "assert first_repeated_char(\"123123\") == \"1\"" ]
[]
753
Write a function to sum elements in two lists.
import re def end_num(string): text = re.compile(r".*[0-9]$") if text.match(string): return True else: return False
[ "assert sum_positivenum([2, 4, -6, -9, 11, -12, 14, -5, 17])==48", "assert sum_positivenum([10,15,-14,13,-18,12,-20])==50", "assert sum_positivenum([19, -65, 57, 39, 152,-639, 121, 44, 90, -190])==522" ]
[]
831
Write a function to list out the list of given strings individually using map function.
def subset(ar, n): res = 0 ar.sort() for i in range(0, n) : count = 1 for i in range(n - 1): if ar[i] == ar[i + 1]: count+=1 else: break res = max(res, count) return res
[ "assert min_difference([(3, 5), (1, 7), (10, 3), (1, 2)]) == 1", "assert min_difference([(4, 6), (12, 8), (11, 4), (2, 13)]) == 2", "assert min_difference([(5, 17), (3, 9), (12, 5), (3, 24)]) == 6" ]
[]
945
Write a function to check whether the given month number contains 30 days or not.
def check_K(test_tup, K): res = False for ele in test_tup: if ele == K: res = True break return (res)
[ "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'" ]
[]
783
Write a function to find minimum k records from tuple list.
def div_list(nums1,nums2): result = map(lambda x, y: x / y, nums1, nums2) return list(result)
[ "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" ]
[]
847
Write a function to combine two dictionaries by adding values for common keys.
def same_Length(A,B): while (A > 0 and B > 0): A = A / 10; B = B / 10; if (A == 0 and B == 0): return True; return False;
[ "assert check([3,2,1,2,3,4],6) == True", "assert check([2,1,4,5,1],5) == True", "assert check([1,2,2,1,2,3],6) == True" ]
[]
616
Write a function to divide two lists using map and lambda function.
def is_odd(n) : if (n^1 == n-1) : return True; else : return False;
[ "assert check_monthnumber_number(6)==True", "assert check_monthnumber_number(2)==False", "assert check_monthnumber_number(12)==False" ]
[]
948
Write a python function to find the sum of non-repeated elements in a given array.
def find_Min_Sum(a,b,n): a.sort() b.sort() sum = 0 for i in range(n): sum = sum + abs(a[i] - b[i]) return sum
[ "assert check_tuples((3, 5, 6, 5, 3, 6),[3, 6, 5]) == True", "assert check_tuples((4, 5, 6, 4, 6, 5),[4, 5, 6]) == True", "assert check_tuples((9, 8, 7, 6, 8, 9),[9, 8, 1]) == False" ]
[]
733
Write a function to pack consecutive duplicates of a given list elements into sublists.
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 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')" ]
[]
806
Write a function to find all anagrams of a string in a given list of strings using lambda function.
def add_tuple(test_list, test_tup): test_list += test_tup return (test_list)
[ "assert sum_even_odd([1,3,5,7,4,1,6,8])==5", "assert sum_even_odd([1,2,3,4,5,6,7,8,9,10])==3", "assert sum_even_odd([1,5,7,9,10])==11" ]
[]
935
Write a function to get an item of a tuple.
def count_reverse_pairs(test_list): res = sum([1 for idx in range(0, len(test_list)) for idxn in range(idx, len( test_list)) if test_list[idxn] == str(''.join(list(reversed(test_list[idx]))))]) return str(res)
[ "assert check_str(\"annie\") == 'Valid'", "assert check_str(\"dawood\") == 'Invalid'", "assert check_str(\"Else\") == 'Valid'" ]
[]
963
Write a python function to get the last element of each sublist.
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 split_upperstring(\"PythonProgramLanguage\")==['Python','Program','Language']", "assert split_upperstring(\"PythonProgram\")==['Python','Program']", "assert split_upperstring(\"ProgrammingLanguage\")==['Programming','Language']" ]
[]
853
Write a python function to find the minimum difference between any two elements in a given array.
def smallest_Divisor(n): if (n % 2 == 0): return 2; i = 3; while (i*i <= n): if (n % i == 0): return i; i += 2; return n;
[ "assert move_num('I1love143you55three3000thousand') == 'Iloveyouthreethousand1143553000'", "assert move_num('Avengers124Assemble') == 'AvengersAssemble124'", "assert move_num('Its11our12path13to14see15things16do17things') == 'Itsourpathtoseethingsdothings11121314151617'" ]
[]
957
Write a function to find the combinations of sums with tuples in the given tuple list.
import math def area_tetrahedron(side): area = math.sqrt(3)*(side*side) return area
[ "assert round_up(123.01247,0)==124", "assert round_up(123.01247,1)==123.1", "assert round_up(123.01247,2)==123.02" ]
[]
708
Write a function to find palindromes in a given list of strings using lambda function.
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 find_max_val(15, 10, 5) == 15", "assert find_max_val(187, 10, 5) == 185", "assert find_max_val(16, 11, 1) == 12" ]
[]
741
Write a python function to count the number of pairs whose sum is equal to ‘sum’.
def ntimes_list(nums,n): result = map(lambda x:n*x, nums) return list(result)
[ "assert reverse_Array_Upto_K([1, 2, 3, 4, 5, 6],4) == [4, 3, 2, 1, 5, 6]", "assert reverse_Array_Upto_K([4, 5, 6, 7], 2) == [5, 4, 6, 7]", "assert reverse_Array_Upto_K([9, 8, 7, 6, 5],3) == [7, 8, 9, 6, 5]" ]
[]
698
Write a function to find the largest possible value of k such that k modulo x is y.
import re pattern = 'fox' text = 'The quick brown fox jumps over the lazy dog.' def find_literals(text, pattern): match = re.search(pattern, text) s = match.start() e = match.end() return (match.re.pattern, s, e)
[ "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)" ]
[]
772
Write a function to remove everything except alphanumeric characters from the given string by using regex.
def _sum(arr): sum=0 for i in arr: sum = sum + i return(sum)
[ "assert check_element((4, 5, 7, 9, 3), [6, 7, 10, 11]) == True", "assert check_element((1, 2, 3, 4), [4, 6, 7, 8, 9]) == True", "assert check_element((3, 2, 1, 4, 5), [9, 8, 7, 6]) == False" ]
[]
964
Write a function to replace all occurrences of spaces, commas, or dots with a colon.
def convert(list): s = [str(i) for i in list] res = int("".join(s)) return (res)
[ "assert convert([1,2,3]) == 123", "assert convert([4,5,6]) == 456", "assert convert([7,8,9]) == 789" ]
[]
736
Write a function to find the sequences of one upper case letter followed by lower case letters.
def get_item(tup1,index): item = tup1[index] return item
[ "assert text_match(\"msb\") == 'Not matched!'", "assert text_match(\"a0c\") == 'Found a match!'", "assert text_match(\"abbc\") == 'Found a match!'" ]
[]
652
Write a python function to convert the given string to upper case.
def sector_area(r,a): pi=22/7 if a >= 360: return None sectorarea = (pi*r**2) * (a/360) return sectorarea
[ "assert check_min_heap([1, 2, 3, 4, 5, 6], 0) == True", "assert check_min_heap([2, 3, 4, 5, 10, 15], 0) == True", "assert check_min_heap([2, 10, 4, 5, 3, 15], 0) == False" ]
[]
771
Write a python function to convert a string to a list.
def binomial_coeffi(n, k): if (k == 0 or k == n): return 1 return (binomial_coeffi(n - 1, k - 1) + binomial_coeffi(n - 1, k)) def rencontres_number(n, m): if (n == 0 and m == 0): return 1 if (n == 1 and m == 0): return 0 if (m == 0): return ((n - 1) * (rencontres_number(n - 1, 0)+ renc...
[ "assert sum_Even(2,5) == 6", "assert sum_Even(3,8) == 18", "assert sum_Even(4,6) == 10" ]
[]
959
Write a python function to find the sum of an array.
def noprofit_noloss(actual_cost,sale_amount): if(sale_amount == actual_cost): return True else: return False
[ "assert remove_parenthesis([\"python (chrome)\"])==(\"python\")", "assert remove_parenthesis([\"string(.abc)\"])==(\"string\")", "assert remove_parenthesis([\"alpha(num)\"])==(\"alpha\")" ]
[]
612
Write a python function to check whether the product of digits of a number at even and odd places is equal or not.
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 check_monthnumb(\"February\")==False", "assert check_monthnumb(\"January\")==True", "assert check_monthnumb(\"March\")==True" ]
[]
793
Write a function to count repeated items of a tuple.
def move_num(test_str): res = '' dig = '' for ele in test_str: if ele.isdigit(): dig += ele else: res += ele res += dig return (res)
[ "assert No_of_cubes(2,1) == 8", "assert No_of_cubes(5,2) == 64", "assert No_of_cubes(1,1) == 1" ]
[]
766
Write a function to find average value of the numbers in a given tuple of tuples.
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 find_Digits(7) == 4", "assert find_Digits(5) == 3", "assert find_Digits(4) == 2" ]
[]
704
Write a function to push all values into a heap and then pop off the smallest values one at a time.
def remove_even(l): for i in l: if i % 2 == 0: l.remove(i) return l
[ "assert recur_gcd(12,14) == 2", "assert recur_gcd(13,17) == 1", "assert recur_gcd(9, 3) == 3" ]
[]
660
Write a function to sort a list of dictionaries using lambda function.
import re def check_substring(string, sample) : if (sample in string): y = "\A" + sample x = re.search(y, string) if x : return ("string starts with the given substring") else : return ("string doesnt start with the given substring") else : retur...
[ "assert is_Isomorphic(\"paper\",\"title\") == True", "assert is_Isomorphic(\"ab\",\"ba\") == True", "assert is_Isomorphic(\"ab\",\"aa\") == False" ]
[]
952
Write a python function to check for odd parity of a given number.
def count_elim(num): count_elim = 0 for n in num: if isinstance(n, tuple): break count_elim += 1 return count_elim
[ "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...
[]
922
Write a function to find out the second most repeated (or frequent) string in the given sequence.
def No_of_cubes(N,K): No = 0 No = (N - K + 1) No = pow(No, 3) return No
[ "assert min_Num([1,2,3,4,5,6,7,8,9],9) == 1", "assert min_Num([1,2,3,4,5,6,7,8],8) == 2", "assert min_Num([1,2,3],3) == 2" ]
[]
647
Write a python function to check whether the length of the word is even or not.
def floor_Min(A,B,N): x = max(B - 1,N) return (A*x) // B
[ "assert maxAverageOfPath([[1, 2, 3], [6, 5, 4], [7, 3, 9]], 3) == 5.2", "assert maxAverageOfPath([[2, 3, 4], [7, 6, 5], [8, 4, 10]], 3) == 6.2", "assert maxAverageOfPath([[3, 4, 5], [8, 7, 6], [9, 5, 11]], 3) == 7.2 " ]
[]
626
Write a python function to check whether all the characters are same or not.
def multiply_elements(test_tup): res = tuple(i * j for i, j in zip(test_tup, test_tup[1:])) return (res)
[ "assert power_base_sum(2,100)==115", "assert power_base_sum(8,10)==37", "assert power_base_sum(8,15)==62" ]
[]
946
Write a function to check if the string is a valid email address or not using regex.
def check_subset(list1,list2): return all(map(list1.__contains__,list2))
[ "assert previous_palindrome(99)==88", "assert previous_palindrome(1221)==1111", "assert previous_palindrome(120)==111" ]
[]
901
Write a function to replace all spaces in the given string with character * list item * list item * list item * list item '%20'.
import re def remove_all_spaces(text): return (re.sub(r'\s+', '',text))
[ "assert check_substring(\"dreams for dreams makes life fun\", \"makes\") == 'string doesnt start with the given substring'", "assert check_substring(\"Hi there how are you Hi alex\", \"Hi\") == 'string starts with the given substring'", "assert check_substring(\"Its been a long day\", \"been\") == 'string doesn...
[]
714
Write a python function to reverse an array upto a given position.
def prime_num(num): if num >=1: for i in range(2, num//2): if (num % i) == 0: return False else: return True else: return False
[ "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)" ...
[]
602
Write a python function to remove negative numbers from a list.
def adjac(ele, sub = []): if not ele: yield sub else: yield from [idx for j in range(ele[0] - 1, ele[0] + 2) for idx in adjac(ele[1:], sub + [j])] def get_coordinates(test_tup): res = list(adjac(test_tup)) return (res)
[ "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]]"...
[]
781
Write a python function to check whether the two given strings are isomorphic to each other or not.
def check_element(test_tup, check_list): res = False for ele in check_list: if ele in test_tup: res = True break return (res)
[ "assert 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]" ]
[]
767
Write a function to count number of unique lists within a list.
from collections import Counter def max_char(str1): temp = Counter(str1) max_char = max(temp, key = temp.get) return max_char
[ "assert find_combinations([(2, 4), (6, 7), (5, 1), (6, 10)]) == [(8, 11), (7, 5), (8, 14), (11, 8), (12, 17), (11, 11)]", "assert find_combinations([(3, 5), (7, 8), (6, 2), (7, 11)]) == [(10, 13), (9, 7), (10, 16), (13, 10), (14, 19), (13, 13)]", "assert find_combinations([(4, 6), (8, 9), (7, 3), (8, 12)]) == [...
[]
792
Write a function to find the index of the first occurrence of a given number in a sorted array.
def listify_list(list1): result = list(map(list,list1)) return result
[ "assert remove_negs([1,-2,3,-4]) == [1,3]", "assert remove_negs([1,2,3,-4]) == [1,2,3]", "assert remove_negs([4,5,-6,7,-8]) == [4,5,7]" ]
[]
707
Write a function that matches a string that has an 'a' followed by anything, ending in 'b'.
def recur_gcd(a, b): low = min(a, b) high = max(a, b) if low == 0: return high elif low == 1: return 1 else: return recur_gcd(low, high%low)
[ "assert remove_empty([(), (), ('',), ('a', 'b'), ('a', 'b', 'c'), ('d')])==[('',), ('a', 'b'), ('a', 'b', 'c'), 'd'] ", "assert remove_empty([(), (), ('',), (\"python\"), (\"program\")])==[('',), (\"python\"), (\"program\")] ", "assert remove_empty([(), (), ('',), (\"java\")])==[('',),(\"java\") ] " ]
[]
873
Write a python function to get the difference between two lists.
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 slope(4,2,2,5) == -1.5", "assert slope(2,4,4,6) == 1", "assert slope(1,2,4,2) == 0" ]
[]
967
Write a function to split the given string at uppercase letters by using regex.
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 are_Rotations(\"abc\",\"cba\") == False", "assert are_Rotations(\"abcd\",\"cdba\") == False", "assert are_Rotations(\"abacd\",\"cdaba\") == True" ]
[]
721
Write a function to check whether the given month name contains 31 days or not.
def rearrange_numbs(array_nums): result = sorted(array_nums, key = lambda i: 0 if i == 0 else -1 / i) return result
[ "assert extract_quotation('Cortex \"A53\" Based \"multi\" tasking \"Processor\"') == ['A53', 'multi', 'Processor']", "assert extract_quotation('Cast your \"favorite\" entertainment \"apps\"') == ['favorite', 'apps']", "assert extract_quotation('Watch content \"4k Ultra HD\" resolution with \"HDR 10\" Support') ...
[]
919
Write a function to check whether the given ip address is valid or not using regex.
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 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]" ]
[]
868
Write a python function to count numeric values in a given string.
def check_Concat(str1,str2): N = len(str1) M = len(str2) if (N % M != 0): return False for i in range(N): if (str1[i] != str2[i % M]): return False return True
[ "assert is_decimal('123.11')==True", "assert is_decimal('e666.86')==False", "assert is_decimal('3.124587')==False" ]
[]
822
Write a function to find the cumulative sum of all the values that are present in the given tuple list.
def nCr_mod_p(n, r, p): if (r > n- r): r = n - r C = [0 for i in range(r + 1)] C[0] = 1 for i in range(1, n + 1): for j in range(min(i, r), 0, -1): C[j] = (C[j] + C[j-1]) % p return C[r]
[ "assert sort_by_dnf([1,2,0,1,0,1,2,1,1], 9) == [0, 0, 1, 1, 1, 1, 1, 2, 2]", "assert sort_by_dnf([1,0,0,1,2,1,2,2,1,0], 10) == [0, 0, 0, 1, 1, 1, 1, 2, 2, 2]", "assert sort_by_dnf([2,2,1,0,0,0,1,1,2,1], 10) == [0, 0, 0, 1, 1, 1, 1, 2, 2, 2]" ]
[]
803
Write a python function to check whether all the bits are within a given range or not.
from collections import Counter def most_common_elem(s,a): most_common_elem=Counter(s).most_common(a) return most_common_elem
[ "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" ]
[]
881
Write a function to remove all whitespaces from a string.
def find_fixed_point(arr, n): for i in range(n): if arr[i] is i: return i return -1
[ "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,...
[]
865
Write a function that matches a string that has an 'a' followed by anything, ending in 'b' by using regex.
def lcs_of_three(X, Y, Z, m, n, o): L = [[[0 for i in range(o+1)] for j in range(n+1)] for k in range(m+1)] for i in range(m+1): for j in range(n+1): for k in range(o+1): if (i == 0 or j == 0 or k == 0): L[i][j][k] = 0 elif (X[i-1] == Y[j-1] and X[i-1] == Z[k-1]): L[i][...
[ "assert return_sum({'a': 100, 'b':200, 'c':300}) == 600", "assert return_sum({'a': 25, 'b':18, 'c':45}) == 88", "assert return_sum({'a': 36, 'b':39, 'c':49}) == 124" ]
[]
904
Write a python function to find sum of products of all possible subarrays.
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_polite(7) == 11", "assert is_polite(4) == 7", "assert is_polite(9) == 13" ]
[]
891
Write a function to remove multiple spaces in a string.
def average_tuple(nums): result = [sum(x) / len(x) for x in zip(*nums)] return result
[ "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" ]
[]
778
Write a function to add all the numbers in a list and divide it with the length of the list.
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 check_Even_Parity(10) == True", "assert check_Even_Parity(11) == False", "assert check_Even_Parity(18) == True" ]
[]
785
Write a function to reverse words in a given string.
def Extract(lst): return [item[-1] for item in lst]
[ "assert text_match_three(\"ac\")==('Not matched!')", "assert text_match_three(\"dc\")==('Not matched!')", "assert text_match_three(\"abbbba\")==('Found a match!')" ]
[]
712
Write a python function to add a minimum number such that the sum of array becomes even.
def count_digs(tup): return sum([len(str(ele)) for ele in tup ]) def sort_list(test_list): test_list.sort(key = count_digs) return (str(test_list))
[ "assert even_position([3,2,1]) == False", "assert even_position([1,2,3]) == False", "assert even_position([2,1,4]) == True" ]
[]
727
Write a function to count coin change.
def slope(x1,y1,x2,y2): return (float)(y2-y1)/(x2-x1)
[ "assert consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4 ])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4]", "assert consecutive_duplicates([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10])==[10, 15, 19, 18, 17, 26, 17, 18, 10]", "assert consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd'])==['a', 'b...
[]
815
Write a function to find the occurrence and position of the substrings within a 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 rencontres_number(7, 2) == 924", "assert rencontres_number(3, 0) == 2", "assert rencontres_number(3, 1) == 3" ]
[]
773
Write a python function to multiply all items in the list.
def profit_amount(actual_cost,sale_amount): if(actual_cost > sale_amount): amount = actual_cost - sale_amount return amount else: return None
[ "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" ]
[]
699
Write a function to calculate the height of the given binary tree.
def count_even(array_nums): count_even = len(list(filter(lambda x: (x%2 == 0) , array_nums))) return count_even
[ "assert Repeat([10, 20, 30, 20, 20, 30, 40, 50, -20, 60, 60, -20, -20]) == [20, 30, -20, 60]", "assert Repeat([-1, 1, -1, 8]) == [-1]", "assert Repeat([1, 2, 3, 1, 2,]) == [1, 2]" ]
[]
848
Write a function to add a dictionary to the tuple.
import math def get_Pos_Of_Right_most_Set_Bit(n): return int(math.log2(n&-n)+1) def set_Right_most_Unset_Bit(n): if (n == 0): return 1 if ((n & (n + 1)) == 0): return n pos = get_Pos_Of_Right_most_Set_Bit(~n) return ((1 << (pos - 1)) | n)
[ "assert road_rd(\"ravipadu Road\")==('ravipadu Rd.')", "assert road_rd(\"palnadu Road\")==('palnadu Rd.')", "assert road_rd(\"eshwar enclave Road\")==('eshwar enclave Rd.')" ]
[]
618
Write a python function to remove the k'th element from a given list.
def substract_elements(test_tup1, test_tup2): res = tuple(tuple(a - b for a, b in zip(tup1, tup2)) for tup1, tup2 in zip(test_tup1, test_tup2)) return (res)
[ "assert remove_duplicate([[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]])==[[10, 20], [30, 56, 25], [33], [40]] ", "assert remove_duplicate([\"a\", \"b\", \"a\", \"c\", \"c\"] )==[\"a\", \"b\", \"c\"]", "assert remove_duplicate([1, 3, 5, 6, 3, 5, 6, 1] )==[1, 3, 5, 6]" ]
[]
960
Write a python function to toggle bits of the number except the first and the last bit.
def min_of_two( x, y ): if x < y: return x return y
[ "assert remove_tuple([(None, 2), (None, None), (3, 4), (12, 3), (None, )] ) == '[(None, 2), (3, 4), (12, 3)]'", "assert remove_tuple([(None, None), (None, None), (3, 6), (17, 3), (None,1 )] ) == '[(3, 6), (17, 3), (None, 1)]'", "assert remove_tuple([(1, 2), (2, None), (3, None), (24, 3), (None, None )] ) == '[(...
[]
843
Write a function to remove an empty tuple from a list of tuples.
def rombus_perimeter(a): perimeter=4*a return perimeter
[ "assert len_complex(3,4)==5.0", "assert len_complex(9,10)==13.45362404707371", "assert len_complex(7,9)==11.40175425099138" ]
[]
775
Write a function to solve tiling problem.
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 pair_OR_Sum([5,9,7,6],4) == 47", "assert pair_OR_Sum([7,3,5],3) == 12", "assert pair_OR_Sum([7,3],2) == 4" ]
[]
939
Write a function to find common index elements from three lists.
import math def lateralsurface_cone(r,h): l = math.sqrt(r * r + h * h) LSA = math.pi * r * l return LSA
[ "assert extract_elements([1, 1, 3, 4, 4, 5, 6, 7],2)==[1, 4]", "assert extract_elements([0, 1, 2, 3, 4, 4, 4, 4, 5, 7],4)==[4]", "assert extract_elements([0,0,0,0,0],5)==[0]" ]
[]
702
Write a python function to find the minimum sum of absolute differences of two arrays.
from collections import Counter def anagram_lambda(texts,str): result = list(filter(lambda x: (Counter(str) == Counter(x)), texts)) return result
[ "assert left_rotate(\"python\",2) == \"thonpy\" ", "assert left_rotate(\"bigdata\",3 ) == \"databig\" ", "assert left_rotate(\"hadoop\",1 ) == \"adooph\" " ]
[]
811
Write a function to find the product of it’s kth index in the given tuples.
import re def extract_quotation(text1): return (re.findall(r'"(.*?)"', text1))
[ "assert check_valid((True, True, True, True) ) == True", "assert check_valid((True, False, True, True) ) == False", "assert check_valid((True, True, True, True) ) == True" ]
[]
687
Write a function to display sign of the chinese zodiac for given year.
import re def text_uppercase_lowercase(text): patterns = '[A-Z]+[a-z]+$' if re.search(patterns, text): return 'Found a match!' else: return ('Not matched!')
[ "assert clear_tuple((1, 5, 3, 6, 8)) == ()", "assert clear_tuple((2, 1, 4 ,5 ,6)) == ()", "assert clear_tuple((3, 2, 5, 6, 8)) == ()" ]
[]
796
Write a function to find the minimum number of platforms required for a railway/bus station.
import re def camel_to_snake(text): str1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', text) return re.sub('([a-z0-9])([A-Z])', r'\1_\2', str1).lower()
[ "assert 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...
[]
861
Write a function to remove multiple spaces in a string by using regex.
def string_length(str1): count = 0 for char in str1: count += 1 return count
[ "assert rearrange_numbs([-1, 2, -3, 5, 7, 8, 9, -10])==[2, 5, 7, 8, 9, -10, -3, -1]", "assert rearrange_numbs([10,15,14,13,-18,12,-20])==[10, 12, 13, 14, 15, -20, -18]", "assert rearrange_numbs([-20,20,-10,10,-30,30])==[10, 20, 30, -30, -20, -10]" ]
[]
910
Write a function to find three closest elements from three sorted arrays.
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 replace_spaces('Jumanji The Jungle') == 'Jumanji_The_Jungle'", "assert replace_spaces('The Avengers') == 'The_Avengers'", "assert replace_spaces('Fast and Furious') == 'Fast_and_Furious'" ]
[]
635
Write function to find the sum of all items in the given dictionary.
def min_k(test_list, K): res = sorted(test_list, key = lambda x: x[1])[:K] return (res)
[ "assert text_match_wordz_middle(\"pythonzabc.\")==('Found a match!')", "assert text_match_wordz_middle(\"xyzabc.\")==('Found a match!')", "assert text_match_wordz_middle(\" lang .\")==('Not matched!')" ]
[]
882
Write a function to find out, if the given number is abundant.
from itertools import groupby def extract_elements(numbers, n): result = [i for i, j in groupby(numbers) if len(list(j)) == n] return result
[ "assert 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" ]
[]
739
Write a python function to check whether the roots of a quadratic equation are numerically equal but opposite in sign or not.
def Split(list): ev_li = [] for i in list: if (i % 2 == 0): ev_li.append(i) return ev_li
[ "assert cube_Sum(2) == 28", "assert cube_Sum(3) == 153", "assert cube_Sum(4) == 496" ]
[]
613
Write a function to check whether the given string is ending with only alphanumeric characters or not using regex.
def count_list(input_list): return (len(input_list))**2
[ "assert Convert('python program') == ['python','program']", "assert Convert('Data Analysis') ==['Data','Analysis']", "assert Convert('Hadoop Training') == ['Hadoop','Training']" ]
[]
748
Write a function to count the number of unique lists within a list.
def word_len(s): s = s.split(' ') for word in s: if len(word)%2==0: return True else: return False
[ "assert sort_tuple([(\"Amana\", 28), (\"Zenat\", 30), (\"Abhishek\", 29),(\"Nikhil\", 21), (\"B\", \"C\")]) == [('Abhishek', 29), ('Amana', 28), ('B', 'C'), ('Nikhil', 21), ('Zenat', 30)]", "assert sort_tuple([(\"aaaa\", 28), (\"aa\", 30), (\"bab\", 29), (\"bb\", 21), (\"csa\", \"C\")]) == [('aa', 30), ('aaaa', 2...
[]
686
Write a function to check a decimal with a precision of 2.
def sort_tuple(tup): n = len(tup) for i in range(n): for j in range(n-i-1): if tup[j][0] > tup[j + 1][0]: tup[j], tup[j + 1] = tup[j + 1], tup[j] return tup
[ "assert check(\"SEEquoiaL\") == 'accepted'", "assert check('program') == \"not accepted\"", "assert check('fine') == \"not accepted\"" ]
[]
End of preview. Expand in Data Studio

edition_2675_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
7