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
625
Write a python function to count numeric values in a given string.
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 Odd_Length_Sum([1,2,4]) == 14", "assert Odd_Length_Sum([1,2,1,2]) == 15", "assert Odd_Length_Sum([1,7]) == 8" ]
[]
691
Write a python function to find minimum adjacent swaps required to sort binary array.
def float_to_tuple(test_str): res = tuple(map(float, test_str.split(', '))) return (res)
[ "assert count_Fac(24) == 3", "assert count_Fac(12) == 2", "assert count_Fac(4) == 1" ]
[]
740
Write a function to find all anagrams of a string in a given list of strings using lambda function.
def sum_nums(x, y,m,n): sum_nums= x + y if sum_nums in range(m, n): return 20 else: return sum_nums
[ "assert max_run_uppercase('GeMKSForGERksISBESt') == 5", "assert max_run_uppercase('PrECIOusMOVemENTSYT') == 6", "assert max_run_uppercase('GooGLEFluTTER') == 4" ]
[]
781
Write a python function to choose points from two ranges such that no point lies in both the ranges.
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 remove_kth_element([1,1,2,3,4,4,5,1],3)==[1, 1, 3, 4, 4, 5, 1]", "assert remove_kth_element([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4],4)==[0, 0, 1, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4]", "assert remove_kth_element([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10],5)==[10,10,15,19, 18, 17, 26, 26, 1...
[]
963
Write a function to check a decimal with a precision of 2.
def check_Concat(str1,str2): N = len(str1) M = len(str2) if (N % M != 0): return False for i in range(N): if (str1[i] != str2[i % M]): return False return True
[ "assert is_triangleexists(50,60,70)==True", "assert is_triangleexists(90,45,45)==True", "assert is_triangleexists(150,30,70)==False" ]
[]
941
Write a function to sort a list of lists by length and value.
def add_tuple(test_list, test_tup): test_list += test_tup return (test_list)
[ "assert mul_even_odd([1,3,5,7,4,1,6,8])==4", "assert mul_even_odd([1,2,3,4,5,6,7,8,9,10])==2", "assert mul_even_odd([1,5,7,9,10])==10" ]
[]
666
Write a python function to count equal element pairs from the given array.
def div_list(nums1,nums2): result = map(lambda x, y: x / y, nums1, nums2) return list(result)
[ "assert capital_words_spaces(\"Python\") == 'Python'", "assert capital_words_spaces(\"PythonProgrammingExamples\") == 'Python Programming Examples'", "assert capital_words_spaces(\"GetReadyToBeCodingFreak\") == 'Get Ready To Be Coding Freak'" ]
[]
830
Write a python function to check whether the count of divisors is even or odd.
def arc_length(d,a): pi=22/7 if a >= 360: return None arclength = (pi*d) * (a/360) return arclength
[ "assert count_Rotation([3,2,1],3) == 1", "assert count_Rotation([4,5,1,2,3],5) == 2", "assert count_Rotation([7,8,9,1,2,3],6) == 3" ]
[]
618
Write a python function to find the length of the shortest word.
def check_K(test_tup, K): res = False for ele in test_tup: if ele == K: res = True break return (res)
[ "assert get_ludic(10) == [1, 2, 3, 5, 7]", "assert get_ludic(25) == [1, 2, 3, 5, 7, 11, 13, 17, 23, 25]", "assert get_ludic(45) == [1, 2, 3, 5, 7, 11, 13, 17, 23, 25, 29, 37, 41, 43]" ]
[]
737
Write a function to abbreviate 'road' as 'rd.' in a given string.
def maximum_product(nums): import heapq a, b = heapq.nlargest(3, nums), heapq.nsmallest(2, nums) return max(a[0] * a[1] * a[2], a[0] * b[0] * b[1])
[ "assert match_num('5-2345861')==True", "assert match_num('6-2345861')==False", "assert match_num('78910')==False" ]
[]
611
Write a function to remove everything except alphanumeric characters from the given string by using regex.
import re def remove_all_spaces(text): return (re.sub(r'\s+', '',text))
[ "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 " ]
[]
683
Write a python function to find the slope of a line.
def Average(lst): return sum(lst) / len(lst)
[ "assert chinese_zodiac(1997)==('Ox')", "assert chinese_zodiac(1998)==('Tiger')", "assert chinese_zodiac(1994)==('Dog')" ]
[]
820
Write a function to locate the left insertion point for a specified value in sorted order.
def get_Number(n, k): arr = [0] * n; i = 0; odd = 1; while (odd <= n): arr[i] = odd; i += 1; odd += 2; even = 2; while (even <= n): arr[i] = even; i += 1; even += 2; return arr[k - 1];
[ "assert min_Jumps(3,4,11)==3.5", "assert min_Jumps(3,4,0)==0", "assert min_Jumps(11,14,11)==1" ]
[]
601
Write a function to remove the parenthesis area in a string.
def unique_Element(arr,n): s = set(arr) if (len(s) == 1): return ('YES') else: return ('NO')
[ "assert find_Min_Swaps([1,0,1,0],4) == 3", "assert find_Min_Swaps([0,1,0],3) == 1", "assert find_Min_Swaps([0,0,1,1,0],5) == 2" ]
[]
845
Write a function to join the tuples if they have similar initial elements.
def is_Product_Even(arr,n): for i in range(0,n): if ((arr[i] & 1) == 0): return True 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" ]
[]
731
Write a function to check if the given tuple contains only k elements.
from math import tan, pi def perimeter_polygon(s,l): perimeter = s*l return perimeter
[ "assert geometric_sum(7) == 1.9921875", "assert geometric_sum(4) == 1.9375", "assert geometric_sum(8) == 1.99609375" ]
[]
821
Write a python function to find minimum number swaps required to make two binary strings equal.
import math def lateralsurface_cone(r,h): l = math.sqrt(r * r + h * h) LSA = math.pi * r * l return LSA
[ "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 python function to merge the first and last elements separately in a list of lists.
def get_inv_count(arr, n): inv_count = 0 for i in range(n): for j in range(i + 1, n): if (arr[i] > arr[j]): inv_count += 1 return inv_count
[ "assert split_list(\"LearnToBuildAnythingWithGoogle\") == ['Learn', 'To', 'Build', 'Anything', 'With', 'Google']", "assert split_list(\"ApmlifyingTheBlack+DeveloperCommunity\") == ['Apmlifying', 'The', 'Black+', 'Developer', 'Community']", "assert split_list(\"UpdateInTheGoEcoSystem\") == ['Update', 'In', 'The'...
[]
935
Write a function to find the maximum sum of subsequences of given array with no adjacent elements.
def average_tuple(nums): result = [sum(x) / len(x) for x in zip(*nums)] return result
[ "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" ]
[]
715
Write a python function to check whether the given string is made up of two alternating characters or not.
def left_rotate(s,d): tmp = s[d : ] + s[0 : d] return tmp
[ "assert sector_area(4,45)==6.285714285714286", "assert sector_area(9,45)==31.82142857142857", "assert sector_area(9,360)==None" ]
[]
650
Write a function to find the product of it’s kth index in the given tuples.
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 check_valid((True, True, True, True) ) == True", "assert check_valid((True, False, True, True) ) == False", "assert check_valid((True, True, True, True) ) == True" ]
[]
700
Write a function to convert the given tuple to a key-value dictionary using adjacent elements.
def sum_column(list1, C): result = sum(row[C] for row in list1) return result
[ "assert first_Digit(5) == 1", "assert first_Digit(10) == 3", "assert first_Digit(7) == 5" ]
[]
649
Write a function to count the elements in a list until an element is a tuple.
def remove_kth_element(list1, L): return list1[:L-1] + list1[L:]
[ "assert is_upper(\"person\") ==\"PERSON\"", "assert is_upper(\"final\") == \"FINAL\"", "assert is_upper(\"Valid\") == \"VALID\"" ]
[]
899
Write a function that matches a word containing 'z', not at the start or end of the word.
def multiply_list(items): tot = 1 for x in items: tot *= x return tot
[ "assert remove_even([1,3,5,2]) == [1,3,5]", "assert remove_even([5,6,7]) == [5,7]", "assert remove_even([1,2,3,4]) == [1,3]" ]
[]
697
Write a function to convert degrees to radians.
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 find_Points(5,10,1,5) == (1,10)", "assert find_Points(3,5,7,9) == (3,9)", "assert find_Points(1,5,2,8) == (1,8)" ]
[]
858
Write a function to merge two dictionaries into a single expression.
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 count_char(\"Python\",'o')==1", "assert count_char(\"little\",'t')==2", "assert count_char(\"assert\",'s')==2" ]
[]
877
Write a function to find the most common elements and their counts of a specified text.
def div_of_nums(nums,m,n): result = list(filter(lambda x: (x % m == 0 and x % n == 0), nums)) return result
[ "assert end_num('abcdef')==False", "assert end_num('abcdef7')==True", "assert end_num('abc')==False" ]
[]
892
Write a function to calculate wind chill index.
def even_position(nums): return all(nums[i]%2==i%2 for i in range(len(nums)))
[ "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" ]
[]
926
Write a function to split the given string at uppercase letters by using regex.
def sum_list(lst1,lst2): res_list = [lst1[i] + lst2[i] for i in range(len(lst1))] return res_list
[ "assert decreasing_trend([-4,-3,-2,-1]) == True", "assert decreasing_trend([1,2,3]) == True", "assert decreasing_trend([3,2,1]) == False" ]
[]
815
Write a function to locate the right insertion point for a specified value in sorted order.
def check_valid(test_tup): res = not any(map(lambda ele: not ele, test_tup)) return (res)
[ "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']...
[]
639
Write a function to check if each element of second tuple is smaller than its corresponding index in first tuple.
def rgb_to_hsv(r, g, b): r, g, b = r/255.0, g/255.0, b/255.0 mx = max(r, g, b) mn = min(r, g, b) df = mx-mn if mx == mn: h = 0 elif mx == r: h = (60 * ((g-b)/df) + 360) % 360 elif mx == g: h = (60 * ((b-r)/df) + 120) % 360 elif mx == b: h = (60...
[ "assert 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'...
[]
779
Write a python function to find sum of all prime divisors of a given number.
def min_k(test_list, K): res = sorted(test_list, key = lambda x: x[1])[:K] return (res)
[ "assert profit_amount(1500,1200)==300", "assert profit_amount(100,200)==None", "assert profit_amount(2000,5000)==None" ]
[]
887
Write a python function to remove even numbers from a given list.
def validity_triangle(a,b,c): total = a + b + c if total == 180: return True else: return False
[ "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]" ]
[]
659
Write a function to find the fixed point in the given array.
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 maximum_segments(7, 5, 2, 5) == 2", "assert maximum_segments(17, 2, 1, 3) == 17", "assert maximum_segments(18, 16, 3, 6) == 6" ]
[]
925
Write a function to find whether an array is subset of another array.
def alternate_elements(list1): result=[] for item in list1[::2]: result.append(item) 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" ]
[]
952
Write a function to rotate a given list by specified number of items to the right direction.
def string_length(str1): count = 0 for char in str1: count += 1 return count
[ "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'" ]
[]
732
Write a function to flatten the given tuple matrix into the tuple list with each tuple representing each column.
import heapq as hq def heap_sort(iterable): h = [] for value in iterable: hq.heappush(h, value) return [hq.heappop(h) for i in range(len(h))]
[ "assert 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-...
[]
814
Write a function to check if a nested list is a subset of another nested list.
import itertools def remove_duplicate(list1): list.sort(list1) remove_duplicate = list(list1 for list1,_ in itertools.groupby(list1)) return remove_duplicate
[ "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" ]
[]
936
Write a function to count coin change.
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 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!')" ]
[]
953
Write a python function to convert the given string to upper case.
def check_monthnumber_number(monthnum3): if(monthnum3==4 or monthnum3==6 or monthnum3==9 or monthnum3==11): return True else: return False
[ "assert camel_to_snake('GoogleAssistant') == 'google_assistant'", "assert camel_to_snake('ChromeCast') == 'chrome_cast'", "assert camel_to_snake('QuadCore') == 'quad_core'" ]
[]
685
Write a function to sum elements in two lists.
def check_subset(list1,list2): return all(map(list1.__contains__,list2))
[ "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]" ]
[]
851
Write a function to sort the given array without using any sorting algorithm. the given array consists of only 0, 1, and 2.
def is_Two_Alter(s): for i in range (len( s) - 2) : if (s[i] != s[i + 2]) : return False if (s[0] == s[1]): return False return True
[ "assert len_complex(3,4)==5.0", "assert len_complex(9,10)==13.45362404707371", "assert len_complex(7,9)==11.40175425099138" ]
[]
633
Write a function to remove similar rows from the given tuple matrix.
from itertools import combinations def sub_lists(my_list): subs = [] for i in range(0, len(my_list)+1): temp = [list(x) for x in combinations(my_list, i)] if len(temp)>0: subs.extend(temp) return subs
[ "assert even_Power_Sum(2) == 272", "assert even_Power_Sum(3) == 1568", "assert even_Power_Sum(4) == 5664" ]
[]
850
Write a function to rearrange positive and negative numbers in a given array using lambda function.
from collections import Counter def max_char(str1): temp = Counter(str1) max_char = max(temp, key = temp.get) return max_char
[ "assert front_and_rear((10, 4, 5, 6, 7)) == (10, 7)", "assert front_and_rear((1, 2, 3, 4, 5)) == (1, 5)", "assert front_and_rear((6, 7, 8, 9, 10)) == (6, 10)" ]
[]
861
Write a python function to find lcm of two positive integers.
def count_char(string,char): count = 0 for i in range(len(string)): if(string[i] == char): count = count + 1 return count
[ "assert fifth_Power_Sum(2) == 33", "assert fifth_Power_Sum(4) == 1300", "assert fifth_Power_Sum(3) == 276" ]
[]
723
Write a function to calculate the harmonic sum of n-1.
def rectangle_perimeter(l,b): perimeter=2*(l+b) return perimeter
[ "assert mul_list([1, 2, 3],[4,5,6])==[4,10,18]", "assert mul_list([1,2],[3,4])==[3,8]", "assert mul_list([90,120],[50,70])==[4500,8400]" ]
[]
651
Write a python function to left rotate the string.
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 product_Equal(2841) == True", "assert product_Equal(1234) == False", "assert product_Equal(1212) == False" ]
[]
946
Write a function to find out, if the given number is abundant.
def sort_by_dnf(arr, n): low=0 mid=0 high=n-1 while mid <= high: if arr[mid] == 0: arr[low], arr[mid] = arr[mid], arr[low] low = low + 1 mid = mid + 1 elif arr[mid] == 1: mid = mid + 1 else: arr[mid], arr[high] = arr[high], arr[mid] high = high - 1 ...
[ "assert slope(4,2,2,5) == -1.5", "assert slope(2,4,4,6) == 1", "assert slope(1,2,4,2) == 0" ]
[]
671
Write a python function to find the first digit in factorial 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 text_match_three(\"ac\")==('Not matched!')", "assert text_match_three(\"dc\")==('Not matched!')", "assert text_match_three(\"abbbba\")==('Found a match!')" ]
[]
944
Write a python function to find the sum of fourth power of first n even natural numbers.
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 text_uppercase_lowercase(\"AaBbGg\")==('Found a match!')", "assert text_uppercase_lowercase(\"aA\")==('Not matched!')", "assert text_uppercase_lowercase(\"PYTHON\")==('Not matched!')" ]
[]
826
Write a function to check if the given tuple has any none value or not.
import re def match_num(string): text = re.compile(r"^5") if text.match(string): return True else: return False
[ "assert sum_of_square(4) == 70", "assert sum_of_square(5) == 252", "assert sum_of_square(2) == 6" ]
[]
915
Write a python function to check whether a sequence of numbers has an increasing trend or not.
from itertools import groupby def consecutive_duplicates(nums): return [key for key, group in groupby(nums)]
[ "assert check_none((10, 4, 5, 6, None)) == True", "assert check_none((7, 8, 9, 11, 14)) == False", "assert check_none((1, 2, 3, 4, None)) == True" ]
[]
792
Write a function to sort the given array by using heap sort.
def word_len(s): s = s.split(' ') for word in s: if len(word)%2==0: return True else: return False
[ "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" ]
[]
808
Write a function to find ln, m lobb number.
def number_ctr(str): number_ctr= 0 for i in range(len(str)): if str[i] >= '0' and str[i] <= '9': number_ctr += 1 return number_ctr
[ "assert prime_num(13)==True", "assert prime_num(7)==True", "assert prime_num(-1010)==False" ]
[]
738
Write a function to find the median of two sorted arrays of same size.
import re regex = '[a-zA-z0-9]$' def check_alphanumeric(string): if(re.search(regex, string)): return ("Accept") else: return ("Discard")
[ "assert first_odd([1,3,5]) == 1", "assert first_odd([2,4,1,3]) == 1", "assert first_odd ([8,9,1]) == 9" ]
[]
673
Write a function to calculate the height of the given binary tree.
def int_to_roman( num): val = [1000, 900, 500, 400,100, 90, 50, 40,10, 9, 5, 4,1] syb = ["M", "CM", "D", "CD","C", "XC", "L", "XL","X", "IX", "V", "IV","I"] roman_num = '' i = 0 while num > 0: for _ in range(num // val[i]): roman_num += syb[i] ...
[ "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'" ]
[]
813
Write a python function to move all zeroes to the end of the given list.
def remove_negs(num_list): for item in num_list: if item < 0: num_list.remove(item) return num_list
[ "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" ]
[]
919
Write a function to find n-th rencontres number.
def Sum_of_Inverse_Divisors(N,Sum): ans = float(Sum)*1.0 /float(N); return round(ans,2);
[ "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" ]
[]
648
Write a python function to check if the string is a concatenation of another string.
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 toggle_middle_bits(9) == 15", "assert toggle_middle_bits(10) == 12", "assert toggle_middle_bits(11) == 13" ]
[]
923
Write a function to increment the numeric values in the given strings by k.
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 sorted_dict({'n1': [2, 3, 1], 'n2': [5, 1, 2], 'n3': [3, 2, 4]})=={'n1': [1, 2, 3], 'n2': [1, 2, 5], 'n3': [2, 3, 4]}", "assert sorted_dict({'n1': [25,37,41], 'n2': [41,54,63], 'n3': [29,38,93]})=={'n1': [25, 37, 41], 'n2': [41, 54, 63], 'n3': [29, 38, 93]}", "assert sorted_dict({'n1': [58,44,56], 'n2':...
[]
768
Write a function to return true if the password is valid.
def reverse_words(s): return ' '.join(reversed(s.split()))
[ "assert find_First_Missing([0,1,2,3],0,3) == 4", "assert find_First_Missing([0,1,2,6,9],0,4) == 3", "assert find_First_Missing([2,3,5,8,9],0,4) == 0" ]
[]
791
Write a python function to find the sum of all even natural numbers within the range l and r.
def check_Even_Parity(x): parity = 0 while (x != 0): x = x & (x - 1) parity += 1 if (parity % 2 == 0): return True else: return False
[ "assert check_K((10, 4, 5, 6, 8), 6) == True", "assert check_K((1, 2, 3, 4, 5, 6), 7) == False", "assert check_K((7, 8, 9, 44, 11, 12), 11) == True" ]
[]
632
Write a python function to find the sum of an array.
def get_item(tup1,index): item = tup1[index] return item
[ "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)]" ]
[]
939
Write a python function to convert a list of multiple integers into a single integer.
def listify_list(list1): result = list(map(list,list1)) return result
[ "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)]) == ...
[]
770
Write a function to compute the value of ncr mod p.
import re def text_match(text): patterns = 'a.*?b$' if re.search(patterns, text): return ('Found a match!') else: return ('Not matched!')
[ "assert remove_duplicate(\"Python Exercises Practice Solution Exercises\")==(\"Python Exercises Practice Solution\")", "assert remove_duplicate(\"Python Exercises Practice Solution Python\")==(\"Python Exercises Practice Solution\")", "assert remove_duplicate(\"Python Exercises Practice Solution Practice\")==(\...
[]
812
Write a python function to check whether the given two arrays are equal or not.
def test_three_equal(x,y,z): result= set([x,y,z]) if len(result)==3: return 0 else: return (4-len(result))
[ "assert sort_String(\"cba\") == \"abc\"", "assert sort_String(\"data\") == \"aadt\"", "assert sort_String(\"zxy\") == \"xyz\"" ]
[]
612
Write a function to get a lucid number smaller than or equal to n.
import math def radian_degree(degree): radian = degree*(math.pi/180) return radian
[ "assert fibonacci(7) == 13", "assert fibonacci(8) == 21", "assert fibonacci(9) == 34" ]
[]
687
Write a function to find the length of the shortest string that has both str1 and str2 as subsequences.
def check_subset(test_tup1, test_tup2): res = set(test_tup2).issubset(test_tup1) return (res)
[ "assert parallelogram_perimeter(10,20)==400", "assert parallelogram_perimeter(15,20)==600", "assert parallelogram_perimeter(8,9)==144" ]
[]
750
Write a python function to get the difference between two lists.
import collections as ct def merge_dictionaries(dict1,dict2): merged_dict = dict(ct.ChainMap({}, dict1, dict2)) return merged_dict
[ "assert min_k([('Manjeet', 10), ('Akshat', 4), ('Akash', 2), ('Nikhil', 8)], 2) == [('Akash', 2), ('Akshat', 4)]", "assert min_k([('Sanjeev', 11), ('Angat', 5), ('Akash', 3), ('Nepin', 9)], 3) == [('Akash', 3), ('Angat', 5), ('Nepin', 9)]", "assert min_k([('tanmay', 14), ('Amer', 11), ('Ayesha', 9), ('SKD', 16)...
[]
897
Write a function to find the n-th power of individual elements in a list using lambda function.
def sector_area(r,a): pi=22/7 if a >= 360: return None sectorarea = (pi*r**2) * (a/360) return sectorarea
[ "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\"]" ]
[]
865
Write a function to check if each element of the second tuple is greater than its corresponding index in the first tuple.
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 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...
[]
893
Write a python function to check whether the given strings are rotations of each other or not.
import re def remove_spaces(text): return (re.sub(' +',' ',text))
[ "assert clear_tuple((1, 5, 3, 6, 8)) == ()", "assert clear_tuple((2, 1, 4 ,5 ,6)) == ()", "assert clear_tuple((3, 2, 5, 6, 8)) == ()" ]
[]
903
Write a python function to check whether the roots of a quadratic equation are numerically equal but opposite in sign or not.
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 floor_Min(10,20,30) == 15", "assert floor_Min(1,2,1) == 0", "assert floor_Min(11,10,9) == 9" ]
[]
873
Write a function to return true if the given number is even else return false.
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 merge([['x', 'y'], ['a', 'b'], ['m', 'n']]) == [['x', 'a', 'm'], ['y', 'b', 'n']]", "assert merge([[1, 2], [3, 4], [5, 6], [7, 8]]) == [[1, 3, 5, 7], [2, 4, 6, 8]]", "assert merge([['x', 'y','z' ], ['a', 'b','c'], ['m', 'n','o']]) == [['x', 'a', 'm'], ['y', 'b', 'n'],['z', 'c','o']]" ]
[]
841
Write a function to count the number of elements in a list which are within a specific range.
def check_greater(test_tup1, test_tup2): res = all(x < y for x, y in zip(test_tup1, test_tup2)) return (res)
[ "assert group_element([(6, 5), (2, 7), (2, 5), (8, 7), (9, 8), (3, 7)]) == {5: [6, 2], 7: [2, 8, 3], 8: [9]}", "assert group_element([(7, 6), (3, 8), (3, 6), (9, 8), (10, 9), (4, 8)]) == {6: [7, 3], 8: [3, 9, 4], 9: [10]}", "assert group_element([(8, 7), (4, 9), (4, 7), (10, 9), (11, 10), (5, 9)]) == {7: [8, 4]...
[]
904
Write a function to remove multiple spaces in a string by using regex.
import math import sys def sd_calc(data): n = len(data) if n <= 1: return 0.0 mean, sd = avg_calc(data), 0.0 for el in data: sd += (float(el) - mean)**2 sd = math.sqrt(sd / float(n-1)) return sd def avg_calc(ls): n, mean = len(ls), 0.0 if n <= 1: ret...
[ "assert round_up(123.01247,0)==124", "assert round_up(123.01247,1)==123.1", "assert round_up(123.01247,2)==123.02" ]
[]
876
Write a function to zip two given lists of lists.
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 _sum([1, 2, 3]) == 6", "assert _sum([15, 12, 13, 10]) == 50", "assert _sum([0, 1, 2]) == 3" ]
[]
854
Write a python function to check whether the given two numbers have same number of digits or not.
def sorted_dict(dict1): sorted_dict = {x: sorted(y) for x, y in dict1.items()} return sorted_dict
[ "assert is_Two_Alter(\"abab\") == True", "assert is_Two_Alter(\"aaaa\") == False", "assert is_Two_Alter(\"xyz\") == False" ]
[]
902
Write a function to find the frequency of each element in the given list.
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 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" ]
[]
712
Write a python function to check for even parity of a given number.
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 text_match(\"aabbbbd\") == 'Not matched!'", "assert text_match(\"aabAbbbc\") == 'Not matched!'", "assert text_match(\"accddbbjjjb\") == 'Found a match!'" ]
[]
924
Write a python function to find the sum of fourth power of first n odd natural numbers.
def return_sum(dict): sum = 0 for i in dict.values(): sum = sum + i return sum
[ "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'" ]
[]
913
Write a python function to count the number of lists in a given number of lists.
def first_odd(nums): first_odd = next((el for el in nums if el%2!=0),-1) return first_odd
[ "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)" ]
[]
836
Write a function to calculate the sum of series 1³+2³+3³+….+n³.
import re def change_date_format(dt): return re.sub(r'(\d{4})-(\d{1,2})-(\d{1,2})', '\\3-\\2-\\1', dt) return change_date_format(dt)
[ "assert count_vowels('bestinstareels') == 7", "assert count_vowels('partofthejourneyistheend') == 12", "assert count_vowels('amazonprime') == 5" ]
[]
855
Write a function to remove consecutive duplicates of a given list.
def first_repeated_char(str1): for index,c in enumerate(str1): if str1[:index+1].count(c) > 1: return c return "None"
[ "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'" ]
[]
621
Write a python function to interchange first and last elements in a given list.
def count_Rotation(arr,n): for i in range (1,n): if (arr[i] < arr[i - 1]): return i return 0
[ "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...
[]
698
Write a function to perfom the modulo of tuple elements in the given two tuples.
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 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)" ]
[]
895
Write a function to find the minimum total path sum in the given triangle.
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 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" ]
[]
868
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 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 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" ]
[]
906
Write a python function to count occurences of a character in a repeated string.
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 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" ]
[]
742
Write a python function to find the kth element in an array containing odd elements first and then even elements.
def is_key_present(d,x): if x in d: return True else: return False
[ "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]" ]
[]
933
Write a function to find a pair with the highest product from a given array of integers.
def filter_data(students,h,w): result = {k: s for k, s in students.items() if s[0] >=h and s[1] >=w} return result
[ "assert 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" ]
[]
657
Write a function to iterate over elements repeating each as many times as its count.
import re def text_match(text): patterns = 'ab*?' if re.search(patterns, text): return ('Found a match!') else: return ('Not matched!')
[ "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" ]
[]
724
Write a function to reverse words in a given string.
def generate_matrix(n): if n<=0: return [] matrix=[row[:] for row in [[0]*n]*n] row_st=0 row_ed=n-1 col_st=0 col_ed=n-1 current=1 while (True): if current>n*n: break f...
[ "assert validity_triangle(60,50,90)==False", "assert validity_triangle(45,75,60)==True", "assert validity_triangle(30,50,100)==True" ]
[]
967
Write a function to compute maximum product of three numbers of a given array of integers using heap queue algorithm.
import heapq def cheap_items(items,n): cheap_items = heapq.nsmallest(n, items, key=lambda s: s['price']) return cheap_items
[ "assert odd_position([2,1,4,3,6,7,6,3]) == True", "assert odd_position([4,1,2]) == True", "assert odd_position([1,2,3]) == False" ]
[]
763
Write a python function to check whether the given number can be represented by sum of two squares or not.
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 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...
[]
917
Write a function to multiply the adjacent elements of the given tuple.
def check_Odd_Parity(x): parity = 0 while (x != 0): x = x & (x - 1) parity += 1 if (parity % 2 == 1): return True else: return False
[ "assert smallest_Divisor(10) == 2", "assert smallest_Divisor(25) == 5", "assert smallest_Divisor(31) == 31" ]
[]
880
Write a function to find the maximum value in record list as tuple attribute in the given tuple list.
def even_num(x): if x%2==0: return True else: return False
[ "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]" ]
[]
825
Write a function to remove all whitespaces from a 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 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" ]
[]
948
Write a function to count number of unique lists within a list.
def swap_List(newList): size = len(newList) temp = newList[0] newList[0] = newList[size - 1] newList[size - 1] = temp return newList
[ "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]" ]
[]
920
Write a function to extract values between quotation marks of the given string by using regex.
import re def split_list(text): return (re.findall('[A-Z][^A-Z]*', text))
[ "assert split_upperstring(\"PythonProgramLanguage\")==['Python','Program','Language']", "assert split_upperstring(\"PythonProgram\")==['Python','Program']", "assert split_upperstring(\"ProgrammingLanguage\")==['Programming','Language']" ]
[]
End of preview. Expand in Data Studio

edition_2146_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