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
856
Write a python function to sort 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 find_Digits(7) == 4", "assert find_Digits(5) == 3", "assert find_Digits(4) == 2" ]
[]
892
Write a function to find the list in a list of lists whose sum of elements is the highest.
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 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]" ]
[]
963
Write a function to find the nth delannoy number.
def tuple_str_int(test_str): res = tuple(int(num) for num in test_str.replace('(', '').replace(')', '').replace('...', '').split(', ')) return (res)
[ "assert is_Word_Present(\"machine learning\",\"machine\") == True", "assert is_Word_Present(\"easy\",\"fun\") == False", "assert is_Word_Present(\"python language\",\"code\") == False" ]
[]
958
Write a function to check if the given tuples contain the k or not.
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_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], [...
[]
955
Write a python function to find the kth element in an array containing odd elements first and then even elements.
def ntimes_list(nums,n): result = map(lambda x:n*x, nums) return list(result)
[ "assert sector_area(4,45)==6.285714285714286", "assert sector_area(9,45)==31.82142857142857", "assert sector_area(9,360)==None" ]
root = Node(1) root.left = Node(2) root.right = Node(3) root.left.left = Node(4) root.left.right = Node(5) root1 = Node(1); root1.left = Node(2); root1.right = Node(3); root1.left.left = Node(4); root1.right.left = Node(5); root1.right.right = Node(6); root1.right.right.right= Node(7); ro...
[]
956
Write a function to find the greatest common divisor (gcd) of two integers by using recursion.
def reverse_list_lists(lists): for l in lists: l.sort(reverse = True) return lists
[ "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 " ]
[]
650
Write a python function to find sum of inverse of divisors.
def Sum_of_Inverse_Divisors(N,Sum): ans = float(Sum)*1.0 /float(N); return round(ans,2);
[ "assert chinese_zodiac(1997)==('Ox')", "assert chinese_zodiac(1998)==('Tiger')", "assert chinese_zodiac(1994)==('Dog')" ]
[]
745
Write a function to count coin change.
import re def replace(string, char): pattern = char + '{2,}' string = re.sub(pattern, char, string) return string
[ "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'" ]
[]
850
Write a python function to count number of vowels in the string.
import re def text_match_three(text): patterns = 'ab{3}?' if re.search(patterns, text): return 'Found a match!' else: return('Not matched!')
[ "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\"...
[]
762
Write a python function to find the slope of a line.
def tuple_to_dict(test_tup): res = dict(test_tup[idx : idx + 2] for idx in range(0, len(test_tup), 2)) return (res)
[ "assert lower_ctr('abc') == 3", "assert lower_ctr('string') == 6", "assert lower_ctr('Python') == 5" ]
[]
957
Write a function to iterate over all pairs of consecutive items in a given list.
def is_decimal(num): import re dnumre = re.compile(r"""^[0-9]+(\.[0-9]{1,2})?$""") result = dnumre.search(num) return bool(result)
[ "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...
[]
710
Write a function to check whether the given month name contains 31 days 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 check_str(\"annie\") == 'Valid'", "assert check_str(\"dawood\") == 'Invalid'", "assert check_str(\"Else\") == 'Valid'" ]
[]
737
Write a function to find n-th rencontres number.
def min_Jumps(a, b, d): temp = a a = min(a, b) b = max(temp, b) if (d >= b): return (d + b - 1) / b if (d == 0): return 0 if (d == a): return 1 else: return 2
[ "assert max_of_two(10,20)==20", "assert max_of_two(19,15)==19", "assert max_of_two(-10,-20)==-10" ]
[]
814
Write a python function to find the last position of an element in a sorted array.
def float_to_tuple(test_str): res = tuple(map(float, test_str.split(', '))) return (res)
[ "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" ]
[]
894
Write a function to join the tuples if they have similar initial elements.
def all_Characters_Same(s) : n = len(s) for i in range(1,n) : if s[i] != s[0] : return False return True
[ "assert get_key({1:'python',2:'java'})==[1,2]", "assert get_key({10:'red',20:'blue',30:'black'})==[10,20,30]", "assert get_key({27:'language',39:'java',44:'little'})==[27,39,44]" ]
[]
622
Write a function to caluclate the area of a tetrahedron.
def reverse_Array_Upto_K(input, k): return (input[k-1::-1] + input[k:])
[ "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" ]
[]
833
Write a function to check whether the given month number contains 28 days or not.
def check_monthnumber_number(monthnum3): if(monthnum3==4 or monthnum3==6 or monthnum3==9 or monthnum3==11): return True else: return False
[ "assert count_list([[1, 3], [5, 7], [9, 11], [13, 15, 17]]) == 4", "assert count_list([[1,2],[2,3],[4,5]]) == 3", "assert count_list([[1,0],[2,0]]) == 2" ]
[]
741
Write a python function to interchange first and last elements in a given list.
def chunk_tuples(test_tup, N): res = [test_tup[i : i + N] for i in range(0, len(test_tup), N)] return (res)
[ "assert merge_dictionaries({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" })=={'B': 'Black', 'R': 'Red', 'P': 'Pink', 'G': 'Green', 'W': 'White'}", "assert merge_dictionaries({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" },{ \"O\": \"Orange\", \"W\": \"White\", \...
[]
909
Write a python function to convert a string to a list.
def Diff(li1,li2): return (list(list(set(li1)-set(li2)) + list(set(li2)-set(li1))))
[ "assert Extract([[1, 2, 3], [4, 5], [6, 7, 8, 9]]) == [3, 5, 9]", "assert Extract([['x', 'y', 'z'], ['m'], ['a', 'b'], ['u', 'v']]) == ['z', 'm', 'b', 'v']", "assert Extract([[1, 2, 3], [4, 5]]) == [3, 5]" ]
[]
635
Write a function to add a dictionary to the tuple.
def left_rotate(s,d): tmp = s[d : ] + s[0 : d] return tmp
[ "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" ]
[]
672
Write a python function to find minimum number swaps required to make two binary strings equal.
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 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 function where a string will start with a specific number.
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 average_Even(2) == 2", "assert average_Even(4) == 3", "assert average_Even(100) == 51" ]
[]
937
Write a function to remove similar rows from the given tuple matrix.
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 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'}" ]
[]
691
Write a function to remove the parenthesis area in a string.
def str_to_tuple(test_str): res = tuple(map(int, test_str.split(', '))) return (res)
[ "assert max_sub_array_sum([-2, -3, 4, -1, -2, 1, 5, -3],8) == 5", "assert max_sub_array_sum([1, -2, 1, 1, -2, 1],6) == 2", "assert max_sub_array_sum([-1, -2, 3, 4, 5],5) == 3" ]
[]
811
Write a function to zip two given lists of lists.
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 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]" ]
[]
695
Write a function to group a sequence of key-value pairs into a dictionary of lists using collections module.
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_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...
[]
627
Write a python function to count number of cubes of size k in a cube of size n.
def parallelogram_perimeter(b,h): perimeter=2*(b*h) return perimeter
[ "assert wind_chill(120,35)==40", "assert wind_chill(40,70)==86", "assert wind_chill(10,100)==116" ]
[]
607
Write a function to combine two given sorted lists using heapq module.
def check_valid(test_tup): res = not any(map(lambda ele: not ele, test_tup)) return (res)
[ "assert is_polite(7) == 11", "assert is_polite(4) == 7", "assert is_polite(9) == 13" ]
[]
685
Write a function to move all the numbers in it to the given string.
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 int_to_roman(1)==(\"I\")", "assert int_to_roman(50)==(\"L\")", "assert int_to_roman(4)==(\"IV\")" ]
[]
705
Write a python function to check whether all the bits are within a given range or not.
def front_and_rear(test_tup): res = (test_tup[0], test_tup[-1]) return (res)
[ "assert rencontres_number(7, 2) == 924", "assert rencontres_number(3, 0) == 2", "assert rencontres_number(3, 1) == 3" ]
[]
823
Write a python function to count occurences of a character in a repeated string.
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 find_max_val(15, 10, 5) == 15", "assert find_max_val(187, 10, 5) == 185", "assert find_max_val(16, 11, 1) == 12" ]
[]
625
Write a function to find the n - cheap price items from a given dataset using heap queue algorithm.
from math import tan, pi def perimeter_polygon(s,l): perimeter = s*l return perimeter
[ "assert toggle_middle_bits(9) == 15", "assert toggle_middle_bits(10) == 12", "assert toggle_middle_bits(11) == 13" ]
[]
754
Write a function to count the most common character in a given string.
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 odd_Num_Sum(2) == 82", "assert odd_Num_Sum(3) == 707", "assert odd_Num_Sum(4) == 3108" ]
[]
884
Write a function to calculate the sum of all digits of the base to the specified power.
def sorted_models(models): sorted_models = sorted(models, key = lambda x: x['color']) return sorted_models
[ "assert convert([1,2,3]) == 123", "assert convert([4,5,6]) == 456", "assert convert([7,8,9]) == 789" ]
[]
624
Write a function to find the sum of first even and odd number of a given list.
def find_Extra(arr1,arr2,n) : for i in range(0, n) : if (arr1[i] != arr2[i]) : return i return n
[ "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" ]
[]
926
Write a function to find the maximum sum of subsequences of given array with no adjacent elements.
def is_odd(n) : if (n^1 == n-1) : return True; else : return False;
[ "assert min_of_two(10,20)==10", "assert min_of_two(19,15)==15", "assert min_of_two(-10,-20)==-20" ]
[]
900
Write a function to check for a number at the end of a string.
def merge(lst): return [list(ele) for ele in list(zip(*lst))]
[ "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" ]
[]
606
Write a python function to check whether the length of the word is even or not.
from itertools import combinations def find_combinations(test_list): res = [(b1 + a1, b2 + a2) for (a1, a2), (b1, b2) in combinations(test_list, 2)] return (res)
[ "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\"]" ]
[]
609
Write a function to locate the left insertion point for a specified value in sorted order.
import math def find_Index(n): x = math.sqrt(2 * math.pow(10,(n - 1))); return round(x);
[ "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)" ]
[]
941
Write a python function to left rotate the bits of a given number.
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 sum_Range_list([2, 1, 5, 6, 8, 3, 4, 9, 10, 11, 8, 12],8,10) == 29", "assert sum_Range_list([1,2,3,4,5],1,2) == 5", "assert sum_Range_list([1,0,1,2,5,6],4,5) == 11" ]
[]
802
Write a function to find the lateral surface area of a cone.
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 is_Isomorphic(\"paper\",\"title\") == True", "assert is_Isomorphic(\"ab\",\"ba\") == True", "assert is_Isomorphic(\"ab\",\"aa\") == False" ]
[]
874
Write a function to find the length of the longest sub-sequence such that elements in the subsequences are consecutive integers.
import re def num_position(text): for m in re.finditer("\d+", text): return m.start()
[ "assert alternate_elements([\"red\", \"black\", \"white\", \"green\", \"orange\"])==['red', 'white', 'orange']", "assert alternate_elements([2, 0, 3, 4, 0, 2, 8, 3, 4, 2])==[2, 3, 0, 8, 4]", "assert alternate_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1,3,5,7,9]" ]
[]
602
Write a function to count the same pair in two given lists using map function.
def is_nonagonal(n): return int(n * (7 * n - 5) / 2)
[ "assert rectangle_perimeter(10,20)==60", "assert rectangle_perimeter(10,5)==30", "assert rectangle_perimeter(4,2)==12" ]
[]
703
Write a function to check if each element of second tuple is smaller than its corresponding index in first tuple.
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 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] " ]
[]
819
Write a function to remove sublists from a given list of lists, which are outside a given range.
def increasing_trend(nums): if (sorted(nums)== nums): return True else: return False
[ "assert tuple_to_dict((1, 5, 7, 10, 13, 5)) == {1: 5, 7: 10, 13: 5}", "assert tuple_to_dict((1, 2, 3, 4, 5, 6)) == {1: 2, 3: 4, 5: 6}", "assert tuple_to_dict((7, 8, 9, 10, 11, 12)) == {7: 8, 9: 10, 11: 12}" ]
[]
970
Write a function to calculate the perimeter of a regular polygon.
def tuple_to_set(t): s = set(t) return (s)
[ "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...
[]
643
Write a function to find the minimum total path sum in the given triangle.
def power_base_sum(base, power): return sum([int(i) for i in str(pow(base, power))])
[ "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]" ]
[]
895
Write a python function to find the sum of all odd natural numbers within the range l and r.
def sort_sublists(list1): list1.sort() list1.sort(key=len) return list1
[ "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)" ]
[]
968
Write a python function to get the position of rightmost set bit.
def sorted_dict(dict1): sorted_dict = {x: sorted(y) for x, y in dict1.items()} return sorted_dict
[ "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}'" ]
[]
657
Write a python function to left rotate the string.
def geometric_sum(n): if n < 0: return 0 else: return 1 / (pow(2, n)) + geometric_sum(n - 1)
[ "assert find_Min_Sum([3,2,1],[2,1,3],3) == 0", "assert find_Min_Sum([1,2,3],[4,5,6],3) == 9", "assert find_Min_Sum([4,1,8,7],[2,3,6,5],4) == 6" ]
[]
855
Write a function to count the pairs of reverse strings in the given string list.
def rearrange_numbs(array_nums): result = sorted(array_nums, key = lambda i: 0 if i == 0 else -1 / i) return result
[ "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...
[]
721
Write a function to check if the given array represents min heap or not.
def average_tuple(nums): result = [sum(x) / len(x) for x in zip(*nums)] return result
[ "assert add_dict_to_tuple((4, 5, 6), {\"MSAM\" : 1, \"is\" : 2, \"best\" : 3} ) == (4, 5, 6, {'MSAM': 1, 'is': 2, 'best': 3})", "assert add_dict_to_tuple((1, 2, 3), {\"UTS\" : 2, \"is\" : 3, \"Worst\" : 4} ) == (1, 2, 3, {'UTS': 2, 'is': 3, 'Worst': 4})", "assert add_dict_to_tuple((8, 9, 10), {\"POS\" : 3, \"is...
[]
879
Write a function to count number of unique lists within a list.
def even_num(x): if x%2==0: return True else: return False
[ "assert sum_Square(25) == True", "assert sum_Square(24) == False", "assert sum_Square(17) == True" ]
[]
764
Write a function to extract unique values from the given dictionary values.
def len_log(list1): min=len(list1[0]) for i in list1: if len(i)<min: min=len(i) return min
[ "assert roman_to_int('MMMCMLXXXVI')==3986", "assert roman_to_int('MMMM')==4000", "assert roman_to_int('C')==100" ]
[]
885
Write a function to check whether the given amount has no profit and no loss
def concatenate_nested(test_tup1, test_tup2): res = test_tup1 + test_tup2 return (res)
[ "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" ]
[]
729
Write a python function to calculate the product of all the numbers of a given tuple.
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 nCr_mod_p(10, 2, 13) == 6", "assert nCr_mod_p(11, 3, 14) == 11", "assert nCr_mod_p(18, 14, 19) == 1" ]
[]
799
Write a function to find out, if the given number is abundant.
def jacobsthal_num(n): dp = [0] * (n + 1) dp[0] = 0 dp[1] = 1 for i in range(2, n+1): dp[i] = dp[i - 1] + 2 * dp[i - 2] return dp[n]
[ "assert Average([15, 9, 55, 41, 35, 20, 62, 49]) == 35.75", "assert Average([4, 5, 1, 2, 9, 7, 10, 8]) == 5.75", "assert Average([1,2,3]) == 2" ]
[]
913
Write a function to find maximum run of uppercase characters in the given string.
def check_tuples(test_tuple, K): res = all(ele in K for ele in test_tuple) return (res)
[ "assert increasing_trend([1,2,3,4]) == True", "assert increasing_trend([4,3,2,1]) == False", "assert increasing_trend([0,1,4,9]) == True" ]
[]
614
Write a python function to check whether the given two numbers have same number of digits or not.
def palindrome_lambda(texts): result = list(filter(lambda x: (x == "".join(reversed(x))), texts)) return result
[ "assert heap_sort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]", "assert heap_sort([25, 35, 22, 85, 14, 65, 75, 25, 58])==[14, 22, 25, 25, 35, 58, 65, 75, 85]", "assert heap_sort( [7, 1, 9, 5])==[1,5,7,9]" ]
[]
887
Write a function to find the area of a trapezium.
def find_Sum(arr,n): arr.sort() sum = arr[0] for i in range(0,n-1): if (arr[i] != arr[i+1]): sum = sum + arr[i+1] return sum
[ "assert check_alphanumeric(\"dawood@\") == 'Discard'", "assert check_alphanumeric(\"skdmsam326\") == 'Accept'", "assert check_alphanumeric(\"cooltricks@\") == 'Discard'" ]
[]
739
Write a function to validate a gregorian date.
def check_smaller(test_tup1, test_tup2): res = all(x > y for x, y in zip(test_tup1, test_tup2)) return (res)
[ "assert are_Rotations(\"abc\",\"cba\") == False", "assert are_Rotations(\"abcd\",\"cdba\") == False", "assert are_Rotations(\"abacd\",\"cdaba\") == True" ]
[]
738
Write a function to convert the given string of float type into tuple.
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 min_Swaps(\"1101\",\"1110\") == 1", "assert min_Swaps(\"1111\",\"0100\") == \"Not Possible\"", "assert min_Swaps(\"1110000\",\"0001101\") == 3" ]
[]
645
## 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
import math def first_Digit(n) : fact = 1 for i in range(2,n + 1) : fact = fact * i while (fact % 10 == 0) : fact = int(fact / 10) while (fact >= 10) : fact = int(fact / 10) return math.floor(fact)
[ "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'" ]
[]
707
Write a function to find ln, m lobb 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 jacobsthal_num(5) == 11", "assert jacobsthal_num(2) == 1", "assert jacobsthal_num(4) == 5" ]
[]
651
Write a python function to find sum of odd factors of a number.
def zip_list(list1,list2): result = list(map(list.__add__, list1, list2)) return result
[ "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-...
[]
620
Write a function to find length of the string.
def check(arr,n): g = 0 for i in range(1,n): if (arr[i] - arr[i - 1] > 0 and g == 1): return False if (arr[i] - arr[i] < 0): g = 1 return True
[ "assert check_Type_Of_Triangle(1,2,3) == \"Obtuse-angled Triangle\"", "assert check_Type_Of_Triangle(2,2,2) == \"Acute-angled Triangle\"", "assert check_Type_Of_Triangle(1,0,1) == \"Right-angled Triangle\"" ]
[]
667
Write a function to rearrange positive and negative numbers in a given array using lambda function.
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 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" ]
[]
743
Write a function to remove multiple spaces in a string.
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 min_Jumps(3,4,11)==3.5", "assert min_Jumps(3,4,0)==0", "assert min_Jumps(11,14,11)==1" ]
[]
922
Write a function to find the equilibrium index of the given array.
def lcm(x, y): if x > y: z = x else: z = y while(True): if((z % x == 0) and (z % y == 0)): lcm = z break z += 1 return lcm
[ "assert super_seq(\"AGGTAB\", \"GXTXAYB\", 6, 7) == 9", "assert super_seq(\"feek\", \"eke\", 4, 3) == 5", "assert super_seq(\"PARRT\", \"RTA\", 5, 3) == 6" ]
[]
967
Write a function that matches a string that has an 'a' followed by anything, ending in 'b' by using regex.
def mul_even_odd(list1): first_even = next((el for el in list1 if el%2==0),-1) first_odd = next((el for el in list1 if el%2!=0),-1) return (first_even*first_odd)
[ "assert count_same_pair([1, 2, 3, 4, 5, 6, 7, 8],[2, 2, 3, 1, 2, 6, 7, 9])==4", "assert count_same_pair([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8],[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==11", "assert count_same_pair([2, 4, -6, -9, 11, -12, 14, -5, 17],[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==1" ]
[]
936
Write a python function to find the index of smallest triangular number with n digits.
def Average(lst): return sum(lst) / len(lst)
[ "assert max_char(\"hello world\")==('l')", "assert max_char(\"hello \")==('l')", "assert max_char(\"python pr\")==('p')" ]
[]
834
Write a function to sort a list in a dictionary.
def noprofit_noloss(actual_cost,sale_amount): if(sale_amount == actual_cost): return True else: return False
[ "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]" ]
[]
734
Write a python function to count the total set bits from 1 to n.
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 lcopy([1, 2, 3]) == [1, 2, 3]", "assert lcopy([4, 8, 2, 10, 15, 18]) == [4, 8, 2, 10, 15, 18]", "assert lcopy([4, 5, 6]) == [4, 5, 6]\n" ]
[]
791
Write a function to extract all the adjacent coordinates of the given coordinate tuple.
def fifth_Power_Sum(n) : sm = 0 for i in range(1,n+1) : sm = sm + (i*i*i*i*i) return sm
[ "assert area_trapezium(6,9,4)==30", "assert area_trapezium(10,20,30)==450", "assert area_trapezium(15,25,35)==700" ]
[]
785
Write a function to find the perimeter of a rectangle.
def extract_unique(test_dict): res = list(sorted({ele for val in test_dict.values() for ele in val})) return res
[ "assert max_similar_indices([(2, 4), (6, 7), (5, 1)],[(5, 4), (8, 10), (8, 14)]) == [(5, 4), (8, 10), (8, 14)]", "assert max_similar_indices([(3, 5), (7, 8), (6, 2)],[(6, 5), (9, 11), (9, 15)]) == [(6, 5), (9, 11), (9, 15)]", "assert max_similar_indices([(4, 6), (8, 9), (7, 3)],[(7, 6), (10, 12), (10, 16)]) == ...
[]
827
Write a python function to check whether the given number can be represented by sum of two squares or not.
def are_Rotations(string1,string2): size1 = len(string1) size2 = len(string2) temp = '' if size1 != size2: return False temp = string1 + string1 if (temp.count(string2)> 0): return True else: return False
[ "assert move_last([1,2,3,4]) == [2,3,4,1]", "assert move_last([2,3,4,1,5,0]) == [3,4,1,5,0,2]", "assert move_last([5,4,3,2,1]) == [4,3,2,1,5]" ]
[]
688
Write a function to find the largest subset where each pair is divisible.
def count_Set_Bits(n) : n += 1; powerOf2 = 2; cnt = n // 2; while (powerOf2 <= n) : totalPairs = n // powerOf2; cnt += (totalPairs // 2) * powerOf2; if (totalPairs & 1) : cnt += (n % powerOf2) else : cnt += 0 powe...
[ "assert last_Two_Digits(7) == 40", "assert last_Two_Digits(5) == 20", "assert last_Two_Digits(2) == 2" ]
[]
658
Write a function to find the nth jacobsthal number.
import math def radian_degree(degree): radian = degree*(math.pi/180) return radian
[ "assert remove_multiple_spaces('Google Assistant') == 'Google Assistant'", "assert remove_multiple_spaces('Quad Core') == 'Quad Core'", "assert remove_multiple_spaces('ChromeCast Built-in') == 'ChromeCast Built-in'" ]
[]
671
Write a function to add all the numbers in a list and divide it with the length of the list.
def remove_similar_row(test_list): res = set(sorted([tuple(sorted(set(sub))) for sub in test_list])) return (res)
[ "assert sort_list_last([(2, 5), (1, 2), (4, 4), (2, 3), (2, 1)])==[(2, 1), (1, 2), (2, 3), (4, 4), (2, 5)] ", "assert sort_list_last([(9,8), (4, 7), (3,5), (7,9), (1,2)])==[(1,2), (3,5), (4,7), (9,8), (7,9)] ", "assert sort_list_last([(20,50), (10,20), (40,40)])==[(10,20),(40,40),(20,50)] " ]
[]
644
Write a python function to find the average of even numbers till a given even number.
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 max_chain_length([Pair(5, 24), Pair(15, 25),Pair(27, 40), Pair(50, 60)], 4) == 3", "assert max_chain_length([Pair(1, 2), Pair(3, 4),Pair(5, 6), Pair(7, 8)], 4) == 4", "assert max_chain_length([Pair(19, 10), Pair(11, 12),Pair(13, 14), Pair(15, 16), Pair(31, 54)], 5) == 5" ]
[]
649
Write a python function to check if the string is a concatenation of another string.
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 No_of_cubes(2,1) == 8", "assert No_of_cubes(5,2) == 64", "assert No_of_cubes(1,1) == 1" ]
[]
803
Write a function to check if the given tuple contains only k elements.
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 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)" ]
[]
786
Write a function to find all anagrams of a string in a given list of strings using lambda function.
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 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]" ]
[]
760
Write a function to calculate the standard deviation.
def harmonic_sum(n): if n < 2: return 1 else: return 1 / n + (harmonic_sum(n - 1))
[ "assert rombus_area(10,20)==100", "assert rombus_area(10,5)==25", "assert rombus_area(4,2)==4" ]
[]
882
Write a python function to check whether the two given strings are isomorphic to each other or not.
def get_key(dict): list = [] for key in dict.keys(): list.append(key) return list
[ "assert radian_degree(90)==1.5707963267948966", "assert radian_degree(60)==1.0471975511965976", "assert radian_degree(120)==2.0943951023931953" ]
[]
942
Write a function to check if one tuple is a subset of another tuple.
import re def remove_char(S): result = re.sub('[\W_]+', '', S) return result
[ "assert check_Even_Parity(10) == True", "assert check_Even_Parity(11) == False", "assert check_Even_Parity(18) == True" ]
[]
612
Write a function to check whether the given string is starting with a vowel or not using regex.
from collections import defaultdict def grouping_dictionary(l): d = defaultdict(list) for k, v in l: d[k].append(v) return d
[ "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...
[]
826
Write a function to check if the given expression is balanced or not.
from collections import deque def check_expression(exp): if len(exp) & 1: return False stack = deque() for ch in exp: if ch == '(' or ch == '{' or ch == '[': stack.append(ch) if ch == ')' or ch == '}' or ch == ']': if not stack: retur...
[ "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" ]
[]
869
Write a function to find maximum of three numbers.
import collections as ct def merge_dictionaries(dict1,dict2): merged_dict = dict(ct.ChainMap({}, dict1, dict2)) return merged_dict
[ "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'}...
[]
864
Write a function to increment the numeric values in the given strings by k.
def sum_num(numbers): total = 0 for x in numbers: total += x return total/len(numbers)
[ "assert is_decimal('123.11')==True", "assert is_decimal('e666.86')==False", "assert is_decimal('3.124587')==False" ]
[]
914
Write a python function to shift first element to the end of given list.
def Check_Solution(a,b,c): if b == 0: return ("Yes") else: return ("No")
[ "assert max_product([1, 2, 3, 4, 7, 0, 8, 4])==(7, 8)", "assert max_product([0, -1, -2, -4, 5, 0, -6])==(-4, -6)", "assert max_product([1, 3, 5, 6, 8, 9])==(8,9)" ]
[]
797
Write a function to check whether the given key is present in the dictionary or not.
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 count_list([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==25", "assert count_list([[1, 3], [5, 7], [9, 11], [13, 15, 17]] )==16", "assert count_list([[2, 4], [[6,8], [4,5,8]], [10, 12, 14]])==9" ]
[]
862
Write a function to find the previous palindrome of a specified number.
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 sum_Of_Subarray_Prod([1,2,3],3) == 20", "assert sum_Of_Subarray_Prod([1,2],2) == 5", "assert sum_Of_Subarray_Prod([1,2,3,4],4) == 84" ]
[]
642
Write a python function to count numeric values in a given string.
def largest_subset(a, n): dp = [0 for i in range(n)] dp[n - 1] = 1; for i in range(n - 2, -1, -1): mxm = 0; for j in range(i + 1, n): if a[j] % a[i] == 0 or a[i] % a[j] == 0: mxm = max(mxm, dp[j]) dp[i] = 1 + mxm return max(dp)
[ "assert sum_nums(2,10,11,20)==20", "assert sum_nums(15,17,1,10)==32", "assert sum_nums(10,15,5,30)==20" ]
[]
854
Write a function to find common index elements from three lists.
def odd_position(nums): return all(nums[i]%2==i%2 for i in range(len(nums)))
[ "assert Check_Solution(2,0,2) == \"Yes\"", "assert Check_Solution(2,-5,2) == \"Yes\"", "assert Check_Solution(1,2,3) == \"No\"" ]
[]
626
Write a python function to print duplicants from a list of integers.
import heapq def nth_super_ugly_number(n, primes): uglies = [1] def gen(prime): for ugly in uglies: yield ugly * prime merged = heapq.merge(*map(gen, primes)) while len(uglies) < n: ugly = next(merged) if ugly != uglies[-1]: uglies.append(ugly) ...
[ "assert sum_Even(2,5) == 6", "assert sum_Even(3,8) == 18", "assert sum_Even(4,6) == 10" ]
[]
686
Write a python function to count the number of digits in factorial of a given number.
from heapq import merge def combine_lists(num1,num2): combine_lists=list(merge(num1, num2)) return combine_lists
[ "assert remove_spaces('python program')==('python program')", "assert remove_spaces('python programming language')==('python programming language')", "assert remove_spaces('python program')==('python program')" ]
[]
952
Write a function to find numbers within a given range where every number is divisible by every digit it contains.
from collections import Counter def max_char(str1): temp = Counter(str1) max_char = max(temp, key = temp.get) return max_char
[ "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'" ]
[]
794
Write a python function to check whether every even index contains even numbers of a given list.
import re def replace_specialchar(text): return (re.sub("[ ,.]", ":", text))
[ "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]" ]
[]
836
Write a function to find the cumulative sum of all the values that are present in the given tuple list.
import re def extract_date(url): return re.findall(r'/(\d{4})/(\d{1,2})/(\d{1,2})/', url)
[ "assert find_k_product([(5, 6, 7), (1, 3, 5), (8, 9, 19)], 2) == 665", "assert find_k_product([(6, 7, 8), (2, 4, 6), (9, 10, 20)], 1) == 280", "assert find_k_product([(7, 8, 9), (3, 5, 7), (10, 11, 21)], 0) == 210" ]
[]
End of preview. Expand in Data Studio

edition_0484_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
11