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
639
Write a function to remove an empty tuple from a list of tuples.
def profit_amount(actual_cost,sale_amount): if(actual_cost > sale_amount): amount = actual_cost - sale_amount return amount else: return None
[ "assert max_sum_of_three_consecutive([100, 1000, 100, 1000, 1], 5) == 2101", "assert max_sum_of_three_consecutive([3000, 2000, 1000, 3, 10], 5) == 5013", "assert max_sum_of_three_consecutive([1, 2, 3, 4, 5, 6, 7, 8], 8) == 27" ]
[]
601
Write a python function to find the minimun number of subsets with distinct elements.
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 profit_amount(1500,1200)==300", "assert profit_amount(100,200)==None", "assert profit_amount(2000,5000)==None" ]
[]
757
Write a python function to check whether the count of divisors is even or odd.
def rectangle_perimeter(l,b): perimeter=2*(l+b) return perimeter
[ "assert last_Two_Digits(7) == 40", "assert last_Two_Digits(5) == 20", "assert last_Two_Digits(2) == 2" ]
[]
638
Write a function to count repeated items of a tuple.
def Check_Vow(string, vowels): final = [each for each in string if each in vowels] return(len(final))
[ "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]" ]
[]
621
Write a function to flatten the given tuple matrix into the tuple list with each tuple representing each column.
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 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)" ]
[]
921
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 text_match(text): patterns = 'ab*?' if re.search(patterns, text): return 'Found a match!' else: return('Not matched!')
[ "assert check_smaller((1, 2, 3), (2, 3, 4)) == False", "assert check_smaller((4, 5, 6), (3, 4, 5)) == True", "assert check_smaller((11, 12, 13), (10, 11, 12)) == True" ]
[]
725
Write a function to remove the nested record from the given tuple.
def new_tuple(test_list, test_str): res = tuple(test_list + [test_str]) return (res)
[ "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" ]
[]
708
Write a function to find the nth super ugly number from a given prime list of size k using heap queue algorithm.
def max_sum_subseq(A): n = len(A) if n == 1: return A[0] look_up = [None] * n look_up[0] = A[0] look_up[1] = max(A[0], A[1]) for i in range(2, n): look_up[i] = max(look_up[i - 1], look_up[i - 2] + A[i]) look_up[i] = max(look_up[i], A[i]) return look_up[n - 1]
[ "assert discriminant_value(4,8,2)==(\"Two solutions\",32)", "assert discriminant_value(5,7,9)==(\"no real solution\",-131)", "assert discriminant_value(0,0,9)==(\"one solution\",0)" ]
[]
637
Write a function to check whether the given string is starting with a vowel or not using regex.
def convert(list): s = [str(i) for i in list] res = int("".join(s)) return (res)
[ "assert max_occurrences([2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,4,6,9,1,2])==2", "assert max_occurrences([1, 3,5, 7,1, 3,13, 15, 17,5, 7,9,1, 11])==1", "assert max_occurrences([1, 2, 3,2, 4, 5,1, 1, 1])==1" ]
[]
937
Write a function to find n-th rencontres number.
def slope(x1,y1,x2,y2): return (float)(y2-y1)/(x2-x1)
[ "assert get_noOfways(4)==3", "assert get_noOfways(3)==2", "assert get_noOfways(5)==5" ]
[]
874
Write a python function to find number of solutions in quadratic equation.
import math def find_Index(n): x = math.sqrt(2 * math.pow(10,(n - 1))); return round(x);
[ "assert test_three_equal(1,1,1) == 3", "assert test_three_equal(-1,-2,-3) == 0", "assert test_three_equal(1,2,2) == 2" ]
[]
816
Write a python function to check whether the given two arrays are equal or not.
def left_rotate(s,d): tmp = s[d : ] + s[0 : d] return tmp
[ "assert check_alphanumeric(\"dawood@\") == 'Discard'", "assert check_alphanumeric(\"skdmsam326\") == 'Accept'", "assert check_alphanumeric(\"cooltricks@\") == 'Discard'" ]
[]
632
Write a function to sort a given list of strings of numbers numerically.
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 : return ("Odd")
[ "assert recur_gcd(12,14) == 2", "assert recur_gcd(13,17) == 1", "assert recur_gcd(9, 3) == 3" ]
[]
696
Write a function to calculate the perimeter of a regular polygon.
def check_subset(list1,list2): return all(map(list1.__contains__,list2))
[ "assert word_len(\"program\") == False", "assert word_len(\"solution\") == True", "assert word_len(\"data\") == True" ]
[]
884
Write a python function to get the difference between two lists.
def remove_duplic_list(l): temp = [] for x in l: if x not in temp: temp.append(x) return temp
[ "assert raw_heap([25, 44, 68, 21, 39, 23, 89])==[21, 25, 23, 44, 39, 68, 89]", "assert raw_heap([25, 35, 22, 85, 14, 65, 75, 25, 58])== [14, 25, 22, 25, 35, 65, 75, 85, 58]", "assert raw_heap([4, 5, 6, 2])==[2, 4, 6, 5]" ]
[]
699
Write a python function to remove negative numbers from a list.
def even_num(x): if x%2==0: return True else: return False
[ "assert join_tuples([(5, 6), (5, 7), (6, 8), (6, 10), (7, 13)] ) == [(5, 6, 7), (6, 8, 10), (7, 13)]", "assert join_tuples([(6, 7), (6, 8), (7, 9), (7, 11), (8, 14)] ) == [(6, 7, 8), (7, 9, 11), (8, 14)]", "assert join_tuples([(7, 8), (7, 9), (8, 10), (8, 12), (9, 15)] ) == [(7, 8, 9), (8, 10, 12), (9, 15)]" ]
[]
922
Write a function to find out the second most repeated (or frequent) string in the given sequence.
def len_log(list1): min=len(list1[0]) for i in list1: if len(i)<min: min=len(i) return min
[ "assert pair_OR_Sum([5,9,7,6],4) == 47", "assert pair_OR_Sum([7,3,5],3) == 12", "assert pair_OR_Sum([7,3],2) == 4" ]
[]
771
Write a python function to find minimum possible value for the given periodic function.
def find_Min_Sum(a,b,n): a.sort() b.sort() sum = 0 for i in range(n): sum = sum + abs(a[i] - b[i]) return sum
[ "assert 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]" ]
[]
721
Write a function to count the most common character 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 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], [9, 11], [13, 14, 15, 17]],0,7)==[[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7]]" ]
[]
931
Write a function to add two lists using map and lambda function.
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 rombus_area(10,20)==100", "assert rombus_area(10,5)==25", "assert rombus_area(4,2)==4" ]
[]
644
Write a function to check if each element of the second tuple is greater than its corresponding index in the first tuple.
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 parallelogram_perimeter(10,20)==400", "assert parallelogram_perimeter(15,20)==600", "assert parallelogram_perimeter(8,9)==144" ]
[]
854
Write a function to find the nth jacobsthal number.
def harmonic_sum(n): if n < 2: return 1 else: return 1 / n + (harmonic_sum(n - 1))
[ "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)" ]
[]
713
Write a function to find the greatest common divisor (gcd) of two integers by using recursion.
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 is_polite(7) == 11", "assert is_polite(4) == 7", "assert is_polite(9) == 13" ]
[]
760
Write a python function to count the number of equal numbers from three given integers.
import math def get_First_Set_Bit_Pos(n): return math.log2(n&-n)+1
[ "assert count_Fac(24) == 3", "assert count_Fac(12) == 2", "assert count_Fac(4) == 1" ]
[]
758
Write a function to return true if the password is valid.
def series_sum(number): total = 0 total = (number * (number + 1) * (2 * number + 1)) / 6 return total
[ "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" ]
[]
835
Write a function to remove all tuples with all none values in the given tuple list.
def decreasing_trend(nums): if (sorted(nums)== nums): return True else: return False
[ "assert Check_Vow('corner','AaEeIiOoUu') == 2", "assert Check_Vow('valid','AaEeIiOoUu') == 2", "assert Check_Vow('true','AaEeIiOoUu') ==2" ]
[]
652
Write a python function to check whether every even index contains even numbers of a given list.
import math def find_Digits(n): if (n < 0): return 0; if (n <= 1): return 1; x = ((n * math.log10(n / math.e) + math.log10(2 * math.pi * n) /2.0)); return math.floor(x) + 1;
[ "assert get_First_Set_Bit_Pos(12) == 3", "assert get_First_Set_Bit_Pos(18) == 2", "assert get_First_Set_Bit_Pos(16) == 5" ]
[]
826
Write a function to find the smallest multiple of the first n numbers.
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 get_Number(8,5) == 2", "assert get_Number(7,2) == 3", "assert get_Number(5,2) == 3" ]
[]
891
Write a function to convert an integer into a roman numeral.
import re def text_match(text): patterns = 'ab*?' if re.search(patterns, text): return ('Found a match!') else: return ('Not matched!')
[ "assert left_Rotate(16,2) == 64", "assert left_Rotate(10,2) == 40", "assert left_Rotate(99,3) == 792" ]
[]
651
Write a python function to toggle bits of the number except the first and the last bit.
import re def extract_max(input): numbers = re.findall('\d+',input) numbers = map(int,numbers) return max(numbers)
[ "assert extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[1, 7]", "assert extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 6, 5],[0, 1, 2, 3, 4, 6, 7])==[1, 6]", "assert extract_index_list([1, 1, 3, 4, 6, 5, 6],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[1, 5]" ]
[]
636
Write a function to count unique keys for each value present in the tuple.
def floor_Min(A,B,N): x = max(B - 1,N) return (A*x) // B
[ "assert rearrange_numbs([-1, 2, -3, 5, 7, 8, 9, -10])==[2, 5, 7, 8, 9, -10, -3, -1]", "assert rearrange_numbs([10,15,14,13,-18,12,-20])==[10, 12, 13, 14, 15, -20, -18]", "assert rearrange_numbs([-20,20,-10,10,-30,30])==[10, 20, 30, -30, -20, -10]" ]
[]
759
Write a python function to check whether the given two numbers have same number of digits or not.
def length_Of_Last_Word(a): l = 0 x = a.strip() for i in range(len(x)): if x[i] == " ": l = 0 else: l += 1 return l
[ "assert 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" ]
[]
641
Write a function to sort a list of lists by length and value.
def reverse_words(s): return ' '.join(reversed(s.split()))
[ "assert is_Two_Alter(\"abab\") == True", "assert is_Two_Alter(\"aaaa\") == False", "assert is_Two_Alter(\"xyz\") == False" ]
[]
693
Write a function to add two integers. however, if the sum is between the given range it will return 20.
def count_list(input_list): return (len(input_list))**2
[ "assert lower_ctr('abc') == 3", "assert lower_ctr('string') == 6", "assert lower_ctr('Python') == 5" ]
[]
698
Write a function to convert camel case string to snake case string.
import sys def find_max_val(n, x, y): ans = -sys.maxsize for k in range(n + 1): if (k % x == y): ans = max(ans, k) return (ans if (ans >= 0 and ans <= n) else -1)
[ "assert remove_extra_char('**//Google Android// - 12. ') == 'GoogleAndroid12'", "assert remove_extra_char('****//Google Flutter//*** - 36. ') == 'GoogleFlutter36'", "assert remove_extra_char('**//Google Firebase// - 478. ') == 'GoogleFirebase478'" ]
[]
946
Write a function to find the maximum of nth column from the given tuple list.
def find_triplet_array(A, arr_size, sum): for i in range( 0, arr_size-2): for j in range(i + 1, arr_size-1): for k in range(j + 1, arr_size): if A[i] + A[j] + A[k] == sum: return A[i],A[j],A[k] return True 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\" : 4, \"Okay\" : 5} ) == (8, 9, 10, {'POS': 3, 'is': 4, 'Okay': 5})" ]
[]
936
Write a function to access the initial and last data of the given tuple record.
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 _sum([1, 2, 3]) == 6", "assert _sum([15, 12, 13, 10]) == 50", "assert _sum([0, 1, 2]) == 3" ]
[]
882
Write a python function to find the first repeated character in a given string.
def heap_sort(arr): heapify(arr) end = len(arr) - 1 while end > 0: arr[end], arr[0] = arr[0], arr[end] shift_down(arr, 0, end - 1) end -= 1 return arr def heapify(arr): start = len(arr) // 2 while start >= 0: shift_down(arr, start, len(arr) - 1) start -= 1 def shift_down(arr, start, end): root = start while root * 2 + 1 <= end: child = root * 2 + 1 if child + 1 <= end and arr[child] < arr[child + 1]: child += 1 if child <= end and arr[root] < arr[child]: arr[root], arr[child] = arr[child], arr[root] root = child else: return
[ "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" ]
[]
650
Write a function to convert the given tuple to a key-value dictionary using adjacent elements.
import re def text_match_zero_one(text): patterns = 'ab?' if re.search(patterns, text): return 'Found a match!' else: return('Not matched!')
[ "assert cummulative_sum([(1, 3), (5, 6, 7), (2, 6)]) == 30", "assert cummulative_sum([(2, 4), (6, 7, 8), (3, 7)]) == 37", "assert cummulative_sum([(3, 5), (7, 8, 9), (4, 8)]) == 44" ]
[]
954
Write a function to print n-times a list using map function.
def count_Unset_Bits(n) : cnt = 0; for i in range(1,n + 1) : temp = i; while (temp) : if (temp % 2 == 0) : cnt += 1; temp = temp // 2; return cnt;
[ "assert check_monthnumb(\"February\")==False", "assert check_monthnumb(\"January\")==True", "assert check_monthnumb(\"March\")==True" ]
[]
939
Write a function to find common index elements from three lists.
def remove_empty(tuple1): #L = [(), (), ('',), ('a', 'b'), ('a', 'b', 'c'), ('d')] tuple1 = [t for t in tuple1 if t] return tuple1
[ "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" ]
[]
762
Write a function that matches a string that has an a followed by zero or one 'b'.
def remove_tuple(test_list): res = [sub for sub in test_list if not all(ele == None for ele in sub)] return (str(res))
[ "assert find_platform([900, 940, 950, 1100, 1500, 1800],[910, 1200, 1120, 1130, 1900, 2000],6)==3", "assert find_platform([100,200,300,400],[700,800,900,1000],4)==4", "assert find_platform([5,6,7,8],[4,3,2,1],4)==1" ]
[]
779
Write a function to find the equilibrium index of the given array.
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 get_item((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),3)==('e')", "assert get_item((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),-4)==('u')", "assert get_item((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),-3)==('r')" ]
[]
833
Write a python function to sort the given string.
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 geometric_sum(7) == 1.9921875", "assert geometric_sum(4) == 1.9375", "assert geometric_sum(8) == 1.99609375" ]
[]
788
Write a python function to count occurences of a character in a repeated string.
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 harmonic_sum(10)==2.9289682539682538", "assert harmonic_sum(4)==2.083333333333333", "assert harmonic_sum(7)==2.5928571428571425 " ]
[]
824
Write a function to split the given string at uppercase letters by using regex.
import math def is_polite(n): n = n + 1 return (int)(n+(math.log((n + math.log(n, 2)), 2)))
[ "assert access_elements([2,3,8,4,7,9],[0,3,5]) == [2, 4, 9]", "assert access_elements([1, 2, 3, 4, 5],[1,2]) == [2,3]", "assert access_elements([1,0,2,3],[0,1]) == [1,0]" ]
[]
753
Write a function to generate a square matrix filled with elements from 1 to n raised to the power of 2 in spiral order.
def move_last(num_list): a = [num_list[0] for i in range(num_list.count(num_list[0]))] x = [ i for i in num_list if i != num_list[0]] x.extend(a) return (x)
[ "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')" ]
[]
809
Write a python function to find the last two digits in factorial of a given number.
import re def pass_validity(p): x = True while x: if (len(p)<6 or len(p)>12): break elif not re.search("[a-z]",p): break elif not re.search("[0-9]",p): break elif not re.search("[A-Z]",p): break elif not re.search("[$#@]",p): break elif re.search("\s",p): break else: return True x=False break if x: 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] " ]
[]
711
Write a function to find the minimum difference in the tuple pairs of given tuples.
from collections import OrderedDict def remove_duplicate(string): result = ' '.join(OrderedDict((w,w) for w in string.split()).keys()) return result
[ "assert remove_negs([1,-2,3,-4]) == [1,3]", "assert remove_negs([1,2,3,-4]) == [1,2,3]", "assert remove_negs([4,5,-6,7,-8]) == [4,5,7]" ]
[]
849
Write a function to put spaces between words starting with capital letters in a given string by using regex.
def lcs_of_three(X, Y, Z, m, n, o): L = [[[0 for i in range(o+1)] for j in range(n+1)] for k in range(m+1)] for i in range(m+1): for j in range(n+1): for k in range(o+1): if (i == 0 or j == 0 or k == 0): L[i][j][k] = 0 elif (X[i-1] == Y[j-1] and X[i-1] == Z[k-1]): L[i][j][k] = L[i-1][j-1][k-1] + 1 else: L[i][j][k] = max(max(L[i-1][j][k], L[i][j-1][k]), L[i][j][k-1]) return L[m][n][o]
[ "assert min_sum_path([[ 2 ], [3, 9 ], [1, 6, 7 ]]) == 6", "assert min_sum_path([[ 2 ], [3, 7 ], [8, 5, 6 ]]) == 10 ", "assert min_sum_path([[ 3 ], [6, 4 ], [5, 2, 7 ]]) == 9" ]
[]
631
Write a function to sort the tuples alphabetically by the first item of each tuple.
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 int_to_roman(1)==(\"I\")", "assert int_to_roman(50)==(\"L\")", "assert int_to_roman(4)==(\"IV\")" ]
[]
710
Write a function to remove duplicate words from a given list of strings.
import re def replace(string, char): pattern = char + '{2,}' string = re.sub(pattern, char, string) return string
[ "assert sum_Square(25) == True", "assert sum_Square(24) == False", "assert sum_Square(17) == True" ]
[]
890
Write a python function to count numeric values in a given string.
import re def text_match(text): patterns = 'a.*?b$' if re.search(patterns, text): return ('Found a match!') else: return ('Not matched!')
[ "assert swap_List([1,2,3]) == [3,2,1]", "assert swap_List([1,2,3,4,4]) == [4,2,3,4,1]", "assert swap_List([4,5,6]) == [6,5,4]" ]
[]
825
Write a python function to move all zeroes to the end of the given list.
import re def split_list(text): return (re.findall('[A-Z][^A-Z]*', text))
[ "assert count_Set_Bits(16) == 33", "assert count_Set_Bits(2) == 2", "assert count_Set_Bits(14) == 28" ]
[]
900
Write a python function to find the sum of fourth power of first n odd natural numbers.
def Check_Solution(a,b,c): if (a == c): return ("Yes"); else: return ("No");
[ "assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],3,4)==[8, 9, 10, 1, 2, 3, 4, 5, 6]", "assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],2,2)==[9, 10, 1, 2, 3, 4, 5, 6, 7, 8]", "assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],5,2)==[6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8]" ]
[]
968
Write a function to count coin change.
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 powerOf2 <<= 1; return cnt;
[ "assert count_Unset_Bits(2) == 1", "assert count_Unset_Bits(5) == 4", "assert count_Unset_Bits(14) == 17" ]
[]
604
Write a function to find the length of the shortest string that has both str1 and str2 as subsequences.
def reverse_Array_Upto_K(input, k): return (input[k-1::-1] + input[k:])
[ "assert find_Index(2) == 4", "assert find_Index(3) == 14", "assert find_Index(4) == 45" ]
[]
730
Write a python function to remove even numbers from a given list.
import re regex = '^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w{2,3}$' def check_email(email): if(re.search(regex,email)): return ("Valid Email") else: return ("Invalid Email")
[ "assert 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" ]
[]
685
Write a function to iterate over elements repeating each as many times as its count.
def str_to_tuple(test_str): res = tuple(map(int, test_str.split(', '))) return (res)
[ "assert sum_num((8, 2, 3, 0, 7))==4.0", "assert sum_num((-10,-20,-30))==-20.0", "assert sum_num((19,15,18))==17.333333333333332" ]
[]
886
Write a function to rotate a given list by specified number of items to the right direction.
def pair_OR_Sum(arr,n) : ans = 0 for i in range(0,n) : for j in range(i + 1,n) : ans = ans + (arr[i] ^ arr[j]) return ans
[ "assert max_char(\"hello world\")==('l')", "assert max_char(\"hello \")==('l')", "assert max_char(\"python pr\")==('p')" ]
[]
792
Write a function to find the maximum sum of subsequences of given array with no adjacent elements.
INT_BITS = 32 def left_Rotate(n,d): return (n << d)|(n >> (INT_BITS - d))
[ "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, 2], [3, 4], [4, 5], [6, 7]])=={(1, 2): 1, (3, 4): 1, (4, 5): 1, (6, 7): 1}" ]
[]
837
Write a function to remove duplicates from a list of lists.
from collections import Counter def second_frequent(input): dict = Counter(input) value = sorted(dict.values(), reverse=True) second_large = value[1] for (key, val) in dict.items(): if val == second_large: return (key)
[ "assert clear_tuple((1, 5, 3, 6, 8)) == ()", "assert clear_tuple((2, 1, 4 ,5 ,6)) == ()", "assert clear_tuple((3, 2, 5, 6, 8)) == ()" ]
[]
715
Write a function to pack consecutive duplicates of a given list elements into sublists.
def rombus_area(p,q): area=(p*q)/2 return area
[ "assert roman_to_int('MMMCMLXXXVI')==3986", "assert roman_to_int('MMMM')==4000", "assert roman_to_int('C')==100" ]
[]
853
Write a function to divide two lists using map and lambda function.
import re regex = '''^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.( 25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.( 25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.( 25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$''' def check_IP(Ip): if(re.search(regex, Ip)): return ("Valid IP address") else: return ("Invalid IP address")
[ "assert floor_Min(10,20,30) == 15", "assert floor_Min(1,2,1) == 0", "assert floor_Min(11,10,9) == 9" ]
[]
871
Write a function to find the minimum number of platforms required for a railway/bus station.
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 decreasing_trend([-4,-3,-2,-1]) == True", "assert decreasing_trend([1,2,3]) == True", "assert decreasing_trend([3,2,1]) == False" ]
[]
737
Write a python function to remove spaces from a given string.
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 text_match(\"aabbbbd\") == 'Not matched!'", "assert text_match(\"aabAbbbc\") == 'Not matched!'", "assert text_match(\"accddbbjjjb\") == 'Found a match!'" ]
[]
717
Write a function to find numbers divisible by m or n from a list of numbers using lambda function.
def div_list(nums1,nums2): result = map(lambda x, y: x / y, nums1, nums2) return list(result)
[ "assert find_Digits(7) == 4", "assert find_Digits(5) == 3", "assert find_Digits(4) == 2" ]
[]
769
Write a function to join the tuples if they have similar initial elements.
import math def area_tetrahedron(side): area = math.sqrt(3)*(side*side) return area
[ "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'" ]
[]
755
Write a function to sum a specific column of a list in a given list of lists.
def nth_nums(nums,n): nth_nums = list(map(lambda x: x ** n, nums)) return nth_nums
[ "assert sum_series(7)==784", "assert sum_series(5)==225", "assert sum_series(15)==14400" ]
[]
846
Write a function to remove duplicate words from a given string using collections module.
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 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]" ]
[]
950
Write a function to calculate the sum of all digits of the base to the specified power.
def is_triangleexists(a,b,c): if(a != 0 and b != 0 and c != 0 and (a + b + c)== 180): if((a + b)>= c or (b + c)>= a or (a + c)>= b): return True else: return False else: return False
[ "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" ]
[]
949
Write a function to find three closest elements from three sorted arrays.
def remove_negs(num_list): for item in num_list: if item < 0: num_list.remove(item) return num_list
[ "assert road_rd(\"ravipadu Road\")==('ravipadu Rd.')", "assert road_rd(\"palnadu Road\")==('palnadu Rd.')", "assert road_rd(\"eshwar enclave Road\")==('eshwar enclave Rd.')" ]
[]
817
Write a python function to find the smallest prime divisor of a number.
def all_Characters_Same(s) : n = len(s) for i in range(1,n) : if s[i] != s[0] : return False return True
[ "assert reverse_Array_Upto_K([1, 2, 3, 4, 5, 6],4) == [4, 3, 2, 1, 5, 6]", "assert reverse_Array_Upto_K([4, 5, 6, 7], 2) == [5, 4, 6, 7]", "assert reverse_Array_Upto_K([9, 8, 7, 6, 5],3) == [7, 8, 9, 6, 5]" ]
[]
731
Write a python function to find sum of odd factors of a number.
import re def extract_date(url): return re.findall(r'/(\d{4})/(\d{1,2})/(\d{1,2})/', url)
[ "assert sort_tuple([(\"Amana\", 28), (\"Zenat\", 30), (\"Abhishek\", 29),(\"Nikhil\", 21), (\"B\", \"C\")]) == [('Abhishek', 29), ('Amana', 28), ('B', 'C'), ('Nikhil', 21), ('Zenat', 30)]", "assert sort_tuple([(\"aaaa\", 28), (\"aa\", 30), (\"bab\", 29), (\"bb\", 21), (\"csa\", \"C\")]) == [('aa', 30), ('aaaa', 28), ('bab', 29), ('bb', 21), ('csa', 'C')]", "assert sort_tuple([(\"Sarala\", 28), (\"Ayesha\", 30), (\"Suman\", 29),(\"Sai\", 21), (\"G\", \"H\")]) == [('Ayesha', 30), ('G', 'H'), ('Sai', 21), ('Sarala', 28), ('Suman', 29)]" ]
[]
889
Write a function to check if the given tuple contains only k elements.
def maximum_segments(n, a, b, c) : dp = [-1] * (n + 10) dp[0] = 0 for i in range(0, n) : if (dp[i] != -1) : if(i + a <= n ): dp[i + a] = max(dp[i] + 1, dp[i + a]) if(i + b <= n ): dp[i + b] = max(dp[i] + 1, dp[i + b]) if(i + c <= n ): dp[i + c] = max(dp[i] + 1, dp[i + c]) return dp[n]
[ "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" ]
[]
943
Write a function to calculate the sum of the positive numbers of a given list of numbers using lambda function.
def parallelogram_perimeter(b,h): perimeter=2*(b*h) return perimeter
[ "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\"" ]
[]
972
Write a function to group the 1st elements on the basis of 2nd elements in the given tuple list.
import re def match_num(string): text = re.compile(r"^5") if text.match(string): return True else: return False
[ "assert prime_num(13)==True", "assert prime_num(7)==True", "assert prime_num(-1010)==False" ]
[]
720
Write a python function to check whether the given number is a perfect square or not.
from collections import Counter import re def n_common_words(text,n): words = re.findall('\w+',text) n_common_words= Counter(words).most_common(n) return list(n_common_words)
[ "assert remove_spaces(\"a b c\") == \"abc\"", "assert remove_spaces(\"1 2 3\") == \"123\"", "assert remove_spaces(\" b c\") == \"bc\"" ]
[]
906
Write a python function to count number of cubes of size k in a cube of size n.
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 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" ]
[]
716
Write a python function to copy a list from a singleton tuple.
from collections import Counter def most_common_elem(s,a): most_common_elem=Counter(s).most_common(a) return most_common_elem
[ "assert cube_Sum(2) == 28", "assert cube_Sum(3) == 153", "assert cube_Sum(4) == 496" ]
[]
610
Write a python function to find the first digit in factorial of a given number.
def min_sum_path(A): memo = [None] * len(A) n = len(A) - 1 for i in range(len(A[n])): memo[i] = A[n][i] for i in range(len(A) - 2, -1,-1): for j in range( len(A[i])): memo[j] = A[i][j] + min(memo[j], memo[j + 1]) return memo[0]
[ "assert reverse_list_lists([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]])==[[4, 3, 2, 1], [8, 7, 6, 5], [12, 11, 10, 9], [16, 15, 14, 13]]", "assert reverse_list_lists([[1,2],[2,3],[3,4]])==[[2,1],[3,2],[4,3]]", "assert reverse_list_lists([[10,20],[30,40]])==[[20,10],[40,30]]" ]
[]
898
Write a python function to find the minimum difference between any two elements in a given array.
def Check_Solution(a,b,c) : if ((b*b) - (4*a*c)) > 0 : return ("2 solutions") elif ((b*b) - (4*a*c)) == 0 : return ("1 solution") else : return ("No solutions")
[ "assert rgb_to_hsv(255, 255, 255)==(0, 0.0, 100.0)", "assert rgb_to_hsv(0, 215, 0)==(120.0, 100.0, 84.31372549019608)", "assert rgb_to_hsv(10, 215, 110)==(149.26829268292684, 95.34883720930233, 84.31372549019608)" ]
[]
838
Write a function to find the largest subset where each pair is divisible.
def palindrome_lambda(texts): result = list(filter(lambda x: (x == "".join(reversed(x))), texts)) return result
[ "assert round_up(123.01247,0)==124", "assert round_up(123.01247,1)==123.1", "assert round_up(123.01247,2)==123.02" ]
[]
839
Write a python function to check whether the two given strings are isomorphic to each other or not.
import re def replace_specialchar(text): return (re.sub("[ ,.]", ":", text))
[ "assert is_upper(\"person\") ==\"PERSON\"", "assert is_upper(\"final\") == \"FINAL\"", "assert is_upper(\"Valid\") == \"VALID\"" ]
[]
868
Write a function to check whether the given key is present in the dictionary 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 check_email(\"[email protected]\") == 'Valid Email'", "assert check_email(\"[email protected]\") == 'Valid Email'", "assert check_email(\"ankitaoie326.com\") == 'Invalid Email'" ]
[]
798
Write a function to find length of the subarray having maximum sum.
def get_key(dict): list = [] for key in dict.keys(): list.append(key) return list
[ "assert find_fixed_point([-10, -1, 0, 3, 10, 11, 30, 50, 100],9) == 3", "assert find_fixed_point([1, 2, 3, 4, 5, 6, 7, 8],8) == -1", "assert find_fixed_point([0, 2, 5, 8, 17],5) == 0" ]
[]
864
Write a python function to find maximum possible value for the given periodic function.
def string_length(str1): count = 0 for char in str1: count += 1 return count
[ "assert lucky_num(10)==[1, 3, 7, 9, 13, 15, 21, 25, 31, 33] ", "assert lucky_num(5)==[1, 3, 7, 9, 13]", "assert lucky_num(8)==[1, 3, 7, 9, 13, 15, 21, 25]" ]
[]
862
Write a python function to accept the strings which contains all vowels.
def float_to_tuple(test_str): res = tuple(map(float, test_str.split(', '))) return (res)
[ "assert max_run_uppercase('GeMKSForGERksISBESt') == 5", "assert max_run_uppercase('PrECIOusMOVemENTSYT') == 6", "assert max_run_uppercase('GooGLEFluTTER') == 4" ]
[]
933
Write a function to find the index of the first occurrence of a given number in a sorted array.
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 even_num(13.5)==False", "assert even_num(0)==True", "assert even_num(-9)==False" ]
[]
789
Write a python function to interchange first and last elements in a given list.
def discriminant_value(x,y,z): discriminant = (y**2) - (4*x*z) if discriminant > 0: return ("Two solutions",discriminant) elif discriminant == 0: return ("one solution",discriminant) elif discriminant < 0: return ("no real solution",discriminant)
[ "assert Odd_Length_Sum([1,2,4]) == 14", "assert Odd_Length_Sum([1,2,1,2]) == 15", "assert Odd_Length_Sum([1,7]) == 8" ]
[]
883
Write a python function to find the average of a list.
def lcopy(xs): return xs[:]
[ "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]" ]
[]
704
Write a function to remove similar rows from the given tuple matrix.
import cmath def len_complex(a,b): cn=complex(a,b) length=abs(cn) return length
[ "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" ]
[]
806
Write a function to count the number of elements in a list which are within a specific range.
import re def remove_char(S): result = re.sub('[\W_]+', '', S) return result
[ "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, 18, 17, 16, 15, 14, 13]]" ]
[]
944
Write a function to caluclate perimeter of a parallelogram.
from sys import maxsize def max_sub_array_sum(a,size): max_so_far = -maxsize - 1 max_ending_here = 0 start = 0 end = 0 s = 0 for i in range(0,size): max_ending_here += a[i] if max_so_far < max_ending_here: max_so_far = max_ending_here start = s end = i if max_ending_here < 0: max_ending_here = 0 s = i+1 return (end - start + 1)
[ "assert most_common_elem('lkseropewdssafsdfafkpwe',3)==[('s', 4), ('e', 3), ('f', 3)] ", "assert most_common_elem('lkseropewdssafsdfafkpwe',2)==[('s', 4), ('e', 3)]", "assert most_common_elem('lkseropewdssafsdfafkpwe',7)==[('s', 4), ('e', 3), ('f', 3), ('k', 2), ('p', 2), ('w', 2), ('d', 2)]" ]
[]
726
Write a python function to count the number of lists in a given number of lists.
def all_Bits_Set_In_The_Given_Range(n,l,r): num = ((1 << r) - 1) ^ ((1 << (l - 1)) - 1) new_num = n & num if (num == new_num): return True return False
[ "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)" ]
[]
744
Write a function to sort dictionary items by tuple product of keys for the given dictionary with tuple keys.
def _sum(arr): sum=0 for i in arr: sum = sum + i return(sum)
[ "assert camel_to_snake('GoogleAssistant') == 'google_assistant'", "assert camel_to_snake('ChromeCast') == 'chrome_cast'", "assert camel_to_snake('QuadCore') == 'quad_core'" ]
[]
959
Write a function to filter the height and width of students which are stored in a dictionary.
def product_Equal(n): if n < 10: return False prodOdd = 1; prodEven = 1 while n > 0: digit = n % 10 prodOdd *= digit n = n//10 if n == 0: break; digit = n % 10 prodEven *= digit n = n//10 if prodOdd == prodEven: return True return False
[ "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]" ]
[]
897
Write a python function to count equal element pairs from the given array.
def previous_palindrome(num): for x in range(num-1,0,-1): if str(x) == str(x)[::-1]: return x
[ "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'" ]
[]
908
Write a function to convert the given string of integers into a tuple.
def get_item(tup1,index): item = tup1[index] return item
[ "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!')" ]
[]
876
Write a function to find a path with the maximum average over all existing paths for the given square matrix of size n*n.
def increment_numerics(test_list, K): res = [str(int(ele) + K) if ele.isdigit() else ele for ele in test_list] return res
[ "assert len_complex(3,4)==5.0", "assert len_complex(9,10)==13.45362404707371", "assert len_complex(7,9)==11.40175425099138" ]
[]
End of preview. Expand in Data Studio

edition_1807_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
16