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 |
|---|---|---|---|---|---|
896 | Write a function to caluclate arc length of an angle. | def Extract(lst):
return [item[-1] for item in lst] | [
"assert max_sub_array_sum([-2, -3, 4, -1, -2, 1, 5, -3],8) == 5",
"assert max_sub_array_sum([1, -2, 1, 1, -2, 1],6) == 2",
"assert max_sub_array_sum([-1, -2, 3, 4, 5],5) == 3"
] | [] | |
888 | Write a python function to check whether all the characters are same or not. | 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 clear_tuple((1, 5, 3, 6, 8)) == ()",
"assert clear_tuple((2, 1, 4 ,5 ,6)) == ()",
"assert clear_tuple((3, 2, 5, 6, 8)) == ()"
] | [] | |
912 | Write a python function to count the number of distinct power of prime factor of given number. | def get_item(tup1,index):
item = tup1[index]
return item | [
"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"
] | [] | |
721 | Write a python function to replace multiple occurence of character by single. | def average_Even(n) :
if (n% 2!= 0) :
return ("Invalid Input")
return -1
sm = 0
count = 0
while (n>= 2) :
count = count+1
sm = sm+n
n = n-2
return sm // count | [
"assert int(lobb_num(5, 3)) == 35",
"assert int(lobb_num(3, 2)) == 5",
"assert int(lobb_num(4, 2)) == 20"
] | [] | |
949 | Write a function to flatten the given tuple matrix into the tuple list with each tuple representing each column. | 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 min_k([('Manjeet', 10), ('Akshat', 4), ('Akash', 2), ('Nikhil', 8)], 2) == [('Akash', 2), ('Akshat', 4)]",
"assert min_k([('Sanjeev', 11), ('Angat', 5), ('Akash', 3), ('Nepin', 9)], 3) == [('Akash', 3), ('Angat', 5), ('Nepin', 9)]",
"assert min_k([('tanmay', 14), ('Amer', 11), ('Ayesha', 9), ('SKD', 16)... | [] | |
831 | Write a function to push all values into a heap and then pop off the smallest values one at a time. | 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 previous_palindrome(99)==88",
"assert previous_palindrome(1221)==1111",
"assert previous_palindrome(120)==111"
] | [] | |
860 | Write a function to add the given tuple to the given list. | def remove_kth_element(list1, L):
return list1[:L-1] + list1[L:] | [
"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"
] | [] | |
668 | Write a function to abbreviate 'road' as 'rd.' in a given string. | def test_three_equal(x,y,z):
result= set([x,y,z])
if len(result)==3:
return 0
else:
return (4-len(result)) | [
"assert check_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"
] | [] | |
889 | Write a function to calculate the sum of series 1²+2²+3²+….+n². | 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 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]"
] | [] | |
627 | 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 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 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)"
] | [] | |
817 | Write a function to combine two dictionaries by adding values for common keys. | 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 max_sum_of_three_consecutive([100, 1000, 100, 1000, 1], 5) == 2101",
"assert max_sum_of_three_consecutive([3000, 2000, 1000, 3, 10], 5) == 5013",
"assert max_sum_of_three_consecutive([1, 2, 3, 4, 5, 6, 7, 8], 8) == 27"
] | [] | |
818 | Write a function to convert an integer into a roman numeral. | 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 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"
] | [] | |
826 | Write a function to caluclate the area of a tetrahedron. | def check_subset(test_tup1, test_tup2):
res = set(test_tup2).issubset(test_tup1)
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]"
] | [] | |
716 | Write a function to display sign of the chinese zodiac for given year. | def len_log(list1):
min=len(list1[0])
for i in list1:
if len(i)<min:
min=len(i)
return min | [
"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] "
] | [] | |
755 | Write a function to check whether the given amount has no profit and no loss | def tuple_to_set(t):
s = set(t)
return (s) | [
"assert num_position(\"there are 70 flats in this apartment\")==10",
"assert num_position(\"every adult have 32 teeth\")==17",
"assert num_position(\"isha has 79 chocolates in her bag\")==9"
] | [] | |
973 | Write a python function to set the right most unset bit. | def remove_empty(tuple1): #L = [(), (), ('',), ('a', 'b'), ('a', 'b', 'c'), ('d')]
tuple1 = [t for t in tuple1 if t]
return tuple1 | [
"assert front_and_rear((10, 4, 5, 6, 7)) == (10, 7)",
"assert front_and_rear((1, 2, 3, 4, 5)) == (1, 5)",
"assert front_and_rear((6, 7, 8, 9, 10)) == (6, 10)"
] | [] | |
636 | Write a python function to check whether the given string is made up of two alternating characters or not. | 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 odd_Num_Sum(2) == 82",
"assert odd_Num_Sum(3) == 707",
"assert odd_Num_Sum(4) == 3108"
] | [] | |
801 | Write a function to calculate wind chill index. | def re_arrange_tuples(test_list, ord_list):
temp = dict(test_list)
res = [(key, temp[key]) for key in ord_list]
return (res) | [
"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] "
] | [] | |
929 | Write a function to check whether the given month number contains 30 days or not. | 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 last([1,2,3],1,3) == 0",
"assert last([1,1,1,2,3,4],1,6) == 2",
"assert last([2,3,2,3,6,8,9],3,8) == 3"
] | [] | |
679 | Write a function to remove all characters except letters and numbers using regex | 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 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'"
] | [] | |
968 | Write a python function to check whether the given two arrays are equal or not. | 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 recur_gcd(12,14) == 2",
"assert recur_gcd(13,17) == 1",
"assert recur_gcd(9, 3) == 3"
] | [] | |
690 | Write a function to find the occurrences of n most common words in a given text. | def check_monthnumber_number(monthnum3):
if(monthnum3==4 or monthnum3==6 or monthnum3==9 or monthnum3==11):
return True
else:
return False | [
"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 )] ) == '[(... | [] | |
698 | Write a function to locate the left insertion point for a specified value in sorted order. | def count_Char(str,x):
count = 0
for i in range(len(str)):
if (str[i] == x) :
count += 1
n = 10
repititions = n // len(str)
count = count * repititions
l = n % len(str)
for i in range(l):
if (str[i] == x):
count += 1
return... | [
"assert sum_Even(2,5) == 6",
"assert sum_Even(3,8) == 18",
"assert sum_Even(4,6) == 10"
] | [] | |
954 | Write a function to find the nth jacobsthal number. | def floor_Max(A,B,N):
x = min(B - 1,N)
return (A*x) // B | [
"assert min_Jumps(3,4,11)==3.5",
"assert min_Jumps(3,4,0)==0",
"assert min_Jumps(11,14,11)==1"
] | [] | |
754 | Write a python function to check whether every even index contains even numbers of a given list. | def cube_Sum(n):
sum = 0
for i in range(0,n) :
sum += (2*i+1)*(2*i+1)*(2*i+1)
return sum | [
"assert extract_max('100klh564abc365bg') == 564",
"assert extract_max('hello300how546mer231') == 546",
"assert extract_max('its233beenalong343journey234') == 343"
] | [] | |
770 | Write a function to find maximum of three numbers. | def area_trapezium(base1,base2,height):
area = 0.5 * (base1 + base2) * height
return area | [
"assert count_elim([10,20,30,(10,20),40])==3",
"assert count_elim([10,(20,30),(10,20),40])==1",
"assert count_elim([(10,(20,30,(10,20),40))])==0"
] | [] | |
629 | Write a function to multiply the adjacent elements of the given tuple. | def check(string):
if len(set(string).intersection("AEIOUaeiou"))>=5:
return ('accepted')
else:
return ("not accepted") | [
"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,... | [] | |
926 | Write a function to calculate the perimeter of a regular polygon. | def get_ludic(n):
ludics = []
for i in range(1, n + 1):
ludics.append(i)
index = 1
while(index != len(ludics)):
first_ludic = ludics[index]
remove_index = index + first_ludic
while(remove_index < len(ludics)):
ludics.remove(ludics[remove_index])
remove_index = remove_index + first_ludic - 1
... | [
"assert find_triplet_array([1, 4, 45, 6, 10, 8], 6, 22) == (4, 10, 8)",
"assert find_triplet_array([12, 3, 5, 2, 6, 9], 6, 24) == (12, 3, 9)",
"assert find_triplet_array([1, 2, 3, 4, 5], 5, 9) == (1, 3, 5)"
] | [] | |
643 | Write a function to find a pair with the highest product from a given array of integers. | 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 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"
] | [] | |
782 | Write a python function to find the smallest prime divisor of a number. | import re
regex = '''^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.(
25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.(
25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.(
25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$'''
def check_IP(Ip):
if(re.search(regex, Ip)):
return ("Valid IP address")
else:
return ("Invalid I... | [
"assert find_Points(5,10,1,5) == (1,10)",
"assert find_Points(3,5,7,9) == (3,9)",
"assert find_Points(1,5,2,8) == (1,8)"
] | [] | |
947 | Write a python function to choose points from two ranges such that no point lies in both the ranges. | def check_monthnumb(monthname2):
if(monthname2=="January" or monthname2=="March"or monthname2=="May" or monthname2=="July" or monthname2=="Augest" or monthname2=="October" or monthname2=="December"):
return True
else:
return False | [
"assert area_trapezium(6,9,4)==30",
"assert area_trapezium(10,20,30)==450",
"assert area_trapezium(15,25,35)==700"
] | [] | |
804 | Write a python function to find the index of smallest triangular number with n digits. | def access_elements(nums, list_index):
result = [nums[i] for i in list_index]
return result | [
"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... | [] | |
692 | Write a python function to find the sum of non-repeated elements in a given array. | def left_rotate(s,d):
tmp = s[d : ] + s[0 : d]
return tmp | [
"assert replace('peep','e') == 'pep'",
"assert replace('Greek','e') == 'Grek'",
"assert replace('Moon','o') == 'Mon'"
] | [] | |
907 | Write a function to count alphabets,digits and special charactes in a given string. | 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 is_Word_Present(\"machine learning\",\"machine\") == True",
"assert is_Word_Present(\"easy\",\"fun\") == False",
"assert is_Word_Present(\"python language\",\"code\") == False"
] | [] | |
625 | Write a python function to find minimum possible value for the given periodic function. | 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 super_seq(\"AGGTAB\", \"GXTXAYB\", 6, 7) == 9",
"assert super_seq(\"feek\", \"eke\", 4, 3) == 5",
"assert super_seq(\"PARRT\", \"RTA\", 5, 3) == 6"
] | [] | |
742 | Write a python function to merge the first and last elements separately in a list of lists. | 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 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... | [] | |
859 | Write a function to rearrange positive and negative numbers in a given array using lambda function. | def remove_list_range(list1, leftrange, rigthrange):
result = [i for i in list1 if (min(i)>=leftrange and max(i)<=rigthrange)]
return result | [
"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]"
] | [] | |
893 | Write a function to split a string at uppercase letters. | 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 cummulative_sum([(1, 3), (5, 6, 7), (2, 6)]) == 30",
"assert cummulative_sum([(2, 4), (6, 7, 8), (3, 7)]) == 37",
"assert cummulative_sum([(3, 5), (7, 8, 9), (4, 8)]) == 44"
] | [] | |
784 | Write a function to find the maximum sum of subsequences of given array with no adjacent elements. | def sum_list(lst1,lst2):
res_list = [lst1[i] + lst2[i] for i in range(len(lst1))]
return res_list | [
"assert listify_list(['Red', 'Blue', 'Black', 'White', 'Pink'])==[['R', 'e', 'd'], ['B', 'l', 'u', 'e'], ['B', 'l', 'a', 'c', 'k'], ['W', 'h', 'i', 't', 'e'], ['P', 'i', 'n', 'k']]",
"assert listify_list(['python'])==[['p', 'y', 't', 'h', 'o', 'n']]",
"assert listify_list([' red ', 'green',' black', 'blue ',' o... | [] | |
610 | Write a python function to count the total set bits from 1 to n. | from operator import eq
def count_same_pair(nums1, nums2):
result = sum(map(eq, nums1, nums2))
return result | [
"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]) == [... | [] | |
683 | Write a function to increment the numeric values in the given strings by k. | def check_valid(test_tup):
res = not any(map(lambda ele: not ele, test_tup))
return (res) | [
"assert is_decimal('123.11')==True",
"assert is_decimal('e666.86')==False",
"assert is_decimal('3.124587')==False"
] | [] | |
894 | Write a function to find average value of the numbers in a given tuple of tuples. | def roman_to_int(s):
rom_val = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
int_val = 0
for i in range(len(s)):
if i > 0 and rom_val[s[i]] > rom_val[s[i - 1]]:
int_val += rom_val[s[i]] - 2 * rom_val[s[i - 1]]
else:
... | [
"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)]) == ... | root = Node(1)
root.left = Node(2)
root.right = Node(3)
root.left.left = Node(4)
root.left.right = Node(5)
root1 = Node(1);
root1.left = Node(2);
root1.right = Node(3);
root1.left.left = Node(4);
root1.right.left = Node(5);
root1.right.right = Node(6);
root1.right.right.right= Node(7);
ro... | [] |
963 | Write a function to calculate the sum of all digits of the base to the specified power. | def unique_Element(arr,n):
s = set(arr)
if (len(s) == 1):
return ('YES')
else:
return ('NO') | [
"assert are_Equal([1,2,3],[3,2,1],3,3) == True",
"assert are_Equal([1,1,1],[2,2,2],3,3) == False",
"assert are_Equal([8,9],[4,5,6],2,3) == False"
] | [] | |
650 | Write a function to remove multiple spaces in a string by using regex. | import re
def check_substring(string, sample) :
if (sample in string):
y = "\A" + sample
x = re.search(y, string)
if x :
return ("string starts with the given substring")
else :
return ("string doesnt start with the given substring")
else :
retur... | [
"assert fibonacci(7) == 13",
"assert fibonacci(8) == 21",
"assert fibonacci(9) == 34"
] | [] | |
718 | Write a function to find length of the string. | def Repeat(x):
_size = len(x)
repeated = []
for i in range(_size):
k = i + 1
for j in range(k, _size):
if x[i] == x[j] and x[i] not in repeated:
repeated.append(x[i])
return repeated | [
"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]"
] | [] | |
628 | Write a function that matches a string that has an a followed by three 'b'. | from itertools import zip_longest, chain, tee
def exchange_elements(lst):
lst1, lst2 = tee(iter(lst), 2)
return list(chain.from_iterable(zip_longest(lst[1::2], lst[::2]))) | [
"assert 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"
] | [] | |
760 | Write a function to calculate the height of the given binary tree. | from heapq import merge
def combine_lists(num1,num2):
combine_lists=list(merge(num1, num2))
return combine_lists | [
"assert rencontres_number(7, 2) == 924",
"assert rencontres_number(3, 0) == 2",
"assert rencontres_number(3, 1) == 3"
] | [] | |
850 | Write a function to remove an empty tuple from a list of tuples. | def is_Word_Present(sentence,word):
s = sentence.split(" ")
for i in s:
if (i == word):
return True
return False | [
"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"
] | [] | |
728 | Write a python function to check whether a sequence of numbers has an increasing trend or not. | 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 is_odd(5) == True",
"assert is_odd(6) == False",
"assert is_odd(7) == True"
] | [] | |
748 | Write a function to find the fixed point in the given array. | from itertools import groupby
def consecutive_duplicates(nums):
return [key for key, group in groupby(nums)] | [
"assert maximum_segments(7, 5, 2, 5) == 2",
"assert maximum_segments(17, 2, 1, 3) == 17",
"assert maximum_segments(18, 16, 3, 6) == 6"
] | [] | |
879 | Write a function to find the maximum of nth column from the given tuple list. | def increment_numerics(test_list, K):
res = [str(int(ele) + K) if ele.isdigit() else ele for ele in test_list]
return res | [
"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']... | [] | |
774 | Write a python function to count the number of lists in a given number of lists. | def profit_amount(actual_cost,sale_amount):
if(actual_cost > sale_amount):
amount = actual_cost - sale_amount
return amount
else:
return None | [
"assert _sum([1, 2, 3]) == 6",
"assert _sum([15, 12, 13, 10]) == 50",
"assert _sum([0, 1, 2]) == 3"
] | [] | |
714 | Write a function to check if the given tuple contains all valid values or not. | def find_platform(arr, dep, n):
arr.sort()
dep.sort()
plat_needed = 1
result = 1
i = 1
j = 0
while (i < n and j < n):
if (arr[i] <= dep[j]):
plat_needed+= 1
i+= 1
elif (arr[i] > dep[j]):
plat_needed-= 1... | [
"assert sort_String(\"cba\") == \"abc\"",
"assert sort_String(\"data\") == \"aadt\"",
"assert sort_String(\"zxy\") == \"xyz\""
] | [] | |
765 | Write a function to convert the given string of float type into tuple. | def are_Equal(arr1,arr2,n,m):
if (n != m):
return False
arr1.sort()
arr2.sort()
for i in range(0,n - 1):
if (arr1[i] != arr2[i]):
return False
return True | [
"assert 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]"
] | [] | |
880 | Write a function to find the equilibrium index of the given array. | def check_smaller(test_tup1, test_tup2):
res = all(x > y for x, y in zip(test_tup1, test_tup2))
return (res) | [
"assert chinese_zodiac(1997)==('Ox')",
"assert chinese_zodiac(1998)==('Tiger')",
"assert chinese_zodiac(1994)==('Dog')"
] | [] | |
885 | Write a function to access the initial and last data of the given tuple record. | def validity_triangle(a,b,c):
total = a + b + c
if total == 180:
return True
else:
return False | [
"assert first_odd([1,3,5]) == 1",
"assert first_odd([2,4,1,3]) == 1",
"assert first_odd ([8,9,1]) == 9"
] | [] | |
847 | Write a python function to copy a list from a singleton 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 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... | [] | |
832 | Write a function to sort the tuples alphabetically by the first item of each tuple. | def check_monthnum_number(monthnum1):
if monthnum1 == 2:
return True
else:
return False | [
"assert roman_to_int('MMMCMLXXXVI')==3986",
"assert roman_to_int('MMMM')==4000",
"assert roman_to_int('C')==100"
] | [] | |
945 | Write a function to reverse words in a given string. | 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 Sum(60) == 10",
"assert Sum(39) == 16",
"assert Sum(40) == 7"
] | [] | |
822 | Write a python function to access multiple elements of specified index from a given list. | def Convert(string):
li = list(string.split(" "))
return li | [
"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]]"
] | [] | |
959 | Write a function to compute the value of ncr mod p. | def min_sum_path(A):
memo = [None] * len(A)
n = len(A) - 1
for i in range(len(A[n])):
memo[i] = A[n][i]
for i in range(len(A) - 2, -1,-1):
for j in range( len(A[i])):
memo[j] = A[i][j] + min(memo[j],
memo[j + 1])
return memo[0] | [
"assert 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"
] | [] | |
649 | Write a function to count the most common character in a given string. | def super_seq(X, Y, m, n):
if (not m):
return n
if (not n):
return m
if (X[m - 1] == Y[n - 1]):
return 1 + super_seq(X, Y, m - 1, n - 1)
return 1 + min(super_seq(X, Y, m - 1, n), super_seq(X, Y, m, n - 1)) | [
"assert dealnnoy_num(3, 4) == 129",
"assert dealnnoy_num(3, 3) == 63",
"assert dealnnoy_num(4, 5) == 681"
] | [] | |
738 | Write a function to calculate the geometric sum of n-1. | 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 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]"
] | [] | |
793 | Write a python function to remove even numbers from a given list. | def access_key(ditionary,key):
return list(ditionary)[key] | [
"assert swap_List([1,2,3]) == [3,2,1]",
"assert swap_List([1,2,3,4,4]) == [4,2,3,4,1]",
"assert swap_List([4,5,6]) == [6,5,4]"
] | [] | |
855 | Write a function to count the elements in a list until an element is a tuple. | def alternate_elements(list1):
result=[]
for item in list1[::2]:
result.append(item)
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"
] | [] | |
919 | Write a function to calculate the sum of the positive numbers of a given list of numbers using lambda function. | def rearrange_numbs(array_nums):
result = sorted(array_nums, key = lambda i: 0 if i == 0 else -1 / i)
return result | [
"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"
] | [] | |
836 | Write a python function to check whether the given strings are rotations of each other or not. | def harmonic_sum(n):
if n < 2:
return 1
else:
return 1 / n + (harmonic_sum(n - 1)) | [
"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')"
] | [] | |
798 | Write a python function to find the minimun number of subsets with distinct elements. | def div_of_nums(nums,m,n):
result = list(filter(lambda x: (x % m == 0 and x % n == 0), nums))
return result | [
"assert count_Rotation([3,2,1],3) == 1",
"assert count_Rotation([4,5,1,2,3],5) == 2",
"assert count_Rotation([7,8,9,1,2,3],6) == 3"
] | [] | |
906 | Write a function to find the nth super ugly number from a given prime list of size k using heap queue algorithm. | def count_vowels(test_str):
res = 0
vow_list = ['a', 'e', 'i', 'o', 'u']
for idx in range(1, len(test_str) - 1):
if test_str[idx] not in vow_list and (test_str[idx - 1] in vow_list or test_str[idx + 1] in vow_list):
res += 1
if test_str[0] not in vow_list and test_str[1] in vow_list:
res +=... | [
"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')"
] | [] | |
674 | Write a function to count unique keys for each value present in the tuple. | from collections import OrderedDict
def remove_duplicate(string):
result = ' '.join(OrderedDict((w,w) for w in string.split()).keys())
return result | [
"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']]"
] | [] | |
830 | Write a python function to left rotate the string. | def sort_numeric_strings(nums_str):
result = [int(x) for x in nums_str]
result.sort()
return result | [
"assert max_of_nth([(5, 6, 7), (1, 3, 5), (8, 9, 19)], 2) == 19",
"assert max_of_nth([(6, 7, 8), (2, 4, 6), (9, 10, 20)], 1) == 10",
"assert max_of_nth([(7, 8, 9), (3, 5, 7), (10, 11, 21)], 1) == 11"
] | [] | |
671 | Write a python function to count the number of pairs whose sum is equal to ‘sum’. | 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 remove_nested((1, 5, 7, (4, 6), 10)) == (1, 5, 7, 10)",
"assert remove_nested((2, 6, 8, (5, 7), 11)) == (2, 6, 8, 11)",
"assert remove_nested((3, 7, 9, (6, 8), 12)) == (3, 7, 9, 12)"
] | [] | |
922 | ## 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 | def count_range_in_list(li, min, max):
ctr = 0
for x in li:
if min <= x <= max:
ctr += 1
return ctr | [
"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"
] | [] | |
902 | Write a function to check whether the given ip address is valid or not using regex. | def Check_Solution(a,b,c):
if b == 0:
return ("Yes")
else:
return ("No") | [
"assert product_Equal(2841) == True",
"assert product_Equal(1234) == False",
"assert product_Equal(1212) == False"
] | [] | |
955 | Write a python function to check whether the word is present in a given sentence or not. | 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 count_vowels('bestinstareels') == 7",
"assert count_vowels('partofthejourneyistheend') == 12",
"assert count_vowels('amazonprime') == 5"
] | [] | |
890 | Write a function to find the maximum value in record list as tuple attribute in the given tuple list. | def last(arr,x,n):
low = 0
high = n - 1
res = -1
while (low <= high):
mid = (low + high) // 2
if arr[mid] > x:
high = mid - 1
elif arr[mid] < x:
low = mid + 1
else:
res = mid
low = mid + 1
return res | [
"assert rombus_perimeter(10)==40",
"assert rombus_perimeter(5)==20",
"assert rombus_perimeter(4)==16"
] | [] | |
787 | Write a function to filter the height and width of students which are stored in a dictionary. | def remove_nested(test_tup):
res = tuple()
for count, ele in enumerate(test_tup):
if not isinstance(ele, tuple):
res = res + (ele, )
return (res) | [
"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"
] | [] | |
900 | Write a python function to check whether the given number is a perfect square or not. | def word_len(s):
s = s.split(' ')
for word in s:
if len(word)%2==0:
return True
else:
return False | [
"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,... | [] | |
601 | Write a function to solve the fibonacci sequence using recursion. | 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 replace_spaces('Jumanji The Jungle') == 'Jumanji_The_Jungle'",
"assert replace_spaces('The Avengers') == 'The_Avengers'",
"assert replace_spaces('Fast and Furious') == 'Fast_and_Furious'"
] | [] | |
667 | Write a function to divide two lists using map and lambda function. | import heapq as hq
def raw_heap(rawheap):
hq.heapify(rawheap)
return rawheap | [
"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 ... | [] | |
670 | Write a function to find the item with maximum occurrences in a given list. | def sort_dict_item(test_dict):
res = {key: test_dict[key] for key in sorted(test_dict.keys(), key = lambda ele: ele[1] * ele[0])}
return (res)
| [
"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)]) == [... | [] | |
848 | Write a python function to remove spaces from a given string. | def geometric_sum(n):
if n < 0:
return 0
else:
return 1 / (pow(2, n)) + geometric_sum(n - 1) | [
"assert remove_all_spaces('python program')==('pythonprogram')",
"assert remove_all_spaces('python programming language')==('pythonprogramminglanguage')",
"assert remove_all_spaces('python program')==('pythonprogram')"
] | [] | |
806 | Write a function to sum a specific column of a list in a given list of lists. | def float_to_tuple(test_str):
res = tuple(map(float, test_str.split(', ')))
return (res) | [
"assert sum_of_odd_Factors(30) == 24",
"assert sum_of_odd_Factors(18) == 13",
"assert sum_of_odd_Factors(2) == 1"
] | [] | |
708 | Write a function to compute maximum product of three numbers of a given array of integers using heap queue algorithm. | def listify_list(list1):
result = list(map(list,list1))
return result | [
"assert last_Two_Digits(7) == 40",
"assert last_Two_Digits(5) == 20",
"assert last_Two_Digits(2) == 2"
] | [] | |
823 | Write a function to count those characters which have vowels as their neighbors in the given 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 tuple_to_set(('x', 'y', 'z') ) == {'y', 'x', 'z'}",
"assert tuple_to_set(('a', 'b', 'c') ) == {'c', 'a', 'b'}",
"assert tuple_to_set(('z', 'd', 'e') ) == {'d', 'e', 'z'}"
] | [] | |
659 | Write a function to remove duplicate words from a given list of strings. | 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 unique_Element([1,1,1],3) == 'YES'",
"assert unique_Element([1,2,1,2],4) == 'NO'",
"assert unique_Element([1,2,3,4,5],5) == 'NO'"
] | [] | |
740 | Write a function to find if there is a triplet in the array whose sum is equal to a given value. | def generate_matrix(n):
if n<=0:
return []
matrix=[row[:] for row in [[0]*n]*n]
row_st=0
row_ed=n-1
col_st=0
col_ed=n-1
current=1
while (True):
if current>n*n:
break
f... | [
"assert Average([15, 9, 55, 41, 35, 20, 62, 49]) == 35.75",
"assert Average([4, 5, 1, 2, 9, 7, 10, 8]) == 5.75",
"assert Average([1,2,3]) == 2"
] | [] | |
739 | Write a function to convert camel case string to snake case string. | def rotate_right(list1,m,n):
result = list1[-(m):]+list1[:-(n)]
return result | [
"assert len_complex(3,4)==5.0",
"assert len_complex(9,10)==13.45362404707371",
"assert len_complex(7,9)==11.40175425099138"
] | [] | |
776 | Write a function to find the nth nonagonal number. | import re
def text_match_three(text):
patterns = 'ab{3}?'
if re.search(patterns, text):
return 'Found a match!'
else:
return('Not matched!') | [
"assert harmonic_sum(10)==2.9289682539682538",
"assert harmonic_sum(4)==2.083333333333333",
"assert harmonic_sum(7)==2.5928571428571425 "
] | [] | |
682 | Write a function to find numbers within a given range where every number is divisible by every digit it contains. | def get_noOfways(n):
if (n == 0):
return 0;
if (n == 1):
return 1;
return get_noOfways(n - 1) + get_noOfways(n - 2); | [
"assert check_Concat(\"abcabcabc\",\"abc\") == True",
"assert check_Concat(\"abcab\",\"abc\") == False",
"assert check_Concat(\"aba\",\"ab\") == False"
] | [] | |
884 | Write a function to find area of a sector. | 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 capital_words_spaces(\"Python\") == 'Python'",
"assert capital_words_spaces(\"PythonProgrammingExamples\") == 'Python Programming Examples'",
"assert capital_words_spaces(\"GetReadyToBeCodingFreak\") == 'Get Ready To Be Coding Freak'"
] | [] | |
969 | Write a python function to find number of solutions in quadratic equation. | def fibonacci(n):
if n == 1 or n == 2:
return 1
else:
return (fibonacci(n - 1) + (fibonacci(n - 2))) | [
"assert split_list(\"LearnToBuildAnythingWithGoogle\") == ['Learn', 'To', 'Build', 'Anything', 'With', 'Google']",
"assert split_list(\"ApmlifyingTheBlack+DeveloperCommunity\") == ['Apmlifying', 'The', 'Black+', 'Developer', 'Community']",
"assert split_list(\"UpdateInTheGoEcoSystem\") == ['Update', 'In', 'The'... | [] | |
837 | Write a function to convert degrees to radians. | def sum_num(numbers):
total = 0
for x in numbers:
total += x
return total/len(numbers) | [
"assert remove_extra_char('**//Google Android// - 12. ') == 'GoogleAndroid12'",
"assert remove_extra_char('****//Google Flutter//*** - 36. ') == 'GoogleFlutter36'",
"assert remove_extra_char('**//Google Firebase// - 478. ') == 'GoogleFirebase478'"
] | [] | |
814 | Write a python function to get the last element of each sublist. | def is_key_present(d,x):
if x in d:
return True
else:
return False | [
"assert Check_Vow('corner','AaEeIiOoUu') == 2",
"assert Check_Vow('valid','AaEeIiOoUu') == 2",
"assert Check_Vow('true','AaEeIiOoUu') ==2"
] | [] | |
892 | Write a python function to shift first element to the end of given list. | 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 is_upper(\"person\") ==\"PERSON\"",
"assert is_upper(\"final\") == \"FINAL\"",
"assert is_upper(\"Valid\") == \"VALID\""
] | [] | |
685 | Write a function to extract the maximum numeric value from a string by using regex. | def Split(list):
ev_li = []
for i in list:
if (i % 2 == 0):
ev_li.append(i)
return ev_li | [
"assert find_Min_Sum([3,2,1],[2,1,3],3) == 0",
"assert find_Min_Sum([1,2,3],[4,5,6],3) == 9",
"assert find_Min_Sum([4,1,8,7],[2,3,6,5],4) == 6"
] | [] | |
946 | Write a function to perform chunking of tuples each of size n. | def count_Rotation(arr,n):
for i in range (1,n):
if (arr[i] < arr[i - 1]):
return i
return 0 | [
"assert check_monthnum_number(2)==True",
"assert check_monthnum_number(1)==False",
"assert check_monthnum_number(3)==False"
] | [] | |
710 | Write a function to return true if the password is valid. | 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 text_match(\"msb\") == 'Not matched!'",
"assert text_match(\"a0c\") == 'Found a match!'",
"assert text_match(\"abbc\") == 'Found a match!'"
] | [] | |
870 | Write a python function to check whether a sequence of numbers has a decreasing trend 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 fifth_Power_Sum(2) == 33",
"assert fifth_Power_Sum(4) == 1300",
"assert fifth_Power_Sum(3) == 276"
] | [] | |
673 | Write a function to find the list in a list of lists whose sum of elements is the highest. | from itertools import groupby
def group_element(test_list):
res = dict()
for key, val in groupby(sorted(test_list, key = lambda ele: ele[1]), key = lambda ele: ele[1]):
res[key] = [ele[0] for ele in val]
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]"
] | [] |
End of preview. Expand in Data Studio
edition_2489_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
- 7