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 |
|---|---|---|---|---|---|
962 | Write a function to count the most common character in a given string. | def slope(x1,y1,x2,y2):
return (float)(y2-y1)/(x2-x1) | [
"assert pass_validity(\"password\")==False",
"assert pass_validity(\"Password@10\")==True",
"assert pass_validity(\"password@10\")==False"
] | [] | |
926 | Write a python function to count equal element pairs from the given array. | 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 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)"
] | [] | |
855 | Write a function to count coin change. | 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 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]"
] | [] | |
902 | Write a function to find the nth super ugly number from a given prime list of size k using heap queue algorithm. | 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 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]"
] | [] | |
892 | Write a function to generate all sublists of a given list. | def mutiple_tuple(nums):
temp = list(nums)
product = 1
for x in temp:
product *= x
return product | [
"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]"
] | [] | |
676 | Write a function to convert the given tuples into set. | def check_identical(test_list1, test_list2):
res = test_list1 == test_list2
return (res) | [
"assert last([1,2,3],1,3) == 0",
"assert last([1,1,1,2,3,4],1,6) == 2",
"assert last([2,3,2,3,6,8,9],3,8) == 3"
] | [] | |
844 | Write a function to count those characters which have vowels as their neighbors in the given string. | def reverse_list_lists(lists):
for l in lists:
l.sort(reverse = True)
return lists | [
"assert group_element([(6, 5), (2, 7), (2, 5), (8, 7), (9, 8), (3, 7)]) == {5: [6, 2], 7: [2, 8, 3], 8: [9]}",
"assert group_element([(7, 6), (3, 8), (3, 6), (9, 8), (10, 9), (4, 8)]) == {6: [7, 3], 8: [3, 9, 4], 9: [10]}",
"assert group_element([(8, 7), (4, 9), (4, 7), (10, 9), (11, 10), (5, 9)]) == {7: [8, 4]... | [] | |
710 | Write a python function to find lcm of two positive integers. | 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 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]"
] | [] | |
697 | Write a function to find the most common elements and their counts of a specified text. | 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 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... | [] | |
809 | Write a function to reverse words in a given string. | 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 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"
] | [] | |
886 | Write a function to find the area of a trapezium. | def check_element(test_tup, check_list):
res = False
for ele in check_list:
if ele in test_tup:
res = True
break
return (res) | [
"assert slope(4,2,2,5) == -1.5",
"assert slope(2,4,4,6) == 1",
"assert slope(1,2,4,2) == 0"
] | [] | |
603 | Write a function to multiply the adjacent elements of the given tuple. | def check_Odd_Parity(x):
parity = 0
while (x != 0):
x = x & (x - 1)
parity += 1
if (parity % 2 == 1):
return True
else:
return False | [
"assert increasing_trend([1,2,3,4]) == True",
"assert increasing_trend([4,3,2,1]) == False",
"assert increasing_trend([0,1,4,9]) == True"
] | [] | |
690 | Write a function to multiply consecutive numbers of a given list. | 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 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"
] | [] | |
852 | Write a function to find length of the string. | 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 most_common_elem('lkseropewdssafsdfafkpwe',3)==[('s', 4), ('e', 3), ('f', 3)] ",
"assert most_common_elem('lkseropewdssafsdfafkpwe',2)==[('s', 4), ('e', 3)]",
"assert most_common_elem('lkseropewdssafsdfafkpwe',7)==[('s', 4), ('e', 3), ('f', 3), ('k', 2), ('p', 2), ('w', 2), ('d', 2)]"
] | [] | |
919 | Write a python function to find the sum of all odd length subarrays. | 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 text_uppercase_lowercase(\"AaBbGg\")==('Found a match!')",
"assert text_uppercase_lowercase(\"aA\")==('Not matched!')",
"assert text_uppercase_lowercase(\"PYTHON\")==('Not matched!')"
] | [] | |
945 | Write a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format. | def increasing_trend(nums):
if (sorted(nums)== nums):
return True
else:
return False | [
"assert count_char(\"Python\",'o')==1",
"assert count_char(\"little\",'t')==2",
"assert count_char(\"assert\",'s')==2"
] | [] | |
933 | 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 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 text_match_wordz_middle(\"pythonzabc.\")==('Found a match!')",
"assert text_match_wordz_middle(\"xyzabc.\")==('Found a match!')",
"assert text_match_wordz_middle(\" lang .\")==('Not matched!')"
] | [] | |
774 | Write a function to remove the nested record from the given tuple. | def sort_sublists(list1):
list1.sort()
list1.sort(key=len)
return list1 | [
"assert cheap_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}],1)==[{'name': 'Item-1', 'price': 101.1}]",
"assert cheap_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}],2)==[{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}]",
"ass... | [] | |
762 | Write a python function to find the slope of a line. | def count_even(array_nums):
count_even = len(list(filter(lambda x: (x%2 == 0) , array_nums)))
return count_even | [
"assert rencontres_number(7, 2) == 924",
"assert rencontres_number(3, 0) == 2",
"assert rencontres_number(3, 1) == 3"
] | [] | |
693 | Write a function to zip two given lists of lists. | 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 odd_position([2,1,4,3,6,7,6,3]) == True",
"assert odd_position([4,1,2]) == True",
"assert odd_position([1,2,3]) == False"
] | [] | |
679 | Write a function to find the lateral surface area of a cone. | import math
def radian_degree(degree):
radian = degree*(math.pi/180)
return radian | [
"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')"
] | [] | |
842 | Write a function to find the frequency of each element in the given list. | 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 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]) == [... | [] | |
727 | Write a function to sort the given tuple list basis the total digits in tuple. | def count_Rotation(arr,n):
for i in range (1,n):
if (arr[i] < arr[i - 1]):
return i
return 0 | [
"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'"
] | [] | |
773 | Write a function to join the tuples if they have similar initial elements. | def check_K(test_tup, K):
res = False
for ele in test_tup:
if ele == K:
res = True
break
return (res) | [
"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'"
] | [] | |
937 | Write a function to solve the fibonacci sequence using recursion. | import heapq
def cheap_items(items,n):
cheap_items = heapq.nsmallest(n, items, key=lambda s: s['price'])
return cheap_items | [
"assert check_monthnumber_number(6)==True",
"assert check_monthnumber_number(2)==False",
"assert check_monthnumber_number(12)==False"
] | [] | |
635 | Write a python function to copy a list from a singleton tuple. | 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 number_ctr('program2bedone') == 1",
"assert number_ctr('3wonders') ==1",
"assert number_ctr('123') == 3"
] | [] | |
718 | Write a python function to find the sum of squares of binomial co-efficients. | def check(string):
if len(set(string).intersection("AEIOUaeiou"))>=5:
return ('accepted')
else:
return ("not accepted") | [
"assert sum_column( [[1,2,3,2],[4,5,6,2],[7,8,9,5],],0)==12",
"assert sum_column( [[1,2,3,2],[4,5,6,2],[7,8,9,5],],1)==15",
"assert sum_column( [[1,2,3,2],[4,5,6,2],[7,8,9,5],],3)==9"
] | [] | |
896 | Write a function to filter the height and width of students which are stored in a dictionary. | from itertools import zip_longest, chain, tee
def exchange_elements(lst):
lst1, lst2 = tee(iter(lst), 2)
return list(chain.from_iterable(zip_longest(lst[1::2], lst[::2]))) | [
"assert sort_String(\"cba\") == \"abc\"",
"assert sort_String(\"data\") == \"aadt\"",
"assert sort_String(\"zxy\") == \"xyz\""
] | [] | |
883 | Write a function to count the elements in a list until an element is a tuple. | from operator import eq
def count_same_pair(nums1, nums2):
result = sum(map(eq, nums1, nums2))
return result | [
"assert check_email(\"ankitrai326@gmail.com\") == 'Valid Email'",
"assert check_email(\"my.ownsite@ourearth.org\") == 'Valid Email'",
"assert check_email(\"ankitaoie326.com\") == 'Invalid Email'"
] | [] | |
701 | Write a function to check if any list element is present in the given list. | def average_tuple(nums):
result = [sum(x) / len(x) for x in zip(*nums)]
return result | [
"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"
] | [] | |
940 | Write a function to group the 1st elements on the basis of 2nd elements in the given tuple list. | def mul_consecutive_nums(nums):
result = [b*a for a, b in zip(nums[:-1], nums[1:])]
return result | [
"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"
] | [] | |
766 | Write a python function to check for even parity of a given number. | def power_base_sum(base, power):
return sum([int(i) for i in str(pow(base, power))]) | [
"assert radian_degree(90)==1.5707963267948966",
"assert radian_degree(60)==1.0471975511965976",
"assert radian_degree(120)==2.0943951023931953"
] | [] | |
684 | Write a function to find out the second most repeated (or frequent) string in the given sequence. | def check(arr,n):
g = 0
for i in range(1,n):
if (arr[i] - arr[i - 1] > 0 and g == 1):
return False
if (arr[i] - arr[i] < 0):
g = 1
return True | [
"assert is_Word_Present(\"machine learning\",\"machine\") == True",
"assert is_Word_Present(\"easy\",\"fun\") == False",
"assert is_Word_Present(\"python language\",\"code\") == False"
] | [] | |
700 | Write a function to check whether the given key is present in the dictionary or not. | def _sum(arr):
sum=0
for i in arr:
sum = sum + i
return(sum) | [
"assert camel_to_snake('PythonProgram')==('python_program')",
"assert camel_to_snake('pythonLanguage')==('python_language')",
"assert camel_to_snake('ProgrammingLanguage')==('programming_language')"
] | [] | |
857 | Write a python function to find nth bell number. | def count_elim(num):
count_elim = 0
for n in num:
if isinstance(n, tuple):
break
count_elim += 1
return count_elim | [
"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)"
] | [] | |
827 | Write a function to list out the list of given strings individually using map function. | def min_Jumps(a, b, d):
temp = a
a = min(a, b)
b = max(temp, b)
if (d >= b):
return (d + b - 1) / b
if (d == 0):
return 0
if (d == a):
return 1
else:
return 2 | [
"assert min_k([('Manjeet', 10), ('Akshat', 4), ('Akash', 2), ('Nikhil', 8)], 2) == [('Akash', 2), ('Akshat', 4)]",
"assert min_k([('Sanjeev', 11), ('Angat', 5), ('Akash', 3), ('Nepin', 9)], 3) == [('Akash', 3), ('Angat', 5), ('Nepin', 9)]",
"assert min_k([('tanmay', 14), ('Amer', 11), ('Ayesha', 9), ('SKD', 16)... | [] | |
903 | Write a function to find the maximum sum of subsequences of given array with no adjacent elements. | 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 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"
] | [] | |
713 | Write a function to find the minimum total path sum in the given triangle. | class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def max_height(node):
if node is None:
return 0 ;
else :
left_height = max_height(node.left)
right_height = max_height(node.right)
if (left_height > right_height):
return left_height+1
... | [
"assert count_Rotation([3,2,1],3) == 1",
"assert count_Rotation([4,5,1,2,3],5) == 2",
"assert count_Rotation([7,8,9,1,2,3],6) == 3"
] | [] | |
651 | Write a function to sum elements in two lists. | import math
def sum_series(number):
total = 0
total = math.pow((number * (number + 1)) /2, 2)
return total | [
"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)"
] | [] | |
916 | Write a python function to choose points from two ranges such that no point lies in both the ranges. | def tuple_modulo(test_tup1, test_tup2):
res = tuple(ele1 % ele2 for ele1, ele2 in zip(test_tup1, test_tup2))
return (res) | [
"assert tuple_str_int(\"(7, 8, 9)\") == (7, 8, 9)",
"assert tuple_str_int(\"(1, 2, 3)\") == (1, 2, 3)",
"assert tuple_str_int(\"(4, 5, 6)\") == (4, 5, 6)"
] | [] | |
670 | Write a function to split a string at uppercase letters. | 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 remove_char(\"123abcjw:, .@! eiw\") == '123abcjweiw'",
"assert remove_char(\"Hello1234:, ! Howare33u\") == 'Hello1234Howare33u'",
"assert remove_char(\"Cool543Triks@:, Make@987Trips\") == 'Cool543TriksMake987Trips' "
] | [] | |
604 | Write a function to remove sublists from a given list of lists, which are outside a given range. | 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 find_Index(2) == 4",
"assert find_Index(3) == 14",
"assert find_Index(4) == 45"
] | [] | |
891 | Write a function to find n-th rencontres number. | def find_first_occurrence(A, x):
(left, right) = (0, len(A) - 1)
result = -1
while left <= right:
mid = (left + right) // 2
if x == A[mid]:
result = mid
right = mid - 1
elif x < A[mid]:
right = mid - 1
else:
left = mi... | [
"assert 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"
] | [] | |
748 | Write a function to remove an empty tuple from a list of tuples. | 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 is_upper(\"person\") ==\"PERSON\"",
"assert is_upper(\"final\") == \"FINAL\"",
"assert is_upper(\"Valid\") == \"VALID\""
] | [] | |
865 | Write a function to create a list taking alternate elements from another given list. | 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 Check_Solution(2,0,2) == \"Yes\"",
"assert Check_Solution(2,-5,2) == \"Yes\"",
"assert Check_Solution(1,2,3) == \"No\""
] | [] | |
826 | Write a function to find ln, m lobb number. | 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 noprofit_noloss(1500,1200)==False",
"assert noprofit_noloss(100,100)==True",
"assert noprofit_noloss(2000,5000)==False"
] | [] | |
965 | Write a function to remove duplicates from a list of lists. | 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 count_list([[1, 3], [5, 7], [9, 11], [13, 15, 17]]) == 4",
"assert count_list([[1,2],[2,3],[4,5]]) == 3",
"assert count_list([[1,0],[2,0]]) == 2"
] | [] | |
835 | Write a function to find the cumulative sum of all the values that are present in the given tuple list. | def concatenate_nested(test_tup1, test_tup2):
res = test_tup1 + test_tup2
return (res) | [
"assert remove_duplic_list([\"Python\", \"Exercises\", \"Practice\", \"Solution\", \"Exercises\"])==['Python', 'Exercises', 'Practice', 'Solution']",
"assert remove_duplic_list([\"Python\", \"Exercises\", \"Practice\", \"Solution\", \"Exercises\",\"Java\"])==['Python', 'Exercises', 'Practice', 'Solution', 'Java']... | [] | |
949 | Write a python function to check for odd parity of a given number. | def palindrome_lambda(texts):
result = list(filter(lambda x: (x == "".join(reversed(x))), texts))
return result | [
"assert check_str(\"annie\") == 'Valid'",
"assert check_str(\"dawood\") == 'Invalid'",
"assert check_str(\"Else\") == 'Valid'"
] | [] | |
847 | Write a function to increment the numeric values in the given strings by k. | 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 sum_Square(25) == True",
"assert sum_Square(24) == False",
"assert sum_Square(17) == True"
] | [] | |
859 | Write a function to push all values into a heap and then pop off the smallest values one at a time. | from collections import Counter
def most_common_elem(s,a):
most_common_elem=Counter(s).most_common(a)
return most_common_elem | [
"assert check_Odd_Parity(13) == True",
"assert check_Odd_Parity(21) == True",
"assert check_Odd_Parity(18) == False"
] | [] | |
739 | Write a function to check if each element of the second tuple is greater than its corresponding index in the first tuple. | def access_key(ditionary,key):
return list(ditionary)[key] | [
"assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],3,4)==[8, 9, 10, 1, 2, 3, 4, 5, 6]",
"assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],2,2)==[9, 10, 1, 2, 3, 4, 5, 6, 7, 8]",
"assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],5,2)==[6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8]"
] | [] | |
960 | Write a python function to find the minimum number of swaps required to convert one binary string to another. | def lucky_num(n):
List=range(-1,n*n+9,2)
i=2
while List[i:]:List=sorted(set(List)-set(List[List[i]::List[i]]));i+=1
return List[1:n+1] | [
"assert Convert('python program') == ['python','program']",
"assert Convert('Data Analysis') ==['Data','Analysis']",
"assert Convert('Hadoop Training') == ['Hadoop','Training']"
] | [] | |
736 | Write a function to sort a list of lists by length and value. | def is_Word_Present(sentence,word):
s = sentence.split(" ")
for i in s:
if (i == word):
return True
return False | [
"assert min_Swaps(\"1101\",\"1110\") == 1",
"assert min_Swaps(\"1111\",\"0100\") == \"Not Possible\"",
"assert min_Swaps(\"1110000\",\"0001101\") == 3"
] | [] | |
752 | Write a function to extract values between quotation marks of the given string by using regex. | import re
def remove_extra_char(text1):
pattern = re.compile('[\W_]+')
return (pattern.sub('', text1)) | [
"assert text_match(\"ac\")==('Found a match!')",
"assert text_match(\"dc\")==('Not matched!')",
"assert text_match(\"abba\")==('Found a match!')"
] | [] | |
642 | Write a python function to check whether the given strings are rotations of each other or not. | 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 lateralsurface_cone(5,12)==204.20352248333654",
"assert lateralsurface_cone(10,15)==566.3586699569488",
"assert lateralsurface_cone(19,17)==1521.8090132193388"
] | [] | |
707 | Write a function to perfom the modulo of tuple elements in the given two tuples. | def Split(list):
ev_li = []
for i in list:
if (i % 2 == 0):
ev_li.append(i)
return ev_li | [
"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"
] | [] | |
655 | Write a function that matches a string that has an a followed by zero or more b's. | 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 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"
] | [] | |
625 | Write a python function to find the average of even numbers till a given even number. | def Sum_of_Inverse_Divisors(N,Sum):
ans = float(Sum)*1.0 /float(N);
return round(ans,2); | [
"assert increment_numerics([\"MSM\", \"234\", \"is\", \"98\", \"123\", \"best\", \"4\"] , 6) == ['MSM', '240', 'is', '104', '129', 'best', '10']",
"assert increment_numerics([\"Dart\", \"356\", \"is\", \"88\", \"169\", \"Super\", \"6\"] , 12) == ['Dart', '368', 'is', '100', '181', 'Super', '18']",
"assert incre... | [] | |
666 | Write a function to check if the given tuple contains all valid values or not. | def is_Product_Even(arr,n):
for i in range(0,n):
if ((arr[i] & 1) == 0):
return True
return False | [
"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"
] | [] | |
613 | Write a function to get dictionary keys as a list. | def profit_amount(actual_cost,sale_amount):
if(actual_cost > sale_amount):
amount = actual_cost - sale_amount
return amount
else:
return None | [
"assert max_of_two(10,20)==20",
"assert max_of_two(19,15)==19",
"assert max_of_two(-10,-20)==-10"
] | [] | |
760 | Write a function to reverse each list in a given list of lists. | def remove_duplic_list(l):
temp = []
for x in l:
if x not in temp:
temp.append(x)
return temp | [
"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"
] | [] | |
680 | Write a python function to count the number of distinct power of prime factor of given number. | def sum_Square(n) :
i = 1
while i*i <= n :
j = 1
while (j*j <= n) :
if (i*i+j*j == n) :
return True
j = j+1
i = i+1
return False | [
"assert len_complex(3,4)==5.0",
"assert len_complex(9,10)==13.45362404707371",
"assert len_complex(7,9)==11.40175425099138"
] | [] | |
973 | Write a python function to find the type of triangle from the given sides. | 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 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]"
] | [] | |
732 | Write a function to add a dictionary to the tuple. | def first_repeated_char(str1):
for index,c in enumerate(str1):
if str1[:index+1].count(c) > 1:
return c
return "None" | [
"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"
] | [] | |
758 | Write a function to find the equilibrium index of the given array. | 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 roman_to_int('MMMCMLXXXVI')==3986",
"assert roman_to_int('MMMM')==4000",
"assert roman_to_int('C')==100"
] | [] | |
867 | Write a python function to calculate the sum of the numbers in a list between the indices of a specified range. | def check_Concat(str1,str2):
N = len(str1)
M = len(str2)
if (N % M != 0):
return False
for i in range(N):
if (str1[i] != str2[i % M]):
return False
return True | [
"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"
] | [] | |
897 | Write a function to find the longest chain which can be formed from the given set of pairs. | 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 text_match_three(\"ac\")==('Not matched!')",
"assert text_match_three(\"dc\")==('Not matched!')",
"assert text_match_three(\"abbbba\")==('Found a match!')"
] | [] | |
881 | Write a function to find the product of it’s kth index in the given tuples. | 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 sort_numeric_strings( ['4','12','45','7','0','100','200','-12','-500'])==[-500, -12, 0, 4, 7, 12, 45, 100, 200]",
"assert sort_numeric_strings(['2','3','8','4','7','9','8','2','6','5','1','6','1','2','3','4','6','9','1','2'])==[1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8, 9, 9]",
"assert sort_n... | [] | |
808 | Write a python function to set the right most unset bit. | import re
def text_match_zero_one(text):
patterns = 'ab?'
if re.search(patterns, text):
return 'Found a match!'
else:
return('Not matched!') | [
"assert count_alpha_dig_spl(\"abc!@#123\")==(3,3,3)",
"assert count_alpha_dig_spl(\"dgsuy@#$%&1255\")==(5,4,5)",
"assert count_alpha_dig_spl(\"fjdsif627348#%$^&\")==(6,6,5)"
] | [] | |
927 | Write a python function to remove negative numbers from a list. | 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 is_nonagonal(10) == 325",
"assert is_nonagonal(15) == 750",
"assert is_nonagonal(18) == 1089"
] | [] | |
904 | Write a function to check whether the given string is ending with only alphanumeric characters or not using regex. | 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 sort_dict_item({(5, 6) : 3, (2, 3) : 9, (8, 4): 10, (6, 4): 12} ) == {(2, 3): 9, (6, 4): 12, (5, 6): 3, (8, 4): 10}",
"assert sort_dict_item({(6, 7) : 4, (3, 4) : 10, (9, 5): 11, (7, 5): 13} ) == {(3, 4): 10, (7, 5): 13, (6, 7): 4, (9, 5): 11}",
"assert sort_dict_item({(7, 8) : 5, (4, 5) : 11, (10, 6): ... | [] | |
647 | Write a python function to check whether the given number is odd or not using bitwise operator. | def validity_triangle(a,b,c):
total = a + b + c
if total == 180:
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"
] | [] | |
614 | Write a python function to find the first odd number in a given list of numbers. | def subset(ar, n):
res = 0
ar.sort()
for i in range(0, n) :
count = 1
for i in range(n - 1):
if ar[i] == ar[i + 1]:
count+=1
else:
break
res = max(res, count)
return res | [
"assert count_Divisors(10) == \"Even\"",
"assert count_Divisors(100) == \"Odd\"",
"assert count_Divisors(125) == \"Even\""
] | [] | |
729 | Write a python function to find the minimum sum of absolute differences of two arrays. | def clear_tuple(test_tup):
temp = list(test_tup)
temp.clear()
test_tup = tuple(temp)
return (test_tup) | [
"assert find_platform([900, 940, 950, 1100, 1500, 1800],[910, 1200, 1120, 1130, 1900, 2000],6)==3",
"assert find_platform([100,200,300,400],[700,800,900,1000],4)==4",
"assert find_platform([5,6,7,8],[4,3,2,1],4)==1"
] | [] | |
709 | Write a python function to find the last position of an element in a sorted array. | def div_of_nums(nums,m,n):
result = list(filter(lambda x: (x % m == 0 and x % n == 0), nums))
return result | [
"assert area_trapezium(6,9,4)==30",
"assert area_trapezium(10,20,30)==450",
"assert area_trapezium(15,25,35)==700"
] | [] | |
832 | Write a python function to find number of solutions in quadratic equation. | from collections import defaultdict
def get_unique(test_list):
res = defaultdict(list)
for sub in test_list:
res[sub[1]].append(sub[0])
res = dict(res)
res_dict = dict()
for key in res:
res_dict[key] = len(list(set(res[key])))
return (str(res_dict)) | [
"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' "
] | [] | |
689 | Write a function to check if a triangle of positive area is possible with the given angles. | import re
def remove_char(S):
result = re.sub('[\W_]+', '', S)
return result | [
"assert sum_of_square(4) == 70",
"assert sum_of_square(5) == 252",
"assert sum_of_square(2) == 6"
] | [] | |
936 | Write a function to sort a list of dictionaries using lambda function. | import bisect
def left_insertion(a, x):
i = bisect.bisect_left(a, x)
return i | [
"assert floor_Max(11,10,9) == 9",
"assert floor_Max(5,7,4) == 2",
"assert floor_Max(2,2,1) == 1"
] | [] | |
854 | Write a python function to count the number of lists in a given number of lists. | def min_Swaps(s1,s2) :
c0 = 0; c1 = 0;
for i in range(len(s1)) :
if (s1[i] == '0' and s2[i] == '1') :
c0 += 1;
elif (s1[i] == '1' and s2[i] == '0') :
c1 += 1;
result = c0 // 2 + c1 // 2;
if (c0 % 2 == 0 and c1 % 2 == 0) :
return r... | [
"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)"
] | [] | |
922 | Write a function to sort the given array by using heap sort. | from itertools import groupby
def consecutive_duplicates(nums):
return [key for key, group in groupby(nums)] | [
"assert tuple_to_set(('x', 'y', 'z') ) == {'y', 'x', 'z'}",
"assert tuple_to_set(('a', 'b', 'c') ) == {'c', 'a', 'b'}",
"assert tuple_to_set(('z', 'd', 'e') ) == {'d', 'e', 'z'}"
] | [] | |
956 | Write a function to exchange the position of every n-th value with (n+1)th value and (n+1)th value with n-th value in a given list. | def number_ctr(str):
number_ctr= 0
for i in range(len(str)):
if str[i] >= '0' and str[i] <= '9': number_ctr += 1
return number_ctr | [
"assert are_Equal([1,2,3],[3,2,1],3,3) == True",
"assert are_Equal([1,1,1],[2,2,2],3,3) == False",
"assert are_Equal([8,9],[4,5,6],2,3) == False"
] | [] | |
954 | Write a python function to find the first repeated character in a given string. | def series_sum(number):
total = 0
total = (number * (number + 1) * (2 * number + 1)) / 6
return total | [
"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)"
] | [] | |
728 | Write a function to iterate over all pairs of consecutive items in a given list. | def harmonic_sum(n):
if n < 2:
return 1
else:
return 1 / n + (harmonic_sum(n - 1)) | [
"assert split_upperstring(\"PythonProgramLanguage\")==['Python','Program','Language']",
"assert split_upperstring(\"PythonProgram\")==['Python','Program']",
"assert split_upperstring(\"ProgrammingLanguage\")==['Programming','Language']"
] | [] | |
699 | Write a python function to find the length of the shortest word. | import re
def road_rd(street):
return (re.sub('Road$', 'Rd.', street)) | [
"assert mutiple_tuple((4, 3, 2, 2, -1, 18)) == -864",
"assert mutiple_tuple((1,2,3)) == 6",
"assert mutiple_tuple((-2,-4,-6)) == -48"
] | [] | |
893 | Write a python function to check whether a sequence of numbers has a decreasing trend or not. | def jacobsthal_num(n):
dp = [0] * (n + 1)
dp[0] = 0
dp[1] = 1
for i in range(2, n+1):
dp[i] = dp[i - 1] + 2 * dp[i - 2]
return dp[n] | [
"assert series_sum(6)==91",
"assert series_sum(7)==140",
"assert series_sum(12)==650"
] | [] | |
755 | Write a function to return true if the password is valid. | def smallest_multiple(n):
if (n<=2):
return n
i = n * 2
factors = [number for number in range(n, 1, -1) if number * 2 > n]
while True:
for a in factors:
if i % a != 0:
i += n
break
if (a == factors[-1] and i % a == 0):
... | [
"assert 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] "
] | [] | |
846 | Write a function that matches a string that has an a followed by three 'b'. | def swap_List(newList):
size = len(newList)
temp = newList[0]
newList[0] = newList[size - 1]
newList[size - 1] = temp
return newList | [
"assert length_Of_Last_Word(\"python language\") == 8",
"assert length_Of_Last_Word(\"PHP\") == 3",
"assert length_Of_Last_Word(\"\") == 0"
] | [] | |
941 | Write a function to sort the given array without using any sorting algorithm. the given array consists of only 0, 1, and 2. | def listify_list(list1):
result = list(map(list,list1))
return result | [
"assert Sum_of_Inverse_Divisors(6,12) == 2",
"assert Sum_of_Inverse_Divisors(9,13) == 1.44",
"assert Sum_of_Inverse_Divisors(1,4) == 4"
] | [] | |
770 | Write a python function to check whether every odd index contains odd numbers of a given list. | 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 anagram_lambda([\"bcda\", \"abce\", \"cbda\", \"cbea\", \"adcb\"],\"abcd\")==['bcda', 'cbda', 'adcb']",
"assert anagram_lambda([\"recitals\",\" python\"], \"articles\" )==[\"recitals\"]",
"assert anagram_lambda([\" keep\",\" abcdef\",\" xyz\"],\" peek\")==[\" keep\"]"
] | [] | |
631 | Write a function to count the same pair in two given lists using map function. | def string_length(str1):
count = 0
for char in str1:
count += 1
return count | [
"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':... | [] | |
879 | Write a function to check if each element of second tuple is smaller than its corresponding index in first tuple. | 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 road_rd(\"ravipadu Road\")==('ravipadu Rd.')",
"assert road_rd(\"palnadu Road\")==('palnadu Rd.')",
"assert road_rd(\"eshwar enclave Road\")==('eshwar enclave Rd.')"
] | [] | |
782 | Write a function to find area of a sector. | def discriminant_value(x,y,z):
discriminant = (y**2) - (4*x*z)
if discriminant > 0:
return ("Two solutions",discriminant)
elif discriminant == 0:
return ("one solution",discriminant)
elif discriminant < 0:
return ("no real solution",discriminant) | [
"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,... | [] | |
889 | Write function to find the sum of all items in the given dictionary. | 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 No_of_cubes(2,1) == 8",
"assert No_of_cubes(5,2) == 64",
"assert No_of_cubes(1,1) == 1"
] | [] | |
695 | Write a function to caluclate the area of a tetrahedron. | def Average(lst):
return sum(lst) / len(lst) | [
"assert remove_nested((1, 5, 7, (4, 6), 10)) == (1, 5, 7, 10)",
"assert remove_nested((2, 6, 8, (5, 7), 11)) == (2, 6, 8, 11)",
"assert remove_nested((3, 7, 9, (6, 8), 12)) == (3, 7, 9, 12)"
] | [] | |
884 | Write a function to convert the given tuple to a key-value dictionary using adjacent elements. | 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 all_Characters_Same(\"python\") == False",
"assert all_Characters_Same(\"aaa\") == True",
"assert all_Characters_Same(\"data\") == False"
] | [] | |
677 | Write a function to move all the numbers in it to the given string. | 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 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'"
] | [] | |
646 | Write a function to find the n - cheap price items from a given dataset using heap queue algorithm. | 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 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... | [] | |
825 | Write a function to find the smallest multiple of the first n numbers. | def count_Char(str,x):
count = 0
for i in range(len(str)):
if (str[i] == x) :
count += 1
n = 10
repititions = n // len(str)
count = count * repititions
l = n % len(str)
for i in range(l):
if (str[i] == x):
count += 1
return... | [
"assert min_difference([(3, 5), (1, 7), (10, 3), (1, 2)]) == 1",
"assert min_difference([(4, 6), (12, 8), (11, 4), (2, 13)]) == 2",
"assert min_difference([(5, 17), (3, 9), (12, 5), (3, 24)]) == 6"
] | [] | |
906 | Write a python function to check whether the given number is a perfect square or not. | def sum_list(lst1,lst2):
res_list = [lst1[i] + lst2[i] for i in range(len(lst1))]
return res_list | [
"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'... | [] |
End of preview. Expand in Data Studio
edition_2724_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