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
|
|---|---|---|---|---|---|
710
|
Write a python function to choose points from two ranges such that no point lies in both the ranges.
|
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 rgb_to_hsv(255, 255, 255)==(0, 0.0, 100.0)",
"assert rgb_to_hsv(0, 215, 0)==(120.0, 100.0, 84.31372549019608)",
"assert rgb_to_hsv(10, 215, 110)==(149.26829268292684, 95.34883720930233, 84.31372549019608)"
] |
[] |
|
829
|
Write a function to convert camel case string to snake case string by using regex.
|
def access_elements(nums, list_index):
result = [nums[i] for i in list_index]
return result
|
[
"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)]"
] |
[] |
|
823
|
Write a function to divide two lists using map and lambda function.
|
def get_product(val) :
res = 1
for ele in val:
res *= ele
return res
def find_k_product(test_list, K):
res = get_product([sub[K] for sub in test_list])
return (res)
|
[
"assert count_variable(4,2,0,-2)==['p', 'p', 'p', 'p', 'q', 'q'] ",
"assert count_variable(0,1,2,3)==['q', 'r', 'r', 's', 's', 's'] ",
"assert count_variable(11,15,12,23)==['p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's']"
] |
[] |
|
689
|
Write a python function to check whether all the characters are same or not.
|
def dealnnoy_num(n, m):
if (m == 0 or n == 0) :
return 1
return dealnnoy_num(m - 1, n) + dealnnoy_num(m - 1, n - 1) + dealnnoy_num(m, n - 1)
|
[
"assert get_odd_occurence([2, 3, 5, 4, 5, 2, 4, 3, 5, 2, 4, 4, 2], 13) == 5",
"assert get_odd_occurence([1, 2, 3, 2, 3, 1, 3], 7) == 3",
"assert get_odd_occurence([5, 7, 2, 7, 5, 2, 5], 7) == 5"
] |
[] |
|
722
|
Write a function that matches a string that has an a followed by zero or more b's.
|
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, -1):
if string[j] == ' ':
string[index] = '0'
string[index-1] = '2'
string[index-2] = '%'
index=index-3
else:
string[index] = string[j]
index -= 1
return ''.join(string)
|
[
"assert last_Two_Digits(7) == 40",
"assert last_Two_Digits(5) == 20",
"assert last_Two_Digits(2) == 2"
] |
[] |
|
767
|
Write a function to return true if the given number is even else return false.
|
def average_Even(n) :
if (n% 2!= 0) :
return ("Invalid Input")
return -1
sm = 0
count = 0
while (n>= 2) :
count = count+1
sm = sm+n
n = n-2
return sm // count
|
[
"assert is_Two_Alter(\"abab\") == True",
"assert is_Two_Alter(\"aaaa\") == False",
"assert is_Two_Alter(\"xyz\") == False"
] |
[] |
|
908
|
Write a function that matches a string that has an 'a' followed by anything, ending in 'b' by using regex.
|
def area_trapezium(base1,base2,height):
area = 0.5 * (base1 + base2) * height
return area
|
[
"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"
] |
[] |
|
835
|
Write a python function to find the sum of all odd natural numbers within the range l and r.
|
def nth_nums(nums,n):
nth_nums = list(map(lambda x: x ** n, nums))
return nth_nums
|
[
"assert power_base_sum(2,100)==115",
"assert power_base_sum(8,10)==37",
"assert power_base_sum(8,15)==62"
] |
[] |
|
793
|
Write a function to multiply two lists using map and lambda function.
|
def find_Min_Swaps(arr,n) :
noOfZeroes = [0] * n
count = 0
noOfZeroes[n - 1] = 1 - arr[n - 1]
for i in range(n-2,-1,-1) :
noOfZeroes[i] = noOfZeroes[i + 1]
if (arr[i] == 0) :
noOfZeroes[i] = noOfZeroes[i] + 1
for i in range(0,n) :
if (arr[i] == 1) :
count = count + noOfZeroes[i]
return count
|
[
"assert previous_palindrome(99)==88",
"assert previous_palindrome(1221)==1111",
"assert previous_palindrome(120)==111"
] |
[] |
|
725
|
Write a function to push all values into a heap and then pop off the smallest values one at a time.
|
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', 'Go', 'Eco', 'System']"
] |
[] |
|
794
|
Write a python function to find the first digit in factorial of a given number.
|
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 check_monthnumb(\"February\")==False",
"assert check_monthnumb(\"January\")==True",
"assert check_monthnumb(\"March\")==True"
] |
[] |
|
870
|
Write a function to find maximum of two numbers.
|
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 (max < mcl[i]):
max = mcl[i]
return max
|
[
"assert round_up(123.01247,0)==124",
"assert round_up(123.01247,1)==123.1",
"assert round_up(123.01247,2)==123.02"
] |
[] |
|
969
|
Write a function where a string will start with a specific number.
|
def rombus_area(p,q):
area=(p*q)/2
return area
|
[
"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, 2], [3, 4], [4, 5], [6, 7]])=={(1, 2): 1, (3, 4): 1, (4, 5): 1, (6, 7): 1}"
] |
[] |
|
729
|
Write a python function to check whether an array can be sorted or not by picking only the corner elements.
|
import math
def sum_series(number):
total = 0
total = math.pow((number * (number + 1)) /2, 2)
return total
|
[
"assert first_Digit(5) == 1",
"assert first_Digit(10) == 3",
"assert first_Digit(7) == 5"
] |
[] |
|
620
|
Write a function to find the fixed point in the given array.
|
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 chinese_zodiac(1997)==('Ox')",
"assert chinese_zodiac(1998)==('Tiger')",
"assert chinese_zodiac(1994)==('Dog')"
] |
[] |
|
819
|
Write a python function to check whether all the bits are within a given range or not.
|
def floor_Min(A,B,N):
x = max(B - 1,N)
return (A*x) // B
|
[
"assert floor_Max(11,10,9) == 9",
"assert floor_Max(5,7,4) == 2",
"assert floor_Max(2,2,1) == 1"
] |
[] |
|
891
|
Write a function to print the first n lucky numbers.
|
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)
start -= 1
def shift_down(arr, start, end):
root = start
while root * 2 + 1 <= end:
child = root * 2 + 1
if child + 1 <= end and arr[child] < arr[child + 1]:
child += 1
if child <= end and arr[root] < arr[child]:
arr[root], arr[child] = arr[child], arr[root]
root = child
else:
return
|
[
"assert div_of_nums([19, 65, 57, 39, 152, 639, 121, 44, 90, 190],2,4)==[ 152,44]",
"assert div_of_nums([1, 2, 3, 5, 7, 8, 10],2,5)==[10]",
"assert div_of_nums([10,15,14,13,18,12,20],10,5)==[10,20]"
] |
[] |
|
779
|
Write a function to find out, if the given number is abundant.
|
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 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"
] |
[] |
|
661
|
Write a function to check whether the given string is ending with only alphanumeric characters or not using regex.
|
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 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"
] |
[] |
|
702
|
Write a function to calculate the height of the given binary tree.
|
import math
def is_polite(n):
n = n + 1
return (int)(n+(math.log((n + math.log(n, 2)), 2)))
|
[
"assert harmonic_sum(10)==2.9289682539682538",
"assert harmonic_sum(4)==2.083333333333333",
"assert harmonic_sum(7)==2.5928571428571425 "
] |
[] |
|
915
|
Write a function to add two integers. however, if the sum is between the given range it will return 20.
|
def add_list(nums1,nums2):
result = map(lambda x, y: x + y, nums1, nums2)
return list(result)
|
[
"assert count_Char(\"abcac\",'a') == 4",
"assert count_Char(\"abca\",'c') == 2",
"assert count_Char(\"aba\",'a') == 7"
] |
[] |
|
711
|
Write a function to flatten the given tuple matrix into the tuple list with each tuple representing each column.
|
def return_sum(dict):
sum = 0
for i in dict.values():
sum = sum + i
return sum
|
[
"assert profit_amount(1500,1200)==300",
"assert profit_amount(100,200)==None",
"assert profit_amount(2000,5000)==None"
] |
[] |
|
963
|
Write a python function to check whether the given number is odd or not using bitwise operator.
|
def reverse_words(s):
return ' '.join(reversed(s.split()))
|
[
"assert is_triangleexists(50,60,70)==True",
"assert is_triangleexists(90,45,45)==True",
"assert is_triangleexists(150,30,70)==False"
] |
[] |
|
690
|
Write a function to calculate the standard deviation.
|
def get_noOfways(n):
if (n == 0):
return 0;
if (n == 1):
return 1;
return get_noOfways(n - 1) + get_noOfways(n - 2);
|
[
"assert is_odd(5) == True",
"assert is_odd(6) == False",
"assert is_odd(7) == True"
] |
[] |
|
874
|
Write a function to get dictionary keys as a list.
|
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 text_uppercase_lowercase(\"AaBbGg\")==('Found a match!')",
"assert text_uppercase_lowercase(\"aA\")==('Not matched!')",
"assert text_uppercase_lowercase(\"PYTHON\")==('Not matched!')"
] |
[] |
|
770
|
Write a function to check if the string is a valid email address or not using regex.
|
import re
def remove_char(S):
result = re.sub('[\W_]+', '', S)
return result
|
[
"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]"
] |
[] |
|
609
|
Write a python function to count equal element pairs from the given array.
|
import bisect
def right_insertion(a, x):
i = bisect.bisect_right(a, x)
return i
|
[
"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"
] |
[] |
|
943
|
Write a function to calculate the sum of series 1³+2³+3³+….+n³.
|
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
curr_sum += curr_term
res *= curr_sum
if n >= 2:
res *= (1 + n)
return res
|
[
"assert max_product([1, 2, 3, 4, 7, 0, 8, 4])==(7, 8)",
"assert max_product([0, -1, -2, -4, 5, 0, -6])==(-4, -6)",
"assert max_product([1, 3, 5, 6, 8, 9])==(8,9)"
] |
[] |
|
748
|
Write a function to find the most common elements and their counts of a specified text.
|
INT_BITS = 32
def left_Rotate(n,d):
return (n << d)|(n >> (INT_BITS - d))
|
[
"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"
] |
[] |
|
832
|
Write a function to remove all tuples with all none values in the given tuple 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_run_uppercase('GeMKSForGERksISBESt') == 5",
"assert max_run_uppercase('PrECIOusMOVemENTSYT') == 6",
"assert max_run_uppercase('GooGLEFluTTER') == 4"
] |
[] |
|
697
|
Write a function to check whether the given amount has no profit and no loss
|
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 sum_num((8, 2, 3, 0, 7))==4.0",
"assert sum_num((-10,-20,-30))==-20.0",
"assert sum_num((19,15,18))==17.333333333333332"
] |
[] |
|
657
|
Write a python function to move all zeroes to the end of the given list.
|
import itertools
def remove_duplicate(list1):
list.sort(list1)
remove_duplicate = list(list1 for list1,_ in itertools.groupby(list1))
return remove_duplicate
|
[
"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"
] |
[] |
|
815
|
Write a function to add two lists using map and lambda function.
|
def sum_Of_Subarray_Prod(arr,n):
ans = 0
res = 0
i = n - 1
while (i >= 0):
incr = arr[i]*(1 + res)
ans += incr
res = incr
i -= 1
return (ans)
|
[
"assert geometric_sum(7) == 1.9921875",
"assert geometric_sum(4) == 1.9375",
"assert geometric_sum(8) == 1.99609375"
] |
[] |
|
758
|
Write a function to convert the given string of integers into a tuple.
|
import re
def split_list(text):
return (re.findall('[A-Z][^A-Z]*', text))
|
[
"assert access_elements([2,3,8,4,7,9],[0,3,5]) == [2, 4, 9]",
"assert access_elements([1, 2, 3, 4, 5],[1,2]) == [2,3]",
"assert access_elements([1,0,2,3],[0,1]) == [1,0]"
] |
[] |
|
849
|
Write a python function to find lcm of two positive integers.
|
def check(string):
if len(set(string).intersection("AEIOUaeiou"))>=5:
return ('accepted')
else:
return ("not accepted")
|
[
"assert fifth_Power_Sum(2) == 33",
"assert fifth_Power_Sum(4) == 1300",
"assert fifth_Power_Sum(3) == 276"
] |
[] |
|
709
|
Write a python function to find sum of products of all possible subarrays.
|
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 even_Power_Sum(2) == 272",
"assert even_Power_Sum(3) == 1568",
"assert even_Power_Sum(4) == 5664"
] |
[] |
|
802
|
Write a python function to find the smallest missing number from the given array.
|
from itertools import combinations
def find_combinations(test_list):
res = [(b1 + a1, b2 + a2) for (a1, a2), (b1, b2) in combinations(test_list, 2)]
return (res)
|
[
"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"
] |
[] |
|
931
|
Write a python function to find number of solutions in quadratic equation.
|
def len_log(list1):
min=len(list1[0])
for i in list1:
if len(i)<min:
min=len(i)
return min
|
[
"assert max_of_three(10,20,30)==30",
"assert max_of_three(55,47,39)==55",
"assert max_of_three(10,49,30)==49"
] |
[] |
|
673
|
Write a python function to check for even parity of a given number.
|
def convert(list):
s = [str(i) for i in list]
res = int("".join(s))
return (res)
|
[
"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 "
] |
[] |
|
624
|
Write a function to create a list taking alternate elements from another given list.
|
def Split(list):
ev_li = []
for i in list:
if (i % 2 == 0):
ev_li.append(i)
return ev_li
|
[
"assert div_list([4,5,6],[1, 2, 3])==[4.0,2.5,2.0]",
"assert div_list([3,2],[1,4])==[3.0, 0.5]",
"assert div_list([90,120],[50,70])==[1.8, 1.7142857142857142]"
] |
[] |
|
646
|
Write a python function to print duplicants from a list of integers.
|
import re
def check_substring(string, sample) :
if (sample in string):
y = "\A" + sample
x = re.search(y, string)
if x :
return ("string starts with the given substring")
else :
return ("string doesnt start with the given substring")
else :
return ("entered string isnt a substring")
|
[
"assert get_coordinates((3, 4)) == [[2, 3], [2, 4], [2, 5], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5]]",
"assert get_coordinates((4, 5)) ==[[3, 4], [3, 5], [3, 6], [4, 4], [4, 5], [4, 6], [5, 4], [5, 5], [5, 6]]",
"assert get_coordinates((5, 6)) == [[4, 5], [4, 6], [4, 7], [5, 5], [5, 6], [5, 7], [6, 5], [6, 6], [6, 7]]"
] |
[] |
|
810
|
Write a function to count the pairs of reverse strings in the given string list.
|
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 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"
] |
[] |
|
784
|
Write a function to find the smallest multiple of the first n numbers.
|
import datetime
def check_date(m, d, y):
try:
m, d, y = map(int, (m, d, y))
datetime.date(y, m, d)
return True
except ValueError:
return False
|
[
"assert 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"
] |
[] |
|
740
|
Write a function to check whether the given month number contains 30 days or not.
|
import math
def get_First_Set_Bit_Pos(n):
return math.log2(n&-n)+1
|
[
"assert (max_height(root)) == 3",
"assert (max_height(root1)) == 5 ",
"assert (max_height(root2)) == 4"
] |
[] |
|
687
|
Write a function to find nth polite number.
|
def mul_list(nums1,nums2):
result = map(lambda x, y: x * y, nums1, nums2)
return list(result)
|
[
"assert check([3,2,1,2,3,4],6) == True",
"assert check([2,1,4,5,1],5) == True",
"assert check([1,2,2,1,2,3],6) == True"
] |
[] |
|
947
|
Write a function to find the largest possible value of k such that k modulo x is y.
|
def chunk_tuples(test_tup, N):
res = [test_tup[i : i + N] for i in range(0, len(test_tup), N)]
return (res)
|
[
"assert check_email(\"ankitrai326@gmail.com\") == 'Valid Email'",
"assert check_email(\"my.ownsite@ourearth.org\") == 'Valid Email'",
"assert check_email(\"ankitaoie326.com\") == 'Invalid Email'"
] |
[] |
|
747
|
Write a function to find the nth jacobsthal number.
|
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 rectangle_perimeter(10,20)==60",
"assert rectangle_perimeter(10,5)==30",
"assert rectangle_perimeter(4,2)==12"
] |
[] |
|
651
|
Write a python function to get the position of rightmost set bit.
|
def length_Of_Last_Word(a):
l = 0
x = a.strip()
for i in range(len(x)):
if x[i] == " ":
l = 0
else:
l += 1
return l
|
[
"assert cube_Sum(2) == 28",
"assert cube_Sum(3) == 153",
"assert cube_Sum(4) == 496"
] |
[] |
|
792
|
Write a function to find the largest subset where each pair is divisible.
|
def first_repeated_char(str1):
for index,c in enumerate(str1):
if str1[:index+1].count(c) > 1:
return c
return "None"
|
[
"assert roman_to_int('MMMCMLXXXVI')==3986",
"assert roman_to_int('MMMM')==4000",
"assert roman_to_int('C')==100"
] |
[] |
|
909
|
Write a function to find length of the subarray having maximum sum.
|
def count_list(input_list):
return (len(input_list))**2
|
[
"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')"
] |
[] |
|
714
|
Write a python function to left rotate the string.
|
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 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"
] |
[] |
|
825
|
Write a python function to convert a list of multiple integers into a single integer.
|
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 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"
] |
[] |
|
601
|
Write a function to count number of unique lists within a list.
|
def get_odd_occurence(arr, arr_size):
for i in range(0, arr_size):
count = 0
for j in range(0, arr_size):
if arr[i] == arr[j]:
count += 1
if (count % 2 != 0):
return arr[i]
return -1
|
[
"assert check_expression(\"{()}[{}]\") == True",
"assert check_expression(\"{()}[{]\") == False",
"assert check_expression(\"{()}[{}][]({})\") == True"
] |
[] |
|
654
|
Write a function to check if the given string starts with a substring using regex.
|
from collections import Counter
def add_dict(d1,d2):
add_dict = Counter(d1) + Counter(d2)
return add_dict
|
[
"assert even_num(13.5)==False",
"assert even_num(0)==True",
"assert even_num(-9)==False"
] |
[] |
|
699
|
Write a python function to calculate the product of all the numbers of a given tuple.
|
def maximum_value(test_list):
res = [(key, max(lst)) for key, lst in test_list]
return (res)
|
[
"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"
] |
[] |
|
778
|
Write a function to replace whitespaces with an underscore and vice versa in a given string by using regex.
|
def swap_List(newList):
size = len(newList)
temp = newList[0]
newList[0] = newList[size - 1]
newList[size - 1] = temp
return newList
|
[
"assert max_char(\"hello world\")==('l')",
"assert max_char(\"hello \")==('l')",
"assert max_char(\"python pr\")==('p')"
] |
[] |
|
842
|
Write a function to find ln, m lobb number.
|
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 all_Bits_Set_In_The_Given_Range(10,2,1) == True ",
"assert all_Bits_Set_In_The_Given_Range(5,2,4) == False",
"assert all_Bits_Set_In_The_Given_Range(22,2,3) == True "
] |
[] |
|
838
|
Write a python function to check whether a sequence of numbers has an increasing trend or not.
|
def tuple_to_set(t):
s = set(t)
return (s)
|
[
"assert remove_all_spaces('python program')==('pythonprogram')",
"assert remove_all_spaces('python programming language')==('pythonprogramminglanguage')",
"assert remove_all_spaces('python program')==('pythonprogram')"
] |
[] |
|
631
|
Write a function to compute the value of ncr mod p.
|
def count_range_in_list(li, min, max):
ctr = 0
for x in li:
if min <= x <= max:
ctr += 1
return ctr
|
[
"assert lcs_of_three('AGGT12', '12TXAYB', '12XBA', 6, 7, 5) == 2",
"assert lcs_of_three('Reels', 'Reelsfor', 'ReelsforReels', 5, 8, 13) == 5 ",
"assert lcs_of_three('abcd1e2', 'bc12ea', 'bd1ea', 7, 6, 5) == 3"
] |
[] |
|
763
|
Write a function to compute maximum product of three numbers of a given array of integers using heap queue algorithm.
|
def No_of_cubes(N,K):
No = 0
No = (N - K + 1)
No = pow(No, 3)
return No
|
[
"assert second_smallest([1, 2, -8, -2, 0, -2])==-2",
"assert second_smallest([1, 1, -0.5, 0, 2, -2, -2])==-0.5",
"assert second_smallest([2,2])==None"
] |
[] |
|
855
|
Write a function to generate a square matrix filled with elements from 1 to n raised to the power of 2 in spiral order.
|
def check_tuples(test_tuple, K):
res = all(ele in K for ele in test_tuple)
return (res)
|
[
"assert sector_area(4,45)==6.285714285714286",
"assert sector_area(9,45)==31.82142857142857",
"assert sector_area(9,360)==None"
] |
[] |
|
682
|
Write a function to count number of lists in a given list of lists and square the count.
|
def decreasing_trend(nums):
if (sorted(nums)== nums):
return True
else:
return False
|
[
"assert Convert('python program') == ['python','program']",
"assert Convert('Data Analysis') ==['Data','Analysis']",
"assert Convert('Hadoop Training') == ['Hadoop','Training']"
] |
[] |
|
655
|
Write a python function to find the last two digits in factorial of a given number.
|
def multiply_list(items):
tot = 1
for x in items:
tot *= x
return tot
|
[
"assert convert([1,2,3]) == 123",
"assert convert([4,5,6]) == 456",
"assert convert([7,8,9]) == 789"
] |
[] |
|
732
|
Write a python function to find minimum possible value for the given periodic function.
|
def sorted_dict(dict1):
sorted_dict = {x: sorted(y) for x, y in dict1.items()}
return sorted_dict
|
[
"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"
] |
[] |
|
769
|
Write a function to remove duplicates from a list of lists.
|
import math
def area_tetrahedron(side):
area = math.sqrt(3)*(side*side)
return area
|
[
"assert front_and_rear((10, 4, 5, 6, 7)) == (10, 7)",
"assert front_and_rear((1, 2, 3, 4, 5)) == (1, 5)",
"assert front_and_rear((6, 7, 8, 9, 10)) == (6, 10)"
] |
[] |
|
898
|
Write a function that matches a string that has an 'a' followed by anything, ending in 'b'.
|
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 * ((r-g)/df) + 240) % 360
if mx == 0:
s = 0
else:
s = (df/mx)*100
v = mx*100
return h, s, v
|
[
"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 ',' orange', 'brown'])==[[' ', 'r', 'e', 'd', ' '], ['g', 'r', 'e', 'e', 'n'], [' ', 'b', 'l', 'a', 'c', 'k'], ['b', 'l', 'u', 'e', ' '], [' ', 'o', 'r', 'a', 'n', 'g', 'e'], ['b', 'r', 'o', 'w', 'n']]"
] |
[] |
|
902
|
Write a function to group the 1st elements on the basis of 2nd elements in the given tuple list.
|
def sum_list(lst1,lst2):
res_list = [lst1[i] + lst2[i] for i in range(len(lst1))]
return res_list
|
[
"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\") ] "
] |
[] |
|
965
|
Write a function to remove everything except alphanumeric characters from the given string by using regex.
|
import re
def remove_multiple_spaces(text1):
return (re.sub(' +',' ',text1))
|
[
"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'}"
] |
[] |
|
700
|
Write a function to display sign of the chinese zodiac for given year.
|
def sum_Of_Primes(n):
prime = [True] * (n + 1)
p = 2
while p * p <= n:
if prime[p] == True:
i = p * 2
while i <= n:
prime[i] = False
i += p
p += 1
sum = 0
for i in range (2,n + 1):
if(prime[i]):
sum += i
return sum
|
[
"assert move_num('I1love143you55three3000thousand') == 'Iloveyouthreethousand1143553000'",
"assert move_num('Avengers124Assemble') == 'AvengersAssemble124'",
"assert move_num('Its11our12path13to14see15things16do17things') == 'Itsourpathtoseethingsdothings11121314151617'"
] |
[] |
|
836
|
Write a function to extract values between quotation marks of the given string by using regex.
|
def rearrange_numbs(array_nums):
result = sorted(array_nums, key = lambda i: 0 if i == 0 else -1 / i)
return result
|
[
"assert find_first_occurrence([2, 5, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 1",
"assert find_first_occurrence([2, 3, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 2",
"assert find_first_occurrence([2, 4, 1, 5, 6, 6, 8, 9, 9, 9], 6) == 4"
] |
[] |
|
790
|
Write a python function to find the minimun number of subsets with distinct elements.
|
def float_to_tuple(test_str):
res = tuple(map(float, test_str.split(', ')))
return (res)
|
[
"assert pair_OR_Sum([5,9,7,6],4) == 47",
"assert pair_OR_Sum([7,3,5],3) == 12",
"assert pair_OR_Sum([7,3],2) == 4"
] |
[] |
|
759
|
Write a python function to check whether the given number is a perfect square or not.
|
def filter_data(students,h,w):
result = {k: s for k, s in students.items() if s[0] >=h and s[1] >=w}
return result
|
[
"assert wind_chill(120,35)==40",
"assert wind_chill(40,70)==86",
"assert wind_chill(10,100)==116"
] |
[] |
|
683
|
Write a function that matches a string that has an a followed by zero or one 'b'.
|
import re
def text_match_wordz_middle(text):
patterns = '\Bz\B'
if re.search(patterns, text):
return 'Found a match!'
else:
return('Not matched!')
|
[
"assert find_Digits(7) == 4",
"assert find_Digits(5) == 3",
"assert find_Digits(4) == 2"
] |
[] |
|
892
|
Write a python function to remove the k'th element from a given list.
|
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
index += 1
return ludics
|
[
"assert recur_gcd(12,14) == 2",
"assert recur_gcd(13,17) == 1",
"assert recur_gcd(9, 3) == 3"
] |
[] |
|
828
|
Write a function to pack consecutive duplicates of a given list elements into sublists.
|
import re
def text_starta_endb(text):
patterns = 'a.*?b$'
if re.search(patterns, text):
return 'Found a match!'
else:
return('Not matched!')
|
[
"assert No_of_cubes(2,1) == 8",
"assert No_of_cubes(5,2) == 64",
"assert No_of_cubes(1,1) == 1"
] |
root = Node(1)
root.left = Node(2)
root.right = Node(3)
root.left.left = Node(4)
root.left.right = Node(5)
root1 = Node(1);
root1.left = Node(2);
root1.right = Node(3);
root1.left.left = Node(4);
root1.right.left = Node(5);
root1.right.right = Node(6);
root1.right.right.right= Node(7);
root1.right.right.right.right = Node(8)
root2 = Node(1)
root2.left = Node(2)
root2.right = Node(3)
root2.left.left = Node(4)
root2.left.right = Node(5)
root2.left.left.left = Node(6)
root2.left.left.right = Node(7)
|
[] |
866
|
Write a python function to calculate the sum of the numbers in a list between the indices of a specified range.
|
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 chunk_tuples((10, 4, 5, 6, 7, 6, 8, 3, 4), 3) == [(10, 4, 5), (6, 7, 6), (8, 3, 4)]",
"assert chunk_tuples((1, 2, 3, 4, 5, 6, 7, 8, 9), 2) == [(1, 2), (3, 4), (5, 6), (7, 8), (9,)]",
"assert chunk_tuples((11, 14, 16, 17, 19, 21, 22, 25), 4) == [(11, 14, 16, 17), (19, 21, 22, 25)]"
] |
[] |
|
662
|
Write a function to find the nth super ugly number from a given prime list of size k using heap queue algorithm.
|
def slope(x1,y1,x2,y2):
return (float)(y2-y1)/(x2-x1)
|
[
"assert toggle_middle_bits(9) == 15",
"assert toggle_middle_bits(10) == 12",
"assert toggle_middle_bits(11) == 13"
] |
[] |
|
694
|
Write a python function to check whether the word is present in a given sentence or not.
|
import re
def capital_words_spaces(str1):
return re.sub(r"(\w)([A-Z])", r"\1 \2", str1)
|
[
"assert first_repeated_char(\"abcabc\") == \"a\"",
"assert first_repeated_char(\"abc\") == \"None\"",
"assert first_repeated_char(\"123123\") == \"1\""
] |
[] |
|
712
|
Write a function to remove the nested record from the given tuple.
|
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] + 1,
dp[i + c])
return dp[n]
|
[
"assert palindrome_lambda([\"php\", \"res\", \"Python\", \"abcd\", \"Java\", \"aaa\"])==['php', 'aaa']",
"assert palindrome_lambda([\"abcd\", \"Python\", \"abba\", \"aba\"])==['abba', 'aba']",
"assert palindrome_lambda([\"abcd\", \"abbccbba\", \"abba\", \"aba\"])==['abbccbba', 'abba', 'aba']"
] |
[] |
|
853
|
Write a function to sum elements in two lists.
|
def noprofit_noloss(actual_cost,sale_amount):
if(sale_amount == actual_cost):
return True
else:
return False
|
[
"assert series_sum(6)==91",
"assert series_sum(7)==140",
"assert series_sum(12)==650"
] |
[] |
|
742
|
Write a function to find numbers divisible by m and n from a list of numbers using lambda function.
|
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] + sum[i-3])
return sum[n-1]
|
[
"assert Split([1,2,3,4,5]) == [2,4]",
"assert Split([4,5,6,7,8,0,1]) == [4,6,8,0]",
"assert Split ([8,12,15,19]) == [8,12]"
] |
[] |
|
771
|
Write a function to sort a list in a dictionary.
|
def last(arr,x,n):
low = 0
high = n - 1
res = -1
while (low <= high):
mid = (low + high) // 2
if arr[mid] > x:
high = mid - 1
elif arr[mid] < x:
low = mid + 1
else:
res = mid
low = mid + 1
return res
|
[
"assert remove_extra_char('**//Google Android// - 12. ') == 'GoogleAndroid12'",
"assert remove_extra_char('****//Google Flutter//*** - 36. ') == 'GoogleFlutter36'",
"assert remove_extra_char('**//Google Firebase// - 478. ') == 'GoogleFirebase478'"
] |
[] |
|
685
|
Write a python function to count the number of rotations required to generate a sorted array.
|
import math
def radian_degree(degree):
radian = degree*(math.pi/180)
return radian
|
[
"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']",
"assert remove_duplic_list([\"Python\", \"Exercises\", \"Practice\", \"Solution\", \"Exercises\",\"C++\",\"C\",\"C++\"])==['Python', 'Exercises', 'Practice', 'Solution','C++','C']"
] |
[] |
|
677
|
Write a function to rearrange positive and negative numbers in a given array using lambda function.
|
def Repeat(x):
_size = len(x)
repeated = []
for i in range(_size):
k = i + 1
for j in range(k, _size):
if x[i] == x[j] and x[i] not in repeated:
repeated.append(x[i])
return repeated
|
[
"assert get_item((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),3)==('e')",
"assert get_item((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),-4)==('u')",
"assert get_item((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),-3)==('r')"
] |
[] |
|
826
|
Write a python function to add a minimum number such that the sum of array becomes even.
|
def check_identical(test_list1, test_list2):
res = test_list1 == test_list2
return (res)
|
[
"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)], 1) == [('Ayesha', 9)]"
] |
[] |
|
834
|
Write a function to remove multiple spaces in a string by using regex.
|
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 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\"]"
] |
[] |
|
703
|
Write a function to remove all the words with k length in the given string.
|
def count_tuplex(tuplex,value):
count = tuplex.count(value)
return count
|
[
"assert noprofit_noloss(1500,1200)==False",
"assert noprofit_noloss(100,100)==True",
"assert noprofit_noloss(2000,5000)==False"
] |
[] |
|
913
|
Write a function to abbreviate 'road' as 'rd.' in a given string.
|
def min_of_two( x, y ):
if x < y:
return x
return y
|
[
"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, 10)], [(12, 15), (20, 21)], [(23, 7), (15, 8)]]) == '[(6, 9, 12, 20, 23, 15), (7, 10, 15, 21, 7, 8)]'"
] |
[] |
|
797
|
Write a function to split the given string at uppercase letters by 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")
else:
return ("Acute-angled Triangle")
|
[
"assert divisible_by_digits(1,22)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]",
"assert divisible_by_digits(1,15)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15]",
"assert divisible_by_digits(20,25)==[22, 24]"
] |
[] |
|
876
|
Write a python function to count number of vowels in the string.
|
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 remove_spaces(\"a b c\") == \"abc\"",
"assert remove_spaces(\"1 2 3\") == \"123\"",
"assert remove_spaces(\" b c\") == \"bc\""
] |
[] |
|
772
|
Write a function to convert the given tuple to a key-value dictionary using adjacent elements.
|
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 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"
] |
[] |
|
776
|
Write a function to check if a nested list is a subset of another nested list.
|
def are_Rotations(string1,string2):
size1 = len(string1)
size2 = len(string2)
temp = ''
if size1 != size2:
return False
temp = string1 + string1
if (temp.count(string2)> 0):
return True
else:
return False
|
[
"assert check_Odd_Parity(13) == True",
"assert check_Odd_Parity(21) == True",
"assert check_Odd_Parity(18) == False"
] |
[] |
|
626
|
Write a function to calculate the sum of all digits of the base to the specified power.
|
def sort_tuple(tup):
n = len(tup)
for i in range(n):
for j in range(n-i-1):
if tup[j][0] > tup[j + 1][0]:
tup[j], tup[j + 1] = tup[j + 1], tup[j]
return tup
|
[
"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"
] |
[] |
|
824
|
Write a python function to interchange first and last elements in a given list.
|
def average_tuple(nums):
result = [sum(x) / len(x) for x in zip(*nums)]
return result
|
[
"assert Odd_Length_Sum([1,2,4]) == 14",
"assert Odd_Length_Sum([1,2,1,2]) == 15",
"assert Odd_Length_Sum([1,7]) == 8"
] |
[] |
|
616
|
Write a function to check if the given tuple contains all valid values or not.
|
def remove_duplic_list(l):
temp = []
for x in l:
if x not in temp:
temp.append(x)
return temp
|
[
"assert left_Rotate(16,2) == 64",
"assert left_Rotate(10,2) == 40",
"assert left_Rotate(99,3) == 792"
] |
[] |
|
972
|
Write a python function to set the right most unset bit.
|
def all_Characters_Same(s) :
n = len(s)
for i in range(1,n) :
if s[i] != s[0] :
return False
return True
|
[
"assert Average([15, 9, 55, 41, 35, 20, 62, 49]) == 35.75",
"assert Average([4, 5, 1, 2, 9, 7, 10, 8]) == 5.75",
"assert Average([1,2,3]) == 2"
] |
[] |
|
897
|
Write a python function to check whether the given number can be represented by sum of two squares or not.
|
def Average(lst):
return sum(lst) / len(lst)
|
[
"assert text_match_zero_one(\"ac\")==('Found a match!')",
"assert text_match_zero_one(\"dc\")==('Not matched!')",
"assert text_match_zero_one(\"abbbba\")==('Found a match!')"
] |
[] |
|
967
|
Write a function to validate a gregorian date.
|
def get_median(arr1, arr2, n):
i = 0
j = 0
m1 = -1
m2 = -1
count = 0
while count < n + 1:
count += 1
if i == n:
m1 = m2
m2 = arr2[0]
break
elif j == n:
m1 = m2
m2 = arr1[0]
break
if arr1[i] <= arr2[j]:
m1 = m2
m2 = arr1[i]
i += 1
else:
m1 = m2
m2 = arr2[j]
j += 1
return (m1 + m2)/2
|
[
"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-s-death-his-brother-in-law-shares-advice-for-fans-1749646/\") == [('2020', '11', '03')]",
"assert extract_date(\"https://economictimes.indiatimes.com/news/economy/2020/12/29/finance/pension-assets-under-pfrda-touch-rs-5-32-lakh-crore/articleshow/79736619.cms\") == [('2020', '12', '29')]"
] |
[] |
|
961
|
Write a function to find the minimum number of platforms required for a railway/bus station.
|
def Check_Solution(a,b,c) :
if ((b*b) - (4*a*c)) > 0 :
return ("2 solutions")
elif ((b*b) - (4*a*c)) == 0 :
return ("1 solution")
else :
return ("No solutions")
|
[
"assert 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]"
] |
[] |
|
873
|
Write a python function to check whether the given two numbers have same number of digits or not.
|
def increasing_trend(nums):
if (sorted(nums)== nums):
return True
else:
return False
|
[
"assert fibonacci(7) == 13",
"assert fibonacci(8) == 21",
"assert fibonacci(9) == 34"
] |
[] |
End of preview. Expand
in Data Studio
edition_1650_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
- 4