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 |
|---|---|---|---|---|---|
707 | Write a python function to add a minimum number such that the sum of array becomes even. | def add_tuple(test_list, test_tup):
test_list += test_tup
return (test_list) | [
"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]"
] | [] | |
722 | Write a python function to remove spaces from a given string. | import sys
def find_max_val(n, x, y):
ans = -sys.maxsize
for k in range(n + 1):
if (k % x == y):
ans = max(ans, k)
return (ans if (ans >= 0 and
ans <= n) else -1) | [
"assert lcm(4,6) == 12",
"assert lcm(15,17) == 255",
"assert lcm(2,6) == 6"
] | [] | |
940 | Write a function to find the smallest multiple of the first n numbers. | def unique_sublists(list1):
result ={}
for l in list1:
result.setdefault(tuple(l), list()).append(1)
for a, b in result.items():
result[a] = sum(b)
return result | [
"assert 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"
] | [] | |
775 | Write a python function to check whether the word is present in a given sentence or not. | 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 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... | [] | |
849 | Write a python function to find the index of smallest triangular number with n digits. | 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 remove_spaces('python program')==('python program')",
"assert remove_spaces('python programming language')==('python programming language')",
"assert remove_spaces('python program')==('python program')"
] | [] | |
809 | Write a function to remove sublists from a given list of lists, which are outside a given range. | def is_decimal(num):
import re
dnumre = re.compile(r"""^[0-9]+(\.[0-9]{1,2})?$""")
result = dnumre.search(num)
return bool(result) | [
"assert even_num(13.5)==False",
"assert even_num(0)==True",
"assert even_num(-9)==False"
] | [] | |
717 | Write a python function to find the last two digits in factorial of a given number. | def ntimes_list(nums,n):
result = map(lambda x:n*x, nums)
return list(result) | [
"assert add_dict_to_tuple((4, 5, 6), {\"MSAM\" : 1, \"is\" : 2, \"best\" : 3} ) == (4, 5, 6, {'MSAM': 1, 'is': 2, 'best': 3})",
"assert add_dict_to_tuple((1, 2, 3), {\"UTS\" : 2, \"is\" : 3, \"Worst\" : 4} ) == (1, 2, 3, {'UTS': 2, 'is': 3, 'Worst': 4})",
"assert add_dict_to_tuple((8, 9, 10), {\"POS\" : 3, \"is... | [] | |
950 | Write a function to sort the tuples alphabetically by the first item of each tuple. | def min_Swaps(str1,str2) :
count = 0
for i in range(len(str1)) :
if str1[i] != str2[i] :
count += 1
if count % 2 == 0 :
return (count // 2)
else :
return ("Not Possible") | [
"assert coin_change([1, 2, 3],3,4)==4",
"assert coin_change([4,5,6,7,8,9],6,9)==2",
"assert coin_change([4,5,6,7,8,9],6,4)==1"
] | [] | |
793 | Write a function where a string will start with a specific number. | import re
pattern = 'fox'
text = 'The quick brown fox jumps over the lazy dog.'
def find_literals(text, pattern):
match = re.search(pattern, text)
s = match.start()
e = match.end()
return (match.re.pattern, s, e) | [
"assert 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"
] | [] | |
922 | Write a function to count number of unique lists within a list. | import cmath
def len_complex(a,b):
cn=complex(a,b)
length=abs(cn)
return length | [
"assert max_of_three(10,20,30)==30",
"assert max_of_three(55,47,39)==55",
"assert max_of_three(10,49,30)==49"
] | [] | |
637 | Write a python function to remove even numbers from a given list. | def max_run_uppercase(test_str):
cnt = 0
res = 0
for idx in range(0, len(test_str)):
if test_str[idx].isupper():
cnt += 1
else:
res = cnt
cnt = 0
if test_str[len(test_str) - 1].isupper():
res = cnt
return (res) | [
"assert 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]"
] | [] | |
965 | Write a python function to find the cube sum of first n odd natural numbers. | def sum_positivenum(nums):
sum_positivenum = list(filter(lambda nums:nums>0,nums))
return sum(sum_positivenum) | [
"assert floor_Max(11,10,9) == 9",
"assert floor_Max(5,7,4) == 2",
"assert floor_Max(2,2,1) == 1"
] | [] | |
688 | Write a function to display sign of the chinese zodiac for given year. | 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 remove_tuple([(None, 2), (None, None), (3, 4), (12, 3), (None, )] ) == '[(None, 2), (3, 4), (12, 3)]'",
"assert remove_tuple([(None, None), (None, None), (3, 6), (17, 3), (None,1 )] ) == '[(3, 6), (17, 3), (None, 1)]'",
"assert remove_tuple([(1, 2), (2, None), (3, None), (24, 3), (None, None )] ) == '[(... | [] | |
833 | Write a function to find the longest common subsequence for the given three string sequence. | def rombus_area(p,q):
area=(p*q)/2
return area | [
"assert test_three_equal(1,1,1) == 3",
"assert test_three_equal(-1,-2,-3) == 0",
"assert test_three_equal(1,2,2) == 2"
] | [] | |
726 | Write a function to convert camel case string to snake case string by using regex. | def cube_Sum(n):
sum = 0
for i in range(0,n) :
sum += (2*i+1)*(2*i+1)*(2*i+1)
return sum | [
"assert remove_all_spaces('python program')==('pythonprogram')",
"assert remove_all_spaces('python programming language')==('pythonprogramminglanguage')",
"assert remove_all_spaces('python program')==('pythonprogram')"
] | [] | |
623 | Write a function to check if the string is a valid email address or not using regex. | def concatenate_nested(test_tup1, test_tup2):
res = test_tup1 + test_tup2
return (res) | [
"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,... | [] | |
831 | Write a python function to find the minimun number of subsets with distinct elements. | def count_list(input_list):
return (len(input_list))**2 | [
"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"
] | [] | |
713 | Write function to find the sum of all items in the given dictionary. | def check_min_heap(arr, i):
if 2 * i + 2 > len(arr):
return True
left_child = (arr[i] <= arr[2 * i + 1]) and check_min_heap(arr, 2 * i + 1)
right_child = (2 * i + 2 == len(arr)) or (arr[i] <= arr[2 * i + 2]
and check_min_heap(arr, 2 * i + 2))
return left_child and right_child | [
"assert Sum(60) == 10",
"assert Sum(39) == 16",
"assert Sum(40) == 7"
] | [] | |
619 | Write a function to find the largest possible value of k such that k modulo x is y. | def all_Characters_Same(s) :
n = len(s)
for i in range(1,n) :
if s[i] != s[0] :
return False
return True | [
"assert check_monthnum_number(2)==True",
"assert check_monthnum_number(1)==False",
"assert check_monthnum_number(3)==False"
] | [] | |
734 | Write a function to remove all the words with k length in the given string. | import heapq as hq
def raw_heap(rawheap):
hq.heapify(rawheap)
return rawheap | [
"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 ... | [] | |
855 | Write a function to remove everything except alphanumeric characters from the given 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 toggle_middle_bits(9) == 15",
"assert toggle_middle_bits(10) == 12",
"assert toggle_middle_bits(11) == 13"
] | [] | |
813 | Write a function to put spaces between words starting with capital letters in a given string by using regex. | from collections import defaultdict
def freq_element(test_tup):
res = defaultdict(int)
for ele in test_tup:
res[ele] += 1
return (str(dict(res))) | [
"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] "
] | [] | |
885 | Write a function to check if the given tuple contains only k elements. | def count_Rotation(arr,n):
for i in range (1,n):
if (arr[i] < arr[i - 1]):
return i
return 0 | [
"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',... | [] | |
961 | Write a function to find a path with the maximum average over all existing paths for the given square matrix of size n*n. | def 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 (((2 * m + 1) *
binomial_coeff(2 * n, m + n))
/ (m + n + 1)) | [
"assert max_char(\"hello world\")==('l')",
"assert max_char(\"hello \")==('l')",
"assert max_char(\"python pr\")==('p')"
] | [] | |
937 | Write a function to find if there is a triplet in the array whose sum is equal to a given value. | 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 jumps[n-1] | [
"assert max_occurrences([2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,4,6,9,1,2])==2",
"assert max_occurrences([1, 3,5, 7,1, 3,13, 15, 17,5, 7,9,1, 11])==1",
"assert max_occurrences([1, 2, 3,2, 4, 5,1, 1, 1])==1"
] | [] | |
903 | Write a python function to find minimum number swaps required to make two binary strings equal. | def listify_list(list1):
result = list(map(list,list1))
return result | [
"assert harmonic_sum(10)==2.9289682539682538",
"assert harmonic_sum(4)==2.083333333333333",
"assert harmonic_sum(7)==2.5928571428571425 "
] | [] | |
777 | Write a function to find the area of a rombus. | M = 100
def maxAverageOfPath(cost, N):
dp = [[0 for i in range(N + 1)] for j in range(N + 1)]
dp[0][0] = cost[0][0]
for i in range(1, N):
dp[i][0] = dp[i - 1][0] + cost[i][0]
for j in range(1, N):
dp[0][j] = dp[0][j - 1] + cost[0][j]
for i in range(1, N):
for j in range(1, N):
dp[i][j] = max(dp[i - 1][j],
dp[i][j - 1]) + cost[i][j]
return dp[N - 1][N - 1] / (2 * N - 1) | [
"assert cube_Sum(2) == 28",
"assert cube_Sum(3) == 153",
"assert cube_Sum(4) == 496"
] | [] | |
887 | Write a function to extract values between quotation marks of the given string 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 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]) == [... | [] | |
645 | Write a function to compute maximum product of three numbers of a given array of integers using heap queue algorithm. | 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
powerOf2 <<= 1;
return cnt; | [
"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"
] | [] | |
709 | Write a python function to reverse an array upto a given position. | def Check_Vow(string, vowels):
final = [each for each in string if each in vowels]
return(len(final))
| [
"assert recur_gcd(12,14) == 2",
"assert recur_gcd(13,17) == 1",
"assert recur_gcd(9, 3) == 3"
] | [] | |
649 | Write a python function to calculate the product of all the numbers of a given tuple. | def len_log(list1):
min=len(list1[0])
for i in list1:
if len(i)<min:
min=len(i)
return min | [
"assert check_Concat(\"abcabcabc\",\"abc\") == True",
"assert check_Concat(\"abcab\",\"abc\") == False",
"assert check_Concat(\"aba\",\"ab\") == False"
] | [] | |
748 | Write a function to combine two dictionaries by adding values for common keys. | def noprofit_noloss(actual_cost,sale_amount):
if(sale_amount == actual_cost):
return True
else:
return False | [
"assert last_Two_Digits(7) == 40",
"assert last_Two_Digits(5) == 20",
"assert last_Two_Digits(2) == 2"
] | [] | |
901 | Write a function to check if the given tuple contains all valid values or not. | 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 find_Digits(7) == 4",
"assert find_Digits(5) == 3",
"assert find_Digits(4) == 2"
] | [] | |
876 | Write a function to access the initial and last data of the given tuple record. | def all_Bits_Set_In_The_Given_Range(n,l,r):
num = ((1 << r) - 1) ^ ((1 << (l - 1)) - 1)
new_num = n & num
if (num == new_num):
return True
return False | [
"assert Repeat([10, 20, 30, 20, 20, 30, 40, 50, -20, 60, 60, -20, -20]) == [20, 30, -20, 60]",
"assert Repeat([-1, 1, -1, 8]) == [-1]",
"assert Repeat([1, 2, 3, 1, 2,]) == [1, 2]"
] | [] | |
918 | Write a function to check if a nested list is a subset of another nested list. | def sum_Range_list(nums, m, n):
sum_range = 0
for i in range(m, n+1, 1):
sum_range += nums[i]
return sum_range | [
"assert sort_sublists([[2], [0], [1, 3], [0, 7], [9, 11], [13, 15, 17]])==[[0], [2], [0, 7], [1, 3], [9, 11], [13, 15, 17]]",
"assert sort_sublists([[1], [2, 3], [4, 5, 6], [7], [10, 11]])==[[1], [7], [2, 3], [10, 11], [4, 5, 6]]",
"assert sort_sublists([[\"python\"],[\"java\",\"C\",\"C++\"],[\"DBMS\"],[\"SQL\"... | [] | |
854 | Write a function to caluclate the area of a tetrahedron. | def mul_list(nums1,nums2):
result = map(lambda x, y: x * y, nums1, nums2)
return list(result) | [
"assert sorted_models([{'make':'Nokia', 'model':216, 'color':'Black'}, {'make':'Mi Max', 'model':2, 'color':'Gold'}, {'make':'Samsung', 'model': 7, 'color':'Blue'}])==[{'make': 'Nokia', 'model': 216, 'color': 'Black'}, {'make': 'Samsung', 'model': 7, 'color': 'Blue'}, {'make': 'Mi Max', 'model': 2, 'color': 'Gold'}... | [] | |
761 | Write a function to calculate the sum of series 1³+2³+3³+….+n³. | def unique_Element(arr,n):
s = set(arr)
if (len(s) == 1):
return ('YES')
else:
return ('NO') | [
"assert Check_Vow('corner','AaEeIiOoUu') == 2",
"assert Check_Vow('valid','AaEeIiOoUu') == 2",
"assert Check_Vow('true','AaEeIiOoUu') ==2"
] | [] | |
652 | Write a python function to find the index of an extra element present in one sorted array. | 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 (max_height(root)) == 3",
"assert (max_height(root1)) == 5 ",
"assert (max_height(root2)) == 4"
] | [] | |
941 | Write a python function to find sum of products of all possible subarrays. | def remove_empty(tuple1): #L = [(), (), ('',), ('a', 'b'), ('a', 'b', 'c'), ('d')]
tuple1 = [t for t in tuple1 if t]
return tuple1 | [
"assert concatenate_nested((3, 4), (5, 6)) == (3, 4, 5, 6)",
"assert concatenate_nested((1, 2), (3, 4)) == (1, 2, 3, 4)",
"assert concatenate_nested((4, 5), (6, 8)) == (4, 5, 6, 8)"
] | [] | |
907 | Write a function to round up a number to specific digits. | def remove_similar_row(test_list):
res = set(sorted([tuple(sorted(set(sub))) for sub in test_list]))
return (res) | [
"assert Check_Solution(2,5,2) == \"2 solutions\"",
"assert Check_Solution(1,1,1) == \"No solutions\"",
"assert Check_Solution(1,2,1) == \"1 solution\""
] | [] | |
932 | Write a python function to count the number of rotations required to generate a sorted array. | from collections import Counter
def second_frequent(input):
dict = Counter(input)
value = sorted(dict.values(), reverse=True)
second_large = value[1]
for (key, val) in dict.items():
if val == second_large:
return (key) | [
"assert sum_Of_Primes(10) == 17",
"assert sum_Of_Primes(20) == 77",
"assert sum_Of_Primes(5) == 10"
] | [] | |
834 | Write a function to check if each element of second tuple is smaller than its corresponding index in first tuple. | 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 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"
] | [] | |
666 | Write a function which accepts an arbitrary list and converts it to a heap using heap queue algorithm. | from itertools import groupby
def pack_consecutive_duplicates(list1):
return [list(group) for key, group in groupby(list1)] | [
"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"
] | [] | |
792 | Write a function to find the item with maximum occurrences in a given list. | def mul_consecutive_nums(nums):
result = [b*a for a, b in zip(nums[:-1], nums[1:])]
return result | [
"assert count_tuplex((2, 4, 5, 6, 2, 3, 4, 4, 7),4)==3",
"assert count_tuplex((2, 4, 5, 6, 2, 3, 4, 4, 7),2)==2",
"assert count_tuplex((2, 4, 7, 7, 7, 3, 4, 4, 7),7)==4"
] | [] | |
888 | Write a function to sum the length of the names of a given list of names after removing the names that start with a lowercase letter. | import math
def find_Index(n):
x = math.sqrt(2 * math.pow(10,(n - 1)));
return round(x); | [
"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,... | [] | |
650 | Write a function that matches a string that has an a followed by three 'b'. | def Check_Solution(a,b,c):
if (a == c):
return ("Yes");
else:
return ("No"); | [
"assert sum_positivenum([2, 4, -6, -9, 11, -12, 14, -5, 17])==48",
"assert sum_positivenum([10,15,-14,13,-18,12,-20])==50",
"assert sum_positivenum([19, -65, 57, 39, 152,-639, 121, 44, 90, -190])==522"
] | [] | |
714 | Write a function to find the second smallest number in a list. | def sorted_dict(dict1):
sorted_dict = {x: sorted(y) for x, y in dict1.items()}
return sorted_dict | [
"assert sum_nums(2,10,11,20)==20",
"assert sum_nums(15,17,1,10)==32",
"assert sum_nums(10,15,5,30)==20"
] | [] | |
661 | Write a function that matches a string that has an 'a' followed by anything, ending in 'b'. | 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 check_none((10, 4, 5, 6, None)) == True",
"assert check_none((7, 8, 9, 11, 14)) == False",
"assert check_none((1, 2, 3, 4, None)) == True"
] | [] | |
615 | Write a function to replace all spaces in the given string with character * list item * list item * list item * list item '%20'. | def roman_to_int(s):
rom_val = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
int_val = 0
for i in range(len(s)):
if i > 0 and rom_val[s[i]] > rom_val[s[i - 1]]:
int_val += rom_val[s[i]] - 2 * rom_val[s[i - 1]]
else:
int_val += rom_val[s[i]]
return int_val | [
"assert consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4 ])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4]",
"assert consecutive_duplicates([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10])==[10, 15, 19, 18, 17, 26, 17, 18, 10]",
"assert consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd'])==['a', 'b... | [] | |
774 | Write a function to count the most common character in a given string. | import re
def text_match(text):
patterns = 'ab*?'
if re.search(patterns, text):
return ('Found a match!')
else:
return ('Not matched!') | [
"assert camel_to_snake('GoogleAssistant') == 'google_assistant'",
"assert camel_to_snake('ChromeCast') == 'chrome_cast'",
"assert camel_to_snake('QuadCore') == 'quad_core'"
] | [] | |
799 | Write a function to count number of lists in a given list of lists and square the count. | def is_Word_Present(sentence,word):
s = sentence.split(" ")
for i in s:
if (i == word):
return True
return False | [
"assert bell_Number(2) == 2",
"assert bell_Number(3) == 5",
"assert bell_Number(4) == 15"
] | [] | |
912 | Write a python function to find the minimum number of swaps required to convert one binary string to another. | def merge(lst):
return [list(ele) for ele in list(zip(*lst))] | [
"assert area_tetrahedron(3)==15.588457268119894",
"assert area_tetrahedron(20)==692.8203230275509",
"assert area_tetrahedron(10)==173.20508075688772"
] | [] | |
919 | Write a function to sum a specific column of a list in a given list of lists. | 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 num_position(\"there are 70 flats in this apartment\")==10",
"assert num_position(\"every adult have 32 teeth\")==17",
"assert num_position(\"isha has 79 chocolates in her bag\")==9"
] | [] | |
895 | Write a python function to find the smallest missing number from the given array. | def arc_length(d,a):
pi=22/7
if a >= 360:
return None
arclength = (pi*d) * (a/360)
return arclength | [
"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\"]"
] | [] | |
602 | Write a function to abbreviate 'road' as 'rd.' in a given string. | def swap_List(newList):
size = len(newList)
temp = newList[0]
newList[0] = newList[size - 1]
newList[size - 1] = temp
return newList | [
"assert join_tuples([(5, 6), (5, 7), (6, 8), (6, 10), (7, 13)] ) == [(5, 6, 7), (6, 8, 10), (7, 13)]",
"assert join_tuples([(6, 7), (6, 8), (7, 9), (7, 11), (8, 14)] ) == [(6, 7, 8), (7, 9, 11), (8, 14)]",
"assert join_tuples([(7, 8), (7, 9), (8, 10), (8, 12), (9, 15)] ) == [(7, 8, 9), (8, 10, 12), (9, 15)]"
] | [] | |
949 | Write a function to calculate the height of the given binary tree. | def tuple_to_set(t):
s = set(t)
return (s) | [
"assert sum_Square(25) == True",
"assert sum_Square(24) == False",
"assert sum_Square(17) == True"
] | [] | |
914 | Write a function to add two lists using map and lambda function. | import math
def is_polite(n):
n = n + 1
return (int)(n+(math.log((n + math.log(n, 2)), 2))) | [
"assert max_chain_length([Pair(5, 24), Pair(15, 25),Pair(27, 40), Pair(50, 60)], 4) == 3",
"assert max_chain_length([Pair(1, 2), Pair(3, 4),Pair(5, 6), Pair(7, 8)], 4) == 4",
"assert max_chain_length([Pair(19, 10), Pair(11, 12),Pair(13, 14), Pair(15, 16), Pair(31, 54)], 5) == 5"
] | [] | |
960 | Write a function to find the maximum sum of subsequences of given array with no adjacent elements. | def find_triplet_array(A, arr_size, sum):
for i in range( 0, arr_size-2):
for j in range(i + 1, arr_size-1):
for k in range(j + 1, arr_size):
if A[i] + A[j] + A[k] == sum:
return A[i],A[j],A[k]
return True
return False | [
"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]"
] | [] | |
744 | Write a function to sort dictionary items by tuple product of keys for the given dictionary with tuple keys. | def string_length(str1):
count = 0
for char in str1:
count += 1
return count | [
"assert parallelogram_perimeter(10,20)==400",
"assert parallelogram_perimeter(15,20)==600",
"assert parallelogram_perimeter(8,9)==144"
] | [] | |
872 | Write a function to check if the given array represents min heap or not. | def same_Length(A,B):
while (A > 0 and B > 0):
A = A / 10;
B = B / 10;
if (A == 0 and B == 0):
return True;
return False; | [
"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}'"
] | [] | |
842 | Write a function to find the occurrence and position of the substrings within a string. | 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 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'"
] | [] | |
718 | Write a function that gives profit amount if the given amount has profit else return none. | def multiply_list(items):
tot = 1
for x in items:
tot *= x
return tot | [
"assert power_base_sum(2,100)==115",
"assert power_base_sum(8,10)==37",
"assert power_base_sum(8,15)==62"
] | [] | |
928 | Write a python function to get the position of rightmost set bit. | import re
def split_list(text):
return (re.findall('[A-Z][^A-Z]*', text)) | [
"assert extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[1, 7]",
"assert extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 6, 5],[0, 1, 2, 3, 4, 6, 7])==[1, 6]",
"assert extract_index_list([1, 1, 3, 4, 6, 5, 6],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[1, 5]"
] | [] | |
841 | Write a function to find out, if the given number is abundant. | 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 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"
] | [] | |
867 | Write a function to calculate the sum of series 1²+2²+3²+….+n². | 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, n):
j = find_ind(arr[i], i,
n, k, arr)
if (j != -1):
ans = min(ans, n -
(j - i + 1))
return ans | [
"assert average_tuple(((10, 10, 10, 12), (30, 45, 56, 45), (81, 80, 39, 32), (1, 2, 3, 4)))==[30.5, 34.25, 27.0, 23.25]",
"assert average_tuple(((1, 1, -5), (30, -15, 56), (81, -60, -39), (-10, 2, 3)))== [25.5, -18.0, 3.75]",
"assert average_tuple( ((100, 100, 100, 120), (300, 450, 560, 450), (810, 800, 390, 32... | [] | |
618 | Write a python function to check whether the given string is made up of two alternating characters or not. | import math
def sum_series(number):
total = 0
total = math.pow((number * (number + 1)) /2, 2)
return total | [
"assert text_match(\"msb\") == 'Not matched!'",
"assert text_match(\"a0c\") == 'Found a match!'",
"assert text_match(\"abbc\") == 'Found a match!'"
] | [] | |
635 | Write a function to calculate wind chill index. | from itertools import groupby
def group_element(test_list):
res = dict()
for key, val in groupby(sorted(test_list, key = lambda ele: ele[1]), key = lambda ele: ele[1]):
res[key] = [ele[0] for ele in val]
return (res)
| [
"assert remove_list_range([[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7], [9, 11], [13, 14, 15, 17]],13,17)==[[13, 14, 15, 17]]",
"assert remove_list_range([[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7], [9, 11], [13, 14, 15, 17]],1,3)==[[2], [1, 2, 3]]",
"assert remove_list_range([[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7], ... | [] | |
746 | Write a python function to count the number of pairs whose sum is equal to ‘sum’. | import re
def end_num(string):
text = re.compile(r".*[0-9]$")
if text.match(string):
return True
else:
return False | [
"assert text_match(\"aabbbbd\") == 'Not matched!'",
"assert text_match(\"aabAbbbc\") == 'Not matched!'",
"assert text_match(\"accddbbjjjb\") == 'Found a match!'"
] | [] | |
871 | Write a function to find the length of the shortest string that has both str1 and str2 as subsequences. | def rotate_right(list1,m,n):
result = list1[-(m):]+list1[:-(n)]
return result | [
"assert triangle_area(0) == 0",
"assert triangle_area(-1) == -1",
"assert triangle_area(2) == 4"
] | [] | |
955 | Write a function to sort a list in a dictionary. | def zip_list(list1,list2):
result = list(map(list.__add__, list1, list2))
return result | [
"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"
] | [] | |
712 | Write a function to remove all whitespaces from a string. | 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 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'"
] | [] | |
747 | Write a function to find maximum run of uppercase characters in the given string. | 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 length_Of_Last_Word(\"python language\") == 8",
"assert length_Of_Last_Word(\"PHP\") == 3",
"assert length_Of_Last_Word(\"\") == 0"
] | [] | |
798 | Write a function to find minimum k records from tuple list. | import math
def lateralsurface_cone(r,h):
l = math.sqrt(r * r + h * h)
LSA = math.pi * r * l
return LSA | [
"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)"
] | [] | |
894 | Write a python function to convert a string to a list. | import re
def pass_validity(p):
x = True
while x:
if (len(p)<6 or len(p)>12):
break
elif not re.search("[a-z]",p):
break
elif not re.search("[0-9]",p):
break
elif not re.search("[A-Z]",p):
break
elif not re.search("[$#@]",p):
break
elif re.search("\s",p):
break
else:
return True
x=False
break
if x:
return False | [
"assert rearrange_numbs([-1, 2, -3, 5, 7, 8, 9, -10])==[2, 5, 7, 8, 9, -10, -3, -1]",
"assert rearrange_numbs([10,15,14,13,-18,12,-20])==[10, 12, 13, 14, 15, -20, -18]",
"assert rearrange_numbs([-20,20,-10,10,-30,30])==[10, 20, 30, -30, -20, -10]"
] | [] | |
938 | Write a function to split the given string at uppercase letters by using regex. | import re
def remove_all_spaces(text):
return (re.sub(r'\s+', '',text)) | [
"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)"
] | [] | |
733 | Write a function to remove multiple spaces in a string by using regex. | def sum_list(lst1,lst2):
res_list = [lst1[i] + lst2[i] for i in range(len(lst1))]
return res_list | [
"assert len_log([\"win\",\"lose\",\"great\"]) == 3",
"assert len_log([\"a\",\"ab\",\"abc\"]) == 1",
"assert len_log([\"12\",\"12\",\"1234\"]) == 2"
] | [] | |
920 | Write a function that matches a string that has an 'a' followed by anything, ending in 'b' by using regex. | def access_key(ditionary,key):
return list(ditionary)[key] | [
"assert is_triangleexists(50,60,70)==True",
"assert is_triangleexists(90,45,45)==True",
"assert is_triangleexists(150,30,70)==False"
] | [] | |
727 | Write a python function to count the total unset bits from 1 to n. | 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 min_Swaps(\"0011\",\"1111\") == 1",
"assert min_Swaps(\"00011\",\"01001\") == 2",
"assert min_Swaps(\"111\",\"111\") == 0"
] | [] | |
686 | Write a python function to calculate the sum of the numbers in a list between the indices of a specified range. | def sum_even_odd(list1):
first_even = next((el for el in list1 if el%2==0),-1)
first_odd = next((el for el in list1 if el%2!=0),-1)
return (first_even+first_odd) | [
"assert check_monthnumb(\"February\")==False",
"assert check_monthnumb(\"January\")==True",
"assert check_monthnumb(\"March\")==True"
] | [] | |
620 | Write a function to find the longest chain which can be formed from the given set of pairs. | 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 sort_list_last([(2, 5), (1, 2), (4, 4), (2, 3), (2, 1)])==[(2, 1), (1, 2), (2, 3), (4, 4), (2, 5)] ",
"assert sort_list_last([(9,8), (4, 7), (3,5), (7,9), (1,2)])==[(1,2), (3,5), (4,7), (9,8), (7,9)] ",
"assert sort_list_last([(20,50), (10,20), (40,40)])==[(10,20),(40,40),(20,50)] "
] | [] | |
936 | Write a function to find the nth jacobsthal number. | def chunk_tuples(test_tup, N):
res = [test_tup[i : i + N] for i in range(0, len(test_tup), N)]
return (res) | [
"assert find_combinations([(2, 4), (6, 7), (5, 1), (6, 10)]) == [(8, 11), (7, 5), (8, 14), (11, 8), (12, 17), (11, 11)]",
"assert find_combinations([(3, 5), (7, 8), (6, 2), (7, 11)]) == [(10, 13), (9, 7), (10, 16), (13, 10), (14, 19), (13, 13)]",
"assert find_combinations([(4, 6), (8, 9), (7, 3), (8, 12)]) == [... | [] | |
858 | Write a python function to find the sum of all even natural numbers within the range l and r. | def get_Number(n, k):
arr = [0] * n;
i = 0;
odd = 1;
while (odd <= n):
arr[i] = odd;
i += 1;
odd += 2;
even = 2;
while (even <= n):
arr[i] = even;
i += 1;
even += 2;
return arr[k - 1]; | [
"assert sum_series(7)==784",
"assert sum_series(5)==225",
"assert sum_series(15)==14400"
] | [] | |
752 | Write a python function to find sum of prime numbers between 1 to n. | def is_Product_Even(arr,n):
for i in range(0,n):
if ((arr[i] & 1) == 0):
return True
return False | [
"assert is_decimal('123.11')==True",
"assert is_decimal('e666.86')==False",
"assert is_decimal('3.124587')==False"
] | [] | |
636 | Write a function to convert tuple string to integer tuple. | import bisect
def right_insertion(a, x):
i = bisect.bisect_right(a, x)
return i | [
"assert cummulative_sum([(1, 3), (5, 6, 7), (2, 6)]) == 30",
"assert cummulative_sum([(2, 4), (6, 7, 8), (3, 7)]) == 37",
"assert cummulative_sum([(3, 5), (7, 8, 9), (4, 8)]) == 44"
] | [] | |
862 | Write a function to check whether the given month number contains 30 days or not. | def reverse_words(s):
return ' '.join(reversed(s.split())) | [
"assert find_Min_Diff((1,5,3,19,18,25),6) == 1",
"assert find_Min_Diff((4,3,2,6),4) == 1",
"assert find_Min_Diff((30,5,20,9),4) == 4"
] | [] | |
782 | Write a function to find the n - cheap price items from a given dataset using heap queue algorithm. | 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_substring(\"dreams for dreams makes life fun\", \"makes\") == 'string doesnt start with the given substring'",
"assert check_substring(\"Hi there how are you Hi alex\", \"Hi\") == 'string starts with the given substring'",
"assert check_substring(\"Its been a long day\", \"been\") == 'string doesn... | [] | |
611 | Write a python function to check for even parity of a given number. | def check_tuples(test_tuple, K):
res = all(ele in K for ele in test_tuple)
return (res) | [
"assert check_subset([[1, 3], [5, 7], [9, 11], [13, 15, 17]] ,[[1, 3],[13,15,17]])==True",
"assert check_subset([[1, 2], [2, 3], [3, 4], [5, 6]],[[3, 4], [5, 6]])==True",
"assert check_subset([[[1, 2], [2, 3]], [[3, 4], [5, 7]]],[[[3, 4], [5, 6]]])==False"
] | [] | |
900 | Write a function to check a decimal with a precision of 2. | def _sum(arr):
sum=0
for i in arr:
sum = sum + i
return(sum) | [
"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'... | [] | |
850 | Write a python function to find the minimum sum of absolute differences of two arrays. | import re
def match_num(string):
text = re.compile(r"^5")
if text.match(string):
return True
else:
return False | [
"assert rencontres_number(7, 2) == 924",
"assert rencontres_number(3, 0) == 2",
"assert rencontres_number(3, 1) == 3"
] | [] | |
750 | Write a function to calculate the sum of the positive numbers of a given list of numbers using lambda function. | def Extract(lst):
return [item[-1] for item in lst] | [
"assert find_Index(2) == 4",
"assert find_Index(3) == 14",
"assert find_Index(4) == 45"
] | [] | |
836 | Write a python function to find sum of all prime divisors of a given number. | def fibonacci(n):
if n == 1 or n == 2:
return 1
else:
return (fibonacci(n - 1) + (fibonacci(n - 2))) | [
"assert sort_by_dnf([1,2,0,1,0,1,2,1,1], 9) == [0, 0, 1, 1, 1, 1, 1, 2, 2]",
"assert sort_by_dnf([1,0,0,1,2,1,2,2,1,0], 10) == [0, 0, 0, 1, 1, 1, 1, 2, 2, 2]",
"assert sort_by_dnf([2,2,1,0,0,0,1,1,2,1], 10) == [0, 0, 0, 1, 1, 1, 1, 2, 2, 2]"
] | [] | |
753 | Write a function to convert the given string of float type into tuple. | def reverse_Array_Upto_K(input, k):
return (input[k-1::-1] + input[k:]) | [
"assert is_polite(7) == 11",
"assert is_polite(4) == 7",
"assert is_polite(9) == 13"
] | [] | |
812 | Write a function to convert the given tuple to a key-value dictionary using adjacent elements. | def sort_String(str) :
str = ''.join(sorted(str))
return (str) | [
"assert series_sum(6)==91",
"assert series_sum(7)==140",
"assert series_sum(12)==650"
] | [] | |
741 | Write a python function to get the difference between two lists. | def count_Unset_Bits(n) :
cnt = 0;
for i in range(1,n + 1) :
temp = i;
while (temp) :
if (temp % 2 == 0) :
cnt += 1;
temp = temp // 2;
return cnt; | [
"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"
] | [] | |
968 | Write a python function to find the sum of an array. | def word_len(s):
s = s.split(' ')
for word in s:
if len(word)%2==0:
return True
else:
return False | [
"assert lateralsurface_cone(5,12)==204.20352248333654",
"assert lateralsurface_cone(10,15)==566.3586699569488",
"assert lateralsurface_cone(19,17)==1521.8090132193388"
] | [] | |
702 | Write a function to find the area of a trapezium. | 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[i][j] = x + y
return table[n][m-1] | [
"assert count_list([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==25",
"assert count_list([[1, 3], [5, 7], [9, 11], [13, 15, 17]] )==16",
"assert count_list([[2, 4], [[6,8], [4,5,8]], [10, 12, 14]])==9"
] | [] | |
917 | Write a python function to check whether a sequence of numbers has an increasing trend or not. | import re
def split_upperstring(text):
return (re.findall('[A-Z][^A-Z]*', text)) | [
"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"
] | [] | |
899 | Write a function to push all values into a heap and then pop off the smallest values one at a time. | 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 wind_chill(120,35)==40",
"assert wind_chill(40,70)==86",
"assert wind_chill(10,100)==116"
] | [] | |
861 | Write a function to calculate the standard deviation. | import math
def area_tetrahedron(side):
area = math.sqrt(3)*(side*side)
return area | [
"assert replace('peep','e') == 'pep'",
"assert replace('Greek','e') == 'Grek'",
"assert replace('Moon','o') == 'Mon'"
] | [] | |
705 | Write a python function to sort the given string. | from itertools import groupby
def consecutive_duplicates(nums):
return [key for key, group in groupby(nums)] | [
"assert count_char(\"Python\",'o')==1",
"assert count_char(\"little\",'t')==2",
"assert count_char(\"assert\",'s')==2"
] | [] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.