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 |
|---|---|---|---|---|---|
949 | Write a python function to check whether the given strings are rotations of each other or not. | def max_similar_indices(test_list1, test_list2):
res = [(max(x[0], y[0]), max(x[1], y[1]))
for x, y in zip(test_list1, test_list2)]
return (res) | [
"assert min_Num([1,2,3,4,5,6,7,8,9],9) == 1",
"assert min_Num([1,2,3,4,5,6,7,8],8) == 2",
"assert min_Num([1,2,3],3) == 2"
] | [] | |
761 | Write a python function to find sum of prime numbers between 1 to n. | def int_to_roman( num):
val = [1000, 900, 500, 400,100, 90, 50, 40,10, 9, 5, 4,1]
syb = ["M", "CM", "D", "CD","C", "XC", "L", "XL","X", "IX", "V", "IV","I"]
roman_num = ''
i = 0
while num > 0:
for _ in range(num // val[i]):
roman_num += syb[i]
... | [
"assert remove_multiple_spaces('Google Assistant') == 'Google Assistant'",
"assert remove_multiple_spaces('Quad Core') == 'Quad Core'",
"assert remove_multiple_spaces('ChromeCast Built-in') == 'ChromeCast Built-in'"
] | [] | |
897 | Write a function to find maximum of two numbers. | def largest_subset(a, n):
dp = [0 for i in range(n)]
dp[n - 1] = 1;
for i in range(n - 2, -1, -1):
mxm = 0;
for j in range(i + 1, n):
if a[j] % a[i] == 0 or a[i] % a[j] == 0:
mxm = max(mxm, dp[j])
dp[i] = 1 + mxm
return max(dp) | [
"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"
] | [] | |
623 | Write a python function to find the sum of all even natural numbers within the range l and r. | def parallelogram_perimeter(b,h):
perimeter=2*(b*h)
return perimeter | [
"assert rombus_area(10,20)==100",
"assert rombus_area(10,5)==25",
"assert rombus_area(4,2)==4"
] | [] | |
881 | Write a function to find whether an array is subset of another array. | def extract_unique(test_dict):
res = list(sorted({ele for val in test_dict.values() for ele in val}))
return res | [
"assert check_Type_Of_Triangle(1,2,3) == \"Obtuse-angled Triangle\"",
"assert check_Type_Of_Triangle(2,2,2) == \"Acute-angled Triangle\"",
"assert check_Type_Of_Triangle(1,0,1) == \"Right-angled Triangle\""
] | [] | |
756 | Write a function to check whether the given ip address is valid or not using regex. | 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 rectangle_perimeter(10,20)==60",
"assert rectangle_perimeter(10,5)==30",
"assert rectangle_perimeter(4,2)==12"
] | [] | |
634 | Write a function to sort the tuples alphabetically by the first item of each tuple. | import math
import sys
def sd_calc(data):
n = len(data)
if n <= 1:
return 0.0
mean, sd = avg_calc(data), 0.0
for el in data:
sd += (float(el) - mean)**2
sd = math.sqrt(sd / float(n-1))
return sd
def avg_calc(ls):
n, mean = len(ls), 0.0
if n <= 1:
ret... | [
"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"
] | [] | |
725 | Write a function to combine two given sorted lists using heapq module. | def concatenate_nested(test_tup1, test_tup2):
res = test_tup1 + test_tup2
return (res) | [
"assert lcopy([1, 2, 3]) == [1, 2, 3]",
"assert lcopy([4, 8, 2, 10, 15, 18]) == [4, 8, 2, 10, 15, 18]",
"assert lcopy([4, 5, 6]) == [4, 5, 6]\n"
] | [] | |
963 | Write a python function to check whether a sequence of numbers has a decreasing trend or not. | 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 check_min_heap([1, 2, 3, 4, 5, 6], 0) == True",
"assert check_min_heap([2, 3, 4, 5, 10, 15], 0) == True",
"assert check_min_heap([2, 10, 4, 5, 3, 15], 0) == False"
] | [] | |
774 | Write a function to find the occurrence and position of the substrings within a string. | def first_odd(nums):
first_odd = next((el for el in nums if el%2!=0),-1)
return first_odd | [
"assert road_rd(\"ravipadu Road\")==('ravipadu Rd.')",
"assert road_rd(\"palnadu Road\")==('palnadu Rd.')",
"assert road_rd(\"eshwar enclave Road\")==('eshwar enclave Rd.')"
] | [] | |
617 | Write a function to sum a specific column of a list in a given list of lists. | import re
def text_match(text):
patterns = 'ab*?'
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"
] | [] | |
746 | Write a function to print the first n lucky numbers. | from itertools import groupby
def pack_consecutive_duplicates(list1):
return [list(group) for key, group in groupby(list1)] | [
"assert check_tuples((3, 5, 6, 5, 3, 6),[3, 6, 5]) == True",
"assert check_tuples((4, 5, 6, 4, 6, 5),[4, 5, 6]) == True",
"assert check_tuples((9, 8, 7, 6, 8, 9),[9, 8, 1]) == False"
] | [] | |
849 | Write a function to find the perimeter of a rectangle. | 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 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\") ] "
] | [] | |
901 | Write a function to caluclate perimeter of a parallelogram. | def left_rotate(s,d):
tmp = s[d : ] + s[0 : d]
return tmp | [
"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"
] | [] | |
865 | Write a function to check if one tuple is a subset of another tuple. | 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 combine_lists([1, 3, 5, 7, 9, 11],[0, 2, 4, 6, 8, 10])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]",
"assert combine_lists([1, 3, 5, 6, 8, 9], [2, 5, 7, 11])==[1,2,3,5,5,6,7,8,9,11]",
"assert combine_lists([1,3,7],[2,4,6])==[1,2,3,4,6,7]"
] | [] | |
633 | Write a function to find the longest chain which can be formed from the given set of pairs. | 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 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]"
] | [] | |
928 | Write a function to sort a given list of strings of numbers numerically. | 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 div_of_nums([19, 65, 57, 39, 152, 639, 121, 44, 90, 190],19,13)==[19, 65, 57, 39, 152, 190]",
"assert div_of_nums([1, 2, 3, 5, 7, 8, 10],2,5)==[2, 5, 8, 10]",
"assert div_of_nums([10,15,14,13,18,12,20],10,5)==[10, 15, 20]"
] | [] | |
732 | Write a function to check if the given tuple contains all valid values or not. | def floor_Min(A,B,N):
x = max(B - 1,N)
return (A*x) // B | [
"assert check_date(11,11,2002)==True",
"assert check_date(13,11,2002)==False",
"assert check_date('11','11','2002')==True"
] | [] | |
709 | Write a function to calculate the sum of all digits of the base to the specified power. | 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 are_Rotations(\"abc\",\"cba\") == False",
"assert are_Rotations(\"abcd\",\"cdba\") == False",
"assert are_Rotations(\"abacd\",\"cdaba\") == True"
] | [] | |
806 | Write a python function to get the difference between two lists. | 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 extract_quotation('Cortex \"A53\" Based \"multi\" tasking \"Processor\"') == ['A53', 'multi', 'Processor']",
"assert extract_quotation('Cast your \"favorite\" entertainment \"apps\"') == ['favorite', 'apps']",
"assert extract_quotation('Watch content \"4k Ultra HD\" resolution with \"HDR 10\" Support') ... | [] | |
608 | Write a function to locate the right insertion point for a specified value in sorted order. | 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 multiply_list([1,-2,3]) == -6",
"assert multiply_list([1,2,3,4]) == 24",
"assert multiply_list([3,1,2,3]) == 18"
] | [] | |
832 | Write a function to find out the second most repeated (or frequent) string in the given sequence. | def validity_triangle(a,b,c):
total = a + b + c
if total == 180:
return True
else:
return False | [
"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"
] | [] | |
968 | Write a function to merge two dictionaries into a single expression. | import itertools
def remove_duplicate(list1):
list.sort(list1)
remove_duplicate = list(list1 for list1,_ in itertools.groupby(list1))
return remove_duplicate | [
"assert toggle_middle_bits(9) == 15",
"assert toggle_middle_bits(10) == 12",
"assert toggle_middle_bits(11) == 13"
] | [] | |
816 | Write a function to find numbers divisible by m or n from a list of numbers using lambda function. | 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 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] "
] | [] | |
951 | Write a function to find the area of a rombus. | def maximum_product(nums):
import heapq
a, b = heapq.nlargest(3, nums), heapq.nsmallest(2, nums)
return max(a[0] * a[1] * a[2], a[0] * b[0] * b[1]) | [
"assert 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"
] | [] | |
722 | Write a python function to find the sum of an array. | import re
def extract_date(url):
return re.findall(r'/(\d{4})/(\d{1,2})/(\d{1,2})/', url) | [
"assert heap_sort([12, 2, 4, 5, 2, 3]) == [2, 2, 3, 4, 5, 12]",
"assert heap_sort([32, 14, 5, 6, 7, 19]) == [5, 6, 7, 14, 19, 32]",
"assert heap_sort([21, 15, 29, 78, 65]) == [15, 21, 29, 65, 78]"
] | [] | |
959 | Write a python function to convert a list of multiple integers into a single integer. | import re
def text_starta_endb(text):
patterns = 'a.*?b$'
if re.search(patterns, text):
return 'Found a match!'
else:
return('Not matched!') | [
"assert sum_of_odd_Factors(30) == 24",
"assert sum_of_odd_Factors(18) == 13",
"assert sum_of_odd_Factors(2) == 1"
] | [] | |
695 | Write a function to rotate a given list by specified number of items to the right direction. | def No_of_cubes(N,K):
No = 0
No = (N - K + 1)
No = pow(No, 3)
return No | [
"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)"
] | [] | |
666 | Write a function to abbreviate 'road' as 'rd.' in a given string. | import heapq as hq
def raw_heap(rawheap):
hq.heapify(rawheap)
return rawheap | [
"assert area_tetrahedron(3)==15.588457268119894",
"assert area_tetrahedron(20)==692.8203230275509",
"assert area_tetrahedron(10)==173.20508075688772"
] | [] | |
860 | Write a function to return true if the given number is even else return false. | def cummulative_sum(test_list):
res = sum(map(sum, test_list))
return (res) | [
"assert remove_spaces(\"a b c\") == \"abc\"",
"assert remove_spaces(\"1 2 3\") == \"123\"",
"assert remove_spaces(\" b c\") == \"bc\""
] | [] | |
605 | Write a python function to check if roots of a quadratic equation are reciprocal of each other or not. | 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 fibonacci(7) == 13",
"assert fibonacci(8) == 21",
"assert fibonacci(9) == 34"
] | [] | |
664 | Write a python function to check whether every odd index contains odd numbers of a given list. | def noprofit_noloss(actual_cost,sale_amount):
if(sale_amount == actual_cost):
return True
else:
return False | [
"assert removals([1, 3, 4, 9, 10,11, 12, 17, 20], 9, 4) == 5",
"assert removals([1, 5, 6, 2, 8], 5, 2) == 3",
"assert removals([1, 2, 3 ,4, 5, 6], 6, 3) == 2"
] | [] | |
886 | Write a python function to remove spaces from a given string. | 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 is_nonagonal(10) == 325",
"assert is_nonagonal(15) == 750",
"assert is_nonagonal(18) == 1089"
] | [] | |
915 | Write a function that gives profit amount if the given amount has profit else return none. | import math
def get_First_Set_Bit_Pos(n):
return math.log2(n&-n)+1 | [
"assert replace('peep','e') == 'pep'",
"assert replace('Greek','e') == 'Grek'",
"assert replace('Moon','o') == 'Mon'"
] | [] | |
737 | Write a function to calculate the sum of series 1²+2²+3²+….+n². | 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 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"
] | [] | |
795 | Write a python function to count lower case letters in a given string. | 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 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... | [] | |
767 | Write a python function to find the length of the shortest word. | def min_of_two( x, y ):
if x < y:
return x
return y | [
"assert arc_length(9,45)==3.5357142857142856",
"assert arc_length(9,480)==None",
"assert arc_length(5,270)==11.785714285714285"
] | [] | |
910 | Write a function to check if the given tuple contains only k elements. | def fibonacci(n):
if n == 1 or n == 2:
return 1
else:
return (fibonacci(n - 1) + (fibonacci(n - 2))) | [
"assert remove_parenthesis([\"python (chrome)\"])==(\"python\")",
"assert remove_parenthesis([\"string(.abc)\"])==(\"string\")",
"assert remove_parenthesis([\"alpha(num)\"])==(\"alpha\")"
] | [] | |
868 | Write a function to find the maximum value in record list as tuple attribute in the given tuple list. | def count_Rotation(arr,n):
for i in range (1,n):
if (arr[i] < arr[i - 1]):
return i
return 0 | [
"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"
] | [] | |
745 | Write a function where a string will start with a specific number. | 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 jacobsthal_num(5) == 11",
"assert jacobsthal_num(2) == 1",
"assert jacobsthal_num(4) == 5"
] | [] | |
769 | Write a function to calculate the sum of the positive numbers of a given list of numbers using lambda function. | 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 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"
] | [] | |
673 | Write a python function to find the kth element in an array containing odd elements first and then even elements. | M = 100
def maxAverageOfPath(cost, N):
dp = [[0 for i in range(N + 1)] for j in range(N + 1)]
dp[0][0] = cost[0][0]
for i in range(1, N):
dp[i][0] = dp[i - 1][0] + cost[i][0]
for j in range(1, N):
dp[0][j] = dp[0][j - 1] + cost[0][j]
for i in range(1, N):
for j in range(1, N):
dp[i][j] ... | [
"assert max_char(\"hello world\")==('l')",
"assert max_char(\"hello \")==('l')",
"assert max_char(\"python pr\")==('p')"
] | [] | |
778 | Write a function to find the frequency of each element in the given list. | from collections import Counter
def count_variable(a,b,c,d):
c = Counter(p=a, q=b, r=c, s=d)
return list(c.elements()) | [
"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')"
] | [] | |
654 | Write a function to remove all whitespaces from a string. | 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_polite(7) == 11",
"assert is_polite(4) == 7",
"assert is_polite(9) == 13"
] | [] | |
955 | Write a function that matches a string that has an 'a' followed by anything, ending in 'b'. | def set_middle_bits(n):
n |= n >> 1;
n |= n >> 2;
n |= n >> 4;
n |= n >> 8;
n |= n >> 16;
return (n >> 1) ^ 1
def toggle_middle_bits(n):
if (n == 1):
return 1
return n ^ set_middle_bits(n) | [
"assert maximum_product( [12, 74, 9, 50, 61, 41])==225700",
"assert maximum_product([25, 35, 22, 85, 14, 65, 75, 25, 58])==414375",
"assert maximum_product([18, 14, 10, 9, 8, 7, 9, 3, 2, 4, 1])==2520"
] | [] | |
668 | Write a python function to left rotate the string. | def div_of_nums(nums,m,n):
result = list(filter(lambda x: (x % m == 0 and x % n == 0), nums))
return result | [
"assert min_of_two(10,20)==10",
"assert min_of_two(19,15)==15",
"assert min_of_two(-10,-20)==-20"
] | [] | |
650 | Write a function to remove all characters except letters and numbers using regex | 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_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)]) == ... | [] | |
640 | Write a function to find a pair with the highest product from a given array of integers. | def Average(lst):
return sum(lst) / len(lst) | [
"assert maximum_value([('key1', [3, 4, 5]), ('key2', [1, 4, 2]), ('key3', [9, 3])]) == [('key1', 5), ('key2', 4), ('key3', 9)]",
"assert maximum_value([('key1', [4, 5, 6]), ('key2', [2, 5, 3]), ('key3', [10, 4])]) == [('key1', 6), ('key2', 5), ('key3', 10)]",
"assert maximum_value([('key1', [5, 6, 7]), ('key2',... | [] | |
636 | Write a function to remove duplicate words from a given list of strings. | def merge(lst):
return [list(ele) for ele in list(zip(*lst))] | [
"assert Odd_Length_Sum([1,2,4]) == 14",
"assert Odd_Length_Sum([1,2,1,2]) == 15",
"assert Odd_Length_Sum([1,7]) == 8"
] | [] | |
601 | Write a function to find number of even elements in the given list using lambda function. | def count_elim(num):
count_elim = 0
for n in num:
if isinstance(n, tuple):
break
count_elim += 1
return count_elim | [
"assert parallelogram_perimeter(10,20)==400",
"assert parallelogram_perimeter(15,20)==600",
"assert parallelogram_perimeter(8,9)==144"
] | [] | |
922 | Write a function to check if each element of second tuple is smaller than its corresponding index in first tuple. | 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 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"
] | [] | |
691 | Write a function to count number of unique lists within a list. | def move_last(num_list):
a = [num_list[0] for i in range(num_list.count(num_list[0]))]
x = [ i for i in num_list if i != num_list[0]]
x.extend(a)
return (x) | [
"assert 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"
] | [] | |
744 | Write a function to reverse words in a given string. | import re
def text_match_three(text):
patterns = 'ab{3}?'
if re.search(patterns, text):
return 'Found a match!'
else:
return('Not matched!') | [
"assert maxAverageOfPath([[1, 2, 3], [6, 5, 4], [7, 3, 9]], 3) == 5.2",
"assert maxAverageOfPath([[2, 3, 4], [7, 6, 5], [8, 4, 10]], 3) == 6.2",
"assert maxAverageOfPath([[3, 4, 5], [8, 7, 6], [9, 5, 11]], 3) == 7.2 "
] | [] | |
740 | Write a function to check if a nested list is a subset of another nested list. | def string_length(str1):
count = 0
for char in str1:
count += 1
return count | [
"assert Sum(60) == 10",
"assert Sum(39) == 16",
"assert Sum(40) == 7"
] | [] | |
822 | Write a function to find the product of it’s kth index in the given tuples. | def mutiple_tuple(nums):
temp = list(nums)
product = 1
for x in temp:
product *= x
return product | [
"assert generate_matrix(3)==[[1, 2, 3], [8, 9, 4], [7, 6, 5]] ",
"assert generate_matrix(2)==[[1,2],[4,3]]",
"assert generate_matrix(7)==[[1, 2, 3, 4, 5, 6, 7], [24, 25, 26, 27, 28, 29, 8], [23, 40, 41, 42, 43, 30, 9], [22, 39, 48, 49, 44, 31, 10], [21, 38, 47, 46, 45, 32, 11], [20, 37, 36, 35, 34, 33, 12], [19... | [] | |
938 | Write a function that matches a string that has an a followed by zero or one 'b'. | def is_key_present(d,x):
if x in d:
return True
else:
return False | [
"assert count_Char(\"abcac\",'a') == 4",
"assert count_Char(\"abca\",'c') == 2",
"assert count_Char(\"aba\",'a') == 7"
] | [] | |
970 | Write a function to sort a list in a dictionary. | def tuple_to_set(t):
s = set(t)
return (s) | [
"assert mutiple_tuple((4, 3, 2, 2, -1, 18)) == -864",
"assert mutiple_tuple((1,2,3)) == 6",
"assert mutiple_tuple((-2,-4,-6)) == -48"
] | [] | |
805 | Write a function to convert the given string of float type into tuple. | def Sum(N):
SumOfPrimeDivisors = [0]*(N + 1)
for i in range(2,N + 1) :
if (SumOfPrimeDivisors[i] == 0) :
for j in range(i,N + 1,i) :
SumOfPrimeDivisors[j] += i
return SumOfPrimeDivisors[N] | [
"assert check_Odd_Parity(13) == True",
"assert check_Odd_Parity(21) == True",
"assert check_Odd_Parity(18) == False"
] | [] | |
835 | Write a function to find the largest subset where each pair is divisible. | 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 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]"
] | [] | |
815 | Write a function to sort dictionary items by tuple product of keys for the given dictionary with tuple keys. | def sum_Range_list(nums, m, n):
sum_range = 0 ... | [
"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)"
] | [] | |
646 | Write a python function to reverse an array upto a given position. | def previous_palindrome(num):
for x in range(num-1,0,-1):
if str(x) == str(x)[::-1]:
return x | [
"assert lucky_num(10)==[1, 3, 7, 9, 13, 15, 21, 25, 31, 33] ",
"assert lucky_num(5)==[1, 3, 7, 9, 13]",
"assert lucky_num(8)==[1, 3, 7, 9, 13, 15, 21, 25]"
] | [] | |
620 | Write a function to calculate the sum of series 1³+2³+3³+….+n³. | def is_odd(n) :
if (n^1 == n-1) :
return True;
else :
return False; | [
"assert is_decimal('123.11')==True",
"assert is_decimal('e666.86')==False",
"assert is_decimal('3.124587')==False"
] | [] | |
854 | Write a function to find ln, m lobb number. | 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 decreasing_trend([-4,-3,-2,-1]) == True",
"assert decreasing_trend([1,2,3]) == True",
"assert decreasing_trend([3,2,1]) == False"
] | [] | |
642 | Write a function to find the occurrences of n most common words in a given text. | 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 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"
] | [] | |
807 | Write a python function to find the minimum sum of absolute differences of two arrays. | def remove_length(test_str, K):
temp = test_str.split()
res = [ele for ele in temp if len(ele) != K]
res = ' '.join(res)
return (res) | [
"assert count_list([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==25",
"assert count_list([[1, 3], [5, 7], [9, 11], [13, 15, 17]] )==16",
"assert count_list([[2, 4], [[6,8], [4,5,8]], [10, 12, 14]])==9"
] | [] | |
730 | 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 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 noprofit_noloss(1500,1200)==False",
"assert noprofit_noloss(100,100)==True",
"assert noprofit_noloss(2000,5000)==False"
] | [] | |
606 | Write a function to find average value of the numbers in a given tuple of tuples. | def min_difference(test_list):
temp = [abs(b - a) for a, b in test_list]
res = min(temp)
return (res) | [
"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"
] | [] | |
679 | Write a function that matches a string that has an a followed by zero or more b's by using regex. | def remove_duplic_list(l):
temp = []
for x in l:
if x not in temp:
temp.append(x)
return temp | [
"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"
] | [] | |
932 | Write a function to check if the triangle is valid or not. | import re
def road_rd(street):
return (re.sub('Road$', 'Rd.', street)) | [
"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... | [] | |
964 | Write a function to find the maximum of nth column from the given tuple list. | def coin_change(S, m, n):
table = [[0 for x in range(m)] for x in range(n+1)]
for i in range(m):
table[0][i] = 1
for i in range(1, n+1):
for j in range(m):
x = table[i - S[j]][j] if i-S[j] >= 0 else 0
y = table[i][j-1] if j >= 1 else 0
table[... | [
"assert radian_degree(90)==1.5707963267948966",
"assert radian_degree(60)==1.0471975511965976",
"assert radian_degree(120)==2.0943951023931953"
] | [] | |
833 | Write a function to iterate over all pairs of consecutive items in a given list. | def last(n):
return n[-1]
def sort_list_last(tuples):
return sorted(tuples, key=last) | [
"assert slope(4,2,2,5) == -1.5",
"assert slope(2,4,4,6) == 1",
"assert slope(1,2,4,2) == 0"
] | [] | |
930 | Write a function to calculate the perimeter of a regular polygon. | 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 Extract([[1, 2, 3], [4, 5], [6, 7, 8, 9]]) == [3, 5, 9]",
"assert Extract([['x', 'y', 'z'], ['m'], ['a', 'b'], ['u', 'v']]) == ['z', 'm', 'b', 'v']",
"assert Extract([[1, 2, 3], [4, 5]]) == [3, 5]"
] | [] | |
853 | Write a function to pack consecutive duplicates of a given list elements into sublists. | 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 first_odd([1,3,5]) == 1",
"assert first_odd([2,4,1,3]) == 1",
"assert first_odd ([8,9,1]) == 9"
] | [] | |
971 | Write a function to display sign of the chinese zodiac for given year. | def get_Pairs_Count(arr,n,sum):
count = 0
for i in range(0,n):
for j in range(i + 1,n):
if arr[i] + arr[j] == sum:
count += 1
return count | [
"assert check_subset((10, 4, 5, 6), (5, 10)) == True",
"assert check_subset((1, 2, 3, 4), (5, 6)) == False",
"assert check_subset((7, 8, 9, 10), (10, 8)) == True"
] | [] | |
689 | Write a python function to count number of vowels in the string. | 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 reverse_words(\"python program\")==(\"program python\")",
"assert reverse_words(\"java language\")==(\"language java\")",
"assert reverse_words(\"indian man\")==(\"man indian\")"
] | [] | |
624 | Write a python function to remove even numbers from a given list. | def Check_Solution(a,b,c):
if (a == c):
return ("Yes");
else:
return ("No"); | [
"assert sum_Range_list([2, 1, 5, 6, 8, 3, 4, 9, 10, 11, 8, 12],8,10) == 29",
"assert sum_Range_list([1,2,3,4,5],1,2) == 5",
"assert sum_Range_list([1,0,1,2,5,6],4,5) == 11"
] | [] | |
611 | Write a function to sort the given array without using any sorting algorithm. the given array consists of only 0, 1, and 2. | def mul_list(nums1,nums2):
result = map(lambda x, y: x * y, nums1, nums2)
return list(result) | [
"assert get_Pairs_Count([1,1,1,1],4,2) == 6",
"assert get_Pairs_Count([1,5,7,-1,5],5,6) == 3",
"assert get_Pairs_Count([1,-2,3],3,1) == 1"
] | [] | |
961 | Write a python function to check whether the roots of a quadratic equation are numerically equal but opposite in sign or not. | def is_subset(arr1, m, arr2, n):
hashset = set()
for i in range(0, m):
hashset.add(arr1[i])
for i in range(0, n):
if arr2[i] in hashset:
continue
else:
return False
return True | [
"assert is_Word_Present(\"machine learning\",\"machine\") == True",
"assert is_Word_Present(\"easy\",\"fun\") == False",
"assert is_Word_Present(\"python language\",\"code\") == False"
] | [] | |
846 | Write a python function to find the smallest prime divisor of a number. | def check_monthnum_number(monthnum1):
if monthnum1 == 2:
return True
else:
return False | [
"assert left_Rotate(16,2) == 64",
"assert left_Rotate(10,2) == 40",
"assert left_Rotate(99,3) == 792"
] | [] | |
799 | Write a python function to find the type of triangle from the given sides. | def float_to_tuple(test_str):
res = tuple(map(float, test_str.split(', ')))
return (res) | [
"assert extract_date(\"https://www.washingtonpost.com/news/football-insider/wp/2016/09/02/odell-beckhams-fame-rests-on-one-stupid-little-ball-josh-norman-tells-author/\") == [('2016', '09', '02')]",
"assert extract_date(\"https://www.indiatoday.in/movies/celebrities/story/wp/2020/11/03/odeof-sushant-singh-rajput-... | [] | |
840 | Write a function to sort a list of lists by length and value. | def check_valid(test_tup):
res = not any(map(lambda ele: not ele, test_tup))
return (res) | [
"assert float_to_tuple(\"1.2, 1.3, 2.3, 2.4, 6.5\") == (1.2, 1.3, 2.3, 2.4, 6.5)",
"assert float_to_tuple(\"2.3, 2.4, 5.6, 5.4, 8.9\") == (2.3, 2.4, 5.6, 5.4, 8.9)",
"assert float_to_tuple(\"0.3, 0.5, 7.8, 9.4\") == (0.3, 0.5, 7.8, 9.4)"
] | [] | |
953 | Write a function to split a string at uppercase letters. | def div_of_nums(nums,m,n):
result = list(filter(lambda x: (x % m == 0 or x % n == 0), 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'... | [] | |
777 | Write a python function to find nth bell number. | def check(string):
if len(set(string).intersection("AEIOUaeiou"))>=5:
return ('accepted')
else:
return ("not accepted") | [
"assert len_log([\"win\",\"lose\",\"great\"]) == 3",
"assert len_log([\"a\",\"ab\",\"abc\"]) == 1",
"assert len_log([\"12\",\"12\",\"1234\"]) == 2"
] | [] | |
607 | Write a python function to check whether every even index contains even numbers of a given list. | def lower_ctr(str):
lower_ctr= 0
for i in range(len(str)):
if str[i] >= 'a' and str[i] <= 'z': lower_ctr += 1
return lower_ctr | [
"assert ntimes_list([1, 2, 3, 4, 5, 6, 7],3)==[3, 6, 9, 12, 15, 18, 21]",
"assert ntimes_list([1, 2, 3, 4, 5, 6, 7],4)==[4, 8, 12, 16, 20, 24, 28]",
"assert ntimes_list([1, 2, 3, 4, 5, 6, 7],10)==[10, 20, 30, 40, 50, 60, 70]"
] | [] | |
906 | Write a function to solve tiling problem. | def sum_column(list1, C):
result = sum(row[C] for row in list1)
return result | [
"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]"
] | [] | |
716 | Write a function to solve the fibonacci sequence using recursion. | def count_Set_Bits(n) :
n += 1;
powerOf2 = 2;
cnt = n // 2;
while (powerOf2 <= n) :
totalPairs = n // powerOf2;
cnt += (totalPairs // 2) * powerOf2;
if (totalPairs & 1) :
cnt += (n % powerOf2)
else :
cnt += 0
powe... | [
"assert remove_duplicate(\"Python Exercises Practice Solution Exercises\")==(\"Python Exercises Practice Solution\")",
"assert remove_duplicate(\"Python Exercises Practice Solution Python\")==(\"Python Exercises Practice Solution\")",
"assert remove_duplicate(\"Python Exercises Practice Solution Practice\")==(\... | [] | |
779 | Write a function to find palindromes in a given list of strings using lambda function. | def add_tuple(test_list, test_tup):
test_list += test_tup
return (test_list) | [
"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']... | [] | |
724 | Write a python function to calculate the product of all the numbers of a given tuple. | def is_upper(string):
return (string.upper()) | [
"assert mul_even_odd([1,3,5,7,4,1,6,8])==4",
"assert mul_even_odd([1,2,3,4,5,6,7,8,9,10])==2",
"assert mul_even_odd([1,5,7,9,10])==10"
] | [] | |
766 | Write a function to find if there is a triplet in the array whose sum is equal to a given value. | def get_inv_count(arr, n):
inv_count = 0
for i in range(n):
for j in range(i + 1, n):
if (arr[i] > arr[j]):
inv_count += 1
return inv_count | [
"assert roman_to_int('MMMCMLXXXVI')==3986",
"assert roman_to_int('MMMM')==4000",
"assert roman_to_int('C')==100"
] | [] | |
839 | Write a function to find maximum run of uppercase characters in the given string. | def is_Two_Alter(s):
for i in range (len( s) - 2) :
if (s[i] != s[i + 2]) :
return False
if (s[0] == s[1]):
return False
return True | [
"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"
] | [] | |
677 | ## 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 lcopy(xs):
return xs[:]
| [
"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"
] | [] | |
847 | Write a function to extract values between quotation marks of the given string by using regex. | 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 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"
] | [] | |
685 | Write a python function to calculate the sum of the numbers in a list between the indices of a specified range. | 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 move_last([1,2,3,4]) == [2,3,4,1]",
"assert move_last([2,3,4,1,5,0]) == [3,4,1,5,0,2]",
"assert move_last([5,4,3,2,1]) == [4,3,2,1,5]"
] | [] | |
943 | Write a python function to find the sum of all odd natural numbers within the range l and r. | def is_Word_Present(sentence,word):
s = sentence.split(" ")
for i in s:
if (i == word):
return True
return False | [
"assert remove_similar_row([[(4, 5), (3, 2)], [(2, 2), (4, 6)], [(3, 2), (4, 5)]] ) == {((2, 2), (4, 6)), ((3, 2), (4, 5))}",
"assert remove_similar_row([[(5, 6), (4, 3)], [(3, 3), (5, 7)], [(4, 3), (5, 6)]] ) == {((4, 3), (5, 6)), ((3, 3), (5, 7))}",
"assert remove_similar_row([[(6, 7), (5, 4)], [(4, 4), (6, 8... | [] | |
933 | Write a function to find the nth nonagonal number. | import re
pattern = 'fox'
text = 'The quick brown fox jumps over the lazy dog.'
def find_literals(text, pattern):
match = re.search(pattern, text)
s = match.start()
e = match.end()
return (match.re.pattern, s, e) | [
"assert is_upper(\"person\") ==\"PERSON\"",
"assert is_upper(\"final\") == \"FINAL\"",
"assert is_upper(\"Valid\") == \"VALID\""
] | [] | |
941 | Write a python function to interchange first and last elements in a given list. | import re
def replace(string, char):
pattern = char + '{2,}'
string = re.sub(pattern, char, string)
return string | [
"assert nth_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],2)==[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]",
"assert nth_nums([10,20,30],3)==([1000, 8000, 27000])",
"assert nth_nums([12,15],5)==([248832, 759375])"
] | [] | |
967 | Write a python function to replace multiple occurence of character by single. | def count_range_in_list(li, min, max):
ctr = 0
for x in li:
if min <= x <= max:
ctr += 1
return ctr | [
"assert recur_gcd(12,14) == 2",
"assert recur_gcd(13,17) == 1",
"assert recur_gcd(9, 3) == 3"
] | [] | |
785 | Write a function to find the nth jacobsthal number. | 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 harmonic_sum(10)==2.9289682539682538",
"assert harmonic_sum(4)==2.083333333333333",
"assert harmonic_sum(7)==2.5928571428571425 "
] | [] | |
826 | Write a python function to convert the given string to upper case. | from collections import defaultdict
def grouping_dictionary(l):
d = defaultdict(list)
for k, v in l:
d[k].append(v)
return d | [
"assert check_email(\"ankitrai326@gmail.com\") == 'Valid Email'",
"assert check_email(\"my.ownsite@ourearth.org\") == 'Valid Email'",
"assert check_email(\"ankitaoie326.com\") == 'Invalid Email'"
] | [] | |
797 | Write a function to count unique keys for each value present in the tuple. | import re
def extract_quotation(text1):
return (re.findall(r'"(.*?)"', text1)) | [
"assert n_common_words(\"python is a programming language\",1)==[('python', 1)]",
"assert n_common_words(\"python is a programming language\",1)==[('python', 1)]",
"assert n_common_words(\"python is a programming language\",5)==[('python', 1),('is', 1), ('a', 1), ('programming', 1), ('language', 1)]"
] | [] |
End of preview. Expand in Data Studio
edition_0551_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