task_id int64 601 974 | text large_stringlengths 38 249 | code large_stringlengths 30 908 | test_list listlengths 3 3 | test_setup_code large_stringclasses 2
values | challenge_test_list listlengths 0 0 |
|---|---|---|---|---|---|
819 | Write a function to add a dictionary to the tuple. | import re
def extract_date(url):
return re.findall(r'/(\d{4})/(\d{1,2})/(\d{1,2})/', url) | [
"assert min_Jumps(3,4,11)==3.5",
"assert min_Jumps(3,4,0)==0",
"assert min_Jumps(11,14,11)==1"
] | [] | |
703 | Write a function to find the area of a rombus. | def increment_numerics(test_list, K):
res = [str(int(ele) + K) if ele.isdigit() else ele for ele in test_list]
return res | [
"assert replace('peep','e') == 'pep'",
"assert replace('Greek','e') == 'Grek'",
"assert replace('Moon','o') == 'Mon'"
] | [] | |
767 | Write a function to find the sum of first even and odd number of a given list. | 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 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]"
] | [] | |
682 | Write a function to combine two given sorted lists using heapq module. | 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 max_sum_subseq([1, 2, 9, 4, 5, 0, 4, 11, 6]) == 26",
"assert max_sum_subseq([1, 2, 9, 5, 6, 0, 5, 12, 7]) == 28",
"assert max_sum_subseq([1, 3, 10, 5, 6, 0, 6, 14, 21]) == 44"
] | [] | |
853 | Write a function to create a new tuple from the given string and list. | 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 super_seq(\"AGGTAB\", \"GXTXAYB\", 6, 7) == 9",
"assert super_seq(\"feek\", \"eke\", 4, 3) == 5",
"assert super_seq(\"PARRT\", \"RTA\", 5, 3) == 6"
] | [] | |
645 | Write a function to find the length of the shortest string that has both str1 and str2 as subsequences. | def product_Equal(n):
if n < 10:
return False
prodOdd = 1; prodEven = 1
while n > 0:
digit = n % 10
prodOdd *= digit
n = n//10
if n == 0:
break;
digit = n % 10
prodEven *= digit
n = n//10
if prodOdd == prodEv... | [
"assert convert([1,2,3]) == 123",
"assert convert([4,5,6]) == 456",
"assert convert([7,8,9]) == 789"
] | [] | |
640 | Write a function to sort a list of lists by length and value. | def rgb_to_hsv(r, g, b):
r, g, b = r/255.0, g/255.0, b/255.0
mx = max(r, g, b)
mn = min(r, g, b)
df = mx-mn
if mx == mn:
h = 0
elif mx == r:
h = (60 * ((g-b)/df) + 360) % 360
elif mx == g:
h = (60 * ((b-r)/df) + 120) % 360
elif mx == b:
h = (60... | [
"assert odd_Num_Sum(2) == 82",
"assert odd_Num_Sum(3) == 707",
"assert odd_Num_Sum(4) == 3108"
] | [] | |
618 | Write a python function to find the sum of an array. | def rearrange_numbs(array_nums):
result = sorted(array_nums, key = lambda i: 0 if i == 0 else -1 / i)
return result | [
"assert jacobsthal_num(5) == 11",
"assert jacobsthal_num(2) == 1",
"assert jacobsthal_num(4) == 5"
] | [] | |
872 | Write a function to find numbers within a given range where every number is divisible by every digit it contains. | def binomial_coeff(n, k):
C = [[0 for j in range(k + 1)]
for i in range(n + 1)]
for i in range(0, n + 1):
for j in range(0, min(i, k) + 1):
if (j == 0 or j == i):
C[i][j] = 1
else:
C[i][j] = (C[i - 1][j - 1]
+ C[i - 1][j])
return C[n][k]
def lobb_num(n, m):
return ((... | [
"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"
] | [] | |
761 | Write a function to calculate the height of the given binary tree. | import math
def first_Digit(n) :
fact = 1
for i in range(2,n + 1) :
fact = fact * i
while (fact % 10 == 0) :
fact = int(fact / 10)
while (fact >= 10) :
fact = int(fact / 10)
return math.floor(fact) | [
"assert sum_even_odd([1,3,5,7,4,1,6,8])==5",
"assert sum_even_odd([1,2,3,4,5,6,7,8,9,10])==3",
"assert sum_even_odd([1,5,7,9,10])==11"
] | [] | |
940 | Write a function to sort a list in a dictionary. | 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 zip_list([[1, 3], [5, 7], [9, 11]] ,[[2, 4], [6, 8], [10, 12, 14]] )==[[1, 3, 2, 4], [5, 7, 6, 8], [9, 11, 10, 12, 14]]",
"assert zip_list([[1, 2], [3, 4], [5, 6]] ,[[7, 8], [9, 10], [11, 12]] )==[[1, 2, 7, 8], [3, 4, 9, 10], [5, 6, 11, 12]]",
"assert zip_list([['a','b'],['c','d']] , [['e','f'],['g','h'... | [] | |
646 | Write a function to check whether the given string is ending with only alphanumeric characters or not using regex. | import math
def find_Digits(n):
if (n < 0):
return 0;
if (n <= 1):
return 1;
x = ((n * math.log10(n / math.e) + math.log10(2 * math.pi * n) /2.0));
return math.floor(x) + 1; | [
"assert move_num('I1love143you55three3000thousand') == 'Iloveyouthreethousand1143553000'",
"assert move_num('Avengers124Assemble') == 'AvengersAssemble124'",
"assert move_num('Its11our12path13to14see15things16do17things') == 'Itsourpathtoseethingsdothings11121314151617'"
] | [] | |
851 | Write a function to zip two given lists of lists. | import re
def extract_quotation(text1):
return (re.findall(r'"(.*?)"', text1)) | [
"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"
] | [] | |
712 | Write a function to filter the height and width of students which are stored in a dictionary. | def average_tuple(nums):
result = [sum(x) / len(x) for x in zip(*nums)]
return result | [
"assert left_insertion([1,2,4,5],6)==4",
"assert left_insertion([1,2,4,5],3)==2",
"assert left_insertion([1,2,4,5],7)==4"
] | [] | |
716 | Write a function to group the 1st elements on the basis of 2nd elements in the given tuple list. | def count_reverse_pairs(test_list):
res = sum([1 for idx in range(0, len(test_list)) for idxn in range(idx, len(
test_list)) if test_list[idxn] == str(''.join(list(reversed(test_list[idx]))))])
return str(res) | [
"assert 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"
] | [] | |
769 | Write a python function to find the cube sum of first n odd natural numbers. | def find_Points(l1,r1,l2,r2):
x = min(l1,l2) if (l1 != l2) else -1
y = max(r1,r2) if (r1 != r2) else -1
return (x,y) | [
"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)"
] | [] | |
659 | Write a python function to count the number of equal numbers from three given integers. | 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 slope(4,2,2,5) == -1.5",
"assert slope(2,4,4,6) == 1",
"assert slope(1,2,4,2) == 0"
] | [] | |
797 | Write a python function to find minimum adjacent swaps required to sort binary array. | import re
regex = '^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w{2,3}$'
def check_email(email):
if(re.search(regex,email)):
return ("Valid Email")
else:
return ("Invalid Email") | [
"assert check_alphanumeric(\"dawood@\") == 'Discard'",
"assert check_alphanumeric(\"skdmsam326\") == 'Accept'",
"assert check_alphanumeric(\"cooltricks@\") == 'Discard'"
] | [] | |
705 | Write a python function to sort the given string. | def min_k(test_list, K):
res = sorted(test_list, key = lambda x: x[1])[:K]
return (res) | [
"assert largest_subset([ 1, 3, 6, 13, 17, 18 ], 6) == 4",
"assert largest_subset([10, 5, 3, 15, 20], 5) == 3",
"assert largest_subset([18, 1, 3, 6, 13, 17], 6) == 4"
] | [] | |
718 | Write a function to find the sequences of one upper case letter followed by lower case letters. | def all_Characters_Same(s) :
n = len(s)
for i in range(1,n) :
if s[i] != s[0] :
return False
return True | [
"assert camel_to_snake('GoogleAssistant') == 'google_assistant'",
"assert camel_to_snake('ChromeCast') == 'chrome_cast'",
"assert camel_to_snake('QuadCore') == 'quad_core'"
] | [] | |
803 | Write a python function to check whether an array can be sorted or not by picking only the corner elements. | def access_key(ditionary,key):
return list(ditionary)[key] | [
"assert remove_length('The person is most value tet', 3) == 'person is most value'",
"assert remove_length('If you told me about this ok', 4) == 'If you me about ok'",
"assert remove_length('Forces of darkeness is come into the play', 4) == 'Forces of darkeness is the'"
] | [] | |
742 | Write a python function to multiply all items in the list. | def count_range_in_list(li, min, max):
ctr = 0
for x in li:
if min <= x <= max:
ctr += 1
return ctr | [
"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"
] | [] | |
605 | Write a python function to find sum of odd factors of a number. | 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 increasing_trend([1,2,3,4]) == True",
"assert increasing_trend([4,3,2,1]) == False",
"assert increasing_trend([0,1,4,9]) == True"
] | [] | |
806 | Write a function to count repeated items of a tuple. | 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 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]"
] | [] | |
664 | Write a python function to find the first odd number in a given list of numbers. | from itertools import groupby
def extract_elements(numbers, n):
result = [i for i, j in groupby(numbers) if len(list(j)) == n]
return result | [
"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] "
] | [] | |
602 | Write a function to find the nth super ugly number from a given prime list of size k using heap queue algorithm. | 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 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)"
] | [] | |
710 | Write a function to re-arrange the given tuples based on the given ordered list. | def count_char(string,char):
count = 0
for i in range(len(string)):
if(string[i] == char):
count = count + 1
return count | [
"assert is_key_present({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60},5)==True",
"assert is_key_present({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60},6)==True",
"assert is_key_present({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60},10)==False"
] | [] | |
858 | Write a function to find the most common elements and their counts of a specified text. | def is_upper(string):
return (string.upper()) | [
"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'"
] | [] | |
822 | Write a python function to check if roots of a quadratic equation are reciprocal of each other or not. | 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 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"
] | [] | |
836 | Write a function to find n-th rencontres number. | 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 first_Digit(5) == 1",
"assert first_Digit(10) == 3",
"assert first_Digit(7) == 5"
] | [] | |
923 | Write a function to check if a triangle of positive area is possible with the given angles. | 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 matrix_to_list([[(4, 5), (7, 8)], [(10, 13), (18, 17)], [(0, 4), (10, 1)]]) == '[(4, 7, 10, 18, 0, 10), (5, 8, 13, 17, 4, 1)]'",
"assert matrix_to_list([[(5, 6), (8, 9)], [(11, 14), (19, 18)], [(1, 5), (11, 2)]]) == '[(5, 8, 11, 19, 1, 11), (6, 9, 14, 18, 5, 2)]'",
"assert matrix_to_list([[(6, 7), (9, 1... | [] | |
861 | Write a python function to merge the first and last elements separately in a list of lists. | import re
def remove_spaces(text):
return (re.sub(' +',' ',text)) | [
"assert smallest_multiple(13)==360360",
"assert smallest_multiple(2)==2",
"assert smallest_multiple(1)==1"
] | [] | |
830 | Write a python function to count numeric values in a given string. | def sorted_dict(dict1):
sorted_dict = {x: sorted(y) for x, y in dict1.items()}
return sorted_dict | [
"assert cube_Sum(2) == 28",
"assert cube_Sum(3) == 153",
"assert cube_Sum(4) == 496"
] | [] | |
801 | Write a function to locate the left insertion point for a specified value in sorted order. | def remove_duplic_list(l):
temp = []
for x in l:
if x not in temp:
temp.append(x)
return temp | [
"assert sort_list([(3, 4, 6, 723), (1, 2), (12345,), (134, 234, 34)] ) == '[(1, 2), (12345,), (3, 4, 6, 723), (134, 234, 34)]'",
"assert sort_list([(3, 4, 8), (1, 2), (1234335,), (1345, 234, 334)] ) == '[(1, 2), (3, 4, 8), (1234335,), (1345, 234, 334)]'",
"assert sort_list([(34, 4, 61, 723), (1, 2), (145,), (13... | [] | |
815 | Write a function to sum a specific column of a list in a given list of lists. | 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"
] | [] | |
914 | Write a python function to replace multiple occurence of character by single. | def chunk_tuples(test_tup, N):
res = [test_tup[i : i + N] for i in range(0, len(test_tup), N)]
return (res) | [
"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"
] | [] | |
668 | Write a function to count occurrence of a character in a string. | def second_smallest(numbers):
if (len(numbers)<2):
return
if ((len(numbers)==2) and (numbers[0] == numbers[1]) ):
return
dup_items = set()
uniq_items = []
for x in numbers:
if x not in dup_items:
uniq_items.append(x)
dup_items.add(x)
uniq_items.sort()
return uniq_... | [
"assert find_First_Missing([0,1,2,3],0,3) == 4",
"assert find_First_Missing([0,1,2,6,9],0,4) == 3",
"assert find_First_Missing([2,3,5,8,9],0,4) == 0"
] | [] | |
660 | Write function to find the sum of all items in the given dictionary. | 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 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... | [] | |
919 | Write a function that matches a string that has an a followed by three 'b'. | def remove_empty(tuple1): #L = [(), (), ('',), ('a', 'b'), ('a', 'b', 'c'), ('d')]
tuple1 = [t for t in tuple1 if t]
return tuple1 | [
"assert min_jumps([1, 3, 6, 1, 0, 9], 6) == 3",
"assert min_jumps([1, 3, 5, 8, 9, 2, 6, 7, 6, 8, 9], 11) == 3",
"assert min_jumps([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 11) == 10"
] | [] | |
970 | Write a function to convert rgb color to hsv color. | def is_abundant(n):
fctrsum = sum([fctr for fctr in range(1, n) if n % fctr == 0])
return fctrsum > n | [
"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... | [] | |
648 | Write a function to find the occurrence and position of the substrings within a string. | def max_of_nth(test_list, N):
res = max([sub[N] for sub in test_list])
return (res) | [
"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)"
] | [] | |
699 | Write a function to solve the fibonacci sequence using recursion. | def check_identical(test_list1, test_list2):
res = test_list1 == test_list2
return (res) | [
"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"
] | [] | |
652 | Write a python function to left rotate the string. | def previous_palindrome(num):
for x in range(num-1,0,-1):
if str(x) == str(x)[::-1]:
return x | [
"assert find_Index(2) == 4",
"assert find_Index(3) == 14",
"assert find_Index(4) == 45"
] | [] | |
739 | Write a function to check if each element of second tuple is smaller than its corresponding index in first tuple. | def div_list(nums1,nums2):
result = map(lambda x, y: x / y, nums1, nums2)
return list(result) | [
"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]"
] | [] | |
813 | Write a function to find the maximum sum that can be formed which has no three consecutive elements present. | import math
def wind_chill(v,t):
windchill = 13.12 + 0.6215*t - 11.37*math.pow(v, 0.16) + 0.3965*t*math.pow(v, 0.16)
return int(round(windchill, 0)) | [
"assert check_expression(\"{()}[{}]\") == True",
"assert check_expression(\"{()}[{]\") == False",
"assert check_expression(\"{()}[{}][]({})\") == True"
] | [] | |
740 | Write a function to calculate the perimeter of a regular polygon. | 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 geometric_sum(7) == 1.9921875",
"assert geometric_sum(4) == 1.9375",
"assert geometric_sum(8) == 1.99609375"
] | [] | |
751 | Write a function to convert an integer into a roman numeral. | 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 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'"
] | [] | |
921 | Write a function to convert the given string of integers into a tuple. | def min_jumps(arr, n):
jumps = [0 for i in range(n)]
if (n == 0) or (arr[0] == 0):
return float('inf')
jumps[0] = 0
for i in range(1, n):
jumps[i] = float('inf')
for j in range(i):
if (i <= j + arr[j]) and (jumps[j] != float('inf')):
jumps[i] = min(jumps[i], jumps[j] + 1)
break
return j... | [
"assert split_upperstring(\"PythonProgramLanguage\")==['Python','Program','Language']",
"assert split_upperstring(\"PythonProgram\")==['Python','Program']",
"assert split_upperstring(\"ProgrammingLanguage\")==['Programming','Language']"
] | [] | |
627 | Write a function to get a lucid number smaller than or equal to n. | def even_num(x):
if x%2==0:
return True
else:
return False | [
"assert find_max_val(15, 10, 5) == 15",
"assert find_max_val(187, 10, 5) == 185",
"assert find_max_val(16, 11, 1) == 12"
] | [] | |
790 | Write a python function to find sum of prime numbers between 1 to n. | def find_Sum(arr,n):
arr.sort()
sum = arr[0]
for i in range(0,n-1):
if (arr[i] != arr[i+1]):
sum = sum + arr[i+1]
return sum | [
"assert is_polite(7) == 11",
"assert is_polite(4) == 7",
"assert is_polite(9) == 13"
] | [] | |
841 | Write a function to check if a nested list is a subset of another nested list. | def remove_tuple(test_list):
res = [sub for sub in test_list if not all(ele == None for ele in sub)]
return (str(res)) | [
"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"
] | [] | |
863 | Write a function to extract values between quotation marks of the given string by using regex. | def is_Perfect_Square(n) :
i = 1
while (i * i<= n):
if ((n % i == 0) and (n / i == i)):
return True
i = i + 1
return False | [
"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"
] | [] | |
630 | Write a python function to remove spaces from a given string. | def maximum_value(test_list):
res = [(key, max(lst)) for key, lst in test_list]
return (res) | [
"assert Sum(60) == 10",
"assert Sum(39) == 16",
"assert Sum(40) == 7"
] | [] | |
838 | Write a python function to find the kth element in an array containing odd elements first and then even elements. | from itertools import combinations
def sub_lists(my_list):
subs = []
for i in range(0, len(my_list)+1):
temp = [list(x) for x in combinations(my_list, i)]
if len(temp)>0:
subs.extend(temp)
return subs | [
"assert 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'... | [] | |
880 | Write a python function to reverse an array upto a given position. | import math
def find_Index(n):
x = math.sqrt(2 * math.pow(10,(n - 1)));
return round(x); | [
"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]"
] | [] | |
936 | Write a function to sort a list of dictionaries using lambda function. | import re
def capital_words_spaces(str1):
return re.sub(r"(\w)([A-Z])", r"\1 \2", str1) | [
"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]"
] | [] | |
733 | Write a function to check if the given expression is balanced or not. | 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 sum_list([10,20,30],[15,25,35])==[25,45,65]",
"assert sum_list([1,2,3],[5,6,7])==[6,8,10]",
"assert sum_list([15,20,30],[15,45,75])==[30,65,105]"
] | [] | |
639 | Write a python function to remove negative numbers from a list. | import math
def radian_degree(degree):
radian = degree*(math.pi/180)
return radian | [
"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 ... | [] | |
690 | Write a python function to check whether the given two numbers have same number of digits or not. | def mutiple_tuple(nums):
temp = list(nums)
product = 1
for x in temp:
product *= x
return product | [
"assert even_num(13.5)==False",
"assert even_num(0)==True",
"assert even_num(-9)==False"
] | [] | |
818 | Write a function to find the longest chain which can be formed from the given set of pairs. | 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 sum_Square(25) == True",
"assert sum_Square(24) == False",
"assert sum_Square(17) == True"
] | [] | |
939 | Write a function to count the number of elements in a list which are within a specific range. | def increasing_trend(nums):
if (sorted(nums)== nums):
return True
else:
return False | [
"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"
] | [] | |
700 | Write a function to find the combinations of sums with tuples in the given tuple list. | import math
def get_First_Set_Bit_Pos(n):
return math.log2(n&-n)+1 | [
"assert even_Power_Sum(2) == 272",
"assert even_Power_Sum(3) == 1568",
"assert even_Power_Sum(4) == 5664"
] | [] | |
727 | Write a python function to remove even numbers from a given list. | from collections import Counter
def anagram_lambda(texts,str):
result = list(filter(lambda x: (Counter(str) == Counter(x)), texts))
return result | [
"assert floor_Min(10,20,30) == 15",
"assert floor_Min(1,2,1) == 0",
"assert floor_Min(11,10,9) == 9"
] | [] | |
634 | Write a function to rotate a given list by specified number of items to the right direction. | 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 is_upper(\"person\") ==\"PERSON\"",
"assert is_upper(\"final\") == \"FINAL\"",
"assert is_upper(\"Valid\") == \"VALID\""
] | [] | |
643 | Write a function to count the number of inversions in the given array. | 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 mutiple_tuple((4, 3, 2, 2, -1, 18)) == -864",
"assert mutiple_tuple((1,2,3)) == 6",
"assert mutiple_tuple((-2,-4,-6)) == -48"
] | [] | |
828 | Write a function to remove all the words with k length in the given string. | def rotate_right(list1,m,n):
result = list1[-(m):]+list1[:-(n)]
return result | [
"assert check_Concat(\"abcabcabc\",\"abc\") == True",
"assert check_Concat(\"abcab\",\"abc\") == False",
"assert check_Concat(\"aba\",\"ab\") == False"
] | [] | |
825 | Write a function to clear the values of the given tuples. | 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 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'"
] | [] | |
839 | Write a function to find the fixed point in the given array. | 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 text_match(\"ac\")==('Found a match!')",
"assert text_match(\"dc\")==('Not matched!')",
"assert text_match(\"abba\")==('Found a match!')"
] | [] | |
878 | Write a function to find the maximum sum of subsequences of given array with no adjacent elements. | def tuple_to_dict(test_tup):
res = dict(test_tup[idx : idx + 2] for idx in range(0, len(test_tup), 2))
return (res) | [
"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,... | [] | |
670 | Write a function to extract specified number of elements from a given list, which follow each other continuously. | 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_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"
] | [] | |
885 | Write a python function to find the minimum sum of absolute differences of two arrays. | 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 find_longest_conseq_subseq([1, 2, 2, 3], 4) == 3",
"assert find_longest_conseq_subseq([1, 9, 3, 10, 4, 20, 2], 7) == 4",
"assert find_longest_conseq_subseq([36, 41, 56, 35, 44, 33, 34, 92, 43, 32, 42], 11) == 5"
] | [] | |
896 | Write a function to find the median of two sorted arrays of same size. | def floor_Max(A,B,N):
x = min(B - 1,N)
return (A*x) // B | [
"assert Check_Vow('corner','AaEeIiOoUu') == 2",
"assert Check_Vow('valid','AaEeIiOoUu') == 2",
"assert Check_Vow('true','AaEeIiOoUu') ==2"
] | [] | |
776 | Write a function to find the equilibrium index of the given array. | 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 find_closet([1, 4, 10],[2, 15, 20],[10, 12],3,3,2) == (10, 15, 10)",
"assert find_closet([20, 24, 100],[2, 19, 22, 79, 800],[10, 12, 23, 24, 119],3,5,5) == (24, 22, 23)",
"assert find_closet([2, 5, 11],[3, 16, 21],[11, 13],3,3,2) == (11, 16, 11)"
] | [] | |
816 | Write a function to find the maximum value in record list as tuple attribute in the given tuple list. | 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 radian_degree(90)==1.5707963267948966",
"assert radian_degree(60)==1.0471975511965976",
"assert radian_degree(120)==2.0943951023931953"
] | [] | |
796 | Write a function to check whether the given string is starting with a vowel or not using regex. | 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 string_length('python')==6",
"assert string_length('program')==7",
"assert string_length('language')==8"
] | [] | |
891 | Write a function to find maximum of two numbers. | def max_sum_of_three_consecutive(arr, n):
sum = [0 for k in range(n)]
if n >= 1:
sum[0] = arr[0]
if n >= 2:
sum[1] = arr[0] + arr[1]
if n > 2:
sum[2] = max(sum[1], max(arr[1] + arr[2], arr[0] + arr[2]))
for i in range(3, n):
sum[i] = max(max(sum[i-1], sum[i-2] + arr[i]), arr[i] + arr[i-1]... | [
"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'"
] | [] | |
625 | Write a function to count number of unique lists within a list. | def Check_Solution(a,b,c):
if b == 0:
return ("Yes")
else:
return ("No") | [
"assert len_log([\"win\",\"lose\",\"great\"]) == 3",
"assert len_log([\"a\",\"ab\",\"abc\"]) == 1",
"assert len_log([\"12\",\"12\",\"1234\"]) == 2"
] | [] | |
691 | Write a function to find ln, m lobb number. | 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 area_trapezium(6,9,4)==30",
"assert area_trapezium(10,20,30)==450",
"assert area_trapezium(15,25,35)==700"
] | [] | |
856 | Write a function to remove multiple spaces in a string. | 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 sorted_dict({'n1': [2, 3, 1], 'n2': [5, 1, 2], 'n3': [3, 2, 4]})=={'n1': [1, 2, 3], 'n2': [1, 2, 5], 'n3': [2, 3, 4]}",
"assert sorted_dict({'n1': [25,37,41], 'n2': [41,54,63], 'n3': [29,38,93]})=={'n1': [25, 37, 41], 'n2': [41, 54, 63], 'n3': [29, 38, 93]}",
"assert sorted_dict({'n1': [58,44,56], 'n2':... | [] | |
968 | 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 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 remove_all_spaces('python program')==('pythonprogram')",
"assert remove_all_spaces('python programming language')==('pythonprogramminglanguage')",
"assert remove_all_spaces('python program')==('pythonprogram')"
] | [] | |
688 | Write a function to find out the second most repeated (or frequent) string in the given sequence. | def equilibrium_index(arr):
total_sum = sum(arr)
left_sum=0
for i, num in enumerate(arr):
total_sum -= num
if left_sum == total_sum:
return i
left_sum += num
return -1 | [
"assert pack_consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4])==[[0, 0], [1], [2], [3], [4, 4], [5], [6, 6, 6], [7], [8], [9], [4, 4]]",
"assert pack_consecutive_duplicates([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10])==[[10, 10], [15], [19], [18, 18], [17], [26, 26], [17], [18], [10]]"... | [] | |
759 | Write a function to find the maximum of nth column from the given tuple list. | def nth_nums(nums,n):
nth_nums = list(map(lambda x: x ** n, nums))
return nth_nums | [
"assert noprofit_noloss(1500,1200)==False",
"assert noprofit_noloss(100,100)==True",
"assert noprofit_noloss(2000,5000)==False"
] | [] | |
658 | Write a python function to get the position of rightmost set bit. | def check_tuples(test_tuple, K):
res = all(ele in K for ele in test_tuple)
return (res) | [
"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}'"
] | [] | |
904 | Write a function to find if there is a triplet in the array whose sum is equal to a given value. | def remove_similar_row(test_list):
res = set(sorted([tuple(sorted(set(sub))) for sub in test_list]))
return (res) | [
"assert average_Even(2) == 2",
"assert average_Even(4) == 3",
"assert average_Even(100) == 51"
] | [] | |
911 | Write a python function to count the number of digits in factorial of a given number. | def harmonic_sum(n):
if n < 2:
return 1
else:
return 1 / n + (harmonic_sum(n - 1)) | [
"assert rombus_perimeter(10)==40",
"assert rombus_perimeter(5)==20",
"assert rombus_perimeter(4)==16"
] | [] | |
756 | Write a function to find length of the string. | def find_Min_Sum(a,b,n):
a.sort()
b.sort()
sum = 0
for i in range(n):
sum = sum + abs(a[i] - b[i])
return sum | [
"assert check_K((10, 4, 5, 6, 8), 6) == True",
"assert check_K((1, 2, 3, 4, 5, 6), 7) == False",
"assert check_K((7, 8, 9, 44, 11, 12), 11) == True"
] | [] | |
726 | Write a function to find the index of the first occurrence of a given number in a sorted array. | 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 all_Characters_Same(\"python\") == False",
"assert all_Characters_Same(\"aaa\") == True",
"assert all_Characters_Same(\"data\") == False"
] | [] | |
617 | Write a function that matches a string that has an a followed by zero or more b's. | def remove_kth_element(list1, L):
return list1[:L-1] + list1[L:] | [
"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"
] | [] | |
743 | Write a function to merge two dictionaries into a single expression. | def multiply_list(items):
tot = 1
for x in items:
tot *= x
return tot | [
"assert pair_wise([1,1,2,3,3,4,4,5])==[(1, 1), (1, 2), (2, 3), (3, 3), (3, 4), (4, 4), (4, 5)]",
"assert pair_wise([1,5,7,9,10])==[(1, 5), (5, 7), (7, 9), (9, 10)]",
"assert pair_wise([1,2,3,4,5,6,7,8,9,10])==[(1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), (8, 9), (9, 10)]"
] | [] | |
895 | Write a python function to find number of solutions in quadratic equation. | 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 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"
] | [] | |
708 | Write a function to find nth polite number. | def check_none(test_tup):
res = any(map(lambda ele: ele is None, test_tup))
return (res) | [
"assert check_date(11,11,2002)==True",
"assert check_date(13,11,2002)==False",
"assert check_date('11','11','2002')==True"
] | [] | |
973 | Write a python function to check whether the given two arrays are equal or not. | def sector_area(r,a):
pi=22/7
if a >= 360:
return None
sectorarea = (pi*r**2) * (a/360)
return sectorarea | [
"assert sum_series(7)==784",
"assert sum_series(5)==225",
"assert sum_series(15)==14400"
] | [] | |
900 | Write a function to find the occurrences of n most common words in a given text. | def Average(lst):
return sum(lst) / len(lst) | [
"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... | [] | |
874 | Write a python function to calculate the sum of the numbers in a list between the indices of a specified range. | import re
def road_rd(street):
return (re.sub('Road$', 'Rd.', street)) | [
"assert count_Pairs([1,1,1,1],4) == 6",
"assert count_Pairs([1,5,1],3) == 1",
"assert count_Pairs([3,2,1,7,8,9],6) == 0"
] | [] | |
824 | Write a function to extract unique values from the given dictionary values. | 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 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"
] | [] | |
650 | Write a function to solve tiling problem. | def max_occurrences(list1):
max_val = 0
result = list1[0]
for i in list1:
occu = list1.count(i)
if occu > max_val:
max_val = occu
result = i
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]"
] | [] | |
732 | Write a function to convert camel case string to snake case string by using regex. | 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 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"
] | [] | |
941 | Write a function to find the area of a trapezium. | 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 wind_chill(120,35)==40",
"assert wind_chill(40,70)==86",
"assert wind_chill(10,100)==116"
] | [] | |
960 | Write a function to compute the value of ncr mod p. | def power_base_sum(base, power):
return sum([int(i) for i in str(pow(base, power))]) | [
"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]"
] | [] | |
723 | Write a function to convert the given tuple to a key-value dictionary using adjacent elements. | def decreasing_trend(nums):
if (sorted(nums)== nums):
return True
else:
return False | [
"assert find_Min_Swaps([1,0,1,0],4) == 3",
"assert find_Min_Swaps([0,1,0],3) == 1",
"assert find_Min_Swaps([0,0,1,1,0],5) == 2"
] | [] |
End of preview. Expand in Data Studio
edition_3109_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
- 10