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
633
Write a python function to check whether the given strings are rotations of each other or not.
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 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)]" ]
[]
713
Write a python function to check whether an array contains only one distinct element or not.
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 find_Extra([1,2,3,4],[1,2,3],3) == 3", "assert find_Extra([2,4,6,8,10],[2,4,6,8],4) == 4", "assert find_Extra([1,3,5,7,9,11],[1,3,5,7,9],5) == 5" ]
[]
617
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 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" ]
[]
778
Write a function to multiply consecutive numbers of a given list.
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 capital_words_spaces(\"Python\") == 'Python'", "assert capital_words_spaces(\"PythonProgrammingExamples\") == 'Python Programming Examples'", "assert capital_words_spaces(\"GetReadyToBeCodingFreak\") == 'Get Ready To Be Coding Freak'" ]
[]
929
Write a function to re-arrange the given tuples based on the given ordered list.
import re text = 'Python Exercises' def replace_spaces(text): text =text.replace (" ", "_") return (text) text =text.replace ("_", " ") return (text)
[ "assert _sum([1, 2, 3]) == 6", "assert _sum([15, 12, 13, 10]) == 50", "assert _sum([0, 1, 2]) == 3" ]
[]
714
Write a python function to find the sum of all odd length subarrays.
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 is_Isomorphic(\"paper\",\"title\") == True", "assert is_Isomorphic(\"ab\",\"ba\") == True", "assert is_Isomorphic(\"ab\",\"aa\") == False" ]
[]
673
Write a function to extract values between quotation marks of the given string by using regex.
def zip_list(list1,list2): result = list(map(list.__add__, list1, list2)) return result
[ "assert remove_multiple_spaces('Google Assistant') == 'Google Assistant'", "assert remove_multiple_spaces('Quad Core') == 'Quad Core'", "assert remove_multiple_spaces('ChromeCast Built-in') == 'ChromeCast Built-in'" ]
[]
709
Write a function to get dictionary keys as a list.
def smallest_multiple(n): if (n<=2): return n i = n * 2 factors = [number for number in range(n, 1, -1) if number * 2 > n] while True: for a in factors: if i % a != 0: i += n break if (a == factors[-1] and i % a == 0): ...
[ "assert previous_palindrome(99)==88", "assert previous_palindrome(1221)==1111", "assert previous_palindrome(120)==111" ]
[]
878
Write a function to calculate the standard deviation.
import re def extract_quotation(text1): return (re.findall(r'"(.*?)"', text1))
[ "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" ]
[]
799
Write a python function to find sum of products of all possible subarrays.
def div_of_nums(nums,m,n): result = list(filter(lambda x: (x % m == 0 and x % n == 0), nums)) return result
[ "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" ]
[]
721
Write a python function to calculate the sum of the numbers in a list between the indices of a specified range.
def fifth_Power_Sum(n) : sm = 0 for i in range(1,n+1) : sm = sm + (i*i*i*i*i) return sm
[ "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'" ]
[]
943
Write a function to calculate the discriminant value.
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 word_len(\"program\") == False", "assert word_len(\"solution\") == True", "assert word_len(\"data\") == True" ]
[]
813
Write a function to find the area of a trapezium.
import re def match_num(string): text = re.compile(r"^5") if text.match(string): return True else: return False
[ "assert even_num(13.5)==False", "assert even_num(0)==True", "assert even_num(-9)==False" ]
[]
922
Write a python function to get the difference between two lists.
def remove_kth_element(list1, L): return list1[:L-1] + list1[L:]
[ "assert coin_change([1, 2, 3],3,4)==4", "assert coin_change([4,5,6,7,8,9],6,9)==2", "assert coin_change([4,5,6,7,8,9],6,4)==1" ]
[]
865
Write a python function to interchange first and last elements in a given list.
def check(string): if len(set(string).intersection("AEIOUaeiou"))>=5: return ('accepted') else: return ("not accepted")
[ "assert toggle_middle_bits(9) == 15", "assert toggle_middle_bits(10) == 12", "assert toggle_middle_bits(11) == 13" ]
[]
968
Write a function to perform chunking of tuples each of size n.
def No_of_cubes(N,K): No = 0 No = (N - K + 1) No = pow(No, 3) return No
[ "assert extract_unique({'msm' : [5, 6, 7, 8],'is' : [10, 11, 7, 5],'best' : [6, 12, 10, 8],'for' : [1, 2, 5]} ) == [1, 2, 5, 6, 7, 8, 10, 11, 12]", "assert extract_unique({'Built' : [7, 1, 9, 4],'for' : [11, 21, 36, 14, 9],'ISP' : [4, 1, 21, 39, 47],'TV' : [1, 32, 38]} ) == [1, 4, 7, 9, 11, 14, 21, 32, 36, 38, 39...
[]
610
Write a function to flatten the given tuple matrix into the tuple list with each tuple representing each column.
def join_tuples(test_list): res = [] for sub in test_list: if res and res[-1][0] == sub[0]: res[-1].extend(sub[1:]) else: res.append([ele for ele in sub]) res = list(map(tuple, res)) return (res)
[ "assert area_trapezium(6,9,4)==30", "assert area_trapezium(10,20,30)==450", "assert area_trapezium(15,25,35)==700" ]
[]
927
Write a function to convert an integer into a roman numeral.
def decreasing_trend(nums): if (sorted(nums)== nums): return True else: return False
[ "assert remove_char(\"123abcjw:, .@! eiw\") == '123abcjweiw'", "assert remove_char(\"Hello1234:, ! Howare33u\") == 'Hello1234Howare33u'", "assert remove_char(\"Cool543Triks@:, Make@987Trips\") == 'Cool543TriksMake987Trips' " ]
[]
669
Write a function to add two lists using map and lambda function.
def div_list(nums1,nums2): result = map(lambda x, y: x / y, nums1, nums2) return list(result)
[ "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" ]
[]
811
Write a python function to check whether an array can be sorted or not by picking only the corner elements.
def unique_Element(arr,n): s = set(arr) if (len(s) == 1): return ('YES') else: return ('NO')
[ "assert len_complex(3,4)==5.0", "assert len_complex(9,10)==13.45362404707371", "assert len_complex(7,9)==11.40175425099138" ]
[]
744
Write a python function to count number of cubes of size k in a cube of size n.
def camel_to_snake(text): import re str1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', text) return re.sub('([a-z0-9])([A-Z])', r'\1_\2', str1).lower()
[ "assert 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)" ]
[]
887
Write a function to solve the fibonacci sequence using recursion.
def check_subset(test_tup1, test_tup2): res = set(test_tup2).issubset(test_tup1) return (res)
[ "assert add_dict({'a': 100, 'b': 200, 'c':300},{'a': 300, 'b': 200, 'd':400})==({'b': 400, 'd': 400, 'a': 400, 'c': 300}) ", "assert add_dict({'a': 500, 'b': 700, 'c':900},{'a': 500, 'b': 600, 'd':900})==({'b': 1300, 'd': 900, 'a': 1000, 'c': 900}) ", "assert add_dict({'a':900,'b':900,'d':900},{'a':900,'b':900,...
[]
855
Write a python function to check whether all the characters are same 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_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\"" ]
[]
940
Write a function to find length of the subarray having maximum sum.
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 parallelogram_perimeter(10,20)==400", "assert parallelogram_perimeter(15,20)==600", "assert parallelogram_perimeter(8,9)==144" ]
[]
687
Write a python function to find the kth element in an array containing odd elements first and then even elements.
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 prime_num(13)==True", "assert prime_num(7)==True", "assert prime_num(-1010)==False" ]
[]
800
Write a function to list out the list of given strings individually using map function.
import math def get_First_Set_Bit_Pos(n): return math.log2(n&-n)+1
[ "assert round_up(123.01247,0)==124", "assert round_up(123.01247,1)==123.1", "assert round_up(123.01247,2)==123.02" ]
[]
733
Write a function to remove the nested record from the given tuple.
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 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" ]
[]
850
Write a function to count the same pair in two given lists using map function.
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 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)" ]
[]
674
Write a function to find the nth nonagonal number.
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 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'...
[]
611
Write a function to check if the given tuples contain the k or not.
def floor_Max(A,B,N): x = min(B - 1,N) return (A*x) // B
[ "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" ]
[]
725
Write a python function to find minimum number swaps required to make two binary strings equal.
import bisect def right_insertion(a, x): i = bisect.bisect_right(a, x) return i
[ "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)" ...
[]
623
Write a python function to find number of solutions in quadratic equation.
import re def remove_extra_char(text1): pattern = re.compile('[\W_]+') return (pattern.sub('', text1))
[ "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'" ]
[]
936
Write a python function to count the number of distinct power of prime factor of given number.
def sort_numeric_strings(nums_str): result = [int(x) for x in nums_str] result.sort() return result
[ "assert check_alphanumeric(\"dawood@\") == 'Discard'", "assert check_alphanumeric(\"skdmsam326\") == 'Accept'", "assert check_alphanumeric(\"cooltricks@\") == 'Discard'" ]
[]
970
Write a function to check a decimal with a precision of 2.
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 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' " ]
[]
625
Write a function to create a new tuple from the given string and list.
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 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 " ]
[]
735
Write a function to check if the given tuple contains all valid values or not.
from itertools import groupby def extract_elements(numbers, n): result = [i for i, j in groupby(numbers) if len(list(j)) == n] return result
[ "assert count_tuplex((2, 4, 5, 6, 2, 3, 4, 4, 7),4)==3", "assert count_tuplex((2, 4, 5, 6, 2, 3, 4, 4, 7),2)==2", "assert count_tuplex((2, 4, 7, 7, 7, 3, 4, 4, 7),7)==4" ]
[]
646
Write a python function to choose points from two ranges such that no point lies in both the ranges.
def is_key_present(d,x): if x in d: return True else: return False
[ "assert sum_Of_Primes(10) == 17", "assert sum_Of_Primes(20) == 77", "assert sum_Of_Primes(5) == 10" ]
[]
908
Write a python function to count numeric values in a given string.
from collections import Counter def add_dict(d1,d2): add_dict = Counter(d1) + Counter(d2) return add_dict
[ "assert check_monthnumber_number(6)==True", "assert check_monthnumber_number(2)==False", "assert check_monthnumber_number(12)==False" ]
[]
817
Write a function to validate a gregorian date.
def sum_Odd(n): terms = (n + 1)//2 sum1 = terms * terms return sum1 def sum_in_Range(l,r): return sum_Odd(r) - sum_Odd(l - 1)
[ "assert decreasing_trend([-4,-3,-2,-1]) == True", "assert decreasing_trend([1,2,3]) == True", "assert decreasing_trend([3,2,1]) == False" ]
[]
921
Write a python function to check whether the product of digits of a number at even and odd places is equal or not.
import math def sum_of_odd_Factors(n): res = 1 while n % 2 == 0: n = n // 2 for i in range(3,int(math.sqrt(n) + 1)): count = 0 curr_sum = 1 curr_term = 1 while n % i == 0: count+=1 n = n // i curr_term *= i ...
[ "assert sum_series(7)==784", "assert sum_series(5)==225", "assert sum_series(15)==14400" ]
[]
618
Write a python function to count the number of lists in a given number of lists.
def rotate_right(list1,m,n): result = list1[-(m):]+list1[:-(n)] return result
[ "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')" ]
[]
869
Write a python function to find maximum possible value for the given periodic function.
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 check_date(11,11,2002)==True", "assert check_date(13,11,2002)==False", "assert check_date('11','11','2002')==True" ]
[]
946
Write a function to find average value of the numbers in a given tuple of tuples.
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 Sum(60) == 10", "assert Sum(39) == 16", "assert Sum(40) == 7" ]
[]
842
Write a function to count repeated items of a 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 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" ]
[]
857
Write a python function to left rotate the bits of a given number.
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 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'" ]
[]
637
Write a function to find the maximum sum of subsequences of given array with no adjacent elements.
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 lateralsurface_cone(5,12)==204.20352248333654", "assert lateralsurface_cone(10,15)==566.3586699569488", "assert lateralsurface_cone(19,17)==1521.8090132193388" ]
[]
931
Write a python function to find the sum of squares of binomial co-efficients.
def reverse_list_lists(lists): for l in lists: l.sort(reverse = True) return lists
[ "assert increment_numerics([\"MSM\", \"234\", \"is\", \"98\", \"123\", \"best\", \"4\"] , 6) == ['MSM', '240', 'is', '104', '129', 'best', '10']", "assert increment_numerics([\"Dart\", \"356\", \"is\", \"88\", \"169\", \"Super\", \"6\"] , 12) == ['Dart', '368', 'is', '100', '181', 'Super', '18']", "assert incre...
[]
694
Write a function to find out the second most repeated (or frequent) string in the given sequence.
def check_subset(list1,list2): return all(map(list1.__contains__,list2))
[ "assert check_monthnumb(\"February\")==False", "assert check_monthnumb(\"January\")==True", "assert check_monthnumb(\"March\")==True" ]
[]
639
Write a function to sum a specific column of a list in a given list of lists.
def count_Rotation(arr,n): for i in range (1,n): if (arr[i] < arr[i - 1]): return i return 0
[ "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'" ]
[]
796
Write a function to rotate a given list by specified number of items to the right direction.
def check_K(test_tup, K): res = False for ele in test_tup: if ele == K: res = True break return (res)
[ "assert merge_dictionaries({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" })=={'B': 'Black', 'R': 'Red', 'P': 'Pink', 'G': 'Green', 'W': 'White'}", "assert merge_dictionaries({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" },{ \"O\": \"Orange\", \"W\": \"White\", \...
[]
847
Write a python function to check if the string is a concatenation of another string.
def count_char(string,char): count = 0 for i in range(len(string)): if(string[i] == char): count = count + 1 return count
[ "assert Average([15, 9, 55, 41, 35, 20, 62, 49]) == 35.75", "assert Average([4, 5, 1, 2, 9, 7, 10, 8]) == 5.75", "assert Average([1,2,3]) == 2" ]
[]
953
Write a function to convert the given string of float type into tuple.
def sum_positivenum(nums): sum_positivenum = list(filter(lambda nums:nums>0,nums)) return sum(sum_positivenum)
[ "assert perimeter_polygon(4,20)==80", "assert perimeter_polygon(10,15)==150", "assert perimeter_polygon(9,7)==63" ]
[]
911
Write a function to convert degrees to radians.
import itertools def remove_duplicate(list1): list.sort(list1) remove_duplicate = list(list1 for list1,_ in itertools.groupby(list1)) return remove_duplicate
[ "assert chinese_zodiac(1997)==('Ox')", "assert chinese_zodiac(1998)==('Tiger')", "assert chinese_zodiac(1994)==('Dog')" ]
[]
767
Write a python function to check whether the given two arrays are equal or not.
def remove_duplic_list(l): temp = [] for x in l: if x not in temp: temp.append(x) return temp
[ "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" ]
[]
955
Write a function to check if any list element is present in the given list.
def last(arr,x,n): low = 0 high = n - 1 res = -1 while (low <= high): mid = (low + high) // 2 if arr[mid] > x: high = mid - 1 elif arr[mid] < x: low = mid + 1 else: res = mid low = mid + 1 return res
[ "assert (Diff([10, 15, 20, 25, 30, 35, 40], [25, 40, 35])) == [10, 20, 30, 15]", "assert (Diff([1,2,3,4,5], [6,7,1])) == [2,3,4,5,6,7]", "assert (Diff([1,2,3], [6,7,1])) == [2,3,6,7]" ]
[]
873
Write a function to display sign of the chinese zodiac for given year.
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 count_variable(4,2,0,-2)==['p', 'p', 'p', 'p', 'q', 'q'] ", "assert count_variable(0,1,2,3)==['q', 'r', 'r', 's', 's', 's'] ", "assert count_variable(11,15,12,23)==['p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'r', 'r',...
[]
790
Write a function to get an item of a tuple.
def find_Extra(arr1,arr2,n) : for i in range(0, n) : if (arr1[i] != arr2[i]) : return i return n
[ "assert max_of_three(10,20,30)==30", "assert max_of_three(55,47,39)==55", "assert max_of_three(10,49,30)==49" ]
[]
699
Write a function to get a lucid number smaller than or equal to n.
import math def lateralsurface_cone(r,h): l = math.sqrt(r * r + h * h) LSA = math.pi * r * l return LSA
[ "assert max_of_nth([(5, 6, 7), (1, 3, 5), (8, 9, 19)], 2) == 19", "assert max_of_nth([(6, 7, 8), (2, 4, 6), (9, 10, 20)], 1) == 10", "assert max_of_nth([(7, 8, 9), (3, 5, 7), (10, 11, 21)], 1) == 11" ]
[]
808
Write a python function to reverse an array upto a given position.
def count_Set_Bits(n) : n += 1; powerOf2 = 2; cnt = n // 2; while (powerOf2 <= n) : totalPairs = n // powerOf2; cnt += (totalPairs // 2) * powerOf2; if (totalPairs & 1) : cnt += (n % powerOf2) else : cnt += 0 powe...
[ "assert count_Char(\"abcac\",'a') == 4", "assert count_Char(\"abca\",'c') == 2", "assert count_Char(\"aba\",'a') == 7" ]
[]
692
Write a function to separate and print the numbers and their position of a given string.
def Average(lst): return sum(lst) / len(lst)
[ "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]" ]
[]
668
Write a function to find the product of first even and odd number of a given list.
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 chunk_tuples((10, 4, 5, 6, 7, 6, 8, 3, 4), 3) == [(10, 4, 5), (6, 7, 6), (8, 3, 4)]", "assert chunk_tuples((1, 2, 3, 4, 5, 6, 7, 8, 9), 2) == [(1, 2), (3, 4), (5, 6), (7, 8), (9,)]", "assert chunk_tuples((11, 14, 16, 17, 19, 21, 22, 25), 4) == [(11, 14, 16, 17), (19, 21, 22, 25)]" ]
[]
897
Write a function to find the smallest multiple of the first n numbers.
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 is_Two_Alter(\"abab\") == True", "assert is_Two_Alter(\"aaaa\") == False", "assert is_Two_Alter(\"xyz\") == False" ]
[]
961
Write a python function to convert the given string to upper case.
def find_Sum(arr,n): arr.sort() sum = arr[0] for i in range(0,n-1): if (arr[i] != arr[i+1]): sum = sum + arr[i+1] return sum
[ "assert sector_area(4,45)==6.285714285714286", "assert sector_area(9,45)==31.82142857142857", "assert sector_area(9,360)==None" ]
[]
853
Write a function to pack consecutive duplicates of a given list elements into sublists.
import math def area_tetrahedron(side): area = math.sqrt(3)*(side*side) return area
[ "assert right_insertion([1,2,4,5],6)==4", "assert right_insertion([1,2,4,5],3)==2", "assert right_insertion([1,2,4,5],7)==4" ]
[]
609
Write a python function to remove even numbers from a given list.
def max_sum_list(lists): return max(lists, key=sum)
[ "assert substract_elements(((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))) == ((-5, -4), (1, -4), (1, 8), (-6, 7))", "assert substract_elements(((13, 4), (14, 6), (13, 10), (12, 11)), ((19, 8), (14, 10), (12, 2), (18, 4))) == ((-6, -4), (0, -4), (1, 8), (-6, 7))", "assert substract_elements...
[]
863
Write a python function to toggle bits of the number except the first and the last bit.
def Sum_of_Inverse_Divisors(N,Sum): ans = float(Sum)*1.0 /float(N); return round(ans,2);
[ "assert count_duplic([1,2,2,2,4,4,4,5,5,5,5])==([1, 2, 4, 5], [1, 3, 3, 4])", "assert count_duplic([2,2,3,1,2,6,7,9])==([2, 3, 1, 2, 6, 7, 9], [2, 1, 1, 1, 1, 1, 1])", "assert count_duplic([2,1,5,6,8,3,4,9,10,11,8,12])==([2, 1, 5, 6, 8, 3, 4, 9, 10, 11, 8, 12], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])" ]
[]
616
Write a function to search a literals string in a string and also find the location within the original string where the pattern occurs by using regex.
def noprofit_noloss(actual_cost,sale_amount): if(sale_amount == actual_cost): return True else: return False
[ "assert check_email(\"ankitrai326@gmail.com\") == 'Valid Email'", "assert check_email(\"my.ownsite@ourearth.org\") == 'Valid Email'", "assert check_email(\"ankitaoie326.com\") == 'Invalid Email'" ]
[]
956
Write a function to calculate the height of the given binary tree.
def rombus_area(p,q): area=(p*q)/2 return area
[ "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]" ]
[]
636
Write a function to compute maximum product of three numbers of a given array of integers using heap queue algorithm.
def sort_sublists(list1): list1.sort() list1.sort(key=len) return list1
[ "assert is_subset([11, 1, 13, 21, 3, 7], 6, [11, 3, 7, 1], 4) == True", "assert is_subset([1, 2, 3, 4, 5, 6], 6, [1, 2, 4], 3) == True", "assert is_subset([10, 5, 2, 23, 19], 5, [19, 5, 3], 3) == False" ]
[]
941
Write a function to convert the given tuples into set.
def tuple_to_set(t): s = set(t) return (s)
[ "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')" ]
[]
861
Write a python function to find the minimum difference between any two elements in a given array.
def profit_amount(actual_cost,sale_amount): if(actual_cost > sale_amount): amount = actual_cost - sale_amount return amount else: return None
[ "assert maximum_segments(7, 5, 2, 5) == 2", "assert maximum_segments(17, 2, 1, 3) == 17", "assert maximum_segments(18, 16, 3, 6) == 6" ]
[]
835
Write a function to add all the numbers in a list and divide it with the length of the list.
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 smallest_Divisor(10) == 2", "assert smallest_Divisor(25) == 5", "assert smallest_Divisor(31) == 31" ]
[]
825
Write a python function to count the total set bits from 1 to n.
def is_odd(n) : if (n^1 == n-1) : return True; else : return False;
[ "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" ]
[]
926
Write a python function to find the index of an extra element present in one sorted array.
def sort_String(str) : str = ''.join(sorted(str)) return (str)
[ "assert geometric_sum(7) == 1.9921875", "assert geometric_sum(4) == 1.9375", "assert geometric_sum(8) == 1.99609375" ]
[]
766
Write a function to find maximum of two numbers.
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 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 " ]
[]
671
Write a function to count the number of elements in a list which are within a specific range.
def check_identical(test_list1, test_list2): res = test_list1 == test_list2 return (res)
[ "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" ]
[]
655
Write a function to locate the left insertion point for a specified value in sorted order.
def Diff(li1,li2): return (list(list(set(li1)-set(li2)) + list(set(li2)-set(li1))))
[ "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]" ]
[]
886
Write a function to solve tiling problem.
def validity_triangle(a,b,c): total = a + b + c if total == 180: return True else: return False
[ "assert extract_elements([1, 1, 3, 4, 4, 5, 6, 7],2)==[1, 4]", "assert extract_elements([0, 1, 2, 3, 4, 4, 4, 4, 5, 7],4)==[4]", "assert extract_elements([0,0,0,0,0],5)==[0]" ]
[]
820
Write a function to find the largest subset where each pair is divisible.
import re def road_rd(street): return (re.sub('Road$', 'Rd.', street))
[ "assert set_Right_most_Unset_Bit(21) == 23", "assert set_Right_most_Unset_Bit(11) == 15", "assert set_Right_most_Unset_Bit(15) == 15" ]
[]
676
Write a function to remove multiple spaces in a string by using regex.
def sorted_dict(dict1): sorted_dict = {x: sorted(y) for x, y in dict1.items()} return sorted_dict
[ "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" ]
[]
798
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.
def are_Equal(arr1,arr2,n,m): if (n != m): return False arr1.sort() arr2.sort() for i in range(0,n - 1): if (arr1[i] != arr2[i]): return False return True
[ "assert clear_tuple((1, 5, 3, 6, 8)) == ()", "assert clear_tuple((2, 1, 4 ,5 ,6)) == ()", "assert clear_tuple((3, 2, 5, 6, 8)) == ()" ]
[]
704
Write a python function to find the largest triangle that can be inscribed in the semicircle.
import re def remove_spaces(text): return (re.sub(' +',' ',text))
[ "assert left_Rotate(16,2) == 64", "assert left_Rotate(10,2) == 40", "assert left_Rotate(99,3) == 792" ]
[]
758
Write a python function to count the number of pairs whose sum is equal to ‘sum’.
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 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']]" ]
[]
606
Write a function to round up a number to specific digits.
def _sum(arr): sum=0 for i in arr: sum = sum + i return(sum)
[ "assert first_repeated_char(\"abcabc\") == \"a\"", "assert first_repeated_char(\"abc\") == \"None\"", "assert first_repeated_char(\"123123\") == \"1\"" ]
[]
635
Write a function to find the maximum of similar indices in two lists of tuples.
def count_Char(str,x): count = 0 for i in range(len(str)): if (str[i] == x) : count += 1 n = 10 repititions = n // len(str) count = count * repititions l = n % len(str) for i in range(l): if (str[i] == x): count += 1 return...
[ "assert check_subset((10, 4, 5, 6), (5, 10)) == True", "assert check_subset((1, 2, 3, 4), (5, 6)) == False", "assert check_subset((7, 8, 9, 10), (10, 8)) == True" ]
[]
871
Write a python function to add a minimum number such that the sum of array becomes even.
from collections import defaultdict def get_unique(test_list): res = defaultdict(list) for sub in test_list: res[sub[1]].append(sub[0]) res = dict(res) res_dict = dict() for key in res: res_dict[key] = len(list(set(res[key]))) return (str(res_dict))
[ "assert text_starta_endb(\"aabbbb\")==('Found a match!')", "assert text_starta_endb(\"aabAbbbc\")==('Not matched!')", "assert text_starta_endb(\"accddbbjjj\")==('Not matched!')" ]
[]
971
Write a python function to count the total unset bits from 1 to n.
from itertools import groupby def pack_consecutive_duplicates(list1): return [list(group) for key, group in groupby(list1)]
[ "assert lcm(4,6) == 12", "assert lcm(15,17) == 255", "assert lcm(2,6) == 6" ]
[]
690
Write a function to split the given string at uppercase letters by using regex.
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 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]]" ]
[]
963
Write a function to return true if the given number is even else return false.
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 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" ]
[]
624
Write a function to caluclate the area of a tetrahedron.
def maximum_value(test_list): res = [(key, max(lst)) for key, lst in test_list] return (res)
[ "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!')" ]
[]
890
Write a function to add the given tuple to the given list.
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 floor_Min(10,20,30) == 15", "assert floor_Min(1,2,1) == 0", "assert floor_Min(11,10,9) == 9" ]
[]
739
Write a function that gives profit amount if the given amount has profit else return none.
def check_min_heap(arr, i): if 2 * i + 2 > len(arr): return True left_child = (arr[i] <= arr[2 * i + 1]) and check_min_heap(arr, 2 * i + 1) right_child = (2 * i + 2 == len(arr)) or (arr[i] <= arr[2 * i + 2] and check_min_heap(arr, 2 * i + 2)) return l...
[ "assert freq_element((4, 5, 4, 5, 6, 6, 5, 5, 4) ) == '{4: 3, 5: 4, 6: 2}'", "assert freq_element((7, 8, 8, 9, 4, 7, 6, 5, 4) ) == '{7: 2, 8: 2, 9: 1, 4: 2, 6: 1, 5: 1}'", "assert freq_element((1, 4, 3, 1, 4, 5, 2, 6, 2, 7) ) == '{1: 2, 4: 2, 3: 1, 5: 1, 2: 2, 6: 1, 7: 1}'" ]
[]
724
Write a function to check if each element of second tuple is smaller than its corresponding index in first tuple.
def count_tuplex(tuplex,value): count = tuplex.count(value) return count
[ "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-...
[]
678
Write a function to locate the right insertion point for a specified value in sorted order.
def geometric_sum(n): if n < 0: return 0 else: return 1 / (pow(2, n)) + geometric_sum(n - 1)
[ "assert number_ctr('program2bedone') == 1", "assert number_ctr('3wonders') ==1", "assert number_ctr('123') == 3" ]
[]
883
Write a function to find the maximum number of segments of lengths a, b and c that can be formed from n.
import collections as ct def merge_dictionaries(dict1,dict2): merged_dict = dict(ct.ChainMap({}, dict1, dict2)) return merged_dict
[ "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...
[]
965
Write a python function to check whether every even index contains even numbers of a given list.
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 rombus_area(10,20)==100", "assert rombus_area(10,5)==25", "assert rombus_area(4,2)==4" ]
[]
757
Write a function to find a pair with the highest product from a given array of integers.
def min_of_two( x, y ): if x < y: return x return y
[ "assert sample_nam(['sally', 'Dylan', 'rebecca', 'Diana', 'Joanne', 'keith'])==16", "assert sample_nam([\"php\", \"res\", \"Python\", \"abcd\", \"Java\", \"aaa\"])==10", "assert sample_nam([\"abcd\", \"Python\", \"abba\", \"aba\"])==6" ]
[]
768
Write a function to find minimum k records from tuple list.
def is_nonagonal(n): return int(n * (7 * n - 5) / 2)
[ "assert floor_Max(11,10,9) == 9", "assert floor_Max(5,7,4) == 2", "assert floor_Max(2,2,1) == 1" ]
[]
894
Write a function to find the minimum difference in the tuple pairs of given tuples.
def palindrome_lambda(texts): result = list(filter(lambda x: (x == "".join(reversed(x))), texts)) return result
[ "assert smallest_multiple(13)==360360", "assert smallest_multiple(2)==2", "assert smallest_multiple(1)==1" ]
[]
691
Write a function to check if the given tuple contains only k elements.
def is_Isomorphic(str1,str2): dict_str1 = {} dict_str2 = {} for i, value in enumerate(str1): dict_str1[value] = dict_str1.get(value,[]) + [i] for j, value in enumerate(str2): dict_str2[value] = dict_str2.get(value,[]) + [j] if sorted(dict_str1.values()) == so...
[ "assert convert([1,2,3]) == 123", "assert convert([4,5,6]) == 456", "assert convert([7,8,9]) == 789" ]
[]
End of preview. Expand in Data Studio

edition_1990_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