Dataset Viewer
Auto-converted to Parquet Duplicate
task_id
int64
601
974
text
large_stringlengths
38
249
code
large_stringlengths
30
908
test_list
listlengths
3
3
test_setup_code
large_stringclasses
2 values
challenge_test_list
listlengths
0
0
799
Write a python function to check whether the product of digits of a number at even and odd places is equal or not.
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 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] " ]
[]
839
Write a function to return true if the password is valid.
def get_noOfways(n): if (n == 0): return 0; if (n == 1): return 1; return get_noOfways(n - 1) + get_noOfways(n - 2);
[ "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" ]
[]
697
Write a function to remove all the words with k length in the given string.
def str_to_tuple(test_str): res = tuple(map(int, test_str.split(', '))) 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)" ]
[]
944
Write a python function to check whether the given two numbers have same number of digits or not.
def sort_sublists(list1): list1.sort() list1.sort(key=len) return list1
[ "assert jacobsthal_num(5) == 11", "assert jacobsthal_num(2) == 1", "assert jacobsthal_num(4) == 5" ]
[]
867
Write a function to find the number which occurs for odd number of times in the given array.
def No_of_cubes(N,K): No = 0 No = (N - K + 1) No = pow(No, 3) return No
[ "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)" ]
[]
710
Write a function to count the elements in a list until an element is a tuple.
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 sum_Of_Primes(10) == 17", "assert sum_Of_Primes(20) == 77", "assert sum_Of_Primes(5) == 10" ]
[]
900
Write a function to validate a gregorian date.
def chunk_tuples(test_tup, N): res = [test_tup[i : i + N] for i in range(0, len(test_tup), N)] 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" ]
[]
797
Write a function to find the item with maximum occurrences in a given list.
import heapq def cheap_items(items,n): cheap_items = heapq.nsmallest(n, items, key=lambda s: s['price']) return cheap_items
[ "assert average_tuple(((10, 10, 10, 12), (30, 45, 56, 45), (81, 80, 39, 32), (1, 2, 3, 4)))==[30.5, 34.25, 27.0, 23.25]", "assert average_tuple(((1, 1, -5), (30, -15, 56), (81, -60, -39), (-10, 2, 3)))== [25.5, -18.0, 3.75]", "assert average_tuple( ((100, 100, 100, 120), (300, 450, 560, 450), (810, 800, 390, 32...
[]
964
Write a python function to remove spaces from a given string.
def set_middle_bits(n): n |= n >> 1; n |= n >> 2; n |= n >> 4; n |= n >> 8; n |= n >> 16; return (n >> 1) ^ 1 def toggle_middle_bits(n): if (n == 1): return 1 return n ^ set_middle_bits(n)
[ "assert remove_empty([(), (), ('',), ('a', 'b'), ('a', 'b', 'c'), ('d')])==[('',), ('a', 'b'), ('a', 'b', 'c'), 'd'] ", "assert remove_empty([(), (), ('',), (\"python\"), (\"program\")])==[('',), (\"python\"), (\"program\")] ", "assert remove_empty([(), (), ('',), (\"java\")])==[('',),(\"java\") ] " ]
[]
901
Write a function to perfom the modulo of tuple elements in the given two tuples.
def max_similar_indices(test_list1, test_list2): res = [(max(x[0], y[0]), max(x[1], y[1])) for x, y in zip(test_list1, test_list2)] return (res)
[ "assert check(\"SEEquoiaL\") == 'accepted'", "assert check('program') == \"not accepted\"", "assert check('fine') == \"not accepted\"" ]
[]
973
Write a function where a string will start with a specific number.
def check_monthnumb(monthname2): if(monthname2=="January" or monthname2=="March"or monthname2=="May" or monthname2=="July" or monthname2=="Augest" or monthname2=="October" or monthname2=="December"): return True else: return False
[ "assert 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" ]
[]
757
Write a function to find whether an array is subset of another array.
def listify_list(list1): result = list(map(list,list1)) return result
[ "assert is_polite(7) == 11", "assert is_polite(4) == 7", "assert is_polite(9) == 13" ]
[]
720
Write a python function to remove the k'th element from a given list.
def access_elements(nums, list_index): result = [nums[i] for i in list_index] return result
[ "assert sum_nums(2,10,11,20)==20", "assert sum_nums(15,17,1,10)==32", "assert sum_nums(10,15,5,30)==20" ]
[]
864
Write a python function to check whether a sequence of numbers has an increasing trend or not.
def move_num(test_str): res = '' dig = '' for ele in test_str: if ele.isdigit(): dig += ele else: res += ele res += dig return (res)
[ "assert sort_list([(3, 4, 6, 723), (1, 2), (12345,), (134, 234, 34)] ) == '[(1, 2), (12345,), (3, 4, 6, 723), (134, 234, 34)]'", "assert sort_list([(3, 4, 8), (1, 2), (1234335,), (1345, 234, 334)] ) == '[(1, 2), (3, 4, 8), (1234335,), (1345, 234, 334)]'", "assert sort_list([(34, 4, 61, 723), (1, 2), (145,), (13...
[]
774
Write a python function to check whether every even index contains even numbers of a given list.
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 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" ]
[]
609
Write a function to find the fixed point in the given array.
def count_digs(tup): return sum([len(str(ele)) for ele in tup ]) def sort_list(test_list): test_list.sort(key = count_digs) return (str(test_list))
[ "assert 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)" ]
[]
665
Write a function to calculate the geometric sum of n-1.
def reverse_Array_Upto_K(input, k): return (input[k-1::-1] + input[k:])
[ "assert nth_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],2)==[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]", "assert nth_nums([10,20,30],3)==([1000, 8000, 27000])", "assert nth_nums([12,15],5)==([248832, 759375])" ]
[]
905
Write a python function to count the total set bits from 1 to n.
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 check_monthnumb(\"February\")==False", "assert check_monthnumb(\"January\")==True", "assert check_monthnumb(\"March\")==True" ]
[]
639
Write a python function to count the number of lists in a given number of lists.
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" ]
[]
847
Write a python function to find the first digit in factorial of a given number.
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_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], ...
[]
956
Write a python function to find minimum adjacent swaps required to sort binary array.
import cmath def len_complex(a,b): cn=complex(a,b) length=abs(cn) return length
[ "assert maximum_value([('key1', [3, 4, 5]), ('key2', [1, 4, 2]), ('key3', [9, 3])]) == [('key1', 5), ('key2', 4), ('key3', 9)]", "assert maximum_value([('key1', [4, 5, 6]), ('key2', [2, 5, 3]), ('key3', [10, 4])]) == [('key1', 6), ('key2', 5), ('key3', 10)]", "assert maximum_value([('key1', [5, 6, 7]), ('key2',...
[]
706
Write a function to find numbers divisible by m and n from a list of numbers using lambda function.
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 removals([1, 3, 4, 9, 10,11, 12, 17, 20], 9, 4) == 5", "assert removals([1, 5, 6, 2, 8], 5, 2) == 3", "assert removals([1, 2, 3 ,4, 5, 6], 6, 3) == 2" ]
[]
783
Write a function to extract unique values from the given dictionary values.
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 check_valid((True, True, True, True) ) == True", "assert check_valid((True, False, True, True) ) == False", "assert check_valid((True, True, True, True) ) == True" ]
[]
954
Write a function to find all anagrams of a string in a given list of strings using lambda function.
def remove_list_range(list1, leftrange, rigthrange): result = [i for i in list1 if (min(i)>=leftrange and max(i)<=rigthrange)] return result
[ "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]" ]
[]
683
Write a python function to remove negative numbers from a list.
def equilibrium_index(arr): total_sum = sum(arr) left_sum=0 for i, num in enumerate(arr): total_sum -= num if left_sum == total_sum: return i left_sum += num return -1
[ "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 function to check whether the given ip address is valid or not using regex.
from operator import eq def count_same_pair(nums1, nums2): result = sum(map(eq, nums1, nums2)) return result
[ "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]" ]
[]
682
Write a function to find numbers divisible by m or n from a list of numbers using lambda function.
def sum_num(numbers): total = 0 for x in numbers: total += x return total/len(numbers)
[ "assert get_noOfways(4)==3", "assert get_noOfways(3)==2", "assert get_noOfways(5)==5" ]
[]
913
Write a function to find the nth nonagonal number.
from collections import Counter def count_variable(a,b,c,d): c = Counter(p=a, q=b, r=c, s=d) return list(c.elements())
[ "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)" ]
[]
937
Write a python function to count numeric values in a given string.
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 is_key_present({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60},5)==True", "assert is_key_present({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60},6)==True", "assert is_key_present({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60},10)==False" ]
[]
643
Write a function to iterate over elements repeating each as many times as its count.
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 remove_similar_row([[(4, 5), (3, 2)], [(2, 2), (4, 6)], [(3, 2), (4, 5)]] ) == {((2, 2), (4, 6)), ((3, 2), (4, 5))}", "assert remove_similar_row([[(5, 6), (4, 3)], [(3, 3), (5, 7)], [(4, 3), (5, 6)]] ) == {((4, 3), (5, 6)), ((3, 3), (5, 7))}", "assert remove_similar_row([[(6, 7), (5, 4)], [(4, 4), (6, 8...
[]
731
Write a function to extract values between quotation marks of the given string by using regex.
def average_tuple(nums): result = [sum(x) / len(x) for x in zip(*nums)] return result
[ "assert is_Product_Even([1,2,3],3) == True", "assert is_Product_Even([1,2,1,4],4) == True", "assert is_Product_Even([1,1],2) == False" ]
[]
837
Write a python function to find the sum of fifth power of n natural numbers.
def last(n): return n[-1] def sort_list_last(tuples): return sorted(tuples, key=last)
[ "assert slope(4,2,2,5) == -1.5", "assert slope(2,4,4,6) == 1", "assert slope(1,2,4,2) == 0" ]
[]
702
Write a python function to check whether a sequence of numbers has a decreasing trend or not.
def is_key_present(d,x): if x in d: return True else: return False
[ "assert number_ctr('program2bedone') == 1", "assert number_ctr('3wonders') ==1", "assert number_ctr('123') == 3" ]
[]
842
Write a function to add a dictionary to the tuple.
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 is_abundant(12)==True", "assert is_abundant(13)==False", "assert is_abundant(9)==False" ]
[]
762
Write a function to find the occurrences of n most common words in a given text.
from itertools import groupby def consecutive_duplicates(nums): return [key for key, group in groupby(nums)]
[ "assert count_Unset_Bits(2) == 1", "assert count_Unset_Bits(5) == 4", "assert count_Unset_Bits(14) == 17" ]
[]
902
Write a python function to find the smallest prime divisor of a number.
def palindrome_lambda(texts): result = list(filter(lambda x: (x == "".join(reversed(x))), texts)) return result
[ "assert max_of_two(10,20)==20", "assert max_of_two(19,15)==19", "assert max_of_two(-10,-20)==-10" ]
[]
891
Write a python function to find the index of smallest triangular number with n digits.
def get_Pairs_Count(arr,n,sum): count = 0 for i in range(0,n): for j in range(i + 1,n): if arr[i] + arr[j] == sum: count += 1 return count
[ "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)]) == ...
[]
862
Write a function that matches a string that has an 'a' followed by anything, ending in 'b'.
from itertools import zip_longest, chain, tee def exchange_elements(lst): lst1, lst2 = tee(iter(lst), 2) return list(chain.from_iterable(zip_longest(lst[1::2], lst[::2])))
[ "assert add_list([1, 2, 3],[4,5,6])==[5, 7, 9]", "assert add_list([1,2],[3,4])==[4,6]", "assert add_list([10,20],[50,70])==[60,90]" ]
[]
796
Write a python function to find the largest triangle that can be inscribed in the semicircle.
import re def end_num(string): text = re.compile(r".*[0-9]$") if text.match(string): return True else: return False
[ "assert exchange_elements([0,1,2,3,4,5])==[1, 0, 3, 2, 5, 4] ", "assert exchange_elements([5,6,7,8,9,10])==[6,5,8,7,10,9] ", "assert exchange_elements([25,35,45,55,75,95])==[35,25,55,45,95,75] " ]
[]
860
Write a python function to check whether the roots of a quadratic equation are numerically equal but opposite in sign or not.
def dealnnoy_num(n, m): if (m == 0 or n == 0) : return 1 return dealnnoy_num(m - 1, n) + dealnnoy_num(m - 1, n - 1) + dealnnoy_num(m, n - 1)
[ "assert left_Rotate(16,2) == 64", "assert left_Rotate(10,2) == 40", "assert left_Rotate(99,3) == 792" ]
[]
838
Write a function to convert degrees to radians.
import datetime def check_date(m, d, y): try: m, d, y = map(int, (m, d, y)) datetime.date(y, m, d) return True except ValueError: return False
[ "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" ]
[]
784
Write a function to sort dictionary items by tuple product of keys for the given dictionary with tuple keys.
def chinese_zodiac(year): if (year - 2000) % 12 == 0: sign = 'Dragon' elif (year - 2000) % 12 == 1: sign = 'Snake' elif (year - 2000) % 12 == 2: sign = 'Horse' elif (year - 2000) % 12 == 3: sign = 'sheep' elif (year - 2000) % 12 == 4: sign = 'Monkey' elif (year - 2000) % 12 == ...
[ "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" ]
[]
861
Write a function to get a lucid number smaller than or equal to n.
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 match_num('5-2345861')==True", "assert match_num('6-2345861')==False", "assert match_num('78910')==False" ]
[]
940
Write a python function to find the minimum number of swaps required to convert one binary string to another.
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]" ]
[]
821
Write a python function to calculate the sum of the numbers in a list between the indices of a specified range.
def Split(list): ev_li = [] for i in list: if (i % 2 == 0): ev_li.append(i) return ev_li
[ "assert check_expression(\"{()}[{}]\") == True", "assert check_expression(\"{()}[{]\") == False", "assert check_expression(\"{()}[{}][]({})\") == True" ]
[]
825
Write a python function to find the sum of all odd natural numbers within the range l and r.
def check_subset(list1,list2): return all(map(list1.__contains__,list2))
[ "assert test_three_equal(1,1,1) == 3", "assert test_three_equal(-1,-2,-3) == 0", "assert test_three_equal(1,2,2) == 2" ]
[]
917
Write a python function to find the index of an extra element present in one sorted array.
import re def remove_extra_char(text1): pattern = re.compile('[\W_]+') return (pattern.sub('', text1))
[ "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'" ]
[]
739
Write a function to re-arrange the given tuples based on the given ordered list.
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 check_str(\"annie\") == 'Valid'", "assert check_str(\"dawood\") == 'Invalid'", "assert check_str(\"Else\") == 'Valid'" ]
[]
661
Write a function to get dictionary keys as a list.
def count_Pairs(arr,n): cnt = 0; for i in range(n): for j in range(i + 1,n): if (arr[i] == arr[j]): cnt += 1; return cnt;
[ "assert recur_gcd(12,14) == 2", "assert recur_gcd(13,17) == 1", "assert recur_gcd(9, 3) == 3" ]
[]
845
Write a python function to sort the given string.
def fifth_Power_Sum(n) : sm = 0 for i in range(1,n+1) : sm = sm + (i*i*i*i*i) return sm
[ "assert bell_Number(2) == 2", "assert bell_Number(3) == 5", "assert bell_Number(4) == 15" ]
[]
898
Write a function to calculate the harmonic sum of n-1.
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 profit_amount(1500,1200)==300", "assert profit_amount(100,200)==None", "assert profit_amount(2000,5000)==None" ]
[]
959
Write a python function to check for even parity of a given number.
def floor_Max(A,B,N): x = min(B - 1,N) return (A*x) // B
[ "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!')" ]
[]
607
Write a function to find the lateral surface area of a cone.
import re def extract_quotation(text1): return (re.findall(r'"(.*?)"', text1))
[ "assert find_Sum([1,2,3,1,1,4,5,6],8) == 21", "assert find_Sum([1,10,9,4,2,10,10,45,4],9) == 71", "assert find_Sum([12,10,9,45,2,10,10,45,10],9) == 78" ]
[]
819
Write a function to sum the length of the names of a given list of names after removing the names that start with a lowercase letter.
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 Check_Solution(2,0,2) == \"Yes\"", "assert Check_Solution(2,-5,2) == \"Yes\"", "assert Check_Solution(1,2,3) == \"No\"" ]
[]
897
Write a python function to check whether the count of divisors is even or odd.
def power_base_sum(base, power): return sum([int(i) for i in str(pow(base, power))])
[ "assert new_tuple([\"WEB\", \"is\"], \"best\") == ('WEB', 'is', 'best')", "assert new_tuple([\"We\", \"are\"], \"Developers\") == ('We', 'are', 'Developers')", "assert new_tuple([\"Part\", \"is\"], \"Wrong\") == ('Part', 'is', 'Wrong')" ]
[]
707
Write a function to check if the string is a valid email address or not using regex.
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 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'}" ]
[]
811
Write a python function to find the average of a list.
def multiply_list(items): tot = 1 for x in items: tot *= x return tot
[ "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" ]
[]
893
Write a function to find the previous palindrome of a specified number.
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 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]" ]
[]
724
Write a function to find maximum run of uppercase characters in the given string.
def test_three_equal(x,y,z): result= set([x,y,z]) if len(result)==3: return 0 else: return (4-len(result))
[ "assert sum_series(7)==784", "assert sum_series(5)==225", "assert sum_series(15)==14400" ]
[]
680
Write a function to find minimum k records from tuple list.
def check_monthnum_number(monthnum1): if monthnum1 == 2: return True else: return False
[ "assert remove_tuple([(None, 2), (None, None), (3, 4), (12, 3), (None, )] ) == '[(None, 2), (3, 4), (12, 3)]'", "assert remove_tuple([(None, None), (None, None), (3, 6), (17, 3), (None,1 )] ) == '[(3, 6), (17, 3), (None, 1)]'", "assert remove_tuple([(1, 2), (2, None), (3, None), (24, 3), (None, None )] ) == '[(...
[]
770
Write a function to create a list taking alternate elements from another given list.
import math def sum_series(number): total = 0 total = math.pow((number * (number + 1)) /2, 2) return total
[ "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" ]
[]
761
Write a function to find the combinations of sums with tuples in the given tuple list.
def count_alpha_dig_spl(string): alphabets=digits = special = 0 for i in range(len(string)): if(string[i].isalpha()): alphabets = alphabets + 1 elif(string[i].isdigit()): digits = digits + 1 else: special = special + 1 return (alphabets,digits,special)
[ "assert count_reverse_pairs([\"julia\", \"best\", \"tseb\", \"for\", \"ailuj\"])== '2'", "assert count_reverse_pairs([\"geeks\", \"best\", \"for\", \"skeeg\"]) == '1'", "assert count_reverse_pairs([\"makes\", \"best\", \"sekam\", \"for\", \"rof\"]) == '2' " ]
[]
768
Write a function to find the nth delannoy number.
def mul_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'" ]
[]
880
Write a function to extract all the adjacent coordinates of the given coordinate tuple.
def Diff(li1,li2): return (list(list(set(li1)-set(li2)) + list(set(li2)-set(li1))))
[ "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'" ]
[]
602
Write a function to find length of the subarray having maximum sum.
def sorted_models(models): sorted_models = sorted(models, key = lambda x: x['color']) return sorted_models
[ "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'" ]
[]
717
Write a python function to move all zeroes to the end of the given list.
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_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" ]
[]
662
Write a function to calculate the sum of series 1³+2³+3³+….+n³.
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 sort_String(\"cba\") == \"abc\"", "assert sort_String(\"data\") == \"aadt\"", "assert sort_String(\"zxy\") == \"xyz\"" ]
[]
836
Write a function to check if the given tuple contains only k elements.
def convert(list): s = [str(i) for i in list] res = int("".join(s)) return (res)
[ "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" ]
[]
953
Write a python function to find sum of products of all possible subarrays.
import re def remove_parenthesis(items): for item in items: return (re.sub(r" ?\([^)]+\)", "", item))
[ "assert min_Swaps(\"0011\",\"1111\") == 1", "assert min_Swaps(\"00011\",\"01001\") == 2", "assert min_Swaps(\"111\",\"111\") == 0" ]
[]
629
Write a python function to check whether the product of numbers is even or not.
def validity_triangle(a,b,c): total = a + b + c if total == 180: return True else: return False
[ "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" ]
[]
765
Write a function to caluclate the area of a tetrahedron.
def binomial_coeffi(n, k): if (k == 0 or k == n): return 1 return (binomial_coeffi(n - 1, k - 1) + binomial_coeffi(n - 1, k)) def rencontres_number(n, m): if (n == 0 and m == 0): return 1 if (n == 1 and m == 0): return 0 if (m == 0): return ((n - 1) * (rencontres_number(n - 1, 0)+ renc...
[ "assert check_email(\"ankitrai326@gmail.com\") == 'Valid Email'", "assert check_email(\"my.ownsite@ourearth.org\") == 'Valid Email'", "assert check_email(\"ankitaoie326.com\") == 'Invalid Email'" ]
[]
644
Write a function to print the first n lucky numbers.
def is_odd(n) : if (n^1 == n-1) : return True; else : return False;
[ "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" ]
[]
718
Write a python function to choose points from two ranges such that no point lies in both the ranges.
def access_key(ditionary,key): return list(ditionary)[key]
[ "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 " ]
[]
874
Write a function to solve the fibonacci sequence using recursion.
def sort_numeric_strings(nums_str): result = [int(x) for x in nums_str] result.sort() return result
[ "assert left_insertion([1,2,4,5],6)==4", "assert left_insertion([1,2,4,5],3)==2", "assert left_insertion([1,2,4,5],7)==4" ]
[]
694
Write a function to find the minimum number of elements that should be removed such that amax-amin<=k.
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 occurance_substring('python programming, python language','python')==('python', 0, 6)", "assert occurance_substring('python programming,programming language','programming')==('programming', 7, 18)", "assert occurance_substring('python programming,programming language','language')==('language', 31, 39)" ...
[]
742
Write a function to find common index elements from three lists.
def clear_tuple(test_tup): temp = list(test_tup) temp.clear() test_tup = tuple(temp) return (test_tup)
[ "assert smallest_multiple(13)==360360", "assert smallest_multiple(2)==2", "assert smallest_multiple(1)==1" ]
[]
766
Write a function to remove duplicates from a list of lists.
def add_tuple(test_list, test_tup): test_list += test_tup return (test_list)
[ "assert first_repeated_char(\"abcabc\") == \"a\"", "assert first_repeated_char(\"abc\") == \"None\"", "assert first_repeated_char(\"123123\") == \"1\"" ]
[]
663
Write a python function to find the sum of non-repeated elements in a given array.
def increment_numerics(test_list, K): res = [str(int(ele) + K) if ele.isdigit() else ele for ele in test_list] return res
[ "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...
[]
890
Write a function to remove all characters except letters and numbers using regex
def lower_ctr(str): lower_ctr= 0 for i in range(len(str)): if str[i] >= 'a' and str[i] <= 'z': lower_ctr += 1 return lower_ctr
[ "assert is_Perfect_Square(10) == False", "assert is_Perfect_Square(36) == True", "assert is_Perfect_Square(14) == False" ]
[]
691
Write a function to find the list in a list of lists whose sum of elements is the highest.
def remove_negs(num_list): for item in num_list: if item < 0: num_list.remove(item) return num_list
[ "assert word_len(\"program\") == False", "assert word_len(\"solution\") == True", "assert word_len(\"data\") == True" ]
[]
879
Write a function to remove the nested record from the given tuple.
def sum_Natural(n): sum = (n * (n + 1)) return int(sum) def sum_Even(l,r): return (sum_Natural(int(r / 2)) - sum_Natural(int((l - 1) / 2)))
[ "assert 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" ]
[]
885
Write a function to find the nth jacobsthal number.
import re def match_num(string): text = re.compile(r"^5") if text.match(string): return True else: return False
[ "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...
[]
870
Write a function to get an item of a tuple.
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...
[]
655
Write a python function to convert a list of multiple integers into a single integer.
def min_difference(test_list): temp = [abs(b - a) for a, b in test_list] res = min(temp) return (res)
[ "assert generate_matrix(3)==[[1, 2, 3], [8, 9, 4], [7, 6, 5]] ", "assert generate_matrix(2)==[[1,2],[4,3]]", "assert generate_matrix(7)==[[1, 2, 3, 4, 5, 6, 7], [24, 25, 26, 27, 28, 29, 8], [23, 40, 41, 42, 43, 30, 9], [22, 39, 48, 49, 44, 31, 10], [21, 38, 47, 46, 45, 32, 11], [20, 37, 36, 35, 34, 33, 12], [19...
[]
950
Write a function to remove multiple spaces in 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 same_Length(12,1) == False", "assert same_Length(2,2) == True", "assert same_Length(10,20) == True" ]
[]
968
Write a python function to find the kth element in an array containing odd elements first and then even elements.
def div_of_nums(nums,m,n): result = list(filter(lambda x: (x % m == 0 or x % n == 0), nums)) return result
[ "assert rectangle_perimeter(10,20)==60", "assert rectangle_perimeter(10,5)==30", "assert rectangle_perimeter(4,2)==12" ]
[]
863
Write a python function to find the minimum difference between any two elements in a given array.
def nth_nums(nums,n): nth_nums = list(map(lambda x: x ** n, nums)) return nth_nums
[ "assert text_starta_endb(\"aabbbb\")==('Found a match!')", "assert text_starta_endb(\"aabAbbbc\")==('Not matched!')", "assert text_starta_endb(\"accddbbjjj\")==('Not matched!')" ]
[]
904
Write a function to count the number of inversions in the given array.
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 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" ]
[]
809
Write a python function to remove even numbers from a given list.
from itertools import groupby def pack_consecutive_duplicates(list1): return [list(group) for key, group in groupby(list1)]
[ "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]" ]
[]
708
Write a function to generate all sublists of a given list.
def Odd_Length_Sum(arr): Sum = 0 l = len(arr) for i in range(l): Sum += ((((i + 1) *(l - i) + 1) // 2) * arr[i]) return Sum
[ "assert 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)" ]
[]
908
Write a function to find length of the string.
import re def remove_char(S): result = re.sub('[\W_]+', '', S) return result
[ "assert str_to_tuple(\"1, -5, 4, 6, 7\") == (1, -5, 4, 6, 7)", "assert str_to_tuple(\"1, 2, 3, 4, 5\") == (1, 2, 3, 4, 5)", "assert str_to_tuple(\"4, 6, 9, 11, 13, 14\") == (4, 6, 9, 11, 13, 14)" ]
[]
676
Write a python function to find the minimum sum of absolute differences of two arrays.
def even_num(x): if x%2==0: return True else: return False
[ "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]" ]
[]
909
Write a function to remove consecutive duplicates of a given list.
import re def replace_specialchar(text): return (re.sub("[ ,.]", ":", text))
[ "assert previous_palindrome(99)==88", "assert previous_palindrome(1221)==1111", "assert previous_palindrome(120)==111" ]
[]
875
Write a python function to calculate the product of all the numbers of a given tuple.
def check_identical(test_list1, test_list2): res = test_list1 == test_list2 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" ]
[]
826
Write a function to count number of unique lists within a list.
def pair_wise(l1): temp = [] for i in range(len(l1) - 1): current_element, next_element = l1[i], l1[i + 1] x = (current_element, next_element) temp.append(x) return temp
[ "assert 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" ]
[]
782
Write a python function to convert a string to a list.
def mutiple_tuple(nums): temp = list(nums) product = 1 for x in temp: product *= x return product
[ "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" ]
[]
709
Write a function to multiply two lists using map and lambda function.
import re def text_match_zero_one(text): patterns = 'ab?' if re.search(patterns, text): return 'Found a match!' else: return('Not matched!')
[ "assert get_Number(8,5) == 2", "assert get_Number(7,2) == 3", "assert get_Number(5,2) == 3" ]
[]
669
Write a function to convert camel case string to snake case string by using regex.
def min_Swaps(s1,s2) : c0 = 0; c1 = 0; for i in range(len(s1)) : if (s1[i] == '0' and s2[i] == '1') : c0 += 1; elif (s1[i] == '1' and s2[i] == '0') : c1 += 1; result = c0 // 2 + c1 // 2; if (c0 % 2 == 0 and c1 % 2 == 0) : return r...
[ "assert combine_lists([1, 3, 5, 7, 9, 11],[0, 2, 4, 6, 8, 10])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]", "assert combine_lists([1, 3, 5, 6, 8, 9], [2, 5, 7, 11])==[1,2,3,5,5,6,7,8,9,11]", "assert combine_lists([1,3,7],[2,4,6])==[1,2,3,4,6,7]" ]
[]
653
Write a function to rotate a given list by specified number of items to the right direction.
def merge(lst): return [list(ele) for ele in list(zip(*lst))]
[ "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]" ]
[]
938
Write a function to push all values into a heap and then pop off the smallest values one at a time.
def area_trapezium(base1,base2,height): area = 0.5 * (base1 + base2) * height return area
[ "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'}...
[]
End of preview. Expand in Data Studio

edition_3124_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
13