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
|
|---|---|---|---|---|---|
733
|
Write a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format.
|
def check_subset(test_tup1, test_tup2):
res = set(test_tup2).issubset(test_tup1)
return (res)
|
[
"assert mul_list([1, 2, 3],[4,5,6])==[4,10,18]",
"assert mul_list([1,2],[3,4])==[3,8]",
"assert mul_list([90,120],[50,70])==[4500,8400]"
] |
[] |
|
649
|
Write a function to remove similar rows from the given tuple matrix.
|
def remove_list_range(list1, leftrange, rigthrange):
result = [i for i in list1 if (min(i)>=leftrange and max(i)<=rigthrange)]
return result
|
[
"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)]"
] |
[] |
|
850
|
Write a python function to find the sum of an array.
|
def div_of_nums(nums,m,n):
result = list(filter(lambda x: (x % m == 0 or x % n == 0), nums))
return result
|
[
"assert find_fixed_point([-10, -1, 0, 3, 10, 11, 30, 50, 100],9) == 3",
"assert find_fixed_point([1, 2, 3, 4, 5, 6, 7, 8],8) == -1",
"assert find_fixed_point([0, 2, 5, 8, 17],5) == 0"
] |
[] |
|
747
|
Write a python function to find the minimum difference between any two elements in a given array.
|
def is_Perfect_Square(n) :
i = 1
while (i * i<= n):
if ((n % i == 0) and (n / i == i)):
return True
i = i + 1
return False
|
[
"assert min_jumps([1, 3, 6, 1, 0, 9], 6) == 3",
"assert min_jumps([1, 3, 5, 8, 9, 2, 6, 7, 6, 8, 9], 11) == 3",
"assert min_jumps([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 11) == 10"
] |
[] |
|
602
|
Write a python function to count equal element pairs from the given array.
|
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 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 )] ) == '[(1, 2), (2, None), (3, None), (24, 3)]'"
] |
[] |
|
886
|
Write a function to list out the list of given strings individually using map function.
|
def prime_num(num):
if num >=1:
for i in range(2, num//2):
if (num % i) == 0:
return False
else:
return True
else:
return False
|
[
"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]"
] |
[] |
|
862
|
Write a python function to interchange first and last elements in a given list.
|
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 alternate_elements([\"red\", \"black\", \"white\", \"green\", \"orange\"])==['red', 'white', 'orange']",
"assert alternate_elements([2, 0, 3, 4, 0, 2, 8, 3, 4, 2])==[2, 3, 0, 8, 4]",
"assert alternate_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1,3,5,7,9]"
] |
[] |
|
619
|
Write a python function to check whether the roots of a quadratic equation are numerically equal but opposite in sign or not.
|
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 float_to_tuple(\"1.2, 1.3, 2.3, 2.4, 6.5\") == (1.2, 1.3, 2.3, 2.4, 6.5)",
"assert float_to_tuple(\"2.3, 2.4, 5.6, 5.4, 8.9\") == (2.3, 2.4, 5.6, 5.4, 8.9)",
"assert float_to_tuple(\"0.3, 0.5, 7.8, 9.4\") == (0.3, 0.5, 7.8, 9.4)"
] |
[] |
|
658
|
## write a function to find the minimum number of jumps to reach the end of the array for the given array of integers where each element represents the max number of steps that can be made forward from that element. > indented block > indented block
|
def 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 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]"
] |
[] |
|
685
|
Write a python function to check whether all the characters are same or not.
|
def get_item(tup1,index):
item = tup1[index]
return item
|
[
"assert bell_Number(2) == 2",
"assert bell_Number(3) == 5",
"assert bell_Number(4) == 15"
] |
[] |
|
931
|
Write a function to abbreviate 'road' as 'rd.' in a given string.
|
import re
def replace(string, char):
pattern = char + '{2,}'
string = re.sub(pattern, char, string)
return string
|
[
"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"
] |
[] |
|
642
|
Write a function to find the greatest common divisor (gcd) of two integers by using recursion.
|
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 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] "
] |
[] |
|
680
|
Write a function to find numbers divisible by m and n from a list of numbers using lambda function.
|
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 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)"
] |
[] |
|
885
|
Write a python function to set the right most unset bit.
|
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 add_list([1, 2, 3],[4,5,6])==[5, 7, 9]",
"assert add_list([1,2],[3,4])==[4,6]",
"assert add_list([10,20],[50,70])==[60,90]"
] |
[] |
|
618
|
Write a function that matches a string that has an a followed by zero or more b's by using regex.
|
import heapq as hq
def heap_sort(iterable):
h = []
for value in iterable:
hq.heappush(h, value)
return [hq.heappop(h) for i in range(len(h))]
|
[
"assert check_Odd_Parity(13) == True",
"assert check_Odd_Parity(21) == True",
"assert check_Odd_Parity(18) == False"
] |
[] |
|
958
|
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.
|
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 end_num('abcdef')==False",
"assert end_num('abcdef7')==True",
"assert end_num('abc')==False"
] |
[] |
|
968
|
Write a function to find the maximum sum that can be formed which has no three consecutive elements present.
|
def left_rotate(s,d):
tmp = s[d : ] + s[0 : d]
return tmp
|
[
"assert replace_spaces('Jumanji The Jungle') == 'Jumanji_The_Jungle'",
"assert replace_spaces('The Avengers') == 'The_Avengers'",
"assert replace_spaces('Fast and Furious') == 'Fast_and_Furious'"
] |
[] |
|
732
|
Write a function to find ln, m lobb number.
|
from itertools import groupby
def extract_elements(numbers, n):
result = [i for i, j in groupby(numbers) if len(list(j)) == n]
return result
|
[
"assert subset([1, 2, 3, 4],4) == 1",
"assert subset([5, 6, 9, 3, 4, 3, 4],7) == 2",
"assert subset([1, 2, 3 ],3) == 1"
] |
[] |
|
781
|
Write a python function to find the last position of an element in a sorted array.
|
def factorial(start,end):
res = 1
for i in range(start,end + 1):
res *= i
return res
def sum_of_square(n):
return int(factorial(n + 1, 2 * n) /factorial(1, n))
|
[
"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'}"
] |
[] |
|
610
|
Write a function to calculate the discriminant value.
|
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 Convert('python program') == ['python','program']",
"assert Convert('Data Analysis') ==['Data','Analysis']",
"assert Convert('Hadoop Training') == ['Hadoop','Training']"
] |
[] |
|
843
|
Write a function to count the number of elements in a list which are within a specific range.
|
import re
def split_list(text):
return (re.findall('[A-Z][^A-Z]*', text))
|
[
"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"
] |
[] |
|
887
|
Write a function to count the elements in a list until an element is a tuple.
|
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 noprofit_noloss(1500,1200)==False",
"assert noprofit_noloss(100,100)==True",
"assert noprofit_noloss(2000,5000)==False"
] |
[] |
|
702
|
Write a function to extract all the adjacent coordinates of the given coordinate tuple.
|
def extract_unique(test_dict):
res = list(sorted({ele for val in test_dict.values() for ele in val}))
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'"
] |
[] |
|
634
|
Write a python function to find minimum possible value for the given periodic function.
|
from math import tan, pi
def perimeter_polygon(s,l):
perimeter = s*l
return perimeter
|
[
"assert match_num('5-2345861')==True",
"assert match_num('6-2345861')==False",
"assert match_num('78910')==False"
] |
[] |
|
628
|
Write a python function to find sum of all prime divisors of a given number.
|
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 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"
] |
[] |
|
937
|
Write a python function to find the smallest prime divisor of a number.
|
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 check_smaller((1, 2, 3), (2, 3, 4)) == False",
"assert check_smaller((4, 5, 6), (3, 4, 5)) == True",
"assert check_smaller((11, 12, 13), (10, 11, 12)) == True"
] |
[] |
|
704
|
Write a python function to toggle bits of the number except the first and the last bit.
|
def min_k(test_list, K):
res = sorted(test_list, key = lambda x: x[1])[:K]
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"
] |
[] |
|
775
|
Write a function to return true if the password is valid.
|
import re
def text_match_three(text):
patterns = 'ab{3}?'
if re.search(patterns, text):
return 'Found a match!'
else:
return('Not matched!')
|
[
"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]"
] |
[] |
|
646
|
Write a python function to replace multiple occurence of character by single.
|
from heapq import merge
def combine_lists(num1,num2):
combine_lists=list(merge(num1, num2))
return combine_lists
|
[
"assert No_of_cubes(2,1) == 8",
"assert No_of_cubes(5,2) == 64",
"assert No_of_cubes(1,1) == 1"
] |
[] |
|
825
|
Write a function to return true if the given number is even else return false.
|
def check_greater(test_tup1, test_tup2):
res = all(x < y for x, y in zip(test_tup1, test_tup2))
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"
] |
[] |
|
868
|
Write a function to find a pair with the highest product from a given array of integers.
|
def count_elim(num):
count_elim = 0
for n in num:
if isinstance(n, tuple):
break
count_elim += 1
return count_elim
|
[
"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]"
] |
[] |
|
972
|
Write a python function to find the sum of xor of all pairs of numbers in the given array.
|
def palindrome_lambda(texts):
result = list(filter(lambda x: (x == "".join(reversed(x))), texts))
return result
|
[
"assert string_length('python')==6",
"assert string_length('program')==7",
"assert string_length('language')==8"
] |
[] |
|
910
|
Write a python function to find sum of inverse of divisors.
|
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 remove_parenthesis([\"python (chrome)\"])==(\"python\")",
"assert remove_parenthesis([\"string(.abc)\"])==(\"string\")",
"assert remove_parenthesis([\"alpha(num)\"])==(\"alpha\")"
] |
[] |
|
904
|
Write a function to access dictionary key’s element by index.
|
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
else:
return right_height+1
|
[
"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"
] |
[] |
|
879
|
Write a python function to check whether a sequence of numbers has an increasing trend or not.
|
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 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', 'c', 'd']"
] |
[] |
|
703
|
Write a python function to find the largest triangle that can be inscribed in the semicircle.
|
def mul_consecutive_nums(nums):
result = [b*a for a, b in zip(nums[:-1], nums[1:])]
return result
|
[
"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)"
] |
[] |
|
823
|
Write a function to check if the given tuple contains all valid values or not.
|
def noprofit_noloss(actual_cost,sale_amount):
if(sale_amount == actual_cost):
return True
else:
return False
|
[
"assert lcm(4,6) == 12",
"assert lcm(15,17) == 255",
"assert lcm(2,6) == 6"
] |
[] |
|
934
|
Write a function to count unique keys for each value present in the tuple.
|
import re
def extract_date(url):
return re.findall(r'/(\d{4})/(\d{1,2})/(\d{1,2})/', url)
|
[
"assert is_odd(5) == True",
"assert is_odd(6) == False",
"assert is_odd(7) == True"
] |
[] |
|
759
|
Write a python function to find the sum of fifth power of n natural numbers.
|
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_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"
] |
[] |
|
648
|
Write a function to check if each element of the second tuple is greater than its corresponding index in the first tuple.
|
def triangle_area(r) :
if r < 0 :
return -1
return r * r
|
[
"assert check_element((4, 5, 7, 9, 3), [6, 7, 10, 11]) == True",
"assert check_element((1, 2, 3, 4), [4, 6, 7, 8, 9]) == True",
"assert check_element((3, 2, 1, 4, 5), [9, 8, 7, 6]) == False"
] |
[] |
|
748
|
Write a function to search a literals string in a string and also find the location within the original string where the pattern occurs by using regex.
|
def count_alpha_dig_spl(string):
alphabets=digits = special = 0
for i in range(len(string)):
if(string[i].isalpha()):
alphabets = alphabets + 1
elif(string[i].isdigit()):
digits = digits + 1
else:
special = special + 1
return (alphabets,digits,special)
|
[
"assert slope(4,2,2,5) == -1.5",
"assert slope(2,4,4,6) == 1",
"assert slope(1,2,4,2) == 0"
] |
[] |
|
722
|
Write a python function to find the length of the shortest word.
|
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 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)"
] |
[] |
|
892
|
Write a function to convert camel case string to snake case string.
|
def count_vowels(test_str):
res = 0
vow_list = ['a', 'e', 'i', 'o', 'u']
for idx in range(1, len(test_str) - 1):
if test_str[idx] not in vow_list and (test_str[idx - 1] in vow_list or test_str[idx + 1] in vow_list):
res += 1
if test_str[0] not in vow_list and test_str[1] in vow_list:
res += 1
if test_str[-1] not in vow_list and test_str[-2] in vow_list:
res += 1
return (res)
|
[
"assert min_Jumps(3,4,11)==3.5",
"assert min_Jumps(3,4,0)==0",
"assert min_Jumps(11,14,11)==1"
] |
[] |
|
791
|
Write a function to check if two lists of tuples are identical or not.
|
def even_position(nums):
return all(nums[i]%2==i%2 for i in range(len(nums)))
|
[
"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)"
] |
[] |
|
840
|
Write a function to locate the right insertion point for a specified value in sorted order.
|
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 tuple_to_dict((1, 5, 7, 10, 13, 5)) == {1: 5, 7: 10, 13: 5}",
"assert tuple_to_dict((1, 2, 3, 4, 5, 6)) == {1: 2, 3: 4, 5: 6}",
"assert tuple_to_dict((7, 8, 9, 10, 11, 12)) == {7: 8, 9: 10, 11: 12}"
] |
[] |
|
954
|
Write a python function to check whether the given number is odd or not using bitwise operator.
|
def lcs_of_three(X, Y, Z, m, n, o):
L = [[[0 for i in range(o+1)] for j in range(n+1)]
for k in range(m+1)]
for i in range(m+1):
for j in range(n+1):
for k in range(o+1):
if (i == 0 or j == 0 or k == 0):
L[i][j][k] = 0
elif (X[i-1] == Y[j-1] and
X[i-1] == Z[k-1]):
L[i][j][k] = L[i-1][j-1][k-1] + 1
else:
L[i][j][k] = max(max(L[i-1][j][k],
L[i][j-1][k]),
L[i][j][k-1])
return L[m][n][o]
|
[
"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"
] |
[] |
|
625
|
Write a function to check if one tuple is a subset of another tuple.
|
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 harmonic_sum(10)==2.9289682539682538",
"assert harmonic_sum(4)==2.083333333333333",
"assert harmonic_sum(7)==2.5928571428571425 "
] |
[] |
|
835
|
Write a function to find the most common elements and their counts of a specified text.
|
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 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']"
] |
[] |
|
914
|
Write a python function to find the average of a list.
|
def Average(lst):
return sum(lst) / len(lst)
|
[
"assert min_Swaps(\"0011\",\"1111\") == 1",
"assert min_Swaps(\"00011\",\"01001\") == 2",
"assert min_Swaps(\"111\",\"111\") == 0"
] |
[] |
|
884
|
Write a function to remove all whitespaces from a string.
|
def Check_Solution(a,b,c):
if b == 0:
return ("Yes")
else:
return ("No")
|
[
"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]) == [(2, 4), (5, 7), (3, 8), (6, 3)]"
] |
[] |
|
749
|
Write a function to flatten the given tuple matrix into the tuple list with each tuple representing each column.
|
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 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"
] |
[] |
|
947
|
Write a function to check whether the given amount has no profit and no loss
|
def rearrange_numbs(array_nums):
result = sorted(array_nums, key = lambda i: 0 if i == 0 else -1 / i)
return result
|
[
"assert cube_Sum(2) == 28",
"assert cube_Sum(3) == 153",
"assert cube_Sum(4) == 496"
] |
[] |
|
698
|
Write a function to find the minimum number of platforms required for a railway/bus station.
|
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 result;
elif ((c0 + c1) % 2 == 0) :
return result + 2;
else :
return -1;
|
[
"assert sum_Of_Primes(10) == 17",
"assert sum_Of_Primes(20) == 77",
"assert sum_Of_Primes(5) == 10"
] |
[] |
|
604
|
Write a python function to check whether an array can be sorted or not by picking only the corner elements.
|
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 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 "
] |
[] |
|
686
|
Write a function to convert the given string of integers into a tuple.
|
def reverse_list_lists(lists):
for l in lists:
l.sort(reverse = True)
return lists
|
[
"assert substract_elements(((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))) == ((-5, -4), (1, -4), (1, 8), (-6, 7))",
"assert substract_elements(((13, 4), (14, 6), (13, 10), (12, 11)), ((19, 8), (14, 10), (12, 2), (18, 4))) == ((-6, -4), (0, -4), (1, 8), (-6, 7))",
"assert substract_elements(((19, 5), (18, 7), (19, 11), (17, 12)), ((12, 9), (17, 11), (13, 3), (19, 5))) == ((7, -4), (1, -4), (6, 8), (-2, 7))"
] |
[] |
|
712
|
Write a function to find number of even elements in the given list using lambda function.
|
def test_three_equal(x,y,z):
result= set([x,y,z])
if len(result)==3:
return 0
else:
return (4-len(result))
|
[
"assert is_triangleexists(50,60,70)==True",
"assert is_triangleexists(90,45,45)==True",
"assert is_triangleexists(150,30,70)==False"
] |
[] |
|
706
|
Write a function to find minimum k records from tuple 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 check_Concat(\"abcabcabc\",\"abc\") == True",
"assert check_Concat(\"abcab\",\"abc\") == False",
"assert check_Concat(\"aba\",\"ab\") == False"
] |
[] |
|
907
|
Write a python function to find the slope of a line.
|
import heapq
def nth_super_ugly_number(n, primes):
uglies = [1]
def gen(prime):
for ugly in uglies:
yield ugly * prime
merged = heapq.merge(*map(gen, primes))
while len(uglies) < n:
ugly = next(merged)
if ugly != uglies[-1]:
uglies.append(ugly)
return uglies[-1]
|
[
"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"
] |
[] |
|
842
|
Write a function to remove duplicate words from a given string using collections module.
|
import heapq as hq
def raw_heap(rawheap):
hq.heapify(rawheap)
return rawheap
|
[
"assert is_Product_Even([1,2,3],3) == True",
"assert is_Product_Even([1,2,1,4],4) == True",
"assert is_Product_Even([1,1],2) == False"
] |
[] |
|
836
|
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 zip_list([[1, 3], [5, 7], [9, 11]] ,[[2, 4], [6, 8], [10, 12, 14]] )==[[1, 3, 2, 4], [5, 7, 6, 8], [9, 11, 10, 12, 14]]",
"assert zip_list([[1, 2], [3, 4], [5, 6]] ,[[7, 8], [9, 10], [11, 12]] )==[[1, 2, 7, 8], [3, 4, 9, 10], [5, 6, 11, 12]]",
"assert zip_list([['a','b'],['c','d']] , [['e','f'],['g','h']] )==[['a','b','e','f'],['c','d','g','h']]"
] |
[] |
|
832
|
Write a function to find the perimeter of a rectangle.
|
def average_tuple(nums):
result = [sum(x) / len(x) for x in zip(*nums)]
return result
|
[
"assert number_ctr('program2bedone') == 1",
"assert number_ctr('3wonders') ==1",
"assert number_ctr('123') == 3"
] |
[] |
|
895
|
Write a function to find length of the string.
|
from collections import Counter
def anagram_lambda(texts,str):
result = list(filter(lambda x: (Counter(str) == Counter(x)), texts))
return result
|
[
"assert sum_Even(2,5) == 6",
"assert sum_Even(3,8) == 18",
"assert sum_Even(4,6) == 10"
] |
[] |
|
720
|
Write a function to check whether the given string is ending with only alphanumeric characters or not using regex.
|
def arc_length(d,a):
pi=22/7
if a >= 360:
return None
arclength = (pi*d) * (a/360)
return arclength
|
[
"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"
] |
[] |
|
951
|
Write a python function to find number of solutions in quadratic equation.
|
def word_len(s):
s = s.split(' ')
for word in s:
if len(word)%2==0:
return True
else:
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}'"
] |
[] |
|
637
|
Write a function to locate the left insertion point for a specified value in sorted order.
|
def rectangle_perimeter(l,b):
perimeter=2*(l+b)
return perimeter
|
[
"assert reverse_Array_Upto_K([1, 2, 3, 4, 5, 6],4) == [4, 3, 2, 1, 5, 6]",
"assert reverse_Array_Upto_K([4, 5, 6, 7], 2) == [5, 4, 6, 7]",
"assert reverse_Array_Upto_K([9, 8, 7, 6, 5],3) == [7, 8, 9, 6, 5]"
] |
[] |
|
620
|
Write a function to move all the numbers in it to the given string.
|
import re
def capital_words_spaces(str1):
return re.sub(r"(\w)([A-Z])", r"\1 \2", str1)
|
[
"assert power_base_sum(2,100)==115",
"assert power_base_sum(8,10)==37",
"assert power_base_sum(8,15)==62"
] |
[] |
|
638
|
Write a function to count the pairs of reverse strings in the given string list.
|
def check_Even_Parity(x):
parity = 0
while (x != 0):
x = x & (x - 1)
parity += 1
if (parity % 2 == 0):
return True
else:
return False
|
[
"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]"
] |
[] |
|
902
|
Write a python function to check for odd parity of a given number.
|
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 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)"
] |
[] |
|
952
|
Write a python function to count occurences of a character in a repeated string.
|
def is_upper(string):
return (string.upper())
|
[
"assert floor_Min(10,20,30) == 15",
"assert floor_Min(1,2,1) == 0",
"assert floor_Min(11,10,9) == 9"
] |
[] |
|
630
|
Write a function to zip two given lists of lists.
|
def rotate_right(list1,m,n):
result = list1[-(m):]+list1[:-(n)]
return result
|
[
"assert div_of_nums([19, 65, 57, 39, 152, 639, 121, 44, 90, 190],19,13)==[19, 65, 57, 39, 152, 190]",
"assert div_of_nums([1, 2, 3, 5, 7, 8, 10],2,5)==[2, 5, 8, 10]",
"assert div_of_nums([10,15,14,13,18,12,20],10,5)==[10, 15, 20]"
] |
[] |
|
898
|
Write a function to find the nth nonagonal number.
|
def access_elements(nums, list_index):
result = [nums[i] for i in list_index]
return result
|
[
"assert capital_words_spaces(\"Python\") == 'Python'",
"assert capital_words_spaces(\"PythonProgrammingExamples\") == 'Python Programming Examples'",
"assert capital_words_spaces(\"GetReadyToBeCodingFreak\") == 'Get Ready To Be Coding Freak'"
] |
[] |
|
855
|
Write a function to calculate the geometric sum of n-1.
|
import re
def remove_multiple_spaces(text1):
return (re.sub(' +',' ',text1))
|
[
"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"
] |
[] |
|
880
|
Write a function to check if the given expression is balanced or not.
|
def Odd_Length_Sum(arr):
Sum = 0
l = len(arr)
for i in range(l):
Sum += ((((i + 1) *(l - i) + 1) // 2) * arr[i])
return Sum
|
[
"assert len_complex(3,4)==5.0",
"assert len_complex(9,10)==13.45362404707371",
"assert len_complex(7,9)==11.40175425099138"
] |
[] |
|
794
|
Write a function to compute the value of ncr mod p.
|
def unique_Element(arr,n):
s = set(arr)
if (len(s) == 1):
return ('YES')
else:
return ('NO')
|
[
"assert sum_of_odd_Factors(30) == 24",
"assert sum_of_odd_Factors(18) == 13",
"assert sum_of_odd_Factors(2) == 1"
] |
[] |
|
656
|
Write a function to find the item with maximum occurrences in a given list.
|
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 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, 18, 17, 16, 15, 14, 13]]"
] |
[] |
|
778
|
Write a python function to check whether every even index contains even numbers of a given list.
|
import re
def occurance_substring(text,pattern):
for match in re.finditer(pattern, text):
s = match.start()
e = match.end()
return (text[s:e], s, e)
|
[
"assert sort_tuple([(\"Amana\", 28), (\"Zenat\", 30), (\"Abhishek\", 29),(\"Nikhil\", 21), (\"B\", \"C\")]) == [('Abhishek', 29), ('Amana', 28), ('B', 'C'), ('Nikhil', 21), ('Zenat', 30)]",
"assert sort_tuple([(\"aaaa\", 28), (\"aa\", 30), (\"bab\", 29), (\"bb\", 21), (\"csa\", \"C\")]) == [('aa', 30), ('aaaa', 28), ('bab', 29), ('bb', 21), ('csa', 'C')]",
"assert sort_tuple([(\"Sarala\", 28), (\"Ayesha\", 30), (\"Suman\", 29),(\"Sai\", 21), (\"G\", \"H\")]) == [('Ayesha', 30), ('G', 'H'), ('Sai', 21), ('Sarala', 28), ('Suman', 29)]"
] |
[] |
|
852
|
Write a python function to find sum of prime numbers between 1 to n.
|
def validity_triangle(a,b,c):
total = a + b + c
if total == 180:
return True
else:
return False
|
[
"assert check_str(\"annie\") == 'Valid'",
"assert check_str(\"dawood\") == 'Invalid'",
"assert check_str(\"Else\") == 'Valid'"
] |
[] |
|
930
|
Write a function to get an item of a tuple.
|
def maximum_value(test_list):
res = [(key, max(lst)) for key, lst in test_list]
return (res)
|
[
"assert rectangle_perimeter(10,20)==60",
"assert rectangle_perimeter(10,5)==30",
"assert rectangle_perimeter(4,2)==12"
] |
[] |
|
912
|
Write a function to find numbers divisible by m or n from a list of numbers using lambda function.
|
def Sum(N):
SumOfPrimeDivisors = [0]*(N + 1)
for i in range(2,N + 1) :
if (SumOfPrimeDivisors[i] == 0) :
for j in range(i,N + 1,i) :
SumOfPrimeDivisors[j] += i
return SumOfPrimeDivisors[N]
|
[
"assert second_frequent(['aaa','bbb','ccc','bbb','aaa','aaa']) == 'bbb'",
"assert second_frequent(['abc','bcd','abc','bcd','bcd','bcd']) == 'abc'",
"assert second_frequent(['cdma','gsm','hspa','gsm','cdma','cdma']) == 'gsm'"
] |
[] |
|
849
|
Write a python function to get the position of rightmost set bit.
|
def rombus_perimeter(a):
perimeter=4*a
return perimeter
|
[
"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"
] |
[] |
|
959
|
Write a python function to move all zeroes to the end of the given list.
|
def check(string):
if len(set(string).intersection("AEIOUaeiou"))>=5:
return ('accepted')
else:
return ("not accepted")
|
[
"assert grouping_dictionary([('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)])== ({'yellow': [1, 3], 'blue': [2, 4], 'red': [1]})",
"assert grouping_dictionary([('yellow', 10), ('blue', 20), ('yellow', 30), ('blue', 40), ('red', 10)])== ({'yellow': [10, 30], 'blue': [20, 40], 'red': [10]})",
"assert grouping_dictionary([('yellow', 15), ('blue', 25), ('yellow', 35), ('blue', 45), ('red', 15)])== ({'yellow': [15, 35], 'blue': [25, 45], 'red': [15]})"
] |
[] |
|
949
|
Write a function to merge two dictionaries into a single expression.
|
def remove_spaces(str1):
str1 = str1.replace(' ','')
return str1
|
[
"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\" : 4, \"Okay\" : 5} ) == (8, 9, 10, {'POS': 3, 'is': 4, 'Okay': 5})"
] |
[] |
|
779
|
Write a function to check if each element of second tuple is smaller than its corresponding index in first tuple.
|
import re
def change_date_format(dt):
return re.sub(r'(\d{4})-(\d{1,2})-(\d{1,2})', '\\3-\\2-\\1', dt)
return change_date_format(dt)
|
[
"assert 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"
] |
[] |
|
774
|
Write a function to count number of lists in a given list of lists and square the count.
|
from operator import eq
def count_same_pair(nums1, nums2):
result = sum(map(eq, nums1, nums2))
return result
|
[
"assert remove_char(\"123abcjw:, .@! eiw\") == '123abcjweiw'",
"assert remove_char(\"Hello1234:, ! Howare33u\") == 'Hello1234Howare33u'",
"assert remove_char(\"Cool543Triks@:, Make@987Trips\") == 'Cool543TriksMake987Trips' "
] |
[] |
|
946
|
Write a function to check whether the given month number contains 28 days or not.
|
def check_tuples(test_tuple, K):
res = all(ele in K for ele in test_tuple)
return (res)
|
[
"assert remove_even([1,3,5,2]) == [1,3,5]",
"assert remove_even([5,6,7]) == [5,7]",
"assert remove_even([1,2,3,4]) == [1,3]"
] |
[] |
|
935
|
Write a function to remove everything except alphanumeric characters from the given string by using regex.
|
def listify_list(list1):
result = list(map(list,list1))
return result
|
[
"assert int(lobb_num(5, 3)) == 35",
"assert int(lobb_num(3, 2)) == 5",
"assert int(lobb_num(4, 2)) == 20"
] |
[] |
|
607
|
Write a function to count the number of inversions in the given array.
|
def area_trapezium(base1,base2,height):
area = 0.5 * (base1 + base2) * height
return area
|
[
"assert sort_String(\"cba\") == \"abc\"",
"assert sort_String(\"data\") == \"aadt\"",
"assert sort_String(\"zxy\") == \"xyz\""
] |
[] |
|
876
|
Write a function to calculate the perimeter of a regular polygon.
|
import re
regex = '[a-zA-z0-9]$'
def check_alphanumeric(string):
if(re.search(regex, string)):
return ("Accept")
else:
return ("Discard")
|
[
"assert jacobsthal_num(5) == 11",
"assert jacobsthal_num(2) == 1",
"assert jacobsthal_num(4) == 5"
] |
[] |
|
743
|
Write a function to find a path with the maximum average over all existing paths for the given square matrix of size n*n.
|
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 left_Rotate(16,2) == 64",
"assert left_Rotate(10,2) == 40",
"assert left_Rotate(99,3) == 792"
] |
[] |
|
963
|
Write a python function to multiply all items in the list.
|
import math
def sum_series(number):
total = 0
total = math.pow((number * (number + 1)) /2, 2)
return total
|
[
"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\"]"
] |
[] |
|
674
|
Write a python function to check whether every odd index contains odd numbers of a given list.
|
def first_repeated_char(str1):
for index,c in enumerate(str1):
if str1[:index+1].count(c) > 1:
return c
return "None"
|
[
"assert get_noOfways(4)==3",
"assert get_noOfways(3)==2",
"assert get_noOfways(5)==5"
] |
[] |
|
841
|
Write a function to check if a triangle of positive area is possible with the given angles.
|
import re
def extract_quotation(text1):
return (re.findall(r'"(.*?)"', text1))
|
[
"assert max_run_uppercase('GeMKSForGERksISBESt') == 5",
"assert max_run_uppercase('PrECIOusMOVemENTSYT') == 6",
"assert max_run_uppercase('GooGLEFluTTER') == 4"
] |
[] |
|
668
|
Write a function to find minimum of two numbers.
|
from collections import Counter
def most_common_elem(s,a):
most_common_elem=Counter(s).most_common(a)
return most_common_elem
|
[
"assert Check_Solution(2,5,2) == \"2 solutions\"",
"assert Check_Solution(1,1,1) == \"No solutions\"",
"assert Check_Solution(1,2,1) == \"1 solution\""
] |
[] |
|
617
|
Write a function that gives profit amount if the given amount has profit else return none.
|
def even_num(x):
if x%2==0:
return True
else:
return False
|
[
"assert decreasing_trend([-4,-3,-2,-1]) == True",
"assert decreasing_trend([1,2,3]) == True",
"assert decreasing_trend([3,2,1]) == False"
] |
[] |
|
665
|
Write a function to group the 1st elements on the basis of 2nd elements in the given tuple list.
|
def check_monthnumb(monthname2):
if(monthname2=="January" or monthname2=="March"or monthname2=="May" or monthname2=="July" or monthname2=="Augest" or monthname2=="October" or monthname2=="December"):
return True
else:
return False
|
[
"assert are_Rotations(\"abc\",\"cba\") == False",
"assert are_Rotations(\"abcd\",\"cdba\") == False",
"assert are_Rotations(\"abacd\",\"cdaba\") == True"
] |
[] |
|
861
|
Write a function to replace whitespaces with an underscore and vice versa in a given string by using regex.
|
def multiply_list(items):
tot = 1
for x in items:
tot *= x
return tot
|
[
"assert arc_length(9,45)==3.5357142857142856",
"assert arc_length(9,480)==None",
"assert arc_length(5,270)==11.785714285714285"
] |
[] |
|
810
|
Write a function to count number of unique lists within a list.
|
import math
def lateralsurface_cone(r,h):
l = math.sqrt(r * r + h * h)
LSA = math.pi * r * l
return LSA
|
[
"assert return_sum({'a': 100, 'b':200, 'c':300}) == 600",
"assert return_sum({'a': 25, 'b':18, 'c':45}) == 88",
"assert return_sum({'a': 36, 'b':39, 'c':49}) == 124"
] |
[] |
|
867
|
Write a function to find the length of the longest sub-sequence such that elements in the subsequences are consecutive integers.
|
def zip_list(list1,list2):
result = list(map(list.__add__, list1, list2))
return result
|
[
"assert is_polite(7) == 11",
"assert is_polite(4) == 7",
"assert is_polite(9) == 13"
] |
[] |
|
636
|
Write a python function to calculate the product of all the numbers of a given tuple.
|
def add_list(nums1,nums2):
result = map(lambda x, y: x + y, nums1, nums2)
return list(result)
|
[
"assert camel_to_snake('GoogleAssistant') == 'google_assistant'",
"assert camel_to_snake('ChromeCast') == 'chrome_cast'",
"assert camel_to_snake('QuadCore') == 'quad_core'"
] |
[] |
|
782
|
Write a function to create a new tuple from the given string and list.
|
def string_length(str1):
count = 0
for char in str1:
count += 1
return count
|
[
"assert n_common_words(\"python is a programming language\",1)==[('python', 1)]",
"assert n_common_words(\"python is a programming language\",1)==[('python', 1)]",
"assert n_common_words(\"python is a programming language\",5)==[('python', 1),('is', 1), ('a', 1), ('programming', 1), ('language', 1)]"
] |
[] |
End of preview. Expand
in Data Studio
edition_2018_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
- 9