mr44/mbsearch huggingface dataset:
Task: Write a function to iterate over elements repeating each as many times as its count.

Solution:
from collections import Counter
def count_variable(a,b,c,d):
  c = Counter(p=a, q=b, r=c, s=d)
  return list(c.elements())


Tests:
assert count_variable(4,2,0,-2)==['p', 'p', 'p', 'p', 'q', 'q'] 
assert count_variable(0,1,2,3)==['q', 'r', 'r', 's', 's', 's'] 
assert count_variable(11,15,12,23)==['p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's']
Task: Write a function to check if two lists of tuples are identical or not.

Solution:
def check_identical(test_list1, test_list2):
  res = test_list1 == test_list2
  return (res) 


Tests:
assert check_identical([(10, 4), (2, 5)], [(10, 4), (2, 5)]) == True
assert check_identical([(1, 2), (3, 7)], [(12, 14), (12, 45)]) == False
assert check_identical([(2, 14), (12, 25)], [(2, 14), (12, 25)]) == True
Task: Write a function to abbreviate 'road' as 'rd.' in a given string.

Solution:
import re
def road_rd(street):
  return (re.sub('Road$', 'Rd.', street))


Tests:
assert road_rd("ravipadu Road")==('ravipadu Rd.')
assert road_rd("palnadu Road")==('palnadu Rd.')
assert road_rd("eshwar enclave Road")==('eshwar enclave Rd.')
Task: Write a function to find length of the string.

Solution:
def string_length(str1):
    count = 0
    for char in str1:
        count += 1
    return count


Tests:
assert string_length('python')==6
assert string_length('program')==7
assert string_length('language')==8
Task: Write a function to find the area of a rombus.

Solution:
def rombus_area(p,q):
  area=(p*q)/2
  return area


Tests:
assert rombus_area(10,20)==100
assert rombus_area(10,5)==25
assert rombus_area(4,2)==4
Task: Write a function to sort the given array without using any sorting algorithm. the given array consists of only 0, 1, and 2.

Solution:
def sort_by_dnf(arr, n):
  low=0
  mid=0
  high=n-1
  while mid <= high:
    if arr[mid] == 0:
      arr[low], arr[mid] = arr[mid], arr[low]
      low = low + 1
      mid = mid + 1
    elif arr[mid] == 1:
      mid = mid + 1
    else:
      arr[mid], arr[high] = arr[high], arr[mid]
      high = high - 1
  return arr


Tests:
assert sort_by_dnf([1,2,0,1,0,1,2,1,1], 9) == [0, 0, 1, 1, 1, 1, 1, 2, 2]
assert sort_by_dnf([1,0,0,1,2,1,2,2,1,0], 10) == [0, 0, 0, 1, 1, 1, 1, 2, 2, 2]
assert sort_by_dnf([2,2,1,0,0,0,1,1,2,1], 10) == [0, 0, 0, 1, 1, 1, 1, 2, 2, 2]
Task: Write a function to clear the values of the given tuples.

Solution:
def clear_tuple(test_tup):
  temp = list(test_tup)
  temp.clear()
  test_tup = tuple(temp)
  return (test_tup) 


Tests:
assert clear_tuple((1, 5, 3, 6, 8)) == ()
assert clear_tuple((2, 1, 4 ,5 ,6)) == ()
assert clear_tuple((3, 2, 5, 6, 8)) == ()
Task: Write a function to find numbers divisible by m or n from a list of numbers using lambda function.

Solution:
def div_of_nums(nums,m,n):
 result = list(filter(lambda x: (x % m == 0 or x % n == 0), nums)) 
 return result


Tests:
assert div_of_nums([19, 65, 57, 39, 152, 639, 121, 44, 90, 190],19,13)==[19, 65, 57, 39, 152, 190]
assert div_of_nums([1, 2, 3, 5, 7, 8, 10],2,5)==[2, 5, 8, 10]
assert div_of_nums([10,15,14,13,18,12,20],10,5)==[10, 15, 20]
Task: Write a python function to count lower case letters in a given string.

Solution:
def lower_ctr(str):
      lower_ctr= 0
      for i in range(len(str)):
          if str[i] >= 'a' and str[i] <= 'z': lower_ctr += 1     
      return  lower_ctr


Tests:
assert lower_ctr('abc') == 3
assert lower_ctr('string') == 6
assert lower_ctr('Python') == 5
Task: Write a function to count the frequency of consecutive duplicate elements in a given list of numbers.

Solution:
def count_duplic(lists):
    element = []
    frequency = []
    if not lists:
        return element
    running_count = 1
    for i in range(len(lists)-1):
        if lists[i] == lists[i+1]:
            running_count += 1
        else:
            frequency.append(running_count)
            element.append(lists[i])
            running_count = 1
    frequency.append(running_count)
    element.append(lists[i+1])
    return element,frequency



Tests:
assert count_duplic([1,2,2,2,4,4,4,5,5,5,5])==([1, 2, 4, 5], [1, 3, 3, 4])
assert count_duplic([2,2,3,1,2,6,7,9])==([2, 3, 1, 2, 6, 7, 9], [2, 1, 1, 1, 1, 1, 1])
assert count_duplic([2,1,5,6,8,3,4,9,10,11,8,12])==([2, 1, 5, 6, 8, 3, 4, 9, 10, 11, 8, 12], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
Task: Write a function to check whether the given month number contains 28 days or not.

Solution:
def check_monthnum_number(monthnum1):
  if monthnum1 == 2:
    return True
  else:
    return False


Tests:
assert check_monthnum_number(2)==True
assert check_monthnum_number(1)==False
assert check_monthnum_number(3)==False
Task: Write a function to merge two dictionaries into a single expression.

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


Tests:
assert merge_dictionaries({ "R": "Red", "B": "Black", "P": "Pink" }, { "G": "Green", "W": "White" })=={'B': 'Black', 'R': 'Red', 'P': 'Pink', 'G': 'Green', 'W': 'White'}
assert merge_dictionaries({ "R": "Red", "B": "Black", "P": "Pink" },{ "O": "Orange", "W": "White", "B": "Black" })=={'O': 'Orange', 'P': 'Pink', 'B': 'Black', 'W': 'White', 'R': 'Red'}
assert merge_dictionaries({ "G": "Green", "W": "White" },{ "O": "Orange", "W": "White", "B": "Black" })=={'W': 'White', 'O': 'Orange', 'G': 'Green', 'B': 'Black'}
Task: Write a function to return true if the password is valid.

Solution:
import re
def pass_validity(p):
 x = True
 while x:  
    if (len(p)<6 or len(p)>12):
        break
    elif not re.search("[a-z]",p):
        break
    elif not re.search("[0-9]",p):
        break
    elif not re.search("[A-Z]",p):
        break
    elif not re.search("[$#@]",p):
        break
    elif re.search("\s",p):
        break
    else:
        return True
        x=False
        break

 if x:
    return False


Tests:
assert pass_validity("password")==False
assert pass_validity("Password@10")==True
assert pass_validity("password@10")==False
Task: Write a function to check if the given string starts with a substring using regex.

Solution:
import re 
def check_substring(string, sample) : 
  if (sample in string): 
      y = "\A" + sample 
      x = re.search(y, string) 
      if x : 
          return ("string starts with the given substring") 
      else : 
          return ("string doesnt start with the given substring") 
  else : 
      return ("entered string isnt a substring")


Tests:
assert check_substring("dreams for dreams makes life fun", "makes") == 'string doesnt start with the given substring'
assert check_substring("Hi there how are you Hi alex", "Hi") == 'string starts with the given substring'
assert check_substring("Its been a long day", "been") == 'string doesnt start with the given substring'
Task: Write a python function to remove even numbers from a given list.

Solution:
def remove_even(l):
    for i in l:
        if i % 2 == 0:
            l.remove(i)
    return l


Tests:
assert remove_even([1,3,5,2]) == [1,3,5]
assert remove_even([5,6,7]) == [5,7]
assert remove_even([1,2,3,4]) == [1,3]
Task: Write a python function to access multiple elements of specified index from a given list.

Solution:
def access_elements(nums, list_index):
    result = [nums[i] for i in list_index]
    return result


Tests:
assert access_elements([2,3,8,4,7,9],[0,3,5]) == [2, 4, 9]
assert access_elements([1, 2, 3, 4, 5],[1,2]) == [2,3]
assert access_elements([1,0,2,3],[0,1]) == [1,0]
Task: Write a python function to find the type of triangle from the given sides.

Solution:
def check_Type_Of_Triangle(a,b,c): 
    sqa = pow(a,2) 
    sqb = pow(b,2) 
    sqc = pow(c,2) 
    if (sqa == sqa + sqb or sqb == sqa + sqc or sqc == sqa + sqb): 
        return ("Right-angled Triangle") 
    elif (sqa > sqc + sqb or sqb > sqa + sqc or sqc > sqa + sqb): 
        return ("Obtuse-angled Triangle") 
    else: 
        return ("Acute-angled Triangle") 


Tests:
assert check_Type_Of_Triangle(1,2,3) == "Obtuse-angled Triangle"
assert check_Type_Of_Triangle(2,2,2) == "Acute-angled Triangle"
assert check_Type_Of_Triangle(1,0,1) == "Right-angled Triangle"
Task: Write a function to sum a specific column of a list in a given list of lists.

Solution:
def sum_column(list1, C):
    result = sum(row[C] for row in list1)
    return result


Tests:
assert sum_column( [[1,2,3,2],[4,5,6,2],[7,8,9,5],],0)==12
assert sum_column( [[1,2,3,2],[4,5,6,2],[7,8,9,5],],1)==15
assert sum_column( [[1,2,3,2],[4,5,6,2],[7,8,9,5],],3)==9
Task: Write a function to count alphabets,digits and special charactes in a given string.

Solution:
def count_alpha_dig_spl(string):
  alphabets=digits = special = 0
  for i in range(len(string)):
    if(string[i].isalpha()):
        alphabets = alphabets + 1
    elif(string[i].isdigit()):
        digits = digits + 1
    else:
        special = special + 1
  return (alphabets,digits,special)   


Tests:
assert count_alpha_dig_spl("abc!@#123")==(3,3,3)
assert count_alpha_dig_spl("dgsuy@#$%&1255")==(5,4,5)
assert count_alpha_dig_spl("fjdsif627348#%$^&")==(6,6,5)
Task: Write a function to find out the second most repeated (or frequent) string in the given sequence.

Solution:
from collections import Counter 
	
def second_frequent(input): 
	dict = Counter(input) 
	value = sorted(dict.values(), reverse=True)  
	second_large = value[1] 
	for (key, val) in dict.items(): 
		if val == second_large: 
			return (key) 


Tests:
assert second_frequent(['aaa','bbb','ccc','bbb','aaa','aaa']) == 'bbb'
assert second_frequent(['abc','bcd','abc','bcd','bcd','bcd']) == 'abc'
assert second_frequent(['cdma','gsm','hspa','gsm','cdma','cdma']) == 'gsm'
Task: Write a function to round up a number to specific digits.

Solution:
import math
def round_up(a, digits):
    n = 10**-digits
    return round(math.ceil(a / n) * n, digits)


Tests:
assert round_up(123.01247,0)==124
assert round_up(123.01247,1)==123.1
assert round_up(123.01247,2)==123.02
Task: Write a python function to count equal element pairs from the given array.

Solution:
def count_Pairs(arr,n): 
    cnt = 0; 
    for i in range(n): 
        for j in range(i + 1,n): 
            if (arr[i] == arr[j]): 
                cnt += 1; 
    return cnt; 


Tests:
assert count_Pairs([1,1,1,1],4) == 6
assert count_Pairs([1,5,1],3) == 1
assert count_Pairs([3,2,1,7,8,9],6) == 0
Task: Write a function to extract the maximum numeric value from a string by using regex.

Solution:
import re 
def extract_max(input): 
	numbers = re.findall('\d+',input) 
	numbers = map(int,numbers) 
	return max(numbers)


Tests:
assert extract_max('100klh564abc365bg') == 564
assert extract_max('hello300how546mer231') == 546
assert extract_max('its233beenalong343journey234') == 343
Task: Write a function to get dictionary keys as a list.

Solution:
def get_key(dict): 
    list = [] 
    for key in dict.keys(): 
        list.append(key)           
    return list


Tests:
assert get_key({1:'python',2:'java'})==[1,2]
assert get_key({10:'red',20:'blue',30:'black'})==[10,20,30]
assert get_key({27:'language',39:'java',44:'little'})==[27,39,44]
Task: Write a function to generate a square matrix filled with elements from 1 to n raised to the power of 2 in spiral order.

Solution:
def generate_matrix(n):
        if n<=0:
            return [] 
        matrix=[row[:] for row in [[0]*n]*n]        
        row_st=0
        row_ed=n-1        
        col_st=0
        col_ed=n-1
        current=1        
        while (True):
            if current>n*n:
                break
            for c in range (col_st, col_ed+1):
                matrix[row_st][c]=current
                current+=1
            row_st+=1
            for r in range (row_st, row_ed+1):
                matrix[r][col_ed]=current
                current+=1
            col_ed-=1
            for c in range (col_ed, col_st-1, -1):
                matrix[row_ed][c]=current
                current+=1
            row_ed-=1
            for r in range (row_ed, row_st-1, -1):
                matrix[r][col_st]=current
                current+=1
            col_st+=1
        return matrix


Tests:
assert generate_matrix(3)==[[1, 2, 3], [8, 9, 4], [7, 6, 5]] 
assert generate_matrix(2)==[[1,2],[4,3]]
assert generate_matrix(7)==[[1, 2, 3, 4, 5, 6, 7], [24, 25, 26, 27, 28, 29, 8], [23, 40, 41, 42, 43, 30, 9], [22, 39, 48, 49, 44, 31, 10], [21, 38, 47, 46, 45, 32, 11], [20, 37, 36, 35, 34, 33, 12], [19, 18, 17, 16, 15, 14, 13]]
Task: Write a python function to find the slope of a line.

Solution:
def slope(x1,y1,x2,y2): 
    return (float)(y2-y1)/(x2-x1)  


Tests:
assert slope(4,2,2,5) == -1.5
assert slope(2,4,4,6) == 1
assert slope(1,2,4,2) == 0
Task: Write a function to find length of the subarray having maximum sum.

Solution:
from sys import maxsize 
def max_sub_array_sum(a,size): 
	max_so_far = -maxsize - 1
	max_ending_here = 0
	start = 0
	end = 0
	s = 0
	for i in range(0,size): 
		max_ending_here += a[i] 
		if max_so_far < max_ending_here: 
			max_so_far = max_ending_here 
			start = s 
			end = i 
		if max_ending_here < 0: 
			max_ending_here = 0
			s = i+1
	return (end - start + 1)


Tests:
assert max_sub_array_sum([-2, -3, 4, -1, -2, 1, 5, -3],8) == 5
assert max_sub_array_sum([1, -2, 1, 1, -2, 1],6) == 2
assert max_sub_array_sum([-1, -2, 3, 4, 5],5) == 3
Task: Write a python function to find the cube sum of first n odd natural numbers.

Solution:
def cube_Sum(n): 
    sum = 0   
    for i in range(0,n) : 
        sum += (2*i+1)*(2*i+1)*(2*i+1) 
    return sum


Tests:
assert cube_Sum(2) == 28
assert cube_Sum(3) == 153
assert cube_Sum(4) == 496
Task: Write a python function to find minimum number swaps required to make two binary strings equal.

Solution:
def min_Swaps(s1,s2) :  
    c0 = 0; c1 = 0;  
    for i in range(len(s1)) :  
        if (s1[i] == '0' and s2[i] == '1') : 
            c0 += 1;    
        elif (s1[i] == '1' and s2[i] == '0') : 
            c1 += 1;  
    result = c0 // 2 + c1 // 2;  
    if (c0 % 2 == 0 and c1 % 2 == 0) : 
        return result;  
    elif ((c0 + c1) % 2 == 0) : 
        return result + 2;  
    else : 
        return -1;  


Tests:
assert min_Swaps("0011","1111") == 1
assert min_Swaps("00011","01001") == 2
assert min_Swaps("111","111") == 0
Task: Write a function to sort the tuples alphabetically by the first item of each tuple.

Solution:
def sort_tuple(tup): 
	n = len(tup) 
	for i in range(n): 
		for j in range(n-i-1): 
			if tup[j][0] > tup[j + 1][0]: 
				tup[j], tup[j + 1] = tup[j + 1], tup[j] 
	return tup


Tests:
assert sort_tuple([("Amana", 28), ("Zenat", 30), ("Abhishek", 29),("Nikhil", 21), ("B", "C")]) == [('Abhishek', 29), ('Amana', 28), ('B', 'C'), ('Nikhil', 21), ('Zenat', 30)]
assert sort_tuple([("aaaa", 28), ("aa", 30), ("bab", 29), ("bb", 21), ("csa", "C")]) == [('aa', 30), ('aaaa', 28), ('bab', 29), ('bb', 21), ('csa', 'C')]
assert sort_tuple([("Sarala", 28), ("Ayesha", 30), ("Suman", 29),("Sai", 21), ("G", "H")]) == [('Ayesha', 30), ('G', 'H'), ('Sai', 21), ('Sarala', 28), ('Suman', 29)]
Task: Write a python function to check whether the roots of a quadratic equation are numerically equal but opposite in sign or not.

Solution:
def Check_Solution(a,b,c):  
    if b == 0:  
        return ("Yes")  
    else: 
        return ("No")  


Tests:
assert Check_Solution(2,0,-1) == "Yes"
assert Check_Solution(1,-5,6) == "No"
assert Check_Solution(2,0,2) == "Yes"
Task: Write a function to count the number of inversions in the given array.

Solution:
def get_inv_count(arr, n): 
	inv_count = 0
	for i in range(n): 
		for j in range(i + 1, n): 
			if (arr[i] > arr[j]): 
				inv_count += 1
	return inv_count 


Tests:
assert get_inv_count([1, 20, 6, 4, 5], 5) == 5
assert get_inv_count([8, 4, 2, 1], 4) == 6
assert get_inv_count([3, 1, 2], 3) == 2
Task: Write a function to find the number which occurs for odd number of times in the given array.

Solution:
def get_odd_occurence(arr, arr_size):
  for i in range(0, arr_size):
    count = 0
    for j in range(0, arr_size):
      if arr[i] == arr[j]:
        count += 1
    if (count % 2 != 0):
      return arr[i]
  return -1


Tests:
assert get_odd_occurence([2, 3, 5, 4, 5, 2, 4, 3, 5, 2, 4, 4, 2], 13) == 5
assert get_odd_occurence([1, 2, 3, 2, 3, 1, 3], 7) == 3
assert get_odd_occurence([5, 7, 2, 7, 5, 2, 5], 7) == 5
Task: Write a function to find the nth super ugly number from a given prime list of size k using heap queue algorithm.

Solution:
import heapq
def nth_super_ugly_number(n, primes):
    uglies = [1]
    def gen(prime):
        for ugly in uglies:
            yield ugly * prime
    merged = heapq.merge(*map(gen, primes))
    while len(uglies) < n:
        ugly = next(merged)
        if ugly != uglies[-1]:
            uglies.append(ugly)
    return uglies[-1]


Tests:
assert nth_super_ugly_number(12,[2,7,13,19])==32
assert nth_super_ugly_number(10,[2,7,13,19])==26
assert nth_super_ugly_number(100,[2,7,13,19])==5408
Task: Write a python function to find the kth element in an array containing odd elements first and then even elements.

Solution:
def get_Number(n, k): 
    arr = [0] * n; 
    i = 0; 
    odd = 1; 
    while (odd <= n):   
        arr[i] = odd; 
        i += 1; 
        odd += 2;
    even = 2; 
    while (even <= n): 
        arr[i] = even; 
        i += 1;
        even += 2; 
    return arr[k - 1]; 


Tests:
assert get_Number(8,5) == 2
assert get_Number(7,2) == 3
assert get_Number(5,2) == 3
Task: Write a python function to count the number of digits in factorial of a given number.

Solution:
import math 
def find_Digits(n): 
    if (n < 0): 
        return 0;
    if (n <= 1): 
        return 1; 
    x = ((n * math.log10(n / math.e) + math.log10(2 * math.pi * n) /2.0)); 
    return math.floor(x) + 1; 


Tests:
assert find_Digits(7) == 4
assert find_Digits(5) == 3
assert find_Digits(4) == 2
Task: Write a function to find the minimum number of platforms required for a railway/bus station.

Solution:
def find_platform(arr, dep, n): 
    arr.sort() 
    dep.sort() 
    plat_needed = 1
    result = 1
    i = 1
    j = 0
    while (i < n and j < n): 
        if (arr[i] <= dep[j]):           
            plat_needed+= 1
            i+= 1
        elif (arr[i] > dep[j]):           
            plat_needed-= 1
            j+= 1
        if (plat_needed > result):  
            result = plat_needed           
    return result


Tests:
assert find_platform([900, 940, 950, 1100, 1500, 1800],[910, 1200, 1120, 1130, 1900, 2000],6)==3
assert find_platform([100,200,300,400],[700,800,900,1000],4)==4
assert find_platform([5,6,7,8],[4,3,2,1],4)==1
Task: Write a python function to copy a list from a singleton tuple.

Solution:
def lcopy(xs):
  return xs[:]



Tests:
assert lcopy([1, 2, 3]) == [1, 2, 3]
assert lcopy([4, 8, 2, 10, 15, 18]) == [4, 8, 2, 10, 15, 18]
assert lcopy([4, 5, 6]) == [4, 5, 6]
Task: Write a function to find the area of a trapezium.

Solution:
def area_trapezium(base1,base2,height):
 area = 0.5 * (base1 + base2) * height
 return area


Tests:
assert area_trapezium(6,9,4)==30
assert area_trapezium(10,20,30)==450
assert area_trapezium(15,25,35)==700
Task: Write a python function to find sum of all prime divisors of a given number.

Solution:
def Sum(N): 
    SumOfPrimeDivisors = [0]*(N + 1)   
    for i in range(2,N + 1) : 
        if (SumOfPrimeDivisors[i] == 0) : 
            for j in range(i,N + 1,i) : 
                SumOfPrimeDivisors[j] += i           
    return SumOfPrimeDivisors[N] 


Tests:
assert Sum(60) == 10
assert Sum(39) == 16
assert Sum(40) == 7
Task: Write a function to check if a triangle of positive area is possible with the given angles.

Solution:
def is_triangleexists(a,b,c): 
    if(a != 0 and b != 0 and c != 0 and (a + b + c)== 180): 
        if((a + b)>= c or (b + c)>= a or (a + c)>= b): 
            return True 
        else:
            return False
    else:
        return False


Tests:
assert is_triangleexists(50,60,70)==True
assert is_triangleexists(90,45,45)==True
assert is_triangleexists(150,30,70)==False
Task: Write a python function to find sum of inverse of divisors.

Solution:
def Sum_of_Inverse_Divisors(N,Sum): 
    ans = float(Sum)*1.0 /float(N);  
    return round(ans,2); 


Tests:
assert Sum_of_Inverse_Divisors(6,12) == 2
assert Sum_of_Inverse_Divisors(9,13) == 1.44
assert Sum_of_Inverse_Divisors(1,4) == 4
Task: Write a python function to remove negative numbers from a list.

Solution:
def remove_negs(num_list): 
    for item in num_list: 
        if item < 0: 
           num_list.remove(item) 
    return num_list


Tests:
assert remove_negs([1,-2,3,-4]) == [1,3]
assert remove_negs([1,2,3,-4]) == [1,2,3]
assert remove_negs([4,5,-6,7,-8]) == [4,5,7]
Task: Write a python function to find sum of odd factors of a number.

Solution:
import math
def sum_of_odd_Factors(n): 
    res = 1
    while n % 2 == 0: 
        n = n // 2 
    for i in range(3,int(math.sqrt(n) + 1)): 
        count = 0
        curr_sum = 1
        curr_term = 1
        while n % i == 0: 
            count+=1 
            n = n // i 
            curr_term *= i 
            curr_sum += curr_term    
        res *= curr_sum  
    if n >= 2: 
        res *= (1 + n) 
    return res 


Tests:
assert sum_of_odd_Factors(30) == 24
assert sum_of_odd_Factors(18) == 13
assert sum_of_odd_Factors(2) == 1
Task: Write a function which accepts an arbitrary list and converts it to a heap using heap queue algorithm.

Solution:
import heapq as hq
def raw_heap(rawheap):
  hq.heapify(rawheap)
  return rawheap


Tests:
assert raw_heap([25, 44, 68, 21, 39, 23, 89])==[21, 25, 23, 44, 39, 68, 89]
assert raw_heap([25, 35, 22, 85, 14, 65, 75, 25, 58])== [14, 25, 22, 25, 35, 65, 75, 85, 58]
assert raw_heap([4, 5, 6, 2])==[2, 4, 6, 5]
Task: Write a python function to check for even parity of a given number.

Solution:
def check_Even_Parity(x): 
    parity = 0
    while (x != 0): 
        x = x & (x - 1) 
        parity += 1
    if (parity % 2 == 0): 
        return True
    else: 
        return False


Tests:
assert check_Even_Parity(10) == True
assert check_Even_Parity(11) == False
assert check_Even_Parity(18) == True
Task: Write a python function to find minimum adjacent swaps required to sort binary array.

Solution:
def find_Min_Swaps(arr,n) : 
    noOfZeroes = [0] * n 
    count = 0 
    noOfZeroes[n - 1] = 1 - arr[n - 1] 
    for i in range(n-2,-1,-1) : 
        noOfZeroes[i] = noOfZeroes[i + 1] 
        if (arr[i] == 0) : 
            noOfZeroes[i] = noOfZeroes[i] + 1
    for i in range(0,n) : 
        if (arr[i] == 1) : 
            count = count + noOfZeroes[i] 
    return count 


Tests:
assert find_Min_Swaps([1,0,1,0],4) == 3
assert find_Min_Swaps([0,1,0],3) == 1
assert find_Min_Swaps([0,0,1,1,0],5) == 2
Task: Write a function to list out the list of given strings individually using map function.

Solution:
def listify_list(list1):
  result = list(map(list,list1)) 
  return result 


Tests:
assert listify_list(['Red', 'Blue', 'Black', 'White', 'Pink'])==[['R', 'e', 'd'], ['B', 'l', 'u', 'e'], ['B', 'l', 'a', 'c', 'k'], ['W', 'h', 'i', 't', 'e'], ['P', 'i', 'n', 'k']]
assert listify_list(['python'])==[['p', 'y', 't', 'h', 'o', 'n']]
assert listify_list([' red ', 'green',' black', 'blue ',' orange', 'brown'])==[[' ', 'r', 'e', 'd', ' '], ['g', 'r', 'e', 'e', 'n'], [' ', 'b', 'l', 'a', 'c', 'k'], ['b', 'l', 'u', 'e', ' '], [' ', 'o', 'r', 'a', 'n', 'g', 'e'], ['b', 'r', 'o', 'w', 'n']]
Task: Write a function to count number of lists in a given list of lists and square the count.

Solution:
def count_list(input_list): 
    return (len(input_list))**2


Tests:
assert count_list([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==25
assert count_list([[1, 3], [5, 7], [9, 11], [13, 15, 17]] )==16
assert count_list([[2, 4], [[6,8], [4,5,8]], [10, 12, 14]])==9