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 |
|---|---|---|---|---|---|
662 | Write a python function to count occurences of a character in a repeated string. | 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 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 ... | [] | |
763 | Write a function to pack consecutive duplicates of a given list elements into sublists. | def is_odd(n) :
if (n^1 == n-1) :
return True;
else :
return False; | [
"assert floor_Max(11,10,9) == 9",
"assert floor_Max(5,7,4) == 2",
"assert floor_Max(2,2,1) == 1"
] | [] | |
743 | Write a function to merge two dictionaries into a single expression. | def listify_list(list1):
result = list(map(list,list1))
return result | [
"assert remove_even([1,3,5,2]) == [1,3,5]",
"assert remove_even([5,6,7]) == [5,7]",
"assert remove_even([1,2,3,4]) == [1,3]"
] | [] | |
806 | Write a function to find a pair with the highest product from a given array of integers. | def check_monthnum_number(monthnum1):
if monthnum1 == 2:
return True
else:
return False | [
"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]"
] | [] | |
760 | Write a function to extract the maximum numeric value from a string by using regex. | 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 validity_triangle(60,50,90)==False",
"assert validity_triangle(45,75,60)==True",
"assert validity_triangle(30,50,100)==True"
] | [] | |
749 | Write a function to find the perimeter of a rectangle. | import re
def split_upperstring(text):
return (re.findall('[A-Z][^A-Z]*', text)) | [
"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"
] | [] | |
819 | Write a python function to find the sum of an array. | import re
def remove_all_spaces(text):
return (re.sub(r'\s+', '',text)) | [
"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"
] | [] | |
843 | 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. | import re
def extract_quotation(text1):
return (re.findall(r'"(.*?)"', text1)) | [
"assert end_num('abcdef')==False",
"assert end_num('abcdef7')==True",
"assert end_num('abc')==False"
] | [] | |
847 | Write a function to find length of the subarray having maximum sum. | def adjac(ele, sub = []):
if not ele:
yield sub
else:
yield from [idx for j in range(ele[0] - 1, ele[0] + 2)
for idx in adjac(ele[1:], sub + [j])]
def get_coordinates(test_tup):
res = list(adjac(test_tup))
return (res) | [
"assert remove_duplicate([[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]])==[[10, 20], [30, 56, 25], [33], [40]] ",
"assert remove_duplicate([\"a\", \"b\", \"a\", \"c\", \"c\"] )==[\"a\", \"b\", \"c\"]",
"assert remove_duplicate([1, 3, 5, 6, 3, 5, 6, 1] )==[1, 3, 5, 6]"
] | [] | |
730 | Write a function to divide two lists using map and lambda function. | 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 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"
] | [] | |
773 | Write a function to replace all occurrences of spaces, commas, or dots with a colon. | 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 replace_spaces('Jumanji The Jungle') == 'Jumanji_The_Jungle'",
"assert replace_spaces('The Avengers') == 'The_Avengers'",
"assert replace_spaces('Fast and Furious') == 'Fast_and_Furious'"
] | [] | |
882 | Write a function to find palindromes in a given list of strings using lambda function. | def move_zero(num_list):
a = [0 for i in range(num_list.count(0))]
x = [ i for i in num_list if i != 0]
x.extend(a)
return (x) | [
"assert extract_elements([1, 1, 3, 4, 4, 5, 6, 7],2)==[1, 4]",
"assert extract_elements([0, 1, 2, 3, 4, 4, 4, 4, 5, 7],4)==[4]",
"assert extract_elements([0,0,0,0,0],5)==[0]"
] | [] | |
972 | Write a python function to count the number of rotations required to generate a sorted array. | 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 divisible_by_digits(1,22)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]",
"assert divisible_by_digits(1,15)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15]",
"assert divisible_by_digits(20,25)==[22, 24]"
] | [] | |
681 | Write a python function to interchange first and last elements in a given list. | def count_list(input_list):
return (len(input_list))**2 | [
"assert mutiple_tuple((4, 3, 2, 2, -1, 18)) == -864",
"assert mutiple_tuple((1,2,3)) == 6",
"assert mutiple_tuple((-2,-4,-6)) == -48"
] | [] | |
791 | Write a function to count the number of elements in a list which are within a specific range. | 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 check_Odd_Parity(13) == True",
"assert check_Odd_Parity(21) == True",
"assert check_Odd_Parity(18) == False"
] | [] | |
814 | Write a python function to check whether the given number can be represented by sum of two squares or not. | 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 count_Set_Bits(16) == 33",
"assert count_Set_Bits(2) == 2",
"assert count_Set_Bits(14) == 28"
] | [] | |
766 | Write a python function to check whether the given number is odd or not using bitwise operator. | from collections import Counter
import re
def n_common_words(text,n):
words = re.findall('\w+',text)
n_common_words= Counter(words).most_common(n)
return list(n_common_words) | [
"assert is_triangleexists(50,60,70)==True",
"assert is_triangleexists(90,45,45)==True",
"assert is_triangleexists(150,30,70)==False"
] | [] | |
617 | Write a python function to remove negative numbers from a list. | 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 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... | [] | |
786 | Write a function to create a new tuple from the given string and list. | def pair_wise(l1):
temp = []
for i in range(len(l1) - 1):
current_element, next_element = l1[i], l1[i + 1]
x = (current_element, next_element)
temp.append(x)
return temp | [
"assert area_tetrahedron(3)==15.588457268119894",
"assert area_tetrahedron(20)==692.8203230275509",
"assert area_tetrahedron(10)==173.20508075688772"
] | [] | |
694 | Write a function to remove an empty tuple from a list of tuples. | def clear_tuple(test_tup):
temp = list(test_tup)
temp.clear()
test_tup = tuple(temp)
return (test_tup) | [
"assert replace_spaces(\"My Name is Dawood\") == 'My%20Name%20is%20Dawood'",
"assert replace_spaces(\"I am a Programmer\") == 'I%20am%20a%20Programmer'",
"assert replace_spaces(\"I love Coding\") == 'I%20love%20Coding'"
] | [] | |
809 | Write a function to check whether the given string is ending with only alphanumeric characters or not using regex. | def decreasing_trend(nums):
if (sorted(nums)== nums):
return True
else:
return False | [
"assert all_Characters_Same(\"python\") == False",
"assert all_Characters_Same(\"aaa\") == True",
"assert all_Characters_Same(\"data\") == False"
] | [] | |
635 | Write a function to find the median of two sorted arrays of same size. | 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 check_IP(\"192.168.0.1\") == 'Valid IP address'",
"assert check_IP(\"110.234.52.124\") == 'Valid IP address'",
"assert check_IP(\"366.1.2.2\") == 'Invalid IP address'"
] | [] | |
822 | Write a function to calculate the height of the given binary tree. | import re
def road_rd(street):
return (re.sub('Road$', 'Rd.', street)) | [
"assert max_chain_length([Pair(5, 24), Pair(15, 25),Pair(27, 40), Pair(50, 60)], 4) == 3",
"assert max_chain_length([Pair(1, 2), Pair(3, 4),Pair(5, 6), Pair(7, 8)], 4) == 4",
"assert max_chain_length([Pair(19, 10), Pair(11, 12),Pair(13, 14), Pair(15, 16), Pair(31, 54)], 5) == 5"
] | [] | |
739 | Write a function to find minimum k records from tuple list. | import heapq as hq
def raw_heap(rawheap):
hq.heapify(rawheap)
return rawheap | [
"assert lower_ctr('abc') == 3",
"assert lower_ctr('string') == 6",
"assert lower_ctr('Python') == 5"
] | [] | |
930 | Write a function to find the combinations of sums with tuples in the given tuple list. | def is_upper(string):
return (string.upper()) | [
"assert str_to_tuple(\"1, -5, 4, 6, 7\") == (1, -5, 4, 6, 7)",
"assert str_to_tuple(\"1, 2, 3, 4, 5\") == (1, 2, 3, 4, 5)",
"assert str_to_tuple(\"4, 6, 9, 11, 13, 14\") == (4, 6, 9, 11, 13, 14)"
] | [] | |
774 | Write a function to find the index of the first occurrence of a given number in a sorted array. | def triangle_area(r) :
if r < 0 :
return -1
return r * r | [
"assert left_Rotate(16,2) == 64",
"assert left_Rotate(10,2) == 40",
"assert left_Rotate(99,3) == 792"
] | [] | |
959 | Write a function to rotate a given list by specified number of items to the right direction. | def find_Min_Swaps(arr,n) :
noOfZeroes = [0] * n
count = 0
noOfZeroes[n - 1] = 1 - arr[n - 1]
for i in range(n-2,-1,-1) :
noOfZeroes[i] = noOfZeroes[i + 1]
if (arr[i] == 0) :
noOfZeroes[i] = noOfZeroes[i] + 1
for i in range(0,n) :
if (arr[i] == 1)... | [
"assert match_num('5-2345861')==True",
"assert match_num('6-2345861')==False",
"assert match_num('78910')==False"
] | [] | |
686 | Write a python function to check if roots of a quadratic equation are reciprocal of each other or not. | 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 get_coordinates((3, 4)) == [[2, 3], [2, 4], [2, 5], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5]]",
"assert get_coordinates((4, 5)) ==[[3, 4], [3, 5], [3, 6], [4, 4], [4, 5], [4, 6], [5, 4], [5, 5], [5, 6]]",
"assert get_coordinates((5, 6)) == [[4, 5], [4, 6], [4, 7], [5, 5], [5, 6], [5, 7], [6, 5], [... | [] | |
668 | Write a python function to check whether the given number is a perfect square or not. | 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 get_First_Set_Bit_Pos(12) == 3",
"assert get_First_Set_Bit_Pos(18) == 2",
"assert get_First_Set_Bit_Pos(16) == 5"
] | [] | |
652 | Write a python function to find sum of inverse of divisors. | def is_Word_Present(sentence,word):
s = sentence.split(" ")
for i in s:
if (i == word):
return True
return False | [
"assert check_expression(\"{()}[{}]\") == True",
"assert check_expression(\"{()}[{]\") == False",
"assert check_expression(\"{()}[{}][]({})\") == True"
] | [] | |
745 | Write a python function to find the sum of all odd natural numbers within the range l and r. | def sort_String(str) :
str = ''.join(sorted(str))
return (str) | [
"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"
] | [] | |
912 | Write a python function to find nth bell number. | import datetime
def check_date(m, d, y):
try:
m, d, y = map(int, (m, d, y))
datetime.date(y, m, d)
return True
except ValueError:
return False | [
"assert 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... | [] | |
793 | Write a function to remove multiple spaces in a string by using regex. | 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 equilibrium_index([1, 2, 3, 4, 1, 2, 3]) == 3",
"assert equilibrium_index([-7, 1, 5, 2, -4, 3, 0]) == 3",
"assert equilibrium_index([1, 2, 3]) == -1"
] | [] | |
968 | Write a python function to find minimum adjacent swaps required to sort binary array. | import re
regex = '[a-zA-z0-9]$'
def check_alphanumeric(string):
if(re.search(regex, string)):
return ("Accept")
else:
return ("Discard") | [
"assert find_max_val(15, 10, 5) == 15",
"assert find_max_val(187, 10, 5) == 185",
"assert find_max_val(16, 11, 1) == 12"
] | [] | |
758 | Write a function to add two integers. however, if the sum is between the given range it will return 20. | def count_Rotation(arr,n):
for i in range (1,n):
if (arr[i] < arr[i - 1]):
return i
return 0 | [
"assert len_log([\"win\",\"lose\",\"great\"]) == 3",
"assert len_log([\"a\",\"ab\",\"abc\"]) == 1",
"assert len_log([\"12\",\"12\",\"1234\"]) == 2"
] | 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... | [] |
942 | Write a python function to check whether every odd index contains odd numbers of a given list. | def get_odd_occurence(arr, arr_size):
for i in range(0, arr_size):
count = 0
for j in range(0, arr_size):
if arr[i] == arr[j]:
count += 1
if (count % 2 != 0):
return arr[i]
return -1 | [
"assert sort_tuple([(\"Amana\", 28), (\"Zenat\", 30), (\"Abhishek\", 29),(\"Nikhil\", 21), (\"B\", \"C\")]) == [('Abhishek', 29), ('Amana', 28), ('B', 'C'), ('Nikhil', 21), ('Zenat', 30)]",
"assert sort_tuple([(\"aaaa\", 28), (\"aa\", 30), (\"bab\", 29), (\"bb\", 21), (\"csa\", \"C\")]) == [('aa', 30), ('aaaa', 2... | [] | |
876 | Write a function to access the initial and last data of the given tuple record. | def sum_Odd(n):
terms = (n + 1)//2
sum1 = terms * terms
return sum1
def sum_in_Range(l,r):
return sum_Odd(r) - sum_Odd(l - 1) | [
"assert Convert('python program') == ['python','program']",
"assert Convert('Data Analysis') ==['Data','Analysis']",
"assert Convert('Hadoop Training') == ['Hadoop','Training']"
] | [] | |
871 | Write a function to get dictionary keys as a list. | 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 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]"
] | [] | |
697 | Write a function to remove all the words with k length in the given string. | def re_arrange_tuples(test_list, ord_list):
temp = dict(test_list)
res = [(key, temp[key]) for key in ord_list]
return (res) | [
"assert is_Word_Present(\"machine learning\",\"machine\") == True",
"assert is_Word_Present(\"easy\",\"fun\") == False",
"assert is_Word_Present(\"python language\",\"code\") == False"
] | [] | |
970 | Write a function to separate and print the numbers and their position of a given string. | 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 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"
] | [] | |
644 | Write a function to calculate the sum of the positive numbers of a given list of numbers using lambda function. | 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 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"
] | [] | |
926 | Write a function to count the most common character in a given string. | 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 find_Index(2) == 4",
"assert find_Index(3) == 14",
"assert find_Index(4) == 45"
] | [] | |
705 | ## 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 multiply_list(items):
tot = 1
for x in items:
tot *= x
return tot | [
"assert round_up(123.01247,0)==124",
"assert round_up(123.01247,1)==123.1",
"assert round_up(123.01247,2)==123.02"
] | [] | |
807 | Write a python function to shift first element to the end of given list. | def maximum_segments(n, a, b, c) :
dp = [-1] * (n + 10)
dp[0] = 0
for i in range(0, n) :
if (dp[i] != -1) :
if(i + a <= n ):
dp[i + a] = max(dp[i] + 1,
dp[i + a])
if(i + b <= n ):
dp[i + b] = max(dp[i] + 1,
dp[i + b])
if(i + c <= n ):
dp[i + c] = max(dp[i] ... | [
"assert add_tuple([5, 6, 7], (9, 10)) == [5, 6, 7, 9, 10]",
"assert add_tuple([6, 7, 8], (10, 11)) == [6, 7, 8, 10, 11]",
"assert add_tuple([7, 8, 9], (11, 12)) == [7, 8, 9, 11, 12]"
] | [] | |
895 | Write a function to find a path with the maximum average over all existing paths for the given square matrix of size n*n. | def count_char(string,char):
count = 0
for i in range(len(string)):
if(string[i] == char):
count = count + 1
return count | [
"assert sum_Of_Subarray_Prod([1,2,3],3) == 20",
"assert sum_Of_Subarray_Prod([1,2],2) == 5",
"assert sum_Of_Subarray_Prod([1,2,3,4],4) == 84"
] | [] | |
764 | Write a function to find the nth super ugly number from a given prime list of size k using heap queue algorithm. | def rearrange_numbs(array_nums):
result = sorted(array_nums, key = lambda i: 0 if i == 0 else -1 / i)
return result | [
"assert is_Perfect_Square(10) == False",
"assert is_Perfect_Square(36) == True",
"assert is_Perfect_Square(14) == False"
] | [] | |
831 | Write a function to check if each element of the second tuple is greater than its corresponding index in the first tuple. | 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 increasing_trend([1,2,3,4]) == True",
"assert increasing_trend([4,3,2,1]) == False",
"assert increasing_trend([0,1,4,9]) == True"
] | [] | |
775 | Write a python function to find sum of prime numbers between 1 to n. | 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 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)"
] | [] | |
620 | Write a python function to count equal element pairs from the given array. | 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 count_reverse_pairs([\"julia\", \"best\", \"tseb\", \"for\", \"ailuj\"])== '2'",
"assert count_reverse_pairs([\"geeks\", \"best\", \"for\", \"skeeg\"]) == '1'",
"assert count_reverse_pairs([\"makes\", \"best\", \"sekam\", \"for\", \"rof\"]) == '2' "
] | [] | |
883 | Write a python function to sort the given string. | def count_elim(num):
count_elim = 0
for n in num:
if isinstance(n, tuple):
break
count_elim += 1
return count_elim | [
"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"
] | [] | |
626 | Write a function to caluclate arc length of an angle. | def _sum(arr):
sum=0
for i in arr:
sum = sum + i
return(sum) | [
"assert No_of_cubes(2,1) == 8",
"assert No_of_cubes(5,2) == 64",
"assert No_of_cubes(1,1) == 1"
] | [] | |
891 | Write a function to check if the given integer is a prime number. | def div_list(nums1,nums2):
result = map(lambda x, y: x / y, nums1, nums2)
return list(result) | [
"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']... | [] | |
771 | Write a function to check if any list element is present in the given list. | MAX=1000;
def replace_spaces(string):
string=string.strip()
i=len(string)
space_count=string.count(' ')
new_length = i + space_count*2
if new_length > MAX:
return -1
index = new_length-1
string=list(string)
for f in range(i-2, new_length-2):
string.append('0')
for j in range(i-1, 0... | [
"assert get_unique([(3, 4), (1, 2), (2, 4), (8, 2), (7, 2), (8, 1), (9, 1), (8, 4), (10, 4)] ) == '{4: 4, 2: 3, 1: 2}'",
"assert get_unique([(4, 5), (2, 3), (3, 5), (9, 3), (8, 3), (9, 2), (10, 2), (9, 5), (11, 5)] ) == '{5: 4, 3: 3, 2: 2}'",
"assert get_unique([(6, 5), (3, 4), (2, 6), (11, 1), (8, 22), (8, 11)... | [] | |
866 | Write a function to replace whitespaces with an underscore and vice versa in a given string by using regex. | def first_repeated_char(str1):
for index,c in enumerate(str1):
if str1[:index+1].count(c) > 1:
return c
return "None" | [
"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"
] | [] | |
755 | Write a function to check whether the given amount has no profit and no loss | 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_vowels('bestinstareels') == 7",
"assert count_vowels('partofthejourneyistheend') == 12",
"assert count_vowels('amazonprime') == 5"
] | [] | |
724 | Write a function to replace all spaces in the given string with character * list item * list item * list item * list item '%20'. | def merge(lst):
return [list(ele) for ele in list(zip(*lst))] | [
"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}'"
] | [] | |
906 | Write a python function to check whether an array contains only one distinct element or not. | import re
def text_match(text):
patterns = 'ab*?'
if re.search(patterns, text):
return ('Found a match!')
else:
return ('Not matched!') | [
"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']]"
] | [] | |
910 | Write a function to remove the nested record from the given tuple. | 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 decreasing_trend([-4,-3,-2,-1]) == True",
"assert decreasing_trend([1,2,3]) == True",
"assert decreasing_trend([3,2,1]) == False"
] | [] | |
823 | Write a function to print the first n lucky numbers. | def swap_List(newList):
size = len(newList)
temp = newList[0]
newList[0] = newList[size - 1]
newList[size - 1] = temp
return newList | [
"assert min_Swaps(\"1101\",\"1110\") == 1",
"assert min_Swaps(\"1111\",\"0100\") == \"Not Possible\"",
"assert min_Swaps(\"1110000\",\"0001101\") == 3"
] | [] | |
901 | Write function to find the sum of all items in the given dictionary. | 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 min_Jumps(3,4,11)==3.5",
"assert min_Jumps(3,4,0)==0",
"assert min_Jumps(11,14,11)==1"
] | [] | |
605 | Write a function to check if one tuple is a subset of another tuple. | def remove_similar_row(test_list):
res = set(sorted([tuple(sorted(set(sub))) for sub in test_list]))
return (res) | [
"assert word_len(\"program\") == False",
"assert word_len(\"solution\") == True",
"assert word_len(\"data\") == True"
] | [] | |
798 | Write a function to validate a gregorian date. | INT_BITS = 32
def left_Rotate(n,d):
return (n << d)|(n >> (INT_BITS - d)) | [
"assert min_sum_path([[ 2 ], [3, 9 ], [1, 6, 7 ]]) == 6",
"assert min_sum_path([[ 2 ], [3, 7 ], [8, 5, 6 ]]) == 10 ",
"assert min_sum_path([[ 3 ], [6, 4 ], [5, 2, 7 ]]) == 9"
] | [] | |
687 | Write a function to generate all sublists of a given list. | def Check_Vow(string, vowels):
final = [each for each in string if each in vowels]
return(len(final))
| [
"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]"
] | [] | |
714 | Write a function to calculate the sum of series 1³+2³+3³+….+n³. | import re
def change_date_format(dt):
return re.sub(r'(\d{4})-(\d{1,2})-(\d{1,2})', '\\3-\\2-\\1', dt)
return change_date_format(dt) | [
"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"
] | [] | |
765 | Write a function to count alphabets,digits and special charactes in a given string. | 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 is_Isomorphic(\"paper\",\"title\") == True",
"assert is_Isomorphic(\"ab\",\"ba\") == True",
"assert is_Isomorphic(\"ab\",\"aa\") == False"
] | [] | |
885 | Write a function to list out the list of given strings individually using map function. | def convert(list):
s = [str(i) for i in list]
res = int("".join(s))
return (res) | [
"assert text_match_three(\"ac\")==('Not matched!')",
"assert text_match_three(\"dc\")==('Not matched!')",
"assert text_match_three(\"abbbba\")==('Found a match!')"
] | [] | |
872 | Write a function to search a literals string in a string and also find the location within the original string where the pattern occurs by using regex. | def floor_Max(A,B,N):
x = min(B - 1,N)
return (A*x) // B | [
"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"
] | [] | |
651 | Write a function to calculate the sum of all digits of the base to the specified power. | from collections import Counter
def add_dict(d1,d2):
add_dict = Counter(d1) + Counter(d2)
return add_dict | [
"assert sum_of_odd_Factors(30) == 24",
"assert sum_of_odd_Factors(18) == 13",
"assert sum_of_odd_Factors(2) == 1"
] | [] | |
892 | Write a function to find the nth jacobsthal 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 reverse_Array_Upto_K([1, 2, 3, 4, 5, 6],4) == [4, 3, 2, 1, 5, 6]",
"assert reverse_Array_Upto_K([4, 5, 6, 7], 2) == [5, 4, 6, 7]",
"assert reverse_Array_Upto_K([9, 8, 7, 6, 5],3) == [7, 8, 9, 6, 5]"
] | [] | |
808 | Write a function to check if the triangle is valid or not. | def recur_gcd(a, b):
low = min(a, b)
high = max(a, b)
if low == 0:
return high
elif low == 1:
return 1
else:
return recur_gcd(low, high%low) | [
"assert max_of_three(10,20,30)==30",
"assert max_of_three(55,47,39)==55",
"assert max_of_three(10,49,30)==49"
] | [] | |
682 | Write a function to find the greatest common divisor (gcd) of two integers by using recursion. | from collections import defaultdict
def grouping_dictionary(l):
d = defaultdict(list)
for k, v in l:
d[k].append(v)
return d | [
"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 "
] | [] | |
678 | Write a python function to check if the string is a concatenation of another string. | def slope(x1,y1,x2,y2):
return (float)(y2-y1)/(x2-x1) | [
"assert text_match(\"msb\") == 'Not matched!'",
"assert text_match(\"a0c\") == 'Found a match!'",
"assert text_match(\"abbc\") == 'Found a match!'"
] | [] | |
723 | Write a function to remove duplicate words from a given string using collections module. | 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 dealnnoy_num(3, 4) == 129",
"assert dealnnoy_num(3, 3) == 63",
"assert dealnnoy_num(4, 5) == 681"
] | [] | |
659 | Write a function to caluclate perimeter of a parallelogram. | def chunk_tuples(test_tup, N):
res = [test_tup[i : i + N] for i in range(0, len(test_tup), N)]
return (res) | [
"assert fifth_Power_Sum(2) == 33",
"assert fifth_Power_Sum(4) == 1300",
"assert fifth_Power_Sum(3) == 276"
] | [] | |
909 | Write a function to check whether the given month name contains 31 days or not. | def No_of_cubes(N,K):
No = 0
No = (N - K + 1)
No = pow(No, 3)
return No | [
"assert cube_Sum(2) == 28",
"assert cube_Sum(3) == 153",
"assert cube_Sum(4) == 496"
] | [] | |
633 | Write a function to count those characters which have vowels as their neighbors in the 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 rearrange_numbs([-1, 2, -3, 5, 7, 8, 9, -10])==[2, 5, 7, 8, 9, -10, -3, -1]",
"assert rearrange_numbs([10,15,14,13,-18,12,-20])==[10, 12, 13, 14, 15, -20, -18]",
"assert rearrange_numbs([-20,20,-10,10,-30,30])==[10, 20, 30, -30, -20, -10]"
] | [] | |
772 | Write a function to sort dictionary items by tuple product of keys for the given dictionary with tuple keys. | def tuple_modulo(test_tup1, test_tup2):
res = tuple(ele1 % ele2 for ele1, ele2 in zip(test_tup1, test_tup2))
return (res) | [
"assert area_trapezium(6,9,4)==30",
"assert area_trapezium(10,20,30)==450",
"assert area_trapezium(15,25,35)==700"
] | [] | |
824 | Write a function to combine two given sorted lists using heapq module. | def even_Power_Sum(n):
sum = 0;
for i in range(1,n + 1):
j = 2*i;
sum = sum + (j*j*j*j);
return sum; | [
"assert remove_spaces(\"a b c\") == \"abc\"",
"assert remove_spaces(\"1 2 3\") == \"123\"",
"assert remove_spaces(\" b c\") == \"bc\""
] | [] | |
740 | Write a function to extract all the adjacent coordinates of the given coordinate tuple. | 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 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)"
] | [] | |
829 | Write a function to check if the given string starts with a substring using regex. | def fifth_Power_Sum(n) :
sm = 0
for i in range(1,n+1) :
sm = sm + (i*i*i*i*i)
return sm | [
"assert radian_degree(90)==1.5707963267948966",
"assert radian_degree(60)==1.0471975511965976",
"assert radian_degree(120)==2.0943951023931953"
] | [] | |
868 | Write a python function to copy a list from a singleton tuple. | def increasing_trend(nums):
if (sorted(nums)== nums):
return True
else:
return False | [
"assert get_Number(8,5) == 2",
"assert get_Number(7,2) == 3",
"assert get_Number(5,2) == 3"
] | [] | |
665 | Write a python function to check whether every even index contains even numbers of a given list. | def min_Swaps(str1,str2) :
count = 0
for i in range(len(str1)) :
if str1[i] != str2[i] :
count += 1
if count % 2 == 0 :
return (count // 2)
else :
return ("Not Possible") | [
"assert wind_chill(120,35)==40",
"assert wind_chill(40,70)==86",
"assert wind_chill(10,100)==116"
] | [] | |
853 | Write a python function to find the minimum difference between any two elements in a given array. | 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 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"
] | [] | |
756 | Write a function to convert camel case string to snake case string. | 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 count_Fac(24) == 3",
"assert count_Fac(12) == 2",
"assert count_Fac(4) == 1"
] | [] | |
736 | Write a function to check if two lists of tuples are identical or not. | import re
def num_position(text):
for m in re.finditer("\d+", text):
return m.start() | [
"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)"
] | [] | |
950 | Write a function to find common index elements from three lists. | def float_to_tuple(test_str):
res = tuple(map(float, test_str.split(', ')))
return (res) | [
"assert remove_list_range([[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7], [9, 11], [13, 14, 15, 17]],13,17)==[[13, 14, 15, 17]]",
"assert remove_list_range([[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7], [9, 11], [13, 14, 15, 17]],1,3)==[[2], [1, 2, 3]]",
"assert remove_list_range([[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7], ... | [] | |
896 | Write a python function to reverse an array upto a given position. | def bell_Number(n):
bell = [[0 for i in range(n+1)] for j in range(n+1)]
bell[0][0] = 1
for i in range(1, n+1):
bell[i][0] = bell[i-1][i-1]
for j in range(1, i+1):
bell[i][j] = bell[i-1][j-1] + bell[i][j-1]
return bell[n][0] | [
"assert triangle_area(0) == 0",
"assert triangle_area(-1) == -1",
"assert triangle_area(2) == 4"
] | [] | |
816 | Write a function to convert the given string of integers into a tuple. | def sum_positivenum(nums):
sum_positivenum = list(filter(lambda nums:nums>0,nums))
return sum(sum_positivenum) | [
"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]) == [... | [] | |
903 | Write a function to remove the parenthesis area in a string. | 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 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... | [] | |
845 | Write a function to sort a list in increasing order by the last element in each tuple from a given list of non-empty tuples. | def access_key(ditionary,key):
return list(ditionary)[key] | [
"assert check_monthnum_number(2)==True",
"assert check_monthnum_number(1)==False",
"assert check_monthnum_number(3)==False"
] | [] | |
691 | Write a python function to find the index of an extra element present in one sorted array. | def max_run_uppercase(test_str):
cnt = 0
res = 0
for idx in range(0, len(test_str)):
if test_str[idx].isupper():
cnt += 1
else:
res = cnt
cnt = 0
if test_str[len(test_str) - 1].isupper():
res = cnt
return (res) | [
"assert bell_Number(2) == 2",
"assert bell_Number(3) == 5",
"assert bell_Number(4) == 15"
] | [] | |
936 | Write a function to caluclate the area of a tetrahedron. | from operator import eq
def count_same_pair(nums1, nums2):
result = sum(map(eq, nums1, nums2))
return result | [
"assert clear_tuple((1, 5, 3, 6, 8)) == ()",
"assert clear_tuple((2, 1, 4 ,5 ,6)) == ()",
"assert clear_tuple((3, 2, 5, 6, 8)) == ()"
] | [] | |
867 | Write a function to count occurrence of a character in a string. | def find_fixed_point(arr, n):
for i in range(n):
if arr[i] is i:
return i
return -1 | [
"assert check_element((4, 5, 7, 9, 3), [6, 7, 10, 11]) == True",
"assert check_element((1, 2, 3, 4), [4, 6, 7, 8, 9]) == True",
"assert check_element((3, 2, 1, 4, 5), [9, 8, 7, 6]) == False"
] | [] | |
937 | Write a function to check for the number of jumps required of given length to reach a point of form (d, 0) from origin in a 2d plane. | def average_tuple(nums):
result = [sum(x) / len(x) for x in zip(*nums)]
return result | [
"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'... | [] | |
886 | Write a python function to set the right most unset bit. | def add_list(nums1,nums2):
result = map(lambda x, y: x + y, nums1, nums2)
return list(result) | [
"assert chunk_tuples((10, 4, 5, 6, 7, 6, 8, 3, 4), 3) == [(10, 4, 5), (6, 7, 6), (8, 3, 4)]",
"assert chunk_tuples((1, 2, 3, 4, 5, 6, 7, 8, 9), 2) == [(1, 2), (3, 4), (5, 6), (7, 8), (9,)]",
"assert chunk_tuples((11, 14, 16, 17, 19, 21, 22, 25), 4) == [(11, 14, 16, 17), (19, 21, 22, 25)]"
] | [] | |
621 | Write a function to check whether the given key is present in the dictionary 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 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"
] | [] | |
961 | Write a function to find the minimum number of elements that should be removed such that amax-amin<=k. | 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 length_Of_Last_Word(\"python language\") == 8",
"assert length_Of_Last_Word(\"PHP\") == 3",
"assert length_Of_Last_Word(\"\") == 0"
] | [] | |
746 | Write a python function to find the length of the last word in a given string. | import math
def get_First_Set_Bit_Pos(n):
return math.log2(n&-n)+1 | [
"assert text_uppercase_lowercase(\"AaBbGg\")==('Found a match!')",
"assert text_uppercase_lowercase(\"aA\")==('Not matched!')",
"assert text_uppercase_lowercase(\"PYTHON\")==('Not matched!')"
] | [] | |
927 | Write a function to find the occurrences of n most common words in a given text. | import heapq
def cheap_items(items,n):
cheap_items = heapq.nsmallest(n, items, key=lambda s: s['price'])
return cheap_items | [
"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)"
] | [] | |
897 | Write a function to count repeated items of a tuple. | 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_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"
] | [] |
End of preview. Expand in Data Studio
edition_0972_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