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
|
|---|---|---|---|---|---|
672
|
Write a function to find out the second most repeated (or frequent) string in the given sequence.
|
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 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)"
] |
[] |
|
753
|
Write a python function to convert the given string to upper case.
|
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 remove_spaces(\"a b c\") == \"abc\"",
"assert remove_spaces(\"1 2 3\") == \"123\"",
"assert remove_spaces(\" b c\") == \"bc\""
] |
[] |
|
899
|
Write a function to find the nth delannoy number.
|
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 is_Two_Alter(\"abab\") == True",
"assert is_Two_Alter(\"aaaa\") == False",
"assert is_Two_Alter(\"xyz\") == False"
] |
[] |
|
952
|
Write a function to substract the elements of the given nested tuples.
|
def string_length(str1):
count = 0
for char in str1:
count += 1
return count
|
[
"assert slope(4,2,2,5) == -1.5",
"assert slope(2,4,4,6) == 1",
"assert slope(1,2,4,2) == 0"
] |
[] |
|
815
|
Write a function to find the area of a trapezium.
|
def even_num(x):
if x%2==0:
return True
else:
return False
|
[
"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"
] |
[] |
|
680
|
Write a function to count number of lists in a given list of lists and square the count.
|
def count_Char(str,x):
count = 0
for i in range(len(str)):
if (str[i] == x) :
count += 1
n = 10
repititions = n // len(str)
count = count * repititions
l = n % len(str)
for i in range(l):
if (str[i] == x):
count += 1
return count
|
[
"assert remove_all_spaces('python program')==('pythonprogram')",
"assert remove_all_spaces('python programming language')==('pythonprogramminglanguage')",
"assert remove_all_spaces('python program')==('pythonprogram')"
] |
[] |
|
758
|
Write a function to remove all tuples with all none values in the given tuple list.
|
def palindrome_lambda(texts):
result = list(filter(lambda x: (x == "".join(reversed(x))), texts))
return 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\" : 4, \"Okay\" : 5} ) == (8, 9, 10, {'POS': 3, 'is': 4, 'Okay': 5})"
] |
[] |
|
666
|
Write a function to remove the parenthesis area in a string.
|
def second_smallest(numbers):
if (len(numbers)<2):
return
if ((len(numbers)==2) and (numbers[0] == numbers[1]) ):
return
dup_items = set()
uniq_items = []
for x in numbers:
if x not in dup_items:
uniq_items.append(x)
dup_items.add(x)
uniq_items.sort()
return uniq_items[1]
|
[
"assert (max_height(root)) == 3",
"assert (max_height(root1)) == 5 ",
"assert (max_height(root2)) == 4"
] |
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)
|
[] |
809
|
Write a function to perfom the modulo of tuple elements in the given two tuples.
|
def check_subset(list1,list2):
return all(map(list1.__contains__,list2))
|
[
"assert get_Pairs_Count([1,1,1,1],4,2) == 6",
"assert get_Pairs_Count([1,5,7,-1,5],5,6) == 3",
"assert get_Pairs_Count([1,-2,3],3,1) == 1"
] |
[] |
|
652
|
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.
|
from collections import OrderedDict
def remove_duplicate(string):
result = ' '.join(OrderedDict((w,w) for w in string.split()).keys())
return result
|
[
"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')]"
] |
[] |
|
827
|
Write a python function to remove negative numbers from a list.
|
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 is_polite(7) == 11",
"assert is_polite(4) == 7",
"assert is_polite(9) == 13"
] |
[] |
|
972
|
Write a function to check if the triangle is valid or not.
|
def pair_OR_Sum(arr,n) :
ans = 0
for i in range(0,n) :
for j in range(i + 1,n) :
ans = ans + (arr[i] ^ arr[j])
return ans
|
[
"assert is_nonagonal(10) == 325",
"assert is_nonagonal(15) == 750",
"assert is_nonagonal(18) == 1089"
] |
[] |
|
762
|
Write a function to round up a number to specific digits.
|
import math
def find_Index(n):
x = math.sqrt(2 * math.pow(10,(n - 1)));
return round(x);
|
[
"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"
] |
[] |
|
760
|
Write a function to remove an empty tuple from a list of tuples.
|
def rearrange_numbs(array_nums):
result = sorted(array_nums, key = lambda i: 0 if i == 0 else -1 / i)
return result
|
[
"assert sum_nums(2,10,11,20)==20",
"assert sum_nums(15,17,1,10)==32",
"assert sum_nums(10,15,5,30)==20"
] |
[] |
|
628
|
Write a python function to copy a list from a singleton tuple.
|
import bisect
def right_insertion(a, x):
i = bisect.bisect_right(a, x)
return i
|
[
"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]"
] |
[] |
|
916
|
Write a function to find the frequency of each element in the given list.
|
import math
def count_Divisors(n) :
count = 0
for i in range(1, (int)(math.sqrt(n)) + 2) :
if (n % i == 0) :
if( n // i == i) :
count = count + 1
else :
count = count + 2
if (count % 2 == 0) :
return ("Even")
else :
return ("Odd")
|
[
"assert int_to_roman(1)==(\"I\")",
"assert int_to_roman(50)==(\"L\")",
"assert int_to_roman(4)==(\"IV\")"
] |
[] |
|
784
|
Write a function to find the largest subset where each pair is divisible.
|
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 previous_palindrome(99)==88",
"assert previous_palindrome(1221)==1111",
"assert previous_palindrome(120)==111"
] |
[] |
|
777
|
Write a function to find the second smallest number in a list.
|
def Split(list):
ev_li = []
for i in list:
if (i % 2 == 0):
ev_li.append(i)
return ev_li
|
[
"assert find_Digits(7) == 4",
"assert find_Digits(5) == 3",
"assert find_Digits(4) == 2"
] |
[] |
|
661
|
Write a function to extract all the adjacent coordinates of the given coordinate tuple.
|
def last(n):
return n[-1]
def sort_list_last(tuples):
return sorted(tuples, key=last)
|
[
"assert sum_Of_Primes(10) == 17",
"assert sum_Of_Primes(20) == 77",
"assert sum_Of_Primes(5) == 10"
] |
[] |
|
835
|
Write a function to convert camel case string to snake case string by using regex.
|
def mul_consecutive_nums(nums):
result = [b*a for a, b in zip(nums[:-1], nums[1:])]
return result
|
[
"assert count_Divisors(10) == \"Even\"",
"assert count_Divisors(100) == \"Odd\"",
"assert count_Divisors(125) == \"Even\""
] |
[] |
|
616
|
Write a function to check a decimal with a precision of 2.
|
def find_first_occurrence(A, x):
(left, right) = (0, len(A) - 1)
result = -1
while left <= right:
mid = (left + right) // 2
if x == A[mid]:
result = mid
right = mid - 1
elif x < A[mid]:
right = mid - 1
else:
left = mid + 1
return result
|
[
"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"
] |
[] |
|
922
|
Write a python function to remove the k'th element from a given list.
|
def Diff(li1,li2):
return (list(list(set(li1)-set(li2)) + list(set(li2)-set(li1))))
|
[
"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 "
] |
[] |
|
837
|
Write a function to find the minimum total path sum in the given triangle.
|
def sort_by_dnf(arr, n):
low=0
mid=0
high=n-1
while mid <= high:
if arr[mid] == 0:
arr[low], arr[mid] = arr[mid], arr[low]
low = low + 1
mid = mid + 1
elif arr[mid] == 1:
mid = mid + 1
else:
arr[mid], arr[high] = arr[high], arr[mid]
high = high - 1
return arr
|
[
"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,'d':900})==({'b': 1800, 'd': 1800, 'a': 1800})"
] |
[] |
|
913
|
Write a function to access the initial and last data of the given tuple record.
|
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 get_noOfways(4)==3",
"assert get_noOfways(3)==2",
"assert get_noOfways(5)==5"
] |
[] |
|
939
|
Write a function to caluclate arc length of an angle.
|
def max_similar_indices(test_list1, test_list2):
res = [(max(x[0], y[0]), max(x[1], y[1]))
for x, y in zip(test_list1, test_list2)]
return (res)
|
[
"assert check_str(\"annie\") == 'Valid'",
"assert check_str(\"dawood\") == 'Invalid'",
"assert check_str(\"Else\") == 'Valid'"
] |
[] |
|
606
|
Write a function to find average value of the numbers in a given tuple of tuples.
|
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 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]"
] |
[] |
|
964
|
Write a function to find the maximum value in record list as tuple attribute in the given tuple list.
|
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 rectangle_perimeter(10,20)==60",
"assert rectangle_perimeter(10,5)==30",
"assert rectangle_perimeter(4,2)==12"
] |
[] |
|
789
|
Write a python function to count the number of digits in factorial of a given number.
|
def find_platform(arr, dep, n):
arr.sort()
dep.sort()
plat_needed = 1
result = 1
i = 1
j = 0
while (i < n and j < n):
if (arr[i] <= dep[j]):
plat_needed+= 1
i+= 1
elif (arr[i] > dep[j]):
plat_needed-= 1
j+= 1
if (plat_needed > result):
result = plat_needed
return result
|
[
"assert Check_Solution(2,5,2) == \"2 solutions\"",
"assert Check_Solution(1,1,1) == \"No solutions\"",
"assert Check_Solution(1,2,1) == \"1 solution\""
] |
[] |
|
708
|
Write a function to find length of the subarray having maximum sum.
|
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 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'"
] |
[] |
|
954
|
Write a function to create a list taking alternate elements from another given 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 word_len(\"program\") == False",
"assert word_len(\"solution\") == True",
"assert word_len(\"data\") == True"
] |
[] |
|
908
|
Write a function to check for the number of jumps required of given length to reach a point of form (d, 0) from origin in a 2d plane.
|
import re
def remove_spaces(text):
return (re.sub(' +',' ',text))
|
[
"assert Sum(60) == 10",
"assert Sum(39) == 16",
"assert Sum(40) == 7"
] |
[] |
|
830
|
Write a function to convert the given tuple to a key-value dictionary using adjacent elements.
|
import math
def find_Digits(n):
if (n < 0):
return 0;
if (n <= 1):
return 1;
x = ((n * math.log10(n / math.e) + math.log10(2 * math.pi * n) /2.0));
return math.floor(x) + 1;
|
[
"assert convert([1,2,3]) == 123",
"assert convert([4,5,6]) == 456",
"assert convert([7,8,9]) == 789"
] |
[] |
|
751
|
Write a python function to find the kth element in an array containing odd elements first and then even elements.
|
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 check_valid((True, True, True, True) ) == True",
"assert check_valid((True, False, True, True) ) == False",
"assert check_valid((True, True, True, True) ) == True"
] |
[] |
|
668
|
Write a python function to replace multiple occurence of character by single.
|
def check_tuples(test_tuple, K):
res = all(ele in K for ele in test_tuple)
return (res)
|
[
"assert last_Two_Digits(7) == 40",
"assert last_Two_Digits(5) == 20",
"assert last_Two_Digits(2) == 2"
] |
[] |
|
622
|
Write a function to find the lateral surface area of a cone.
|
def subset(ar, n):
res = 0
ar.sort()
for i in range(0, n) :
count = 1
for i in range(n - 1):
if ar[i] == ar[i + 1]:
count+=1
else:
break
res = max(res, count)
return res
|
[
"assert 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"
] |
[] |
|
775
|
Write a python function to check whether every even index contains even numbers of a given list.
|
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 are_Equal([1,2,3],[3,2,1],3,3) == True",
"assert are_Equal([1,1,1],[2,2,2],3,3) == False",
"assert are_Equal([8,9],[4,5,6],2,3) == False"
] |
[] |
|
951
|
Write a function to put spaces between words starting with capital letters in a given string by using regex.
|
def first_odd(nums):
first_odd = next((el for el in nums if el%2!=0),-1)
return first_odd
|
[
"assert is_triangleexists(50,60,70)==True",
"assert is_triangleexists(90,45,45)==True",
"assert is_triangleexists(150,30,70)==False"
] |
[] |
|
941
|
Write a python function to find maximum possible value for the given periodic function.
|
import math
def get_First_Set_Bit_Pos(n):
return math.log2(n&-n)+1
|
[
"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"
] |
[] |
|
691
|
Write a function to find the maximum of similar indices in two lists of tuples.
|
def is_key_present(d,x):
if x in d:
return True
else:
return False
|
[
"assert camel_to_snake('PythonProgram')==('python_program')",
"assert camel_to_snake('pythonLanguage')==('python_language')",
"assert camel_to_snake('ProgrammingLanguage')==('programming_language')"
] |
[] |
|
731
|
Write a function to check if a nested list is a subset of another nested list.
|
def check_none(test_tup):
res = any(map(lambda ele: ele is None, test_tup))
return (res)
|
[
"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)]"
] |
[] |
|
821
|
Write a function to check if the given string starts with a substring using regex.
|
def swap_List(newList):
size = len(newList)
temp = newList[0]
newList[0] = newList[size - 1]
newList[size - 1] = temp
return newList
|
[
"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"
] |
[] |
|
722
|
Write a function to join the tuples if they have similar initial elements.
|
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 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"
] |
[] |
|
960
|
Write a python function to find the slope of a line.
|
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 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']"
] |
[] |
|
791
|
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 lcm(4,6) == 12",
"assert lcm(15,17) == 255",
"assert lcm(2,6) == 6"
] |
[] |
|
867
|
Write a python function to find the last two digits in factorial of a given number.
|
def arc_length(d,a):
pi=22/7
if a >= 360:
return None
arclength = (pi*d) * (a/360)
return arclength
|
[
"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!')"
] |
[] |
|
763
|
Write a function to remove multiple spaces in a string by using regex.
|
def parallelogram_perimeter(b,h):
perimeter=2*(b*h)
return perimeter
|
[
"assert sector_area(4,45)==6.285714285714286",
"assert sector_area(9,45)==31.82142857142857",
"assert sector_area(9,360)==None"
] |
[] |
|
605
|
Write a function to find the length of the longest sub-sequence such that elements in the subsequences are consecutive integers.
|
import re
def remove_all_spaces(text):
return (re.sub(r'\s+', '',text))
|
[
"assert remove_spaces('python program')==('python program')",
"assert remove_spaces('python programming language')==('python programming language')",
"assert remove_spaces('python program')==('python program')"
] |
[] |
|
662
|
Write a function to find if there is a triplet in the array whose sum is equal to a given value.
|
import re
def text_match_zero_one(text):
patterns = 'ab?'
if re.search(patterns, text):
return 'Found a match!'
else:
return('Not matched!')
|
[
"assert left_Rotate(16,2) == 64",
"assert left_Rotate(10,2) == 40",
"assert left_Rotate(99,3) == 792"
] |
[] |
|
857
|
Write a function to divide two lists using map and lambda function.
|
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 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]"
] |
[] |
|
682
|
Write a function that matches a string that has an 'a' followed by anything, ending in 'b' by using regex.
|
def nCr_mod_p(n, r, p):
if (r > n- r):
r = n - r
C = [0 for i in range(r + 1)]
C[0] = 1
for i in range(1, n + 1):
for j in range(min(i, r), 0, -1):
C[j] = (C[j] + C[j-1]) % p
return C[r]
|
[
"assert text_match(\"ac\")==('Found a match!')",
"assert text_match(\"dc\")==('Not matched!')",
"assert text_match(\"abba\")==('Found a match!')"
] |
[] |
|
714
|
Write a function to find the number which occurs for odd number of times in the given array.
|
def convert(list):
s = [str(i) for i in list]
res = int("".join(s))
return (res)
|
[
"assert change_date_format('2026-01-02')=='02-01-2026'",
"assert change_date_format('2021-01-04')=='04-01-2021'",
"assert change_date_format('2030-06-06')=='06-06-2030'"
] |
[] |
|
969
|
Write a function to multiply the adjacent elements of the given tuple.
|
import re
regex = '[a-zA-z0-9]$'
def check_alphanumeric(string):
if(re.search(regex, string)):
return ("Accept")
else:
return ("Discard")
|
[
"assert bell_Number(2) == 2",
"assert bell_Number(3) == 5",
"assert bell_Number(4) == 15"
] |
[] |
|
726
|
Write a function to find the nth jacobsthal number.
|
from operator import eq
def count_same_pair(nums1, nums2):
result = sum(map(eq, nums1, nums2))
return result
|
[
"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 "
] |
[] |
|
854
|
Write a function to find the length of the shortest string that has both str1 and str2 as subsequences.
|
def max_sum_list(lists):
return max(lists, key=sum)
|
[
"assert Sum_of_Inverse_Divisors(6,12) == 2",
"assert Sum_of_Inverse_Divisors(9,13) == 1.44",
"assert Sum_of_Inverse_Divisors(1,4) == 4"
] |
[] |
|
709
|
Write a function to validate a gregorian date.
|
def clear_tuple(test_tup):
temp = list(test_tup)
temp.clear()
test_tup = tuple(temp)
return (test_tup)
|
[
"assert first_odd([1,3,5]) == 1",
"assert first_odd([2,4,1,3]) == 1",
"assert first_odd ([8,9,1]) == 9"
] |
[] |
|
973
|
Write a function to count the most common character in a given string.
|
def rectangle_perimeter(l,b):
perimeter=2*(l+b)
return perimeter
|
[
"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]"
] |
[] |
|
624
|
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.
|
import cmath
def len_complex(a,b):
cn=complex(a,b)
length=abs(cn)
return length
|
[
"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"
] |
[] |
|
738
|
Write a function to count number of unique lists within a list.
|
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 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"
] |
[] |
|
695
|
Write a function to convert rgb color to hsv color.
|
import math
def radian_degree(degree):
radian = degree*(math.pi/180)
return radian
|
[
"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"
] |
[] |
|
920
|
Write a python function to count equal element pairs from the given array.
|
def remove_even(l):
for i in l:
if i % 2 == 0:
l.remove(i)
return l
|
[
"assert check_email(\"[email protected]\") == 'Valid Email'",
"assert check_email(\"[email protected]\") == 'Valid Email'",
"assert check_email(\"ankitaoie326.com\") == 'Invalid Email'"
] |
[] |
|
946
|
Write a function to display sign of the chinese zodiac for given year.
|
import re
def replace(string, char):
pattern = char + '{2,}'
string = re.sub(pattern, char, string)
return string
|
[
"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)]) == [(12, 15), (11, 9), (12, 18), (15, 12), (16, 21), (15, 15)]"
] |
[] |
|
955
|
Write a function to convert degrees to radians.
|
import re
def num_position(text):
for m in re.finditer("\d+", text):
return m.start()
|
[
"assert maximum_segments(7, 5, 2, 5) == 2",
"assert maximum_segments(17, 2, 1, 3) == 17",
"assert maximum_segments(18, 16, 3, 6) == 6"
] |
[] |
|
794
|
Write a function to find three closest elements from three sorted arrays.
|
def first_repeated_char(str1):
for index,c in enumerate(str1):
if str1[:index+1].count(c) > 1:
return c
return "None"
|
[
"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] "
] |
[] |
|
893
|
Write a function to find the list in a list of lists whose sum of elements is the highest.
|
def check(arr,n):
g = 0
for i in range(1,n):
if (arr[i] - arr[i - 1] > 0 and g == 1):
return False
if (arr[i] - arr[i] < 0):
g = 1
return True
|
[
"assert even_num(13.5)==False",
"assert even_num(0)==True",
"assert even_num(-9)==False"
] |
[] |
|
971
|
Write a function that gives profit amount if the given amount has profit else return none.
|
def profit_amount(actual_cost,sale_amount):
if(actual_cost > sale_amount):
amount = actual_cost - sale_amount
return amount
else:
return None
|
[
"assert merge([['x', 'y'], ['a', 'b'], ['m', 'n']]) == [['x', 'a', 'm'], ['y', 'b', 'n']]",
"assert merge([[1, 2], [3, 4], [5, 6], [7, 8]]) == [[1, 3, 5, 7], [2, 4, 6, 8]]",
"assert merge([['x', 'y','z' ], ['a', 'b','c'], ['m', 'n','o']]) == [['x', 'a', 'm'], ['y', 'b', 'n'],['z', 'c','o']]"
] |
[] |
|
845
|
Write a python function to count the number of equal numbers from three given integers.
|
def extract_unique(test_dict):
res = list(sorted({ele for val in test_dict.values() for ele in val}))
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"
] |
[] |
|
886
|
Write a function to locate the left insertion point for a specified value in sorted order.
|
def tuple_to_set(t):
s = set(t)
return (s)
|
[
"assert count_range_in_list([10,20,30,40,40,40,70,80,99],40,100)==6",
"assert count_range_in_list(['a','b','c','d','e','f'],'a','e')==5",
"assert count_range_in_list([7,8,9,15,17,19,45],15,20)==3"
] |
[] |
|
641
|
Write a function to reverse words in a given string.
|
def generate_matrix(n):
if n<=0:
return []
matrix=[row[:] for row in [[0]*n]*n]
row_st=0
row_ed=n-1
col_st=0
col_ed=n-1
current=1
while (True):
if current>n*n:
break
for c in range (col_st, col_ed+1):
matrix[row_st][c]=current
current+=1
row_st+=1
for r in range (row_st, row_ed+1):
matrix[r][col_ed]=current
current+=1
col_ed-=1
for c in range (col_ed, col_st-1, -1):
matrix[row_ed][c]=current
current+=1
row_ed-=1
for r in range (row_ed, row_st-1, -1):
matrix[r][col_st]=current
current+=1
col_st+=1
return matrix
|
[
"assert count_Fac(24) == 3",
"assert count_Fac(12) == 2",
"assert count_Fac(4) == 1"
] |
[] |
|
779
|
## 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 min_Num(arr,n):
odd = 0
for i in range(n):
if (arr[i] % 2):
odd += 1
if (odd % 2):
return 1
return 2
|
[
"assert str_to_tuple(\"1, -5, 4, 6, 7\") == (1, -5, 4, 6, 7)",
"assert str_to_tuple(\"1, 2, 3, 4, 5\") == (1, 2, 3, 4, 5)",
"assert str_to_tuple(\"4, 6, 9, 11, 13, 14\") == (4, 6, 9, 11, 13, 14)"
] |
[] |
|
795
|
Write a python function to find the sum of non-repeated elements in a given array.
|
def reverse_list_lists(lists):
for l in lists:
l.sort(reverse = True)
return lists
|
[
"assert min_Swaps(\"1101\",\"1110\") == 1",
"assert min_Swaps(\"1111\",\"0100\") == \"Not Possible\"",
"assert min_Swaps(\"1110000\",\"0001101\") == 3"
] |
[] |
|
692
|
Write a python function to find the average of even numbers till a given even number.
|
from math import tan, pi
def perimeter_polygon(s,l):
perimeter = s*l
return perimeter
|
[
"assert add_tuple([5, 6, 7], (9, 10)) == [5, 6, 7, 9, 10]",
"assert add_tuple([6, 7, 8], (10, 11)) == [6, 7, 8, 10, 11]",
"assert add_tuple([7, 8, 9], (11, 12)) == [7, 8, 9, 11, 12]"
] |
[] |
|
861
|
Write a function where a string will start with a specific number.
|
def int_to_roman( num):
val = [1000, 900, 500, 400,100, 90, 50, 40,10, 9, 5, 4,1]
syb = ["M", "CM", "D", "CD","C", "XC", "L", "XL","X", "IX", "V", "IV","I"]
roman_num = ''
i = 0
while num > 0:
for _ in range(num // val[i]):
roman_num += syb[i]
num -= val[i]
i += 1
return roman_num
|
[
"assert noprofit_noloss(1500,1200)==False",
"assert noprofit_noloss(100,100)==True",
"assert noprofit_noloss(2000,5000)==False"
] |
[] |
|
812
|
Write a python function to find the smallest missing number from the given array.
|
import sys
def find_closet(A, B, C, p, q, r):
diff = sys.maxsize
res_i = 0
res_j = 0
res_k = 0
i = 0
j = 0
k = 0
while(i < p and j < q and k < r):
minimum = min(A[i], min(B[j], C[k]))
maximum = max(A[i], max(B[j], C[k]));
if maximum-minimum < diff:
res_i = i
res_j = j
res_k = k
diff = maximum - minimum;
if diff == 0:
break
if A[i] == minimum:
i = i+1
elif B[j] == minimum:
j = j+1
else:
k = k+1
return A[res_i],B[res_j],C[res_k]
|
[
"assert cube_Sum(2) == 28",
"assert cube_Sum(3) == 153",
"assert cube_Sum(4) == 496"
] |
[] |
|
623
|
Write a python function to find the first repeated character in a given string.
|
import math
def round_up(a, digits):
n = 10**-digits
return round(math.ceil(a / n) * n, digits)
|
[
"assert find_triplet_array([1, 4, 45, 6, 10, 8], 6, 22) == (4, 10, 8)",
"assert find_triplet_array([12, 3, 5, 2, 6, 9], 6, 24) == (12, 3, 9)",
"assert find_triplet_array([1, 2, 3, 4, 5], 5, 9) == (1, 3, 5)"
] |
[] |
|
660
|
Write a python function to find the sum of fifth power of n natural numbers.
|
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 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']]"
] |
[] |
|
654
|
Write a python function to find sum of inverse of divisors.
|
from collections import defaultdict
def grouping_dictionary(l):
d = defaultdict(list)
for k, v in l:
d[k].append(v)
return d
|
[
"assert remove_length('The person is most value tet', 3) == 'person is most value'",
"assert remove_length('If you told me about this ok', 4) == 'If you me about ok'",
"assert remove_length('Forces of darkeness is come into the play', 4) == 'Forces of darkeness is the'"
] |
[] |
|
609
|
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 multiply_elements((1, 5, 7, 8, 10)) == (5, 35, 56, 80)",
"assert multiply_elements((2, 4, 5, 6, 7)) == (8, 20, 30, 42)",
"assert multiply_elements((12, 13, 14, 9, 15)) == (156, 182, 126, 135)"
] |
[] |
|
776
|
Write a function to check whether the given ip address is valid or not using regex.
|
def sort_String(str) :
str = ''.join(sorted(str))
return (str)
|
[
"assert count_duplic([1,2,2,2,4,4,4,5,5,5,5])==([1, 2, 4, 5], [1, 3, 3, 4])",
"assert count_duplic([2,2,3,1,2,6,7,9])==([2, 3, 1, 2, 6, 7, 9], [2, 1, 1, 1, 1, 1, 1])",
"assert count_duplic([2,1,5,6,8,3,4,9,10,11,8,12])==([2, 1, 5, 6, 8, 3, 4, 9, 10, 11, 8, 12], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])"
] |
[] |
|
839
|
Write a function to find the occurrence and position of the substrings within a string.
|
def max_sum_of_three_consecutive(arr, n):
sum = [0 for k in range(n)]
if n >= 1:
sum[0] = arr[0]
if n >= 2:
sum[1] = arr[0] + arr[1]
if n > 2:
sum[2] = max(sum[1], max(arr[1] + arr[2], arr[0] + arr[2]))
for i in range(3, n):
sum[i] = max(max(sum[i-1], sum[i-2] + arr[i]), arr[i] + arr[i-1] + sum[i-3])
return sum[n-1]
|
[
"assert get_ludic(10) == [1, 2, 3, 5, 7]",
"assert get_ludic(25) == [1, 2, 3, 5, 7, 11, 13, 17, 23, 25]",
"assert get_ludic(45) == [1, 2, 3, 5, 7, 11, 13, 17, 23, 25, 29, 37, 41, 43]"
] |
[] |
|
849
|
Write a function to sort a given list of strings of numbers numerically.
|
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 is_Isomorphic(\"paper\",\"title\") == True",
"assert is_Isomorphic(\"ab\",\"ba\") == True",
"assert is_Isomorphic(\"ab\",\"aa\") == False"
] |
[] |
|
882
|
Write a function to sort a list in a dictionary.
|
def reverse_words(s):
return ' '.join(reversed(s.split()))
|
[
"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"
] |
[] |
|
764
|
Write a function to calculate the sum of all digits of the base to the specified power.
|
import heapq as hq
def raw_heap(rawheap):
hq.heapify(rawheap)
return rawheap
|
[
"assert recur_gcd(12,14) == 2",
"assert recur_gcd(13,17) == 1",
"assert recur_gcd(9, 3) == 3"
] |
[] |
|
810
|
Write a function to find the cumulative sum of all the values that are present in the given tuple list.
|
def remove_spaces(str1):
str1 = str1.replace(' ','')
return str1
|
[
"assert get_inv_count([1, 20, 6, 4, 5], 5) == 5",
"assert get_inv_count([8, 4, 2, 1], 4) == 6",
"assert get_inv_count([3, 1, 2], 3) == 2"
] |
[] |
|
840
|
Write a function to replace all occurrences of spaces, commas, or dots with a colon.
|
def smallest_multiple(n):
if (n<=2):
return n
i = n * 2
factors = [number for number in range(n, 1, -1) if number * 2 > n]
while True:
for a in factors:
if i % a != 0:
i += n
break
if (a == factors[-1] and i % a == 0):
return i
|
[
"assert pair_wise([1,1,2,3,3,4,4,5])==[(1, 1), (1, 2), (2, 3), (3, 3), (3, 4), (4, 4), (4, 5)]",
"assert pair_wise([1,5,7,9,10])==[(1, 5), (5, 7), (7, 9), (9, 10)]",
"assert pair_wise([1,2,3,4,5,6,7,8,9,10])==[(1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), (8, 9), (9, 10)]"
] |
[] |
|
601
|
Write a function to check if the given integer is a prime number.
|
import re
def replace_specialchar(text):
return (re.sub("[ ,.]", ":", text))
|
[
"assert sum_Range_list([2, 1, 5, 6, 8, 3, 4, 9, 10, 11, 8, 12],8,10) == 29",
"assert sum_Range_list([1,2,3,4,5],1,2) == 5",
"assert sum_Range_list([1,0,1,2,5,6],4,5) == 11"
] |
[] |
|
961
|
Write a function to count the number of elements in a list which are within a specific range.
|
def merge(lst):
return [list(ele) for ele in list(zip(*lst))]
|
[
"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"
] |
[] |
|
891
|
Write a function to find the area of a rombus.
|
import math
import sys
def sd_calc(data):
n = len(data)
if n <= 1:
return 0.0
mean, sd = avg_calc(data), 0.0
for el in data:
sd += (float(el) - mean)**2
sd = math.sqrt(sd / float(n-1))
return sd
def avg_calc(ls):
n, mean = len(ls), 0.0
if n <= 1:
return ls[0]
for el in ls:
mean = mean + float(el)
mean = mean / float(n)
return mean
|
[
"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]"
] |
[] |
|
906
|
Write a python function to set the right most unset bit.
|
def sort_dict_item(test_dict):
res = {key: test_dict[key] for key in sorted(test_dict.keys(), key = lambda ele: ele[1] * ele[0])}
return (res)
|
[
"assert max_sum_list([[1,2,3], [4,5,6], [10,11,12], [7,8,9]])==[10, 11, 12] ",
"assert max_sum_list([[3,2,1], [6,5,4], [12,11,10]])==[12,11,10] ",
"assert max_sum_list([[2,3,1]])==[2,3,1] "
] |
[] |
|
870
|
Write a python function to merge the first and last elements separately in a list of lists.
|
def sample_nam(sample_names):
sample_names=list(filter(lambda el:el[0].isupper() and el[1:].islower(),sample_names))
return len(''.join(sample_names))
|
[
"assert smallest_Divisor(10) == 2",
"assert smallest_Divisor(25) == 5",
"assert smallest_Divisor(31) == 31"
] |
[] |
|
645
|
Write a python function to find the minimun number of subsets with distinct elements.
|
def area_trapezium(base1,base2,height):
area = 0.5 * (base1 + base2) * height
return area
|
[
"assert text_uppercase_lowercase(\"AaBbGg\")==('Found a match!')",
"assert text_uppercase_lowercase(\"aA\")==('Not matched!')",
"assert text_uppercase_lowercase(\"PYTHON\")==('Not matched!')"
] |
[] |
|
846
|
Write a function to find palindromes in a given list of strings using lambda function.
|
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 find_Sum([1,2,3,1,1,4,5,6],8) == 21",
"assert find_Sum([1,10,9,4,2,10,10,45,4],9) == 71",
"assert find_Sum([12,10,9,45,2,10,10,45,10],9) == 78"
] |
[] |
|
687
|
Write a function to caluclate the area of a tetrahedron.
|
def float_to_tuple(test_str):
res = tuple(map(float, test_str.split(', ')))
return (res)
|
[
"assert access_key({'physics': 80, 'math': 90, 'chemistry': 86},0)== 'physics'",
"assert access_key({'python':10, 'java': 20, 'C++':30},2)== 'C++'",
"assert access_key({'program':15,'computer':45},1)== 'computer'"
] |
[] |
|
752
|
Write a python function to check whether a sequence of numbers has an increasing trend or not.
|
def odd_position(nums):
return all(nums[i]%2==i%2 for i in range(len(nums)))
|
[
"assert series_sum(6)==91",
"assert series_sum(7)==140",
"assert series_sum(12)==650"
] |
[] |
|
956
|
Write a function to compute the value of ncr mod p.
|
def mul_list(nums1,nums2):
result = map(lambda x, y: x * y, nums1, nums2)
return list(result)
|
[
"assert fibonacci(7) == 13",
"assert fibonacci(8) == 21",
"assert fibonacci(9) == 34"
] |
[] |
|
614
|
Write a function to check if each element of second tuple is smaller than its corresponding index in first tuple.
|
def find_fixed_point(arr, n):
for i in range(n):
if arr[i] is i:
return i
return -1
|
[
"assert string_length('python')==6",
"assert string_length('program')==7",
"assert string_length('language')==8"
] |
[] |
|
959
|
Write a python function to find the last position of an element in a sorted array.
|
import re
def split_upperstring(text):
return (re.findall('[A-Z][^A-Z]*', text))
|
[
"assert sort_String(\"cba\") == \"abc\"",
"assert sort_String(\"data\") == \"aadt\"",
"assert sort_String(\"zxy\") == \"xyz\""
] |
[] |
|
713
|
Write a function to add a dictionary to the tuple.
|
def cummulative_sum(test_list):
res = sum(map(sum, test_list))
return (res)
|
[
"assert remove_duplic_list([\"Python\", \"Exercises\", \"Practice\", \"Solution\", \"Exercises\"])==['Python', 'Exercises', 'Practice', 'Solution']",
"assert remove_duplic_list([\"Python\", \"Exercises\", \"Practice\", \"Solution\", \"Exercises\",\"Java\"])==['Python', 'Exercises', 'Practice', 'Solution', 'Java']",
"assert remove_duplic_list([\"Python\", \"Exercises\", \"Practice\", \"Solution\", \"Exercises\",\"C++\",\"C\",\"C++\"])==['Python', 'Exercises', 'Practice', 'Solution','C++','C']"
] |
[] |
|
811
|
Write a function to find the product of first even and odd number of a given list.
|
def remove_empty(tuple1): #L = [(), (), ('',), ('a', 'b'), ('a', 'b', 'c'), ('d')]
tuple1 = [t for t in tuple1 if t]
return tuple1
|
[
"assert _sum([1, 2, 3]) == 6",
"assert _sum([15, 12, 13, 10]) == 50",
"assert _sum([0, 1, 2]) == 3"
] |
[] |
|
632
|
Write a python function to remove even numbers from a given list.
|
from collections import Counter
def count_variable(a,b,c,d):
c = Counter(p=a, q=b, r=c, s=d)
return list(c.elements())
|
[
"assert sorted_dict({'n1': [2, 3, 1], 'n2': [5, 1, 2], 'n3': [3, 2, 4]})=={'n1': [1, 2, 3], 'n2': [1, 2, 5], 'n3': [2, 3, 4]}",
"assert sorted_dict({'n1': [25,37,41], 'n2': [41,54,63], 'n3': [29,38,93]})=={'n1': [25, 37, 41], 'n2': [41, 54, 63], 'n3': [29, 38, 93]}",
"assert sorted_dict({'n1': [58,44,56], 'n2': [91,34,58], 'n3': [100,200,300]})=={'n1': [44, 56, 58], 'n2': [34, 58, 91], 'n3': [100, 200, 300]}"
] |
[] |
|
851
|
Write a function to find the fixed point in the given array.
|
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 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\",\"HTML\"]])==[['DBMS'], ['python'], ['SQL', 'HTML'], ['java', 'C', 'C++']]"
] |
[] |
End of preview. Expand
in Data Studio
edition_2949_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