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
873
Write a function to count repeated items of a tuple.
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 pack_consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4])==[[0, 0], [1], [2], [3], [4, 4], [5], [6, 6, 6], [7], [8], [9], [4, 4]]", "assert pack_consecutive_duplicates([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10])==[[10, 10], [15], [19], [18, 18], [17], [26, 26], [17], [18], [10]]"...
[]
651
Write a python function to replace multiple occurence of character by single.
def coin_change(S, m, n): table = [[0 for x in range(m)] for x in range(n+1)] for i in range(m): table[0][i] = 1 for i in range(1, n+1): for j in range(m): x = table[i - S[j]][j] if i-S[j] >= 0 else 0 y = table[i][j-1] if j >= 1 else 0 table[...
[ "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...
[]
612
Write a function to count the frequency of consecutive duplicate elements in a given list of numbers.
def is_subset(arr1, m, arr2, n): hashset = set() for i in range(0, m): hashset.add(arr1[i]) for i in range(0, n): if arr2[i] in hashset: continue else: return False return True
[ "assert 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 )] ) == '[(...
[]
708
Write a function to remove consecutive duplicates of a given list.
class Pair(object): def __init__(self, a, b): self.a = a self.b = b def max_chain_length(arr, n): max = 0 mcl = [1 for i in range(n)] for i in range(1, n): for j in range(0, i): if (arr[i].a > arr[j].b and mcl[i] < mcl[j] + 1): mcl[i] = mcl[j] + 1 for i in range(n): if (ma...
[ "assert floor_Min(10,20,30) == 15", "assert floor_Min(1,2,1) == 0", "assert floor_Min(11,10,9) == 9" ]
[]
765
Write a function to locate the left insertion point for a specified value in sorted order.
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 check_expression(\"{()}[{}]\") == True", "assert check_expression(\"{()}[{]\") == False", "assert check_expression(\"{()}[{}][]({})\") == True" ]
[]
943
Write a function to convert the given string of integers into a tuple.
def alternate_elements(list1): result=[] for item in list1[::2]: result.append(item) return result
[ "assert count_range_in_list([10,20,30,40,40,40,70,80,99],40,100)==6", "assert count_range_in_list(['a','b','c','d','e','f'],'a','e')==5", "assert count_range_in_list([7,8,9,15,17,19,45],15,20)==3" ]
[]
772
Write a function to calculate the sum of the positive numbers of a given list of numbers using lambda function.
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 validity_triangle(60,50,90)==False", "assert validity_triangle(45,75,60)==True", "assert validity_triangle(30,50,100)==True" ]
[]
675
Write a python function to convert a list of multiple integers into a single integer.
import re def extract_max(input): numbers = re.findall('\d+',input) numbers = map(int,numbers) return max(numbers)
[ "assert increasing_trend([1,2,3,4]) == True", "assert increasing_trend([4,3,2,1]) == False", "assert increasing_trend([0,1,4,9]) == True" ]
[]
864
Write a function to find the nth nonagonal number.
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 replace_specialchar('Python language, Programming language.')==('Python:language::Programming:language:')", "assert replace_specialchar('a b c,d e f')==('a:b:c:d:e:f')", "assert replace_specialchar('ram reshma,ram rahim')==('ram:reshma:ram:rahim')" ]
[]
666
Write a function to sum elements in two lists.
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 move_zero([1,0,2,0,3,4]) == [1,2,3,4,0,0]", "assert move_zero([2,3,2,0,0,4,0,5,0]) == [2,3,2,4,5,0,0,0,0]", "assert move_zero([0,1,0,1,1]) == [1,1,1,0,0]" ]
[]
638
Write a function that matches a word containing 'z', not at the start or end of the word.
import re def remove_all_spaces(text): return (re.sub(r'\s+', '',text))
[ "assert Repeat([10, 20, 30, 20, 20, 30, 40, 50, -20, 60, 60, -20, -20]) == [20, 30, -20, 60]", "assert Repeat([-1, 1, -1, 8]) == [-1]", "assert Repeat([1, 2, 3, 1, 2,]) == [1, 2]" ]
[]
820
Write a python function to get the last element of each sublist.
def remove_list_range(list1, leftrange, rigthrange): result = [i for i in list1 if (min(i)>=leftrange and max(i)<=rigthrange)] return result
[ "assert profit_amount(1500,1200)==300", "assert profit_amount(100,200)==None", "assert profit_amount(2000,5000)==None" ]
[]
854
Write a python function to count lower case letters in a given string.
def check_smaller(test_tup1, test_tup2): res = all(x > y for x, y in zip(test_tup1, test_tup2)) return (res)
[ "assert divisible_by_digits(1,22)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]", "assert divisible_by_digits(1,15)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15]", "assert divisible_by_digits(20,25)==[22, 24]" ]
[]
650
Write a python function to calculate the sum of the numbers in a list between the indices of a specified range.
def increment_numerics(test_list, K): res = [str(int(ele) + K) if ele.isdigit() else ele for ele in test_list] return res
[ "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]" ]
[]
683
Write a function to find the perimeter of a rectangle.
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 sum_Of_Subarray_Prod([1,2,3],3) == 20", "assert sum_Of_Subarray_Prod([1,2],2) == 5", "assert sum_Of_Subarray_Prod([1,2,3,4],4) == 84" ]
[]
817
Write a python function to find the sum of all odd length subarrays.
def ntimes_list(nums,n): result = map(lambda x:n*x, nums) return list(result)
[ "assert n_common_words(\"python is a programming language\",1)==[('python', 1)]", "assert n_common_words(\"python is a programming language\",1)==[('python', 1)]", "assert n_common_words(\"python is a programming language\",5)==[('python', 1),('is', 1), ('a', 1), ('programming', 1), ('language', 1)]" ]
[]
691
Write a python function to find minimum adjacent swaps required to sort binary array.
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 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...
[]
781
Write a function to remove multiple spaces in a string by using regex.
def is_Perfect_Square(n) : i = 1 while (i * i<= n): if ((n % i == 0) and (n / i == i)): return True i = i + 1 return False
[ "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" ]
[]
614
Write a python function to count number of vowels in the string.
def check_monthnumber_number(monthnum3): if(monthnum3==4 or monthnum3==6 or monthnum3==9 or monthnum3==11): return True else: return False
[ "assert text_match(\"ac\")==('Found a match!')", "assert text_match(\"dc\")==('Not matched!')", "assert text_match(\"abba\")==('Found a match!')" ]
[]
914
Write a function to check if the given tuple contains all valid values or not.
import re def remove_parenthesis(items): for item in items: return (re.sub(r" ?\([^)]+\)", "", item))
[ "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'" ]
[]
959
Write a function to find out the second most repeated (or frequent) string in the given sequence.
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 check_alphanumeric(\"dawood@\") == 'Discard'", "assert check_alphanumeric(\"skdmsam326\") == 'Accept'", "assert check_alphanumeric(\"cooltricks@\") == 'Discard'" ]
[]
821
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 add_dict_to_tuple(test_tup, test_dict): test_tup = list(test_tup) test_tup.append(test_dict) test_tup = tuple(test_tup) return (test_tup)
[ "assert reverse_words(\"python program\")==(\"program python\")", "assert reverse_words(\"java language\")==(\"language java\")", "assert reverse_words(\"indian man\")==(\"man indian\")" ]
[]
877
Write a python function to check if roots of a quadratic equation are reciprocal of each other or not.
import re def text_match(text): patterns = 'ab*?' if re.search(patterns, text): return 'Found a match!' else: return('Not matched!')
[ "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" ]
[]
769
Write a python function to count numeric values in a given string.
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 is_triangleexists(50,60,70)==True", "assert is_triangleexists(90,45,45)==True", "assert is_triangleexists(150,30,70)==False" ]
[]
961
Write a function to convert an integer into a roman numeral.
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 sum_Even(2,5) == 6", "assert sum_Even(3,8) == 18", "assert sum_Even(4,6) == 10" ]
[]
921
Write a function to find nth polite number.
def max_run_uppercase(test_str): cnt = 0 res = 0 for idx in range(0, len(test_str)): if test_str[idx].isupper(): cnt += 1 else: res = cnt cnt = 0 if test_str[len(test_str) - 1].isupper(): res = cnt return (res)
[ "assert get_First_Set_Bit_Pos(12) == 3", "assert get_First_Set_Bit_Pos(18) == 2", "assert get_First_Set_Bit_Pos(16) == 5" ]
[]
678
Write a function to find the largest subset where each pair is divisible.
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 count_alpha_dig_spl(\"abc!@#123\")==(3,3,3)", "assert count_alpha_dig_spl(\"dgsuy@#$%&1255\")==(5,4,5)", "assert count_alpha_dig_spl(\"fjdsif627348#%$^&\")==(6,6,5)" ]
[]
707
Write a python function to find the minimum sum of absolute differences of two arrays.
def sort_by_dnf(arr, n): low=0 mid=0 high=n-1 while mid <= high: if arr[mid] == 0: arr[low], arr[mid] = arr[mid], arr[low] low = low + 1 mid = mid + 1 elif arr[mid] == 1: mid = mid + 1 else: arr[mid], arr[high] = arr[high], arr[mid] high = high - 1 ...
[ "assert road_rd(\"ravipadu Road\")==('ravipadu Rd.')", "assert road_rd(\"palnadu Road\")==('palnadu Rd.')", "assert road_rd(\"eshwar enclave Road\")==('eshwar enclave Rd.')" ]
[]
668
Write a function to filter the height and width of students which are stored in a dictionary.
def floor_Max(A,B,N): x = min(B - 1,N) return (A*x) // B
[ "assert find_First_Missing([0,1,2,3],0,3) == 4", "assert find_First_Missing([0,1,2,6,9],0,4) == 3", "assert find_First_Missing([2,3,5,8,9],0,4) == 0" ]
[]
634
Write a function to replace whitespaces with an underscore and vice versa in a given string by using regex.
import re def extract_date(url): return re.findall(r'/(\d{4})/(\d{1,2})/(\d{1,2})/', url)
[ "assert recur_gcd(12,14) == 2", "assert recur_gcd(13,17) == 1", "assert recur_gcd(9, 3) == 3" ]
[]
656
Write a function to find maximum of three numbers.
def check_subset(list1,list2): return all(map(list1.__contains__,list2))
[ "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] " ]
[]
853
Write a function to find the index of the first occurrence of a given number in a sorted array.
import heapq def cheap_items(items,n): cheap_items = heapq.nsmallest(n, items, key=lambda s: s['price']) return cheap_items
[ "assert Odd_Length_Sum([1,2,4]) == 14", "assert Odd_Length_Sum([1,2,1,2]) == 15", "assert Odd_Length_Sum([1,7]) == 8" ]
[]
928
Write a python function to convert a string to a list.
def decreasing_trend(nums): if (sorted(nums)== nums): return True else: return False
[ "assert find_max_val(15, 10, 5) == 15", "assert find_max_val(187, 10, 5) == 185", "assert find_max_val(16, 11, 1) == 12" ]
[]
809
Write a function to check if the given integer is a prime number.
import re text = 'Python Exercises' def replace_spaces(text): text =text.replace (" ", "_") return (text) text =text.replace ("_", " ") return (text)
[ "assert set_Right_most_Unset_Bit(21) == 23", "assert set_Right_most_Unset_Bit(11) == 15", "assert set_Right_most_Unset_Bit(15) == 15" ]
[]
652
Write a function to check for the number of jumps required of given length to reach a point of form (d, 0) from origin in a 2d plane.
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 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" ]
[]
687
Write a function to check if the given tuple has any none value or not.
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 (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]" ]
[]
810
Write a function to find the product of first even and odd number of a given list.
def is_Word_Present(sentence,word): s = sentence.split(" ") for i in s: if (i == word): return True return False
[ "assert nth_super_ugly_number(12,[2,7,13,19])==32", "assert nth_super_ugly_number(10,[2,7,13,19])==26", "assert nth_super_ugly_number(100,[2,7,13,19])==5408" ]
[]
949
Write a python function to add a minimum number such that the sum of array becomes even.
def max_occurrences(list1): max_val = 0 result = list1[0] for i in list1: occu = list1.count(i) if occu > max_val: max_val = occu result = i return result
[ "assert 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)]" ]
[]
748
Write a python function to find the last two digits in factorial of a given number.
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 match_num('5-2345861')==True", "assert match_num('6-2345861')==False", "assert match_num('78910')==False" ]
[]
699
Write a function to check whether the given month number contains 30 days or not.
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 rencontres_number(7, 2) == 924", "assert rencontres_number(3, 0) == 2", "assert rencontres_number(3, 1) == 3" ]
[]
761
Write a python function to convert the given string to upper case.
def mul_even_odd(list1): first_even = next((el for el in list1 if el%2==0),-1) first_odd = next((el for el in list1 if el%2!=0),-1) return (first_even*first_odd)
[ "assert group_element([(6, 5), (2, 7), (2, 5), (8, 7), (9, 8), (3, 7)]) == {5: [6, 2], 7: [2, 8, 3], 8: [9]}", "assert group_element([(7, 6), (3, 8), (3, 6), (9, 8), (10, 9), (4, 8)]) == {6: [7, 3], 8: [3, 9, 4], 9: [10]}", "assert group_element([(8, 7), (4, 9), (4, 7), (10, 9), (11, 10), (5, 9)]) == {7: [8, 4]...
[]
813
Write a function to convert the given tuples into set.
def concatenate_nested(test_tup1, test_tup2): res = test_tup1 + test_tup2 return (res)
[ "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" ]
[]
953
Write a function to find the list in a list of lists whose sum of elements is the highest.
def even_num(x): if x%2==0: return True else: return False
[ "assert remove_kth_element([1,1,2,3,4,4,5,1],3)==[1, 1, 3, 4, 4, 5, 1]", "assert remove_kth_element([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4],4)==[0, 0, 1, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4]", "assert remove_kth_element([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10],5)==[10,10,15,19, 18, 17, 26, 26, 1...
[]
753
Write a python function to find even numbers from a mixed list.
import heapq as hq def raw_heap(rawheap): hq.heapify(rawheap) return rawheap
[ "assert count_Divisors(10) == \"Even\"", "assert count_Divisors(100) == \"Odd\"", "assert count_Divisors(125) == \"Even\"" ]
[]
863
Write a function to convert degrees to radians.
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 count_Unset_Bits(2) == 1", "assert count_Unset_Bits(5) == 4", "assert count_Unset_Bits(14) == 17" ]
[]
659
Write a function to find the number which occurs for odd number of times in the given array.
def max_of_nth(test_list, N): res = max([sub[N] for sub in test_list]) return (res)
[ "assert text_match(\"msb\") == 'Not matched!'", "assert text_match(\"a0c\") == 'Found a match!'", "assert text_match(\"abbc\") == 'Found a match!'" ]
[]
725
Write a python function to left rotate the bits of a given number.
def div_of_nums(nums,m,n): result = list(filter(lambda x: (x % m == 0 and x % n == 0), nums)) return result
[ "assert get_Pairs_Count([1,1,1,1],4,2) == 6", "assert get_Pairs_Count([1,5,7,-1,5],5,6) == 3", "assert get_Pairs_Count([1,-2,3],3,1) == 1" ]
[]
919
Write a function to get the length of a complex number.
from itertools import groupby def consecutive_duplicates(nums): return [key for key, group in groupby(nums)]
[ "assert Split([1,2,3,4,5]) == [2,4]", "assert Split([4,5,6,7,8,0,1]) == [4,6,8,0]", "assert Split ([8,12,15,19]) == [8,12]" ]
[]
828
Write a python function to find lcm of two positive integers.
import math def first_Digit(n) : fact = 1 for i in range(2,n + 1) : fact = fact * i while (fact % 10 == 0) : fact = int(fact / 10) while (fact >= 10) : fact = int(fact / 10) return math.floor(fact)
[ "assert lower_ctr('abc') == 3", "assert lower_ctr('string') == 6", "assert lower_ctr('Python') == 5" ]
[]
840
Write a python function to check whether every odd index contains odd numbers of a given list.
def check_monthnum_number(monthnum1): if monthnum1 == 2: return True else: return False
[ "assert find_Digits(7) == 4", "assert find_Digits(5) == 3", "assert find_Digits(4) == 2" ]
[]
779
Write a function to calculate wind chill index.
def min_of_two( x, y ): if x < y: return x return y
[ "assert Check_Solution(2,0,2) == \"Yes\"", "assert Check_Solution(2,-5,2) == \"Yes\"", "assert Check_Solution(1,2,3) == \"No\"" ]
[]
829
Write a function to get an item of a tuple.
import collections as ct def merge_dictionaries(dict1,dict2): merged_dict = dict(ct.ChainMap({}, dict1, dict2)) return merged_dict
[ "assert int(lobb_num(5, 3)) == 35", "assert int(lobb_num(3, 2)) == 5", "assert int(lobb_num(4, 2)) == 20" ]
[]
685
Write a function to find average value of the numbers in a given tuple of tuples.
def reverse_list_lists(lists): for l in lists: l.sort(reverse = True) return lists
[ "assert is_Word_Present(\"machine learning\",\"machine\") == True", "assert is_Word_Present(\"easy\",\"fun\") == False", "assert is_Word_Present(\"python language\",\"code\") == False" ]
[]
907
Write a python function to toggle bits of the number except the first and the last bit.
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 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'" ]
[]
866
Write a function to extract unique values from the given dictionary values.
import cmath def len_complex(a,b): cn=complex(a,b) length=abs(cn) return length
[ "assert previous_palindrome(99)==88", "assert previous_palindrome(1221)==1111", "assert previous_palindrome(120)==111" ]
[]
892
Write a python function to check whether an array contains only one distinct element or not.
from collections import Counter def max_char(str1): temp = Counter(str1) max_char = max(temp, key = temp.get) return max_char
[ "assert parallelogram_perimeter(10,20)==400", "assert parallelogram_perimeter(15,20)==600", "assert parallelogram_perimeter(8,9)==144" ]
[]
807
Write a function to combine two dictionaries by adding values for common keys.
def cummulative_sum(test_list): res = sum(map(sum, test_list)) return (res)
[ "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], ...
[]
790
Write a python function to find the index of smallest triangular number with n digits.
def nth_nums(nums,n): nth_nums = list(map(lambda x: x ** n, nums)) return nth_nums
[ "assert floor_Max(11,10,9) == 9", "assert floor_Max(5,7,4) == 2", "assert floor_Max(2,2,1) == 1" ]
[]
871
Write a python function to find sum of odd factors of a number.
def access_key(ditionary,key): return list(ditionary)[key]
[ "assert float_to_tuple(\"1.2, 1.3, 2.3, 2.4, 6.5\") == (1.2, 1.3, 2.3, 2.4, 6.5)", "assert float_to_tuple(\"2.3, 2.4, 5.6, 5.4, 8.9\") == (2.3, 2.4, 5.6, 5.4, 8.9)", "assert float_to_tuple(\"0.3, 0.5, 7.8, 9.4\") == (0.3, 0.5, 7.8, 9.4)" ]
[]
730
Write a function to find the minimum number of platforms required for a railway/bus station.
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 slope(4,2,2,5) == -1.5", "assert slope(2,4,4,6) == 1", "assert slope(1,2,4,2) == 0" ]
[]
785
Write a function to merge two dictionaries into a single expression.
def substract_elements(test_tup1, test_tup2): res = tuple(tuple(a - b for a, b in zip(tup1, tup2)) for tup1, tup2 in zip(test_tup1, test_tup2)) return (res)
[ "assert remove_spaces(\"a b c\") == \"abc\"", "assert remove_spaces(\"1 2 3\") == \"123\"", "assert remove_spaces(\" b c\") == \"bc\"" ]
[]
896
Write a python function to calculate the product of all the numbers of a given tuple.
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 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)" ]
[]
655
Write a python function to check for odd parity of a given number.
def check(string): if len(set(string).intersection("AEIOUaeiou"))>=5: return ('accepted') else: return ("not accepted")
[ "assert pair_wise([1,1,2,3,3,4,4,5])==[(1, 1), (1, 2), (2, 3), (3, 3), (3, 4), (4, 4), (4, 5)]", "assert pair_wise([1,5,7,9,10])==[(1, 5), (5, 7), (7, 9), (9, 10)]", "assert pair_wise([1,2,3,4,5,6,7,8,9,10])==[(1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), (8, 9), (9, 10)]" ]
[]
721
Write a python function to count occurences of a character in a repeated string.
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 same_Length(12,1) == False", "assert same_Length(2,2) == True", "assert same_Length(10,20) == True" ]
[]
874
Write a python function to find sum of prime numbers between 1 to n.
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 div_of_nums([19, 65, 57, 39, 152, 639, 121, 44, 90, 190],2,4)==[ 152,44]", "assert div_of_nums([1, 2, 3, 5, 7, 8, 10],2,5)==[10]", "assert div_of_nums([10,15,14,13,18,12,20],10,5)==[10,20]" ]
[]
684
Write a function to find the maximum sum that can be formed which has no three consecutive elements present.
import math def wind_chill(v,t): windchill = 13.12 + 0.6215*t - 11.37*math.pow(v, 0.16) + 0.3965*t*math.pow(v, 0.16) return int(round(windchill, 0))
[ "assert min_Jumps(3,4,11)==3.5", "assert min_Jumps(3,4,0)==0", "assert min_Jumps(11,14,11)==1" ]
[]
882
Write a function to calculate the harmonic sum of n-1.
def factorial(start,end): res = 1 for i in range(start,end + 1): res *= i return res def sum_of_square(n): return int(factorial(n + 1, 2 * n) /factorial(1, n))
[ "assert is_Isomorphic(\"paper\",\"title\") == True", "assert is_Isomorphic(\"ab\",\"ba\") == True", "assert is_Isomorphic(\"ab\",\"aa\") == False" ]
[]
878
Write a function to generate all sublists of a given list.
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 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]" ]
[]
758
Write a function to sort the given tuple list basis the total digits in tuple.
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 area_tetrahedron(3)==15.588457268119894", "assert area_tetrahedron(20)==692.8203230275509", "assert area_tetrahedron(10)==173.20508075688772" ]
[]
648
Write a function to remove sublists from a given list of lists, which are outside a given range.
def first_odd(nums): first_odd = next((el for el in nums if el%2!=0),-1) return first_odd
[ "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)" ]
[]
622
Write a python function to check whether all the bits are within a given range or not.
def div_list(nums1,nums2): result = map(lambda x, y: x / y, nums1, nums2) return list(result)
[ "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'...
[]
966
Write a function to sort dictionary items by tuple product of keys for the given dictionary with tuple keys.
import bisect def left_insertion(a, x): i = bisect.bisect_left(a, x) return i
[ "assert text_match_zero_one(\"ac\")==('Found a match!')", "assert text_match_zero_one(\"dc\")==('Not matched!')", "assert text_match_zero_one(\"abbbba\")==('Found a match!')" ]
[]
891
Write a function that matches a string that has an a followed by three 'b'.
import re def text_match(text): patterns = 'a.*?b$' if re.search(patterns, text): return ('Found a match!') else: return ('Not matched!')
[ "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\") ] " ]
[]
775
Write a python function to find the smallest missing number from the given array.
def extract_unique(test_dict): res = list(sorted({ele for val in test_dict.values() for ele in val})) return res
[ "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]" ]
[]
636
Write a python function to check whether the product of numbers is even or not.
from collections import OrderedDict def remove_duplicate(string): result = ' '.join(OrderedDict((w,w) for w in string.split()).keys()) return result
[ "assert dealnnoy_num(3, 4) == 129", "assert dealnnoy_num(3, 3) == 63", "assert dealnnoy_num(4, 5) == 681" ]
[]
825
Write a function to find maximum run of uppercase characters in the given string.
def re_arrange_tuples(test_list, ord_list): temp = dict(test_list) res = [(key, temp[key]) for key in ord_list] return (res)
[ "assert remove_all_spaces('python program')==('pythonprogram')", "assert remove_all_spaces('python programming language')==('pythonprogramminglanguage')", "assert remove_all_spaces('python program')==('pythonprogram')" ]
[]
774
Write a function to calculate the geometric sum of n-1.
import re def text_match_three(text): patterns = 'ab{3}?' if re.search(patterns, text): return 'Found a match!' else: return('Not matched!')
[ "assert mutiple_tuple((4, 3, 2, 2, -1, 18)) == -864", "assert mutiple_tuple((1,2,3)) == 6", "assert mutiple_tuple((-2,-4,-6)) == -48" ]
[]
606
Write a python function to count the number of rotations required to generate a sorted array.
def check(arr,n): g = 0 for i in range(1,n): if (arr[i] - arr[i - 1] > 0 and g == 1): return False if (arr[i] - arr[i] < 0): g = 1 return True
[ "assert even_num(13.5)==False", "assert even_num(0)==True", "assert even_num(-9)==False" ]
[]
703
Write a function to check if two lists of tuples are identical or not.
import math def get_First_Set_Bit_Pos(n): return math.log2(n&-n)+1
[ "assert cheap_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}],1)==[{'name': 'Item-1', 'price': 101.1}]", "assert cheap_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}],2)==[{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}]", "ass...
[]
806
Write a function to split the given string at uppercase letters by using regex.
def count_even(array_nums): count_even = len(list(filter(lambda x: (x%2 == 0) , array_nums))) return count_even
[ "assert count_Char(\"abcac\",'a') == 4", "assert count_Char(\"abca\",'c') == 2", "assert count_Char(\"aba\",'a') == 7" ]
[]
831
Write a function to get dictionary keys as a list.
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 remove_extra_char('**//Google Android// - 12. ') == 'GoogleAndroid12'", "assert remove_extra_char('****//Google Flutter//*** - 36. ') == 'GoogleFlutter36'", "assert remove_extra_char('**//Google Firebase// - 478. ') == 'GoogleFirebase478'" ]
[]
827
Write a function to group a sequence of key-value pairs into a dictionary of lists using collections module.
import re regex = '[a-zA-z0-9]$' def check_alphanumeric(string): if(re.search(regex, string)): return ("Accept") else: return ("Discard")
[ "assert check_monthnumb(\"February\")==False", "assert check_monthnumb(\"January\")==True", "assert check_monthnumb(\"March\")==True" ]
[]
945
Write a function that matches a string that has an a followed by zero or more b's.
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 sub_lists([10, 20, 30, 40])==[[], [10], [20], [30], [40], [10, 20], [10, 30], [10, 40], [20, 30], [20, 40], [30, 40], [10, 20, 30], [10, 20, 40], [10, 30, 40], [20, 30, 40], [10, 20, 30, 40]]", "assert sub_lists(['X', 'Y', 'Z'])==[[], ['X'], ['Y'], ['Z'], ['X', 'Y'], ['X', 'Z'], ['Y', 'Z'], ['X', 'Y', 'Z'...
[]
616
Write a function to count number of unique lists within a list.
def count_tuplex(tuplex,value): count = tuplex.count(value) return count
[ "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...
[]
618
Write a python function to check whether the roots of a quadratic equation are numerically equal but opposite in sign or not.
def remove_duplic_list(l): temp = [] for x in l: if x not in temp: temp.append(x) return temp
[ "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...
[]
841
Write a function to convert camel case string to snake case string.
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 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)]) == ...
[]
631
Write a function to check if the given tuples contain the k or not.
def float_to_tuple(test_str): res = tuple(map(float, test_str.split(', '))) return (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]]" ]
[]
663
Write a function to find area of a sector.
def rectangle_perimeter(l,b): perimeter=2*(l+b) return perimeter
[ "assert maximum_segments(7, 5, 2, 5) == 2", "assert maximum_segments(17, 2, 1, 3) == 17", "assert maximum_segments(18, 16, 3, 6) == 6" ]
[]
937
Write a python function to find the sum of fourth power of first n even natural numbers.
def sorted_dict(dict1): sorted_dict = {x: sorted(y) for x, y in dict1.items()} return sorted_dict
[ "assert rombus_area(10,20)==100", "assert rombus_area(10,5)==25", "assert rombus_area(4,2)==4" ]
[]
904
Write a function that matches a string that has an a followed by zero or more b's by using regex.
def extract_index_list(l1, l2, l3): result = [] for m, n, o in zip(l1, l2, l3): if (m == n == o): result.append(m) return result
[ "assert 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" ]
[]
737
Write a python function to reverse an array upto a given position.
def check_none(test_tup): res = any(map(lambda ele: ele is None, test_tup)) return (res)
[ "assert clear_tuple((1, 5, 3, 6, 8)) == ()", "assert clear_tuple((2, 1, 4 ,5 ,6)) == ()", "assert clear_tuple((3, 2, 5, 6, 8)) == ()" ]
[]
902
Write a function to find minimum of two numbers.
from heapq import merge def combine_lists(num1,num2): combine_lists=list(merge(num1, num2)) return combine_lists
[ "assert No_of_cubes(2,1) == 8", "assert No_of_cubes(5,2) == 64", "assert No_of_cubes(1,1) == 1" ]
[]
946
Write a function to sort a list in increasing order by the last element in each tuple from a given list of non-empty tuples.
def max_sum_list(lists): return max(lists, key=sum)
[ "assert find_Min_Diff((1,5,3,19,18,25),6) == 1", "assert find_Min_Diff((4,3,2,6),4) == 1", "assert find_Min_Diff((30,5,20,9),4) == 4" ]
[]
647
Write a function to caluclate arc length of an angle.
def maximum_value(test_list): res = [(key, max(lst)) for key, lst in test_list] return (res)
[ "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" ]
[]
653
Write a python function to get the position of rightmost set bit.
def sum_Range_list(nums, m, n): sum_range = 0 ...
[ "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'" ]
[]
679
Write a python function to check whether the given two arrays are equal or not.
import re def text_uppercase_lowercase(text): patterns = '[A-Z]+[a-z]+$' if re.search(patterns, text): return 'Found a match!' else: return ('Not matched!')
[ "assert noprofit_noloss(1500,1200)==False", "assert noprofit_noloss(100,100)==True", "assert noprofit_noloss(2000,5000)==False" ]
[]
916
Write a function to convert tuple string to integer tuple.
def prime_num(num): if num >=1: for i in range(2, num//2): if (num % i) == 0: return False else: return True else: return False
[ "assert 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]" ]
[]
673
Write a python function to find the cube sum of first n odd natural numbers.
def is_key_present(d,x): if x in d: return True else: return False
[ "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])" ]
[]
736
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 string_length(str1): count = 0 for char in str1: count += 1 return count
[ "assert remove_duplicate(\"Python Exercises Practice Solution Exercises\")==(\"Python Exercises Practice Solution\")", "assert remove_duplicate(\"Python Exercises Practice Solution Python\")==(\"Python Exercises Practice Solution\")", "assert remove_duplicate(\"Python Exercises Practice Solution Practice\")==(\...
[]
743
Write a python function to check whether the product of digits of a number at even and odd places is equal or not.
def check_identical(test_list1, test_list2): res = test_list1 == test_list2 return (res)
[ "assert get_ludic(10) == [1, 2, 3, 5, 7]", "assert get_ludic(25) == [1, 2, 3, 5, 7, 11, 13, 17, 23, 25]", "assert get_ludic(45) == [1, 2, 3, 5, 7, 11, 13, 17, 23, 25, 29, 37, 41, 43]" ]
[]
End of preview. Expand in Data Studio

edition_1453_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
9