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
613
Write a function to find the length of the shortest string that has both str1 and str2 as subsequences.
def is_decimal(num): import re dnumre = re.compile(r"""^[0-9]+(\.[0-9]{1,2})?$""") result = dnumre.search(num) return bool(result)
[ "assert nth_super_ugly_number(12,[2,7,13,19])==32", "assert nth_super_ugly_number(10,[2,7,13,19])==26", "assert nth_super_ugly_number(100,[2,7,13,19])==5408" ]
[]
890
Write a python function to add a minimum number such that the sum of array becomes even.
import math def radian_degree(degree): radian = degree*(math.pi/180) return radian
[ "assert coin_change([1, 2, 3],3,4)==4", "assert coin_change([4,5,6,7,8,9],6,9)==2", "assert coin_change([4,5,6,7,8,9],6,4)==1" ]
[]
766
Write a function to calculate the harmonic sum of n-1.
import math def wind_chill(v,t): windchill = 13.12 + 0.6215*t - 11.37*math.pow(v, 0.16) + 0.3965*t*math.pow(v, 0.16) return int(round(windchill, 0))
[ "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...
[]
927
Write a function to check whether the given month number contains 30 days or not.
def multiply_elements(test_tup): res = tuple(i * j for i, j in zip(test_tup, test_tup[1:])) return (res)
[ "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" ]
[]
687
Write a function to convert camel case string to snake case string by using regex.
def Convert(string): li = list(string.split(" ")) return li
[ "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" ]
[]
670
Write a function to find length of the string.
import cmath def len_complex(a,b): cn=complex(a,b) length=abs(cn) return length
[ "assert find_Index(2) == 4", "assert find_Index(3) == 14", "assert find_Index(4) == 45" ]
[]
860
Write a function to find the nth delannoy number.
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 _sum([1, 2, 3]) == 6", "assert _sum([15, 12, 13, 10]) == 50", "assert _sum([0, 1, 2]) == 3" ]
[]
743
Write a function to check if a triangle of positive area is possible with the given angles.
def sorted_models(models): sorted_models = sorted(models, key = lambda x: x['color']) return sorted_models
[ "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]" ]
[]
896
Write a function to count the frequency of consecutive duplicate elements in a given list of numbers.
def length_Of_Last_Word(a): l = 0 x = a.strip() for i in range(len(x)): if x[i] == " ": l = 0 else: l += 1 return l
[ "assert n_common_words(\"python is a programming language\",1)==[('python', 1)]", "assert n_common_words(\"python is a programming language\",1)==[('python', 1)]", "assert n_common_words(\"python is a programming language\",5)==[('python', 1),('is', 1), ('a', 1), ('programming', 1), ('language', 1)]" ]
[]
834
Write a function to access dictionary key’s element by index.
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 roman_to_int('MMMCMLXXXVI')==3986", "assert roman_to_int('MMMM')==4000", "assert roman_to_int('C')==100" ]
[]
913
Write a python function to check whether the given string is made up of two alternating characters or not.
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_coordinates((3, 4)) == [[2, 3], [2, 4], [2, 5], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5]]", "assert get_coordinates((4, 5)) ==[[3, 4], [3, 5], [3, 6], [4, 4], [4, 5], [4, 6], [5, 4], [5, 5], [5, 6]]", "assert get_coordinates((5, 6)) == [[4, 5], [4, 6], [4, 7], [5, 5], [5, 6], [5, 7], [6, 5], [...
[]
627
Write a function to caluclate the area of a tetrahedron.
def is_upper(string): return (string.upper())
[ "assert add_tuple([5, 6, 7], (9, 10)) == [5, 6, 7, 9, 10]", "assert add_tuple([6, 7, 8], (10, 11)) == [6, 7, 8, 10, 11]", "assert add_tuple([7, 8, 9], (11, 12)) == [7, 8, 9, 11, 12]" ]
[]
879
Write a function to find out the second most repeated (or frequent) string in the given sequence.
import math def lateralsurface_cone(r,h): l = math.sqrt(r * r + h * h) LSA = math.pi * r * l return LSA
[ "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-...
[]
682
Write a python function to calculate the sum of the numbers in a list between the indices of a specified range.
def sum_column(list1, C): result = sum(row[C] for row in list1) return result
[ "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" ]
[]
626
Write a python function to find the sum of xor of all pairs of numbers in the given array.
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 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" ]
[]
754
Write a function to find numbers divisible by m or n from a list of numbers using lambda function.
import re def remove_parenthesis(items): for item in items: return (re.sub(r" ?\([^)]+\)", "", item))
[ "assert check(\"SEEquoiaL\") == 'accepted'", "assert check('program') == \"not accepted\"", "assert check('fine') == \"not accepted\"" ]
[]
800
Write a python function to find the sum of non-repeated elements in a given array.
import re def occurance_substring(text,pattern): for match in re.finditer(pattern, text): s = match.start() e = match.end() return (text[s:e], s, e)
[ "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',...
[]
703
Write a function to find numbers divisible by m and n from a list of numbers using lambda function.
def remove_empty(tuple1): #L = [(), (), ('',), ('a', 'b'), ('a', 'b', 'c'), ('d')] tuple1 = [t for t in tuple1 if t] return tuple1
[ "assert equilibrium_index([1, 2, 3, 4, 1, 2, 3]) == 3", "assert equilibrium_index([-7, 1, 5, 2, -4, 3, 0]) == 3", "assert equilibrium_index([1, 2, 3]) == -1" ]
[]
716
Write a function to find the number which occurs for odd number of times in the given array.
def count_Unset_Bits(n) : cnt = 0; for i in range(1,n + 1) : temp = i; while (temp) : if (temp % 2 == 0) : cnt += 1; temp = temp // 2; return cnt;
[ "assert 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] " ]
[]
693
Write a function to count the elements in a list until an element is a tuple.
import re def text_match(text): patterns = 'a.*?b$' if re.search(patterns, text): return ('Found a match!') else: return ('Not matched!')
[ "assert smallest_Divisor(10) == 2", "assert smallest_Divisor(25) == 5", "assert smallest_Divisor(31) == 31" ]
[]
635
Write a function to substract the elements of the given nested tuples.
def profit_amount(actual_cost,sale_amount): if(actual_cost > sale_amount): amount = actual_cost - sale_amount return amount else: return None
[ "assert sum_of_odd_Factors(30) == 24", "assert sum_of_odd_Factors(18) == 13", "assert sum_of_odd_Factors(2) == 1" ]
[]
805
Write a python function to find the smallest prime divisor of a number.
def str_to_tuple(test_str): res = tuple(map(int, test_str.split(', '))) return (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" ]
[]
664
Write a python function to check whether the two given strings are isomorphic to each other or not.
from collections import defaultdict def get_unique(test_list): res = defaultdict(list) for sub in test_list: res[sub[1]].append(sub[0]) res = dict(res) res_dict = dict() for key in res: res_dict[key] = len(list(set(res[key]))) return (str(res_dict))
[ "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" ]
[]
885
Write a python function to find the cube sum of first n odd natural numbers.
def sort_String(str) : str = ''.join(sorted(str)) return (str)
[ "assert check_expression(\"{()}[{}]\") == True", "assert check_expression(\"{()}[{]\") == False", "assert check_expression(\"{()}[{}][]({})\") == True" ]
[]
762
Write a python function to find sum of odd factors of a number.
def remove_length(test_str, K): temp = test_str.split() res = [ele for ele in temp if len(ele) != K] res = ' '.join(res) return (res)
[ "assert area_tetrahedron(3)==15.588457268119894", "assert area_tetrahedron(20)==692.8203230275509", "assert area_tetrahedron(10)==173.20508075688772" ]
[]
866
Write a python function to find the sum of all odd natural numbers within the range l and r.
def second_smallest(numbers): if (len(numbers)<2): return if ((len(numbers)==2) and (numbers[0] == numbers[1]) ): return dup_items = set() uniq_items = [] for x in numbers: if x not in dup_items: uniq_items.append(x) dup_items.add(x) uniq_items.sort() return uniq_...
[ "assert sum_in_Range(2,5) == 8", "assert sum_in_Range(5,7) == 12", "assert sum_in_Range(7,13) == 40" ]
[]
917
Write a function to count the same pair in two given lists using map 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 odd_Num_Sum(2) == 82", "assert odd_Num_Sum(3) == 707", "assert odd_Num_Sum(4) == 3108" ]
[]
780
Write a function to calculate wind chill index.
def is_abundant(n): fctrsum = sum([fctr for fctr in range(1, n) if n % fctr == 0]) return fctrsum > n
[ "assert is_Word_Present(\"machine learning\",\"machine\") == True", "assert is_Word_Present(\"easy\",\"fun\") == False", "assert is_Word_Present(\"python language\",\"code\") == False" ]
[]
852
Write a function to check whether the given amount has no profit and no loss
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 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]" ]
[]
948
Write a function to locate the left insertion point for a specified value in sorted order.
def smallest_multiple(n): if (n<=2): return n i = n * 2 factors = [number for number in range(n, 1, -1) if number * 2 > n] while True: for a in factors: if i % a != 0: i += n break if (a == factors[-1] and i % a == 0): ...
[ "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...
[]
725
Write a python function to remove the k'th element from a given list.
def rectangle_perimeter(l,b): perimeter=2*(l+b) return perimeter
[ "assert access_key({'physics': 80, 'math': 90, 'chemistry': 86},0)== 'physics'", "assert access_key({'python':10, 'java': 20, 'C++':30},2)== 'C++'", "assert access_key({'program':15,'computer':45},1)== 'computer'" ]
[]
669
Write a python function to count the number of distinct power of prime factor of given number.
import math def count_Divisors(n) : count = 0 for i in range(1, (int)(math.sqrt(n)) + 2) : if (n % i == 0) : if( n // i == i) : count = count + 1 else : count = count + 2 if (count % 2 == 0) : return ("Even") else...
[ "assert second_frequent(['aaa','bbb','ccc','bbb','aaa','aaa']) == 'bbb'", "assert second_frequent(['abc','bcd','abc','bcd','bcd','bcd']) == 'abc'", "assert second_frequent(['cdma','gsm','hspa','gsm','cdma','cdma']) == 'gsm'" ]
[]
660
Write a function to find n-th rencontres number.
def max_sum_of_three_consecutive(arr, n): sum = [0 for k in range(n)] if n >= 1: sum[0] = arr[0] if n >= 2: sum[1] = arr[0] + arr[1] if n > 2: sum[2] = max(sum[1], max(arr[1] + arr[2], arr[0] + arr[2])) for i in range(3, n): sum[i] = max(max(sum[i-1], sum[i-2] + arr[i]), arr[i] + arr[i-1]...
[ "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]" ]
[]
739
Write a function to convert camel case string to snake case string.
def sum_list(lst1,lst2): res_list = [lst1[i] + lst2[i] for i in range(len(lst1))] return res_list
[ "assert sort_numeric_strings( ['4','12','45','7','0','100','200','-12','-500'])==[-500, -12, 0, 4, 7, 12, 45, 100, 200]", "assert sort_numeric_strings(['2','3','8','4','7','9','8','2','6','5','1','6','1','2','3','4','6','9','1','2'])==[1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8, 9, 9]", "assert sort_n...
[]
878
Write a function to caluclate arc length of an angle.
def count_Fac(n): m = n count = 0 i = 2 while((i * i) <= m): total = 0 while (n % i == 0): n /= i total += 1 temp = 0 j = 1 while((temp + j) <= total): temp += j count += 1 j += 1 ...
[ "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 " ]
[]
747
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.
import re def remove_extra_char(text1): pattern = re.compile('[\W_]+') return (pattern.sub('', text1))
[ "assert largest_subset([ 1, 3, 6, 13, 17, 18 ], 6) == 4", "assert largest_subset([10, 5, 3, 15, 20], 5) == 3", "assert largest_subset([18, 1, 3, 6, 13, 17], 6) == 4" ]
[]
602
Write a function to count occurrence of a character in a string.
def validity_triangle(a,b,c): total = a + b + c if total == 180: return True else: return False
[ "assert check_valid((True, True, True, True) ) == True", "assert check_valid((True, False, True, True) ) == False", "assert check_valid((True, True, True, True) ) == True" ]
[]
807
Write a function to find the product of it’s kth index in the given tuples.
import bisect def left_insertion(a, x): i = bisect.bisect_left(a, x) return i
[ "assert rencontres_number(7, 2) == 924", "assert rencontres_number(3, 0) == 2", "assert rencontres_number(3, 1) == 3" ]
[]
674
Write a python function to check if roots of a quadratic equation are reciprocal of each other or not.
def tuple_to_set(t): s = set(t) return (s)
[ "assert are_Rotations(\"abc\",\"cba\") == False", "assert are_Rotations(\"abcd\",\"cdba\") == False", "assert are_Rotations(\"abacd\",\"cdaba\") == True" ]
[]
799
Write a function to check a decimal with a precision of 2.
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 count_char(\"Python\",'o')==1", "assert count_char(\"little\",'t')==2", "assert count_char(\"assert\",'s')==2" ]
[]
690
Write a function to find palindromes in a given list of strings using lambda function.
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 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'" ]
[]
904
Write a function to find the n-th power of individual elements in a list using lambda function.
def Average(lst): return sum(lst) / len(lst)
[ "assert concatenate_nested((3, 4), (5, 6)) == (3, 4, 5, 6)", "assert concatenate_nested((1, 2), (3, 4)) == (1, 2, 3, 4)", "assert concatenate_nested((4, 5), (6, 8)) == (4, 5, 6, 8)" ]
[]
942
Write a function to combine two given sorted lists using heapq module.
def arc_length(d,a): pi=22/7 if a >= 360: return None arclength = (pi*d) * (a/360) return arclength
[ "assert increasing_trend([1,2,3,4]) == True", "assert increasing_trend([4,3,2,1]) == False", "assert increasing_trend([0,1,4,9]) == True" ]
[]
794
Write a function to find a path with the maximum average over all existing paths for the given square matrix of size n*n.
import re regex = '^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w{2,3}$' def check_email(email): if(re.search(regex,email)): return ("Valid Email") else: return ("Invalid Email")
[ "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" ]
[]
842
Write a function to remove multiple spaces in a string by using regex.
class Node: def __init__(self, data): self.data = data self.left = None self.right = None def max_height(node): if node is None: return 0 ; else : left_height = max_height(node.left) right_height = max_height(node.right) if (left_height > right_height): return left_height+1 ...
[ "assert chunk_tuples((10, 4, 5, 6, 7, 6, 8, 3, 4), 3) == [(10, 4, 5), (6, 7, 6), (8, 3, 4)]", "assert chunk_tuples((1, 2, 3, 4, 5, 6, 7, 8, 9), 2) == [(1, 2), (3, 4), (5, 6), (7, 8), (9,)]", "assert chunk_tuples((11, 14, 16, 17, 19, 21, 22, 25), 4) == [(11, 14, 16, 17), (19, 21, 22, 25)]" ]
[]
846
Write a function to locate the right insertion point for a specified value in sorted order.
from collections import OrderedDict def remove_duplicate(string): result = ' '.join(OrderedDict((w,w) for w in string.split()).keys()) return result
[ "assert reverse_list_lists([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]])==[[4, 3, 2, 1], [8, 7, 6, 5], [12, 11, 10, 9], [16, 15, 14, 13]]", "assert reverse_list_lists([[1,2],[2,3],[3,4]])==[[2,1],[3,2],[4,3]]", "assert reverse_list_lists([[10,20],[30,40]])==[[20,10],[40,30]]" ]
[]
930
Write a python function to find nth bell number.
def max_sum_list(lists): return max(lists, key=sum)
[ "assert bell_Number(2) == 2", "assert bell_Number(3) == 5", "assert bell_Number(4) == 15" ]
[]
604
Write a python function to find maximum possible value for the given periodic function.
def max_run_uppercase(test_str): cnt = 0 res = 0 for idx in range(0, len(test_str)): if test_str[idx].isupper(): cnt += 1 else: res = cnt cnt = 0 if test_str[len(test_str) - 1].isupper(): res = cnt return (res)
[ "assert find_literals('The quick brown fox jumps over the lazy dog.', 'fox') == ('fox', 16, 19)", "assert find_literals('Its been a very crazy procedure right', 'crazy') == ('crazy', 16, 21)", "assert find_literals('Hardest choices required strongest will', 'will') == ('will', 35, 39)" ]
[]
680
Write a function to count coin change.
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 sum_nums(2,10,11,20)==20", "assert sum_nums(15,17,1,10)==32", "assert sum_nums(10,15,5,30)==20" ]
[]
620
Write a function to count number of unique lists within a list.
def is_Word_Present(sentence,word): s = sentence.split(" ") for i in s: if (i == word): return True return False
[ "assert find_platform([900, 940, 950, 1100, 1500, 1800],[910, 1200, 1120, 1130, 1900, 2000],6)==3", "assert find_platform([100,200,300,400],[700,800,900,1000],4)==4", "assert find_platform([5,6,7,8],[4,3,2,1],4)==1" ]
[]
839
Write a function to count those characters which have vowels as their neighbors in the given string.
def ntimes_list(nums,n): result = map(lambda x:n*x, nums) return list(result)
[ "assert first_Digit(5) == 1", "assert first_Digit(10) == 3", "assert first_Digit(7) == 5" ]
[]
707
Write a function to find ln, m lobb number.
def geometric_sum(n): if n < 0: return 0 else: return 1 / (pow(2, n)) + geometric_sum(n - 1)
[ "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" ]
[]
724
Write a python function to check whether the given two numbers have same number of digits or not.
def min_difference(test_list): temp = [abs(b - a) for a, b in test_list] res = min(temp) return (res)
[ "assert check_monthnumber_number(6)==True", "assert check_monthnumber_number(2)==False", "assert check_monthnumber_number(12)==False" ]
[]
907
Write a function to zip two given lists of lists.
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 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], ...
[]
943
Write a function to find the largest subset where each pair is divisible.
def get_ludic(n): ludics = [] for i in range(1, n + 1): ludics.append(i) index = 1 while(index != len(ludics)): first_ludic = ludics[index] remove_index = index + first_ludic while(remove_index < len(ludics)): ludics.remove(ludics[remove_index]) remove_index = remove_index + first_ludic - 1 ...
[ "assert Sum(60) == 10", "assert Sum(39) == 16", "assert Sum(40) == 7" ]
[]
826
Write a function to calculate the sum of all digits of the base to the specified power.
def convert(list): s = [str(i) for i in list] res = int("".join(s)) return (res)
[ "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'" ]
[]
748
Write a function that matches a string that has an a followed by zero or one 'b'.
from math import tan, pi def perimeter_polygon(s,l): perimeter = s*l return perimeter
[ "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" ]
[]
824
Write a function to check if the given expression is balanced or not.
def remove_duplic_list(l): temp = [] for x in l: if x not in temp: temp.append(x) return temp
[ "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): ...
[]
831
Write a function to find the area of a rombus.
def check(string): if len(set(string).intersection("AEIOUaeiou"))>=5: return ('accepted') else: return ("not accepted")
[ "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)" ]
[]
634
Write a function to extract all the adjacent coordinates of the given coordinate tuple.
MAX=1000; def replace_spaces(string): string=string.strip() i=len(string) space_count=string.count(' ') new_length = i + space_count*2 if new_length > MAX: return -1 index = new_length-1 string=list(string) for f in range(i-2, new_length-2): string.append('0') for j in range(i-1, 0...
[ "assert left_rotate(\"python\",2) == \"thonpy\" ", "assert left_rotate(\"bigdata\",3 ) == \"databig\" ", "assert left_rotate(\"hadoop\",1 ) == \"adooph\" " ]
[]
759
Write a function to rearrange positive and negative numbers in a given array using lambda function.
def rombus_perimeter(a): perimeter=4*a return perimeter
[ "assert sort_String(\"cba\") == \"abc\"", "assert sort_String(\"data\") == \"aadt\"", "assert sort_String(\"zxy\") == \"xyz\"" ]
[]
697
Write a function to flatten the given tuple matrix into the tuple list with each tuple representing each column.
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 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" ]
[]
607
Write a python function to find the average of a list.
def find_longest_conseq_subseq(arr, n): ans = 0 count = 0 arr.sort() v = [] v.append(arr[0]) for i in range(1, n): if (arr[i] != arr[i - 1]): v.append(arr[i]) for i in range(len(v)): if (i > 0 and v[i] == v[i - 1] + 1): count += 1 else: count = 1 ans = max(ans, count) ...
[ "assert replace_specialchar('Python language, Programming language.')==('Python:language::Programming:language:')", "assert replace_specialchar('a b c,d e f')==('a:b:c:d:e:f')", "assert replace_specialchar('ram reshma,ram rahim')==('ram:reshma:ram:rahim')" ]
[]
615
Write a python function to find the sum of fourth power of first n even natural numbers.
def sort_sublists(list1): list1.sort() list1.sort(key=len) return list1
[ "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'" ]
[]
791
Write a function to check if the given array represents min heap or not.
def check_none(test_tup): res = any(map(lambda ele: ele is None, test_tup)) return (res)
[ "assert ntimes_list([1, 2, 3, 4, 5, 6, 7],3)==[3, 6, 9, 12, 15, 18, 21]", "assert ntimes_list([1, 2, 3, 4, 5, 6, 7],4)==[4, 8, 12, 16, 20, 24, 28]", "assert ntimes_list([1, 2, 3, 4, 5, 6, 7],10)==[10, 20, 30, 40, 50, 60, 70]" ]
[]
967
Write a function to put spaces between words starting with capital letters in a given string by 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 convert([1,2,3]) == 123", "assert convert([4,5,6]) == 456", "assert convert([7,8,9]) == 789" ]
[]
665
Write a function to split the given string at uppercase letters by using regex.
def listify_list(list1): result = list(map(list,list1)) return result
[ "assert tuple_str_int(\"(7, 8, 9)\") == (7, 8, 9)", "assert tuple_str_int(\"(1, 2, 3)\") == (1, 2, 3)", "assert tuple_str_int(\"(4, 5, 6)\") == (4, 5, 6)" ]
[]
636
Write a python function to find the length of the last word in a given string.
def pair_OR_Sum(arr,n) : ans = 0 for i in range(0,n) : for j in range(i + 1,n) : ans = ans + (arr[i] ^ arr[j]) return ans
[ "assert check_str(\"annie\") == 'Valid'", "assert check_str(\"dawood\") == 'Invalid'", "assert check_str(\"Else\") == 'Valid'" ]
[]
699
Write a python function to set the right most unset bit.
def multiply_list(items): tot = 1 for x in items: tot *= x return tot
[ "assert remove_nested((1, 5, 7, (4, 6), 10)) == (1, 5, 7, 10)", "assert remove_nested((2, 6, 8, (5, 7), 11)) == (2, 6, 8, 11)", "assert remove_nested((3, 7, 9, (6, 8), 12)) == (3, 7, 9, 12)" ]
[]
792
Write a python function to find the sum of all odd length subarrays.
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 number_ctr('program2bedone') == 1", "assert number_ctr('3wonders') ==1", "assert number_ctr('123') == 3" ]
[]
922
Write a function to find the nth jacobsthal number.
import re def capital_words_spaces(str1): return re.sub(r"(\w)([A-Z])", r"\1 \2", str1)
[ "assert find_first_occurrence([2, 5, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 1", "assert find_first_occurrence([2, 3, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 2", "assert find_first_occurrence([2, 4, 1, 5, 6, 6, 8, 9, 9, 9], 6) == 4" ]
[]
694
Write a function to iterate over elements repeating each as many times as its count.
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 discriminant_value(4,8,2)==(\"Two solutions\",32)", "assert discriminant_value(5,7,9)==(\"no real solution\",-131)", "assert discriminant_value(0,0,9)==(\"one solution\",0)" ]
[]
671
Write a function to concatenate the given two tuples to a nested tuple.
import math def is_polite(n): n = n + 1 return (int)(n+(math.log((n + math.log(n, 2)), 2)))
[ "assert sorted_models([{'make':'Nokia', 'model':216, 'color':'Black'}, {'make':'Mi Max', 'model':2, 'color':'Gold'}, {'make':'Samsung', 'model': 7, 'color':'Blue'}])==[{'make': 'Nokia', 'model': 216, 'color': 'Black'}, {'make': 'Samsung', 'model': 7, 'color': 'Blue'}, {'make': 'Mi Max', 'model': 2, 'color': 'Gold'}...
[]
735
Write a function to return true if the password is valid.
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 No_of_cubes(2,1) == 8", "assert No_of_cubes(5,2) == 64", "assert No_of_cubes(1,1) == 1" ]
[]
933
Write a python function to find the first repeated character in a given string.
import re def text_match_zero_one(text): patterns = 'ab?' if re.search(patterns, text): return 'Found a match!' else: return('Not matched!')
[ "assert dealnnoy_num(3, 4) == 129", "assert dealnnoy_num(3, 3) == 63", "assert dealnnoy_num(4, 5) == 681" ]
[]
646
Write a python function to accept the strings which contains all vowels.
def mul_list(nums1,nums2): result = map(lambda x, y: x * y, nums1, nums2) return list(result)
[ "assert floor_Min(10,20,30) == 15", "assert floor_Min(1,2,1) == 0", "assert floor_Min(11,10,9) == 9" ]
[]
882
Write a function to convert rgb color to hsv color.
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 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)" ]
[]
771
Write a function to check if the given tuple contains only k elements.
def get_noOfways(n): if (n == 0): return 0; if (n == 1): return 1; return get_noOfways(n - 1) + get_noOfways(n - 2);
[ "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" ]
[]
700
Write a python function to find the minimum difference between any two elements in a given array.
import heapq as hq def raw_heap(rawheap): hq.heapify(rawheap) return rawheap
[ "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']...
[]
863
Write a python function to copy a list from a singleton tuple.
def floor_Min(A,B,N): x = max(B - 1,N) return (A*x) // B
[ "assert get_inv_count([1, 20, 6, 4, 5], 5) == 5", "assert get_inv_count([8, 4, 2, 1], 4) == 6", "assert get_inv_count([3, 1, 2], 3) == 2" ]
[]
938
Write a python function to count the number of pairs whose sum is equal to ‘sum’.
def Sum_of_Inverse_Divisors(N,Sum): ans = float(Sum)*1.0 /float(N); return round(ans,2);
[ "assert zip_list([[1, 3], [5, 7], [9, 11]] ,[[2, 4], [6, 8], [10, 12, 14]] )==[[1, 3, 2, 4], [5, 7, 6, 8], [9, 11, 10, 12, 14]]", "assert zip_list([[1, 2], [3, 4], [5, 6]] ,[[7, 8], [9, 10], [11, 12]] )==[[1, 2, 7, 8], [3, 4, 9, 10], [5, 6, 11, 12]]", "assert zip_list([['a','b'],['c','d']] , [['e','f'],['g','h'...
[]
925
Write a python function to find the slope of a line.
def find_Min_Diff(arr,n): arr = sorted(arr) diff = 10**20 for i in range(n-1): if arr[i+1] - arr[i] < diff: diff = arr[i+1] - arr[i] return diff
[ "assert sort_sublists([[2], [0], [1, 3], [0, 7], [9, 11], [13, 15, 17]])==[[0], [2], [0, 7], [1, 3], [9, 11], [13, 15, 17]]", "assert sort_sublists([[1], [2, 3], [4, 5, 6], [7], [10, 11]])==[[1], [7], [2, 3], [10, 11], [4, 5, 6]]", "assert sort_sublists([[\"python\"],[\"java\",\"C\",\"C++\"],[\"DBMS\"],[\"SQL\"...
[]
969
Write a function to remove everything except alphanumeric characters from the given string by using regex.
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 arc_length(9,45)==3.5357142857142856", "assert arc_length(9,480)==None", "assert arc_length(5,270)==11.785714285714285" ]
[]
774
Write a python function to remove negative numbers from a list.
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 split_upperstring(\"PythonProgramLanguage\")==['Python','Program','Language']", "assert split_upperstring(\"PythonProgram\")==['Python','Program']", "assert split_upperstring(\"ProgrammingLanguage\")==['Programming','Language']" ]
[]
912
Write a function to check if each element of second tuple is smaller than its corresponding index in first tuple.
def check_monthnumber_number(monthnum3): if(monthnum3==4 or monthnum3==6 or monthnum3==9 or monthnum3==11): return True else: return False
[ "assert sector_area(4,45)==6.285714285714286", "assert sector_area(9,45)==31.82142857142857", "assert sector_area(9,360)==None" ]
[]
782
Write a function to sort a list of dictionaries using lambda function.
def sum_num(numbers): total = 0 for x in numbers: total += x return total/len(numbers)
[ "assert count_Set_Bits(16) == 33", "assert count_Set_Bits(2) == 2", "assert count_Set_Bits(14) == 28" ]
[]
945
Write a function to add two integers. however, if the sum is between the given range it will return 20.
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 move_num('I1love143you55three3000thousand') == 'Iloveyouthreethousand1143553000'", "assert move_num('Avengers124Assemble') == 'AvengersAssemble124'", "assert move_num('Its11our12path13to14see15things16do17things') == 'Itsourpathtoseethingsdothings11121314151617'" ]
[]
641
Write a python function to count the number of lists in a given number of lists.
def Check_Solution(a,b,c): if b == 0: return ("Yes") else: return ("No")
[ "assert text_match_three(\"ac\")==('Not matched!')", "assert text_match_three(\"dc\")==('Not matched!')", "assert text_match_three(\"abbbba\")==('Found a match!')" ]
[]
798
Write a function to print n-times a list using map function.
from collections import defaultdict def grouping_dictionary(l): d = defaultdict(list) for k, v in l: d[k].append(v) return d
[ "assert cube_Sum(2) == 28", "assert cube_Sum(3) == 153", "assert cube_Sum(4) == 496" ]
[]
698
Write a function to round up a number to specific digits.
def is_odd(n) : if (n^1 == n-1) : return True; else : return False;
[ "assert is_Perfect_Square(10) == False", "assert is_Perfect_Square(36) == True", "assert is_Perfect_Square(14) == False" ]
[]
658
Write a python function to count occurences of a character in a repeated string.
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 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" ]
[]
972
Write a function to find the longest chain which can be formed from the given set of pairs.
def fibonacci(n): if n == 1 or n == 2: return 1 else: return (fibonacci(n - 1) + (fibonacci(n - 2)))
[ "assert word_len(\"program\") == False", "assert word_len(\"solution\") == True", "assert word_len(\"data\") == True" ]
[]
688
Write a function to remove the nested record from the given 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 count_tuplex((2, 4, 5, 6, 2, 3, 4, 4, 7),4)==3", "assert count_tuplex((2, 4, 5, 6, 2, 3, 4, 4, 7),2)==2", "assert count_tuplex((2, 4, 7, 7, 7, 3, 4, 4, 7),7)==4" ]
[]
611
Write a function to access the initial and last data of the given tuple record.
def noprofit_noloss(actual_cost,sale_amount): if(sale_amount == actual_cost): return True else: return False
[ "assert count_vowels('bestinstareels') == 7", "assert count_vowels('partofthejourneyistheend') == 12", "assert count_vowels('amazonprime') == 5" ]
[]
966
Write a python function to remove even numbers from a given list.
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 maximum_segments(7, 5, 2, 5) == 2", "assert maximum_segments(17, 2, 1, 3) == 17", "assert maximum_segments(18, 16, 3, 6) == 6" ]
[]
717
Write a function that matches a string that has an 'a' followed by anything, ending in 'b'.
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 lower_ctr('abc') == 3", "assert lower_ctr('string') == 6", "assert lower_ctr('Python') == 5" ]
[]
957
Write a python function to get the last element of each sublist.
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 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 " ]
[]
666
Write a function that matches a string that has an 'a' followed by anything, ending in 'b' by using regex.
def zip_list(list1,list2): result = list(map(list.__add__, list1, list2)) return result
[ "assert divisible_by_digits(1,22)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]", "assert divisible_by_digits(1,15)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15]", "assert divisible_by_digits(20,25)==[22, 24]" ]
[]
715
Write a function to convert the given tuple to a key-value dictionary using adjacent elements.
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 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" ]
[]
618
Write a python function to replace multiple occurence of character by single.
def extract_unique(test_dict): res = list(sorted({ele for val in test_dict.values() for ele in val})) return res
[ "assert check_monthnum_number(2)==True", "assert check_monthnum_number(1)==False", "assert check_monthnum_number(3)==False" ]
[]
End of preview. Expand in Data Studio

edition_0465_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