task_id int64 601 974 | text large_stringlengths 38 249 | code large_stringlengths 30 908 | test_list listlengths 3 3 | test_setup_code large_stringclasses 2
values | challenge_test_list listlengths 0 0 |
|---|---|---|---|---|---|
735 | Write a function to convert tuple string to integer tuple. | def check_none(test_tup):
res = any(map(lambda ele: ele is None, test_tup))
return (res) | [
"assert Extract([[1, 2, 3], [4, 5], [6, 7, 8, 9]]) == [3, 5, 9]",
"assert Extract([['x', 'y', 'z'], ['m'], ['a', 'b'], ['u', 'v']]) == ['z', 'm', 'b', 'v']",
"assert Extract([[1, 2, 3], [4, 5]]) == [3, 5]"
] | [] | |
808 | Write a python function to check for even parity of a given number. | 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 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"
] | [] | |
778 | Write a function to find common index elements from three lists. | def sort_sublists(list1):
list1.sort()
list1.sort(key=len)
return list1 | [
"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"
] | [] | |
673 | Write a function to count the most common character in a given string. | def count_even(array_nums):
count_even = len(list(filter(lambda x: (x%2 == 0) , array_nums)))
return count_even | [
"assert maximum_segments(7, 5, 2, 5) == 2",
"assert maximum_segments(17, 2, 1, 3) == 17",
"assert maximum_segments(18, 16, 3, 6) == 6"
] | [] | |
679 | Write a python function to count the number of rotations required to generate a sorted array. | import re
def end_num(string):
text = re.compile(r".*[0-9]$")
if text.match(string):
return True
else:
return False | [
"assert number_ctr('program2bedone') == 1",
"assert number_ctr('3wonders') ==1",
"assert number_ctr('123') == 3"
] | [] | |
649 | Write a function to extract values between quotation marks of the given string by using regex. | def lcopy(xs):
return xs[:]
| [
"assert rombus_area(10,20)==100",
"assert rombus_area(10,5)==25",
"assert rombus_area(4,2)==4"
] | [] | |
658 | Write a function to check if the triangle is valid or not. | 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 check_alphanumeric(\"dawood@\") == 'Discard'",
"assert check_alphanumeric(\"skdmsam326\") == 'Accept'",
"assert check_alphanumeric(\"cooltricks@\") == 'Discard'"
] | [] | |
768 | Write a function to find the item with maximum occurrences in a given list. | import re
def text_match(text):
patterns = 'a.*?b$'
if re.search(patterns, text):
return ('Found a match!')
else:
return ('Not matched!') | [
"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"
] | [] | |
614 | Write a python function to remove even numbers from a given list. | def dealnnoy_num(n, m):
if (m == 0 or n == 0) :
return 1
return dealnnoy_num(m - 1, n) + dealnnoy_num(m - 1, n - 1) + dealnnoy_num(m, n - 1) | [
"assert rectangle_perimeter(10,20)==60",
"assert rectangle_perimeter(10,5)==30",
"assert rectangle_perimeter(4,2)==12"
] | [] | |
965 | Write a function to count the frequency of consecutive duplicate elements in a given list of numbers. | def lucky_num(n):
List=range(-1,n*n+9,2)
i=2
while List[i:]:List=sorted(set(List)-set(List[List[i]::List[i]]));i+=1
return List[1:n+1] | [
"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"
] | [] | |
843 | Write a function to find if there is a triplet in the array whose sum is equal to a given value. | 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 get_odd_occurence([2, 3, 5, 4, 5, 2, 4, 3, 5, 2, 4, 4, 2], 13) == 5",
"assert get_odd_occurence([1, 2, 3, 2, 3, 1, 3], 7) == 3",
"assert get_odd_occurence([5, 7, 2, 7, 5, 2, 5], 7) == 5"
] | [] | |
870 | Write a python function to find the average of a list. | def count_tuplex(tuplex,value):
count = tuplex.count(value)
return count | [
"assert anagram_lambda([\"bcda\", \"abce\", \"cbda\", \"cbea\", \"adcb\"],\"abcd\")==['bcda', 'cbda', 'adcb']",
"assert anagram_lambda([\"recitals\",\" python\"], \"articles\" )==[\"recitals\"]",
"assert anagram_lambda([\" keep\",\" abcdef\",\" xyz\"],\" peek\")==[\" keep\"]"
] | [] | |
713 | Write a python function to count lower case letters in a given string. | def are_Rotations(string1,string2):
size1 = len(string1)
size2 = len(string2)
temp = ''
if size1 != size2:
return False
temp = string1 + string1
if (temp.count(string2)> 0):
return True
else:
return False | [
"assert 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"
] | [] | |
678 | Write a python function to find sum of prime numbers between 1 to n. | def increasing_trend(nums):
if (sorted(nums)== nums):
return True
else:
return False | [
"assert check_tuples((3, 5, 6, 5, 3, 6),[3, 6, 5]) == True",
"assert check_tuples((4, 5, 6, 4, 6, 5),[4, 5, 6]) == True",
"assert check_tuples((9, 8, 7, 6, 8, 9),[9, 8, 1]) == False"
] | [] | |
814 | Write a function to remove all characters except letters and numbers using regex | 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 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)"
] | [] | |
666 | Write a function to replace all spaces in the given string with character * list item * list item * list item * list item '%20'. | import re
def extract_quotation(text1):
return (re.findall(r'"(.*?)"', text1)) | [
"assert lateralsurface_cone(5,12)==204.20352248333654",
"assert lateralsurface_cone(10,15)==566.3586699569488",
"assert lateralsurface_cone(19,17)==1521.8090132193388"
] | [] | |
787 | Write a python function to left rotate the bits of a given number. | import heapq as hq
def heap_sort(iterable):
h = []
for value in iterable:
hq.heappush(h, value)
return [hq.heappop(h) for i in range(len(h))] | [
"assert recur_gcd(12,14) == 2",
"assert recur_gcd(13,17) == 1",
"assert recur_gcd(9, 3) == 3"
] | [] | |
885 | Write a function to check whether the given amount has no profit and no loss | 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 mutiple_tuple((4, 3, 2, 2, -1, 18)) == -864",
"assert mutiple_tuple((1,2,3)) == 6",
"assert mutiple_tuple((-2,-4,-6)) == -48"
] | [] | |
602 | Write a function to iterate over all pairs of consecutive items in a given list. | def last(n):
return n[-1]
def sort_list_last(tuples):
return sorted(tuples, key=last) | [
"assert roman_to_int('MMMCMLXXXVI')==3986",
"assert roman_to_int('MMMM')==4000",
"assert roman_to_int('C')==100"
] | [] | |
723 | Write a function to find the minimum difference in the tuple pairs of given tuples. | import re
def split_upperstring(text):
return (re.findall('[A-Z][^A-Z]*', text)) | [
"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... | [] | |
908 | Write a python function to find the last position of an element in a sorted array. | def nCr_mod_p(n, r, p):
if (r > n- r):
r = n - r
C = [0 for i in range(r + 1)]
C[0] = 1
for i in range(1, n + 1):
for j in range(min(i, r), 0, -1):
C[j] = (C[j] + C[j-1]) % p
return C[r] | [
"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... | [] | |
731 | Write a function to find length of the string. | def all_Characters_Same(s) :
n = len(s)
for i in range(1,n) :
if s[i] != s[0] :
return False
return True | [
"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]"
] | [] | |
925 | Write a function to convert degrees to radians. | def find_first_occurrence(A, x):
(left, right) = (0, len(A) - 1)
result = -1
while left <= right:
mid = (left + right) // 2
if x == A[mid]:
result = mid
right = mid - 1
elif x < A[mid]:
right = mid - 1
else:
left = mi... | [
"assert is_Isomorphic(\"paper\",\"title\") == True",
"assert is_Isomorphic(\"ab\",\"ba\") == True",
"assert is_Isomorphic(\"ab\",\"aa\") == False"
] | [] | |
909 | Write a python function to calculate the product of all the numbers of a given tuple. | 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 len_complex(3,4)==5.0",
"assert len_complex(9,10)==13.45362404707371",
"assert len_complex(7,9)==11.40175425099138"
] | [] | |
874 | Write a function to caluclate the area of a tetrahedron. | def geometric_sum(n):
if n < 0:
return 0
else:
return 1 / (pow(2, n)) + geometric_sum(n - 1) | [
"assert sort_String(\"cba\") == \"abc\"",
"assert sort_String(\"data\") == \"aadt\"",
"assert sort_String(\"zxy\") == \"xyz\""
] | [] | |
848 | Write a python function to find the first odd number in a given list of numbers. | def arc_length(d,a):
pi=22/7
if a >= 360:
return None
arclength = (pi*d) * (a/360)
return arclength | [
"assert text_match(\"msb\") == 'Not matched!'",
"assert text_match(\"a0c\") == 'Found a match!'",
"assert text_match(\"abbc\") == 'Found a match!'"
] | [] | |
849 | Write a python function to replace multiple occurence of character by single. | def check_greater(test_tup1, test_tup2):
res = all(x < y for x, y in zip(test_tup1, test_tup2))
return (res) | [
"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... | [] | |
631 | Write a python function to convert a list of multiple integers into a single integer. | def min_jumps(arr, n):
jumps = [0 for i in range(n)]
if (n == 0) or (arr[0] == 0):
return float('inf')
jumps[0] = 0
for i in range(1, n):
jumps[i] = float('inf')
for j in range(i):
if (i <= j + arr[j]) and (jumps[j] != float('inf')):
jumps[i] = min(jumps[i], jumps[j] + 1)
break
return j... | [
"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"
] | [] | |
651 | Write a function to find the maximum of nth column from the given tuple list. | 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 tuple_to_dict((1, 5, 7, 10, 13, 5)) == {1: 5, 7: 10, 13: 5}",
"assert tuple_to_dict((1, 2, 3, 4, 5, 6)) == {1: 2, 3: 4, 5: 6}",
"assert tuple_to_dict((7, 8, 9, 10, 11, 12)) == {7: 8, 9: 10, 11: 12}"
] | [] | |
743 | Write a function to remove an empty tuple from a list of tuples. | def unique_sublists(list1):
result ={}
for l in list1:
result.setdefault(tuple(l), list()).append(1)
for a, b in result.items():
result[a] = sum(b)
return result | [
"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"
] | [] | |
750 | Write a function to divide two lists using map and lambda function. | def nth_nums(nums,n):
nth_nums = list(map(lambda x: x ** n, nums))
return nth_nums | [
"assert largest_subset([ 1, 3, 6, 13, 17, 18 ], 6) == 4",
"assert largest_subset([10, 5, 3, 15, 20], 5) == 3",
"assert largest_subset([18, 1, 3, 6, 13, 17], 6) == 4"
] | [] | |
671 | Write a python function to check for odd parity of a given number. | def is_odd(n) :
if (n^1 == n-1) :
return True;
else :
return False; | [
"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]"
] | [] | |
652 | Write a function that matches a string that has an a followed by zero or one 'b'. | 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 reverse_words(\"python program\")==(\"program python\")",
"assert reverse_words(\"java language\")==(\"language java\")",
"assert reverse_words(\"indian man\")==(\"man indian\")"
] | [] | |
704 | Write a python function to find maximum possible value for the given periodic function. | def Split(list):
ev_li = []
for i in list:
if (i % 2 == 0):
ev_li.append(i)
return ev_li | [
"assert sum_Of_Primes(10) == 17",
"assert sum_Of_Primes(20) == 77",
"assert sum_Of_Primes(5) == 10"
] | [] | |
839 | Write a function to find the nth nonagonal number. | def find_First_Missing(array,start,end):
if (start > end):
return end + 1
if (start != array[start]):
return start;
mid = int((start + end) / 2)
if (array[mid] == mid):
return find_First_Missing(array,mid+1,end)
return find_First_Missing(array,start,mid) | [
"assert prime_num(13)==True",
"assert prime_num(7)==True",
"assert prime_num(-1010)==False"
] | [] | |
873 | 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. | import re
def split_list(text):
return (re.findall('[A-Z][^A-Z]*', text)) | [
"assert check_Concat(\"abcabcabc\",\"abc\") == True",
"assert check_Concat(\"abcab\",\"abc\") == False",
"assert check_Concat(\"aba\",\"ab\") == False"
] | [] | |
625 | Write a function to check if the given tuples contain the k or not. | M = 100
def maxAverageOfPath(cost, N):
dp = [[0 for i in range(N + 1)] for j in range(N + 1)]
dp[0][0] = cost[0][0]
for i in range(1, N):
dp[i][0] = dp[i - 1][0] + cost[i][0]
for j in range(1, N):
dp[0][j] = dp[0][j - 1] + cost[0][j]
for i in range(1, N):
for j in range(1, N):
dp[i][j] ... | [
"assert perimeter_polygon(4,20)==80",
"assert perimeter_polygon(10,15)==150",
"assert perimeter_polygon(9,7)==63"
] | [] | |
674 | Write a python function to move all zeroes to the end of the given list. | def is_upper(string):
return (string.upper()) | [
"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]"
] | [] | |
950 | Write a python function to count number of vowels in the string. | 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 string_length('python')==6",
"assert string_length('program')==7",
"assert string_length('language')==8"
] | [] | |
711 | Write a function to convert camel case string to snake case string by using regex. | 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 Sum_of_Inverse_Divisors(6,12) == 2",
"assert Sum_of_Inverse_Divisors(9,13) == 1.44",
"assert Sum_of_Inverse_Divisors(1,4) == 4"
] | [] | |
759 | Write a python function to find the sum of an array. | def set_middle_bits(n):
n |= n >> 1;
n |= n >> 2;
n |= n >> 4;
n |= n >> 8;
n |= n >> 16;
return (n >> 1) ^ 1
def toggle_middle_bits(n):
if (n == 1):
return 1
return n ^ set_middle_bits(n) | [
"assert 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,... | [] | |
974 | Write a python function to find the sum of fourth power of first n odd natural numbers. | 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 get_First_Set_Bit_Pos(12) == 3",
"assert get_First_Set_Bit_Pos(18) == 2",
"assert get_First_Set_Bit_Pos(16) == 5"
] | [] | |
809 | Write a function that gives profit amount if the given amount has profit else return none. | 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 check_Even_Parity(10) == True",
"assert check_Even_Parity(11) == False",
"assert check_Even_Parity(18) == True"
] | [] | |
887 | Write a python function to interchange first and last elements in a given list. | 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_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')"
] | [] | |
639 | Write a function to convert the given string of float type into tuple. | def increment_numerics(test_list, K):
res = [str(int(ele) + K) if ele.isdigit() else ele for ele in test_list]
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"
] | [] | |
700 | Write a python function to check whether the given number is a perfect square or not. | def floor_Max(A,B,N):
x = min(B - 1,N)
return (A*x) // B | [
"assert max_of_three(10,20,30)==30",
"assert max_of_three(55,47,39)==55",
"assert max_of_three(10,49,30)==49"
] | [] | |
728 | Write a function to find the combinations of sums with tuples in the given tuple list. | def check_element(test_tup, check_list):
res = False
for ele in check_list:
if ele in test_tup:
res = True
break
return (res) | [
"assert fifth_Power_Sum(2) == 33",
"assert fifth_Power_Sum(4) == 1300",
"assert fifth_Power_Sum(3) == 276"
] | [] | |
739 | Write a function that matches a string that has an 'a' followed by anything, ending in 'b'. | def convert(list):
s = [str(i) for i in list]
res = int("".join(s))
return (res) | [
"assert count_Set_Bits(16) == 33",
"assert count_Set_Bits(2) == 2",
"assert count_Set_Bits(14) == 28"
] | [] | |
903 | Write a function to find whether an array is subset of another array. | 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 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"
] | [] | |
938 | Write a python function to find minimum possible value for the given periodic function. | def sort_tuple(tup):
n = len(tup)
for i in range(n):
for j in range(n-i-1):
if tup[j][0] > tup[j + 1][0]:
tup[j], tup[j + 1] = tup[j + 1], tup[j]
return tup | [
"assert 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"
] | [] | |
737 | Write a function to remove everything except alphanumeric characters from the given string by using regex. | def div_list(nums1,nums2):
result = map(lambda x, y: x / y, nums1, nums2)
return list(result) | [
"assert first_repeated_char(\"abcabc\") == \"a\"",
"assert first_repeated_char(\"abc\") == \"None\"",
"assert first_repeated_char(\"123123\") == \"1\""
] | [] | |
686 | Write a python function to find minimum adjacent swaps required to sort binary array. | from collections import Counter
def max_char(str1):
temp = Counter(str1)
max_char = max(temp, key = temp.get)
return max_char | [
"assert average_tuple(((10, 10, 10, 12), (30, 45, 56, 45), (81, 80, 39, 32), (1, 2, 3, 4)))==[30.5, 34.25, 27.0, 23.25]",
"assert average_tuple(((1, 1, -5), (30, -15, 56), (81, -60, -39), (-10, 2, 3)))== [25.5, -18.0, 3.75]",
"assert average_tuple( ((100, 100, 100, 120), (300, 450, 560, 450), (810, 800, 390, 32... | [] | |
727 | Write a function to validate a gregorian date. | 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 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)]"
] | [] | |
827 | Write a function to perform chunking of tuples each of size n. | from collections import Counter
def most_common_elem(s,a):
most_common_elem=Counter(s).most_common(a)
return most_common_elem | [
"assert sort_by_dnf([1,2,0,1,0,1,2,1,1], 9) == [0, 0, 1, 1, 1, 1, 1, 2, 2]",
"assert sort_by_dnf([1,0,0,1,2,1,2,2,1,0], 10) == [0, 0, 0, 1, 1, 1, 1, 2, 2, 2]",
"assert sort_by_dnf([2,2,1,0,0,0,1,1,2,1], 10) == [0, 0, 0, 1, 1, 1, 1, 2, 2, 2]"
] | [] | |
745 | Write a function to find three closest elements from three sorted arrays. | 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 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]"
] | [] | |
927 | Write a python function to find the sum of all odd length subarrays. | def count_duplic(lists):
element = []
frequency = []
if not lists:
return element
running_count = 1
for i in range(len(lists)-1):
if lists[i] == lists[i+1]:
running_count += 1
else:
frequency.append(running_count)
element.append(... | [
"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'... | [] | |
883 | Write a function to find the list in a list of lists whose sum of elements is the highest. | 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 find_literals('The quick brown fox jumps over the lazy dog.', 'fox') == ('fox', 16, 19)",
"assert find_literals('Its been a very crazy procedure right', 'crazy') == ('crazy', 16, 21)",
"assert find_literals('Hardest choices required strongest will', 'will') == ('will', 35, 39)"
] | [] | |
764 | Write a function to find the minimum total path sum in the given triangle. | def noprofit_noloss(actual_cost,sale_amount):
if(sale_amount == actual_cost):
return True
else:
return False | [
"assert min_Swaps(\"1101\",\"1110\") == 1",
"assert min_Swaps(\"1111\",\"0100\") == \"Not Possible\"",
"assert min_Swaps(\"1110000\",\"0001101\") == 3"
] | [] | |
853 | Write a function to find n-th rencontres number. | def triangle_area(r) :
if r < 0 :
return -1
return r * r | [
"assert check_valid((True, True, True, True) ) == True",
"assert check_valid((True, False, True, True) ) == False",
"assert check_valid((True, True, True, True) ) == True"
] | [] | |
901 | Write a function to find the sum of first even and odd number of a given 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 int(lobb_num(5, 3)) == 35",
"assert int(lobb_num(3, 2)) == 5",
"assert int(lobb_num(4, 2)) == 20"
] | [] | |
637 | Write a function to add all the numbers in a list and divide it with the length of the list. | def same_Length(A,B):
while (A > 0 and B > 0):
A = A / 10;
B = B / 10;
if (A == 0 and B == 0):
return True;
return False; | [
"assert re_arrange_tuples([(4, 3), (1, 9), (2, 10), (3, 2)], [1, 4, 2, 3]) == [(1, 9), (4, 3), (2, 10), (3, 2)]",
"assert re_arrange_tuples([(5, 4), (2, 10), (3, 11), (4, 3)], [3, 4, 2, 3]) == [(3, 11), (4, 3), (2, 10), (3, 11)]",
"assert re_arrange_tuples([(6, 3), (3, 8), (5, 7), (2, 4)], [2, 5, 3, 6]) == [... | [] | |
684 | Write a function to count the number of unique lists within a list. | from collections import defaultdict
def freq_element(test_tup):
res = defaultdict(int)
for ele in test_tup:
res[ele] += 1
return (str(dict(res))) | [
"assert check_email(\"ankitrai326@gmail.com\") == 'Valid Email'",
"assert check_email(\"my.ownsite@ourearth.org\") == 'Valid Email'",
"assert check_email(\"ankitaoie326.com\") == 'Invalid Email'"
] | [] | |
694 | Write a function that matches a string that has an a followed by zero or more b's. | def odd_Num_Sum(n) :
j = 0
sm = 0
for i in range(1,n + 1) :
j = (2*i-1)
sm = sm + (j*j*j*j)
return sm | [
"assert is_Word_Present(\"machine learning\",\"machine\") == True",
"assert is_Word_Present(\"easy\",\"fun\") == False",
"assert is_Word_Present(\"python language\",\"code\") == False"
] | [] | |
672 | Write a python function to convert the given string to upper case. | 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 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] "
] | [] | |
730 | Write a function to check if the given integer is a prime number. | def sum_nums(x, y,m,n):
sum_nums= x + y
if sum_nums in range(m, n):
return 20
else:
return sum_nums | [
"assert 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], ... | [] | |
823 | 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 lcs_of_three('AGGT12', '12TXAYB', '12XBA', 6, 7, 5) == 2",
"assert lcs_of_three('Reels', 'Reelsfor', 'ReelsforReels', 5, 8, 13) == 5 ",
"assert lcs_of_three('abcd1e2', 'bc12ea', 'bd1ea', 7, 6, 5) == 3"
] | [] | |
761 | Write a python function to shift first element to the end of given list. | import math
def sum_series(number):
total = 0
total = math.pow((number * (number + 1)) /2, 2)
return total | [
"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]"
] | [] | |
660 | Write a python function to check whether a sequence of numbers has an increasing trend or not. | import re
def extract_max(input):
numbers = re.findall('\d+',input)
numbers = map(int,numbers)
return max(numbers) | [
"assert consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4 ])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4]",
"assert consecutive_duplicates([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10])==[10, 15, 19, 18, 17, 26, 17, 18, 10]",
"assert consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd'])==['a', 'b... | [] | |
930 | Write a function to remove the nested record from the given tuple. | def is_abundant(n):
fctrsum = sum([fctr for fctr in range(1, n) if n % fctr == 0])
return fctrsum > n | [
"assert check_monthnum_number(2)==True",
"assert check_monthnum_number(1)==False",
"assert check_monthnum_number(3)==False"
] | [] | |
789 | ## write a function to find the minimum number of jumps to reach the end of the array for the given array of integers where each element represents the max number of steps that can be made forward from that element. > indented block > indented block | 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 r... | [
"assert min_Jumps(3,4,11)==3.5",
"assert min_Jumps(3,4,0)==0",
"assert min_Jumps(11,14,11)==1"
] | [] | |
879 | Write a function to group the 1st elements on the basis of 2nd elements in the given tuple list. | def count_list(input_list):
return len(input_list) | [
"assert text_starta_endb(\"aabbbb\")==('Found a match!')",
"assert text_starta_endb(\"aabAbbbc\")==('Not matched!')",
"assert text_starta_endb(\"accddbbjjj\")==('Not matched!')"
] | [] | |
640 | Write a python function to add a minimum number such that the sum of array becomes even. | 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 find_combinations([(2, 4), (6, 7), (5, 1), (6, 10)]) == [(8, 11), (7, 5), (8, 14), (11, 8), (12, 17), (11, 11)]",
"assert find_combinations([(3, 5), (7, 8), (6, 2), (7, 11)]) == [(10, 13), (9, 7), (10, 16), (13, 10), (14, 19), (13, 13)]",
"assert find_combinations([(4, 6), (8, 9), (7, 3), (8, 12)]) == [... | [] | |
632 | Write a function to reverse words in a given string. | 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 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 "
] | [] | |
706 | Write a function to count alphabets,digits and special charactes in a given string. | 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 min_Num([1,2,3,4,5,6,7,8,9],9) == 1",
"assert min_Num([1,2,3,4,5,6,7,8],8) == 2",
"assert min_Num([1,2,3],3) == 2"
] | [] | |
945 | Write a function to substract the elements of the given nested tuples. | 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 find_k_product([(5, 6, 7), (1, 3, 5), (8, 9, 19)], 2) == 665",
"assert find_k_product([(6, 7, 8), (2, 4, 6), (9, 10, 20)], 1) == 280",
"assert find_k_product([(7, 8, 9), (3, 5, 7), (10, 11, 21)], 0) == 210"
] | [] | |
878 | Write a function to split the given string at uppercase letters by using regex. | def palindrome_lambda(texts):
result = list(filter(lambda x: (x == "".join(reversed(x))), texts))
return result | [
"assert sort_list([(3, 4, 6, 723), (1, 2), (12345,), (134, 234, 34)] ) == '[(1, 2), (12345,), (3, 4, 6, 723), (134, 234, 34)]'",
"assert sort_list([(3, 4, 8), (1, 2), (1234335,), (1345, 234, 334)] ) == '[(1, 2), (3, 4, 8), (1234335,), (1345, 234, 334)]'",
"assert sort_list([(34, 4, 61, 723), (1, 2), (145,), (13... | [] | |
862 | Write a python function to find sum of all prime divisors of a given number. | import math
def get_Pos_Of_Right_most_Set_Bit(n):
return int(math.log2(n&-n)+1)
def set_Right_most_Unset_Bit(n):
if (n == 0):
return 1
if ((n & (n + 1)) == 0):
return n
pos = get_Pos_Of_Right_most_Set_Bit(~n)
return ((1 << (pos - 1)) | n) | [
"assert max_sum_subseq([1, 2, 9, 4, 5, 0, 4, 11, 6]) == 26",
"assert max_sum_subseq([1, 2, 9, 5, 6, 0, 5, 12, 7]) == 28",
"assert max_sum_subseq([1, 3, 10, 5, 6, 0, 6, 14, 21]) == 44"
] | [] | |
605 | Write a function to convert the given tuple to a key-value dictionary using adjacent elements. | def remove_empty(tuple1): #L = [(), (), ('',), ('a', 'b'), ('a', 'b', 'c'), ('d')]
tuple1 = [t for t in tuple1 if t]
return tuple1 | [
"assert first_Digit(5) == 1",
"assert first_Digit(10) == 3",
"assert first_Digit(7) == 5"
] | [] | |
783 | Write a python function to find even numbers from a mixed list. | import re
def extract_date(url):
return re.findall(r'/(\d{4})/(\d{1,2})/(\d{1,2})/', url) | [
"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]]"... | [] | |
744 | Write a python function to find the smallest missing number from the given array. | def sort_numeric_strings(nums_str):
result = [int(x) for x in nums_str]
result.sort()
return result | [
"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)"
] | [] | |
777 | 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 find_ind(key, i, n,
k, arr):
ind = -1
start = i + 1
end = n - 1;
while (start < end):
mid = int(start +
(end - start) / 2)
if (arr[mid] - key <= k):
ind = mid
start = mid + 1
else:
end = mid
return ind
def removals(arr, n, k):
ans = n - 1
arr.sort()
for i in range(0, ... | [
"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"
] | [] | |
959 | Write a function to compute the value of ncr mod p. | def sum_Of_Subarray_Prod(arr,n):
ans = 0
res = 0
i = n - 1
while (i >= 0):
incr = arr[i]*(1 + res)
ans += incr
res = incr
i -= 1
return (ans) | [
"assert clear_tuple((1, 5, 3, 6, 8)) == ()",
"assert clear_tuple((2, 1, 4 ,5 ,6)) == ()",
"assert clear_tuple((3, 2, 5, 6, 8)) == ()"
] | [] | |
622 | Write a function to get dictionary keys as a list. | def mul_consecutive_nums(nums):
result = [b*a for a, b in zip(nums[:-1], nums[1:])]
return result | [
"assert slope(4,2,2,5) == -1.5",
"assert slope(2,4,4,6) == 1",
"assert slope(1,2,4,2) == 0"
] | [] | |
659 | Write a function to sort the given array by using heap sort. | 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 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... | [] | |
910 | Write a function to find the perimeter of a rombus. | 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 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}'"
] | [] | |
685 | Write a python function to choose points from two ranges such that no point lies in both the ranges. | def maximum_value(test_list):
res = [(key, max(lst)) for key, lst in test_list]
return (res) | [
"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]"
] | [] | |
802 | Write a function to check for a number at the end of a string. | def fifth_Power_Sum(n) :
sm = 0
for i in range(1,n+1) :
sm = sm + (i*i*i*i*i)
return sm | [
"assert div_list([4,5,6],[1, 2, 3])==[4.0,2.5,2.0]",
"assert div_list([3,2],[1,4])==[3.0, 0.5]",
"assert div_list([90,120],[50,70])==[1.8, 1.7142857142857142]"
] | [] | |
629 | Write a function to convert rgb color to hsv color. | def area_trapezium(base1,base2,height):
area = 0.5 * (base1 + base2) * height
return area | [
"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]"
] | [] | |
648 | Write a function to concatenate the given two tuples to a nested tuple. | def floor_Min(A,B,N):
x = max(B - 1,N)
return (A*x) // B | [
"assert sort_sublists([[2], [0], [1, 3], [0, 7], [9, 11], [13, 15, 17]])==[[0], [2], [0, 7], [1, 3], [9, 11], [13, 15, 17]]",
"assert sort_sublists([[1], [2, 3], [4, 5, 6], [7], [10, 11]])==[[1], [7], [2, 3], [10, 11], [4, 5, 6]]",
"assert sort_sublists([[\"python\"],[\"java\",\"C\",\"C++\"],[\"DBMS\"],[\"SQL\"... | [] | |
836 | Write a python function to find the minimum difference between any two elements in a given array. | def is_key_present(d,x):
if x in d:
return True
else:
return False | [
"assert get_noOfways(4)==3",
"assert get_noOfways(3)==2",
"assert get_noOfways(5)==5"
] | [] | |
842 | Write a function to check a decimal with a precision of 2. | 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 match_num('5-2345861')==True",
"assert match_num('6-2345861')==False",
"assert match_num('78910')==False"
] | [] | |
828 | Write a function to find the product of it’s kth index in the given tuples. | def get_key(dict):
list = []
for key in dict.keys():
list.append(key)
return list | [
"assert odd_Num_Sum(2) == 82",
"assert odd_Num_Sum(3) == 707",
"assert odd_Num_Sum(4) == 3108"
] | [] | |
661 | Write a function to check whether the given month number contains 28 days or not. | import cmath
def len_complex(a,b):
cn=complex(a,b)
length=abs(cn)
return length | [
"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... | [] | |
767 | Write a function to push all values into a heap and then pop off the smallest values one at a time. | def remove_list_range(list1, leftrange, rigthrange):
result = [i for i in list1 if (min(i)>=leftrange and max(i)<=rigthrange)]
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... | [] | |
816 | Write a python function to find the sum of non-repeated elements in a given array. | 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 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])"
] | [] | |
726 | Write a python function to find lcm of two positive integers. | def access_key(ditionary,key):
return list(ditionary)[key] | [
"assert chinese_zodiac(1997)==('Ox')",
"assert chinese_zodiac(1998)==('Tiger')",
"assert chinese_zodiac(1994)==('Dog')"
] | [] | |
692 | Write a python function to get the last element of each sublist. | def check_subset(list1,list2):
return all(map(list1.__contains__,list2)) | [
"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]]"
] | [] | |
790 | Write a function to convert camel case string to snake case string. | 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 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]"
] | [] | |
793 | Write a function to count the number of elements in a list which are within a specific range. | 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 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"
] | [] | |
850 | Write a function to convert a roman numeral to an integer. | from itertools import groupby
def pack_consecutive_duplicates(list1):
return [list(group) for key, group in groupby(list1)] | [
"assert text_uppercase_lowercase(\"AaBbGg\")==('Found a match!')",
"assert text_uppercase_lowercase(\"aA\")==('Not matched!')",
"assert text_uppercase_lowercase(\"PYTHON\")==('Not matched!')"
] | [] |
End of preview. Expand in Data Studio
edition_3112_google-research-datasets-mbpp-readymade
A Readymade by TheFactoryX
Original Dataset
Process
This dataset is a "readymade" - inspired by Marcel Duchamp's concept of taking everyday objects and recontextualizing them as art.
What we did:
- Selected the original dataset from Hugging Face
- Shuffled each column independently
- Destroyed all row-wise relationships
- 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
- 6