shawnmkim/compete-collab-taskbank huggingface dataset:
Write a python function to find the average of even numbers till a given even number.

The function signature must exactly match the following example (same function name and argument order):
assert average_Even(2) == 2


Tests:
assert average_Even(4) == 3
assert average_Even(100) == 51
Write a python function to shift first element to the end of given list.

The function signature must exactly match the following example (same function name and argument order):
assert move_last([1,2,3,4]) == [2,3,4,1]


Tests:
assert move_last([2,3,4,1,5,0]) == [3,4,1,5,0,2]
assert move_last([5,4,3,2,1]) == [4,3,2,1,5]
Write a function to count occurrence of a character in a string.

The function signature must exactly match the following example (same function name and argument order):
assert count_char("Python",'o')==1


Tests:
assert count_char("little",'t')==2
assert count_char("assert",'s')==2
Write a python function to count number of vowels in the string.

The function signature must exactly match the following example (same function name and argument order):
assert Check_Vow('corner','AaEeIiOoUu') == 2


Tests:
assert Check_Vow('valid','AaEeIiOoUu') == 2
assert Check_Vow('true','AaEeIiOoUu') ==2
Write a python function to replace multiple occurence of character by single.

The function signature must exactly match the following example (same function name and argument order):
assert replace('peep','e') == 'pep'


Tests:
assert replace('Greek','e') == 'Grek'
assert replace('Moon','o') == 'Mon'
Write a function to check whether the given ip address is valid or not using regex.

The function signature must exactly match the following example (same function name and argument order):
assert check_IP("192.168.0.1") == 'Valid IP address'


Tests:
assert check_IP("110.234.52.124") == 'Valid IP address'
assert check_IP("366.1.2.2") == 'Invalid IP address'
Write a python function to check whether a sequence of numbers has a decreasing trend or not.

The function signature must exactly match the following example (same function name and argument order):
assert decreasing_trend([-4,-3,-2,-1]) == True


Tests:
assert decreasing_trend([1,2,3]) == True
assert decreasing_trend([3,2,1]) == False
Write a python function to set the right most unset bit.

The function signature must exactly match the following example (same function name and argument order):
assert set_Right_most_Unset_Bit(21) == 23


Tests:
assert set_Right_most_Unset_Bit(11) == 15
assert set_Right_most_Unset_Bit(15) == 15
Write a function to find maximum of three numbers.

The function signature must exactly match the following example (same function name and argument order):
assert max_of_three(10,20,30)==30


Tests:
assert max_of_three(55,47,39)==55
assert max_of_three(10,49,30)==49
Write a python function to convert a list of multiple integers into a single integer.

The function signature must exactly match the following example (same function name and argument order):
assert convert([1,2,3]) == 123


Tests:
assert convert([4,5,6]) == 456
assert convert([7,8,9]) == 789
Write a function to remove duplicate words from a given string using collections module.

The function signature must exactly match the following example (same function name and argument order):
assert remove_duplicate("Python Exercises Practice Solution Exercises")==("Python Exercises Practice Solution")


Tests:
assert remove_duplicate("Python Exercises Practice Solution Python")==("Python Exercises Practice Solution")
assert remove_duplicate("Python Exercises Practice Solution Practice")==("Python Exercises Practice Solution")
Write a function to add two integers. however, if the sum is between the given range it will return 20.

The function signature must exactly match the following example (same function name and argument order):
assert sum_nums(2,10,11,20)==20


Tests:
assert sum_nums(15,17,1,10)==32
assert sum_nums(10,15,5,30)==20
Write a function to remove everything except alphanumeric characters from the given string by using regex.

The function signature must exactly match the following example (same function name and argument order):
assert remove_extra_char('**//Google Android// - 12. ') == 'GoogleAndroid12'


Tests:
assert remove_extra_char('****//Google Flutter//*** - 36. ') == 'GoogleFlutter36'
assert remove_extra_char('**//Google Firebase// - 478. ') == 'GoogleFirebase478'
Write a function to check if the triangle is valid or not.

The function signature must exactly match the following example (same function name and argument order):
assert validity_triangle(60,50,90)==False


Tests:
assert validity_triangle(45,75,60)==True
assert validity_triangle(30,50,100)==True
Write a python function to remove spaces from a given string.

The function signature must exactly match the following example (same function name and argument order):
assert remove_spaces("a b c") == "abc"


Tests:
assert remove_spaces("1 2 3") == "123"
assert remove_spaces(" b c") == "bc"
Write a function to access dictionary key’s element by index.

The function signature must exactly match the following example (same function name and argument order):
assert access_key({'physics': 80, 'math': 90, 'chemistry': 86},0)== 'physics'


Tests:
assert access_key({'python':10, 'java': 20, 'C++':30},2)== 'C++'
assert access_key({'program':15,'computer':45},1)== 'computer'
Write a python function to check whether a sequence of numbers has an increasing trend or not.

The function signature must exactly match the following example (same function name and argument order):
assert increasing_trend([1,2,3,4]) == True


Tests:
assert increasing_trend([4,3,2,1]) == False
assert increasing_trend([0,1,4,9]) == True
Write a python function to find the smallest prime divisor of a number.

The function signature must exactly match the following example (same function name and argument order):
assert smallest_Divisor(10) == 2


Tests:
assert smallest_Divisor(25) == 5
assert smallest_Divisor(31) == 31
Write a function to multiply two lists using map and lambda function.

The function signature must exactly match the following example (same function name and argument order):
assert mul_list([1, 2, 3],[4,5,6])==[4,10,18]


Tests:
assert mul_list([1,2],[3,4])==[3,8]
assert mul_list([90,120],[50,70])==[4500,8400]
Write a python function to check whether the given number can be represented by sum of two squares or not.

The function signature must exactly match the following example (same function name and argument order):
assert sum_Square(25) == True


Tests:
assert sum_Square(24) == False
assert sum_Square(17) == True
Write a python function to count occurences of a character in a repeated string.

The function signature must exactly match the following example (same function name and argument order):
assert count_Char("abcac",'a') == 4


Tests:
assert count_Char("abca",'c') == 2
assert count_Char("aba",'a') == 7
Write a python function to find sum of prime numbers between 1 to n.

The function signature must exactly match the following example (same function name and argument order):
assert sum_Of_Primes(10) == 17


Tests:
assert sum_Of_Primes(20) == 77
assert sum_Of_Primes(5) == 10
Write a function to find the frequency of each element in the given list.

The function signature must exactly match the following example (same function name and argument order):
assert freq_element((4, 5, 4, 5, 6, 6, 5, 5, 4) ) == '{4: 3, 5: 4, 6: 2}'


Tests:
assert freq_element((7, 8, 8, 9, 4, 7, 6, 5, 4) ) == '{7: 2, 8: 2, 9: 1, 4: 2, 6: 1, 5: 1}'
assert freq_element((1, 4, 3, 1, 4, 5, 2, 6, 2, 7) ) == '{1: 2, 4: 2, 3: 1, 5: 1, 2: 2, 6: 1, 7: 1}'
Write a function to find the greatest common divisor (gcd) of two integers by using recursion.

The function signature must exactly match the following example (same function name and argument order):
assert recur_gcd(12,14) == 2


Tests:
assert recur_gcd(13,17) == 1
assert recur_gcd(9, 3) == 3
Write a function to get the length of a complex number.

The function signature must exactly match the following example (same function name and argument order):
assert len_complex(3,4)==5.0


Tests:
assert len_complex(9,10)==13.45362404707371
assert len_complex(7,9)==11.40175425099138
## write a function to find the minimum number of jumps to reach the end of the array for the given array of integers where each element represents the max number of steps that can be made forward from that element. > indented block > indented block

The function signature must exactly match the following example (same function name and argument order):
assert min_jumps([1, 3, 6, 1, 0, 9], 6) == 3


Tests:
assert min_jumps([1, 3, 5, 8, 9, 2, 6, 7, 6, 8, 9], 11) == 3
assert min_jumps([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 11) == 10
Write a function to multiply consecutive numbers of a given list.

The function signature must exactly match the following example (same function name and argument order):
assert mul_consecutive_nums([1, 1, 3, 4, 4, 5, 6, 7])==[1, 3, 12, 16, 20, 30, 42]


Tests:
assert mul_consecutive_nums([4, 5, 8, 9, 6, 10])==[20, 40, 72, 54, 60]
assert mul_consecutive_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[2, 6, 12, 20, 30, 42, 56, 72, 90]
Write a function to group the 1st elements on the basis of 2nd elements in the given tuple list.

The function signature must exactly match the following example (same function name and argument order):
assert group_element([(6, 5), (2, 7), (2, 5), (8, 7), (9, 8), (3, 7)]) == {5: [6, 2], 7: [2, 8, 3], 8: [9]}


Tests:
assert group_element([(7, 6), (3, 8), (3, 6), (9, 8), (10, 9), (4, 8)]) == {6: [7, 3], 8: [3, 9, 4], 9: [10]}
assert group_element([(8, 7), (4, 9), (4, 7), (10, 9), (11, 10), (5, 9)]) == {7: [8, 4], 9: [4, 10, 5], 10: [11]}
Write a python function to find the last two digits in factorial of a given number.

The function signature must exactly match the following example (same function name and argument order):
assert last_Two_Digits(7) == 40


Tests:
assert last_Two_Digits(5) == 20
assert last_Two_Digits(2) == 2
Write a function to remove multiple spaces in a string by using regex.

The function signature must exactly match the following example (same function name and argument order):
assert remove_multiple_spaces('Google      Assistant') == 'Google Assistant'


Tests:
assert remove_multiple_spaces('Quad      Core') == 'Quad Core'
assert remove_multiple_spaces('ChromeCast      Built-in') == 'ChromeCast Built-in'
Write a function to extract unique values from the given dictionary values.

The function signature must exactly match the following example (same function name and argument order):
assert extract_unique({'msm' : [5, 6, 7, 8],'is' : [10, 11, 7, 5],'best' : [6, 12, 10, 8],'for' : [1, 2, 5]} ) == [1, 2, 5, 6, 7, 8, 10, 11, 12]


Tests:
assert extract_unique({'Built' : [7, 1, 9, 4],'for' : [11, 21, 36, 14, 9],'ISP' : [4, 1, 21, 39, 47],'TV' : [1, 32, 38]} ) == [1, 4, 7, 9, 11, 14, 21, 32, 36, 38, 39, 47]
assert extract_unique({'F' : [11, 13, 14, 17],'A' : [12, 11, 15, 18],'N' : [19, 21, 15, 36],'G' : [37, 36, 35]}) == [11, 12, 13, 14, 15, 17, 18, 19, 21, 35, 36, 37]
Write a function to check if each element of the second tuple is greater than its corresponding index in the first tuple.

The function signature must exactly match the following example (same function name and argument order):
assert check_greater((10, 4, 5), (13, 5, 18)) == True


Tests:
assert check_greater((1, 2, 3), (2, 1, 4)) == False
assert check_greater((4, 5, 6), (5, 6, 7)) == True
Write a function to zip two given lists of lists.

The function signature must exactly match the following example (same function name and argument order):
assert zip_list([[1, 3], [5, 7], [9, 11]] ,[[2, 4], [6, 8], [10, 12, 14]] )==[[1, 3, 2, 4], [5, 7, 6, 8], [9, 11, 10, 12, 14]]


Tests:
assert zip_list([[1, 2], [3, 4], [5, 6]] ,[[7, 8], [9, 10], [11, 12]] )==[[1, 2, 7, 8], [3, 4, 9, 10], [5, 6, 11, 12]]
assert zip_list([['a','b'],['c','d']] , [['e','f'],['g','h']] )==[['a','b','e','f'],['c','d','g','h']]
Write a function to find number of even elements in the given list using lambda function.

The function signature must exactly match the following example (same function name and argument order):
assert count_even([1, 2, 3, 5, 7, 8, 9, 10])==3


Tests:
assert count_even([10,15,14,13,-18,12,-20])==5
assert count_even([1, 2, 4, 8, 9])==3
Write a function to sort dictionary items by tuple product of keys for the given dictionary with tuple keys.

The function signature must exactly match the following example (same function name and argument order):
assert sort_dict_item({(5, 6) : 3, (2, 3) : 9, (8, 4): 10, (6, 4): 12} ) == {(2, 3): 9, (6, 4): 12, (5, 6): 3, (8, 4): 10}


Tests:
assert sort_dict_item({(6, 7) : 4, (3, 4) : 10, (9, 5): 11, (7, 5): 13} ) == {(3, 4): 10, (7, 5): 13, (6, 7): 4, (9, 5): 11}
assert sort_dict_item({(7, 8) : 5, (4, 5) : 11, (10, 6): 12, (8, 6): 14} ) == {(4, 5): 11, (8, 6): 14, (7, 8): 5, (10, 6): 12}
Write a python function to find the minimum number of swaps required to convert one binary string to another.

The function signature must exactly match the following example (same function name and argument order):
assert min_Swaps("1101","1110") == 1


Tests:
assert min_Swaps("1111","0100") == "Not Possible"
assert min_Swaps("1110000","0001101") == 3
Write a function to count the number of elements in a list which are within a specific range.

The function signature must exactly match the following example (same function name and argument order):
assert count_range_in_list([10,20,30,40,40,40,70,80,99],40,100)==6


Tests:
assert count_range_in_list(['a','b','c','d','e','f'],'a','e')==5
assert count_range_in_list([7,8,9,15,17,19,45],15,20)==3
Write a function to find the equilibrium index of the given array.

The function signature must exactly match the following example (same function name and argument order):
assert equilibrium_index([1, 2, 3, 4, 1, 2, 3]) == 3


Tests:
assert equilibrium_index([-7, 1, 5, 2, -4, 3, 0]) == 3
assert equilibrium_index([1, 2, 3]) == -1
Write a function to find the minimum number of elements that should be removed such that amax-amin<=k.

The function signature must exactly match the following example (same function name and argument order):
assert removals([1, 3, 4, 9, 10,11, 12, 17, 20], 9, 4) == 5


Tests:
assert removals([1, 5, 6, 2, 8], 5, 2) == 3
assert removals([1, 2, 3 ,4, 5, 6], 6, 3) == 2
Write a function to check whether the given key is present in the dictionary or not.

The function signature must exactly match the following example (same function name and argument order):
assert is_key_present({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60},5)==True


Tests:
assert is_key_present({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60},6)==True
assert is_key_present({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60},10)==False
Write a function to calculate the harmonic sum of n-1.

The function signature must exactly match the following example (same function name and argument order):
assert harmonic_sum(10)==2.9289682539682538


Tests:
assert harmonic_sum(4)==2.083333333333333
assert harmonic_sum(7)==2.5928571428571425
Write a function to sort a list of lists by length and value.

The function signature must exactly match the following example (same function name and argument order):
assert sort_sublists([[2], [0], [1, 3], [0, 7], [9, 11], [13, 15, 17]])==[[0], [2], [0, 7], [1, 3], [9, 11], [13, 15, 17]]


Tests:
assert sort_sublists([[1], [2, 3], [4, 5, 6], [7], [10, 11]])==[[1], [7], [2, 3], [10, 11], [4, 5, 6]]
assert sort_sublists([["python"],["java","C","C++"],["DBMS"],["SQL","HTML"]])==[['DBMS'], ['python'], ['SQL', 'HTML'], ['java', 'C', 'C++']]
Write a function to find whether an array is subset of another array.

The function signature must exactly match the following example (same function name and argument order):
assert is_subset([11, 1, 13, 21, 3, 7], 6, [11, 3, 7, 1], 4) == True


Tests:
assert is_subset([1, 2, 3, 4, 5, 6], 6, [1, 2, 4], 3) == True
assert is_subset([10, 5, 2, 23, 19], 5, [19, 5, 3], 3) == False
Write a python function to count the total set bits from 1 to n.

The function signature must exactly match the following example (same function name and argument order):
assert count_Set_Bits(16) == 33


Tests:
assert count_Set_Bits(2) == 2
assert count_Set_Bits(14) == 28
Write a python function to convert a string to a list.

The function signature must exactly match the following example (same function name and argument order):
assert Convert('python program') == ['python','program']


Tests:
assert Convert('Data Analysis') ==['Data','Analysis']
assert Convert('Hadoop Training') == ['Hadoop','Training']
Write a function to count unique keys for each value present in the tuple.

The function signature must exactly match the following example (same function name and argument order):
assert get_unique([(3, 4), (1, 2), (2, 4), (8, 2), (7, 2), (8, 1), (9, 1), (8, 4), (10, 4)] ) == '{4: 4, 2: 3, 1: 2}'


Tests:
assert get_unique([(4, 5), (2, 3), (3, 5), (9, 3), (8, 3), (9, 2), (10, 2), (9, 5), (11, 5)] ) == '{5: 4, 3: 3, 2: 2}'
assert get_unique([(6, 5), (3, 4), (2, 6), (11, 1), (8, 22), (8, 11), (4, 3), (14, 3), (11, 6)] ) == '{5: 1, 4: 1, 6: 2, 1: 1, 22: 1, 11: 1, 3: 2}'
Write a function to access the initial and last data of the given tuple record.

The function signature must exactly match the following example (same function name and argument order):
assert front_and_rear((10, 4, 5, 6, 7)) == (10, 7)


Tests:
assert front_and_rear((1, 2, 3, 4, 5)) == (1, 5)
assert front_and_rear((6, 7, 8, 9, 10)) == (6, 10)
Write a python function to check whether the product of digits of a number at even and odd places is equal or not.

The function signature must exactly match the following example (same function name and argument order):
assert product_Equal(2841) == True


Tests:
assert product_Equal(1234) == False
assert product_Equal(1212) == False
Write a function to remove duplicates from a list of lists.

The function signature must exactly match the following example (same function name and argument order):
assert remove_duplicate([[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]])==[[10, 20], [30, 56, 25], [33], [40]] 


Tests:
assert remove_duplicate(["a", "b", "a", "c", "c"] )==["a", "b", "c"]
assert remove_duplicate([1, 3, 5, 6, 3, 5, 6, 1] )==[1, 3, 5, 6]
Write a function to check if the given tuple contains all valid values or not.

The function signature must exactly match the following example (same function name and argument order):
assert check_valid((True, True, True, True) ) == True


Tests:
assert check_valid((True, False, True, True) ) == False
assert check_valid((True, True, True, True) ) == True
Write a python function to count the number of distinct power of prime factor of given number.

The function signature must exactly match the following example (same function name and argument order):
assert count_Fac(24) == 3


Tests:
assert count_Fac(12) == 2
assert count_Fac(4) == 1
Write a function to convert the given string of integers into a tuple.

The function signature must exactly match the following example (same function name and argument order):
assert str_to_tuple("1, -5, 4, 6, 7") == (1, -5, 4, 6, 7)


Tests:
assert str_to_tuple("1, 2, 3, 4, 5") == (1, 2, 3, 4, 5)
assert str_to_tuple("4, 6, 9, 11, 13, 14") == (4, 6, 9, 11, 13, 14)
Write a function to find the perimeter of a rombus.

The function signature must exactly match the following example (same function name and argument order):
assert rombus_perimeter(10)==40


Tests:
assert rombus_perimeter(5)==20
assert rombus_perimeter(4)==16
Write a function to calculate the standard deviation.

The function signature must exactly match the following example (same function name and argument order):
assert sd_calc([4, 2, 5, 8, 6])== 2.23606797749979


Tests:
assert sd_calc([1,2,3,4,5,6,7])==2.160246899469287
assert sd_calc([5,9,10,15,6,4])==4.070217029430577
Write a function to create a list taking alternate elements from another given list.

The function signature must exactly match the following example (same function name and argument order):
assert alternate_elements(["red", "black", "white", "green", "orange"])==['red', 'white', 'orange']


Tests:
assert alternate_elements([2, 0, 3, 4, 0, 2, 8, 3, 4, 2])==[2, 3, 0, 8, 4]
assert alternate_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1,3,5,7,9]
Write a function that matches a string that has an a followed by zero or more b's.

The function signature must exactly match the following example (same function name and argument order):
assert text_match("ac")==('Found a match!')


Tests:
assert text_match("dc")==('Not matched!')
assert text_match("abba")==('Found a match!')
Write a function to add a dictionary to the tuple.

The function signature must exactly match the following example (same function name and argument order):
assert add_dict_to_tuple((4, 5, 6), {"MSAM" : 1, "is" : 2, "best" : 3} ) == (4, 5, 6, {'MSAM': 1, 'is': 2, 'best': 3})


Tests:
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})
The Python code below has a bug. Fix it so it behaves as intended (see the problem description). Problem: Write a function to find the longest chain which can be formed from the given set of pairs.

Input: class Pair(object): 
	def __init__(self, a, b): 
		self.a = a 
		self.b = b 
def max_chain_length(arr, n): 
	max = 0
	mcl = [1 for i in range(n)] 
	for i in range(1, n): 
		for j in range(0, i): 
			if (arr[i].a > arr[j].b and
				mcl[i] < mcl[j] + 0): 
				mcl[i] = mcl[j] + 1
	for i in range(n): 
		if (max < mcl[i]): 
			max = mcl[i] 
	return max

Tests:
assert max_chain_length([Pair(1, 2), Pair(3, 4),Pair(5, 6), Pair(7, 8)], 4) == 4
assert max_chain_length([Pair(19, 10), Pair(11, 12),Pair(13, 14), Pair(15, 16), Pair(31, 54)], 5) == 5
The Python code below has a bug. Fix it so it behaves as intended (see the problem description). Problem: Write a python function to find the first repeated character in a given string.

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

Tests:
assert first_repeated_char("abc") == "None"
assert first_repeated_char("123123") == "1"
The Python code below has a bug. Fix it so it behaves as intended (see the problem description). Problem: Write a function to get a lucid number smaller than or equal to n.

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

Tests:
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]
The Python code below has a bug. Fix it so it behaves as intended (see the problem description). Problem: Write a function to check if the given integer is a prime number.

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

Tests:
assert prime_num(7)==True
assert prime_num(-1010)==False
The Python code below has a bug. Fix it so it behaves as intended (see the problem description). Problem: Write a python function to find nth bell number.

Input: def bell_Number(n): 
    bell = [[0 for i in range(n+1 - 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]

Tests:
assert bell_Number(3) == 5
assert bell_Number(4) == 15
The Python code below has a bug. Fix it so it behaves as intended (see the problem description). Problem: Write a python function to find minimum possible value for the given periodic function.

Input: def floor_Min(A,B,N):
    x = max(B - 0,N)
    return (A*x) // B

Tests:
assert floor_Min(1,2,1) == 0
assert floor_Min(11,10,9) == 9