Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to find the first repeated character in a given string.

Tests:
assert first_repeated_char("abcabc") == "a"
assert first_repeated_char("abc") == None
assert first_repeated_char("123123") == "1"

def first_repeated_char(str1):
  for index,c in enumerate(str1):
    if str1[:index+1].count(c) > 1:
      return c


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to get all lucid numbers smaller than or equal to a given integer.

Tests:
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]

def get_ludic(n):
	ludics = []
	for i in range(1, n + 1):
		ludics.append(i)
	index = 1
	while(index != len(ludics)):
		first_ludic = ludics[index]
		remove_index = index + first_ludic
		while(remove_index < len(ludics)):
			ludics.remove(ludics[remove_index])
			remove_index = remove_index + first_ludic - 1
		index += 1
	return ludics


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to reverse words seperated by spaces in a given string.

Tests:
assert reverse_words("python program")==("program python")
assert reverse_words("java language")==("language java")
assert reverse_words("indian man")==("man indian")

def reverse_words(s):
        return ' '.join(reversed(s.split()))


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to check if the given integer is a prime number.

Tests:
assert prime_num(13)==True
assert prime_num(7)==True
assert prime_num(-1010)==False

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


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to convert degrees to radians.

Tests:
assert radian_degree(90)==1.5707963267948966
assert radian_degree(60)==1.0471975511965976
assert radian_degree(120)==2.0943951023931953

import math
def radian_degree(degree):
 radian = degree*(math.pi/180)
 return radian


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to search a string for a regex pattern. The function should return the matching subtring, a start index and an end index.

Tests:
assert find_literals('The quick brown fox jumps over the lazy dog.', 'fox') == ('fox', 16, 19)
assert find_literals('Its been a very crazy procedure right', 'crazy') == ('crazy', 16, 21)
assert find_literals('Hardest choices required strongest will', 'will') == ('will', 35, 39)

import re

def find_literals(text, pattern):
  match = re.search(pattern, text)
  s = match.start()
  e = match.end()
  return (match.re.pattern, s, e)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to find nth bell number.

Tests:
assert bell_Number(2) == 2
assert bell_Number(3) == 5
assert bell_Number(4) == 15

def bell_Number(n):
    bell = [[0 for i in range(n+1)] for j in range(n+1)]
    bell[0][0] = 1
    for i in range(1, n+1):
        bell[i][0] = bell[i-1][i-1]
        for j in range(1, i+1):
            bell[i][j] = bell[i-1][j-1] + bell[i][j-1]
    return bell[n][0]


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function which takes a list and returns a list with the same elements, but the k'th element removed.

Tests:
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, 17, 18, 10]

def remove_kth_element(list1, L):
    return  list1[:L-1] + list1[L:]


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function which given a matrix represented as a list of lists returns the max of the n'th column.

Tests:
assert max_of_nth([[5, 6, 7], [1, 3, 5], [8, 9, 19]], 2) == 19
assert max_of_nth([[6, 7, 8], [2, 4, 6], [9, 10, 20]], 1) == 10
assert max_of_nth([[7, 8, 9], [3, 5, 7], [10, 11, 21]], 1) == 11

def max_of_nth(test_list, N):
  res = max([sub[N] for sub in test_list])
  return (res)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function which takes a list of lists, where each sublist has two elements, and returns a list of two lists where the first list has the first element of each sublist and the second one has the second.

Tests:
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']]

def merge(lst):
    return [list(ele) for ele in list(zip(*lst))]


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find the cumulative sum of all the values that are present in the given tuple list.

Tests:
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

def cummulative_sum(test_list):
  res = sum(map(sum, test_list))
  return (res)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function which takes a tuple of tuples and returns the average value for each tuple as a list.

Tests:
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, 320), (10, 20, 30, 40)))==[305.0, 342.5, 270.0, 232.5]

def average_tuple(nums):
    result = [sum(x) / len(x) for x in zip(*nums)]
    return result


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function which takes two tuples of the same length and performs the element wise modulo.

Tests:
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)

def tuple_modulo(test_tup1, test_tup2):
  res = tuple(ele1 % ele2 for ele1, ele2 in zip(test_tup1, test_tup2))
  return (res)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
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.

Tests:
assert min_Jumps((3,4),11)==3.5
assert min_Jumps((3,4),0)==0
assert min_Jumps((11,14),11)==1

def min_Jumps(steps, d):
    (a, b) = steps
    temp = a
    a = min(a, b)
    b = max(temp, b)
    if (d >= b):
        return (d + b - 1) / b
    if (d == 0):
        return 0
    if (d == a):
        return 1
    else:
        return 2


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to divide two lists element wise.

Tests:
assert div_list([4,5,6],[1, 2, 3])==[4.0,2.5,2.0]
assert div_list([3,2],[1,4])==[3.0, 0.5]
assert div_list([90,120],[50,70])==[1.8, 1.7142857142857142]

def div_list(nums1,nums2):
  result = map(lambda x, y: x / y, nums1, nums2)
  return list(result)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to move all the numbers to the end of the given string.

Tests:
assert move_num('I1love143you55three3000thousand') == 'Iloveyouthreethousand1143553000'
assert move_num('Avengers124Assemble') == 'AvengersAssemble124'
assert move_num('Its11our12path13to14see15things16do17things') == 'Itsourpathtoseethingsdothings11121314151617'

def move_num(test_str):
  res = ''
  dig = ''
  for ele in test_str:
    if ele.isdigit():
      dig += ele
    else:
      res += ele
  res += dig
  return (res)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find the size of the largest subset of a list of numbers so that every pair is divisible.

Tests:
assert largest_subset([ 1, 3, 6, 13, 17, 18 ]) == 4
assert largest_subset([10, 5, 3, 15, 20]) == 3
assert largest_subset([18, 1, 3, 6, 13, 17]) == 4

def largest_subset(a):
	n = len(a)
	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)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find the median of two sorted lists of same size.

Tests:
assert get_median([1, 12, 15, 26, 38], [2, 13, 17, 30, 45], 5) == 16.0
assert get_median([2, 4, 8, 9], [7, 13, 19, 28], 4) == 8.5
assert get_median([3, 6, 14, 23, 36, 42], [2, 18, 27, 39, 49, 55], 6) == 25.0

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


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to compute the n-th power of each number in a list.

Tests:
assert nth_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],2)==[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
assert nth_nums([10,20,30],3)==([1000, 8000, 27000])
assert nth_nums([12,15],5)==([248832, 759375])

def nth_nums(nums,n):
 nth_nums = list(map(lambda x: x ** n, nums))
 return nth_nums


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to convert a given string to uppercase.

Tests:
assert is_upper("person") =="PERSON"
assert is_upper("final") == "FINAL"
assert is_upper("Valid") == "VALID"

def is_upper(string):
  return (string.upper())


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to interchange the first and last element in a given list.

Tests:
assert swap_List([1,2,3]) == [3,2,1]
assert swap_List([1,2,3,4,4]) == [4,2,3,4,1]
assert swap_List([4,5,6]) == [6,5,4]

def swap_List(newList):
    size = len(newList)
    temp = newList[0]
    newList[0] = newList[size - 1]
    newList[size - 1] = temp
    return newList


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to find the area of the largest triangle that can be inscribed in a semicircle with a given radius.

Tests:
assert triangle_area(-1) == None
assert triangle_area(0) == 0
assert triangle_area(2) == 4

def triangle_area(r) :
    if r < 0 :
        return None
    return r * r


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to find the smallest missing number from a sorted list of natural numbers.

Tests:
assert find_First_Missing([0,1,2,3]) == 4
assert find_First_Missing([0,1,2,6,9]) == 3
assert find_First_Missing([2,3,5,8,9]) == 0

def find_First_Missing(array,start=0,end=None):
    if end is None:
      end = len(array) - 1
    if (start > end):
        return end + 1
    if (start != array[start]):
        return start;
    mid = int((start + end) / 2)
    if (array[mid] == mid):
        return find_First_Missing(array,mid+1,end)
    return find_First_Missing(array,start,mid)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to replace all spaces in the given string with '%20'.

Tests:
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'

def replace_spaces(string):
  return string.replace(" ", "%20")


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to find even numbers from a list of numbers.

Tests:
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]

def Split(list):
    return [num for num in list if num % 2 == 0]


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to extract all the adjacent coordinates of the given coordinate tuple.

Tests:
assert get_coordinates((3, 4)) == [[2, 3], [2, 4], [2, 5], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5]]
assert get_coordinates((4, 5)) ==[[3, 4], [3, 5], [3, 6], [4, 4], [4, 5], [4, 6], [5, 4], [5, 5], [5, 6]]
assert get_coordinates((5, 6)) == [[4, 5], [4, 6], [4, 7], [5, 5], [5, 6], [5, 7], [6, 5], [6, 6], [6, 7]]

def adjac(ele, sub = []):
  if not ele:
     yield sub
  else:
     yield from [idx for j in range(ele[0] - 1, ele[0] + 2)
                for idx in adjac(ele[1:], sub + [j])]
def get_coordinates(test_tup):
  return list(adjac(test_tup))


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to replace whitespaces with an underscore and vice versa in a given string.

Tests:
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'

def replace_spaces(text):
  return "".join(" " if c == "_" else ("_" if c == " " else c) for c in text)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to move all zeroes to the end of the given list.

Tests:
assert move_zero([1,0,2,0,3,4]) == [1,2,3,4,0,0]
assert move_zero([2,3,2,0,0,4,0,5,0]) == [2,3,2,4,5,0,0,0,0]
assert move_zero([0,1,0,1,1]) == [1,1,1,0,0]

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]
    return x + a


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to find the sum of xor of all pairs of numbers in the given list.

Tests:
assert pair_xor_Sum([5,9,7,6],4) == 47
assert pair_xor_Sum([7,3,5],3) == 12
assert pair_xor_Sum([7,3],2) == 4

def pair_xor_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


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to sort the given list.

Tests:
assert heap_sort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
assert heap_sort([25, 35, 22, 85, 14, 65, 75, 25, 58])==[14, 22, 25, 25, 35, 58, 65, 75, 85]
assert heap_sort( [7, 1, 9, 5])==[1,5,7,9]

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))]


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to check whether the given amount has no profit and no loss

Tests:
assert noprofit_noloss(1500,1200)==False
assert noprofit_noloss(100,100)==True
assert noprofit_noloss(2000,5000)==False

def noprofit_noloss(actual_cost,sale_amount):
  if(sale_amount == actual_cost):
    return True
  else:
    return False


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to calculate the wind chill index rounded to the next integer given the wind velocity in km/h and a temperature in celsius.

Tests:
assert wind_chill(120,35)==40
assert wind_chill(40,20)==19
assert wind_chill(10,8)==6

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))


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
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.

Tests:
assert sample_nam(['sally', 'Dylan', 'rebecca', 'Diana', 'Joanne', 'keith'])==16
assert sample_nam(["php", "res", "Python", "abcd", "Java", "aaa"])==10
assert sample_nam(["abcd", "Python", "abba", "aba"])==6

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))


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to remove the parenthesis and what is inbetween them from a string.

Tests:
assert remove_parenthesis(["python (chrome)"])==("python")
assert remove_parenthesis(["string(.abc)"])==("string")
assert remove_parenthesis(["alpha(num)"])==("alpha")

import re
def remove_parenthesis(items):
 for item in items:
    return (re.sub(r" ?\([^)]+\)", "", item))


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find the nth nonagonal number.

Tests:
assert is_nonagonal(10) == 325
assert is_nonagonal(15) == 750
assert is_nonagonal(18) == 1089

def is_nonagonal(n):
	return int(n * (7 * n - 5) / 2)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function that checks if a strings contains 'z', except at the start and end of the word.

Tests:
assert text_match_wordz_middle("pythonzabc.")==True
assert text_match_wordz_middle("zxyabc.")==False
assert text_match_wordz_middle("  lang  .")==False

import re
def text_match_wordz_middle(text):
        return bool(re.search(r'\Bz\B',  text))


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to reverse an array upto a given position.

Tests:
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]

def reverse_Array_Upto_K(input, k):
  return (input[k-1::-1] + input[k:])


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to add a dictionary to the tuple. The output should be a tuple.

Tests:
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})

def add_dict_to_tuple(test_tup, test_dict):
  test_tup = list(test_tup)
  test_tup.append(test_dict)
  test_tup = tuple(test_tup)
  return (test_tup)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Given a square matrix of size N*N given as a list of lists, where each cell is associated with a specific cost. A path is defined as a specific sequence of cells that starts from the top-left cell move only right or down and ends on bottom right cell. We want to find a path with the maximum average over all existing paths. Average is computed as total cost divided by the number of cells visited in the path.

Tests:
assert maxAverageOfPath([[1, 2, 3], [6, 5, 4], [7, 3, 9]]) == 5.2
assert maxAverageOfPath([[2, 3, 4], [7, 6, 5], [8, 4, 10]]) == 6.2
assert maxAverageOfPath([[3, 4, 5], [8, 7, 6], [9, 5, 11]]) == 7.2
assert maxAverageOfPath([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 5.8

def maxAverageOfPath(cost):
  N = len(cost)
  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)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
The input is given as - a dictionary with a student name as a key and a tuple of float (student_height, student_weight) as a value, - minimal height, - minimal weight. Write a function to filter students that have height and weight above the minimum.

Tests:
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 Vega': (6.2, 70),'Kierra Gentry': (6.0, 68)}
assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},5.7,64)=={'Cierra Vega': (6.2, 70),'Alden Cantrell': (5.9, 65),'Kierra Gentry': (6.0, 68),'Pierre Cox': (5.8, 66)}

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


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
The input is defined as two lists of the same length. Write a function to count indices where the lists have the same values.

Tests:
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
assert count_same_pair([0, 1, 1, 2],[0, 1, 2, 2])==3

from operator import eq
def count_same_pair(nums1, nums2):
    result = sum(map(eq, nums1, nums2))
    return result


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function that takes base and power as arguments and calculate the sum of all digits of the base to the specified power.

Tests:
assert power_base_sum(2,100)==115
assert power_base_sum(8,10)==37
assert power_base_sum(8,15)==62
assert power_base_sum(3,3)==9

def power_base_sum(base, power):
    return sum([int(i) for i in str(pow(base, power))])


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to extract values between quotation marks " " of the given string.

Tests:
assert extract_quotation('Cortex "A53" Based "multi" tasking "Processor"') == ['A53', 'multi', 'Processor']
assert extract_quotation('Cast your "favorite" entertainment "apps"') == ['favorite', 'apps']
assert extract_quotation('Watch content "4k Ultra HD" resolution with "HDR 10" Support') == ['4k Ultra HD', 'HDR 10']
assert extract_quotation("Watch content '4k Ultra HD' resolution with 'HDR 10' Support") == []

import re
def extract_quotation(text1):
  return (re.findall(r'"(.*?)"', text1))


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function that takes as input a tuple of numbers (t_1,...,t_{N+1}) and returns a tuple of length N where the i-th element of the tuple is equal to t_i * t_{i+1}.

Tests:
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)
assert multiply_elements((12,)) == ()

def multiply_elements(test_tup):
  res = tuple(i * j for i, j in zip(test_tup, test_tup[1:]))
  return (res)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function takes as input two lists [a_1,...,a_n], [b_1,...,b_n] and returns [a_1+b_1,...,a_n+b_n].

Tests:
assert sum_list([10,20,30],[15,25,35])==[25,45,65]
assert sum_list([1,2,3],[5,6,7])==[6,8,10]
assert sum_list([15,20,30],[15,45,75])==[30,65,105]

def sum_list(lst1,lst2):
  res_list = [lst1[i] + lst2[i] for i in range(len(lst1))]
  return res_list


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to remove consecutive duplicates of a given list.

Tests:
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']
assert consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd', 'a', 'a'])==['a', 'b', 'c', 'd', 'a']

from itertools import groupby
def consecutive_duplicates(nums):
    return [key for key, group in groupby(nums)]


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find the lateral surface area of a cone given radius r and the height h.

Tests:
assert lateralsurface_cone(5,12)==204.20352248333654
assert lateralsurface_cone(10,15)==566.3586699569488
assert lateralsurface_cone(19,17)==1521.8090132193388

import math
def lateralsurface_cone(r,h):
  l = math.sqrt(r * r + h * h)
  LSA = math.pi * r  * l
  return LSA


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to replace all occurrences of spaces, commas, or dots with a colon.

Tests:
assert replace_specialchar('Python language, Programming language.')==('Python:language::Programming:language:')
assert replace_specialchar('a b c,d e f')==('a:b:c:d:e:f')
assert replace_specialchar('ram reshma,ram rahim')==('ram:reshma:ram:rahim')

import re
def replace_specialchar(text):
 return (re.sub("[ ,.]", ":", text))


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find the index of the first occurrence of a given number in a sorted array.

Tests:
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

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


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to find sum of products of all possible sublists of a given list. https://www.geeksforgeeks.org/sum-of-products-of-all-possible-subarrays/

Tests:
assert sum_Of_Subarray_Prod([1,2,3]) == 20
assert sum_Of_Subarray_Prod([1,2]) == 5
assert sum_Of_Subarray_Prod([1,2,3,4]) == 84

def sum_Of_Subarray_Prod(arr):
    ans = 0
    res = 0
    i = len(arr) - 1
    while (i >= 0):
        incr = arr[i]*(1 + res)
        ans += incr
        res = incr
        i -= 1
    return (ans)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to toggle bits of the number except the first and the last bit. https://www.geeksforgeeks.org/toggle-bits-number-expect-first-last-bits/

Tests:
assert toggle_middle_bits(9) == 15
assert toggle_middle_bits(10) == 12
assert toggle_middle_bits(11) == 13
assert toggle_middle_bits(0b1000001) == 0b1111111
assert toggle_middle_bits(0b1001101) == 0b1110011

def set_middle_bits(n):
    n |= n >> 1;
    n |= n >> 2;
    n |= n >> 4;
    n |= n >> 8;
    n |= n >> 16;
    return (n >> 1) ^ 1
def toggle_middle_bits(n):
    if (n == 1):
        return 1
    return n ^ set_middle_bits(n)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to locate the left insertion point for a specified value in sorted order. https://www.w3resource.com/python-exercises/data-structures-and-algorithms/python-data-structure-exercise-24.php

Tests:
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

import bisect
def left_insertion(a, x):
    i = bisect.bisect_left(a, x)
    return i


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to check whether the given string is starting with a vowel or not using regex.

Tests:
assert check_str("annie")
assert not check_str("dawood")
assert check_str("Else")

import re
regex = '^[aeiouAEIOU][A-Za-z0-9_]*'
def check_str(string):
	return re.search(regex, string)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to calculate the geometric sum of n-1. https://www.w3resource.com/python-exercises/data-structures-and-algorithms/python-recursion-exercise-9.php

Tests:
assert geometric_sum(7) == 1.9921875
assert geometric_sum(4) == 1.9375
assert geometric_sum(8) == 1.99609375

def geometric_sum(n):
  if n < 0:
    return 0
  else:
    return 1 / (pow(2, n)) + geometric_sum(n - 1)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to find the index of smallest triangular number with n digits. https://www.geeksforgeeks.org/index-of-smallest-triangular-number-with-n-digits/

Tests:
assert find_Index(2) == 4
assert find_Index(3) == 14
assert find_Index(4) == 45

import math
def find_Index(n):
    x = math.sqrt(2 * math.pow(10,(n - 1)))
    return round(x)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to convert the given tuple to a key-value dictionary using adjacent elements. https://www.geeksforgeeks.org/python-convert-tuple-to-adjacent-pair-dictionary/

Tests:
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}

def tuple_to_dict(test_tup):
  res = dict(test_tup[idx : idx + 2] for idx in range(0, len(test_tup), 2))
  return (res)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to check whether all the characters are same or not.

Tests:
assert all_Characters_Same("python") == False
assert all_Characters_Same("aaa") == True
assert all_Characters_Same("data") == False

def all_Characters_Same(s) :
    n = len(s)
    for i in range(1,n) :
        if s[i] != s[0] :
            return False
    return True


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to caluclate the area of a tetrahedron.

Tests:
assert area_tetrahedron(3)==15.588457268119894
assert area_tetrahedron(20)==692.8203230275509
assert area_tetrahedron(10)==173.20508075688772

import math
def area_tetrahedron(side):
  area = math.sqrt(3)*(side*side)
  return area


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to rotate a given list by specified number of items to the right direction. https://www.geeksforgeeks.org/python-program-right-rotate-list-n/

Tests:
assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],3)==[8, 9, 10, 1, 2, 3, 4, 5, 6, 7]
assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],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)==[6, 7, 8, 9, 10, 1, 2, 3, 4, 5]

def rotate_right(list, m):
  result =  list[-m:] + list[:-m]
  return result


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to check if the given tuple has any none value or not.

Tests:
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

def check_none(test_tup):
  res = any(map(lambda ele: ele is None, test_tup))
  return res


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find numbers within a given range from startnum ti endnum where every number is divisible by every digit it contains. https://www.w3resource.com/python-exercises/lambda/python-lambda-exercise-24.php

Tests:
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]

def divisible_by_digits(startnum, endnum):
    return [n for n in range(startnum, endnum+1) \
                if not any(map(lambda x: int(x) == 0 or n%int(x) != 0, str(n)))]


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find area of a sector. The function takes the radius and angle as inputs. Function should return None if the angle is larger than 360 degrees.

Tests:
assert sector_area(4,45)==6.283185307179586
assert sector_area(9,45)==31.808625617596654
assert sector_area(9,361)==None

import math
def sector_area(r,a):
    if a > 360:
        return None
    return (math.pi*r**2) * (a/360)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find the longest common subsequence for the given three string sequence. https://www.geeksforgeeks.org/lcs-longest-common-subsequence-three-strings/

Tests:
assert lcs_of_three('AGGT12', '12TXAYB', '12XBA') == 2
assert lcs_of_three('Reels', 'Reelsfor', 'ReelsforReels') == 5
assert lcs_of_three('abcd1e2', 'bc12ea', 'bd1ea') == 3

def lcs_of_three(X, Y, Z):
  m = len(X)
  n = len(Y)
  o = len(Z)
  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]


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to put spaces between words starting with capital letters in a given string.

Tests:
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'

import re
def capital_words_spaces(str1):
  return re.sub(r"(\w)([A-Z])", r"\1 \2", str1)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to sort a given list of strings of numbers numerically. https://www.geeksforgeeks.org/python-sort-numeric-strings-in-a-list/

Tests:
assert sort_numeric_strings( ['4','12','45','7','0','100','200','-12','-500'])==[-500, -12, 0, 4, 7, 12, 45, 100, 200]
assert sort_numeric_strings(['2','3','8','4','7','9','8','2','6','5','1','6','1','2','3','4','6','9','1','2'])==[1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8, 9, 9]
assert sort_numeric_strings(['1','3','5','7','1', '3','13', '15', '17','5', '7 ','9','1', '11'])==[1, 1, 1, 3, 3, 5, 5, 7, 7, 9, 11, 13, 15, 17]

def sort_numeric_strings(nums_str):
    result = [int(x) for x in nums_str]
    result.sort()
    return result


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to add the given tuple to the given list.

Tests:
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]

def add_tuple(test_list, test_tup):
  test_list += test_tup
  return test_list


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to check if the given array represents min heap or not. https://www.geeksforgeeks.org/how-to-check-if-a-given-array-represents-a-binary-heap/

Tests:
assert check_min_heap([1, 2, 3, 4, 5, 6]) == True
assert check_min_heap([2, 3, 4, 5, 10, 15]) == True
assert check_min_heap([2, 10, 4, 5, 3, 15]) == False

def check_min_heap_helper(arr, i):
    if 2 * i + 2 > len(arr):
        return True
    left_child = (arr[i] <= arr[2 * i + 1]) and check_min_heap_helper(arr, 2 * i + 1)
    right_child = (2 * i + 2 == len(arr)) or (arr[i] <= arr[2 * i + 2]
                                      and check_min_heap_helper(arr, 2 * i + 2))
    return left_child and right_child

def check_min_heap(arr):
  return check_min_heap_helper(arr, 0)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find the nth jacobsthal number. https://www.geeksforgeeks.org/jacobsthal-and-jacobsthal-lucas-numbers/ 0, 1, 1, 3, 5, 11, 21, 43, 85, 171, 341, 683, 1365, 2731, ...

Tests:
assert jacobsthal_num(5) == 11
assert jacobsthal_num(2) == 1
assert jacobsthal_num(4) == 5
assert jacobsthal_num(13) == 2731

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]


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find minimum k records from tuple list. https://www.geeksforgeeks.org/python-find-minimum-k-records-from-tuple-list/ - in this case a verbatim copy of test cases

Tests:
assert min_k([('Manjeet', 10), ('Akshat', 4), ('Akash', 2), ('Nikhil', 8)], 2) == [('Akash', 2), ('Akshat', 4)]
assert min_k([('Sanjeev', 11), ('Angat', 5), ('Akash', 3), ('Nepin', 9)], 3) == [('Akash', 3), ('Angat', 5), ('Nepin', 9)]
assert min_k([('tanmay', 14), ('Amer', 11), ('Ayesha', 9), ('SKD', 16)], 1) == [('Ayesha', 9)]

def min_k(test_list, K):
  res = sorted(test_list, key = lambda x: x[1])[:K]
  return (res)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
We say that an element is common for lists l1, l2, l3 if it appears in all three lists under the same index. Write a function to find common elements from three lists. The function should return a list.

Tests:
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]
assert extract_index_list([1, 2, 3, 4, 6, 6, 6],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[]

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


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find the second smallest number in a list.

Tests:
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
assert second_smallest([2,2,2])==None

def second_smallest(numbers):
  unique_numbers = list(set(numbers))
  unique_numbers.sort()
  if len(unique_numbers) < 2:
    return None
  else:
    return unique_numbers[1]


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function that matches a string that has an 'a' followed by one or more 'b's. https://www.w3resource.com/python-exercises/re/python-re-exercise-3.php

Tests:
assert text_match_zero_one("ac")==False
assert text_match_zero_one("dc")==False
assert text_match_zero_one("abbbba")==True
assert text_match_zero_one("dsabbbba")==True
assert text_match_zero_one("asbbbba")==False
assert text_match_zero_one("abaaa")==True

import re
def text_match_zero_one(text):
        patterns = 'ab+?'
        if re.search(patterns,  text):
                return True
        else:
                return False


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to count the pairs of reverse strings in the given string list. https://www.geeksforgeeks.org/python-program-to-count-the-pairs-of-reverse-strings/

Tests:
assert count_reverse_pairs(["julia", "best", "tseb", "for", "ailuj"])== 2
assert count_reverse_pairs(["geeks", "best", "for", "skeeg"]) == 1
assert count_reverse_pairs(["makes", "best", "sekam", "for", "rof"]) == 2

def count_reverse_pairs(test_list):
  res = sum([1 for idx in range(0, len(test_list)) for idxn in range(idx, len(
	test_list)) if test_list[idxn] == str(''.join(list(reversed(test_list[idx]))))])
  return res


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to count lists within a list. The function should return a dictionary where every list is converted to a tuple and the value of such tuple is the number of its occurencies in the original list.

Tests:
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([[10, 20, 30, 40], [60, 70, 50, 50], [90, 100, 200]])=={(10, 20, 30, 40): 1, (60, 70, 50, 50): 1, (90, 100, 200): 1}
assert unique_sublists([['john']])=={('john',): 1}

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


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to check whether a given string is a decimal number with a precision of 2.

Tests:
assert is_decimal('123.11')==True
assert is_decimal('e666.86')==False
assert is_decimal('3.124587')==False
assert is_decimal('1.11')==True
assert is_decimal('1.1.11')==False

def is_decimal(num):
    import re
    dnumre = re.compile(r"""^[0-9]+(\.[0-9]{1,2})?$""")
    result = dnumre.search(num)
    return bool(result)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to check whether a list of numbers contains only one distinct element or not.

Tests:
assert unique_Element([1,1,1]) == True
assert unique_Element([1,2,1,2]) == False
assert unique_Element([1,2,3,4,5]) == False

def unique_Element(arr):
    s = set(arr)
    return len(s) == 1


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to check whether the given month number contains 30 days or not. Months are given as number from 1 to 12.

Tests:
assert check_monthnumber_number(6)==True
assert check_monthnumber_number(2)==False
assert check_monthnumber_number(12)==False

def check_monthnumber_number(monthnum3):
  return monthnum3==4 or monthnum3==6 or monthnum3==9 or monthnum3==11


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to find the minimum difference between any two elements in a given array. https://www.geeksforgeeks.org/find-minimum-difference-pair/

Tests:
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

def find_min_diff(arr,n):
    arr = sorted(arr)
    diff = 10**20
    for i in range(n-1):
        if arr[i+1] - arr[i] < diff:
            diff = arr[i+1] - arr[i]
    return diff


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to count number of digits in a given string.

Tests:
assert number_ctr('program2bedone') == 1
assert number_ctr('3wonders') == 1
assert number_ctr('123') == 3
assert number_ctr('3wond-1ers2') == 3

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


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find nth polite number. geeksforgeeks.org/n-th-polite-number/

Tests:
assert is_polite(7) == 11
assert is_polite(4) == 7
assert is_polite(9) == 13

import math
def is_polite(n):
	n = n + 1
	return (int)(n+(math.log((n + math.log(n, 2)), 2)))


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to return a list of all pairs of consecutive items in a given list.

Tests:
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([5,1,9,7,10])==[(5, 1), (1, 9), (9, 7), (7, 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)]

def pair_wise(l1):
    temp = []
    for i in range(len(l1) - 1):
        current_element, next_element = l1[i], l1[i + 1]
        x = (current_element, next_element)
        temp.append(x)
    return temp


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to count the number of pairs whose sum is equal to ‘sum’. The funtion gets as input a list of numbers and the sum,

Tests:
assert get_pairs_count([1,1,1,1],2) == 6
assert get_pairs_count([1,5,7,-1,5],6) == 3
assert get_pairs_count([1,-2,3],1) == 1
assert get_pairs_count([-1,-2,3],-3) == 1

def get_pairs_count(arr, sum):
    count = 0
    for i in range(len(arr)):
        for j in range(i + 1,len(arr)):
            if arr[i] + arr[j] == sum:
                count += 1
    return count


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to get the difference between two lists.

Tests:
assert (Diff([10, 15, 20, 25, 30, 35, 40], [25, 40, 35])) == [10, 20, 30, 15]
assert (Diff([1,2,3,4,5], [6,7,1])) == [2,3,4,5,6,7]
assert (Diff([1,2,3], [6,7,1])) == [2,3,6,7]

def Diff(li1,li2):
    return list(set(li1)-set(li2)) + list(set(li2)-set(li1))


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to find the sum of fourth power of first n odd natural numbers.

Tests:
assert odd_num_sum(2) == 82
assert odd_num_sum(3) == 707
assert odd_num_sum(4) == 3108

def odd_num_sum(n) :
    j = 0
    sm = 0
    for i in range(1,n + 1) :
        j = (2*i-1)
        sm = sm + (j*j*j*j)
    return sm


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to check if the given expression is balanced or not. https://www.geeksforgeeks.org/check-for-balanced-parentheses-in-an-expression/

Tests:
assert check_expression("{()}[{}]") == True
assert check_expression("{()}[{]") == False
assert check_expression("{()}[{}][]({})") == True

from collections import deque
def check_expression(exp):
    if len(exp) & 1:
        return False
    stack = deque()
    for ch in exp:
        if ch == '(' or ch == '{' or ch == '[':
            stack.append(ch)
        if ch == ')' or ch == '}' or ch == ']':
            if not stack:
                return False
            top = stack.pop()
            if (top == '(' and ch != ')') or (top == '{' and ch != '}' or (top == '[' and ch != ']')):
                return False
    return not stack


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to remove all the words with k length in the given string.

Tests:
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'

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)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find the occurrence and position of the substrings within a string. Return None if there is no match.

Tests:
assert occurance_substring('python programming, python language','python')==('python', 0, 6)
assert occurance_substring('python programming,programming language','programming')==('programming', 7, 18)
assert occurance_substring('python programming,programming language','language')==('language', 31, 39)
assert occurance_substring('c++ programming, c++ language','python')==None

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)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to check whether every odd index contains odd numbers of a given list.

Tests:
assert odd_position([2,1,4,3,6,7,6,3]) == True
assert odd_position([4,1,2]) == True
assert odd_position([1,2,3]) == False

def odd_position(nums):
	return all(nums[i]%2==i%2 for i in range(len(nums)))


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to count those characters which have vowels as their neighbors in the given string.

Tests:
assert count_vowels('bestinstareels') == 7
assert count_vowels('partofthejourneyistheend') == 12
assert count_vowels('amazonprime') == 5

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)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to find the sum of non-repeated elements in a given list.

Tests:
assert find_sum([1,2,3,1,1,4,5,6]) == 21
assert find_sum([1,10,9,4,2,10,10,45,4]) == 71
assert find_sum([12,10,9,45,2,10,10,45,10]) == 78

def find_sum(arr):
    arr.sort()
    sum = arr[0]
    for i in range(len(arr)-1):
        if (arr[i] != arr[i+1]):
            sum = sum + arr[i+1]
    return sum


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to pack consecutive duplicates of a given list elements into sublists.

Tests:
assert pack_consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4])==[[0, 0], [1], [2], [3], [4, 4], [5], [6, 6, 6], [7], [8], [9], [4, 4]]
assert pack_consecutive_duplicates([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10])==[[10, 10], [15], [19], [18, 18], [17], [26, 26], [17], [18], [10]]
assert pack_consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd'])==[['a', 'a'], ['b'], ['c'], ['d', 'd']]

from itertools import groupby
def pack_consecutive_duplicates(list1):
    return [list(group) for key, group in groupby(list1)]


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to count the number of lists within a list. The function should return a dictionary, where every list is turned to a tuple, and the value of the tuple is the number of its occurrences.

Tests:
assert unique_sublists([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]])=={(1, 3): 2, (5, 7): 2, (13, 15, 17): 1, (9, 11): 1}
assert unique_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])=={('green', 'orange'): 2, ('black',): 1, ('white',): 1}
assert unique_sublists([[1, 2], [3, 4], [4, 5], [6, 7]])=={(1, 2): 1, (3, 4): 1, (4, 5): 1, (6, 7): 1}

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


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find the combinations of sums with tuples in the given tuple list. https://www.geeksforgeeks.org/python-combinations-of-sum-with-tuples-in-tuple-list/

Tests:
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)]

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)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to check whether the count of divisors is even. https://www.w3resource.com/python-exercises/basic/python-basic-1-exercise-24.php

Tests:
assert count_divisors(10)
assert not count_divisors(100)
assert count_divisors(125)

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
    return count % 2 == 0


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to find the sum of all odd length subarrays. https://www.geeksforgeeks.org/sum-of-all-odd-length-subarrays/

Tests:
assert odd_length_sum([1,2,4]) == 14
assert odd_length_sum([1,2,1,2]) == 15
assert odd_length_sum([1,7]) == 8

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


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to convert rgb color to hsv color. https://www.geeksforgeeks.org/program-change-rgb-color-model-hsv-color-model/

Tests:
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)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find the product of first even and odd number of a given list.

Tests:
assert mul_even_odd([1,3,5,7,4,1,6,8])==4
assert mul_even_odd([1,2,3,4,5,6,7,8,9,10])==2
assert mul_even_odd([1,5,7,9,10])==10

def mul_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)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to convert tuple string to integer tuple.

Tests:
assert tuple_str_int("(7, 8, 9)") == (7, 8, 9)
assert tuple_str_int("(1, 2, 3)") == (1, 2, 3)
assert tuple_str_int("(4, 5, 6)") == (4, 5, 6)
assert tuple_str_int("(7, 81, 19)") == (7, 81, 19)

def tuple_str_int(test_str):
  res = tuple(int(num) for num in test_str.replace('(', '').replace(')', '').replace('...', '').split(', '))
  return (res)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to locate the right insertion point for a specified value in sorted order.

Tests:
assert right_insertion([1,2,4,5],6)==4
assert right_insertion([1,2,4,5],3)==2
assert right_insertion([1,2,4,5],7)==4

import bisect
def right_insertion(a, x):
    return bisect.bisect_right(a, x)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function that matches a string that has an a followed by three 'b'.

Tests:
assert not text_match_three("ac")
assert not text_match_three("dc")
assert text_match_three("abbbba")
assert text_match_three("caacabbbba")

import re
def text_match_three(text):
        patterns = 'ab{3}?'
        return re.search(patterns,  text)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to create a new tuple from the given string and list.

Tests:
assert new_tuple(["WEB", "is"], "best") == ('WEB', 'is', 'best')
assert new_tuple(["We", "are"], "Developers") == ('We', 'are', 'Developers')
assert new_tuple(["Part", "is"], "Wrong") == ('Part', 'is', 'Wrong')

def new_tuple(test_list, test_str):
  return tuple(test_list + [test_str])


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to check whether every even index contains even numbers of a given list.

Tests:
assert even_position([3,2,1]) == False
assert even_position([1,2,3]) == False
assert even_position([2,1,4]) == True

def even_position(nums):
	return all(nums[i]%2==i%2 for i in range(len(nums)))


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to remove tuples from the given tuple.

Tests:
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)
assert remove_nested((3, 7, 9, (6, 8), (5,12), 12)) == (3, 7, 9, 12)

def remove_nested(test_tup):
  res = tuple()
  for count, ele in enumerate(test_tup):
    if not isinstance(ele, tuple):
      res = res + (ele, )
  return (res)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to count the number of lists in a given number of lists.

Tests:
assert count_list([[1, 3], [5, 7], [9, 11], [13, 15, 17]]) == 4
assert count_list([[1,2],[2,3],[4,5]]) == 3
assert count_list([[1,0],[2,0]]) == 2

def count_list(input_list):
    return len(input_list)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to find the last position of an element in a sorted array.

Tests:
assert last([1,2,3],1) == 0
assert last([1,1,1,2,3,4],1) == 2
assert last([2,3,2,3,6,8,9],3) == 3

def last(arr,x):
    n = len(arr)
    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


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function that matches a string that has an 'a' followed by anything, ending in 'b'.

Tests:
assert text_starta_endb("aabbbb")
assert not text_starta_endb("aabAbbbc")
assert not text_starta_endb("accddbbjjj")

import re
def text_starta_endb(text):
        patterns = 'a.*?b$'
        return re.search(patterns,  text)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write function to find the sum of all items in the given dictionary.

Tests:
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

def return_sum(dict):
  sum = 0
  for i in dict.values():
    sum = sum + i
  return sum


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to find the sum of all odd natural numbers within the range l and r.

Tests:
assert sum_in_range(2,5) == 8
assert sum_in_range(5,7) == 12
assert sum_in_range(7,13) == 40

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)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to find the sum of an array.

Tests:
assert _sum([1, 2, 3]) == 6
assert _sum([15, 12, 13, 10]) == 50
assert _sum([0, 1, 2]) == 3

def _sum(arr):
    sum=0
    for i in arr:
        sum = sum + i
    return(sum)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to that rotate left bits by d bits a given number. We assume that the number is 32 bit.

Tests:
assert left_rotate(16,2) == 64
assert left_rotate(10,2) == 40
assert left_rotate(99,3) == 792
assert left_rotate(99,3) == 792
assert left_rotate(0b0001,3) == 0b1000
assert left_rotate(0b0101,3) == 0b101000
assert left_rotate(0b11101,3) == 0b11101000

def left_rotate(n,d):
    INT_BITS = 32
    return (n << d)|(n >> (INT_BITS - d))


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to remove all whitespaces from a string.

Tests:
assert remove_all_spaces('python  program')==('pythonprogram')
assert remove_all_spaces('python   programming    language')==('pythonprogramminglanguage')
assert remove_all_spaces('python                     program')==('pythonprogram')
assert remove_all_spaces('   python                     program')=='pythonprogram'

import re
def remove_all_spaces(text):
 return (re.sub(r'\s+', '',text))


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to count the number of equal numbers from three given integers.

Tests:
assert test_three_equal(1,1,1) == 3
assert test_three_equal(-1,-2,-3) == 0
assert test_three_equal(1,2,2) == 2

def test_three_equal(x,y,z):
  result = set([x,y,z])
  if len(result)==3:
    return 0
  else:
    return 4-len(result)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to count the number of rotations required to generate a sorted array. https://www.geeksforgeeks.org/count-of-rotations-required-to-generate-a-sorted-array/

Tests:
assert count_rotation([3,2,1]) == 1
assert count_rotation([4,5,1,2,3]) == 2
assert count_rotation([7,8,9,1,2,3]) == 3
assert count_rotation([1,2,3]) == 0
assert count_rotation([1,3,2]) == 2

def count_rotation(arr):
    for i in range (1,len(arr)):
        if (arr[i] < arr[i - 1]):
            return i
    return 0


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to check whether the given number is a perfect square or not. https://www.geeksforgeeks.org/check-if-given-number-is-perfect-square-in-cpp/

Tests:
assert not is_perfect_square(10)
assert is_perfect_square(36)
assert not is_perfect_square(14)
assert is_perfect_square(14*14)
assert not is_perfect_square(125)
assert is_perfect_square(125*125)

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


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to check whether the product of numbers in a list is even or not.

Tests:
assert is_product_even([1,2,3])
assert is_product_even([1,2,1,4])
assert not is_product_even([1,1])

def is_product_even(arr):
    for i in range(len(arr)):
        if (arr[i] & 1) == 0:
            return True
    return False


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function that returns the list in a list of lists whose sum of elements is the highest.

Tests:
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]

def max_sum_list(lists):
 return max(lists, key=sum)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find maximum run of uppercase characters in the given string.

Tests:
assert max_run_uppercase('GeMKSForGERksISBESt') == 5
assert max_run_uppercase('PrECIOusMOVemENTSYT') == 6
assert max_run_uppercase('GooGLEFluTTER') == 4

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)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to find the first odd number in a given list of numbers.

Tests:
assert first_odd([1,3,5]) == 1
assert first_odd([2,4,1,3]) == 1
assert first_odd ([8,9,1]) == 9

def first_odd(nums):
  first_odd = next((el for el in nums if el%2!=0),-1)
  return first_odd


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to check if the given tuples contain the k or not.

Tests:
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

def check_K(test_tup, K):
  res = False
  for ele in test_tup:
    if ele == K:
      res = True
      break
  return res


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to check if each element of second tuple is smaller than its corresponding element in the first tuple.

Tests:
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

def check_smaller(test_tup1, test_tup2):
  return all(x > y for x, y in zip(test_tup1, test_tup2))


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to remove first and last occurrence of a given character from the string.

Tests:
assert remove_Occ("hello","l") == "heo"
assert remove_Occ("abcda","a") == "bcd"
assert remove_Occ("PHP","P") == "H"

def remove_Occ(s,ch):
    for i in range(len(s)):
        if (s[i] == ch):
            s = s[0 : i] + s[i + 1:]
            break
    for i in range(len(s) - 1,-1,-1):
        if (s[i] == ch):
            s = s[0 : i] + s[i + 1:]
            break
    return s


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to sort a given matrix in ascending order according to the sum of its rows.

Tests:
assert sort_matrix([[1, 2, 3], [2, 4, 5], [1, 1, 1]])==[[1, 1, 1], [1, 2, 3], [2, 4, 5]]
assert sort_matrix([[1, 2, 3], [-2, 4, -5], [1, -1, 1]])==[[-2, 4, -5], [1, -1, 1], [1, 2, 3]]
assert sort_matrix([[5,8,9],[6,4,3],[2,1,4]])==[[2, 1, 4], [6, 4, 3], [5, 8, 9]]

def sort_matrix(M):
    result = sorted(M, key=sum)
    return result


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to find the volume of a triangular prism.

Tests:
assert find_Volume(10,8,6) == 240
assert find_Volume(3,2,2) == 6
assert find_Volume(1,2,1) == 1

def find_Volume(l,b,h) :
    return ((l * b * h) / 2)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to that returns true if the input string contains sequences of lowercase letters joined with an underscore and false otherwise.

Tests:
assert text_lowercase_underscore("aab_cbbbc")==(True)
assert text_lowercase_underscore("aab_Abbbc")==(False)
assert text_lowercase_underscore("Aaab_abbbc")==(False)

import re
def text_lowercase_underscore(text):
        patterns = '^[a-z]+_[a-z]+$'
        if re.search(patterns,  text):
                return True
        else:
                return False


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function that returns the perimeter of a square given its side length as input.

Tests:
assert square_perimeter(10)==40
assert square_perimeter(5)==20
assert square_perimeter(4)==16

def square_perimeter(a):
  perimeter=4*a
  return perimeter


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to remove characters from the first string which are present in the second string.

Tests:
assert remove_dirty_chars("probasscurve", "pros") == 'bacuve'
assert remove_dirty_chars("digitalindia", "talent") == 'digiidi'
assert remove_dirty_chars("exoticmiles", "toxic") == 'emles'

NO_OF_CHARS = 256
def str_to_list(string):
	temp = []
	for x in string:
		temp.append(x)
	return temp
def lst_to_string(List):
	return ''.join(List)
def get_char_count_array(string):
	count = [0] * NO_OF_CHARS
	for i in string:
		count[ord(i)] += 1
	return count
def remove_dirty_chars(string, second_string):
	count = get_char_count_array(second_string)
	ip_ind = 0
	res_ind = 0
	temp = ''
	str_list = str_to_list(string)
	while ip_ind != len(str_list):
		temp = str_list[ip_ind]
		if count[ord(temp)] == 0:
			str_list[res_ind] = str_list[ip_ind]
			res_ind += 1
		ip_ind+=1
	return lst_to_string(str_list[0:res_ind])


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find whether a given array of integers contains any duplicate element.

Tests:
assert test_duplicate(([1,2,3,4,5]))==False
assert test_duplicate(([1,2,3,4, 4]))==True
assert test_duplicate([1,1,2,2,3,3,4,4,5])==True

def test_duplicate(arraynums):
    nums_set = set(arraynums)
    return len(arraynums) != len(nums_set)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to check if the given number is woodball or not.

Tests:
assert is_woodall(383) == True
assert is_woodall(254) == False
assert is_woodall(200) == False

def is_woodall(x):
	if (x % 2 == 0):
		return False
	if (x == 1):
		return True
	x = x + 1
	p = 0
	while (x % 2 == 0):
		x = x/2
		p = p + 1
		if (p == x):
			return True
	return False


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to check if a given number is one less than twice its reverse.

Tests:
assert check(70) == False
assert check(23) == False
assert check(73) == True

def rev(num):
    rev_num = 0
    while (num > 0):
        rev_num = (rev_num * 10 + num % 10)
        num = num // 10
    return rev_num
def check(n):
    return (2 * rev(n) == n + 1)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to find the largest number that can be formed with the given list of digits.

Tests:
assert find_Max_Num([1,2,3]) == 321
assert find_Max_Num([4,5,6,1]) == 6541
assert find_Max_Num([1,2,3,9]) == 9321

def find_Max_Num(arr) :
    n = len(arr)
    arr.sort(reverse = True)
    num = arr[0]
    for i in range(1,n) :
        num = num * 10 + arr[i]
    return num


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to check whether the given two integers have opposite sign or not.

Tests:
assert opposite_Signs(1,-2) == True
assert opposite_Signs(3,2) == False
assert opposite_Signs(-10,-10) == False
assert opposite_Signs(-2,2) == True

def opposite_Signs(x,y):
    return ((x ^ y) < 0);


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find the nth octagonal number.

Tests:
assert is_octagonal(5) == 65
assert is_octagonal(10) == 280
assert is_octagonal(15) == 645

def is_octagonal(n):
	return 3 * n * n - 2 * n


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to count the number of substrings with the sum of digits equal to their length.

Tests:
assert count_Substrings('112112') == 6
assert count_Substrings('111') == 6
assert count_Substrings('1101112') == 12

from collections import defaultdict
def count_Substrings(s):
    n = len(s)
    count,sum = 0,0
    mp = defaultdict(lambda : 0)
    mp[0] += 1
    for i in range(n):
        sum += ord(s[i]) - ord('0')
        count += mp[sum - (i + 1)]
        mp[sum - (i + 1)] += 1
    return count


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to find smallest number in a list.

Tests:
assert smallest_num([10, 20, 1, 45, 99]) == 1
assert smallest_num([1, 2, 3]) == 1
assert smallest_num([45, 46, 50, 60]) == 45


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find the maximum difference between available pairs in the given tuple list.

Tests:
assert max_difference([(3, 5), (1, 7), (10, 3), (1, 2)]) == 7
assert max_difference([(4, 6), (2, 17), (9, 13), (11, 12)]) == 15
assert max_difference([(12, 35), (21, 27), (13, 23), (41, 22)]) == 23

def max_difference(test_list):
  temp = [abs(b - a) for a, b in test_list]
  res = max(temp)
  return (res)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to sort a list of tuples using the second value of each tuple.

Tests:
assert subject_marks([('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)])==[('Social sciences', 82), ('English', 88), ('Science', 90), ('Maths', 97)]
assert subject_marks([('Telugu',49),('Hindhi',54),('Social',33)])==([('Social',33),('Telugu',49),('Hindhi',54)])
assert subject_marks([('Physics',96),('Chemistry',97),('Biology',45)])==([('Biology',45),('Physics',96),('Chemistry',97)])

def subject_marks(subjectmarks):
#subject_marks = [('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)])
 subjectmarks.sort(key = lambda x: x[1])
 return subjectmarks


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to flatten a list and sum all of its elements.

Tests:
assert recursive_list_sum(([1, 2, [3,4],[5,6]]))==21
assert recursive_list_sum(([7, 10, [15,14],[19,41]]))==106
assert recursive_list_sum(([10, 20, [30,40],[50,60]]))==210

def recursive_list_sum(data_list):
	total = 0
	for element in data_list:
		if type(element) == type([]):
			total = total + recursive_list_sum(element)
		else:
			total = total + element
	return total


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to count the number of positive numbers in a list.

Tests:
assert pos_count([1,-2,3,-4]) == 2
assert pos_count([3,4,5,-1]) == 3
assert pos_count([1,2,3,4]) == 4

def pos_count(list):
  pos_count= 0
  for num in list:
    if num >= 0:
      pos_count += 1
  return pos_count


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find the number of ways to partition a set of Bell numbers.

Tests:
assert bell_number(2)==2
assert bell_number(10)==115975
assert bell_number(56)==6775685320645824322581483068371419745979053216268760300

def bell_number(n):
    bell = [[0 for i in range(n+1)] for j in range(n+1)]
    bell[0][0] = 1
    for i in range(1, n+1):
        bell[i][0] = bell[i-1][i-1]
        for j in range(1, i+1):
            bell[i][j] = bell[i-1][j-1] + bell[i][j-1]
    return bell[n][0]


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to check whether the given array is monotonic or not.

Tests:
assert is_Monotonic([6, 5, 4, 4]) == True
assert is_Monotonic([1, 2, 2, 3]) == True
assert is_Monotonic([1, 3, 2]) == False

def is_Monotonic(A):
    return (all(A[i] <= A[i + 1] for i in range(len(A) - 1)) or
            all(A[i] >= A[i + 1] for i in range(len(A) - 1)))


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to check whether a list contains the given sublist or not.

Tests:
assert is_sublist([2,4,3,5,7],[3,7])==False
assert is_sublist([2,4,3,5,7],[4,3])==True
assert is_sublist([2,4,3,5,7],[1,6])==False

def is_sublist(l, s):
	sub_set = False
	if s == []:
		sub_set = True
	elif s == l:
		sub_set = True
	elif len(s) > len(l):
		sub_set = False
	else:
		for i in range(len(l)):
			if l[i] == s[0]:
				n = 1
				while (n < len(s)) and (l[i+n] == s[n]):
					n += 1
				if n == len(s):
					sub_set = True
	return sub_set


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find whether all the given tuples have equal length or not.

Tests:
assert get_equal([(11, 22, 33), (44, 55, 66)]) == True
assert get_equal([(1, 2, 3), (4, 5, 6, 7)]) == False
assert get_equal([(1, 2), (3, 4)]) == True

def find_equal_tuple(Input):
  k = 0 if not Input else len(Input[0])
  flag = 1
  for tuple in Input:
    if len(tuple) != k:
      flag = 0
      break
  return flag
def get_equal(Input):
  return find_equal_tuple(Input) == 1


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to sort a list of elements.

Tests:
assert comb_sort([5, 15, 37, 25, 79]) == [5, 15, 25, 37, 79]
assert comb_sort([41, 32, 15, 19, 22]) == [15, 19, 22, 32, 41]
assert comb_sort([99, 15, 13, 47]) == [13, 15, 47, 99]

def comb_sort(nums):
    shrink_fact = 1.3
    gaps = len(nums)
    swapped = True
    i = 0
    while gaps > 1 or swapped:
        gaps = int(float(gaps) / shrink_fact)
        swapped = False
        i = 0
        while gaps + i < len(nums):
            if nums[i] > nums[i+gaps]:
                nums[i], nums[i+gaps] = nums[i+gaps], nums[i]
                swapped = True
            i += 1
    return nums


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to check whether the given number can be represented as the difference of two squares or not.

Tests:
assert dif_Square(5) == True
assert dif_Square(10) == False
assert dif_Square(15) == True

def dif_Square(n):
    if (n % 4 != 2):
        return True
    return False


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to check whether it follows the sequence given in the patterns array.

Tests:
assert is_samepatterns(["red","green","green"], ["a", "b", "b"])==True
assert is_samepatterns(["red","green","greenn"], ["a","b","b"])==False
assert is_samepatterns(["red","green","greenn"], ["a","b"])==False

def is_samepatterns(colors, patterns):
    if len(colors) != len(patterns):
        return False
    sdict = {}
    pset = set()
    sset = set()
    for i in range(len(patterns)):
        pset.add(patterns[i])
        sset.add(colors[i])
        if patterns[i] not in sdict.keys():
            sdict[patterns[i]] = []

        keys = sdict[patterns[i]]
        keys.append(colors[i])
        sdict[patterns[i]] = keys

    if len(pset) != len(sset):
        return False

    for values in sdict.values():

        for i in range(len(values) - 1):
            if values[i] != values[i+1]:
                return False

    return True


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find tuples which have all elements divisible by k from the given list of tuples.

Tests:
assert find_tuples([(6, 24, 12), (7, 9, 6), (12, 18, 21)], 6) == [(6, 24, 12)]
assert find_tuples([(5, 25, 30), (4, 2, 3), (7, 8, 9)], 5) == [(5, 25, 30)]
assert find_tuples([(7, 9, 16), (8, 16, 4), (19, 17, 18)], 4) == [(8, 16, 4)]

def find_tuples(test_list, K):
  res = [sub for sub in test_list if all(ele % K == 0 for ele in sub)]
  return res


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to find whether a number is divisible by 11.

Tests:
assert is_Diff (12345) == False
assert is_Diff(1212112) == True
assert is_Diff(1212) == False

def is_Diff(n):
    return (n % 11 == 0)

def is_Diff(n):
    return (n % 11 == 0)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to check whether the length of the word is odd or not.

Tests:
assert word_len("Hadoop") == False
assert word_len("great") == True
assert word_len("structure") == True

def word_len(s):
    s = s.split(' ')
    for word in s:
        if len(word)%2!=0:
            return True
        else:
          return False


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find the nth tetrahedral number.

Tests:
assert tetrahedral_number(5) == 35
assert tetrahedral_number(6) == 56
assert tetrahedral_number(7) == 84

def tetrahedral_number(n):
	return (n * (n + 1) * (n + 2)) / 6


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find the volume of a sphere.

Tests:
assert math.isclose(volume_sphere(10), 4188.790204786391, rel_tol=0.001)
assert math.isclose(volume_sphere(25), 65449.84694978735, rel_tol=0.001)
assert math.isclose(volume_sphere(20), 33510.32163829113, rel_tol=0.001)

import math
def volume_sphere(r):
  volume=(4/3)*math.pi*r*r*r
  return volume


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a python function to find the character made by adding the ASCII value of all the characters of the given string modulo 26.

Tests:
assert get_Char("abc") == "f"
assert get_Char("gfg") == "t"
assert get_Char("ab") == "c"

def get_Char(strr):
    summ = 0
    for i in range(len(strr)):
        summ += (ord(strr[i]) - ord('a') + 1)
    if (summ % 26 == 0):
        return ord('z')
    else:
        summ = summ % 26
        return chr(ord('a') + summ - 1)


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find the nth number in the newman conway sequence.

Tests:
assert sequence(10) == 6
assert sequence(2) == 1
assert sequence(3) == 2

def sequence(n):
	if n == 1 or n == 2:
		return 1
	else:
		return sequence(sequence(n-1)) + sequence(n-sequence(n-1))


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find the surface area of a sphere.

Tests:
assert math.isclose(surfacearea_sphere(10), 1256.6370614359173, rel_tol=0.001)
assert math.isclose(surfacearea_sphere(15), 2827.4333882308138, rel_tol=0.001)
assert math.isclose(surfacearea_sphere(20), 5026.548245743669, rel_tol=0.001)

import math
def surfacearea_sphere(r):
  surfacearea=4*math.pi*r*r
  return surfacearea


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to find nth centered hexagonal number.

Tests:
assert centered_hexagonal_number(10) == 271
assert centered_hexagonal_number(2) == 7
assert centered_hexagonal_number(9) == 217

def centered_hexagonal_number(n):
  return 3 * n * (n - 1) + 1


Question:
Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.

Description:
Write a function to merge three dictionaries into a single dictionary.

Tests:
assert merge_dictionaries_three({ "R": "Red", "B": "Black", "P": "Pink" }, { "G": "Green", "W": "White" },{ "O": "Orange", "W": "White", "B": "Black" })=={'B': 'Black', 'R': 'Red', 'P': 'Pink', 'G': 'Green', 'W': 'White', 'O': 'Orange'}
assert merge_dictionaries_three({ "R": "Red", "B": "Black", "P": "Pink" }, { "G": "Green", "W": "White" },{"L":"lavender","B":"Blue"})=={'W': 'White', 'P': 'Pink', 'B': 'Black', 'R': 'Red', 'G': 'Green', 'L': 'lavender'}
assert merge_dictionaries_three({ "R": "Red", "B": "Black", "P": "Pink" },{"L":"lavender","B":"Blue"},{ "G": "Green", "W": "White" })=={'B': 'Black', 'P': 'Pink', 'R': 'Red', 'G': 'Green', 'L': 'lavender', 'W': 'White'}

import collections as ct
def merge_dictionaries_three(dict1,dict2, dict3):
    merged_dict = dict(ct.ChainMap({},dict1,dict2,dict3))
    return merged_dict