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 |
|---|---|---|---|---|---|
744 | Write a function to count those characters which have vowels as their neighbors in the given string. | def floor_Min(A,B,N):
x = max(B - 1,N)
return (A*x) // B | [
"assert min_difference([(3, 5), (1, 7), (10, 3), (1, 2)]) == 1",
"assert min_difference([(4, 6), (12, 8), (11, 4), (2, 13)]) == 2",
"assert min_difference([(5, 17), (3, 9), (12, 5), (3, 24)]) == 6"
] | [] | |
908 | Write a function to find the occurrences of n most common words in a given text. | def lcs_of_three(X, Y, Z, m, n, o):
L = [[[0 for i in range(o+1)] for j in range(n+1)]
for k in range(m+1)]
for i in range(m+1):
for j in range(n+1):
for k in range(o+1):
if (i == 0 or j == 0 or k == 0):
L[i][j][k] = 0
elif (X[i-1] == Y[j-1] and
X[i-1] == Z[k-1]):
L[i][... | [
"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"
] | [] | |
690 | Write a function to find minimum k records from tuple list. | 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 max_of_three(10,20,30)==30",
"assert max_of_three(55,47,39)==55",
"assert max_of_three(10,49,30)==49"
] | [] | |
677 | Write a python function to check whether the count of divisors is even or odd. | def check_Type_Of_Triangle(a,b,c):
sqa = pow(a,2)
sqb = pow(b,2)
sqc = pow(c,2)
if (sqa == sqa + sqb or sqb == sqa + sqc or sqc == sqa + sqb):
return ("Right-angled Triangle")
elif (sqa > sqc + sqb or sqb > sqa + sqc or sqc > sqa + sqb):
return ("Obtuse-angled Triangle"... | [
"assert raw_heap([25, 44, 68, 21, 39, 23, 89])==[21, 25, 23, 44, 39, 68, 89]",
"assert raw_heap([25, 35, 22, 85, 14, 65, 75, 25, 58])== [14, 25, 22, 25, 35, 65, 75, 85, 58]",
"assert raw_heap([4, 5, 6, 2])==[2, 4, 6, 5]"
] | [] | |
745 | Write a function to remove duplicate words from a given list of strings. | 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 word_len(\"program\") == False",
"assert word_len(\"solution\") == True",
"assert word_len(\"data\") == True"
] | [] | |
866 | Write a function that matches a word containing 'z', not at the start or end of the word. | def remove_empty(tuple1): #L = [(), (), ('',), ('a', 'b'), ('a', 'b', 'c'), ('d')]
tuple1 = [t for t in tuple1 if t]
return tuple1 | [
"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)"
... | [] | |
800 | Write a python function to shift first element to the end of given list. | def find_longest_conseq_subseq(arr, n):
ans = 0
count = 0
arr.sort()
v = []
v.append(arr[0])
for i in range(1, n):
if (arr[i] != arr[i - 1]):
v.append(arr[i])
for i in range(len(v)):
if (i > 0 and v[i] == v[i - 1] + 1):
count += 1
else:
count = 1
ans = max(ans, count)
... | [
"assert sum_num((8, 2, 3, 0, 7))==4.0",
"assert sum_num((-10,-20,-30))==-20.0",
"assert sum_num((19,15,18))==17.333333333333332"
] | [] | |
806 | Write a python function to find the average of a list. | import re
def road_rd(street):
return (re.sub('Road$', 'Rd.', street)) | [
"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"
] | [] | |
631 | Write a function to remove everything except alphanumeric characters from the given string by using regex. | def find_Min_Diff(arr,n):
arr = sorted(arr)
diff = 10**20
for i in range(n-1):
if arr[i+1] - arr[i] < diff:
diff = arr[i+1] - arr[i]
return diff | [
"assert fifth_Power_Sum(2) == 33",
"assert fifth_Power_Sum(4) == 1300",
"assert fifth_Power_Sum(3) == 276"
] | [] | |
858 | Write a function to remove consecutive duplicates of a given list. | 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 test_three_equal(1,1,1) == 3",
"assert test_three_equal(-1,-2,-3) == 0",
"assert test_three_equal(1,2,2) == 2"
] | [] | |
668 | Write a function to convert the given string of integers into a tuple. | import math
def round_up(a, digits):
n = 10**-digits
return round(math.ceil(a / n) * n, digits) | [
"assert check_identical([(10, 4), (2, 5)], [(10, 4), (2, 5)]) == True",
"assert check_identical([(1, 2), (3, 7)], [(12, 14), (12, 45)]) == False",
"assert check_identical([(2, 14), (12, 25)], [(2, 14), (12, 25)]) == True"
] | [] | |
893 | Write a function to count the frequency of consecutive duplicate elements in a given list of numbers. | def count_list(input_list):
return (len(input_list))**2 | [
"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"
] | [] | |
602 | Write a function to get a lucid number smaller than or equal to n. | 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 sd_calc([4, 2, 5, 8, 6])== 2.23606797749979",
"assert sd_calc([1,2,3,4,5,6,7])==2.160246899469287",
"assert sd_calc([5,9,10,15,6,4])==4.070217029430577"
] | [] | |
928 | Write a function to sort the given tuple list basis the total digits in tuple. | def check_identical(test_list1, test_list2):
res = test_list1 == test_list2
return (res) | [
"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])"
] | [] | |
941 | Write a function to remove multiple spaces in a string. | def max_of_nth(test_list, N):
res = max([sub[N] for sub in test_list])
return (res) | [
"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']]"
] | [] | |
921 | Write a function to count number of unique lists within a list. | def sum_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 dealnnoy_num(3, 4) == 129",
"assert dealnnoy_num(3, 3) == 63",
"assert dealnnoy_num(4, 5) == 681"
] | [] | |
803 | Write a function to extract values between quotation marks of the given string by using regex. | 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_positivenum([2, 4, -6, -9, 11, -12, 14, -5, 17])==48",
"assert sum_positivenum([10,15,-14,13,-18,12,-20])==50",
"assert sum_positivenum([19, -65, 57, 39, 152,-639, 121, 44, 90, -190])==522"
] | [] | |
875 | Write a function to find palindromes in a given list of strings using lambda function. | def left_rotate(s,d):
tmp = s[d : ] + s[0 : d]
return tmp | [
"assert number_ctr('program2bedone') == 1",
"assert number_ctr('3wonders') ==1",
"assert number_ctr('123') == 3"
] | [] | |
725 | Write a function to access the initial and last data of the given tuple record. | import re
def text_match_wordz_middle(text):
patterns = '\Bz\B'
if re.search(patterns, text):
return 'Found a match!'
else:
return('Not matched!') | [
"assert check_monthnumber_number(6)==True",
"assert check_monthnumber_number(2)==False",
"assert check_monthnumber_number(12)==False"
] | [] | |
881 | Write a function to split the given string at uppercase letters by using regex. | 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 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')"
] | [] | |
845 | Write a python function to multiply all items in the list. | 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 sum_column( [[1,2,3,2],[4,5,6,2],[7,8,9,5],],0)==12",
"assert sum_column( [[1,2,3,2],[4,5,6,2],[7,8,9,5],],1)==15",
"assert sum_column( [[1,2,3,2],[4,5,6,2],[7,8,9,5],],3)==9"
] | [] | |
728 | Write a python function to merge the first and last elements separately in a list of lists. | 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 palindrome_lambda([\"php\", \"res\", \"Python\", \"abcd\", \"Java\", \"aaa\"])==['php', 'aaa']",
"assert palindrome_lambda([\"abcd\", \"Python\", \"abba\", \"aba\"])==['abba', 'aba']",
"assert palindrome_lambda([\"abcd\", \"abbccbba\", \"abba\", \"aba\"])==['abbccbba', 'abba', 'aba']"
] | [] | |
956 | Write a function to find the maximum of nth column from the given tuple list. | def Diff(li1,li2):
return (list(list(set(li1)-set(li2)) + list(set(li2)-set(li1))))
| [
"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,... | [] | |
954 | Write a function to check whether the given string is ending with only alphanumeric characters or not using regex. | def heap_sort(arr):
heapify(arr)
end = len(arr) - 1
while end > 0:
arr[end], arr[0] = arr[0], arr[end]
shift_down(arr, 0, end - 1)
end -= 1
return arr
def heapify(arr):
start = len(arr) // 2
while start >= 0:
shift_down(arr, start, len(arr) - 1)
... | [
"assert average_Even(2) == 2",
"assert average_Even(4) == 3",
"assert average_Even(100) == 51"
] | [] | |
674 | Write a function to check if the string is a valid email address or not using regex. | 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 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)"
] | [] | |
781 | Write a function to find the previous palindrome of a specified number. | def is_odd(n) :
if (n^1 == n-1) :
return True;
else :
return False; | [
"assert sum_list([10,20,30],[15,25,35])==[25,45,65]",
"assert sum_list([1,2,3],[5,6,7])==[6,8,10]",
"assert sum_list([15,20,30],[15,45,75])==[30,65,105]"
] | [] | |
624 | Write a python function to find the index of smallest triangular number with n digits. | def count_range_in_list(li, min, max):
ctr = 0
for x in li:
if min <= x <= max:
ctr += 1
return ctr | [
"assert (max_height(root)) == 3",
"assert (max_height(root1)) == 5 ",
"assert (max_height(root2)) == 4"
] | [] | |
749 | Write a function to find all anagrams of a string in a given list of strings using lambda function. | def max_product(arr):
arr_len = len(arr)
if (arr_len < 2):
return None
x = arr[0]; y = arr[1]
for i in range(0, arr_len):
for j in range(i + 1, arr_len):
if (arr[i] * arr[j] > x * y):
x = arr[i]; y = arr[j]
return x,y | [
"assert mutiple_tuple((4, 3, 2, 2, -1, 18)) == -864",
"assert mutiple_tuple((1,2,3)) == 6",
"assert mutiple_tuple((-2,-4,-6)) == -48"
] | [] | |
709 | Write a function to solve tiling problem. | def sum_list(lst1,lst2):
res_list = [lst1[i] + lst2[i] for i in range(len(lst1))]
return res_list | [
"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')"
] | [] | |
818 | Write a python function to calculate the product of all the numbers of a given tuple. | import re
regex = '[a-zA-z0-9]$'
def check_alphanumeric(string):
if(re.search(regex, string)):
return ("Accept")
else:
return ("Discard") | [
"assert max_sum_list([[1,2,3], [4,5,6], [10,11,12], [7,8,9]])==[10, 11, 12] ",
"assert max_sum_list([[3,2,1], [6,5,4], [12,11,10]])==[12,11,10] ",
"assert max_sum_list([[2,3,1]])==[2,3,1] "
] | [] | |
824 | Write a function to calculate the sum of series 1²+2²+3²+….+n². | import re
def text_starta_endb(text):
patterns = 'a.*?b$'
if re.search(patterns, text):
return 'Found a match!'
else:
return('Not matched!') | [
"assert is_odd(5) == True",
"assert is_odd(6) == False",
"assert is_odd(7) == True"
] | [] | |
618 | Write a function to calculate the standard deviation. | def area_trapezium(base1,base2,height):
area = 0.5 * (base1 + base2) * height
return area | [
"assert is_nonagonal(10) == 325",
"assert is_nonagonal(15) == 750",
"assert is_nonagonal(18) == 1089"
] | [] | |
916 | Write a function to find the smallest multiple of the first n numbers. | def word_len(s):
s = s.split(' ')
for word in s:
if len(word)%2==0:
return True
else:
return False | [
"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\"... | [] | |
775 | Write a python function to find sum of odd factors of a number. | def is_decimal(num):
import re
dnumre = re.compile(r"""^[0-9]+(\.[0-9]{1,2})?$""")
result = dnumre.search(num)
return bool(result) | [
"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)"
] | [] | |
641 | Write a function to find out the second most repeated (or frequent) string in the given sequence. | def Extract(lst):
return [item[-1] for item in lst] | [
"assert match_num('5-2345861')==True",
"assert match_num('6-2345861')==False",
"assert match_num('78910')==False"
] | [] | |
873 | Write a function to check if the given integer is a prime number. | from operator import eq
def count_same_pair(nums1, nums2):
result = sum(map(eq, nums1, nums2))
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"
] | [] | |
819 | Write a function to caluclate perimeter of a parallelogram. | def sum_Of_Primes(n):
prime = [True] * (n + 1)
p = 2
while p * p <= n:
if prime[p] == True:
i = p * 2
while i <= n:
prime[i] = False
i += p
p += 1
sum = 0
for i in range (2,n + 1):
if(prime[i]): ... | [
"assert is_decimal('123.11')==True",
"assert is_decimal('e666.86')==False",
"assert is_decimal('3.124587')==False"
] | [] | |
960 | Write a function to caluclate arc length of an angle. | 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 Check_Solution(2,5,2) == \"2 solutions\"",
"assert Check_Solution(1,1,1) == \"No solutions\"",
"assert Check_Solution(1,2,1) == \"1 solution\""
] | [] | |
953 | Write a function to replace all occurrences of spaces, commas, or dots with a colon. | def div_of_nums(nums,m,n):
result = list(filter(lambda x: (x % m == 0 and x % n == 0), nums))
return result | [
"assert first_repeated_char(\"abcabc\") == \"a\"",
"assert first_repeated_char(\"abc\") == \"None\"",
"assert first_repeated_char(\"123123\") == \"1\""
] | [] | |
777 | Write a python function to find the sum of all odd length subarrays. | def sector_area(r,a):
pi=22/7
if a >= 360:
return None
sectorarea = (pi*r**2) * (a/360)
return sectorarea | [
"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')"
] | [] | |
804 | Write a function to calculate wind chill index. | 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 min_Swaps(\"1101\",\"1110\") == 1",
"assert min_Swaps(\"1111\",\"0100\") == \"Not Possible\"",
"assert min_Swaps(\"1110000\",\"0001101\") == 3"
] | [] | |
879 | Write a function to find the product of first even and odd number of a given list. | def check_tuples(test_tuple, K):
res = all(ele in K for ele in test_tuple)
return (res) | [
"assert check_valid((True, True, True, True) ) == True",
"assert check_valid((True, False, True, True) ) == False",
"assert check_valid((True, True, True, True) ) == True"
] | [] | |
844 | Write a function to find minimum of two numbers. | def max_sum_list(lists):
return max(lists, key=sum) | [
"assert check_monthnumb(\"February\")==False",
"assert check_monthnumb(\"January\")==True",
"assert check_monthnumb(\"March\")==True"
] | [] | |
633 | Write a function to iterate over elements repeating each as many times as its count. | def check_K(test_tup, K):
res = False
for ele in test_tup:
if ele == K:
res = True
break
return (res) | [
"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'"
] | [] | |
783 | Write a function to convert a roman numeral to an integer. | 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 second_smallest([1, 2, -8, -2, 0, -2])==-2",
"assert second_smallest([1, 1, -0.5, 0, 2, -2, -2])==-0.5",
"assert second_smallest([2,2])==None"
] | [] | |
609 | Write a function to get an item of a tuple. | def all_Characters_Same(s) :
n = len(s)
for i in range(1,n) :
if s[i] != s[0] :
return False
return True | [
"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\") ] "
] | [] | |
860 | Write a python function to check whether the given string is made up of two alternating characters or not. | 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 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"
] | [] | |
825 | Write a python function to find the smallest prime divisor of a number. | def mul_consecutive_nums(nums):
result = [b*a for a, b in zip(nums[:-1], nums[1:])]
return result | [
"assert is_Word_Present(\"machine learning\",\"machine\") == True",
"assert is_Word_Present(\"easy\",\"fun\") == False",
"assert is_Word_Present(\"python language\",\"code\") == False"
] | [] | |
811 | Write a function to find the combinations of sums with tuples in the given tuple list. | from itertools import groupby
def pack_consecutive_duplicates(list1):
return [list(group) for key, group in groupby(list1)] | [
"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)"
] | [] | |
936 | Write a function to add a dictionary to the tuple. | 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 mul_consecutive_nums([1, 1, 3, 4, 4, 5, 6, 7])==[1, 3, 12, 16, 20, 30, 42]",
"assert mul_consecutive_nums([4, 5, 8, 9, 6, 10])==[20, 40, 72, 54, 60]",
"assert mul_consecutive_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[2, 6, 12, 20, 30, 42, 56, 72, 90]"
] | [] | |
634 | Write a python function to count the number of equal numbers from three given integers. | 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 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',... | [] | |
656 | Write a function to generate all sublists of a given list. | 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 max_of_two(10,20)==20",
"assert max_of_two(19,15)==19",
"assert max_of_two(-10,-20)==-10"
] | [] | |
823 | Write a python function to check if roots of a quadratic equation are reciprocal of each other or not. | 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 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"
] | [] | |
682 | Write a function to find the list in a list of lists whose sum of elements is the highest. | def cummulative_sum(test_list):
res = sum(map(sum, test_list))
return (res) | [
"assert sum_of_odd_Factors(30) == 24",
"assert sum_of_odd_Factors(18) == 13",
"assert sum_of_odd_Factors(2) == 1"
] | [] | |
897 | Write a python function to check whether the roots of a quadratic equation are numerically equal but opposite in sign or not. | def divisible_by_digits(startnum, endnum):
return [n for n in range(startnum, endnum+1) \
if not any(map(lambda x: int(x) == 0 or n%int(x) != 0, str(n)))] | [
"assert area_tetrahedron(3)==15.588457268119894",
"assert area_tetrahedron(20)==692.8203230275509",
"assert area_tetrahedron(10)==173.20508075688772"
] | [] | |
829 | Write a function where a string will start with a specific number. | import re
def remove_all_spaces(text):
return (re.sub(r'\s+', '',text)) | [
"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)"
] | [] | |
894 | Write a python function to left rotate the string. | 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 sort_list_last([(2, 5), (1, 2), (4, 4), (2, 3), (2, 1)])==[(2, 1), (1, 2), (2, 3), (4, 4), (2, 5)] ",
"assert sort_list_last([(9,8), (4, 7), (3,5), (7,9), (1,2)])==[(1,2), (3,5), (4,7), (9,8), (7,9)] ",
"assert sort_list_last([(20,50), (10,20), (40,40)])==[(10,20),(40,40),(20,50)] "
] | [] | |
874 | Write a python function to find the first odd number in a given list of numbers. | 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 count_same_pair([1, 2, 3, 4, 5, 6, 7, 8],[2, 2, 3, 1, 2, 6, 7, 9])==4",
"assert count_same_pair([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8],[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==11",
"assert count_same_pair([2, 4, -6, -9, 11, -12, 14, -5, 17],[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==1"
] | [] | |
835 | Write a function to find the maximum sum that can be formed which has no three consecutive elements present. | 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 sector_area(4,45)==6.285714285714286",
"assert sector_area(9,45)==31.82142857142857",
"assert sector_area(9,360)==None"
] | [] | |
944 | Write a function to substract the elements of the given nested tuples. | def decreasing_trend(nums):
if (sorted(nums)== nums):
return True
else:
return False | [
"assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},6.0,70)=={'Cierra Vega': (6.2, 70)}",
"assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},5.9,67)=={'Cierra ... | [] | |
854 | Write a function to sort dictionary items by tuple product of keys for the given dictionary with tuple keys. | def remove_duplic_list(l):
temp = []
for x in l:
if x not in temp:
temp.append(x)
return temp | [
"assert Check_Solution(2,0,2) == \"Yes\"",
"assert Check_Solution(2,-5,2) == \"Yes\"",
"assert Check_Solution(1,2,3) == \"No\""
] | [] | |
847 | Write a function to remove sublists from a given list of lists, which are outside a given range. | def div_of_nums(nums,m,n):
result = list(filter(lambda x: (x % m == 0 or x % n == 0), nums))
return result | [
"assert even_num(13.5)==False",
"assert even_num(0)==True",
"assert even_num(-9)==False"
] | [] | |
746 | Write a function to exchange the position of every n-th value with (n+1)th value and (n+1)th value with n-th value in a given list. | def is_upper(string):
return (string.upper()) | [
"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)]"
] | [] | |
694 | Write a function to find numbers divisible by m or n from a list of numbers using lambda function. | def sum_Range_list(nums, m, n):
sum_range = 0 ... | [
"assert max_occurrences([2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,4,6,9,1,2])==2",
"assert max_occurrences([1, 3,5, 7,1, 3,13, 15, 17,5, 7,9,1, 11])==1",
"assert max_occurrences([1, 2, 3,2, 4, 5,1, 1, 1])==1"
] | [] | |
779 | Write a function to separate and print the numbers and their position of a given string. | def subset(ar, n):
res = 0
ar.sort()
for i in range(0, n) :
count = 1
for i in range(n - 1):
if ar[i] == ar[i + 1]:
count+=1
else:
break
res = max(res, count)
return res | [
"assert is_Perfect_Square(10) == False",
"assert is_Perfect_Square(36) == True",
"assert is_Perfect_Square(14) == False"
] | [] | |
812 | Write a function to convert the given tuples into set. | def palindrome_lambda(texts):
result = list(filter(lambda x: (x == "".join(reversed(x))), texts))
return result | [
"assert find_Digits(7) == 4",
"assert find_Digits(5) == 3",
"assert find_Digits(4) == 2"
] | [] | |
917 | Write a python function to left rotate the bits of a given number. | def find_triplet_array(A, arr_size, sum):
for i in range( 0, arr_size-2):
for j in range(i + 1, arr_size-1):
for k in range(j + 1, arr_size):
if A[i] + A[j] + A[k] == sum:
return A[i],A[j],A[k]
return True
return False | [
"assert 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"
] | [] | |
759 | Write a function to find the minimum number of elements that should be removed such that amax-amin<=k. | from itertools import groupby
def consecutive_duplicates(nums):
return [key for key, group in groupby(nums)] | [
"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"
] | [] | |
724 | Write a function to find length of the subarray having maximum sum. | def binomial_coeffi(n, k):
if (k == 0 or k == n):
return 1
return (binomial_coeffi(n - 1, k - 1)
+ binomial_coeffi(n - 1, k))
def rencontres_number(n, m):
if (n == 0 and m == 0):
return 1
if (n == 1 and m == 0):
return 0
if (m == 0):
return ((n - 1) * (rencontres_number(n - 1, 0)+ renc... | [
"assert Sum(60) == 10",
"assert Sum(39) == 16",
"assert Sum(40) == 7"
] | [] | |
791 | Write a function to find the largest possible value of k such that k modulo x is y. | def chinese_zodiac(year):
if (year - 2000) % 12 == 0:
sign = 'Dragon'
elif (year - 2000) % 12 == 1:
sign = 'Snake'
elif (year - 2000) % 12 == 2:
sign = 'Horse'
elif (year - 2000) % 12 == 3:
sign = 'sheep'
elif (year - 2000) % 12 == 4:
sign = 'Monkey'
elif (year - 2000) % 12 == ... | [
"assert find_Index(2) == 4",
"assert find_Index(3) == 14",
"assert find_Index(4) == 45"
] | [] | |
801 | Write a function to convert camel case string to snake case string. | def check_Odd_Parity(x):
parity = 0
while (x != 0):
x = x & (x - 1)
parity += 1
if (parity % 2 == 1):
return True
else:
return False | [
"assert all_Characters_Same(\"python\") == False",
"assert all_Characters_Same(\"aaa\") == True",
"assert all_Characters_Same(\"data\") == False"
] | [] | |
722 | Write a function to find the maximum of similar indices in two lists of tuples. | def convert(list):
s = [str(i) for i in list]
res = int("".join(s))
return (res) | [
"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]"
] | [] | |
756 | Write a python function to check whether the given two numbers have same number of digits or not. | 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 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... | [] | |
704 | Write a function to add the given tuple to the given list. | import re
def replace(string, char):
pattern = char + '{2,}'
string = re.sub(pattern, char, string)
return string | [
"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]]"... | [] | |
891 | Write a python function to find even numbers from a mixed list. | def all_Bits_Set_In_The_Given_Range(n,l,r):
num = ((1 << r) - 1) ^ ((1 << (l - 1)) - 1)
new_num = n & num
if (num == new_num):
return True
return False | [
"assert 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]) == [... | [] | |
964 | Write a function to calculate the sum of series 1³+2³+3³+….+n³. | 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'"
] | [] | |
684 | Write a function to calculate the harmonic sum of n-1. | def is_abundant(n):
fctrsum = sum([fctr for fctr in range(1, n) if n % fctr == 0])
return fctrsum > n | [
"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... | [] | |
957 | Write a function to sort a list of dictionaries using lambda function. | def remove_similar_row(test_list):
res = set(sorted([tuple(sorted(set(sub))) for sub in test_list]))
return (res) | [
"assert check_greater((10, 4, 5), (13, 5, 18)) == True",
"assert check_greater((1, 2, 3), (2, 1, 4)) == False",
"assert check_greater((4, 5, 6), (5, 6, 7)) == True"
] | [] | |
867 | Write a function to split a string at uppercase letters. | def check_subset(test_tup1, test_tup2):
res = set(test_tup2).issubset(test_tup1)
return (res) | [
"assert convert([1,2,3]) == 123",
"assert convert([4,5,6]) == 456",
"assert convert([7,8,9]) == 789"
] | [] | |
659 | Write a function that gives profit amount if the given amount has profit else return none. | def access_key(ditionary,key):
return list(ditionary)[key] | [
"assert camel_to_snake('PythonProgram')==('python_program')",
"assert camel_to_snake('pythonLanguage')==('python_language')",
"assert camel_to_snake('ProgrammingLanguage')==('programming_language')"
] | [] | |
769 | Write a function to rearrange positive and negative numbers in a given array using lambda function. | def min_difference(test_list):
temp = [abs(b - a) for a, b in test_list]
res = min(temp)
return (res) | [
"assert left_Rotate(16,2) == 64",
"assert left_Rotate(10,2) == 40",
"assert left_Rotate(99,3) == 792"
] | [] | |
734 | Write a function to check whether the given ip address is valid or not using regex. | import sys
def find_closet(A, B, C, p, q, r):
diff = sys.maxsize
res_i = 0
res_j = 0
res_k = 0
i = 0
j = 0
k = 0
while(i < p and j < q and k < r):
minimum = min(A[i], min(B[j], C[k]))
maximum = max(A[i], max(B[j], C[k]));
if maximum-minimum < diff:
res_i = i
res_j = j
re... | [
"assert remove_duplic_list([\"Python\", \"Exercises\", \"Practice\", \"Solution\", \"Exercises\"])==['Python', 'Exercises', 'Practice', 'Solution']",
"assert remove_duplic_list([\"Python\", \"Exercises\", \"Practice\", \"Solution\", \"Exercises\",\"Java\"])==['Python', 'Exercises', 'Practice', 'Solution', 'Java']... | [] | |
878 | Write a function to extract year, month and date from a url by using regex. | def last(n):
return n[-1]
def sort_list_last(tuples):
return sorted(tuples, key=last) | [
"assert count_vowels('bestinstareels') == 7",
"assert count_vowels('partofthejourneyistheend') == 12",
"assert count_vowels('amazonprime') == 5"
] | [] | |
966 | Write a python function to find the kth element in an array containing odd elements first and then even elements. | 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 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... | [] | |
925 | Write a function to remove all characters except letters and numbers using regex | def ntimes_list(nums,n):
result = map(lambda x:n*x, nums)
return list(result) | [
"assert chinese_zodiac(1997)==('Ox')",
"assert chinese_zodiac(1998)==('Tiger')",
"assert chinese_zodiac(1994)==('Dog')"
] | [] | |
780 | Write a function to add two lists using map and lambda function. | import cmath
def len_complex(a,b):
cn=complex(a,b)
length=abs(cn)
return length | [
"assert int(lobb_num(5, 3)) == 35",
"assert int(lobb_num(3, 2)) == 5",
"assert int(lobb_num(4, 2)) == 20"
] | [] | |
707 | Write a function to calculate the sum of all digits of the base to the specified power. | def div_list(nums1,nums2):
result = map(lambda x, y: x / y, nums1, nums2)
return list(result) | [
"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"
] | [] | |
912 | Write a python function to count lower case letters in a given string. | 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 wind_chill(120,35)==40",
"assert wind_chill(40,70)==86",
"assert wind_chill(10,100)==116"
] | [] | |
672 | Write a function to calculate the sum of the positive numbers of a given list of numbers using lambda function. | 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 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... | [] | |
952 | Write a python function to interchange first and last elements in a given list. | def number_ctr(str):
number_ctr= 0
for i in range(len(str)):
if str[i] >= '0' and str[i] <= '9': number_ctr += 1
return number_ctr | [
"assert 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"
] | [] | |
606 | Write a python function to remove spaces from a given string. | def Average(lst):
return sum(lst) / len(lst) | [
"assert check_smaller((1, 2, 3), (2, 3, 4)) == False",
"assert check_smaller((4, 5, 6), (3, 4, 5)) == True",
"assert check_smaller((11, 12, 13), (10, 11, 12)) == True"
] | [] | |
841 | Write a python function to find number of solutions in quadratic equation. | 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"
] | [] | |
760 | Write a function to remove the nested record from the given tuple. | import heapq
def cheap_items(items,n):
cheap_items = heapq.nsmallest(n, items, key=lambda s: s['price'])
return cheap_items | [
"assert int_to_roman(1)==(\"I\")",
"assert int_to_roman(50)==(\"L\")",
"assert int_to_roman(4)==(\"IV\")"
] | [] | |
802 | Write a function to combine two dictionaries by adding values for common keys. | 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 min_jumps([1, 3, 6, 1, 0, 9], 6) == 3",
"assert min_jumps([1, 3, 5, 8, 9, 2, 6, 7, 6, 8, 9], 11) == 3",
"assert min_jumps([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 11) == 10"
] | [] | |
710 | Write a function to check if the given array represents min heap or not. | def second_smallest(numbers):
if (len(numbers)<2):
return
if ((len(numbers)==2) and (numbers[0] == numbers[1]) ):
return
dup_items = set()
uniq_items = []
for x in numbers:
if x not in dup_items:
uniq_items.append(x)
dup_items.add(x)
uniq_items.sort()
return uniq_... | [
"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]"
] | [] | |
830 | Write a python function to remove even numbers from a given list. | import heapq as hq
def raw_heap(rawheap):
hq.heapify(rawheap)
return rawheap | [
"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)"
] | [] | |
612 | Write a function to solve the fibonacci sequence using recursion. | 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 return_sum({'a': 100, 'b':200, 'c':300}) == 600",
"assert return_sum({'a': 25, 'b':18, 'c':45}) == 88",
"assert return_sum({'a': 36, 'b':39, 'c':49}) == 124"
] | [] | |
715 | Write a function to extract specified number of elements from a given list, which follow each other continuously. | def sum_positivenum(nums):
sum_positivenum = list(filter(lambda nums:nums>0,nums))
return sum(sum_positivenum) | [
"assert remove_parenthesis([\"python (chrome)\"])==(\"python\")",
"assert remove_parenthesis([\"string(.abc)\"])==(\"string\")",
"assert remove_parenthesis([\"alpha(num)\"])==(\"alpha\")"
] | [] | |
605 | 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 sum_column(list1, C):
result = sum(row[C] for row in list1)
return result | [
"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"
] | [] | |
767 | Write a python function to check whether an array contains only one distinct element or not. | def fibonacci(n):
if n == 1 or n == 2:
return 1
else:
return (fibonacci(n - 1) + (fibonacci(n - 2))) | [
"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"
] | [] |
End of preview. Expand in Data Studio
edition_2045_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
- 5