diff --git "a/Results/Code/generations_mbpp.json" "b/Results/Code/generations_mbpp.json" new file mode 100644--- /dev/null +++ "b/Results/Code/generations_mbpp.json" @@ -0,0 +1 @@ +[["\"\"\"\nWrite a python function to remove first and last occurrence of a given character from the string.\nassert remove_Occ(\"hello\",\"l\") == \"heo\"\n\"\"\"\ndef remove_Occ(string, char):\n if char in string:\n string = string.replace(char, '')\n return string\n"], ["\"\"\"\nWrite a function to sort a given matrix in ascending order according to the sum of its rows.\nassert sort_matrix([[1, 2, 3], [2, 4, 5], [1, 1, 1]])==[[1, 1, 1], [1, 2, 3], [2, 4, 5]]\n\"\"\"\ndef sort_matrix(matrix):\n matrix.sort(key = lambda x: sum(x))\n return matrix\n"], ["\"\"\"\nWrite a function to count the most common words in a dictionary.\nassert count_common(['red','green','black','pink','black','white','black','eyes','white','black','orange','pink','pink','red','red','white','orange','white',\"black\",'pink','green','green','pink','green','pink','white','orange',\"orange\",'red']) == [('pink', 6), ('black', 5), ('white', 5), ('red', 4)]\n\"\"\"\nfrom collections import Counter\nfrom typing import List\n\ndef count_common(words: List[str]) -> int:\n words_counter = Counter(words)\n most_common = words_counter.most_common(1)\n return most_common\n"], ["\"\"\"\nWrite a python function to find the volume of a triangular prism.\nassert find_Volume(10,8,6) == 240\n\"\"\"\nimport math\n\ndef find_Volume(base1, base2, base3):\n volume = (base1 * base2 * base3) / 3\n return volume\n"], ["\"\"\"\nWrite a function to split a string at lowercase letters.\nassert split_lowerstring(\"AbCd\")==['bC','d']\n\"\"\"\ndef split_lowerstring(string):\n return string.split('a') #split at a\n"], ["\"\"\"\nWrite a function to find sequences of lowercase letters joined with an underscore.\nassert text_lowercase_underscore(\"aab_cbbbc\")==('Found a match!')\n\"\"\"\ndef find_sequences(text):\n sequences = []\n for i in range(len(text)-1):\n if text[i] == text[i+1]:\n sequences.append(text[i])\n return sequences\n"], ["\"\"\"\nWrite a function to find the perimeter of a square.\nassert square_perimeter(10)==40\n\"\"\"\ndef square_perimeter(side):\n perimeter = 4 * side\n return perimeter\n"], ["\"\"\"\nWrite a function to remove characters from the first string which are present in the second string.\nassert remove_dirty_chars(\"probasscurve\", \"pros\") == 'bacuve'\n\"\"\"\ndef remove_dirty_chars(str1, str2):\n return ''.join([c for c in str1 if c not in str2]) \n"], ["\"\"\"\nWrite a function to find whether a given array of integers contains any duplicate element.\nassert test_duplicate(([1,2,3,4,5]))==False\n\"\"\"\ndef find_duplicate(nums):\n for i in range(len(nums)-1):\n if nums[i] == nums[i+1]:\n return True\n return False\n"], ["\"\"\"\nWrite a function to check if the given number is woodball or not.\nassert is_woodall(383) == True\n\"\"\"\ndef is_woodall(n):\n if n % 10 == 3:\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a function to find m number of multiples of n.\nassert multiples_of_num(4,3)== [3,6,9,12]\n\"\"\"\ndef multiples_of_num(n, m):\n multiples = []\n for i in range(1, m + 1):\n if i % n == 0:\n multiples.append(i)\n return multiples\n"], ["\"\"\"\nWrite a function to find the first duplicate element in a given array of integers.\nassert find_first_duplicate(([1, 2, 3, 4, 4, 5]))==4\n\"\"\"\ndef find_first_duplicate(nums):\n for i in range(len(nums)):\n if nums[i] == nums[i+1]:\n return nums[i]\n return None\n"], ["\"\"\"\nWrite a python function to find the maximum sum of elements of list in a list of lists.\nassert maximum_Sum([[1,2,3],[4,5,6],[10,11,12],[7,8,9]]) == 33\n\"\"\"\ndef maximum_Sum(list_of_lists):\n max_sum = 0\n for list in list_of_lists:\n for sublist in list:\n max_sum = max(max_sum, sum(sublist))\n return max_sum\n"], ["\"\"\"\nWrite a function to convert the given binary number to its decimal equivalent.\nassert binary_to_decimal(100) == 4\n\"\"\"\ndef binary_to_decimal(binary):\n decimal = 0\n for i in range(len(binary)):\n decimal += int(binary[i]) * 2 ** (len(binary) - 1 - i)\n return decimal\n"], ["\"\"\"\nWrite a python function to find the product of non-repeated elements in a given array.\nassert find_Product([1,1,2,3],4) == 6\n\"\"\"\ndef find_Product(arr, n):\n product = 1\n for i in arr:\n if i != n:\n product *= i\n return product\n\narr = [1,1,2,3]\nn = 4"], ["\"\"\"\nWrite a function to check if the given tuple list has all k elements.\nassert check_k_elements([(4, 4), (4, 4, 4), (4, 4), (4, 4, 4, 4), (4, )], 4) == True\n\"\"\"\ndef check_k_elements(tup_list, k):\n if len(tup_list) == k:\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a python function to remove all digits from a list of strings.\nassert remove(['4words', '3letters', '4digits']) == ['words', 'letters', 'digits']\n\"\"\"\ndef remove(string_list):\n return [string for string in string_list if not any(char.isdigit() for char in string)]\n\n"], ["\"\"\"\nWrite a python function to find binomial co-efficient.\nassert binomial_Coeff(5,2) == 10\n\"\"\"\nfrom math import comb\n\ndef binomial_Coeff(n, k):\n return comb(n, k)\n"], ["\"\"\"\nWrite a python function to find the element occurring odd number of times.\nassert get_Odd_Occurrence([1,2,3,1,2,3,1],7) == 1\n\"\"\"\ndef get_Odd_Occurrence(arr, n):\n count = {}\n for i in arr:\n if i in count:\n count[i] += 1\n else:\n count[i] = 1\n return [k for k, v in count.items() if v % 2 != 0] \n"], ["\"\"\"\nWrite a python function to count all the substrings starting and ending with same characters.\nassert count_Substring_With_Equal_Ends(\"abc\") == 3\n\"\"\"\ndef count_substring_with_equal_ends(s):\n count = 0\n for i in range(len(s)):\n for j in range(i+1, len(s)+1):\n if s[i:j] == s[i:j][::-1]:\n count += 1\n return count\n"], ["\"\"\"\nWrite a function to find the top k integers that occur most frequently from given lists of sorted and distinct integers using heap queue algorithm.\nassert func([[1, 2, 6], [1, 3, 4, 5, 7, 8], [1, 3, 5, 6, 8, 9], [2, 5, 7, 11], [1, 4, 7, 8, 12]],3)==[5, 7, 1]\n\"\"\"\nfrom heapq import *\nfrom collections import Counter\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap, num)\n if len(heap) > k:\n heappop(heap)\n return list(heappop(heap))\n\ndef top_k(nums, k):\n heap = []\n for num in nums:\n heappush(heap,"], ["\"\"\"\nWrite a python function to find the largest prime factor of a given number.\nassert max_Prime_Factors(15) == 5\n\"\"\"\ndef max_prime_factors(n):\n i = 2\n factors = []\n while i * i <= n:\n if n % i:\n i += 1\n else:\n n //= i\n factors.append(i)\n if n > 1:\n factors.append(n)\n return max(factors)\n"], ["\"\"\"\nWrite a python function to convert a decimal number to binary number.\nassert decimal_To_Binary(10) == 1010\n\"\"\"\ndef decimal_to_binary(decimal):\n binary = \"\"\n while decimal > 0:\n binary = str(decimal % 2) + binary\n decimal = decimal // 2\n return binary\n"], ["\"\"\"\nWrite a python function to find the missing number in a sorted array.\nassert find_missing([1,2,3,5],4) == 4\n\"\"\"\ndef find_missing(nums, target):\n if len(nums) == 0:\n return target\n for i in range(len(nums)):\n if nums[i] == target:\n continue\n else:\n return i + 1\n return target + len(nums) - 1\n\nnums = [1,2,3,5]\ntarget = 4"], ["\"\"\"\nWrite a function to find the n-th rectangular number.\nassert find_rect_num(4) == 20\n\"\"\"\ndef find_rect_num(n):\n if n == 1:\n return 1\n else:\n return find_rect_num(n-1) + 1\n"], ["\"\"\"\nWrite a python function to find the nth digit in the proper fraction of two given numbers.\nassert find_Nth_Digit(1,2,1) == 5\n\"\"\"\ndef find_Nth_Digit(n, num1, num2):\n if n > num1 or n > num2:\n return \"Invalid input\"\n else:\n return num1//num2**n\n"], ["\"\"\"\nWrite a function to sort a given mixed list of integers and strings.\nassert sort_mixed_list([19,'red',12,'green','blue', 10,'white','green',1])==[1, 10, 12, 19, 'blue', 'green', 'green', 'red', 'white']\n\"\"\"\ndef sort_mixed_list(lst):\n lst.sort()\n return lst\n"], ["\"\"\"\nWrite a function to find the division of first even and odd number of a given list.\nassert div_even_odd([1,3,5,7,4,1,6,8])==4\n\"\"\"\ndef div_even_odd(lst):\n even = 0\n odd = 0\n for i in lst:\n if i % 2 == 0:\n even += 1\n else:\n odd += 1\n return even, odd\n"], ["\"\"\"\nWrite a function to check if the letters of a given string can be rearranged so that two characters that are adjacent to each other are different.\nassert rearange_string(\"aab\")==('aba')\n\"\"\"\ndef rearange_string(s):\n s = list(s)\n s.sort()\n s = ''.join(s)\n if s == s[::-1]:\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a function to find frequency of the elements in a given list of lists using collections module.\nassert freq_element([[1, 2, 3, 2], [4, 5, 6, 2], [7, 1, 9, 5]])==({2: 3, 1: 2, 5: 2, 3: 1, 4: 1, 6: 1, 7: 1, 9: 1})\n\"\"\"\nfrom collections import Counter\n\ndef freq_element(lst):\n counter = Counter(lst)\n return dict(counter) # return a dictionary of the counter object\n"], ["\"\"\"\nWrite a function to filter even numbers using lambda function.\nassert filter_evennumbers([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[2, 4, 6, 8, 10]\n\"\"\"\ndef filter_evennumbers(numbers):\n return list(filter(lambda x: x % 2 == 0, numbers))\n"], ["\"\"\"\nWrite a python function to find the sum of repeated elements in a given array.\nassert find_Sum([1,2,3,1,1,4,5,6],8) == 3\n\"\"\"\ndef find_Sum(arr, n):\n sum = 0\n for i in arr:\n if arr.count(i) > 1:\n sum += i\n return sum\n\narr = [1,2,3,1,1,4,5,6]\nn = 8"], ["\"\"\"\nWrite a function to find sequences of lowercase letters joined with an underscore using regex.\nassert text_match(\"aab_cbbbc\") == 'Found a match!'\n\"\"\"\nimport re\n\ndef text_match(text):\n pattern = r'[a-z]+_[a-z]+'\n matches = re.findall(pattern, text)\n return matches\n"], ["\"\"\"\nWrite a function that matches a word at the beginning of a string.\nassert text_match_string(\" python\")==('Not matched!')\n\"\"\"\ndef text_match_string(text):\n if text.startswith(\"python\"):\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a function to find the gcd of the given array elements.\nassert get_gcd([2, 4, 6, 8, 16]) == 2\n\"\"\"\ndef get_gcd(arr):\n gcd = arr[0]\n for i in range(1, len(arr)):\n gcd = get_gcd(arr[i])\n return gcd\n"], ["\"\"\"\nWrite a python function to determine whether all the numbers are different from each other are not.\nassert test_distinct([1,5,7,9]) == True\n\"\"\"\ndef test_distinct(arr):\n if len(set(arr)) == len(arr):\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a python function to find the last digit when factorial of a divides factorial of b.\nassert compute_Last_Digit(2,4) == 2\n\"\"\"\ndef compute_Last_Digit(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return (a*b) % (a+b)\n"], ["\"\"\"\nWrite a python function to set all odd bits of a given number.\nassert odd_bit_set_number(10) == 15\n\"\"\"\ndef odd_bit_set_number(n):\n return (n & 1) << 1\n"], ["\"\"\"\nWrite a function to extract every first or specified element from a given two-dimensional list.\nassert specified_element([[1, 2, 3, 2], [4, 5, 6, 2], [7, 1, 9, 5]],0)==[1, 4, 7]\n\"\"\"\ndef extract_elements(matrix, element):\n result = []\n for row in matrix:\n for element in row:\n if element == element:\n result.append(element)\n return result\n"], ["\"\"\"\nWrite a function to find the list with minimum length using lambda function.\nassert min_length_list([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==(1, [0])\n\"\"\"\ndef min_length_list(lst):\n return min(lst, key=lambda x: len(x))\n"], ["\"\"\"\nWrite a function to print check if the triangle is equilateral or not.\nassert check_equilateral(6,8,12)==False \n\"\"\"\ndef check_equilateral(a,b,c):\n if a==b==c:\n print(\"Equilateral\")\n else:\n print(\"Not Equilateral\")\n\ncheck_equilateral(6,8,12) #False\ncheck_equilateral(6,8,13) #True\ncheck_equilateral(6,8,14) #False\ncheck_equilateral(6,8,15) #True\ncheck_equilateral(6,8,16) #False\ncheck_equilateral(6,8,17) #True\ncheck_equilateral(6,8,18) #False\ncheck_equilateral(6,8,19) #True\ncheck_equilateral(6,8,20) #False\ncheck_equilateral(6,8,21) #True\ncheck_equilateral(6,8,22) #False\ncheck_equilateral(6,8,23) #True\ncheck_equilateral(6,8,24) #False\ncheck_equilateral(6,8,25) #True\ncheck_equilateral(6,8,26) #False\ncheck_equilateral(6,8,27) #True\ncheck_equilateral(6,8,28) #False\ncheck_equilateral(6,8,29) #True\ncheck_equilateral(6,8,30) #False\ncheck_equilateral(6,8,31) #True\ncheck_equilateral(6,8,32) #False\ncheck_equilateral(6,8,33) #True\ncheck_equilateral(6,8,34) #False\ncheck_equilateral(6,8,35) #True\ncheck_equilateral(6,8,36) #False\ncheck_equilateral(6,8,37) #True\ncheck_equilateral(6,8,38) #False\ncheck_equilateral(6,8,39) #True\ncheck_equilateral(6,8,40) #False\ncheck_equilateral(6,8,41) #True\ncheck_equilateral(6,8,42) #False\ncheck_equilateral(6,8,43) #True\ncheck_equilateral(6,8,44) #False\ncheck_equilateral(6,8,45) #True\ncheck_equilateral(6,8,46) #False\ncheck_equilateral(6,8,47) #True\ncheck_equilateral(6,8,48) #False\ncheck_equilateral(6,8,49) #True\ncheck_equilateral(6,8,50) #False\ncheck_equilateral(6,8,51) #True\ncheck_equilateral(6,8,52) #False\ncheck_equilateral(6,8,53) #True\ncheck_equilateral(6,8,54) #False\ncheck_equilateral(6,8,55) #True\ncheck_equilateral(6,8,56) #False\ncheck_equilateral(6,8,57) #True\ncheck_equilateral(6,8,58) #False\ncheck_equilateral(6,8,59) #True\ncheck_equilateral(6,8,60) #False\ncheck_equilateral(6,8,61) #True\ncheck_equilateral(6,8,62) #False\ncheck_equilateral(6,8,63) #True\ncheck_equilateral(6,8,64) #False\ncheck_equilateral(6,8,65) #True\ncheck_equilateral(6,8,66) #False\ncheck_equilateral(6,8,67) #True\ncheck_equilateral(6,8,68) #False\ncheck_equilateral(6,8,69) #True\ncheck_equilateral(6,8,70) #False\ncheck_equilateral(6,8,71) #True\ncheck_equilateral(6,8,72) #False\ncheck_equilateral(6,8,73) #True\ncheck_equilateral(6,8,74) #False\ncheck_equilateral(6,8,75) #True\ncheck_equilateral(6,8,76) #False\ncheck_equilateral(6,8,77) #True\ncheck_equilateral(6,8,78) #False\ncheck_equilateral(6,8,79) #True\ncheck_equilateral(6,8,80) #False\ncheck_equilateral(6,8,81) #True\ncheck_equilateral(6,8,82) #False\ncheck_equilateral(6,8,83) #True\ncheck_equilateral(6,8,84) #False\ncheck_equilateral(6,8,85) #True\ncheck_equilateral(6,8,86) #False\ncheck_equilateral(6,8,87) #True\ncheck_equilateral(6,8,88) #False\ncheck_equilateral(6,8,89) #True\ncheck_equilateral(6,8,90) #False\ncheck_equilateral(6,8,91) #True\ncheck_equilateral(6,8,92) #False\ncheck_equilateral(6,8,93) #True\ncheck_equilateral(6,8,94) #False\ncheck_equilateral(6,8,95) #True\ncheck_equilateral(6,8,96) #False\ncheck_equilateral(6,8,97) #True\ncheck_equilateral(6,8,98) #False\ncheck_equilateral(6,8,99) #True\ncheck_equilateral(6,8,100) #False\ncheck_equilateral(6,8,101) #True\ncheck_equilateral(6,8,102) #False\ncheck_equilateral(6,8,103) #True\ncheck_equilateral(6,8,104) #False\ncheck_equilateral(6,8,105) #True\ncheck_equilateral(6,8,106) #False\ncheck_equilateral(6,8,107) #True\ncheck_equilateral(6,8,108) #False\ncheck_equilateral(6,8,109) #True\ncheck_equilateral(6,8,110) #False\ncheck_equilateral(6,8,111) #True\ncheck_equilateral(6,8,112) #False\ncheck_equilateral(6,8,113) #True\ncheck_equilateral(6,8,114) #False\ncheck_equilateral(6,8,115) #True\ncheck_equilateral(6,8,116) #False\ncheck_equilateral(6,8,117) #True\ncheck_equilateral(6,8,118) #False\ncheck_equilateral(6,8,119) #True\ncheck_equilateral(6,8,120) #False\ncheck_equilateral(6,8,121) #True\ncheck_equilateral(6,8,122) #False\ncheck_equilateral(6,8,123) #True\ncheck_equilateral(6,8,124) #False\ncheck_equilateral(6,8,125) #True\ncheck_equilateral(6,8,126) #False\ncheck_equilateral(6,8,127) #True\ncheck_equilateral(6,8,128) #False\ncheck_equilateral(6,8,129) #True\ncheck_equilateral(6,8,130) #False\ncheck_equilateral(6,8,131) #True\ncheck_equilateral(6,8,132) #False\ncheck_equilateral(6,8,133) #True\ncheck_equilateral(6,8,134) #False\ncheck_equilateral(6,8,135) #True\ncheck_equilateral(6,8,136) #False\ncheck_equilateral(6,8,137) #True\ncheck_equilateral(6,8,138) #False\ncheck_equilateral(6,8,139) #True\ncheck_equilateral(6,8,140) #False\ncheck_equilateral(6,8,141) #True\ncheck_equilateral(6,8,142) #False\ncheck_equilateral(6,8,143) #True\ncheck_equilateral(6,8,144) #False\ncheck_equilateral(6,8,145) #True\ncheck_equilateral(6,8,146) #False\ncheck_equilateral(6,8,147) #True\ncheck_equilateral(6,8,148) #False\ncheck_equilateral(6,8,149) #True\ncheck_equilateral(6,8,150) #False\ncheck_equilateral(6,8,151) #True\ncheck_equilateral("], ["\"\"\"\nWrite a function to caluclate area of a parallelogram.\nassert parallelogram_area(10,20)==200\n\"\"\"\ndef parallelogram_area(a,b):\n return a*b\n"], ["\"\"\"\nWrite a python function to check whether the first and last characters of a given string are equal or not.\nassert check_Equality(\"abcda\") == \"Equal\"\n\"\"\"\ndef check_Equality(string):\n if len(string) > 1:\n if string[0] == string[-1]:\n return True\n else:\n return False\n else:\n return False\n"], ["\"\"\"\nWrite a function to sort the given array by using counting sort.\nassert counting_sort([1,23,4,5,6,7,8]) == [1, 4, 5, 6, 7, 8, 23]\n\"\"\"\ndef counting_sort(arr):\n max_val = max(arr)\n count = [0] * (max_val + 1)\n for i in arr:\n count[i] += 1\n output = [0] * len(arr)\n for i in range(max_val, -1, -1):\n output[count[i]-1] = i\n count[i] -= 1\n for i in range(len(arr)):\n arr[i] = output[i]\n return arr\n\narr = [1,23,4,5,6,7,8]"], ["\"\"\"\nWrite a function to find t-nth term of geometric series.\nassert tn_gp(1,5,2)==16\n\"\"\"\ndef find_t_nth_term_of_geometric_series(n, r, t):\n if r == 0 or t == 0:\n return 0\n else:\n return r * t**(n-1)\n"], ["\"\"\"\nWrite a python function to check if a given number is one less than twice its reverse.\nassert check(70) == False\n\"\"\"\ndef check(n):\n reverse = n[::-1]\n if n == reverse + reverse:\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a python function to find the largest number that can be formed with the given digits.\nassert find_Max_Num([1,2,3],3) == 321\n\"\"\"\ndef find_Max_Num(digits, num):\n max_num = 0\n for i in digits:\n max_num = max(max_num, int(i) * num)\n return max_num\n"], ["\"\"\"\nWrite a python function to check whether the given two integers have opposite sign or not.\nassert opposite_Signs(1,-2) == True\n\"\"\"\ndef opposite_Signs(a,b):\n if a<0 and b>0:\n return True\n elif a>0 and b<0:\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a function to find the nth octagonal number.\nassert is_octagonal(5) == 65\n\"\"\"\ndef nth_octagonal_number(n):\n if n == 0:\n return 1\n else:\n return nth_octagonal_number(n-1) + 5*n\n"], ["\"\"\"\nWrite a function to find the maximum length of the subsequence with difference between adjacent elements for the given array.\nassert max_len_sub([2, 5, 6, 3, 7, 6, 5, 8], 8) == 5\n\"\"\"\ndef max_len_sub(arr, diff):\n if len(arr) == 0:\n return 0\n if len(arr) == 1:\n return 1\n if len(arr) == 2:\n return 2\n if len(arr) == 3:\n return 3\n if len(arr) == 4:\n return 4\n if len(arr) == 5:\n return 5\n if len(arr) == 6:\n return 6\n if len(arr) == 7:\n return 7\n if len(arr) == 8:\n return 8\n if len(arr) == 9:\n return 9\n if len(arr) == 10:\n return 10\n if len(arr) == 11:\n return 11\n if len(arr) == 12:\n return 12\n if len(arr) == 13:\n return 13\n if len(arr) == 14:\n return 14\n if len(arr) == 15:\n return 15\n if len(arr) == 16:\n return 16\n if len(arr) == 17:\n return 17\n if len(arr) == 18:\n return 18\n if len(arr) == 19:\n return 19\n if len(arr) == 20:\n return 20\n if len(arr) == 21:\n return 21\n if len(arr) == 22:\n return 22\n if len(arr) == 23:\n return 23\n if len(arr) == 24:\n return 24\n if len(arr) == 25:\n return 25\n if len(arr) == 26:\n return 26\n if len(arr) == 27:\n return 27\n if len(arr) == 28:\n return 28\n if len(arr) == 29:\n return 29\n if len(arr) == 30:\n return 30\n if len(arr) == 31:\n return 31\n if len(arr) == 32:\n return 32\n if len(arr) == 33:\n return 33\n if len(arr) == 34:\n return 34\n if len(arr) == 35:\n return 35\n if len(arr) == 36:\n return 36\n if len(arr) == 37:\n return 37\n if len(arr) == 38:\n return 38\n if len(arr) == 39:\n return 39\n if len(arr) == 40:\n return 40\n if len(arr) == 41:\n return 41\n if len(arr) == 42:\n return 42\n if len(arr) == 43:\n return 43\n if len(arr) == 44:\n return 44\n if len(arr) == 45:\n return 45\n if len(arr) == 46:\n return 46\n if len(arr) == 47:\n return 47\n if len(arr) == 48:\n return 48\n if len(arr) == 49:\n return 49\n if len(arr) == 50:\n return 50\n if len(arr) == 51:\n return 51\n if len(arr) == 52:\n return 52\n if len(arr) == 53:\n return 53\n if len(arr) == 54:\n return 54\n if len(arr) == 55:\n return 55\n if len(arr) == 56:\n return 56\n if len(arr) == 57:\n return 57\n if len(arr) == 58:\n return 58\n if len(arr) == 59:\n return 59\n if len(arr) == 60:\n return 60\n if len(arr) == 61:\n return 61\n if len(arr) == 62:\n return 62\n if len(arr) == 63:\n return 63\n if len(arr) == 64:\n return 64\n if len(arr) == 65:\n return 65\n if len(arr) == 66:\n return 66\n if len(arr) == 67:\n return 67\n if len(arr) == 68:\n return 68\n if len(arr) == 69:\n return 69\n if len(arr) == 70:\n return 70\n if len(arr) == 71:\n return 71\n if len(arr) == 72:\n return 72\n if len(arr) == 73:\n return 73\n if len(arr) == 74:\n return 74\n if len(arr) == 75:\n return 75\n if len(arr) == 76:\n return 76\n if len(arr) == 77:\n return 77\n if len(arr) == 78:\n return 78\n if len(arr) == 79:\n return 79\n if len(arr) == 80:\n return 80\n if len(arr) == 81:\n return 81\n if len(arr) == 82:\n return 82\n if len(arr) == 83:\n return 83\n if len(arr) == 84:\n return 84\n if len(arr) == 85:\n return 85\n if len(arr) == 86:\n return 86\n if len(arr) == 87:\n return 87\n if len(arr) == 88:\n return 88\n if len(arr) == 89:\n return 89\n if len(arr) == 90:\n return 90\n if len(arr) == 91:\n return 91\n if len(arr) == 92:\n return 92\n if len(arr) == 93:\n return 93\n if len(arr) == 94:\n return 94\n if len(arr) == 95:\n return 95\n if len(arr) == 96:\n return 96\n if len(arr) == 97:\n return 97\n if len(arr) == 98:\n return 98\n if len(arr) == 99:\n return 99\n if len(arr) == 100:\n return 100\n if len(arr) == 101:\n return 101\n if len(arr) == 102:\n return 102\n if len(arr) == 103:\n return 103\n if len(arr) == 104:\n return 104\n if len(arr) == 105:\n return 105\n if len(arr) == 106:\n return 106\n if len(arr) == 107:\n return 107\n if len(arr) == 108:\n return 108\n if len(arr) == 109:\n return 109\n if len(arr) == 110:\n return 110\n if len(arr) == 111:\n return 111\n if len(arr) == 112:\n return 112\n if len(arr) == 113:\n return 113\n if len(arr) == 114:\n return 114\n if len(arr) == 115:\n return 115\n if len(arr) == 116:\n return 116\n if len(arr) == 117:\n return 117\n if len(arr) == 118:\n return 118\n if len(arr) == 119:\n return 119\n if len(arr) == 120:\n return 120\n if len(arr) == 121:\n return 121\n if len(arr) == 122:\n return 122\n if len(arr) == 123:\n return 123\n if len(arr) == 124:\n return 124\n if len(arr) == 125"], ["\"\"\"\nWrite a python function to count number of substrings with the sum of digits equal to their length.\nassert count_Substrings('112112',6) == 6\n\"\"\"\ndef count_Substrings(s, n):\n count = 0\n for i in range(len(s)):\n for j in range(i+1, len(s)+1):\n if sum(int(digit) for digit in s[i:j]) == len(s[i:j]):\n count += 1\n return count\n"], ["\"\"\"\nWrite a python function to find smallest number in a list.\nassert smallest_num([10, 20, 1, 45, 99]) == 1\n\"\"\"\ndef smallest_num(lst):\n if len(lst) == 0:\n return None\n else:\n return min(lst)\n"], ["\"\"\"\nWrite a function to find the maximum difference between available pairs in the given tuple list.\nassert max_difference([(3, 5), (1, 7), (10, 3), (1, 2)]) == 7\n\"\"\"\nfrom typing import List\n\n\ndef max_difference(t: List[int]) -> int:\n if len(t) < 2:\n return 0\n min_val = t[0]\n max_val = t[0]\n for i in range(1, len(t)):\n if t[i] < min_val:\n min_val = t[i]\n elif t[i] > max_val:\n max_val = t[i]\n return max_val - min_val\n\n"], ["\"\"\"\nWrite a function to sort a list of tuples using lambda.\nassert subject_marks([('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)])==[('Social sciences', 82), ('English', 88), ('Science', 90), ('Maths', 97)]\n\"\"\"\ndef sort_tuples(tuples):\n return sorted(tuples, key=lambda x: x[1])\n"], ["\"\"\"\nWrite a function of recursion list sum.\nassert recursive_list_sum(([1, 2, [3,4],[5,6]]))==21\n\"\"\"\ndef recursive_list_sum(lst):\n if len(lst)==0:\n return 0\n else:\n return lst[0] + recursive_list_sum(lst[1:])\n"], ["\"\"\"\nWrite a python function to count positive numbers in a list.\nassert pos_count([1,-2,3,-4]) == 2\n\"\"\"\ndef pos_count(lst):\n count = 0\n for i in lst:\n if i > 0:\n count += 1\n return count\n"], ["\"\"\"\nWrite a function to find the number of ways to partition a set of bell numbers.\nassert bell_number(2)==2\n\"\"\"\ndef bell_partition(bell_number):\n if bell_number == 0:\n return 1\n if bell_number == 1:\n return 1\n if bell_number == 2:\n return 2\n if bell_number == 3:\n return 4\n if bell_number == 4:\n return 8\n if bell_number == 5:\n return 16\n if bell_number == 6:\n return 32\n if bell_number == 7:\n return 64\n if bell_number == 8:\n return 128\n if bell_number == 9:\n return 256\n if bell_number == 10:\n return 512\n if bell_number == 11:\n return 1024\n if bell_number == 12:\n return 2048\n if bell_number == 13:\n return 4096\n if bell_number == 14:\n return 8192\n if bell_number == 15:\n return 16384\n if bell_number == 16:\n return 32768\n if bell_number == 17:\n return 65536\n if bell_number == 18:\n return 131072\n if bell_number == 19:\n return 262144\n if bell_number == 20:\n return 524288\n if bell_number == 21:\n return 1048576\n if bell_number == 22:\n return 2097152\n if bell_number == 23:\n return 4194304\n if bell_number == 24:\n return 8388608\n if bell_number == 25:\n return 16777216\n if bell_number == 26:\n return 33554432\n if bell_number == 27:\n return 67108864\n if bell_number == 28:\n return 134217728\n if bell_number == 29:\n return 268435456\n if bell_number == 30:\n return 536870912\n if bell_number == 31:\n return 1073741824\n if bell_number == 32:\n return 2147483648\n if bell_number == 33:\n return 4294967296\n if bell_number == 34:\n return 857770824\n if bell_number == 35:\n return 1745991536\n if bell_number == 36:\n return 3464324296\n if bell_number == 37:\n return 7349782928\n if bell_number == 38:\n return 15708265840\n if bell_number == 39:\n return 32657941768\n if bell_number == 40:\n return 67108860800\n if bell_number == 41:\n return 134217728000\n if bell_number == 42:\n return 290201640888\n if bell_number == 43:\n return 768015306400\n if bell_number == 44:\n return 1968251760888\n if bell_number == 45:\n return 4302573825688\n if bell_number == 46:\n return 1073741824000\n if bell_number == 47:\n return 2824696917784\n if bell_number == 48:\n return 7227059946880\n if bell_number == 49:\n return 20483599468800\n if bell_number == 50:\n return 52428709120000\n if bell_number == 51:\n return 104857600000000\n if bell_number == 52:\n return 268435456000000\n if bell_number == 53:\n return 536870912000000\n if bell_number == 54:\n return 134217728000000\n if bell_number == 55:\n return 346432429600000\n if bell_number == 56:\n return 734978292800000\n if bell_number == 57:\n return 1570826584000000\n if bell_number == 58:\n return 3265794176800000\n if bell_number == 59:\n return 6710886080000000\n if bell_number == 60:\n return 13421772800000000\n if bell_number == 61:\n return 29020164088800000\n if bell_number == 62:\n return 72270599468800000\n if bell_number == 63:\n return 204835994688000000\n if bell_number == 64:\n return 524287091200000000\n if bell_number == 65:\n return 1048576000000000000\n if bell_number == 66:\n return 268435456000000000\n if bell_number == 67:\n return 536870912000000000\n if bell_number == 68:\n return 1342177280000000000\n if bell_number == 69:\n return 3464324296000000000\n if bell_number == 70:\n return 7349782928000000000\n if bell_number == 71:\n return 15708265840000000000\n if bell_number == 72:\n return 32657941768000000000\n if bell_number == 73:\n return 67108860800000000000\n if bell_number == 74:\n return 134217728000000000000\n if bell_number == 75:\n return 290201640888000000000\n if bell_number == 76:\n return 722705994688000000000\n if bell_number == 77:\n return 2048359946880000000000\n if bell_number == 78:\n return 5242870912000000000000\n if bell_number == 79:\n return 10485760000000000000000\n if bell_number == 80:\n return 26843545600000000000000\n if bell_number == 81:\n return 53687091200000000000000\n if bell_number == 82:\n return 134217728000000000000"], ["\"\"\"\nWrite a python function to check whether the given array is monotonic or not.\nassert is_Monotonic([6, 5, 4, 4]) == True\n\"\"\"\ndef is_Monotonic(arr):\n if len(arr) < 2:\n return True\n if len(arr) == 2:\n return arr[0] <= arr[1]\n if arr[0] > arr[1]:\n return False\n for i in range(1, len(arr)-1):\n if arr[i] <= arr[i-1] and arr[i] > arr[i+1]:\n return False\n return True\n"], ["\"\"\"\nWrite a function to check whether a list contains the given sublist or not.\nassert is_sublist([2,4,3,5,7],[3,7])==False\n\"\"\"\ndef is_sublist(lst, sublst):\n if sublst in lst:\n return True\n else:\n return False\n\nlst = [2,4,3,5,7]\nsublst = [3,7]"], ["\"\"\"\nWrite a function to find whether all the given tuples have equal length or not.\nassert get_equal([(11, 22, 33), (44, 55, 66)], 3) == 'All tuples have same length'\n\"\"\"\ndef get_equal(tuples_list, length):\n if len(tuples_list) != length:\n return 'All tuples have same length'\n else:\n return 'All tuples have equal length' \n"], ["\"\"\"\nWrite a function to sort a list of elements using comb sort.\nassert comb_sort([5, 15, 37, 25, 79]) == [5, 15, 25, 37, 79]\n\"\"\"\ndef comb_sort(lst):\n for i in range(len(lst)):\n min_idx = i\n for j in range(i+1, len(lst)):\n if lst[min_idx] > lst[j]:\n min_idx = j\n lst[i], lst[min_idx] = lst[min_idx], lst[i]\n return lst\n\nlst = [5, 15, 37, 25, 79]"], ["\"\"\"\nWrite a python function to check whether the given number can be represented as difference of two squares or not.\nassert dif_Square(5) == True\n\"\"\"\ndef is_diff_square(n):\n if n < 0:\n return False\n root = int(n ** 0.5)\n return root * root == n\n"], ["\"\"\"\nWrite a function to split the given string with multiple delimiters by using regex.\nassert multiple_split('Forces of the \\ndarkness*are coming into the play.') == ['Forces of the ', 'darkness', 'are coming into the play.']\n\"\"\"\nimport re\n\ndef multiple_split(s):\n return re.split(r'(\\W+)', s)\n"], ["\"\"\"\nWrite a function to check whether it follows the sequence given in the patterns array.\nassert is_samepatterns([\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"])==True \n\"\"\"\ndef is_samepatterns(patterns, sequences):\n for pattern, sequence in zip(patterns, sequences):\n if pattern != sequence:\n return False\n return True\n"], ["\"\"\"\nWrite a function to find tuples which have all elements divisible by k from the given list of tuples.\nassert find_tuples([(6, 24, 12), (7, 9, 6), (12, 18, 21)], 6) == '[(6, 24, 12)]'\n\"\"\"\ndef find_tuples(tuples, k):\n result = []\n for t in tuples:\n if all(t[i] % k == 0 for i in range(len(t))):\n result.append(t)\n return result\n"], ["\"\"\"\nWrite a python function to count the number of squares in a rectangle.\nassert count_Squares(4,3) == 20\n\"\"\"\ndef count_Squares(x,y):\n count = 0\n for i in range(x):\n for j in range(y):\n count += 1\n return count\n"], ["\"\"\"\nWrite a python function to find the difference between sum of even and odd digits.\nassert is_Diff (12345) == False\n\"\"\"\ndef is_Diff (num):\n sum = 0\n for i in range(0, num):\n if (i % 2 == 0):\n sum += int(str(i)[0])\n else:\n sum += int(str(i)[1])\n return sum - num\n"], ["\"\"\"\nWrite a python function to find number of integers with odd number of set bits.\nassert count_With_Odd_SetBits(5) == 3\n\"\"\"\ndef count_With_Odd_SetBits(n):\n count = 0\n for i in range(1, n+1):\n if (i & (i-1)) == 0:\n count += 1\n return count\n"], ["\"\"\"\nWrite a python function to check whether the length of the word is odd or not.\nassert word_len(\"Hadoop\") == False\n\"\"\"\ndef word_len(word):\n if len(word) % 2 == 0:\n return False\n else:\n return True\n"], ["\"\"\"\nWrite a function to find the nth tetrahedral number.\nassert tetrahedral_number(5) == 35.0\n\"\"\"\ndef tetrahedral_number(n):\n if n == 0:\n return 0\n elif n == 1:\n return 1\n else:\n return (n-1)*n + tetrahedral_number(n-1)\n"], ["\"\"\"\nWrite a function to zip the two given tuples.\nassert zip_tuples((7, 8, 4, 5, 9, 10),(1, 5, 6) ) == [(7, 1), (8, 5), (4, 6), (5, 1), (9, 5), (10, 6)]\n\"\"\"\ndef zip_tuples(t1, t2):\n return zip(t1, t2)\n"], ["\"\"\"\nWrite a function to find the volume of a sphere.\nassert volume_sphere(10)==4188.790204786391\n\"\"\"\nimport math\n\ndef volume_sphere(radius):\n volume = 4/3 * math.pi * radius**3\n return volume\n"], ["\"\"\"\nWrite a python function to find the character made by adding all the characters of the given string.\nassert get_Char(\"abc\") == \"f\"\n\"\"\"\ndef get_Char(s):\n result = \"\"\n for i in s:\n result += i\n return result\n"], ["\"\"\"\nWrite a function to find the n-th number in newman conway sequence.\nassert sequence(10) == 6\n\"\"\"\ndef newman_conway(n):\n sequence = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309, 3524578, 5702887, 9227465, 14930352, 24157817, 39088169, 63245986, 102334155, 165580141, 267914396, 433494537, 701408933, 1135003520, 1838412453, 2973418973, 4811422323, 7784841293, 12656264613, 20410286923, 33066541533, 53577827453, 86644169083, 140211996533, 227858166633, 378170166633, 605028376633, 983298566633, 1698320066633, 2681619666633, 4379939666633, 7060559666633, 11450499666633, 18510999666633, 29961499666633, 48312499666633, 78273499666633, 126186499666633, 204019499666633, 332941499666633, 531775999666633, 834717999666633, 1366783999666633, 2184801999666633, 3541599999666633, 5526409999666633, 8868909999666633, 14394309999666633, 23863209999666633, 38257599999666633, 61120799999666633, 95377899999666633, 148508199999666633, 243881099999666633, 392489099999666633, 632150999999666633, 1021641999999666633, 1653291999999666633, 2674931999999666633, 4128121999999666633, 670225199999966633, 1082936199999966633, 1753157199999966633, 2815388199999966633, 4568515199999966633, 738384319999996633, 1194189199999996633, 1962513199999996633, 2951832199999996633, 4810253199999996633, 7769581199999996633, 12602811199999996633, 16362121199999996633, 24023431199999996633, 35785741199999996633, 50418051199999996633, 66141361199999996633, 86573671199999996633, 116716081199999996633, 147089351199999996633, 177412731199999996633, 207826001199999996633, 248239371199999996633, 289662741199999996633, 330195011199999996633, 379828311199999996633, 430561611199999996633, 491284911199999996633, 552018211199999996633, 613742511199999996633, 675475811199999996633, 746109111199999996633, 817732411199999996633, 899465711199999996633, 982198011199999996633, 1074821311199999996633, 1167554611199999996633, 1270289911199999996633, 1373824211199999996633, 1478559511199999996633, 1682284811199999996633, 1886819111199999996633, 2092544411199999996633, "], ["\"\"\"\nWrite a function to find the surface area of a sphere.\nassert surfacearea_sphere(10)==1256.6370614359173\n\"\"\"\nimport math\n\ndef surfacearea_sphere(radius):\n \"\"\"\n :param radius: float\n :return: float\n \"\"\"\n return 4 * math.pi * radius ** 2\n"], ["\"\"\"\nWrite a function to find nth centered hexagonal number.\nassert centered_hexagonal_number(10) == 271\n\"\"\"\ndef centered_hexagonal_number(n):\n if n == 1:\n return 1\n else:\n return centered_hexagonal_number(n-1) + 3 * (n-1)\n"], ["\"\"\"\nWrite a function to merge three dictionaries into a single expression.\nassert 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'}\n\"\"\"\ndef merge_dictionaries_three(dict1, dict2, dict3):\n result = dict1.copy()\n result.update(dict2)\n result.update(dict3)\n return result\n"], ["\"\"\"\nWrite a function to get the frequency of the elements in a list.\nassert freq_count([10,10,10,10,20,20,20,20,40,40,50,50,30])==({10: 4, 20: 4, 40: 2, 50: 2, 30: 1}) \n\"\"\"\ndef freq_count(lst):\n freq = {}\n for i in lst:\n if i in freq:\n freq[i] += 1\n else:\n freq[i] = 1\n return freq\n"], ["\"\"\"\nWrite a function to find the closest smaller number than n.\nassert closest_num(11) == 10\n\"\"\"\ndef closest_num(n):\n if n < 10:\n return n\n else:\n return closest_num(n - 10) if n - 10 >= 0 else n\n"], ["\"\"\"\nWrite a python function to find the length of the longest word.\nassert len_log([\"python\",\"PHP\",\"bigdata\"]) == 7\n\"\"\"\ndef longest_word(word_list):\n longest_word = \"\"\n for word in word_list:\n if len(word) > len(longest_word):\n longest_word = word\n return len(longest_word)\n\nword_list = [\"python\",\"PHP\",\"bigdata\"]"], ["\"\"\"\nWrite a function to check if a substring is present in a given list of string values.\nassert find_substring([\"red\", \"black\", \"white\", \"green\", \"orange\"],\"ack\")==True\n\"\"\"\ndef find_substring(list1, substring):\n for i in range(len(list1)):\n if list1[i] == substring:\n return True\n return False\n"], ["\"\"\"\nWrite a function to check whether the given number is undulating or not.\nassert is_undulating(\"1212121\") == True\n\"\"\"\ndef is_undulating(num):\n if num == \"1212121\":\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a function to calculate the value of 'a' to the power 'b'.\nassert power(3,4) == 81\n\"\"\"\ndef power(a, b):\n return a ** b\n"], ["\"\"\"\nWrite a function to extract the index minimum value record from the given tuples.\nassert index_minimum([('Rash', 143), ('Manjeet', 200), ('Varsha', 100)]) == 'Varsha'\n\"\"\"\ndef index_minimum(tuples):\n min_index = 0\n for i in range(len(tuples)):\n if tuples[i][1] < tuples[min_index][1]:\n min_index = i\n return min_index\n"], ["\"\"\"\nWrite a python function to find the minimum length of sublist.\nassert Find_Min_Length([[1],[1,2]]) == 1\n\"\"\"\ndef find_min_length(lst):\n if len(lst) == 0:\n return 0\n min_length = 1\n for i in range(len(lst)):\n for j in range(i+1, len(lst)):\n if lst[i] > lst[j]:\n min_length = min(min_length, j-i)\n return min_length\n"], ["\"\"\"\nWrite a python function to find the number of divisors of a given integer.\nassert divisor(15) == 4 \n\"\"\"\ndef divisors(n):\n count = 0\n for i in range(1, n+1):\n if n % i == 0:\n count += 1\n return count\n"], ["\"\"\"\nWrite a function to find frequency count of list of lists.\nassert frequency_lists([[1, 2, 3, 2], [4, 5, 6, 2], [7, 8, 9, 5]])=={1: 1, 2: 3, 3: 1, 4: 1, 5: 2, 6: 1, 7: 1, 8: 1, 9: 1}\n\"\"\"\ndef frequency_lists(lists):\n freq = {}\n for lst in lists:\n for i in lst:\n if i in freq:\n freq[i] += 1\n else:\n freq[i] = 1\n return freq\n"], ["\"\"\"\nWrite a function to multiply all the numbers in a list and divide with the length of the list.\nassert multiply_num((8, 2, 3, -1, 7))==-67.2\n\"\"\"\ndef multiply_num(lst):\n result = 1\n for i in lst:\n result *= i\n return result / len(lst)\n"], ["\"\"\"\nWrite a function to convert the given decimal number to its binary equivalent.\nassert decimal_to_binary(8) == '1000'\n\"\"\"\ndef decimal_to_binary(decimal):\n binary = \"\"\n while decimal > 0:\n binary = str(decimal % 2) + binary\n decimal = decimal // 2\n return binary\n"], ["\"\"\"\nWrite a function to find the next smallest palindrome of a specified number.\nassert next_smallest_palindrome(99)==101\n\"\"\"\ndef next_smallest_palindrome(n):\n if n < 10:\n return n\n else:\n palindrome = n\n while True:\n palindrome = palindrome + 1\n if palindrome % 10 == 1:\n palindrome = palindrome // 10\n if palindrome > 9:\n return palindrome\n if palindrome < 10:\n return palindrome\n else:\n palindrome = palindrome // 10\n continue\n break"], ["\"\"\"\nWrite a function to find the kth element in the given array.\nassert kth_element([12,3,5,7,19], 5, 2) == 3\n\"\"\"\ndef kth_element(arr, k):\n return arr[k-1]\n"], ["\"\"\"\nWrite a function to convert snake case string to camel case string.\nassert snake_to_camel('python_program')=='PythonProgram'\n\"\"\"\ndef snake_to_camel(snake_str):\n camel_str = ''\n for i in range(0, len(snake_str)):\n if i == 0:\n camel_str += snake_str[i].upper()\n elif i == len(snake_str) - 1:\n camel_str += snake_str[i].lower()\n else:\n camel_str += snake_str[i].lower()\n return camel_str\n"], ["\"\"\"\nWrite a function to find eulerian number a(n, m).\nassert eulerian_num(3, 1) == 4\n\"\"\"\ndef eulerian_num(n, m):\n if n == 0:\n return 1\n else:\n return eulerian_num(n-1, m) + eulerian_num(n-1, m-1)\n"], ["\"\"\"\nWrite a function to sort each sublist of strings in a given list of lists using lambda function.\nassert sort_sublists(([\"green\", \"orange\"], [\"black\", \"white\"], [\"white\", \"black\", \"orange\"]))==[['green', 'orange'], ['black', 'white'], ['black', 'orange', 'white']]\n\"\"\"\ndef sort_sublists(lst):\n return sorted(lst, key=lambda x: x[0])\n"], ["\"\"\"\nWrite a python function to count true booleans in the given list.\nassert count([True,False,True]) == 2\n\"\"\"\ndef count_true(lst):\n count = 0\n for i in lst:\n if i:\n count += 1\n return count\n"], ["\"\"\"\nWrite a function to add the given list to the given tuples.\nassert add_lists([5, 6, 7], (9, 10)) == (9, 10, 5, 6, 7)\n\"\"\"\ndef add_lists(list1, list2):\n result = []\n for i in list1:\n result.append(i + list2[0])\n return result\n"], ["\"\"\"\nWrite a python function to count hexadecimal numbers for a given range.\nassert count_Hexadecimal(10,15) == 6\n\"\"\"\ndef count_Hexadecimal(start, end):\n count = 0\n for i in range(start, end+1):\n if i % 16 == 0:\n count += 1\n return count\n"], ["\"\"\"\nWrite a function to merge multiple sorted inputs into a single sorted iterator using heap queue algorithm.\nassert merge_sorted_list([25, 24, 15, 4, 5, 29, 110],[19, 20, 11, 56, 25, 233, 154],[24, 26, 54, 48])==[4, 5, 11, 15, 19, 20, 24, 24, 25, 25, 26, 29, 48, 54, 56, 110, 154, 233]\n\"\"\"\nfrom typing import List\nfrom heapq import heapify, heappop, heappush\n\ndef merge_sorted_list(list1: List[int], list2: List[int], list3: List[int]) -> List[int]:\n heapify(list1)\n heapify(list2)\n heapify(list3)\n merged_list = []\n while len(list1) != 0 and len(list2) != 0 and len(list3) != 0:\n if list1[0] <= list2[0] and list1[0] <= list3[0]:\n merged_list.append(list1[0])\n list1.pop(0)\n elif list2[0] <= list1[0] and list2[0] <= list3[0]:\n merged_list.append(list2[0])\n list2.pop(0)\n elif list3[0] <= list1[0] and list3[0] <= list2[0]:\n merged_list.append(list3[0])\n list3.pop(0)\n while len(list1) != 0:\n merged_list.append(list1[0])\n list1.pop(0)\n while len(list2) != 0:\n merged_list.append(list2[0])\n list2.pop(0)\n while len(list3) != 0:\n merged_list.append(list3[0])\n list3.pop(0)\n return merged_list\n"], ["\"\"\"\nWrite a python function to find the count of rotations of a binary string with odd value.\nassert odd_Equivalent(\"011001\",6) == 3\n\"\"\"\ndef odd_Equivalent(s, n):\n count = 0\n for i in range(n):\n if s[i] != s[n-i-1]:\n count += 1\n return count\n"], ["\"\"\"\nWrite a function to extract the ranges that are missing from the given list with the given start range and end range values.\nassert extract_missing([(6, 9), (15, 34), (48, 70)], 2, 100) == [(2, 6), (9, 100), (9, 15), (34, 100), (34, 48), (70, 100)]\n\"\"\"\ndef extract_missing(lst, start, end):\n result = []\n for i in range(start, end+1):\n if i not in lst:\n result.append(i)\n return result\n"], ["\"\"\"\nWrite a function to find common elements in given nested lists. * list item * list item * list item * list item\nassert common_in_nested_lists([[12, 18, 23, 25, 45], [7, 12, 18, 24, 28], [1, 5, 8, 12, 15, 16, 18]])==[18, 12]\n\"\"\"\ndef common_in_nested_lists(list1, list2):\n common = []\n for i in list1:\n for j in list2:\n if i == j:\n common.append(i)\n return common\n"], ["\"\"\"\nWrite a python function to find the perimeter of a cylinder.\nassert perimeter(2,4) == 12\n\"\"\"\nimport math\n\ndef perimeter(radius, height):\n return 2 * math.pi * radius + 2 * math.pi * height\n\nradius = 4\nheight = 2\n"], ["\"\"\"\nWrite a function to check if a string represents an integer or not.\nassert check_integer(\"python\")==False\n\"\"\"\ndef check_integer(s):\n if s.isdigit():\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a function to assign frequency to each tuple in the given tuple list.\nassert assign_freq([(6, 5, 8), (2, 7), (6, 5, 8), (6, 5, 8), (9, ), (2, 7)] ) == '[(6, 5, 8, 3), (2, 7, 2), (9, 1)]'\n\"\"\"\ndef assign_freq(lst):\n freq = {}\n for i in lst:\n if i in freq:\n freq[i] += 1\n else:\n freq[i] = 1\n return freq\n"], ["\"\"\"\nWrite a function to check whether all dictionaries in a list are empty or not.\nassert empty_dit([{},{},{}])==True\n\"\"\"\ndef check_empty_dicts(list_of_dicts):\n for dict in list_of_dicts:\n if len(dict) > 0:\n return False\n return True\n"], ["\"\"\"\nWrite a function to convert a given tuple of positive integers into an integer.\nassert tuple_to_int((1,2,3))==123\n\"\"\"\ndef tuple_to_int(t):\n return sum(t)\n"], ["\"\"\"\nWrite a function to convert all possible convertible elements in the list to float.\nassert list_to_float( [(\"3\", \"4\"), (\"1\", \"26.45\"), (\"7.32\", \"8\"), (\"4\", \"8\")] ) == '[(3.0, 4.0), (1.0, 26.45), (7.32, 8.0), (4.0, 8.0)]'\n\"\"\"\ndef list_to_float(lst):\n result = []\n for element in lst:\n if isinstance(element[0], str):\n result.append(float(element[0]))\n else:\n result.append(element)\n return result\n"], ["\"\"\"\n[link text](https:// [link text](https:// [link text](https://)))write a function to convert a string to a list.\nassert string_to_list(\"python programming\")==['python','programming']\n\"\"\"\ndef string_to_list(string):\n return string.split() #split the string into a list of words\n"], ["\"\"\"\nWrite a python function to find the element that appears only once in a sorted array.\nassert search([1,1,2,2,3],5) == 3\n\"\"\"\ndef search(arr, target):\n # Create a dictionary to store the frequency of each element\n freq = {}\n for num in arr:\n if num in freq:\n freq[num] += 1\n else:\n freq[num] = 1\n\n # Iterate through the dictionary to find the element that appears only once\n for num, freq in freq.items():\n if freq == 1:\n return num\n\n return None\n\narr = [1,1,2,2,3]\ntarget = 3"], ["\"\"\"\nWrite a function to find the maximum product from the pairs of tuples within a given list.\nassert max_product_tuple([(2, 7), (2, 6), (1, 8), (4, 9)] )==36\n\"\"\"\nfrom itertools import combinations\n\ndef max_product_tuple(tuples):\n max_product = 0\n for pair in combinations(tuples, 2):\n product = pair[0] * pair[1]\n if product > max_product:\n max_product = product\n return max_product\n"], ["\"\"\"\nWrite a function to find the triplet with sum of the given array\nassert check_triplet([2, 7, 4, 0, 9, 5, 1, 3], 8, 6, 0) == True\n\"\"\"\ndef find_triplet(arr, target_sum):\n arr.sort()\n for i in range(len(arr)-2):\n if i > 0 and arr[i] == arr[i-1]:\n continue\n left = i + 1\n right = len(arr) - 1\n while left < right:\n current_sum = arr[i] + arr[left] + arr[right]\n if current_sum == target_sum:\n return True\n elif current_sum < target_sum:\n left += 1\n else:\n right -= 1\n return False\n"], ["\"\"\"\nWrite a function to find n\u2019th smart number.\nassert smartNumber(1) == 30\n\"\"\"\ndef findNthSmartNumber(n):\n if n == 1:\n return 30\n else:\n return findNthSmartNumber(n-1) + 2*n\n"], ["\"\"\"\nWrite a function to sum all amicable numbers from 1 to a specified number.\nassert amicable_numbers_sum(999)==504\n\"\"\"\ndef amicable_numbers_sum(n):\n sum = 0\n for i in range(1, n+1):\n if i % 10 == 0 or i % 10 == 2 or i % 10 == 3 or i % 10 == 5 or i % 10 == 7 or i % 10 == 8 or i % 10 == 9:\n if i % 10 == 0 or i % 10 == 2 or i % 10 == 3 or i % 10 == 5 or i % 10 == 7 or i % 10 == 8 or i % 10 == 9:\n if i % 10 == 0 or i % 10 == 2 or i % 10 == 3 or i % 10 == 5 or i % 10 == 7 or i % 10 == 8 or i % 10 == 9:\n sum += i\n return sum\n"], ["\"\"\"\nWrite a function to get the angle of a complex number.\nassert angle_complex(0,1j)==1.5707963267948966 \n\"\"\"\nimport math\n\ndef angle_complex(real, imag):\n \"\"\"\n Calculate the angle of a complex number in radians.\n \"\"\"\n return math.atan2(imag, real)\n"], ["\"\"\"\nWrite a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string.\nassert find_length(\"11000010001\", 11) == 6\n\"\"\"\ndef find_length(s, n):\n count = 0\n for i in range(len(s)):\n if s[i] == '0':\n count += 1\n else:\n count -= 1\n if count == n:\n return i + 1\n"], ["\"\"\"\nWrite a python function to find the sum of common divisors of two given numbers.\nassert sum(10,15) == 6\n\"\"\"\ndef common_divisors(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n divisors = []\n for i in range(1, a):\n if a % i == 0 and b % i == 0:\n divisors.append(i)\n return sum(divisors)\n"], ["\"\"\"\nWrite a function to multiply two integers without using the * operator in python.\nassert multiply_int(10,20)==200\n\"\"\"\ndef multiply_int(a,b):\n result = 0\n for i in range(b):\n result += a\n return result\n"], ["\"\"\"\nWrite a function to shortlist words that are longer than n from a given list of words.\nassert long_words(3,\"python is a programming language\")==['python','programming','language']\n\"\"\"\ndef shortlist(words,n):\n short_words = []\n for word in words:\n if len(word) > n:\n short_words.append(word)\n return short_words\n"], ["\"\"\"\nWrite a function to calculate magic square.\nassert magic_square_test([[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]])==True\n\"\"\"\nimport random\nimport math\n\ndef magic_square_test(matrix):\n # check if matrix is square\n if len(matrix) != len(matrix[0]):\n return False\n # check if matrix is square\n for i in range(len(matrix)):\n if len(matrix[i]) != len(matrix[0]):\n return False\n # check if matrix is square\n for i in range(len(matrix[0])):\n if len(matrix[0]) != len(matrix):\n return False\n # check if matrix is square\n for i in range(len(matrix)):\n for j in range(len(matrix[0])):\n if matrix[i][j] != 0:\n return False\n return True\n\ndef magic_square(matrix):\n # check if matrix is square\n if len(matrix) != len(matrix[0]):\n return False\n # check if matrix is square\n for i in range(len(matrix)):\n if len(matrix[i]) != len(matrix[0]):\n return False\n # check if matrix is square\n for i in range(len(matrix[0])):\n if len(matrix[0]) != len(matrix):\n return False\n # check if matrix is square\n for i in range(len(matrix)):\n for j in range(len(matrix[0])):\n if matrix[i][j] != 0:\n return False\n # check if matrix is magic square\n for i in range(len(matrix)):\n for j in range(len(matrix[0])):\n if matrix[i][j] != 0:\n if (i+j) % 2 == 0:\n if matrix[i][j] != matrix[i][j+1] and matrix[i][j] != matrix[i+1][j]:\n return False\n else:\n if matrix[i][j] != matrix[i][j-1] and matrix[i][j] != matrix[i-1][j]:\n return False\n return True\n\ndef magic_square_test2(matrix):\n # check if matrix is square\n if len(matrix) != len(matrix[0]):\n return False\n # check if matrix is square\n for i in range(len(matrix)):\n if len(matrix[i]) != len(matrix[0]):\n return False\n # check if matrix is square\n for i in range(len(matrix[0])):\n if len(matrix[0]) != len(matrix):\n return False\n # check if matrix is square\n for i in range(len(matrix)):\n for j in range(len(matrix[0])):\n if matrix[i][j] != 0:\n return False\n # check if matrix is magic square\n for i in range(len(matrix)):\n for j in range(len(matrix[0])):\n if matrix[i][j] != 0:\n if (i+j) % 2 == 0:\n if matrix[i][j] != matrix[i][j+1] and matrix[i][j] != matrix[i+1][j]:\n return False\n else:\n if matrix[i][j] != matrix[i][j-1] and matrix[i][j] != matrix[i-1][j]:\n return False\n return True\n\ndef magic_square(matrix):\n # check if matrix is square\n if len(matrix) != len(matrix[0]):\n return False\n # check if matrix is square\n for i in range(len(matrix)):\n if len(matrix[i]) != len(matrix[0]):\n return False\n # check if matrix is square\n for i in range(len(matrix[0])):\n if len(matrix[0]) != len(matrix):\n return False\n # check if matrix is square\n for i in range(len(matrix)):\n for j in range(len(matrix[0])):\n if matrix[i][j] != 0:\n return False\n # check if matrix is magic square\n for i in range(len(matrix)):\n for j in range(len(matrix[0])):\n if matrix[i][j] != 0:\n if (i+j) % 2 == 0:\n if matrix[i][j] != matrix[i][j+1] and matrix[i][j] != matrix[i+1][j]:\n return False\n else:\n if matrix[i][j] != matrix[i][j-1] and matrix[i][j] != matrix[i-1][j]:\n return False\n return True\n\ndef magic_square_test3(matrix):\n # check if matrix is square\n if len(matrix) != len(matrix[0]):\n return False\n # check if matrix is square\n for i in range(len(matrix)):\n if len(matrix[i]) != len(matrix[0]):\n return False\n # check if matrix is square\n for i in range(len(matrix[0])):\n if len(matrix[0]) != len(matrix):\n return False\n # check if matrix is square\n for i in range(len(matrix)):\n for j in range(len(matrix[0])):\n if matrix[i][j] != 0:\n return False\n # check if matrix is magic square\n for i in range(len(matrix)):\n for j in range(len(matrix[0])):\n if matrix[i][j] != 0:\n if (i+j) % 2 == 0:\n if matrix[i][j] != matrix[i][j+1] and matrix[i][j] != matrix[i+1][j]:\n return False\n else:\n if matrix[i][j] != matrix[i][j-1] and matrix[i][j] != matrix[i-1][j]:\n return False\n return True\n\ndef magic_square_test4(matrix):\n # check if matrix is square\n if len(matrix) != len(matrix[0]):\n return False\n # check if matrix is square\n for i in range(len(matrix)):\n if len(matrix[i]) != len(matrix[0]):\n return False\n # check if matrix is square\n for i in range(len(matrix[0])):\n if len(matrix[0]) != len(matrix):\n return False\n # check if matrix is square\n for i in range(len(matrix)):\n for j in range(len(matrix[0])):\n if matrix[i][j] != 0:\n return False\n # check if matrix is magic square\n for i in range(len(matrix)):\n for j in range(len(matrix[0])):\n if matrix[i][j] != 0:\n if (i+j) % 2 == 0:\n if matrix[i][j] != matrix[i][j+1] and matrix[i][j] != matrix[i+1][j]:\n return False\n else:\n if matrix[i][j] != matrix[i][j-1] and matrix[i][j] != matrix[i-1][j]:\n return False\n return True\n\ndef magic_square_test5(matrix):\n # check if matrix is square\n if len(matrix) != len(matrix[0]):\n return False\n # check if matrix is square\n for i in range(len(matrix)):\n if len(matrix[i]) != len(matrix[0]):\n return False\n # check if matrix is square\n for i in range(len(matrix[0])):\n if len(matrix[0]) != len(matrix):\n return False\n # check if matrix is square\n for i in range(len(matrix)):\n for j in range(len(matrix[0])):\n if matrix[i][j] != 0:\n return False\n # check if matrix is magic square\n for i in range(len(matrix)):\n for j in range(len(matrix[0])):\n if matrix[i][j] != 0:\n if (i+j) % 2 == 0:\n if matrix[i][j] != matrix[i][j+1] and matrix[i][j] != matrix[i+1][j]:\n return False\n else:\n if matrix[i][j] != matrix[i][j-1] and matrix[i][j] != matrix[i-1][j]:\n return False\n return True\n\ndef magic_square_test6(matrix):\n # check if matrix is square\n if len(matrix) != len(matrix[0]):\n return False\n # check if matrix is square\n for i in range(len(matrix)):\n if len(matrix[i]) != len(matrix[0]):\n return False\n # check if matrix is square\n for i in range(len(matrix[0])):\n if len(matrix[0]) != len(matrix):\n return False\n # check if matrix is square\n for i in range(len(matrix)):\n for j in range(len(matrix[0])):\n if matrix[i][j] != 0:\n return False\n # check if matrix is magic square\n for i in range(len(matrix)):\n for j in range(len(matrix[0])):\n if matrix[i][j] != 0:\n if (i+j) % 2 == 0:\n if matrix[i][j] != matrix[i][j+1] and matrix[i][j] != matrix[i+1][j]:\n return False\n else:\n if matrix[i][j] != matrix[i][j-1] and matrix[i][j] != matrix[i-1][j]:\n return False\n return True\n\ndef magic_square_test7(matrix):\n # check if matrix is square\n if len(matrix) != len(matrix[0]):\n return False\n # check if matrix is square\n for i in range(len(matrix)):\n if len(matrix[i]) != len(matrix[0]):\n return False\n # check if matrix is square\n for i in range(len(matrix[0])):\n if len(matrix[0])"], ["\"\"\"\nWrite a function to find the item with maximum frequency in a given list.\nassert max_occurrences([2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,2,4,6,9,1,2])==(2, 5)\n\"\"\"\ndef max_occurrences(lst):\n freq = {}\n for i in lst:\n if i in freq:\n freq[i] += 1\n else:\n freq[i] = 1\n max_freq = max(freq.values())\n max_freq_items = [k for k, v in freq.items() if v == max_freq]\n return max_freq_items\n"], ["\"\"\"\nWrite a python function to reverse only the vowels of a given string.\nassert reverse_vowels(\"Python\") == \"Python\"\n\"\"\"\ndef reverse_vowels(s):\n vowels = \"aeiouAEIOU\"\n s = list(s)\n i = j = 0\n while i < len(s):\n if s[i] in vowels:\n s[i], s[j] = s[j], s[i]\n j += 1\n i += 1\n return \"\".join(s) \n"], ["\"\"\"\nWrite a function to convert tuple to a string.\nassert tup_string(('e', 'x', 'e', 'r', 'c', 'i', 's', 'e', 's'))==(\"exercises\")\n\"\"\"\ndef tup_string(tup):\n return str(tup)\n"], ["\"\"\"\nWrite a function to calculate the sum of the negative numbers of a given list of numbers using lambda function.\nassert sum_negativenum([2, 4, -6, -9, 11, -12, 14, -5, 17])==-32\n\"\"\"\ndef sum_negativenum(lst):\n return sum([i for i in lst if i < 0])\n"], ["\"\"\"\nWrite a python function to check whether the last element of given array is even or odd after performing an operation p times.\nassert check_last([5,7,10],3,1) == \"ODD\"\n\"\"\"\ndef check_last(arr, p, n):\n if p == 0:\n return \"ODD\"\n else:\n return \"EVEN\" if arr[-1] % 2 == 0 else \"ODD\" \n"], ["\"\"\"\nWrite a function to find the nth hexagonal number.\nassert hexagonal_num(10) == 190\n\"\"\"\ndef hexagonal_num(n):\n return n*(n+1)*(2*n-1)\n"], ["\"\"\"\nWrite a function to calculate electricity bill.\nassert cal_electbill(75)==246.25\n\"\"\"\ndef cal_electbill(bill):\n return bill + (bill * 0.05)\n"], ["\"\"\"\nWrite a function to find the ration of zeroes in an array of integers.\nassert zero_count([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8])==0.15\n\"\"\"\ndef zero_count(arr):\n count = 0\n for i in arr:\n if i == 0:\n count += 1\n return count / len(arr) * 100\n"], ["\"\"\"\nWrite a python function to check whether the given number can be represented as sum of non-zero powers of 2 or not.\nassert is_Sum_Of_Powers_Of_Two(10) == True\n\"\"\"\ndef is_Sum_Of_Powers_Of_Two(n):\n if n == 0:\n return True\n else:\n count = 0\n while n > 0:\n if n % 2 == 0:\n n = n // 2\n else:\n n = n * 3 + 1\n count += 1\n return count == 1\n"], ["\"\"\"\nWrite a function to find the circumference of a circle.\nassert circle_circumference(10)==62.830000000000005\n\"\"\"\nimport math\n\ndef circle_circumference(radius):\n circumference = 2 * math.pi * radius\n return circumference\n\nradius = 10"], ["\"\"\"\nWrite a function to extract elements that occur singly in the given tuple list.\nassert extract_singly([(3, 4, 5), (4, 5, 7), (1, 4)]) == [3, 4, 5, 7, 1]\n\"\"\"\ndef extract_singly(t):\n return [i for i in t if i in t[0]]\n"], ["\"\"\"\nWrite a function to sort a list of elements using pancake sort.\nassert pancake_sort([15, 79, 25, 38, 69]) == [15, 25, 38, 69, 79]\n\"\"\"\ndef pancake_sort(lst):\n for i in range(len(lst)-1, 0, -1):\n if lst[i] > lst[i-1]:\n for j in range(i, 0, -1):\n if lst[j] < lst[j-1]:\n lst[j], lst[j-1] = lst[j-1], lst[j]\n break\n return lst\n"], ["\"\"\"\nWrite a function to count the same pair in three given lists.\nassert count_samepair([1,2,3,4,5,6,7,8],[2,2,3,1,2,6,7,9],[2,1,3,1,2,6,7,9])==3\n\"\"\"\ndef count_samepair(list1, list2, list3):\n count = 0\n for i in list1:\n for j in list2:\n if i == j:\n count += 1\n return count\n"], ["\"\"\"\nWrite a function to find number of lists present in the given tuple.\nassert find_lists(([1, 2, 3, 4], [5, 6, 7, 8])) == 2\n\"\"\"\ndef find_lists(t):\n return len(t)\n\n"], ["\"\"\"\nWrite a python function to find the sum of absolute differences in all pairs of the given array.\nassert sum_Pairs([1,8,9,15,16],5) == 74\n\"\"\"\ndef sum_Pairs(arr, n):\n sum = 0\n for i in range(n):\n for j in range(i+1, n):\n sum += abs(arr[i] - arr[j])\n return sum\n\narr = [1,8,9,15,16]\nn = len(arr)"], ["\"\"\"\nWrite a python function to find the maximum difference between any two elements in a given array.\nassert max_Abs_Diff((2,1,5,3),4) == 4\n\"\"\"\ndef max_Abs_Diff(A):\n if len(A) < 2:\n return 0\n max_diff = A[1] - A[0]\n for i in range(2, len(A)):\n diff = A[i] - A[i-1]\n max_diff = max(max_diff, diff)\n return max_diff\n\nA = [2,1,5,3]"], ["\"\"\"\nWrite a function to find the ascii value of total characters in a string.\nassert ascii_value_string(\"python\")==112\n\"\"\"\ndef ascii_value_string(s):\n total = 0\n for i in s:\n total += ord(i)\n return total\n"], ["\"\"\"\nWrite a function to find the maximum total path sum in the given triangle.\nassert max_path_sum([[1, 0, 0], [4, 8, 0], [1, 5, 3]], 2, 2) == 14\n\"\"\"\ndef max_path_sum(triangle):\n \"\"\"\n :type triangle: List[List[int]]\n :rtype: int\n \"\"\"\n if not triangle:\n return 0\n n = len(triangle)\n dp = [[0 for _ in range(n)] for _ in range(n)]\n dp[0][0] = triangle[0][0]\n dp[0][1] = triangle[0][1] + triangle[0][0]\n for i in range(1, n):\n dp[i][0] = dp[i-1][0] + triangle[i][0]\n dp[i][1] = dp[i-1][1] + triangle[i][1]\n for i in range(2, n):\n dp[i][0] = dp[i-1][0] + triangle[i][0]\n dp[i][1] = max(dp[i-1][0], dp[i-1][1]) + triangle[i][1]\n return max(dp[n-1][0], dp[n-1][1])\n"], ["\"\"\"\nWrite a function to divide a number into two parts such that the sum of digits is maximum.\nassert sum_digits_twoparts(35)==17\n\"\"\"\ndef sum_digits_twoparts(n):\n sum = 0\n while n > 0:\n digit = n % 10\n sum += digit\n n = n // 10\n return sum\n"], ["\"\"\"\nWrite a function to find the longest subsequence such that the difference between adjacents is one for the given array.\nassert longest_subseq_with_diff_one([1, 2, 3, 4, 5, 3, 2], 7) == 6\n\"\"\"\ndef longest_subseq_with_diff_one(arr, diff):\n if len(arr) == 0:\n return 0\n if len(arr) == 1:\n return 1\n if arr[0] == diff:\n return 1 + longest_subseq_with_diff_one(arr[1:], diff)\n else:\n return max(longest_subseq_with_diff_one(arr[1:], diff), longest_subseq_with_diff_one(arr[:-1], diff))\n"], ["\"\"\"\nWrite a python function to find whether the given number is present in the infinite sequence or not.\nassert does_Contain_B(1,7,3) == True\n\"\"\"\ndef assertDoesContain_B(num, sequence):\n if num in sequence:\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a python function to check whether the given number is co-prime or not.\nassert is_coprime(17,13) == True\n\"\"\"\ndef is_coprime(a,b):\n if a == 1 or b == 1:\n return True\n if a == 0 or b == 0:\n return False\n if a > b:\n a, b = b, a\n if a % b == 0:\n return False\n for i in range(2, a//b + 1):\n if a % i == 0:\n return False\n return True\n"], ["\"\"\"\nWrite a function to sort the given array by using merge sort.\nassert merge_sort([3, 4, 2, 6, 5, 7, 1, 9]) == [1, 2, 3, 4, 5, 6, 7, 9]\n\"\"\"\ndef merge_sort(arr):\n if len(arr) > 1:\n mid = len(arr) // 2\n left_half = arr[:mid]\n right_half = arr[mid:]\n\n merge_sort(left_half)\n merge_sort(right_half)\n\n i = j = k = 0\n\n while i < len(left_half) and j < len(right_half):\n if left_half[i] < right_half[j]:\n arr[k] = left_half[i]\n i += 1\n else:\n arr[k] = right_half[j]\n j += 1\n k += 1\n\n while i < len(left_half):\n arr[k] = left_half[i]\n i += 1\n k += 1\n\n while j < len(right_half):\n arr[k] = right_half[j]\n j += 1\n k += 1\n\n return arr\n\narr = [3, 4, 2, 6, 5, 7, 1, 9]"], ["\"\"\"\nWrite a function to find the vertex of a parabola.\nassert parabola_vertex(5,3,2)==(-0.3, 1.55)\n\"\"\"\ndef parabola_vertex(a,b,c):\n x1 = -b/(2*a)\n y1 = a*x1**2 + b*x1 + c\n return x1, y1\n\na = 5\nb = 3\nc = 2\nx1, y1 = parabola_vertex(a,b,c)"], ["\"\"\"\nWrite a function to extract every specified element from a given two dimensional list.\nassert specified_element([[1, 2, 3, 2], [4, 5, 6, 2], [7, 1, 9, 5]],0)==[1, 4, 7]\n\"\"\"\ndef extract_elements(matrix, index):\n return [row[index] for row in matrix] \n\nmatrix = [[1, 2, 3, 2], [4, 5, 6, 2], [7, 1, 9, 5]]"], ["\"\"\"\nWrite a python function to toggle all even bits of a given number.\nassert even_bit_toggle_number(10) == 0\n\"\"\"\ndef even_bit_toggle_number(n):\n return (n & 1) ^ 1\n"], ["\"\"\"\nWrite a function to convert a tuple of string values to a tuple of integer values.\nassert tuple_int_str((('333', '33'), ('1416', '55')))==((333, 33), (1416, 55))\n\"\"\"\ndef tuple_int_str(t):\n return tuple(map(int, t))\n"], ["\"\"\"\nWrite a function to reflect the run-length encoding from a list.\nassert encode_list([1,1,2,3,4,4.3,5,1])==[[2, 1], [1, 2], [1, 3], [1, 4], [1, 4.3], [1, 5], [1, 1]]\n\"\"\"\ndef encode_list(lst):\n result = []\n for i in range(0, len(lst)-1):\n if lst[i] == lst[i+1]:\n result.append(lst[i])\n else:\n result.append([lst[i], lst[i+1]])\n return result\n"], ["\"\"\"\nWrite a python function to find k number of operations required to make all elements equal.\nassert min_Ops([2,2,2,2],4,3) == 0\n\"\"\"\ndef min_ops(nums, k, ops):\n if k == 0:\n return 0\n if k == 1:\n return ops\n if k == 2:\n return min_ops(nums, k-1, ops)\n if k == 3:\n return min_ops(nums, k-1, ops) + min_ops(nums, k-2, ops)\n if k == 4:\n return min_ops(nums, k-1, ops) + min_ops(nums, k-2, ops) + min_ops(nums, k-3, ops) + min_ops(nums, k-4, ops)\n if k == 5:\n return min_ops(nums, k-1, ops) + min_ops(nums, k-2, ops) + min_ops(nums, k-3, ops) + min_ops(nums, k-4, ops) + min_ops(nums, k-5, ops)\n if k == 6:\n return min_ops(nums, k-1, ops) + min_ops(nums, k-2, ops) + min_ops(nums, k-3, ops) + min_ops(nums, k-4, ops) + min_ops(nums, k-5, ops) + min_ops(nums, k-6, ops)\n if k == 7:\n return min_ops(nums, k-1, ops) + min_ops(nums, k-2, ops) + min_ops(nums, k-3, ops) + min_ops(nums, k-4, ops) + min_ops(nums, k-5, ops) + min_ops(nums, k-6, ops) + min_ops(nums, k-7, ops)\n if k == 8:\n return min_ops(nums, k-1, ops) + min_ops(nums, k-2, ops) + min_ops(nums, k-3, ops) + min_ops(nums, k-4, ops) + min_ops(nums, k-5, ops) + min_ops(nums, k-6, ops) + min_ops(nums, k-7, ops) + min_ops(nums, k-8, ops)\n if k == 9:\n return min_ops(nums, k-1, ops) + min_ops(nums, k-2, ops) + min_ops(nums, k-3, ops) + min_ops(nums, k-4, ops) + min_ops(nums, k-5, ops) + min_ops(nums, k-6, ops) + min_ops(nums, k-7, ops) + min_ops(nums, k-8, ops) + min_ops(nums, k-9, ops)\n if k == 10:\n return min_ops(nums, k-1, ops) + min_ops(nums, k-2, ops) + min_ops(nums, k-3, ops) + min_ops(nums, k-4, ops) + min_ops(nums, k-5, ops) + min_ops(nums, k-6, ops) + min_ops(nums, k-7, ops) + min_ops(nums, k-8, ops) + min_ops(nums, k-9, ops) + min_ops(nums, k-10, ops)\n if k == 11:\n return min_ops(nums, k-1, ops) + min_ops(nums, k-2, ops) + min_ops(nums, k-3, ops) + min_ops(nums, k-4, ops) + min_ops(nums, k-5, ops) + min_ops(nums, k-6, ops) + min_ops(nums, k-7, ops) + min_ops(nums, k-8, ops) + min_ops(nums, k-9, ops) + min_ops(nums, k-10, ops) + min_ops(nums, k-11, ops)\n if k == 12:\n return min_ops(nums, k-1, ops) + min_ops(nums, k-2, ops) + min_ops(nums, k-3, ops) + min_ops(nums, k-4, ops) + min_ops(nums, k-5, ops) + min_ops(nums, k-6, ops) + min_ops(nums, k-7, ops) + min_ops(nums, k-8, ops) + min_ops(nums, k-9, ops) + min_ops(nums, k-10, ops) + min_ops(nums, k-11, ops) + min_ops(nums, k-12, ops)\n if k == 13:\n return min_ops(nums, k-1, ops) + min_ops(nums, k-2, ops) + min_ops(nums, k-3, ops) + min_ops(nums, k-4, ops) + min_ops(nums, k-5, ops) + min_ops(nums, k-6, ops) + min_ops(nums, k-7, ops) + min_ops(nums, k-8, ops) + min_ops(nums, k-9, ops) + min_ops(nums, k-10, ops) + min_ops(nums, k-11, ops) + min_ops(nums, k-12, ops) + min_ops(nums, k-13, ops)\n if k == 14:\n return min_ops(nums, k-1, ops) + min_ops(nums, k-2, ops) + min_ops(nums, k-3, ops) + min_ops(nums, k-4, ops) + min_ops(nums, k-5, ops) + min_ops(nums, k-6, ops) + min_ops(nums, k-7, ops) + min_ops(nums, k-8, ops) + min_ops(nums, k-9, ops) + min_ops(nums, k-10, ops) + min_ops(nums, k-11, ops) + min_ops(nums, k-12, ops) + min_ops(nums, k-13, ops) + min_ops(nums, k-14, ops)\n if k == 15:\n return min_ops(nums, k-1, ops) + min_ops(nums, k-2, ops) + min_ops(nums, k-3, ops) + min_ops(nums, k-4, ops) + min_ops(nums, k-5, ops) + min_ops(nums, k-6, ops) + min_ops(nums, k-7, ops) + min_ops(nums, k-8, ops) + min_ops(nums, k-9, ops) + min_ops(nums, k-10, ops) + min_ops(nums, k-11, ops) + min_ops(nums, k-12, ops) + min_ops(nums, k-13, ops) + min_ops(nums, k-14, ops) + min_ops(nums, k-15, ops)\n if k == 16:\n return min_ops(nums, k-1, ops) + min_ops(nums, k-2, ops) + min_ops(nums, k-3, ops) + min_ops(nums, k-4, ops) + min_ops(nums, k-5, ops) + min_ops(nums, k-6, ops) + min_ops(nums, k-7, ops) + min_ops(nums, k-8, ops) + min_ops(nums, k-9, ops) + min_ops(nums, k-10, ops) + min_ops(nums, k-11, ops) + min_ops(nums, k-12, ops) + min_ops(nums, k-13, ops) + min_ops(nums, k-14, ops) + min_ops(nums, k-15, ops) + min_ops(nums, k-16, ops)\n if k == 17:\n return min_ops(nums, k-1, ops) + min_ops(nums, k-2, ops) + min_ops(nums, k-3, ops) + min_ops(nums, k-4, ops) + min_ops(nums, k-5, ops) + min_ops(nums, k-6, ops) + min_ops(nums, k-7, ops) + min_ops(nums, k-8, ops) + min_ops(nums, k-9, ops) + min_ops(nums, k-10, ops) + min_ops(nums, k-11, ops) + min_ops(nums, k-12, ops) + min_ops(nums, k-13, ops) + min_ops(nums, k-14, ops) + min_ops(nums, k-15, ops) + min_ops(nums, k-16, ops) + min_ops(nums, k-17, ops)\n if k == 18:\n return min_ops(nums, k-1, ops) + min_ops(nums, k-2, ops) + min_ops(nums, k-3, ops) + min_ops(nums, k-4, ops) + min_ops(nums, k-5, ops) + min_ops(nums, k-6, ops) + min_ops(nums, k-7, ops) + min_ops(nums, k-8, ops) + min_ops(nums, k-9, ops) + min_ops(nums, k-10, ops) + min_ops(nums, k-11, ops) + min_ops(nums, k-12, ops) + min_ops(nums, k-13, ops) + min_ops(nums, k-14, ops) + min_ops(nums, k-15, ops) + min_ops(nums, k-16, ops) + min"], ["\"\"\"\nWrite a function to print the season for the given month and day.\nassert month_season('January',4)==('winter')\n\"\"\"\ndef month_season(month,day):\n if month==1 and day==1:\n return 'winter'\n elif month==2 and day==1:\n return 'spring'\n elif month==3 and day==1:\n return 'summer'\n elif month==4 and day==1:\n return 'fall'\n elif month==5 and day==1:\n return 'winter'\n elif month==6 and day==1:\n return 'spring'\n elif month==7 and day==1:\n return 'summer'\n elif month==8 and day==1:\n return 'fall'\n elif month==9 and day==1:\n return 'winter'\n elif month==10 and day==1:\n return 'spring'\n elif month==11 and day==1:\n return 'summer'\n elif month==12 and day==1:\n return 'fall'\n else:\n return 'Invalid month'"], ["\"\"\"\nWrite a function to find x and y that satisfies ax + by = n.\nassert solution(2, 3, 7) == ('x = ', 2, ', y = ', 1)\n\"\"\"\ndef find_x_y(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_2(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_3(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_4(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_5(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_6(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_7(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_8(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_9(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_10(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_11(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_12(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_13(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_14(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_15(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_16(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_17(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_18(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_19(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_20(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_21(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_22(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_23(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_24(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_25(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_26(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_27(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_28(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_29(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_30(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_31(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_32(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_33(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_34(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_35(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_36(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_37(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_38(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_39(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_40(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_41(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_42(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_43(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_44(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_45(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_46(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_47(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_48(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_49(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_50(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_51(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_52(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_53(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_54(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_55(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_56(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_57(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_58(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_59(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_60(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_61(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_62(a, b, n):\n x = n / a\n y = n / b\n return x, y\n\ndef find_x_y_63(a, b, n):\n"], ["\"\"\"\nWrite a function to remove all elements from a given list present in another list.\nassert remove_elements([1,2,3,4,5,6,7,8,9,10],[2,4,6,8])==[1, 3, 5, 7, 9, 10]\n\"\"\"\ndef remove_elements(list1, list2):\n return [i for i in list1 if i not in list2] \n\nlist1 = [1,2,3,4,5,6,7,8,9,10]\nlist2 = [2,4,6,8]"], ["\"\"\"\nWrite a function to calculate the sum of the positive integers of n+(n-2)+(n-4)... (until n-x =< 0).\nassert sum_series(6)==12\n\"\"\"\ndef sum_series(n):\n sum = 0\n for i in range(1, n+1):\n sum += i\n return sum\n"], ["\"\"\"\nWrite a function to calculate the area of a regular polygon.\nassert area_polygon(4,20)==400.00000000000006\n\"\"\"\nimport math\n\ndef area_polygon(n,sides):\n \"\"\"\n Calculate the area of a regular polygon\n \"\"\"\n # Calculate the apothem\n apothem = sides / (2 * math.tan(math.pi / n))\n # Calculate the perimeter\n perimeter = sides * n\n # Calculate the area\n area = (perimeter * apothem) / 2\n return area\n\n# Test the function"], ["\"\"\"\nWrite a python function to check whether the sum of divisors are same or not.\nassert areEquivalent(36,57) == False\n\"\"\"\ndef areEquivalent(a,b):\n if a % b == 0:\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a python function to count characters at same position in a given string (lower and uppercase characters) as in english alphabet.\nassert count_char_position(\"xbcefg\") == 2\n\"\"\"\ndef count_char_position(s):\n count = 0\n for i in range(len(s)):\n if s[i].isalpha():\n count += 1\n return count\n"], ["\"\"\"\nWrite a python function to count the pairs with xor as an even number.\nassert find_even_Pair([5,4,7,2,1],5) == 4\n\"\"\"\ndef find_even_Pair(arr, n):\n count = 0\n for i in range(len(arr)):\n for j in range(i+1, len(arr)):\n if arr[i] ^ arr[j] == 0:\n count += 1\n return count\n\narr = [5,4,7,2,1]\nn = 5"], ["\"\"\"\nWrite a python function to find smallest power of 2 greater than or equal to n.\nassert next_Power_Of_2(0) == 1\n\"\"\"\ndef next_Power_Of_2(n):\n if n == 0:\n return 1\n else:\n return 2 ** (n - 1) + 1\n"], ["\"\"\"\nWrite a python function to find the frequency of a number in a given array.\nassert frequency([1,2,3],4) == 0\n\"\"\"\ndef frequency(arr, num):\n count = 0\n for i in arr:\n if i == num:\n count += 1\n return count\n\narr = [1,2,3,4,4,4,5,6,6,6,6]\nnum = 4"], ["\"\"\"\nWrite a function to calculate the nth pell number.\nassert get_pell(4) == 12\n\"\"\"\ndef get_pell(n):\n if n == 0:\n return 0\n elif n == 1:\n return 1\n else:\n return get_pell(n-1) + get_pell(n-2)\n"], ["\"\"\"\nWrite a function to find sum of the numbers in a list between the indices of a specified range.\nassert sum_range_list( [2,1,5,6,8,3,4,9,10,11,8,12],8,10)==29\n\"\"\"\ndef sum_range_list(lst, start, end):\n sum = 0\n for i in range(start, end+1):\n sum += lst[i]\n return sum\n"], ["\"\"\"\nWrite a function to find the perimeter of a pentagon.\nassert perimeter_pentagon(5)==25\n\"\"\"\ndef perimeter_pentagon(n):\n perimeter = 0\n for i in range(1, n+1):\n for j in range(i+1, n+1):\n for k in range(j+1, n+1):\n for l in range(k+1, n+1):\n perimeter += 10 + 2 * i + 2 * j + 2 * k + 2 * l\n return perimeter\n"], ["\"\"\"\nWrite a function to find the occurence of characters 'std' in the given string 1. list item 1. list item 1. list item 2. list item 2. list item 2. list item\nassert count_occurance(\"letstdlenstdporstd\") == 3\n\"\"\"\ndef count_occurance(string):\n count = 0\n for i in string:\n if i == 'std':\n count += 1\n return count\n"], ["\"\"\"\nWrite a function to remove everything except alphanumeric characters from a string.\nassert remove_splchar('python @#&^%$*program123')==('pythonprogram123')\n\"\"\"\ndef remove_splchar(s):\n return ''.join(ch for ch in s if ch.isalnum())\n"], ["\"\"\"\nWrite a function to group a sequence of key-value pairs into a dictionary of lists.\nassert group_keyvalue([('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)])=={'yellow': [1, 3], 'blue': [2, 4], 'red': [1]}\n\"\"\"\ndef group_keyvalue(keyvalue_pairs):\n result = {}\n for key, value in keyvalue_pairs:\n if key in result:\n result[key].append(value)\n else:\n result[key] = [value]\n return result\n\nkeyvalue_pairs = [('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)]"], ["\"\"\"\nWrite a function to verify validity of a string of parentheses.\nassert is_valid_parenthese(\"(){}[]\")==True\n\"\"\"\ndef is_valid_parenthese(s):\n stack = []\n for i in s:\n if i == '(':\n stack.append(i)\n elif i == ')':\n if len(stack) == 0:\n return False\n else:\n stack.pop()\n if len(stack) == 0:\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a function to find the perimeter of a triangle.\nassert perimeter_triangle(10,20,30)==60\n\"\"\"\ndef perimeter_triangle(a,b,c):\n perimeter = a + b + c\n return perimeter\n"], ["\"\"\"\nWrite a python function to find two distinct numbers such that their lcm lies within the given range.\nassert answer(3,8) == (3,6)\n\"\"\"\nfrom math import gcd\nfrom itertools import combinations\n\ndef find_two_numbers(lcm_range):\n # find all combinations of two numbers in the range\n combinations_list = list(combinations(range(1, lcm_range+1), 2))\n # filter out the numbers that are not in the range\n valid_combinations = [num for num in combinations_list if num >= lcm_range]\n # find the lcm of the valid combinations\n lcm_list = [num for num in valid_combinations if lcm_range % num == 0]\n # find the two numbers that have the lcm in the range\n two_numbers = [num for num in lcm_list if num in valid_combinations]\n # return the two numbers that are in the range\n return two_numbers[0], two_numbers[1]\n\ndef lcm(a, b):\n return abs(a*b) // gcd(a, b)\n\ndef find_two_numbers(lcm_range):\n # find two numbers that have lcm in the range\n two_numbers = find_two_numbers(lcm_range)\n # return the two numbers\n return two_numbers\n"], ["\"\"\"\nWrite a function to search some literals strings in a string.\nassert string_literals(['language'],'python language')==('Matched!')\n\"\"\"\ndef search_literals(string, literals):\n for literal in literals:\n if literal in string:\n return literal\n return None\n"], ["\"\"\"\nWrite a function to find if the given number is a keith number or not.\nassert is_num_keith(14) == True\n\"\"\"\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith_number(n):\n if n % 2 == 0:\n return False\n else:\n return True\n\ndef is_keith"], ["\"\"\"\nWrite a function to calculate distance between two points using latitude and longitude.\nassert distance_lat_long(23.5,67.5,25.5,69.5)==12179.372041317429\n\"\"\"\nimport math\n\ndef distance_lat_long(lat1, lon1, lat2, lon2):\n \"\"\"\n Calculate distance between two points using latitude and longitude.\n \"\"\"\n # Convert latitude and longitude to radians\n lat1, lon1, lat2, lon2 = map(math.radians, [lat1, lon1, lat2, lon2])\n\n # Calculate distance using Haversine formula\n dlat = lat2 - lat1\n dlon = lon2 - lon1\n a = math.sin(dlat/2)**2 + math.cos(lat1) * math.cos(lat2) * math.sin(dlon/2)**2\n c = 2 * math.asin(math.sqrt(a))\n r = 6371 # km\n return c * r # km\n"], ["\"\"\"\nWrite a function to find the longest common prefix in the given set of strings.\nassert common_prefix([\"tablets\", \"tables\", \"taxi\", \"tamarind\"], 4) == 'ta'\n\"\"\"\ndef longest_common_prefix(strs):\n if not strs:\n return \"\"\n if len(strs) == 1:\n return strs[0]\n min_len = min(len(s) for s in strs)\n for i in range(min_len):\n for s in strs:\n if s[i] != strs[0][i]:\n return strs[0:min_len-i-1]\n return strs[0:min_len] # return the first common prefix\n\n"], ["\"\"\"\nWrite a function to find uppercase, lowercase, special character and numeric values using regex.\nassert find_character(\"ThisIsGeeksforGeeks\") == (['T', 'I', 'G', 'G'], ['h', 'i', 's', 's', 'e', 'e', 'k', 's', 'f', 'o', 'r', 'e', 'e', 'k', 's'], [], [])\n\"\"\"\nimport re\n\ndef find_character(s):\n uppercase = re.findall(r'[A-Z]', s)\n lowercase = re.findall(r'[a-z]', s)\n special = re.findall(r'[!@#$%^&*(),.?\":{}|<>]', s)\n numeric = re.findall(r'[0-9]', s)\n return (uppercase, lowercase, special, numeric)\n"], ["\"\"\"\nWrite a function to count all the distinct pairs having a difference of k in any array.\nassert count_pairs([1, 5, 3, 4, 2], 5, 3) == 2\n\"\"\"\ndef count_pairs(arr, k):\n count = 0\n for i in range(len(arr)-1):\n for j in range(i+1, len(arr)):\n if abs(arr[i] - arr[j]) == k:\n count += 1\n return count\n"], ["\"\"\"\nWrite a function to find all the values in a list that are greater than a specified number.\nassert greater_specificnum([220, 330, 500],200)==True\n\"\"\"\ndef greater_specificnum(lst, num):\n return [x for x in lst if x > num] \n"], ["\"\"\"\nWrite a function to find the focus of a parabola.\nassert parabola_focus(5,3,2)==(-0.3, 1.6)\n\"\"\"\ndef parabola_focus(a, b, c):\n x1 = -b/(2*a)\n y1 = a*x1**2 + b*x1 + c\n x2 = -b/(2*a)\n y2 = a*x2**2 + b*x2 + c\n if x1*x2 < 0:\n return (x1, y1)\n elif x1*x2 > 0:\n return (x2, y2)\n else:\n return (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 < y2 else (x2, y2) if y2 < y1 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 < y2 else (x2, y2) if y1 > y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1 == y2 else (x2, y1) if y2 == y1 else (x1, y1) if y1 > y2 else (x2, y2) if y1 < y2 else (x1, y2) if y1"], ["\"\"\"\nWrite a function to search some literals strings in a string by using regex.\nassert check_literals('The quick brown fox jumps over the lazy dog.',['fox']) == 'Matched!'\n\"\"\"\nimport re\n\ndef search_literals(string, literals):\n for literal in literals:\n if re.search(literal, string):\n return literal\n return None\n\n# Test the function\nstring = 'The quick brown fox jumps over the lazy dog.'\nliterals = ['fox']"], ["\"\"\"\nWrite a function to find the longest common subsequence for the given two sequences.\nassert longest_common_subsequence(\"AGGTAB\" , \"GXTXAYB\", 6, 7) == 4\n\"\"\"\ndef longest_common_subsequence(seq1, seq2, n, m):\n dp = [[0 for i in range(m+1)] for j in range(n+1)]\n for i in range(1, n+1):\n for j in range(1, m+1):\n if seq1[i-1] == seq2[j-1]:\n dp[i][j] = dp[i-1][j-1] + 1\n else:\n dp[i][j] = max(dp[i-1][j], dp[i][j-1])\n return dp[n][m]\n"], ["\"\"\"\nWrite a python function to check whether the given number can be represented by product of two squares or not.\nassert prod_Square(25) == False\n\"\"\"\ndef is_square(n):\n if n < 0:\n return False\n root = int(n ** 0.5)\n return root * root == n\n\ndef prod_Square(n):\n if n < 0:\n return False\n root = int(n ** 0.5)\n return root * root * root == n\n"], ["\"\"\"\nWrite a python function to find the first missing positive number.\nassert first_Missing_Positive([1,2,3,-1,5],5) == 4\n\"\"\"\ndef first_Missing_Positive(nums, target):\n if target < 1:\n return 1\n for i in range(1, target+1):\n if i not in nums:\n return i\n return target\n"], ["\"\"\"\nWrite a python function to count the number of integral co-ordinates that lie inside a square.\nassert count_Intgral_Points(1,1,4,4) == 4\n\"\"\"\ndef count_Intgral_Points(x,y,z,w):\n count = 0\n for i in range(x-1, x+w+1):\n for j in range(y-1, y+w+1):\n for k in range(z-1, z+w+1):\n for l in range(w-1, w+w+1):\n if i==x and j==y and k==z and l==w:\n count += 1\n return count\n"], ["\"\"\"\nWrite a function to check whether the given month name contains 30 days or not.\nassert check_monthnumber(\"February\")==False\n\"\"\"\ndef check_monthnumber(month):\n if month in [\"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"]:\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a python function to check whether a string has atleast one letter and one number.\nassert check_String('thishasboth29') == True\n\"\"\"\ndef check_String(string):\n if len(string) >= 1 and len(string) >= 1:\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a function to remove the duplicates from the given tuple.\nassert remove_tuple((1, 3, 5, 2, 3, 5, 1, 1, 3)) == (1, 2, 3, 5)\n\"\"\"\ndef remove_tuple(t):\n return tuple(set(t))\n\n"], ["\"\"\"\nWrite a python function to convert octal number to decimal number.\nassert octal_To_Decimal(25) == 21\n\"\"\"\ndef octal_To_Decimal(octal):\n decimal = 0\n for i in range(len(octal)):\n decimal += int(octal[i]) * (8 ** (len(octal) - 1 - i))\n return decimal\n"], ["\"\"\"\nWrite a python function to find the first position of an element in a sorted array.\nassert first([1,2,3,4,5,6,6],6,6) == 5\n\"\"\"\ndef first(arr, target, index):\n if index == 0:\n return 0\n if index == len(arr) - 1:\n return len(arr) - 1\n if arr[index] == target:\n return index\n if arr[index] > target:\n return first(arr, target, index - 1)\n return first(arr, target, index + 1)\n\narr = [1,2,3,4,5,6,6]\ntarget = 6"], ["\"\"\"\nWrite a function to remove all the tuples with length k.\nassert remove_tuples([(4, 5), (4, ), (8, 6, 7), (1, ), (3, 4, 6, 7)] , 1) == [(4, 5), (8, 6, 7), (3, 4, 6, 7)]\n\"\"\"\ndef remove_tuples(tuples, k):\n return [tuple(t) for t in tuples if len(t) - k > 0] + [tuple(t) for t in tuples if len(t) - k == 0] + [tuple(t) for t in tuples if len(t) == k] + [tuple(t) for t in tuples if len(t) == 0] + [tuple(t) for t in tuples if len(t) == k + 1] + [tuple(t) for t in tuples if len(t) == k + 2] + [tuple(t) for t in tuples if len(t) == k + 3] + [tuple(t) for t in tuples if len(t) == k + 4] + [tuple(t) for t in tuples if len(t) == k + 5] + [tuple(t) for t in tuples if len(t) == k + 6] + [tuple(t) for t in tuples if len(t) == k + 7] + [tuple(t) for t in tuples if len(t) == k + 8] + [tuple(t) for t in tuples if len(t) == k + 9] + [tuple(t) for t in tuples if len(t) == k + 10] + [tuple(t) for t in tuples if len(t) == k + 11] + [tuple(t) for t in tuples if len(t) == k + 12] + [tuple(t) for t in tuples if len(t) == k + 13] + [tuple(t) for t in tuples if len(t) == k + 14] + [tuple(t) for t in tuples if len(t) == k + 15] + [tuple(t) for t in tuples if len(t) == k + 16] + [tuple(t) for t in tuples if len(t) == k + 17] + [tuple(t) for t in tuples if len(t) == k + 18] + [tuple(t) for t in tuples if len(t) == k + 19] + [tuple(t) for t in tuples if len(t) == k + 20] + [tuple(t) for t in tuples if len(t) == k + 21] + [tuple(t) for t in tuples if len(t) == k + 22] + [tuple(t) for t in tuples if len(t) == k + 23] + [tuple(t) for t in tuples if len(t) == k + 24] + [tuple(t) for t in tuples if len(t) == k + 25] + [tuple(t) for t in tuples if len(t) == k + 26] + [tuple(t) for t in tuples if len(t) == k + 27] + [tuple(t) for t in tuples if len(t) == k + 28] + [tuple(t) for t in tuples if len(t) == k + 29] + [tuple(t) for t in tuples if len(t) == k + 30] + [tuple(t) for t in tuples if len(t) == k + 31] + [tuple(t) for t in tuples if len(t) == k + 32] + [tuple(t) for t in tuples if len(t) == k + 33] + [tuple(t) for t in tuples if len(t) == k + 34] + [tuple(t) for t in tuples if len(t) == k + 35] + [tuple(t) for t in tuples if len(t) == k + 36] + [tuple(t) for t in tuples if len(t) == k + 37] + [tuple(t) for t in tuples if len(t) == k + 38] + [tuple(t) for t in tuples if len(t) == k + 39] + [tuple(t) for t in tuples if len(t) == k + 40] + [tuple(t) for t in tuples if len(t) == k + 41] + [tuple(t) for t in tuples if len(t) == k + 42] + [tuple(t) for t in tuples if len(t) == k + 43] + [tuple(t) for t in tuples if len(t) == k + 44] + [tuple(t) for t in tuples if len(t) == k + 45] + [tuple(t) for t in tuples if len(t) == k + 46] + [tuple(t) for t in tuples if len(t) == k + 47] + [tuple(t) for t in tuples if len(t) == k + 48] + [tuple(t) for t in tuples if len(t) == k + 49] + [tuple(t) for t in tuples if len(t) == k + 50] + [tuple(t) for t in tuples if len(t) == k + 51] + [tuple(t) for t in tuples if len(t) == k + 52] + [tuple(t) for t in tuples if len(t) == k + 53] + [tuple(t) for t in tuples if len(t) == k + 54] + [tuple(t) for t in tuples if len(t) == k + 55] + [tuple(t) for t in tuples if len(t) == k + 56] + [tuple(t) for t in tuples if len(t) == k + 57] + [tuple(t) for t in tuples if len(t) == k + 58] + [tuple(t) for t in tuples if len(t) == k + 59] + [tuple(t) for t in tuples if len(t) == k + 60] + [tuple(t) for t in tuples if len(t) == k + 61] + [tuple(t) for t in tuples if len(t) == k + 62] + [tuple(t) for t in tuples if len(t) == k + 63] + [tuple(t) for t in tuples if len(t) == k + 64] + [tuple(t) for t in tuples if len(t) == k + 65] + [tuple(t) for t in tuples if len(t) == k + 66] + [tuple(t) for t in tuples if len(t) == k + 67] + [tuple(t) for t in tuples if len(t) == k + 68] + [tuple(t) for t in tuples if len(t) == k + 69] + [tuple(t) for t in tuples if len(t) == k + 70] + [tuple(t) for t in tuples if len(t) == k + 71] + [tuple(t) for t in tuples if len(t) == k + 72] + [tuple(t) for t in tuples if len(t) == k + 73] + [tuple(t) for t in tuples if len(t) == k + 74] + [tuple(t) for t in tuples if len(t) == k + 75] + [tuple(t) for t in tuples if len(t) == k + 76] + [tuple(t) for t in tuples if len(t) == k + 77] + [tuple(t) for t in tuples if len(t) == k + 78] + [tuple(t) for t in tuples if len(t) == k + 79] + [tuple(t) for t in tuples if len(t) == k + 80] + [tuple(t) for t in tuples if len(t) == k + 81] + [tuple(t) for t in tuples if len(t) == k + 82] + [tuple(t) for t in tuples if len(t) == k + 83] + [tuple(t) for t in tuples if len(t) == k + 84] + [tuple(t) for t in tuples if len(t) == k + 85] + [tuple(t) for t in tuples if len(t) == k + 86] + [tuple(t) for t in tuples if len(t) == k + 87] + [tuple(t) for t in tuples if len(t) == k + 88] + [tuple(t) for t in tuples if len(t) == k + 89] + [tuple(t) for t in tuples if len(t) == k + 90] + [tuple(t) for t in tuples if len(t) == k + 91] + [tuple(t) for t in tuples if len(t) == k + 92] + [tuple(t) for t in tuples if len(t) == k + 93] + [tuple(t) for t in tuples if len(t) == k + 94] + [tuple(t) for t in tuples if len(t) == k + 95] + [tuple(t) for t in tuples if len(t) == k + 96] + [tuple(t) for t in tuples if len(t) == k + 97] + [tuple(t) for t in tuples if len(t) == k + 98] + [tuple(t) for t in tuples if len(t) == k + "], ["\"\"\"\nWrite a function to perform the exponentiation of the given two tuples.\nassert find_exponentio((10, 4, 5, 6), (5, 6, 7, 5)) == (100000, 4096, 78125, 7776)\n\"\"\"\nfrom typing import Tuple\n\n\ndef exponentio(a: Tuple[int, ...], b: Tuple[int, ...]) -> Tuple[int, ...]:\n result = []\n for i in range(len(a)):\n result.append(a[i] ** b[i])\n return tuple(result)\n\n"], ["\"\"\"\nWrite a function to find the largest triangle that can be inscribed in an ellipse.\nassert largest_triangle(4,2)==10.392304845413264\n\"\"\"\nimport math\ndef largest_triangle(a,b):\n # calculate the area of the triangle\n area = 0.5 * a * b\n # calculate the perimeter of the triangle\n perimeter = a + b + math.sqrt(a*a + b*b)\n # calculate the length of the longest side of the triangle\n longest_side = math.sqrt(perimeter)\n # calculate the largest triangle\n largest_triangle = longest_side / 2\n return largest_triangle\n\ndef main():\n a = 4\n b = 2\n print(largest_triangle(a,b))\n"], ["\"\"\"\nWrite a python function to find highest power of 2 less than or equal to given number.\nassert highest_Power_of_2(10) == 8\n\"\"\"\ndef highest_power_of_2(n):\n if n <= 0:\n return 0\n else:\n return 2 ** (n - 1)\n"], ["\"\"\"\nWrite a function to find all index positions of the maximum values in a given list.\nassert position_max([12,33,23,10,67,89,45,667,23,12,11,10,54])==[7]\n\"\"\"\ndef find_max_positions(lst):\n max_positions = []\n for i in range(len(lst)):\n if lst[i] > max_positions[-1]:\n max_positions.append(i)\n return max_positions\n"], ["\"\"\"\nWrite a python function to check whether the elements in a list are same or not.\nassert chkList(['one','one','one']) == True\n\"\"\"\ndef sameList(list1):\n for i in list1:\n if i != 'one':\n return False\n return True\n"], ["\"\"\"\nWrite a function to remove even characters in a string.\nassert remove_even(\"python\")==(\"pto\")\n\"\"\"\ndef remove_even(s):\n return \"\".join([c for c in s if c != \"e\"]) \n"], ["\"\"\"\nWrite a python function to find the hamming distance between given two integers.\nassert hamming_Distance(4,8) == 2\n\"\"\"\ndef hamming_Distance(a, b):\n if a == b:\n return 0\n else:\n return 1 + hamming_Distance(a >> 1, b >> 1) + (a & b) ^ (a & b)\n"], ["\"\"\"\nWrite a python function to count the occurrence of a given character in a string.\nassert count(\"abcc\",\"c\") == 2\n\"\"\"\ndef count(s, c):\n count = 0\n for i in s:\n if i == c:\n count += 1\n return count\n"], ["\"\"\"\nWrite a function to find the inversions of tuple elements in the given tuple list.\nassert inversion_elements((7, 8, 9, 1, 10, 7)) == (-8, -9, -10, -2, -11, -8)\n\"\"\"\ndef inversions_elements(t):\n inversions = []\n for i in range(len(t)):\n for j in range(i+1, len(t)):\n if t[i] > t[j]:\n inversions.append((t[i], t[j]))\n return inversions\n"], ["\"\"\"\nWrite a function to perform the adjacent element concatenation in the given tuples.\nassert concatenate_elements((\"DSP \", \"IS \", \"BEST \", \"FOR \", \"ALL \", \"UTS\")) == ('DSP IS ', 'IS BEST ', 'BEST FOR ', 'FOR ALL ', 'ALL UTS')\n\"\"\"\ndef adjacent_element_concatenation(tuples):\n result = []\n for i in range(len(tuples)):\n result.append(tuples[i] + tuples[i+1])\n return result\n"], ["\"\"\"\nWrite a function to count the longest repeating subsequences such that the two subsequences don\u2019t have same string characters at same positions.\nassert find_longest_repeating_subseq(\"AABEBCDD\") == 3\n\"\"\"\nfrom collections import defaultdict\nfrom itertools import combinations\n\ndef find_longest_repeating_subseq(s):\n \"\"\"\n :type s: str\n :rtype: int\n \"\"\"\n # Initialize the result\n result = 0\n\n # Initialize the dictionary to store the count of each character\n char_count = defaultdict(int)\n\n # Iterate over the string\n for i in range(len(s)):\n # If the current character is already in the dictionary, increment its count\n if s[i] in char_count:\n char_count[s[i]] += 1\n else:\n # Otherwise, initialize the count to 1\n char_count[s[i]] = 1\n\n # If the count of the current character is greater than the count of the previous character, update the result\n if char_count[s[i]] > char_count[s[i - 1]]:\n result = i - 1\n\n return result\n\n"], ["\"\"\"\nWrite a function to check the given decimal with a precision of 2 by using regex.\nassert is_decimal('123.11') == True\n\"\"\"\nimport re\n\ndef is_decimal(s):\n \"\"\"\n :param s: str\n :return: bool\n \"\"\"\n if re.match(r'^-?\\d+(\\.\\d+)?$', s):\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a function to delete the smallest element from the given heap and then insert a new item.\nassert heap_replace( [25, 44, 68, 21, 39, 23, 89],21)==[21, 25, 23, 44, 39, 68, 89]\n\"\"\"\nimport heapq\n\ndef heap_replace(heap, new_item):\n heapq.heapify(heap)\n heapq.heappush(heap, new_item)\n return heap\n\ndef heap_replace_2(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heapify(heap):\n for i in range(len(heap)-1, 0, -1):\n return heap[0], heap[1:]\n return heap[0], None\n\ndef heap_replace_3(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_4(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_5(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_6(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_7(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_8(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_9(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_10(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_11(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_12(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_13(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_14(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_15(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_16(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_17(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_18(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_19(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_20(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_21(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_22(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_23(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_24(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_25(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_26(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_27(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_28(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_29(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_30(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_31(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_32(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_33(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_34(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_35(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_36(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_37(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_38(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_39(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_40(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_41(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_42(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_43(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_44(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_45(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_46(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_47(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_48(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_49(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_50(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_51(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_52(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_53(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_54(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_55(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_56(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_57(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_58(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_59(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_60(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_61(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_62(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap_replace_63(heap, new_item):\n heap = heapify(heap)\n heap = heap_replace(heap, new_item)\n return heap\n\ndef heap"], ["\"\"\"\nWrite a function to check that the given string contains only a certain set of characters(in this case a-z, a-z and 0-9) by using regex.\nassert is_allowed_specific_char(\"ABCDEFabcdef123450\") == True\n\"\"\"\nimport re\n\ndef is_allowed_specific_char(s):\n return re.search(r'[a-z0-9]', s) is not None\n"], ["\"\"\"\nWrite a python function to count numbers whose oth and nth bits are set.\nassert count_Num(2) == 1\n\"\"\"\ndef count_Num(n):\n count = 0\n for i in range(n):\n if (i+1) & 1 == 1:\n count += 1\n return count\n"], ["\"\"\"\nWrite a python function to find the sum of fourth power of n natural numbers.\nassert fourth_Power_Sum(2) == 17\n\"\"\"\ndef fourth_Power_Sum(n):\n sum = 0\n for i in range(1, n+1):\n sum += i**4\n return sum\n"], ["\"\"\"\nWrite a function to perform the concatenation of two string tuples.\nassert concatenate_strings((\"Manjeet\", \"Nikhil\", \"Akshat\"), (\" Singh\", \" Meherwal\", \" Garg\")) == ('Manjeet Singh', 'Nikhil Meherwal', 'Akshat Garg')\n\"\"\"\ndef concatenate_strings(string_tuple1, string_tuple2):\n return string_tuple1 + string_tuple2\n"], ["\"\"\"\nWrite a function to convert radians to degrees.\nassert degree_radian(90)==5156.620156177409\n\"\"\"\nimport math\n\ndef rad_to_deg(radian):\n return math.degrees(radian)\n\ndef main():\n print(rad_to_deg(90))\n"], ["\"\"\"\nWrite a function to decode a run-length encoded given list.\nassert decode_list([[2, 1], 2, 3, [2, 4], 5,1])==[1,1,2,3,4,4,5,1]\n\"\"\"\ndef decode_list(lst):\n result = []\n for i in range(0, len(lst), 2):\n result.append(lst[i])\n result.append(lst[i+1])\n return result\n"], ["\"\"\"\nWrite a function to check if a nested list is a subset of another nested list.\nassert check_subset_list([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],[[12, 18, 23, 25, 45], [7, 11, 19, 24, 28], [1, 5, 8, 18, 15, 16]])==False\n\"\"\"\ndef check_subset_list(list1, list2):\n if len(list1) != len(list2):\n return False\n for i in range(len(list1)):\n if list1[i] != list2[i]:\n return False\n return True\n"], ["\"\"\"\nWrite a python function to find the first repeated character in a given string.\nassert first_Repeated_Char(\"Google\") == \"o\"\n\"\"\"\ndef first_Repeated_Char(string):\n char_dict = {}\n for char in string:\n if char in char_dict:\n return char\n else:\n char_dict[char] = 1\n return None\n"], ["\"\"\"\nWrite a python function to find the minimum operations required to make two numbers equal.\nassert min_Operations(2,4) == 1\n\"\"\"\ndef min_Operations(a,b):\n if a == b:\n return 0\n if a > b:\n return 1 + min_Operations(a-b, b)\n else:\n return 1 + min_Operations(a+b, b)\n"], ["\"\"\"\nWrite a function to extract maximum and minimum k elements in the given tuple.\nassert extract_min_max((5, 20, 3, 7, 6, 8), 2) == (3, 5, 8, 20)\n\"\"\"\nfrom typing import List\n\n\ndef extract_min_max(t: List[int], k: int) -> List[int]:\n if len(t) < k:\n return []\n else:\n return sorted(t)[:k]\n\n"], ["\"\"\"\nWrite a function to replace maximum n occurrences of spaces, commas, or dots with a colon.\nassert replace_max_specialchar('Python language, Programming language.',2)==('Python:language: Programming language.')\n\"\"\"\ndef replace_max_specialchar(s, n):\n s = s.replace(' ', ':')\n s = s.replace(',', ':')\n s = s.replace('.', ':')\n return s\n"], ["\"\"\"\nWrite a python function to find the first even number in a given list of numbers.\nassert first_even ([1, 3, 5, 7, 4, 1, 6, 8]) == 4\n\"\"\"\ndef first_even(lst):\n for i in lst:\n if i % 2 == 0:\n return i\n return None\n"], ["\"\"\"\nWrite a function to check if all the elements in tuple have same data type or not.\nassert check_type((5, 6, 7, 3, 5, 6) ) == True\n\"\"\"\ndef check_type(t):\n if type(t) == int:\n return True\n elif type(t) == float:\n return True\n elif type(t) == str:\n return True\n elif type(t) == list:\n return True\n elif type(t) == tuple:\n return True\n elif type(t) == set:\n return True\n elif type(t) == bool:\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a function to check for majority element in the given sorted array.\nassert is_majority([1, 2, 3, 3, 3, 3, 10], 7, 3) == True\n\"\"\"\ndef is_majority(nums, target, count):\n count = count % 2 == 0\n if count == 0:\n return False\n else:\n return count == len(nums) // 2\n\nnums = [1, 2, 3, 3, 3, 3, 10]\ntarget = 7\ncount = 3"], ["\"\"\"\nWrite a python function to count set bits of a given number.\nassert count_Set_Bits(2) == 1\n\"\"\"\ndef count_Set_Bits(n):\n count = 0\n while n:\n n &= n - 1\n count += 1\n return count\n"], ["\"\"\"\nWrite a python function to find the minimum element in a sorted and rotated array.\nassert find_Min([1,2,3,4,5],0,4) == 1\n\"\"\"\ndef find_Min(arr,low,high):\n if low > high:\n return None\n mid = (low+high)//2\n if mid == 0 or mid == high:\n return arr[mid]\n if mid < high:\n return find_Min(arr,low,mid-1)\n else:\n return find_Min(arr,mid+1,high)\n\narr = [1,2,3,4,5]\nn = len(arr)"], ["\"\"\"\nWrite a python function to remove the characters which have odd index values of a given string.\nassert odd_values_string('abcdef') == 'ace'\n\"\"\"\ndef remove_odd_values(string):\n return ''.join([char for i, char in enumerate(string) if i % 2 == 0])\n"], ["\"\"\"\nWrite a function to find minimum of three numbers.\nassert min_of_three(10,20,0)==0\n\"\"\"\ndef min_of_three(a,b,c):\n if a arr[j] + arr[i]:\n max_sum = max(max_sum, arr[i] + arr[j])\n return max_sum\n"], ["\"\"\"\nWrite a function to get the n largest items from a dataset.\nassert larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],2)==[100,90]\n\"\"\"\ndef get_largest_items(dataset, n):\n return sorted(dataset, key = lambda x: x, reverse=True)[:n] # sort the dataset in descending order and return the first n items\n\ndataset = [10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100]\nn = 2"], ["\"\"\"\nWrite a function to find the lateral surface area of a cylinder.\nassert lateralsuface_cylinder(10,5)==314.15000000000003\n\"\"\"\nimport math\n\ndef lateral_surface_area_cylinder(radius, height):\n \"\"\"\n :param radius: float\n :param height: float\n :return: float\n \"\"\"\n lateral_surface_area = 2 * math.pi * radius * height\n return lateral_surface_area\n\ndef main():\n \"\"\"\n :return: float\n \"\"\"\n print(lateral_surface_area_cylinder(10,5))\n"], ["\"\"\"\nWrite a function to find the volume of a cube.\nassert volume_cube(3)==27\n\"\"\"\nimport unittest\n\ndef volume_cube(side):\n return side ** 3\n"], ["\"\"\"\nWrite a python function to set all even bits of a given number.\nassert even_bit_set_number(10) == 10\n\"\"\"\ndef even_bit_set_number(number):\n return (number & 0x01) << 1\n"], ["\"\"\"\nWrite a python function to count the maximum number of equilateral triangles that can be formed within a given equilateral triangle.\nassert No_of_Triangle(4,2) == 7\n\"\"\"\ndef no_of_triangles(n, k):\n if n == 0 or k == 0:\n return 0\n if n == 1 or k == 1:\n return 1\n if n == 2 or k == 2:\n return 2\n if n == 3 or k == 3:\n return 4\n if n == 4 or k == 4:\n return 8\n if n == 5 or k == 5:\n return 12\n if n == 6 or k == 6:\n return 20\n if n == 7 or k == 7:\n return 30\n if n == 8 or k == 8:\n return 40\n if n == 9 or k == 9:\n return 50\n if n == 10 or k == 10:\n return 60\n if n == 11 or k == 11:\n return 70\n if n == 12 or k == 12:\n return 80\n if n == 13 or k == 13:\n return 90\n if n == 14 or k == 14:\n return 100\n if n == 15 or k == 15:\n return 120\n if n == 16 or k == 16:\n return 150\n if n == 17 or k == 17:\n return 180\n if n == 18 or k == 18:\n return 210\n if n == 19 or k == 19:\n return 240\n if n == 20 or k == 20:\n return 270\n if n == 21 or k == 21:\n return 300\n if n == 22 or k == 22:\n return 330\n if n == 23 or k == 23:\n return 360\n if n == 24 or k == 24:\n return 400\n if n == 25 or k == 25:\n return 450\n if n == 26 or k == 26:\n return 500\n if n == 27 or k == 27:\n return 540\n if n == 28 or k == 28:\n return 600\n if n == 29 or k == 29:\n return 660\n if n == 30 or k == 30:\n return 700\n if n == 31 or k == 31:\n return 750\n if n == 32 or k == 32:\n return 800\n if n == 33 or k == 33:\n return 850\n if n == 34 or k == 34:\n return 900\n if n == 35 or k == 35:\n return 950\n if n == 36 or k == 36:\n return 1000\n if n == 37 or k == 37:\n return 1050\n if n == 38 or k == 38:\n return 1100\n if n == 39 or k == 39:\n return 1150\n if n == 40 or k == 40:\n return 1200\n if n == 41 or k == 41:\n return 1250\n if n == 42 or k == 42:\n return 1300\n if n == 43 or k == 43:\n return 1350\n if n == 44 or k == 44:\n return 1400\n if n == 45 or k == 45:\n return 1450\n if n == 46 or k == 46:\n return 1500\n if n == 47 or k == 47:\n return 1550\n if n == 48 or k == 48:\n return 1600\n if n == 49 or k == 49:\n return 1650\n if n == 50 or k == 50:\n return 1700\n if n == 51 or k == 51:\n return 1750\n if n == 52 or k == 52:\n return 1800\n if n == 53 or k == 53:\n return 1850\n if n == 54 or k == 54:\n return 1900\n if n == 55 or k == 55:\n return 1950\n if n == 56 or k == 56:\n return 2000\n if n == 57 or k == 57:\n return 2050\n if n == 58 or k == 58:\n return 2100\n if n == 59 or k == 59:\n return 2150\n if n == 60 or k == 60:\n return 2200\n if n == 61 or k == 61:\n return 2250\n if n == 62 or k == 62:\n return 2300\n if n == 63 or k == 63:\n return 2350\n if n == 64 or k == 64:\n return 2400\n if n == 65 or k == 65:\n return 2450\n if n == 66 or k == 66:\n return 2500\n if n == 67 or k == 67:\n return 2550\n if n == 68 or k == 68:\n return 2600\n if n == 69 or k == 69:\n return 2650\n if n == 70 or k == 70:\n return 2700\n if n == 71 or k == 71:\n return 2750\n if n == 72 or k == 72:\n return 2800\n if n == 73 or k == 73:\n return 2850\n if n == 74 or k == 74:\n return 2900\n if n == 75 or k == 75:\n return 2950\n if n == 76 or k == 76:\n return 3000\n if n == 77 or k == 77:\n return 3050\n if n == 78 or k == 78:\n return 3100\n if n == 79 or k == 79:\n return 3150\n if n == 80 or k == 80:\n return 3200\n if n == 81 or k == 81:\n return 3250\n if n == 82 or k == 82:\n return 3300\n if n == 83 or k == 83:\n return 3350\n if n == 84 or k == 84:\n return 3400\n if n == 85 or k == 85:\n return 3450\n if n == 86 or k == 86:\n return 3500\n if n == 87 or k == 87:\n return 3550\n if n == 88 or k == 88:\n return 3600\n if n == 89 or k == 89:\n return 3650\n if n == 90 or k == 90:\n return 3700\n if n == 91 or k == 91:\n return 3750\n if n == 92 or k == 92:\n return 3800\n if n == 93 or k == 93:\n return 3850\n if n == 94 or k == 94:\n return 3900\n if n == 95 or k == 95:\n return 3950\n if"], ["\"\"\"\nWrite a function to check the occurrences of records which occur similar times in the given tuples.\nassert check_occurences([(3, 1), (1, 3), (2, 5), (5, 2), (6, 3)] ) == {(1, 3): 2, (2, 5): 2, (3, 6): 1}\n\"\"\"\ndef check_occurences(tuples):\n result = {}\n for i in range(len(tuples)):\n for j in range(i+1, len(tuples)):\n if tuples[i][0] == tuples[j][0] and tuples[i][1] == tuples[j][1]:\n if tuples[i][0] in result:\n result[tuples[i][0]] += 1\n else:\n result[tuples[i][0]] = 1\n if tuples[j][0] in result:\n result[tuples[j][0]] += 1\n else:\n result[tuples[j][0]] = 1\n return result\n"], ["\"\"\"\nWrite a python function to count number of non-empty substrings of a given string.\nassert number_of_substrings(\"abc\") == 6\n\"\"\"\ndef count_substrings(s):\n count = 0\n for i in range(len(s)):\n for j in range(i+1, len(s)+1):\n count += 1\n return count\n"], ["\"\"\"\nWrite a function to find the number of possible sequences of length n such that each of the next element is greater than or equal to twice of the previous element but less than or equal to m.\nassert get_total_number_of_sequences(10, 4) == 4\n\"\"\"\ndef get_total_number_of_sequences(n, m):\n if n == 0 or m == 0:\n return 0\n if n == 1:\n return 1\n if m == 1:\n return 0\n if n == 2:\n return 1\n if m == 2:\n return 0\n if n == 3:\n return 2\n if m == 3:\n return 1\n if n == 4:\n return 4\n if m == 4:\n return 0\n if n == 5:\n return 5\n if m == 5:\n return 4\n if n == 6:\n return 9\n if m == 6:\n return 4\n if n == 7:\n return 16\n if m == 7:\n return 9\n if n == 8:\n return 32\n if m == 8:\n return 16\n if n == 9:\n return 51\n if m == 9:\n return 4\n if n == 10:\n return 100\n if m == 10:\n return 9\n if n == 11:\n return 200\n if m == 11:\n return 16\n if n == 12:\n return 400\n if m == 12:\n return 16\n if n == 13:\n return 800\n if m == 13:\n return 16\n if n == 14:\n return 1600\n if m == 14:\n return 16\n if n == 15:\n return 3200\n if m == 15:\n return 16\n if n == 16:\n return 5100\n if m == 16:\n return 16\n if n == 17:\n return 10000\n if m == 17:\n return 16\n if n == 18:\n return 20000\n if m == 18:\n return 16\n if n == 19:\n return 20000\n if m == 19:\n return 16\n if n == 20:\n return 32000\n if m == 20:\n return 16\n if n == 21:\n return 32000\n if m == 21:\n return 16\n if n == 22:\n return 40000\n if m == 22:\n return 16\n if n == 23:\n return 40000\n if m == 23:\n return 16\n if n == 24:\n return 51000\n if m == 24:\n return 16\n if n == 25:\n return 51000\n if m == 25:\n return 16\n if n == 26:\n return 80000\n if m == 26:\n return 16\n if n == 27:\n return 80000\n if m == 27:\n return 16\n if n == 28:\n return 160000\n if m == 28:\n return 16\n if n == 29:\n return 320000\n if m == 29:\n return 16\n if n == 30:\n return 320000\n if m == 30:\n return 16\n if n == 31:\n return 510000\n if m == 31:\n return 16\n if n == 32:\n return 510000\n if m == 32:\n return 16\n if n == 33:\n return 800000\n if m == 33:\n return 16\n if n == 34:\n return 800000\n if m == 34:\n return 16\n if n == 35:\n return 1600000\n if m == 35:\n return 16\n if n == 36:\n return 3200000\n if m == 36:\n return 16\n if n == 37:\n return 3200000\n if m == 37:\n return 16\n if n == 38:\n return 5100000\n if m == 38:\n return 16\n if n == 39:\n return 5100000\n if m == 39:\n return 16\n if n == 40:\n return 8000000\n if m == 40:\n return 16\n if n == 41:\n return 8000000\n if m == 41:\n return 16\n if n == 42:\n return 16000000\n if m == 42:\n return 16\n if n == 43:\n return 32000000\n if m == 43:\n return 16\n if n == 44:\n return 32000000\n if m == 44:\n return 16\n if n == 45:\n return 51000000\n if m == 45:\n return 16\n if n == 46:\n return 51000000\n if m == 46:\n return 16\n if n == 47:\n return 80000000\n if m == 47:\n return 16\n if n == 48:\n return 80000000\n if m == 48:\n return 16\n if n == 49:\n return 160000000\n if m == 49:\n return 16\n if n == 50:\n return 320000000\n if m == 50:\n return 16\n if n == 51:\n return 320000000\n if m == 51:\n return 16\n if n == 52:\n return 510000000\n if m == 52:\n return 16\n if n == 53:\n return 510000000\n if m == 53:\n return 16\n if n == 54:\n return 800000000\n if m == 54:\n return 16\n if n == 55:\n return 800000000\n if m == 55:\n return 16\n if n == 56:\n return 1600000000\n if m == 56:\n return 16\n if n == 57:\n return 3200000000\n if m == 57:\n return 16\n if n == 58:\n return 3200000000\n if m == 58:\n return 16\n if n == 59:\n return 5100000000\n if m == 59:\n return 16\n if n == 60:\n return 5100000000\n if m == 60:\n return 16\n if n == 61:\n return 8000000000\n if m == 61:\n return 16\n if n == 62:\n return 8000000000\n if m == 62:\n return 16\n if n == 63:\n return 16000000000\n if m == 63:\n return 16\n if n == 64:\n return 32000000000\n if m == "], ["\"\"\"\nWrite a function to replace the last element of the list with another list.\nassert replace_list([1, 3, 5, 7, 9, 10],[2, 4, 6, 8])==[1, 3, 5, 7, 9, 2, 4, 6, 8]\n\"\"\"\ndef replace_list(lst, new_lst):\n lst[-1] = new_lst\n return lst\n"], ["\"\"\"\nWrite a function to generate a 3d array having each element as '*'.\nassert array_3d(6,4,3)==[[['*', '*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*', '*']], [['*', '*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*', '*']], [['*', '*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*', '*']]]\n\"\"\"\nimport numpy as np\ndef array_3d(n,m,p):\n array_3d = np.zeros((n,m,p))\n for i in range(n):\n for j in range(m):\n for k in range(p):\n array_3d[i,j,k] = '*'\n return array_3d"], ["\"\"\"\nWrite a function to count total characters in a string.\nassert count_charac(\"python programming\")==18\n\"\"\"\ndef count_charac(string):\n count = 0\n for i in string:\n count += 1\n return count\n"], ["\"\"\"\nWrite a function to sort the given list based on the occurrence of first element of tuples.\nassert sort_on_occurence([(1, 'Jake'), (2, 'Bob'), (1, 'Cara')]) == [(1, 'Jake', 'Cara', 2), (2, 'Bob', 1)]\n\"\"\"\ndef sort_on_occurence(lst):\n return sorted(lst, key=lambda x: x[0])\n\n# Test"], ["\"\"\"\nWrite a python function to find the next perfect square greater than a given number.\nassert next_Perfect_Square(35) == 36\n\"\"\"\nimport math\n\ndef next_Perfect_Square(n):\n \"\"\"\n Find the next perfect square greater than a given number.\n \"\"\"\n # find the square root of the number\n root = math.sqrt(n)\n # find the next perfect square\n next_square = int(root + 0.5)\n return next_square\n"], ["\"\"\"\nWrite a function to find the maximum sum of bi-tonic sub-sequence for the given array.\nassert max_sum([1, 15, 51, 45, 33, 100, 12, 18, 9], 9) == 194\n\"\"\"\nfrom typing import List\n\n\ndef max_sum(arr: List[int]) -> int:\n if not arr:\n return 0\n if len(arr) == 1:\n return arr[0]\n if len(arr) == 2:\n return max(arr[0], arr[1])\n\n max_sum = arr[0]\n for i in range(1, len(arr)):\n if arr[i] > arr[i - 1]:\n max_sum = max(max_sum, arr[i] + max_sum)\n else:\n max_sum = max(max_sum, arr[i] + arr[i - 1])\n\n return max_sum\n\n"], ["\"\"\"\nWrite a function for computing square roots using the babylonian method.\nassert babylonian_squareroot(10)==3.162277660168379\n\"\"\"\nimport math\n\ndef babylonian_squareroot(n):\n \"\"\"\n Compute the square root of n using the Babylonian method.\n \"\"\"\n # Initialize the first two values\n a = 1\n b = 0.5\n c = 0.0\n\n # Compute the next values\n while b**2 < n:\n c = (a + b) / 2.0\n a = b\n b = c\n return b\n\n# Test the function"], ["\"\"\"\nWrite a function to find the longest palindromic subsequence in the given string.\nassert lps(\"TENS FOR TENS\") == 5 \n\"\"\"\ndef lps(s):\n n = len(s)\n dp = [[0 for i in range(n)] for j in range(n)]\n for i in range(n):\n dp[i][i] = 1\n for i in range(n-1, -1, -1):\n for j in range(i+1, n):\n if s[i] == s[j]:\n dp[i][j] = dp[i+1][j-1] + 2\n else:\n dp[i][j] = max(dp[i+1][j], dp[i][j-1])\n lps = \"\"\n i = 0\n j = n-1\n while i < j:\n if s[i] == s[j]:\n lps = lps + s[i]\n i += 1\n j -= 1\n elif dp[i+1][j] > dp[i][j-1]:\n i += 1\n else:\n j -= 1\n return lps"], ["\"\"\"\nWrite a function to calculate the harmonic sum of n-1.\nassert harmonic_sum(7) == 2.5928571428571425\n\"\"\"\ndef harmonic_sum(n):\n sum = 0\n for i in range(1, n+1):\n sum += 1/i\n return sum\n"], ["\"\"\"\nWrite a function to find the intersection of two arrays using lambda function.\nassert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[1, 2, 4, 8, 9])==[1, 2, 8, 9]\n\"\"\"\ndef intersection_array(array1,array2):\n intersection = []\n for i in array1:\n if i in array2:\n intersection.append(i)\n return intersection\n"], ["\"\"\"\nWrite a python function to count the occcurences of an element in a tuple.\nassert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),4) == 0\n\"\"\"\ndef count_X(tup, element):\n count = 0\n for i in tup:\n if i == element:\n count += 1\n return count\n"], ["\"\"\"\nWrite a function to insert an element before each element of a list.\nassert insert_element(['Red', 'Green', 'Black'] ,'c')==['c', 'Red', 'c', 'Green', 'c', 'Black'] \n\"\"\"\ndef insert_element(lst, element):\n for i in range(len(lst)):\n lst[i] = element\n return lst\n\nlst = ['Red', 'Green', 'Black']"], ["\"\"\"\nWrite a python function to convert complex numbers to polar coordinates.\nassert convert(1) == (1.0, 0.0)\n\"\"\"\nimport math\n\ndef convert(c):\n \"\"\"\n Convert complex numbers to polar coordinates.\n \"\"\"\n r = abs(c)\n theta = math.atan2(c.imag, c.real)\n return r, theta\n\ndef convert_polar(r, theta):\n \"\"\"\n Convert complex numbers to polar coordinates.\n \"\"\"\n return r, theta\n\ndef convert_complex(c):\n \"\"\"\n Convert complex numbers to polar coordinates.\n \"\"\"\n r, theta = convert(c)\n return r, theta\n\ndef main():\n \"\"\"\n Test the convert_complex function.\n \"\"\"\n print(convert_complex(1))\n print(convert_polar(convert_complex(1), 0))\n print(convert_polar(convert_complex(1), math.pi))\n print(convert_polar(convert_complex(1), math.pi/2))\n print(convert_polar(convert_complex(1), math.pi/4))\n print(convert_polar(convert_complex(1), math.pi/8))\n print(convert_polar(convert_complex(1), math.pi/16))\n print(convert_polar(convert_complex(1), math.pi/32))\n print(convert_polar(convert_complex(1), math.pi/64))\n print(convert_polar(convert_complex(1), math.pi/128))\n print(convert_polar(convert_complex(1), math.pi/256))\n print(convert_polar(convert_complex(1), math.pi/512))\n print(convert_polar(convert_complex(1), math.pi/1024))\n print(convert_polar(convert_complex(1), math.pi/2048))\n print(convert_polar(convert_complex(1), math.pi/4096))\n print(convert_polar(convert_complex(1), math.pi/8192))\n print(convert_polar(convert_complex(1), math.pi/16384))\n print(convert_polar(convert_complex(1), math.pi/32768))\n print(convert_polar(convert_complex(1), math.pi/65536))\n print(convert_polar(convert_complex(1), math.pi/131072))\n print(convert_polar(convert_complex(1), math.pi/262144))\n print(convert_polar(convert_complex(1), math.pi/524288))\n print(convert_polar(convert_complex(1), math.pi/1048576))\n print(convert_polar(convert_complex(1), math.pi/2097152))\n print(convert_polar(convert_complex(1), math.pi/4179928))\n print(convert_polar(convert_complex(1), math.pi/8388608))\n print(convert_polar(convert_complex(1), math.pi/17283840))\n print(convert_polar(convert_complex(1), math.pi/34576728))\n print(convert_polar(convert_complex(1), math.pi/77722776))\n print(convert_polar(convert_complex(1), math.pi/305970584))\n print(convert_polar(convert_complex(1), math.pi/1015841072))\n print(convert_polar(convert_complex(1), math.pi/2041682816))\n print(convert_polar(convert_complex(1), math.pi/4074296024))\n print(convert_polar(convert_complex(1), math.pi/8248296024))\n print(convert_polar(convert_complex(1), math.pi/163840296024))\n print(convert_polar(convert_complex(1), math.pi/327680296024))\n print(convert_polar(convert_complex(1), math.pi/65536024024))\n print(convert_polar(convert_complex(1), math.pi/1310720296024))\n print(convert_polar(convert_complex(1), math.pi/2621440296024))\n print(convert_polar(convert_complex(1), math.pi/5242880296024))\n print(convert_polar(convert_complex(1), math.pi/1048576024024))\n print(convert_polar(convert_complex(1), math.pi/17283840024024))\n print(convert_polar(convert_complex(1), math.pi/2097152024024))\n print(convert_polar(convert_complex(1), math.pi/4179928024024))\n print(convert_polar(convert_complex(1), math.pi/8388608024024))\n print(convert_polar(convert_complex(1), math.pi/17283840024024))\n print(convert_polar(convert_complex(1), math.pi/34576728024024))\n print(convert_polar(convert_complex(1), math.pi/305970584024024))\n print(convert_polar(convert_complex(1), math.pi/1015841072024024))\n print(convert_polar(convert_complex(1), math.pi/4074296024024024))\n print(convert_polar(convert_complex(1), math.pi/8248296024024024))\n print(convert_polar(convert_complex(1), math.pi/163840296024024024))\n print(convert_polar(convert_complex(1), math.pi/327680296024024024))\n print(convert_polar(convert_complex(1), math.pi/65536024024024024))\n print(convert_polar(convert_complex(1), math.pi/1310720296024024))\n print(convert_polar(convert_complex(1), math.pi/2621440296024024))\n print(convert_polar(convert_complex(1), math.pi/5242880296024024))\n print(convert_polar(convert_complex(1), math.pi/1048576024024024))\n print(convert_polar(convert_complex(1), math.pi/17283840024024024))\n print(convert_polar(convert_complex(1), math.pi/2097152024024024))\n print(convert_polar(convert_complex(1), math.pi/4179928024024024))\n print(convert_polar(convert_complex(1), math.pi/8388608024024024))\n print(convert_polar(convert_complex(1), math.pi/17283840024024024))\n print(convert_polar(convert_complex(1), math.pi/34576728024024024))\n print(convert_polar(convert_complex(1), math.pi/305970584024024024))\n print(convert_polar(convert_complex(1), math.pi/1015841072024024024))\n print(convert_polar(convert_complex(1), math.pi/4074296024024024024))\n print(convert_polar(convert_complex(1), math.pi/8248296024024024024))\n print(convert_polar(convert_complex(1), math.pi/163840296024024024024))\n print(convert_polar(convert_complex(1), math.pi/327680296024024024024))\n print(convert_polar(convert_complex(1), math.pi/65536024024024024024))\n print(convert_polar(convert_complex(1), math.pi/1310720296024024024024))\n print(convert_polar(convert_complex(1), math.pi/2621440296024024024024))\n print(convert_polar(convert_complex(1), math.pi/5242880296024024024024))\n print(convert_polar(convert_complex(1), math.pi/1048576024024024024024))\n print(convert_polar(convert_complex(1), math.pi/17283840024024024024024))\n print(convert_polar(convert_complex(1), math.pi/209"], ["\"\"\"\nWrite a python function to count integers from a given list.\nassert count_integer([1,2,'abc',1.2]) == 2\n\"\"\"\ndef count_integer(lst):\n count = 0\n for i in lst:\n if isinstance(i, int):\n count += 1\n return count\n"], ["\"\"\"\nWrite a function to find all words starting with 'a' or 'e' in a given string.\nassert words_ae(\"python programe\")==['ame']\n\"\"\"\ndef find_words_ae(string):\n words = string.split()\n result = []\n for word in words:\n if word[0].lower() in ['a', 'e']:\n result.append(word)\n return result\n"], ["\"\"\"\nWrite a function to choose specified number of colours from three different colours and generate all the combinations with repetitions.\nassert combinations_colors( [\"Red\",\"Green\",\"Blue\"],1)==[('Red',), ('Green',), ('Blue',)]\n\"\"\"\nfrom itertools import combinations\n\ndef combinations_colors(colors, n):\n return list(combinations(colors, n))\n\ncolors = [\"Red\",\"Green\",\"Blue\"]\nn = 1"], ["\"\"\"\nWrite a python function to count the number of prime numbers less than a given non-negative number.\nassert count_Primes_nums(5) == 2\n\"\"\"\ndef count_Primes_nums(n):\n count = 0\n for i in range(2, n):\n if is_prime(i):\n count += 1\n return count\n\ndef is_prime(num):\n if num <= 1:\n return False\n for i in range(2, num):\n if num % i == 0:\n return False\n return True\n"], ["\"\"\"\nWrite a function to swap two numbers.\nassert swap_numbers(10,20)==(20,10)\n\"\"\"\ndef swap_numbers(a,b):\n temp = a\n a = b\n b = temp\n return a,b\n"], ["\"\"\"\nWrite a function to find number of odd elements in the given list using lambda function.\nassert count_odd([1, 2, 3, 5, 7, 8, 10])==4\n\"\"\"\ndef count_odd(lst):\n return sum(1 for i in lst if i % 2 != 0)\n"], ["\"\"\"\nWrite a function to maximize the given two tuples.\nassert maximize_elements(((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))) == ((6, 7), (4, 9), (2, 9), (7, 10))\n\"\"\"\ndef maximize_elements(tuples):\n max_sum = 0\n for i in range(len(tuples)):\n for j in range(i+1, len(tuples)):\n if sum(tuples[i]) + sum(tuples[j]) > max_sum:\n max_sum = sum(tuples[i]) + sum(tuples[j])\n return tuples\n"], ["\"\"\"\nWrite a function to find the nth newman\u2013shanks\u2013williams prime number.\nassert newman_prime(3) == 7 \n\"\"\"\ndef newman_prime(n):\n if n == 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\ndef newman_prime_2(n):\n if n == 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\ndef newman_prime_3(n):\n if n == 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\ndef newman_prime_4(n):\n if n == 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\ndef newman_prime_5(n):\n if n == 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\ndef newman_prime_6(n):\n if n == 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\ndef newman_prime_7(n):\n if n == 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\ndef newman_prime_8(n):\n if n == 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\ndef newman_prime_9(n):\n if n == 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\ndef newman_prime_10(n):\n if n == 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\ndef newman_prime_11(n):\n if n == 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\ndef newman_prime_12(n):\n if n == 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\ndef newman_prime_13(n):\n if n == 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\ndef newman_prime_14(n):\n if n == 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\ndef newman_prime_15(n):\n if n == 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\ndef newman_prime_16(n):\n if n == 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\ndef newman_prime_17(n):\n if n == 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\ndef newman_prime_18(n):\n if n == 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\ndef newman_prime_19(n):\n if n == 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\ndef newman_prime_20(n):\n if n == 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\ndef newman_prime_21(n):\n if n == 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\ndef newman_prime_22(n):\n if n == 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\ndef newman_prime_23(n):\n if n == 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\ndef newman_prime_24(n):\n if n == 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\ndef newman_prime_25(n):\n if n == 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n i = 3\n while i * i <= n:\n if n % i == 0:\n return False\n i += 2\n return True\n\ndef newman_prime_26(n):\n"], ["\"\"\"\nWrite a function to perform mathematical division operation across the given tuples.\nassert division_elements((10, 4, 6, 9),(5, 2, 3, 3)) == (2, 2, 2, 3)\n\"\"\"\ndef divide(t1, t2):\n if t1[0] == t2[0]:\n return t1[1] / t2[1]\n else:\n return \"Error: Division by zero\"\n"], ["\"\"\"\nWrite a function to split a given list into two parts where the length of the first part of the list is given.\nassert split_two_parts([1,1,2,3,4,4,5,1],3)==([1, 1, 2], [3, 4, 4, 5, 1])\n\"\"\"\ndef split_two_parts(lst, n):\n mid = len(lst) // 2\n return lst[:mid], lst[mid:]\n\nlst = [1,1,2,3,4,4,5,1]\nn = 3"], ["\"\"\"\nWrite a function to merge two dictionaries.\nassert merge_dict({'a': 100, 'b': 200},{'x': 300, 'y': 200})=={'x': 300, 'y': 200, 'a': 100, 'b': 200}\n\"\"\"\ndef merge_dict(dict1, dict2):\n merged_dict = dict1.copy()\n merged_dict.update(dict2)\n return merged_dict\n\ndict1 = {'a': 100, 'b': 200}\ndict2 = {'x': 300, 'y': 200}"], ["\"\"\"\nWrite a function to calculate a dog's age in dog's years.\nassert dog_age(12)==61\n\"\"\"\ndef dog_age(dog_age):\n return dog_age * 12\n"], ["\"\"\"\nWrite a function to split a list for every nth element.\nassert list_split(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'],3)==[['a', 'd', 'g', 'j', 'm'], ['b', 'e', 'h', 'k', 'n'], ['c', 'f', 'i', 'l']] \n\"\"\"\ndef list_split(lst, n):\n return [lst[i:i+n] for i in range(0, len(lst), n)]\n\n"], ["\"\"\"\nWrite a function to find the lateral surface area of a cube.\nassert lateralsurface_cube(5)==100\n\"\"\"\nimport math\n\ndef lateral_surface_cube(side):\n \"\"\"\n This function calculates the lateral surface area of a cube.\n \"\"\"\n return side * 4\n"], ["\"\"\"\nWrite a python function to find the sum of squares of first n odd natural numbers.\nassert square_Sum(2) == 10\n\"\"\"\ndef square_Sum(n):\n sum = 0\n for i in range(1, n+1):\n sum += i**2\n return sum\n"], ["\"\"\"\nWrite a function to find the n'th star number.\nassert find_star_num(3) == 37\n\"\"\"\ndef find_star_num(n):\n if n == 1:\n return 1\n else:\n return 1 + find_star_num(n-1)\n"], ["\"\"\"\nWrite a function to find the ascii value of a character.\nassert ascii_value('A')==65\n\"\"\"\ndef ascii_value(char):\n ascii_value = ord(char)\n return ascii_value\n"], ["\"\"\"\nWrite a python function to find the sum of even numbers at even positions.\nassert sum_even_and_even_index([5, 6, 12, 1, 18, 8],6) == 30\n\"\"\"\ndef sum_even_and_even_index(arr, index):\n sum = 0\n for i in range(index, len(arr)):\n if arr[i] % 2 == 0:\n sum += arr[i]\n return sum\n"], ["\"\"\"\nWrite a python function to find the sum of fifth power of first n even natural numbers.\nassert even_Power_Sum(2) == 1056\n\"\"\"\ndef even_Power_Sum(n):\n sum = 0\n for i in range(1, n+1):\n if i % 2 == 0:\n sum += i ** 5\n return sum\n"], ["\"\"\"\nWrite a function to perfom the rear element extraction from list of tuples records.\nassert rear_extract([(1, 'Rash', 21), (2, 'Varsha', 20), (3, 'Kil', 19)]) == [21, 20, 19]\n\"\"\"\ndef rear_extract(lst):\n return lst[::-1] # reverse the list and return the last element\n\n# Test the function"], ["\"\"\"\nWrite a function to substract the contents of one tuple with corresponding index of other tuple.\nassert substract_elements((10, 4, 5), (2, 5, 18)) == (8, -1, -13)\n\"\"\"\nfrom typing import Tuple\n\n\ndef substract_elements(tuple1: Tuple[int, int, int], tuple2: Tuple[int, int, int]) -> Tuple[int, int, int]:\n \"\"\"\n Substract the contents of one tuple with corresponding index of other tuple.\n :param tuple1: Tuple of integers\n :param tuple2: Tuple of integers\n :return: Tuple of integers\n \"\"\"\n return tuple1[1] - tuple2[1], tuple1[2] - tuple2[2], tuple1[0] - tuple2[0]\n\n"], ["\"\"\"\nWrite a python function to find sum of even index binomial coefficients.\nassert even_binomial_Coeff_Sum(4) == 8\n\"\"\"\ndef even_binomial_Coeff_Sum(n):\n sum = 0\n for i in range(n):\n if i % 2 == 0:\n sum += binomial(n, i)\n return sum\n\ndef binomial(n, k):\n if k > n:\n return 0\n if k == 0 or k == n:\n return 1\n return binomial(n-1, k-1) + binomial(n-1, k)\n"], ["\"\"\"\nWrite a python function to find the position of the last removed element from the given array.\nassert get_Position([2,5,4],3,2) == 2\n\"\"\"\ndef get_Position(arr, pos, val):\n for i in range(len(arr)-1, -1, -1):\n if arr[i] == val:\n return i\n return -1\n\narr = [2,5,4,3,2]\npos = 2\nval = 3"], ["\"\"\"\nWrite a function to find the volume of a cylinder.\nassert volume_cylinder(10,5)==1570.7500000000002\n\"\"\"\nimport math\n\ndef volume_cylinder(radius, height):\n volume = math.pi * radius ** 2 * height\n return volume\n\nvolume_cylinder(10,5) # 1570.7500000000002\n\n# Test"], ["\"\"\"\nWrite a function to filter a dictionary based on values.\nassert dict_filter({'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},170)=={'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190}\n\"\"\"\ndef dict_filter(dict1, value):\n return {k: v for k, v in dict1.items() if v == value} \n\ndict_filter({'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},170) # {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output: {'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190} \n\n# Output"], ["\"\"\"\nWrite a function to find the element count that occurs before the record in the given tuple.\nassert count_first_elements((1, 5, 7, (4, 6), 10) ) == 3\n\"\"\"\ndef count_first_elements(t):\n count = 0\n for i in t:\n if i == t[0]:\n count += 1\n return count\n"], ["\"\"\"\nWrite a function to find the nth decagonal number.\nassert is_num_decagonal(3) == 27\n\"\"\"\ndef decagonal(n):\n if n == 1:\n return 1\n else:\n return 1 + decagonal(n-1)\n\ndef is_num_decagonal(n):\n return decagonal(n) == n\n"], ["\"\"\"\nWrite a function to search an element in the given array by using sequential search.\nassert sequential_search([11,23,58,31,56,77,43,12,65,19],31) == (True, 3)\n\"\"\"\ndef sequential_search(array, element):\n for i in range(len(array)):\n if array[i] == element:\n return True, i\n return False, -1\n"], ["\"\"\"\nWrite a python function to check if the elements of a given list are unique or not.\nassert all_unique([1,2,3]) == True\n\"\"\"\ndef all_unique(lst):\n return len(lst) == len(set(lst))\n"], ["\"\"\"\nWrite a function to substaract two lists using map and lambda function.\nassert sub_list([1, 2, 3],[4,5,6])==[-3,-3,-3]\n\"\"\"\ndef sub_star(list1, list2):\n return list(map(lambda x: x*2, list1)) + list(map(lambda x: x*2, list2))\n\nlist1 = [1, 2, 3]\nlist2 = [4, 5, 6]"], ["\"\"\"\nWrite a python function to check whether the frequency of each digit is less than or equal to the digit itself.\nassert validate(1234) == True\n\"\"\"\ndef validate(num):\n freq = {}\n for i in str(num):\n if i in freq:\n freq[i] += 1\n else:\n freq[i] = 1\n for key in freq:\n if freq[key] > 1:\n return False\n return True\n"], ["\"\"\"\nWrite a function to check whether all items of a list are equal to a given string.\nassert check_element([\"green\", \"orange\", \"black\", \"white\"],'blue')==False\n\"\"\"\ndef check_element(lst, string):\n if len(lst) == len(string):\n for i in range(len(lst)):\n if lst[i] != string:\n return False\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a function that matches a string that has an a followed by two to three 'b'.\nassert text_match_two_three(\"ac\")==('Not matched!')\n\"\"\"\ndef text_match_two_three(text):\n if text[0] == 'a' and text[1] == 'b' and text[2] == 'b':\n return 'Matched!'\n else:\n return 'Not matched!'\n"], ["\"\"\"\nWrite a function to find the largest sum of contiguous array in the modified array which is formed by repeating the given array k times.\nassert max_sub_array_sum_repeated([10, 20, -30, -1], 4, 3) == 30\n\"\"\"\ndef max_sub_array_sum_repeated(arr, k):\n max_sum = 0\n for i in range(0, len(arr)):\n for j in range(0, len(arr)):\n for l in range(0, len(arr)):\n for m in range(0, len(arr)):\n temp_sum = 0\n for n in range(0, len(arr)):\n temp_sum += arr[n]\n if temp_sum > max_sum:\n max_sum = temp_sum\n return max_sum\n"], ["\"\"\"\nWrite a python function to find the sum of squares of first n even natural numbers.\nassert square_Sum(2) == 20\n\"\"\"\ndef square_Sum(n):\n sum = 0\n for i in range(1, n+1):\n sum += i * i\n return sum\n"], ["\"\"\"\nWrite a function to count array elements having modular inverse under given prime number p equal to itself.\nassert modular_inverse([ 1, 6, 4, 5 ], 4, 7) == 2\n\"\"\"\ndef modular_inverse(a, p):\n if p == 1:\n return 0\n if a % p == 0:\n return a // p\n else:\n return modular_inverse(a, p - 2)\n\ndef count_elements(a, p):\n count = 0\n for i in a:\n if modular_inverse(i, p) == 1:\n count += 1\n return count\n"], ["\"\"\"\nWrite a python function to calculate the number of odd days in a given year.\nassert odd_Days(100) == 5\n\"\"\"\ndef odd_Days(year):\n count = 0\n for i in range(1, year+1):\n if i % 2 != 0:\n count += 1\n return count\n"], ["\"\"\"\nWrite a function to find the list of lists with maximum length.\nassert max_length([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==(3, [13, 15, 17])\n\"\"\"\ndef max_length(lst):\n max_length = 0\n max_length_list = []\n for i in range(len(lst)):\n for j in range(i+1, len(lst)):\n if len(lst[i]) > len(lst[j]):\n max_length = len(lst[i])\n max_length_list = [lst[i]]\n elif len(lst[i]) == len(lst[j]):\n if len(lst[i]) > max_length:\n max_length = len(lst[i])\n max_length_list = [lst[i]]\n return max_length, max_length_list\n"], ["\"\"\"\nWrite a function to find out the number of ways of painting the fence such that at most 2 adjacent posts have the same color for the given fence with n posts and k colors.\nassert count_no_of_ways(2, 4) == 16\n\"\"\"\ndef count_no_of_ways(n, k):\n if n == 0 or k == 0:\n return 0\n if n == 1:\n return 1\n if k == 1:\n return 1\n if n == 2:\n return 2\n if k == 2:\n return 2 * count_no_of_ways(n-1, 1)\n if k == 3:\n return 2 * count_no_of_ways(n-1, 2)\n if k == 4:\n return 2 * count_no_of_ways(n-1, 3)\n if k == 5:\n return 2 * count_no_of_ways(n-1, 4)\n if k == 6:\n return 2 * count_no_of_ways(n-1, 5)\n if k == 7:\n return 2 * count_no_of_ways(n-1, 6)\n if k == 8:\n return 2 * count_no_of_ways(n-1, 7)\n if k == 9:\n return 2 * count_no_of_ways(n-1, 8)\n if k == 10:\n return 2 * count_no_of_ways(n-1, 9)\n if k == 11:\n return 2 * count_no_of_ways(n-1, 10)\n if k == 12:\n return 2 * count_no_of_ways(n-1, 11)\n if k == 13:\n return 2 * count_no_of_ways(n-1, 12)\n if k == 14:\n return 2 * count_no_of_ways(n-1, 13)\n if k == 15:\n return 2 * count_no_of_ways(n-1, 14)\n if k == 16:\n return 2 * count_no_of_ways(n-1, 15)\n if k == 17:\n return 2 * count_no_of_ways(n-1, 16)\n if k == 18:\n return 2 * count_no_of_ways(n-1, 17)\n if k == 19:\n return 2 * count_no_of_ways(n-1, 18)\n if k == 20:\n return 2 * count_no_of_ways(n-1, 19)\n if k == 21:\n return 2 * count_no_of_ways(n-1, 20)\n if k == 22:\n return 2 * count_no_of_ways(n-1, 21)\n if k == 23:\n return 2 * count_no_of_ways(n-1, 22)\n if k == 24:\n return 2 * count_no_of_ways(n-1, 23)\n if k == 25:\n return 2 * count_no_of_ways(n-1, 24)\n if k == 26:\n return 2 * count_no_of_ways(n-1, 25)\n if k == 27:\n return 2 * count_no_of_ways(n-1, 26)\n if k == 28:\n return 2 * count_no_of_ways(n-1, 27)\n if k == 29:\n return 2 * count_no_of_ways(n-1, 28)\n if k == 30:\n return 2 * count_no_of_ways(n-1, 29)\n if k == 31:\n return 2 * count_no_of_ways(n-1, 30)\n if k == 32:\n return 2 * count_no_of_ways(n-1, 31)\n if k == 33:\n return 2 * count_no_of_ways(n-1, 32)\n if k == 34:\n return 2 * count_no_of_ways(n-1, 33)\n if k == 35:\n return 2 * count_no_of_ways(n-1, 34)\n if k == 36:\n return 2 * count_no_of_ways(n-1, 35)\n if k == 37:\n return 2 * count_no_of_ways(n-1, 36)\n if k == 38:\n return 2 * count_no_of_ways(n-1, 37)\n if k == 39:\n return 2 * count_no_of_ways(n-1, 38)\n if k == 40:\n return 2 * count_no_of_ways(n-1, 39)\n if k == 41:\n return 2 * count_no_of_ways(n-1, 40)\n if k == 42:\n return 2 * count_no_of_ways(n-1, 41)\n if k == 43:\n return 2 * count_no_of_ways(n-1, 42)\n if k == 44:\n return 2 * count_no_of_ways(n-1, 43)\n if k == 45:\n return 2 * count_no_of_ways(n-1, 44)\n if k == 46:\n return 2 * count_no_of_ways(n-1, 45)\n if k == 47:\n return 2 * count_no_of_ways(n-1, 46)\n if k == 48:\n return 2 * count_no_of_ways(n-1, 47)\n if k == 49:\n return 2 * count_no_of_ways(n-1, 48)\n if k == 50:\n return 2 * count_no_of_ways(n-1, 49)\n if k == 51:\n return 2 * count_no_of_ways(n-1, 50)\n if k == 52:\n return 2 * count_no_of_ways(n-1, 51)\n if k == 53:\n return 2 * count_no_of_ways(n-1, 52)\n if k == 54:\n return 2 * count_no_of_ways(n-1, 53)\n if k == 55:\n return 2 * count_no_of_ways(n-1, 54)\n if k == 56:\n return 2 * count_no_of_ways(n-1, 55)\n if k == 57:\n return 2 * count_no_of_ways(n-1, 56)\n if k == 58:\n return 2 * count_no_of_ways(n-1, 57)\n if k == 59:\n return 2 * count_no_of_ways(n-1, 58)\n if k == 60:\n return 2 * count_no_of_ways(n-1, 59)\n if k == 61:\n return 2 * count_no_of_ways(n-1, 60)\n if k == 62:\n return 2 * count_no_of_ways(n-1, 61)\n if k == 63:\n return 2 * count_no_of_ways(n-1, 62)\n if k == 64:\n return 2 * count_no_of_ways(n-1, 63)\n if k == 65:\n return 2 * count_no_of_ways(n-1, 64)\n if k == 66:\n return 2 * count_no_of_ways(n-1, 65)\n if k == 67:\n return 2 * count_no_of_ways(n-1, 66)\n if k == 68:\n return 2 * count_no_of_ways(n-1, 67)\n if k == 69:\n return 2 * count_no_of_ways(n-1, 68)\n if k == 70:\n return 2 * count_no_of_ways(n-1, 69)\n if k == 71:\n return 2 * count_no_of_ways(n-1, 70)\n if k == 72:\n return 2 * count_no_of_ways(n-1, 71)\n if k == 73:\n return 2 * count_no_of_ways(n-1, 72)\n if k == 74:\n return 2 * count_no_of_ways(n-1, 73)\n if k == 75:\n return 2 * count_no_of_ways(n-1, 74)\n if k == 76:\n return 2 * count_no_of_ways(n-1, 75)\n if k == 77:\n return 2 * count_no_of_ways(n-1, 76)\n if k == 78:\n return 2 * count_no_of_ways(n-1, 77)\n"], ["\"\"\"\nWrite a python function to find quotient of two numbers.\nassert find(10,3) == 3\n\"\"\"\ndef find(a,b):\n return a/b\n"], ["\"\"\"\nWrite a function to find the third side of a right angled triangle.\nassert otherside_rightangle(7,8)==10.63014581273465\n\"\"\"\ndef otherside_rightangle(a,b):\n c = (a**2 + b**2)**0.5\n return c\n"], ["\"\"\"\nWrite a function to find the maximum value in a given heterogeneous list.\nassert max_val(['Python', 3, 2, 4, 5, 'version'])==5\n\"\"\"\ndef max_val(lst):\n max_val = 0\n for i in lst:\n if i > max_val:\n max_val = i\n return max_val\n"], ["\"\"\"\nWrite a function to return the sum of all divisors of a number.\nassert sum_div(8)==7\n\"\"\"\ndef sum_div(n):\n sum=0\n for i in range(1,n+1):\n if n%i==0:\n sum+=i\n return sum\n"], ["\"\"\"\nWrite a python function to count inversions in an array.\nassert get_Inv_Count([1,20,6,4,5],5) == 5\n\"\"\"\ndef get_Inv_Count(arr, n):\n inv_count = 0\n for i in range(n):\n for j in range(i+1, n):\n if arr[i] > arr[j]:\n inv_count += 1\n return inv_count\n\narr = [1,20,6,4,5]\nn = len(arr)"], ["\"\"\"\nWrite a function to flatten a given nested list structure.\nassert flatten_list([0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]])==[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]\n\"\"\"\ndef flatten_list(nested_list):\n flat_list = []\n for i in nested_list:\n if isinstance(i, list):\n flat_list.extend(i)\n else:\n flat_list.append(i)\n return flat_list\n"], ["\"\"\"\nWrite a function to find the nested list elements which are present in another list.\nassert intersection_nested_lists( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],[[12, 18, 23, 25, 45], [7, 11, 19, 24, 28], [1, 5, 8, 18, 15, 16]])==[[12], [7, 11], [1, 5, 8]]\n\"\"\"\ndef intersection_nested_lists(list1, list2):\n result = []\n for i in list2:\n if i in list1:\n result.append(i)\n return result\n"], ["\"\"\"\nWrite a function to calculate the maximum aggregate from the list of tuples.\nassert max_aggregate([('Juan Whelan',90),('Sabah Colley',88),('Peter Nichols',7),('Juan Whelan',122),('Sabah Colley',84)])==('Juan Whelan', 212)\n\"\"\"\ndef max_aggregate(tuples):\n max_value = 0\n for tup in tuples:\n max_value = max(max_value, tup[1])\n return max_value\n"], ["\"\"\"\nWrite a function to find the count of all binary sequences of length 2n such that sum of first n bits is same as sum of last n bits.\nassert count_binary_seq(1) == 2.0\n\"\"\"\nfrom collections import defaultdict\nfrom itertools import combinations\n\ndef count_binary_seq(n):\n # Create a dictionary to store the count of each binary sequence\n count_dict = defaultdict(int)\n\n # Generate all possible binary sequences of length 2n\n for i in range(0, 2*n, 2):\n # Generate all possible combinations of 2n bits\n for comb in combinations(range(2*n), 2):\n # Extract the first and last bits of the binary sequence\n first_bit = comb[0]\n last_bit = comb[-1]\n\n # Check if the sum of the first and last bits is equal\n if first_bit == last_bit:\n # Increment the count of the binary sequence\n count_dict[first_bit] += 1\n\n # Return the count of the binary sequence\n return count_dict[0]\n"], ["\"\"\"\nWrite a function to find the depth of a dictionary.\nassert dict_depth({'a':1, 'b': {'c': {'d': {}}}})==4\n\"\"\"\ndef dict_depth(d):\n if isinstance(d, dict):\n return 1 + max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max([max"], ["\"\"\"\nWrite a python function to find the most significant bit number which is also a set bit.\nassert set_Bit_Number(6) == 4\n\"\"\"\ndef most_significant_bit_set_bit(n):\n # Your code here\n count = 0\n while n != 0:\n n = n & (n - 1)\n count += 1\n return count\n"], ["\"\"\"\nWrite a python function to check whether the count of inversion of two types are same or not.\nassert solve([1,0,2],3) == True\n\"\"\"\ndef solve(a,b):\n count = 0\n for i in range(len(a)):\n for j in range(i+1,len(a)):\n if a[i] == a[j]:\n count += 1\n if count == b:\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a python function to find element at a given index after number of rotations.\nassert find_Element([1,2,3,4,5],[[0,2],[0,3]],2,1) == 3\n\"\"\"\ndef find_Element(nums,rotations,rot_index,rot_num):\n for i in range(rot_num):\n nums = nums[rot_index:] + nums[:rot_index]\n return nums[rot_index]\n\n"], ["\"\"\"\nWrite a function to match two words from a list of words starting with letter 'p'.\nassert start_withp([\"Python PHP\", \"Java JavaScript\", \"c c++\"])==('Python', 'PHP')\n\"\"\"\ndef match_word(word1, word2):\n if word1[0] == 'p' and word2[0] == 'p':\n return word1, word2\n else:\n return None\n"], ["\"\"\"\nWrite a function to find the maximum sum of increasing subsequence from prefix till ith index and also including a given kth element which is after i, i.e., k > i .\nassert max_sum_increasing_subseq([1, 101, 2, 3, 100, 4, 5 ], 7, 4, 6) == 11\n\"\"\"\ndef max_sum_increasing_subseq(arr, k, l, r):\n if k > r:\n return 0\n if l > r:\n return max_sum_increasing_subseq(arr, k, l+1, r)\n if arr[l] < arr[k]:\n return arr[k]\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return arr[l] + max_sum_increasing_subseq(arr, k+1, l+1, r)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1, r+1)\n if arr[l] < arr[k] and arr[l] < arr[r]:\n return max_sum_increasing_subseq(arr, k+1, l+1"], ["\"\"\"\nWrite a function to get a colon of a tuple.\nassert colon_tuplex((\"HELLO\", 5, [], True) ,2,50)==(\"HELLO\", 5, [50], True) \n\"\"\"\ndef get_colon(tuplex):\n colon = \"\"\n for i in tuplex:\n colon += i + \" \"\n return colon\n"], ["\"\"\"\nWrite a function to find the specified number of largest products from two given lists.\nassert large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],3)==[60, 54, 50]\n\"\"\"\ndef largest_product(list1, list2, n):\n list1.sort()\n list2.sort()\n result = []\n for i in range(n):\n result.append(list1[i]*list2[i])\n return result\n"], ["\"\"\"\nWrite a python function to find the maximum of two numbers.\nassert maximum(5,10) == 10\n\"\"\"\ndef max_of_two(a,b):\n if a > b:\n return a\n else:\n return b\n"], ["\"\"\"\nWrite a function to convert a given string to a tuple.\nassert string_to_tuple(\"python 3.0\")==('p', 'y', 't', 'h', 'o', 'n', '3', '.', '0')\n\"\"\"\ndef string_to_tuple(s):\n return s.split('.')[:3] + s.split('.')[-1] + s.split('.')[:-3]\n"], ["\"\"\"\nWrite a python function to set the left most unset bit.\nassert set_left_most_unset_bit(10) == 14\n\"\"\"\ndef set_left_most_unset_bit(n):\n if n == 0:\n return 1\n else:\n return n & (n - 1)\n"], ["\"\"\"\nWrite a function to find the volume of a cone.\nassert volume_cone(5,12)==314.15926535897927\n\"\"\"\nimport math\n\ndef volume_cone(radius, height):\n volume = (1/3) * math.pi * radius**2 * height\n return volume\n\nvolume_cone(5,12) # 314.15926535897927\n"], ["\"\"\"\nWrite a python function to print positive numbers in a list.\nassert pos_nos([-1,-2,1,2]) == 1,2\n\"\"\"\ndef print_positive_numbers(nos):\n for i in nos:\n if i > 0:\n print(i)\n"], ["\"\"\"\nWrite a function to find out the maximum sum such that no two chosen numbers are adjacent for the given rectangular grid of dimension 2 x n.\nassert max_sum_rectangular_grid([ [1, 4, 5], [2, 0, 0 ] ], 3) == 7\n\"\"\"\ndef max_sum_rectangular_grid(grid, n):\n # Initialize the maximum sum to 0\n max_sum = 0\n\n # Iterate over the grid\n for i in range(n):\n # Iterate over the grid\n for j in range(n):\n # Iterate over the grid\n for k in range(n):\n # Iterate over the grid\n for l in range(n):\n # Add the current number to the sum\n max_sum += grid[i][j][k] + grid[i][j][l] + grid[i][k][l]\n\n # Return the maximum sum\n return max_sum\n"], ["\"\"\"\nWrite a python function to find the first maximum length of even word.\nassert find_Max_Len_Even(\"python language\") == \"language\"\n\"\"\"\ndef find_Max_Len_Even(word):\n words = word.split()\n max_len = 0\n for word in words:\n if len(word) % 2 == 0:\n max_len = max(max_len, len(word))\n return max_len\n"], ["\"\"\"\nWrite a function to find the index of the last occurrence of a given number in a sorted array.\nassert find_last_occurrence([2, 5, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 3\n\"\"\"\ndef find_last_occurrence(arr, num):\n left = 0\n right = len(arr) - 1\n while left <= right:\n mid = left + (right - left) // 2\n if arr[mid] == num:\n return mid\n elif arr[mid] < num:\n left = mid + 1\n else:\n right = mid - 1\n return -1\n\narr = [2, 5, 5, 5, 6, 6, 8, 9, 9, 9]\nnum = 5"], ["\"\"\"\nWrite a function to reflect the modified run-length encoding from a list.\nassert modified_encode([1,1,2,3,4,4,5,1])==[[2, 1], 2, 3, [2, 4], 5, 1]\n\"\"\"\ndef modified_encode(lst):\n result = []\n for i in range(0, len(lst)-1):\n if lst[i] == lst[i+1]:\n result.append(lst[i])\n else:\n result.append(lst[i])\n result.append(lst[i+1])\n return result\n"], ["\"\"\"\nWrite a python function to find the maximum volume of a cuboid with given sum of sides.\nassert max_volume(8) == 18\n\"\"\"\ndef max_volume(sides):\n if sides[0] + sides[1] + sides[2] > sides[3]:\n return sides[0] + sides[1] + sides[2]\n else:\n return sides[3] + sides[0] + sides[1]\n"], ["\"\"\"\nWrite a function to find all five characters long word in the given string by using regex.\nassert find_long_word('Please move back to strem') == ['strem']\n\"\"\"\nimport re\n\ndef find_long_word(s):\n pattern = r'\\b\\w+\\b'\n matches = re.findall(pattern, s)\n return matches\n"], ["\"\"\"\nWrite a function to calculate the difference between the squared sum of first n natural numbers and the sum of squared first n natural numbers.\nassert sum_difference(12)==5434\n\"\"\"\ndef sum_difference(n):\n sum1 = 0\n sum2 = 0\n for i in range(1, n+1):\n sum1 += i\n sum2 += i**2\n return sum1 - sum2\n"], ["\"\"\"\nWrite a function to find the demlo number for the given number.\nassert find_demlo(\"111111\") == '12345654321'\n\"\"\"\ndef find_demlo(n):\n demlo = 0\n for i in range(1, n+1):\n demlo += i\n return demlo\n"], ["\"\"\"\nWrite a function to find all index positions of the minimum values in a given list.\nassert position_min([12,33,23,10,67,89,45,667,23,12,11,10,54])==[3,11]\n\"\"\"\ndef find_min_positions(lst):\n min_val = min(lst)\n min_positions = [i for i, x in enumerate(lst) if x == min_val]\n return min_positions\n"], ["\"\"\"\nWrite a function to re-arrange the given array in alternating positive and negative items.\nassert re_arrange([-5, -2, 5, 2, 4,\t7, 1, 8, 0, -8], 10) == [-5, 5, -2, 2, -8, 4, 7, 1, 8, 0]\n\"\"\"\ndef re_arrange(arr, n):\n for i in range(n):\n if i % 2 == 0:\n arr[i] = -arr[i]\n else:\n arr[i] = arr[i]\n return arr\n\narr = [-5, -2, 5, 2, 4, 7, 1, 8, 0, -8]\nn = 10"], ["\"\"\"\nWrite a function to extract the sum of alternate chains of tuples.\nassert sum_of_alternates((5, 6, 3, 6, 10, 34)) == (46, 18)\n\"\"\"\ndef sum_of_alternates(tuples):\n sum = 0\n for i in range(len(tuples)):\n if i % 2 == 0:\n sum += tuples[i]\n else:\n sum += tuples[i][::-1]\n return sum\n"], ["\"\"\"\nWrite a python function to find the minimum number of squares whose sum is equal to a given number.\nassert get_Min_Squares(6) == 3\n\"\"\"\ndef get_Min_Squares(n):\n if n == 0:\n return 0\n if n == 1:\n return 1\n if n == 2:\n return 2\n if n == 3:\n return 3\n if n == 4:\n return 4\n if n == 5:\n return 5\n if n == 6:\n return 6\n if n == 7:\n return 7\n if n == 8:\n return 8\n if n == 9:\n return 9\n if n == 10:\n return 10\n if n == 11:\n return 12\n if n == 12:\n return 14\n if n == 13:\n return 16\n if n == 14:\n return 18\n if n == 15:\n return 20\n if n == 16:\n return 22\n if n == 17:\n return 24\n if n == 18:\n return 26\n if n == 19:\n return 28\n if n == 20:\n return 30\n if n == 21:\n return 32\n if n == 22:\n return 34\n if n == 23:\n return 36\n if n == 24:\n return 38\n if n == 25:\n return 40\n if n == 26:\n return 42\n if n == 27:\n return 44\n if n == 28:\n return 46\n if n == 29:\n return 48\n if n == 30:\n return 50\n if n == 31:\n return 52\n if n == 32:\n return 54\n if n == 33:\n return 56\n if n == 34:\n return 58\n if n == 35:\n return 60\n if n == 36:\n return 62\n if n == 37:\n return 64\n if n == 38:\n return 66\n if n == 39:\n return 68\n if n == 40:\n return 70\n if n == 41:\n return 72\n if n == 42:\n return 74\n if n == 43:\n return 76\n if n == 44:\n return 78\n if n == 45:\n return 80\n if n == 46:\n return 82\n if n == 47:\n return 84\n if n == 48:\n return 86\n if n == 49:\n return 88\n if n == 50:\n return 90\n if n == 51:\n return 92\n if n == 52:\n return 94\n if n == 53:\n return 96\n if n == 54:\n return 98\n if n == 55:\n return 100\n if n == 56:\n return 102\n if n == 57:\n return 104\n if n == 58:\n return 106\n if n == 59:\n return 108\n if n == 60:\n return 110\n if n == 61:\n return 112\n if n == 62:\n return 114\n if n == 63:\n return 116\n if n == 64:\n return 118\n if n == 65:\n return 120\n if n == 66:\n return 122\n if n == 67:\n return 124\n if n == 68:\n return 126\n if n == 69:\n return 128\n if n == 70:\n return 130\n if n == 71:\n return 132\n if n == 72:\n return 134\n if n == 73:\n return 136\n if n == 74:\n return 138\n if n == 75:\n return 140\n if n == 76:\n return 142\n if n == 77:\n return 144\n if n == 78:\n return 146\n if n == 79:\n return 148\n if n == 80:\n return 150\n if n == 81:\n return 152\n if n == 82:\n return 154\n if n == 83:\n return 156\n if n == 84:\n return 158\n if n == 85:\n return 160\n if n == 86:\n return 162\n if n == 87:\n return 164\n if n == 88:\n return 166\n if n == 89:\n return 168\n if n == 90:\n return 170\n if n == 91:\n return 172\n if n == 92:\n return 174\n if n == 93:\n return 176\n if n == 94:\n return 178\n if n == 95:\n return 180\n if n == 96:\n return 182\n if n == 97:\n return 184\n if n == 98:\n return 186\n if n == 99:\n return 188\n if n == 100:\n return 190\n if n == 101:\n return 192\n if n == 102:\n return 194\n if n == 103:\n return 196\n if n == 104:\n return 198\n if n == 105:\n return 200\n if n == 106:\n return 202\n if n == 107:\n return 204\n if n == 108:\n return 206\n if n == 109:\n return 208\n if n == 110:\n return 210\n if n == 111:\n return 212\n if n == 112:\n return 214\n if n == 113:\n return 216\n if n == 114:\n return 218\n if n == 115:\n return 220\n if n == 116:\n return 222\n if n == 117:\n return 224\n if n == 118:\n return 226\n if n == 119:\n return 228\n if n == 120:\n return 230\n if n == 121:\n return 232\n if n == 122:\n return 234\n if n == 123:\n return 236\n if n == 124:\n return 238\n if n == 125:\n return 240\n if n == 126:\n return 242\n if n == 127:\n return 244\n if n == 128:\n return 246\n if n == 129:\n return 248\n if n == 130:\n return 250\n if n == 131:\n return 252\n if n == 132:\n return 254\n if n == 133:\n return 256\n if n == 134:\n return 258\n if n == 135:\n return 260\n if n == 136:\n return 262\n if n == 137:\n return 264\n if n == 138"], ["\"\"\"\nWrite a function to get the word with most number of occurrences in the given strings list.\nassert most_occurrences([\"UTS is best for RTF\", \"RTF love UTS\", \"UTS is best\"] ) == 'UTS'\n\"\"\"\ndef most_occurrences(strings):\n # Create a dictionary to store the count of each word\n word_count = {}\n for string in strings:\n words = string.split()\n for word in words:\n if word in word_count:\n word_count[word] += 1\n else:\n word_count[word] = 1\n\n # Find the word with the maximum count\n max_count = 0\n max_word = ''\n for word, count in word_count.items():\n if count > max_count:\n max_count = count\n max_word = word\n\n return max_word\n"], ["\"\"\"\nWrite a function to print check if the triangle is isosceles or not.\nassert check_isosceles(6,8,12)==False \n\"\"\"\ndef check_isosceles(a,b,c):\n if a==b==c:\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a function to rotate a given list by specified number of items to the left direction.\nassert rotate_left([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],3,4)==[4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4]\n\"\"\"\ndef rotate_left(lst, n):\n if n == 0:\n return lst\n else:\n return lst[-n:] + lst[:-n]\n"], ["\"\"\"\nWrite a python function to count negative numbers in a list.\nassert neg_count([-1,-2,3,-4,-5]) == 4\n\"\"\"\ndef neg_count(lst):\n count = 0\n for i in lst:\n if i < 0:\n count += 1\n return count\n"], ["\"\"\"\nWrite a function to find all three, four, five characters long words in the given string by using regex.\nassert find_char('For the four consumer complaints contact manager AKR reddy') == ['For', 'the', 'four', 'AKR', 'reddy']\n\"\"\"\nimport re\n\ndef find_char(s):\n pattern = r'\\b\\w{3,5}\\b'\n matches = re.findall(pattern, s)\n return matches\n"], ["\"\"\"\nWrite a python function to count unset bits of a given number.\nassert count_unset_bits(2) == 1\n\"\"\"\ndef count_unset_bits(n):\n count = 0\n while n != 0:\n n &= n - 1\n count += 1\n return count\n"], ["\"\"\"\nWrite a function to count character frequency of a given string.\nassert char_frequency('python')=={'p': 1, 'y': 1, 't': 1, 'h': 1, 'o': 1, 'n': 1}\n\"\"\"\ndef char_frequency(s):\n freq = {}\n for char in s:\n if char in freq:\n freq[char] += 1\n else:\n freq[char] = 1\n return freq\n"], ["\"\"\"\nWrite a python function to sort a list according to the second element in sublist.\nassert Sort([['a', 10], ['b', 5], ['c', 20], ['d', 15]]) == [['b', 5], ['a', 10], ['d', 15], ['c', 20]]\n\"\"\"\ndef sort_by_second_element(lst):\n lst.sort(key=lambda x: x[1])\n return lst\n"], ["\"\"\"\nWrite a python function to check whether the triangle is valid or not if sides are given.\nassert check_Validity(1,2,3) == False\n\"\"\"\ndef check_Validity(a,b,c):\n if a+b>c and a+c>b and b+c>a:\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a function to find the sum of arithmetic progression.\nassert ap_sum(1,5,2)==25\n\"\"\"\ndef ap_sum(n, a, d):\n sum = 0\n for i in range(1, n+1):\n sum += a + (i-1)*d\n return sum\n"], ["\"\"\"\nWrite a function to check whether the given month name contains 28 days or not.\nassert check_monthnum(\"February\")==True\n\"\"\"\ndef check_monthnum(month):\n if month in [\"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"]:\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a function that matches a word at the end of a string, with optional punctuation.\nassert text_match_word(\"python.\")==('Found a match!')\n\"\"\"\ndef text_match_word(text):\n words = text.split()\n if words[-1] == \"match\":\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a python function to count the number of substrings with same first and last characters.\nassert count_Substring_With_Equal_Ends('aba') == 4\n\"\"\"\ndef count_Substring_With_Equal_Ends(s):\n count = 0\n for i in range(len(s)):\n for j in range(i+1, len(s)+1):\n if s[i] == s[j-1]:\n count += 1\n return count\n"], ["\"\"\"\nWrite a python function to find the maximum occuring divisor in an interval.\nassert find_Divisor(2,2) == 2\n\"\"\"\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n return 0\n else:\n return max(a,b) - min(a,b)\n\ndef find_Divisor(a,b):\n if a == 0 or b == 0:\n"], ["\"\"\"\nWrite a python function to find the sum of the three lowest positive numbers from a given list of numbers.\nassert sum_three_smallest_nums([10,20,30,40,50,60,7]) == 37\n\"\"\"\ndef sum_three_smallest_nums(nums):\n nums.sort()\n return nums[:3] # return the first three elements of the list\n"], ["\"\"\"\nWrite a function to convert the given set into ordered tuples.\nassert set_to_tuple({1, 2, 3, 4, 5}) == (1, 2, 3, 4, 5)\n\"\"\"\ndef set_to_tuple(set_):\n return tuple(set_)\n"], ["\"\"\"\nWrite a function to find the smallest range that includes at-least one element from each of the given arrays.\nassert find_minimum_range([[3, 6, 8, 10, 15], [1, 5, 12], [4, 8, 15, 16], [2, 6]]) == (4, 6)\n\"\"\"\nfrom typing import List\n\n\ndef find_minimum_range(arr1: List[int], arr2: List[int], arr3: List[int]) -> int:\n min_range = float('inf')\n for i in range(len(arr1)):\n for j in range(len(arr2)):\n for k in range(len(arr3)):\n if arr1[i] < arr2[j] < arr3[k]:\n min_range = min(min_range, abs(arr1[i] - arr2[j]) + abs(arr1[i] - arr3[k]))\n return min_range\n\n"], ["\"\"\"\nWrite a function to calculate the number of digits and letters in a string.\nassert dig_let(\"python\")==(6,0)\n\"\"\"\ndef count_digits_and_letters(s):\n count = 0\n for char in s:\n if char.isdigit():\n count += 1\n elif char.isalpha():\n count += 1\n return count\n"], ["\"\"\"\nWrite a python function to find number of elements with odd factors in a given range.\nassert count_Odd_Squares(5,100) == 8\n\"\"\"\ndef count_Odd_Squares(start, end):\n count = 0\n for i in range(start, end+1):\n if i % 2 != 0:\n count += 1\n return count\n"], ["\"\"\"\nWrite a function to find the difference between two consecutive numbers in a given list.\nassert diff_consecutivenums([1, 1, 3, 4, 4, 5, 6, 7])==[0, 2, 1, 0, 1, 1, 1]\n\"\"\"\ndef diff_consecutivenums(lst):\n diff = 0\n for i in range(1, len(lst)):\n diff += abs(lst[i] - lst[i-1])\n return diff\n"], ["\"\"\"\nWrite a function to find entringer number e(n, k).\nassert zigzag(4, 3) == 5\n\"\"\"\ndef zigzag(n, k):\n if n == 0:\n return 0\n if n == 1:\n return 1\n if n == 2:\n return 2\n if n == 3:\n return 3\n if n == 4:\n return 4\n if n == 5:\n return 5\n if n == 6:\n return 6\n if n == 7:\n return 7\n if n == 8:\n return 8\n if n == 9:\n return 9\n if n == 10:\n return 10\n if n == 11:\n return 11\n if n == 12:\n return 12\n if n == 13:\n return 13\n if n == 14:\n return 14\n if n == 15:\n return 15\n if n == 16:\n return 16\n if n == 17:\n return 17\n if n == 18:\n return 18\n if n == 19:\n return 19\n if n == 20:\n return 20\n if n == 21:\n return 21\n if n == 22:\n return 22\n if n == 23:\n return 23\n if n == 24:\n return 24\n if n == 25:\n return 25\n if n == 26:\n return 26\n if n == 27:\n return 27\n if n == 28:\n return 28\n if n == 29:\n return 29\n if n == 30:\n return 30\n if n == 31:\n return 31\n if n == 32:\n return 32\n if n == 33:\n return 33\n if n == 34:\n return 34\n if n == 35:\n return 35\n if n == 36:\n return 36\n if n == 37:\n return 37\n if n == 38:\n return 38\n if n == 39:\n return 39\n if n == 40:\n return 40\n if n == 41:\n return 41\n if n == 42:\n return 42\n if n == 43:\n return 43\n if n == 44:\n return 44\n if n == 45:\n return 45\n if n == 46:\n return 46\n if n == 47:\n return 47\n if n == 48:\n return 48\n if n == 49:\n return 49\n if n == 50:\n return 50\n if n == 51:\n return 51\n if n == 52:\n return 52\n if n == 53:\n return 53\n if n == 54:\n return 54\n if n == 55:\n return 55\n if n == 56:\n return 56\n if n == 57:\n return 57\n if n == 58:\n return 58\n if n == 59:\n return 59\n if n == 60:\n return 60\n if n == 61:\n return 61\n if n == 62:\n return 62\n if n == 63:\n return 63\n if n == 64:\n return 64\n if n == 65:\n return 65\n if n == 66:\n return 66\n if n == 67:\n return 67\n if n == 68:\n return 68\n if n == 69:\n return 69\n if n == 70:\n return 70\n if n == 71:\n return 71\n if n == 72:\n return 72\n if n == 73:\n return 73\n if n == 74:\n return 74\n if n == 75:\n return 75\n if n == 76:\n return 76\n if n == 77:\n return 77\n if n == 78:\n return 78\n if n == 79:\n return 79\n if n == 80:\n return 80\n if n == 81:\n return 81\n if n == 82:\n return 82\n if n == 83:\n return 83\n if n == 84:\n return 84\n if n == 85:\n return 85\n if n == 86:\n return 86\n if n == 87:\n return 87\n if n == 88:\n return 88\n if n == 89:\n return 89\n if n == 90:\n return 90\n if n == 91:\n return 91\n if n == 92:\n return 92\n if n == 93:\n return 93\n if n == 94:\n return 94\n if n == 95:\n return 95\n if n == 96:\n return 96\n if n == 97:\n return 97\n if n == 98:\n return 98\n if n == 99:\n return 99\n if n == 100:\n return 100\n if n == 101:\n return 101\n if n == 102:\n return 102\n if n == 103:\n return 103\n if n == 104:\n return 104\n if n == 105:\n return 105\n if n == 106:\n return 106\n if n == 107:\n return 107\n if n == 108:\n return 108\n if n == 109:\n return 109\n if n == 110:\n return 110\n if n == 111:\n return 111\n if n == 112:\n return 112\n if n == 113:\n return 113\n if n == 114:\n return 114\n if n == 115:\n return 115\n if n == 116:\n return 116\n if n == 117:\n return 117\n if n == 118:\n return 118\n if n == 119:\n return 119\n if n == 120:\n return 120\n if n == 121:\n return 121\n if n == 122:\n return 122\n if n == 123:\n return 123\n if n == 124:\n return 124\n if n == 125:\n return 125\n if n == 126:\n return 126\n if n == 127:\n return 127\n if n == 128:\n return 128\n if n == 129:\n return 129\n if n == 130:\n return 130\n if n == 131:\n return 131\n if n == 132:\n return 132\n if n == 133:\n return 133\n if n == 134:\n return 134\n if n == 135:\n return 135\n if n == 136:\n return 136\n if n == 137:\n return 137\n if n == 138:\n return 138\n if n == 139:\n return 139\n if n == 140:\n return 140\n if n == "], ["\"\"\"\nWrite a python function to count the number of squares in a rectangle.\nassert count_Squares(4,3) == 20\n\"\"\"\ndef count_Squares(x,y):\n count = 0\n for i in range(x):\n for j in range(y):\n count += 1\n return count\n"], ["\"\"\"\nWrite a function to count sequences of given length having non-negative prefix sums that can be generated by given values.\nassert find_ways(4) == 2\n\"\"\"\nfrom collections import defaultdict\nfrom itertools import combinations\n\ndef find_ways(n, values):\n # Initialize the result\n result = 0\n\n # Generate all possible combinations of n values\n for r in range(1, n + 1):\n # Generate all possible combinations of r values\n for comb in combinations(values, r):\n # Calculate the sum of the current combination\n sum_comb = sum(comb)\n # Calculate the sum of the prefix sum of the current combination\n prefix_sum_comb = sum(comb[:r])\n # If the prefix sum of the current combination is greater than or equal to the current result\n if prefix_sum_comb >= sum_comb:\n # Add the result to the total\n result += 1\n\n return result\n"], ["\"\"\"\nWrite a python function to check whether the given string is a binary string or not.\nassert check(\"01010101010\") == \"Yes\"\n\"\"\"\ndef check(s):\n if s.count('0') == s.count('1'):\n return \"Yes\"\n else:\n return \"No\" \n"], ["\"\"\"\nWrite a python function to minimize the length of the string by removing occurrence of only one character.\nassert minimum_Length(\"mnm\") == 1\n\"\"\"\ndef minimum_Length(s):\n count = 0\n for i in range(len(s)):\n if s.count(s[i]) == 1:\n count += 1\n else:\n count = 0\n return count\n"], ["\"\"\"\nWrite a python function to find the first element occurring k times in a given array.\nassert first_Element([0,1,2,3,4,5],6,1) == 0\n\"\"\"\ndef first_Element(arr, k):\n count = 0\n for i in range(len(arr)):\n if arr[i] == k:\n count += 1\n return count\n"], ["\"\"\"\nWrite a python function to check whether all the characters in a given string are unique.\nassert unique_Characters('aba') == False\n\"\"\"\ndef unique_Characters(string):\n if len(string) == len(set(string)):\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a function to remove a specified column from a given nested list.\nassert remove_column([[1, 2, 3], [2, 4, 5], [1, 1, 1]],0)==[[2, 3], [4, 5], [1, 1]]\n\"\"\"\ndef remove_column(lst, col):\n return [item for item in lst if item[col] != 0] \n\nlst = [[1, 2, 3], [2, 4, 5], [1, 1, 1]]"], ["\"\"\"\nWrite a function to find t-nth term of arithemetic progression.\nassert tn_ap(1,5,2)==9\n\"\"\"\ndef nth_term(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_2(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_3(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_4(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_5(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_6(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_7(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_8(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_9(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_10(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_11(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_12(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_13(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_14(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_15(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_16(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_17(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_18(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_19(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_20(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_21(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_22(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_23(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_24(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_25(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_26(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_27(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_28(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_29(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_30(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_31(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_32(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_33(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_34(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len(arithmetic_progression)):\n sum += arithmetic_progression[i-1]\n n += 1\n return sum\n\ndef nth_term_ap_35(arithmetic_progression):\n n = 1\n sum = 0\n for i in range(1, len"], ["\"\"\"\nWrite a python function to count the number of rectangles in a circle of radius r.\nassert count_Rectangles(2) == 8\n\"\"\"\nimport math\n\ndef count_Rectangles(r):\n count = 0\n for i in range(1, r+1):\n for j in range(1, r+1):\n for k in range(1, r+1):\n if i + j + k == r:\n count += 1\n return count\n"], ["\"\"\"\nWrite a function to find the third angle of a triangle using two angles.\nassert find_angle(47,89)==44\n\"\"\"\ndef find_angle(a,b):\n c = 180 - a - b\n return c\n"], ["\"\"\"\nWrite a function to find the maximum element of all the given tuple records.\nassert find_max([(2, 4), (6, 7), (5, 1), (6, 10), (8, 7)]) == 10\n\"\"\"\nfrom typing import List, Tuple\n\n\ndef find_max(records: List[Tuple[int, int]]) -> int:\n max_val = 0\n for record in records:\n max_val = max(max_val, record[0])\n return max_val\n\n"], ["\"\"\"\nWrite a function to find modulo division of two lists using map and lambda function.\nassert moddiv_list([4,5,6],[1, 2, 3])==[0, 1, 0]\n\"\"\"\ndef moddiv_list(list1, list2):\n return list(map(lambda x: x % 2, list1) * list2)\n"], ["\"\"\"\nWrite a python function to check whether one root of the quadratic equation is twice of the other or not.\nassert Check_Solution(1,3,2) == \"Yes\"\n\"\"\"\ndef Check_Solution(a,b,c):\n if a == 2*b:\n return \"Yes\"\n else:\n return \"No\"\n"], ["\"\"\"\nWrite a function to find the n\u2019th carol number.\nassert get_carol(2) == 7\n\"\"\"\ndef get_carol(n):\n if n == 1:\n return 1\n else:\n return get_carol(n-1) + 1\n"], ["\"\"\"\nWrite a function to remove empty lists from a given list of lists.\nassert remove_empty([[], [], [], 'Red', 'Green', [1,2], 'Blue', [], []])==['Red', 'Green', [1, 2], 'Blue']\n\"\"\"\ndef remove_empty(lst):\n return [x for x in lst if x != '']\n"], ["\"\"\"\nWrite a python function to find the item with maximum occurrences in a given list.\nassert max_occurrences([1,2,3,1,2,3,12,4,2]) == 2\n\"\"\"\ndef max_occurrences(lst):\n max_count = 0\n max_item = None\n for item in lst:\n count = lst.count(item)\n if count > max_count:\n max_count = count\n max_item = item\n return max_item\n"], ["\"\"\"\nWrite a function to add the k elements to each element in the tuple.\nassert add_K_element([(1, 3, 4), (2, 4, 6), (3, 8, 1)], 4) == [(5, 7, 8), (6, 8, 10), (7, 12, 5)]\n\"\"\"\ndef add_K_element(tuple_list, k):\n new_tuple = tuple_list\n for i in range(k):\n new_tuple[i] = new_tuple[i] + 1\n return new_tuple\n"], ["\"\"\"\nWrite a function to find the number of flips required to make the given binary string a sequence of alternate characters.\nassert min_flip_to_make_string_alternate(\"0001010111\") == 2\n\"\"\"\ndef min_flip_to_make_string_alternate(s):\n flip_count = 0\n for i in range(len(s)-1):\n if s[i] == s[i+1]:\n flip_count += 1\n return flip_count\n"], ["\"\"\"\nWrite a python function to count the number of digits of a given number.\nassert count_Digit(12345) == 5\n\"\"\"\ndef count_Digit(n):\n count = 0\n while n > 0:\n n = n // 10\n count += 1\n return count\n"], ["\"\"\"\nWrite a python function to find the largest product of the pair of adjacent elements from a given list of integers.\nassert adjacent_num_product([1,2,3,4,5,6]) == 30\n\"\"\"\ndef adjacent_num_product(nums):\n max_product = 0\n for i in range(len(nums)-1):\n product = nums[i] * nums[i+1]\n if product > max_product:\n max_product = product\n return max_product\n"], ["\"\"\"\nWrite a function to check if a binary tree is balanced or not.\nassert is_tree_balanced(root) == False\n\"\"\"\nfrom typing import Optional\n\n"], ["\"\"\"\nWrite a function to repeat the given tuple n times.\nassert repeat_tuples((1, 3), 4) == ((1, 3), (1, 3), (1, 3), (1, 3))\n\"\"\"\ndef repeat_tuples(tup, n):\n return tup * n\n"], ["\"\"\"\nWrite a function to find the lateral surface area of cuboid\nassert lateralsurface_cuboid(8,5,6)==156\n\"\"\"\ndef lateral_surface_cuboid(length, width, height):\n lateral_surface_area = 2*(length*width + width*height + length*height)\n return lateral_surface_area\n"], ["\"\"\"\nWrite a function to sort a tuple by its float element.\nassert float_sort([('item1', '12.20'), ('item2', '15.10'), ('item3', '24.5')])==[('item3', '24.5'), ('item2', '15.10'), ('item1', '12.20')] \n\"\"\"\ndef float_sort(t):\n return sorted(t, key=float) \n"], ["\"\"\"\nWrite a function to find the smallest missing element in a sorted array.\nassert smallest_missing([0, 1, 2, 3, 4, 5, 6], 0, 6) == 7\n\"\"\"\ndef smallest_missing(arr):\n if len(arr) == 0:\n return 1\n if len(arr) == 1:\n return 0\n\n for i in range(len(arr)):\n if i == 0 or arr[i-1] != arr[i]:\n return arr[i]\n return arr[-1] + 1\n\narr = [0, 1, 2, 3, 4, 5, 6]"], ["\"\"\"\nWrite a function to sort a given list of elements in ascending order using heap queue algorithm.\nassert heap_assending([18, 14, 10, 9, 8, 7, 9, 3, 2, 4, 1])==[1, 2, 3, 4, 7, 8, 9, 9, 10, 14, 18]\n\"\"\"\nfrom heapq import heapify, heappop, heappush\n\ndef heap_sort(lst):\n heapify(lst)\n for i in range(len(lst)-1, 0, -1):\n lst[0], lst[i] = heappop(lst), lst[i]\n return lst\n"], ["\"\"\"\nWrite a function to find the volume of a cuboid.\nassert volume_cuboid(1,2,3)==6\n\"\"\"\ndef volume_cuboid(length, width, height):\n volume = length * width * height\n return volume\n"], ["\"\"\"\nWrite a function to print all permutations of a given string including duplicates.\nassert permute_string('ab')==['ab', 'ba']\n\"\"\"\ndef permute_string(s):\n if len(s) == 0:\n return ['']\n else:\n first = s[0]\n rest = s[1:]\n rest_permutations = permute_string(rest)\n permutations = [first + p for p in rest_permutations]\n return permutations + first + rest_permutations\n"], ["\"\"\"\nWrite a function to round the given number to the nearest multiple of a specific number.\nassert round_num(4722,10)==4720\n\"\"\"\ndef round_num(num, multiple):\n return round(num/multiple, 1) * multiple\n"], ["\"\"\"\nWrite a function to remove tuple elements that occur more than once and replace the duplicates with some custom value.\nassert remove_replica((1, 1, 4, 4, 4, 5, 5, 6, 7, 7)) == (1, 'MSP', 4, 'MSP', 'MSP', 5, 'MSP', 6, 7, 'MSP')\n\"\"\"\ndef remove_replica(t):\n t = list(set(t))\n t.sort()\n return tuple(t) if len(t) > 1 else t[0] if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0] # if len(t) > 1 else t[0]"], ["\"\"\"\nWrite a python function to remove all occurrences of a character in a given string.\nassert remove_Char(\"aba\",'a') == \"b\"\n\"\"\"\ndef remove_char(string, char):\n return string.replace(char, '')\n"], ["\"\"\"\nWrite a python function to shift last element to first position in the given list.\nassert move_first([1,2,3,4]) == [4,1,2,3]\n\"\"\"\ndef move_first(lst):\n if len(lst) > 0:\n lst[0] = lst[-1]\n return lst\n"], ["\"\"\"\nWrite a function to find the surface area of a cuboid.\nassert surfacearea_cuboid(1,2,3)==22\n\"\"\"\ndef surfacearea_cuboid(length, breadth, height):\n surface_area = 2*(length*breadth + length*height + breadth*height)\n return surface_area\n"], ["\"\"\"\nWrite a function to generate a two-dimensional array.\nassert multi_list(3,4)==[[0, 0, 0, 0], [0, 1, 2, 3], [0, 2, 4, 6]] \n\"\"\"\ndef multi_list(n, m):\n return [[i+j for j in range(m)] for i in range(n)]\n\n"], ["\"\"\"\nWrite a function to sort a list of lists by a given index of the inner list.\nassert index_on_inner_list([('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,0)==[('Beau Turnbull', 94, 98), ('Brady Kent', 97, 96), ('Greyson Fulton', 98, 99), ('Wyatt Knott', 91, 94)]\n\"\"\"\ndef sort_by_index(list_of_lists, index):\n list_of_lists.sort(key=lambda x: x[index])\n return list_of_lists\n\nlist_of_lists = [('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)]\nindex_on_inner_list = [0, 1, 2, 3]"], ["\"\"\"\nWrite a function to find the number of rotations in a circularly sorted array.\nassert find_rotation_count([8, 9, 10, 1, 2, 3, 4, 5, 6, 7]) == 3\n\"\"\"\ndef find_rotation_count(nums):\n if len(nums) == 0:\n return 0\n left = 0\n right = len(nums) - 1\n while left < right:\n if nums[left] > nums[right]:\n left += 1\n else:\n right -= 1\n return right - left - 1\n\n"], ["\"\"\"\nWrite a python function to toggle all odd bits of a given number.\nassert even_bit_toggle_number(10) == 15\n\"\"\"\ndef even_bit_toggle_number(n):\n return (n & 1) ^ (n >> 1)\n"], ["\"\"\"\nWrite a python function to find the frequency of the smallest value in a given array.\nassert frequency_Of_Smallest(5,[1,2,3,4,3]) == 1\n\"\"\"\ndef frequency_Of_Smallest(arr):\n freq = 0\n for i in arr:\n if i == min(arr):\n freq += 1\n return freq\n"], ["\"\"\"\nWrite a function to find the n'th perrin number using recursion.\nassert get_perrin(9) == 12\n\"\"\"\ndef get_perrin(n):\n if n == 0:\n return 1\n else:\n return get_perrin(n-1) + get_perrin(n-2)\n"], ["\"\"\"\nWrite a function to find out the minimum no of swaps required for bracket balancing in the given string.\nassert swap_count(\"[]][][\") == 2\n\"\"\"\ndef min_swaps(s):\n stack = []\n count = 0\n for i in s:\n if i == '(':\n stack.append(i)\n elif i == ')':\n if not stack:\n count += 1\n else:\n stack.pop()\n return count\n"], ["\"\"\"\nWrite a python function to check whether the hexadecimal number is even or odd.\nassert even_or_odd(\"AB3454D\") ==\"Odd\"\n\"\"\"\ndef even_or_odd(hex_num):\n hex_num = hex_num.upper()\n if hex_num[0] == '0':\n return \"Even\"\n else:\n return \"Odd\"\n"], ["\"\"\"\nWrite a python function to find the highest power of 2 that is less than or equal to n.\nassert highest_Power_of_2(10) == 8\n\"\"\"\ndef highest_power_of_2(n):\n if n <= 0:\n return 0\n else:\n return 2 ** (n - 1) - 1\n"], ["\"\"\"\nWrite a function to find the n'th lucas number.\nassert find_lucas(9) == 76\n\"\"\"\ndef find_lucas(n):\n if n == 0:\n return 2\n elif n == 1:\n return 1\n else:\n return find_lucas(n-1) + find_lucas(n-2)\n"], ["\"\"\"\nWrite a function to insert a given string at the beginning of all items in a list.\nassert add_string([1,2,3,4],'temp{0}')==['temp1', 'temp2', 'temp3', 'temp4']\n\"\"\"\ndef add_string(lst, string):\n for i in lst:\n lst.insert(0, string)\n return lst\n"], ["\"\"\"\nWrite a function to convert more than one list to nested dictionary.\nassert convert_list_dictionary([\"S001\", \"S002\", \"S003\", \"S004\"],[\"Adina Park\", \"Leyton Marsh\", \"Duncan Boyle\", \"Saim Richards\"] ,[85, 98, 89, 92])==[{'S001': {'Adina Park': 85}}, {'S002': {'Leyton Marsh': 98}}, {'S003': {'Duncan Boyle': 89}}, {'S004': {'Saim Richards': 92}}]\n\"\"\"\ndef convert_list_dictionary(list1, list2, list3):\n result = {}\n for i in list1:\n result[i] = {}\n for j in list2:\n result[i][j] = {}\n for k in list3:\n result[i][j][k] = k\n return result\n"], ["\"\"\"\nWrite a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n).\nassert get_max_sum(60) == 106\n\"\"\"\ndef get_max_sum(n):\n if n == 1:\n return 1\n elif n == 2:\n return 2\n elif n == 3:\n return 3\n elif n == 4:\n return 4\n elif n == 5:\n return 5\n elif n == 6:\n return 6\n elif n == 7:\n return 7\n elif n == 8:\n return 8\n elif n == 9:\n return 9\n elif n == 10:\n return 10\n elif n == 11:\n return 11\n elif n == 12:\n return 12\n elif n == 13:\n return 13\n elif n == 14:\n return 14\n elif n == 15:\n return 15\n elif n == 16:\n return 16\n elif n == 17:\n return 17\n elif n == 18:\n return 18\n elif n == 19:\n return 19\n elif n == 20:\n return 20\n elif n == 21:\n return 21\n elif n == 22:\n return 22\n elif n == 23:\n return 23\n elif n == 24:\n return 24\n elif n == 25:\n return 25\n elif n == 26:\n return 26\n elif n == 27:\n return 27\n elif n == 28:\n return 28\n elif n == 29:\n return 29\n elif n == 30:\n return 30\n elif n == 31:\n return 31\n elif n == 32:\n return 32\n elif n == 33:\n return 33\n elif n == 34:\n return 34\n elif n == 35:\n return 35\n elif n == 36:\n return 36\n elif n == 37:\n return 37\n elif n == 38:\n return 38\n elif n == 39:\n return 39\n elif n == 40:\n return 40\n elif n == 41:\n return 41\n elif n == 42:\n return 42\n elif n == 43:\n return 43\n elif n == 44:\n return 44\n elif n == 45:\n return 45\n elif n == 46:\n return 46\n elif n == 47:\n return 47\n elif n == 48:\n return 48\n elif n == 49:\n return 49\n elif n == 50:\n return 50\n elif n == 51:\n return 51\n elif n == 52:\n return 52\n elif n == 53:\n return 53\n elif n == 54:\n return 54\n elif n == 55:\n return 55\n elif n == 56:\n return 56\n elif n == 57:\n return 57\n elif n == 58:\n return 58\n elif n == 59:\n return 59\n elif n == 60:\n return 60\n else:\n return 0\n"], ["\"\"\"\nWrite a function to find the list with maximum length using lambda function.\nassert max_length_list([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==(3, [13, 15, 17])\n\"\"\"\ndef max_length_list(lst):\n max_length = 0\n for i in lst:\n if len(i) > max_length:\n max_length = len(i)\n return max_length\n"], ["\"\"\"\nWrite a function to check if given tuple is distinct or not.\nassert check_distinct((1, 4, 5, 6, 1, 4)) == False\n\"\"\"\ndef check_distinct(t):\n if len(t) != len(set(t)):\n return False\n else:\n return True\n\n# Test cases"], ["\"\"\"\nWrite a python function to find the first non-repeated character in a given string.\nassert first_non_repeating_character(\"abcabc\") == None\n\"\"\"\ndef first_non_repeating_character(s):\n char_dict = {}\n for i in s:\n if i in char_dict:\n char_dict[i] += 1\n else:\n char_dict[i] = 1\n for i in char_dict:\n if char_dict[i] == 1:\n return i\n return None\n"], ["\"\"\"\nWrite a function to check whether the given string starts and ends with the same character or not using regex.\nassert check_char(\"abba\") == \"Valid\"\n\"\"\"\nimport re\n\ndef check_char(s):\n if s[0] == s[-1]:\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a function to find the median of three specific numbers.\nassert median_numbers(25,55,65)==55.0\n\"\"\"\ndef median_numbers(a,b,c):\n if a > b and a > c:\n return a\n elif b > a and b > c:\n return b\n else:\n return c\n"], ["\"\"\"\nWrite a function to compute the sum of digits of each number of a given list.\nassert sum_of_digits([10,2,56])==14\n\"\"\"\ndef sum_of_digits(lst):\n sum = 0\n for i in lst:\n sum += i\n return sum\n"], ["\"\"\"\nWrite a function to perform the mathematical bitwise xor operation across the given tuples.\nassert bitwise_xor((10, 4, 6, 9), (5, 2, 3, 3)) == (15, 6, 5, 10)\n\"\"\"\nfrom typing import List, Tuple\n\n\ndef bitwise_xor(tuples: List[Tuple[int, int, int, int]]) -> Tuple[int, int, int, int]:\n xor_result = 0\n for i in range(len(tuples)):\n xor_result ^= tuples[i]\n return xor_result\n\n"], ["\"\"\"\nWrite a function to extract the frequency of unique tuples in the given list order irrespective.\nassert extract_freq([(3, 4), (1, 2), (4, 3), (5, 6)] ) == 3\n\"\"\"\nfrom collections import Counter\nfrom typing import List\n\n\ndef extract_freq(lst: List[List[int]]) -> int:\n counter = Counter(lst)\n return counter.most_common(1)[0][1]\n\n"], ["\"\"\"\nWrite a function to perform index wise addition of tuple elements in the given two nested tuples.\nassert add_nested_tuples(((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))) == ((7, 10), (7, 14), (3, 10), (8, 13))\n\"\"\"\ndef add_nested_tuples(t1, t2):\n result = []\n for i in range(len(t1)):\n for j in range(len(t2[0])):\n result.append(t1[i][j] + t2[i][j])\n return result\n"], ["\"\"\"\nWrite a function to compute the value of ncr%p.\nassert ncr_modp(10,2,13)==6\n\"\"\"\nfrom math import factorial\ndef ncr_modp(n, r, p):\n if n < r:\n return 0\n if r == 0 or p == 1:\n return 1\n if r == 1:\n return factorial(n) // (factorial(r) * factorial(n-r))\n if r > n:\n return 0\n return (ncr_modp(n-1, r-1, p) * factorial(n)) % p\n"], ["\"\"\"\nWrite a function to check if a url is valid or not using regex.\nassert is_valid_URL(\"https://www.google.com\") == True\n\"\"\"\nimport re\n\ndef is_valid_URL(url):\n pattern = re.compile(\n r'^(?:http|ftp)s?://' # http:// or https://\n r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\\.)+(?:[A-Z]{2,6}\\.?|[A-Z0-9-]{2,}\\.?)|' # domain...\n r'localhost|' # localhost...\n r'\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})' # ...or ip\n r'(?::\\d+)?' # optional port\n r'(?:/?|[/?]\\S+)$', re.IGNORECASE)\n return bool(pattern.match(url)) # return True if the url is valid, False otherwise\n"], ["\"\"\"\nWrite a python function to find the minimum of two numbers.\nassert minimum(1,2) == 1\n\"\"\"\ndef minimum(a,b):\n if a max_product:\n max_product = product\n if product < min_product:\n min_product = product\n return max_product, min_product\n\narr = [1,2,3,4,7,0,8,4]"], ["\"\"\"\nWrite a function to find the maximum sum we can make by dividing number in three parts recursively and summing them up together for the given number.\nassert breakSum(12) == 13\n\"\"\"\ndef breakSum(n):\n if n == 0:\n return 0\n else:\n return n + breakSum(n - 1) + breakSum(n - 2) + breakSum(n - 3) + breakSum(n - 4) + breakSum(n - 5) + breakSum(n - 6) + breakSum(n - 7) + breakSum(n - 8) + breakSum(n - 9) + breakSum(n - 10) + breakSum(n - 11) + breakSum(n - 12) + breakSum(n - 13) + breakSum(n - 14) + breakSum(n - 15) + breakSum(n - 16) + breakSum(n - 17) + breakSum(n - 18) + breakSum(n - 19) + breakSum(n - 20) + breakSum(n - 21) + breakSum(n - 22) + breakSum(n - 23) + breakSum(n - 24) + breakSum(n - 25) + breakSum(n - 26) + breakSum(n - 27) + breakSum(n - 28) + breakSum(n - 29) + breakSum(n - 30) + breakSum(n - 31) + breakSum(n - 32) + breakSum(n - 33) + breakSum(n - 34) + breakSum(n - 35) + breakSum(n - 36) + breakSum(n - 37) + breakSum(n - 38) + breakSum(n - 39) + breakSum(n - 40) + breakSum(n - 41) + breakSum(n - 42) + breakSum(n - 43) + breakSum(n - 44) + breakSum(n - 45) + breakSum(n - 46) + breakSum(n - 47) + breakSum(n - 48) + breakSum(n - 49) + breakSum(n - 50) + breakSum(n - 51) + breakSum(n - 52) + breakSum(n - 53) + breakSum(n - 54) + breakSum(n - 55) + breakSum(n - 56) + breakSum(n - 57) + breakSum(n - 58) + breakSum(n - 59) + breakSum(n - 60) + breakSum(n - 61) + breakSum(n - 62) + breakSum(n - 63) + breakSum(n - 64) + breakSum(n - 65) + breakSum(n - 66) + breakSum(n - 67) + breakSum(n - 68) + breakSum(n - 69) + breakSum(n - 70) + breakSum(n - 71) + breakSum(n - 72) + breakSum(n - 73) + breakSum(n - 74) + breakSum(n - 75) + breakSum(n - 76) + breakSum(n - 77) + breakSum(n - 78) + breakSum(n - 79) + breakSum(n - 80) + breakSum(n - 81) + breakSum(n - 82) + breakSum(n - 83) + breakSum(n - 84) + breakSum(n - 85) + breakSum(n - 86) + breakSum(n - 87) + breakSum(n - 88) + breakSum(n - 89) + breakSum(n - 90) + breakSum(n - 91) + breakSum(n - 92) + breakSum(n - 93) + breakSum(n - 94) + breakSum(n - 95) + breakSum(n - 96) + breakSum(n - 97) + breakSum(n - 98) + breakSum(n - 99) + breakSum(n - 100) + breakSum(n - 101) + breakSum(n - 102) + breakSum(n - 103) + breakSum(n - 104) + breakSum(n - 105) + breakSum(n - 106) + breakSum(n - 107) + breakSum(n - 108) + breakSum(n - 109) + breakSum(n - 110) + breakSum(n - 111) + breakSum(n - 112) + breakSum(n - 113) + breakSum(n - 114) + breakSum(n - 115) + breakSum(n - 116) + breakSum(n - 117) + breakSum(n - 118) + breakSum(n - 119) + breakSum(n - 120) + breakSum(n - 121) + breakSum(n - 122) + breakSum(n - 123) + breakSum(n - 124) + breakSum(n - 125) + breakSum(n - 126) + breakSum(n - 127) + breakSum(n - 128) + breakSum(n - 129) + breakSum(n - 130) + breakSum(n - 131) + breakSum(n - 132) + breakSum(n - 133) + breakSum(n - 134) + breakSum(n - 135) + breakSum(n - 136) + breakSum(n - 137) + breakSum(n - 138) + breakSum(n - 139) + breakSum(n - 140) + breakSum(n - 141) + breakSum(n - 142) + breakSum(n - 143) + breakSum(n - 144) + breakSum(n - 145) + breakSum(n - 146) + breakSum(n - 147) + breakSum(n - 148) + breakSum(n - 149) + breakSum(n - 150) + breakSum(n - 151) + breakSum(n - 152) + breakSum(n - 153) + breakSum(n - 154) + breakSum(n - 155) + breakSum(n - 156) + breakSum(n - 157) + breakSum(n - 158) + breakSum(n - 159) + breakSum(n - 160) + breakSum(n - 161) + breakSum(n - 162) + breakSum(n - 163) + breakSum(n - 164) + breakSum(n - 165) + breakSum(n - 166) + breakSum(n - 167) + breakSum(n - 168) + breakSum(n - 169) + breakSum(n - 170) + breakSum(n - 171) + breakSum(n - 172) + breakSum(n - 173) + breakSum(n - 174) + breakSum(n - 175) + breakSum(n - 176) + breakSum(n - 177) + breakSum(n - 178) + breakSum(n - 179) + breakSum(n - 180) + breakSum(n - 181) + breakSum(n - 182) + breakSum(n - 183) + breakSum(n - 184) + breakSum(n - 185) + breakSum(n - 186) + breakSum(n - 187) + breakSum(n - 188) + breakSum(n - 189) + breakSum(n - 190) + breakSum(n - 191) + breakSum(n - 192) + breakSum(n - 193) + breakSum(n - 194) + breakSum(n - 195) + breakSum(n - 196) + breakSum(n - 197) + breakSum(n - 198) + breakSum(n - 199) + breakSum(n - 200) + breakSum(n - 201) + breakSum(n - 202) + breakSum(n - 203) + breakSum(n - 204) + breakSum(n - 205) + breakSum(n - 206) + breakSum(n - 207) + breakSum(n - 208) + breakSum(n - 209) + breakSum(n - 210) + breakSum(n - 211) + breakSum(n - 212) + breakSum(n - 213) + breakSum"], ["\"\"\"\nWrite a function to find common first element in given list of tuple.\nassert group_tuples([('x', 'y'), ('x', 'z'), ('w', 't')]) == [('x', 'y', 'z'), ('w', 't')]\n\"\"\"\ndef common_first_element(group_tuples):\n first_elements = []\n for group in group_tuples:\n first_elements.append(group[0])\n return first_elements\n\ngroup_tuples = [('x', 'y'), ('x', 'z'), ('w', 't')]"], ["\"\"\"\nWrite a python function to find the sublist having maximum length.\nassert Find_Max([['A'],['A','B'],['A','B','C']]) == ['A','B','C']\n\"\"\"\ndef Find_Max(lst):\n max_length = 0\n max_sublist = []\n for sublist in lst:\n length = len(sublist)\n if length > max_length:\n max_length = length\n max_sublist = sublist\n return max_sublist\n"], ["\"\"\"\nWrite a function to round every number of a given list of numbers and print the total sum multiplied by the length of the list.\nassert round_and_sum([22.4, 4.0, -16.22, -9.10, 11.00, -12.22, 14.20, -5.20, 17.50])==243\n\"\"\"\ndef round_and_sum(numbers):\n total_sum = 0\n for num in numbers:\n total_sum += round(num)\n print(total_sum)\n\nnumbers = [22.4, 4.0, -16.22, -9.10, 11.00, -12.22, 14.20, -5.20, 17.50]\nround_and_sum(numbers) # 243\n"], ["\"\"\"\nWrite a python function to find the cube sum of first n even natural numbers.\nassert cube_Sum(2) == 72\n\"\"\"\ndef cube_Sum(n):\n sum = 0\n for i in range(1, n+1):\n sum += i**3\n return sum\n"], ["\"\"\"\nWrite a function to concatenate each element of tuple by the delimiter.\nassert concatenate_tuple((\"ID\", \"is\", 4, \"UTS\") ) == 'ID-is-4-UTS'\n\"\"\"\ndef concatenate_tuple(tuple_list, delimiter):\n return delimiter.join(tuple_list)\n"], ["\"\"\"\nWrite a python function to find the average of cubes of first n natural numbers.\nassert find_Average_Of_Cube(2) == 4.5\n\"\"\"\ndef find_Average_Of_Cube(n):\n sum = 0\n for i in range(1, n+1):\n sum += (i**3)\n return sum/n\n"], ["\"\"\"\nWrite a function to solve gold mine problem.\nassert get_maxgold([[1, 3, 1, 5],[2, 2, 4, 1],[5, 0, 2, 3],[0, 6, 1, 2]],4,4)==16\n\"\"\"\nfrom collections import deque\nfrom heapq import heapify, heappop, heappush\n\ndef get_maxgold(matrix, gold, depth):\n if depth == 4:\n return gold\n for i in range(len(matrix)):\n for j in range(len(matrix[i])):\n if matrix[i][j] > gold:\n gold = matrix[i][j]\n heapify(matrix[i][j])\n return get_maxgold(matrix, gold, depth + 1)\n\nmatrix = [[1, 3, 1, 5],[2, 2, 4, 1],[5, 0, 2, 3],[0, 6, 1, 2]]\ngold = 4\ndepth = 4"], ["\"\"\"\nWrite a function to extract only the rear index element of each string in the given tuple.\nassert extract_rear(('Mers', 'for', 'Vers') ) == ['s', 'r', 's']\n\"\"\"\ndef extract_rear(tuple_list):\n result = []\n for item in tuple_list:\n if len(item) > 0:\n result.append(item[-1])\n return result\n"], ["\"\"\"\nWrite a function to count the number of sublists containing a particular element.\nassert count_element_in_list([[1, 3], [5, 7], [1, 11], [1, 15, 7]],1)==3\n\"\"\"\ndef count_element_in_list(lst, element):\n count = 0\n for sublist in lst:\n if sublist == element:\n count += 1\n return count\n"], ["\"\"\"\nWrite a function to filter odd numbers using lambda function.\nassert filter_oddnumbers([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1,3,5,7,9]\n\"\"\"\ndef filter_odd_numbers(numbers):\n return list(filter(lambda x: x % 2 != 0, numbers))\n"], ["\"\"\"\nWrite a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format by using regex.\nassert change_date_format(\"2026-01-02\") == '02-01-2026'\n\"\"\"\nfrom datetime import datetime\n\ndef change_date_format(date_string):\n date = datetime.strptime(date_string, \"%Y-%m-%d\")\n new_date = date.strftime(\"%d-%m-%Y\")\n return new_date\n"], ["\"\"\"\nWrite a function to sort the given array by using shell sort.\nassert shell_sort([12, 23, 4, 5, 3, 2, 12, 81, 56, 95]) == [2, 3, 4, 5, 12, 12, 23, 56, 81, 95]\n\"\"\"\ndef shell_sort(arr):\n n = len(arr)\n gap = n // 2\n while gap > 0:\n for i in range(gap, n):\n temp = arr[i]\n j = i\n while j >= gap and arr[j - gap] > temp:\n arr[j] = arr[j - gap]\n j -= gap\n arr[j] = temp\n gap //= 2\n return arr\n"], ["\"\"\"\nWrite a function to extract the elementwise and tuples from the given two tuples.\nassert and_tuples((10, 4, 6, 9), (5, 2, 3, 3)) == (0, 0, 2, 1)\n\"\"\"\nfrom typing import Tuple\nfrom collections import defaultdict\n\ndef extract_elements(t1: Tuple[int, ...], t2: Tuple[int, ...]) -> Tuple[int, ...]:\n \"\"\"\n Extracts the elementwise and tuples from the given two tuples.\n :param t1: first tuple\n :param t2: second tuple\n :return: tuple of elementwise and tuples\n \"\"\"\n elementwise = defaultdict(list)\n tuples = defaultdict(list)\n\n for i in range(len(t1)):\n elementwise[t1[i]].append(t1[i])\n tuples[t1[i]].append(t1[i])\n\n for i in range(len(t2)):\n elementwise[t2[i]].append(t2[i])\n tuples[t2[i]].append(t2[i])\n\n return elementwise, tuples\n"], ["\"\"\"\nWrite a function to find the directrix of a parabola.\nassert parabola_directrix(5,3,2)==-198\n\"\"\"\ndef parabola_directrix(a,b,c):\n return a*(c**2)-b**2\n\na = 5\nb = 3\nc = 2"], ["\"\"\"\nWrite a function that takes two lists and returns true if they have at least one common element.\nassert common_element([1,2,3,4,5], [5,6,7,8,9])==True\n\"\"\"\ndef common_element(list1, list2):\n common = []\n for i in list1:\n if i in list2:\n common.append(i)\n return common\n"], ["\"\"\"\nWrite a function to find the median of a trapezium.\nassert median_trapezium(15,25,35)==20\n\"\"\"\ndef median_trapezium(a,b,c):\n if a+b>c and a+c>b and b+c>a:\n return (a+b+c)/2\n else:\n return a+b+c\n"], ["\"\"\"\nWrite a function to check whether the entered number is greater than the elements of the given array.\nassert check_greater([1, 2, 3, 4, 5], 4) == 'No, entered number is less than those in the array'\n\"\"\"\ndef check_greater(arr, num):\n if num > arr:\n return 'No, entered number is less than those in the array'\n else:\n return 'Yes, entered number is greater than those in the array' \n"], ["\"\"\"\nWrite a function that matches a string that has an a followed by one or more b's.\nassert text_match_one(\"ac\")==('Not matched!')\n\"\"\"\ndef text_match_one(text):\n if text[0] == 'a':\n return 'Not matched!'\n else:\n return 'Matched!'\n\n"], ["\"\"\"\nWrite a python function to find the last digit of a given number.\nassert last_Digit(123) == 3\n\"\"\"\ndef last_Digit(n):\n if n < 0:\n return -1\n else:\n return n % 10\n"], ["\"\"\"\nWrite a python function to print negative numbers in a list.\nassert neg_nos([-1,4,5,-6]) == -1,-6\n\"\"\"\ndef print_neg_nos(lst):\n for i in lst:\n if i < 0:\n print(i)"], ["\"\"\"\nWrite a function to remove odd characters in a string.\nassert remove_odd(\"python\")==(\"yhn\")\n\"\"\"\ndef remove_odd(s):\n return \"\".join([c for c in s if c != \"o\"]) \n"], ["\"\"\"\nWrite a function to count bidirectional tuple pairs.\nassert count_bidirectional([(5, 6), (1, 2), (6, 5), (9, 1), (6, 5), (2, 1)] ) == '3'\n\"\"\"\ndef count_bidirectional(tuples):\n count = 0\n for i in range(len(tuples)-1):\n for j in range(i+1, len(tuples)):\n if tuples[i][0] == tuples[j][1]:\n count += 1\n return count\n"], ["\"\"\"\nWrite a function to convert a list of multiple integers into a single integer.\nassert multiple_to_single([11, 33, 50])==113350\n\"\"\"\ndef multiple_to_single(lst):\n return sum(lst)\n"], ["\"\"\"\nWrite a function to find all adverbs and their positions in a given sentence.\nassert find_adverb_position(\"clearly!! we can see the sky\")==(0, 7, 'clearly')\n\"\"\"\ndef find_adverb_position(sentence):\n adverbs = []\n for i in range(len(sentence)):\n if sentence[i] in ['!', '?', '.']:\n adverbs.append(i)\n return adverbs\n"], ["\"\"\"\nWrite a function to find the surface area of a cube.\nassert surfacearea_cube(5)==150\n\"\"\"\nimport math\n\ndef surfacearea_cube(side):\n return 6 * side ** 2\n"], ["\"\"\"\nWrite a function to find the ration of positive numbers in an array of integers.\nassert positive_count([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8])==0.54\n\"\"\"\ndef positive_count(arr):\n count = 0\n for i in arr:\n if i > 0:\n count += 1\n return count / len(arr) * 100\n"], ["\"\"\"\nWrite a python function to find the largest negative number from the given list.\nassert largest_neg([1,2,3,-4,-6]) == -6\n\"\"\"\ndef largest_neg(lst):\n largest = -float('inf')\n for num in lst:\n if num < 0:\n largest = num\n return largest\n"], ["\"\"\"\nWrite a function to trim each tuple by k in the given tuple list.\nassert trim_tuple([(5, 3, 2, 1, 4), (3, 4, 9, 2, 1),(9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 2) == '[(2,), (9,), (2,), (2,)]'\n\"\"\"\ndef trim_tuple(tuples, k):\n return [tuple(t for t in t if t[k] == 0) for t in tuples] \n"], ["\"\"\"\nWrite a function to perform index wise multiplication of tuple elements in the given two tuples.\nassert index_multiplication(((1, 3), (4, 5), (2, 9), (1, 10)),((6, 7), (3, 9), (1, 1), (7, 3)) ) == ((6, 21), (12, 45), (2, 9), (7, 30))\n\"\"\"\ndef index_multiplication(t1, t2):\n result = []\n for i in range(len(t1)):\n result.append(t1[i] * t2[i])\n return result\n"], ["\"\"\"\nWrite a python function to count the occurence of all elements of list in a tuple.\nassert count_Occurrence(('a', 'a', 'c', 'b', 'd'),['a', 'b'] ) == 3\n\"\"\"\ndef count_Occurrence(list1, list2):\n count = 0\n for i in list1:\n if i in list2:\n count += 1\n return count\n\nlist1 = ['a', 'a', 'c', 'b', 'd']\nlist2 = ['a', 'b']"], ["\"\"\"\nWrite a function to find cubes of individual elements in a list using lambda function.\nassert cube_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]\n\"\"\"\ndef cube_nums(nums):\n return [num**3 for num in nums]\n"], ["\"\"\"\nWrite a function to calculate the sum of perrin numbers.\nassert cal_sum(9) == 49\n\"\"\"\ndef cal_sum(n):\n sum = 0\n for i in range(1, n+1):\n sum += i\n return sum\n"], ["\"\"\"\nWrite a python function to check whether the triangle is valid or not if 3 points are given.\nassert check_Triangle(1,5,2,5,4,6) == 'Yes'\n\"\"\"\ndef check_Triangle(a,b,c):\n if a+b>c and a+c>b and b+c>a:\n return 'Yes'\n else:\n return 'No'"], ["\"\"\"\nWrite a function to extract specified size of strings from a give list of string values.\nassert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,8)==['practice', 'solution']\n\"\"\"\ndef extract_string(lst, size):\n return [lst[i:i+size] for i in range(0, len(lst), size)]\n\n"], ["\"\"\"\nWrite a function to remove all whitespaces from the given string using regex.\nassert remove_whitespaces(' Google Flutter ') == 'GoogleFlutter'\n\"\"\"\nimport re\n\ndef remove_whitespaces(s):\n return re.sub(r'\\s+', '', s)\n"], ["\"\"\"\nWrite a function that gives loss amount if the given amount has loss else return none.\nassert loss_amount(1500,1200)==None\n\"\"\"\ndef loss_amount(amount,loss):\n if amount-loss<0:\n return None\n else:\n return loss_amount(amount+loss,loss)"], ["\"\"\"\nWrite a python function to find the sum of even factors of a number.\nassert sumofFactors(18) == 26\n\"\"\"\ndef sumofFactors(n):\n sum = 0\n for i in range(2, n+1):\n if n % i == 0:\n sum += i\n return sum\n"], ["\"\"\"\nWrite a function that matches a word containing 'z'.\nassert text_match_wordz(\"pythonz.\")==('Found a match!')\n\"\"\"\ndef text_match_wordz(word):\n if word == \"z\":\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a function to check whether the given month number contains 31 days or not.\nassert check_monthnumb_number(5)==True\n\"\"\"\ndef check_monthnumb_number(month):\n if month == 1 or month == 3 or month == 5 or month == 7 or month == 8 or month == 10 or month == 12:\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a function to reverse strings in a given list of string values.\nassert reverse_string_list(['Red', 'Green', 'Blue', 'White', 'Black'])==['deR', 'neerG', 'eulB', 'etihW', 'kcalB']\n\"\"\"\ndef reverse_string_list(lst):\n return [lst[i][::-1] for i in range(len(lst))]\n"], ["\"\"\"\nWrite a python function to find the sublist having minimum length.\nassert Find_Min([[1],[1,2],[1,2,3]]) == [1]\n\"\"\"\ndef Find_Min(lst):\n min_length = 0\n for i in range(len(lst)):\n for j in range(i+1, len(lst)):\n if len(lst[i]) < len(lst[j]):\n min_length = len(lst[i])\n break\n return min_length\n"], ["\"\"\"\nWrite a function to find the area of a rectangle.\nassert rectangle_area(10,20)==200\n\"\"\"\ndef rectangle_area(length, breadth):\n area = length * breadth\n return area\n"], ["\"\"\"\nWrite a function to remove uppercase substrings from a given string by using regex.\nassert remove_uppercase('cAstyoUrFavoRitETVshoWs') == 'cstyoravoitshos'\n\"\"\"\ndef remove_uppercase(s):\n return s.replace('U', '') # replace all uppercase with nothing\n"], ["\"\"\"\nWrite a python function to get the first element of each sublist.\nassert Extract([[1, 2], [3, 4, 5], [6, 7, 8, 9]]) == [1, 3, 6]\n\"\"\"\ndef extract_sublists(lst):\n return [lst[i] for i in range(len(lst))]\n"], ["\"\"\"\nWrite a python function to count the upper case characters in a given string.\nassert upper_ctr('PYthon') == 1\n\"\"\"\ndef upper_ctr(s):\n upper_ctr = 0\n for i in s:\n if i.isupper():\n upper_ctr += 1\n return upper_ctr\n"], ["\"\"\"\nWrite a function to find all possible combinations of the elements of a given list.\nassert combinations_list(['orange', 'red', 'green', 'blue'])==[[], ['orange'], ['red'], ['red', 'orange'], ['green'], ['green', 'orange'], ['green', 'red'], ['green', 'red', 'orange'], ['blue'], ['blue', 'orange'], ['blue', 'red'], ['blue', 'red', 'orange'], ['blue', 'green'], ['blue', 'green', 'orange'], ['blue', 'green', 'red'], ['blue', 'green', 'red', 'orange']]\n\"\"\"\ndef combinations_list(lst):\n result = []\n for i in range(len(lst)):\n for j in range(i+1, len(lst)+1):\n result.append(lst[i:j])\n return result\n"], ["\"\"\"\nWrite a function to find the maximum product subarray of the given array.\nassert max_subarray_product([1, -2, -3, 0, 7, -8, -2]) == 112\n\"\"\"\nfrom typing import List\n\n\ndef max_subarray_product(nums: List[int]) -> int:\n max_product = float('-inf')\n min_product = float('inf')\n current_max = current_min = nums[0]\n\n for num in nums:\n current_max = max(num, current_max * num)\n current_min = min(num, current_min * num)\n\n max_product = max(max_product, current_max)\n min_product = min(min_product, current_min)\n\n return max_product if max_product > 0 else min_product\n\n"], ["\"\"\"\nWrite a function to check if all values are same in a dictionary.\nassert check_value({'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},10)==False\n\"\"\"\ndef check_value(dict1,dict2):\n if dict1 == dict2:\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a function to drop empty items from a given dictionary.\nassert drop_empty({'c1': 'Red', 'c2': 'Green', 'c3':None})=={'c1': 'Red', 'c2': 'Green'}\n\"\"\"\ndef drop_empty(d):\n return {k:v for k,v in d.items() if v is not None} \n"], ["\"\"\"\nWrite a function to find the peak element in the given array.\nassert find_peak([1, 3, 20, 4, 1, 0], 6) == 2\n\"\"\"\ndef find_peak(arr):\n if len(arr) == 0:\n return None\n if len(arr) == 1:\n return arr[0]\n if len(arr) == 2:\n return max(arr)\n if len(arr) == 3:\n return min(arr)\n if len(arr) == 4:\n return max(arr[0], arr[1])\n if len(arr) == 5:\n return min(arr[0], arr[1], arr[2], arr[3], arr[4])\n if len(arr) == 6:\n return max(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5])\n if len(arr) == 7:\n return max(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6])\n if len(arr) == 8:\n return max(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7])\n if len(arr) == 9:\n return max(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8])\n if len(arr) == 10:\n return max(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8], arr[9])\n if len(arr) == 11:\n return max(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8], arr[9], arr[10])\n if len(arr) == 12:\n return max(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8], arr[9], arr[10], arr[11])\n if len(arr) == 13:\n return max(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8], arr[9], arr[10], arr[11], arr[12])\n if len(arr) == 14:\n return max(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8], arr[9], arr[10], arr[11], arr[12], arr[13])\n if len(arr) == 15:\n return max(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8], arr[9], arr[10], arr[11], arr[12], arr[13], arr[14])\n if len(arr) == 16:\n return max(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8], arr[9], arr[10], arr[11], arr[12], arr[13], arr[14], arr[15])\n if len(arr) == 17:\n return max(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8], arr[9], arr[10], arr[11], arr[12], arr[13], arr[14], arr[15], arr[16])\n if len(arr) == 18:\n return max(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8], arr[9], arr[10], arr[11], arr[12], arr[13], arr[14], arr[15], arr[16], arr[17])\n if len(arr) == 19:\n return max(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8], arr[9], arr[10], arr[11], arr[12], arr[13], arr[14], arr[15], arr[16], arr[17], arr[18])\n if len(arr) == 20:\n return max(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8], arr[9], arr[10], arr[11], arr[12], arr[13], arr[14], arr[15], arr[16], arr[17], arr[18], arr[19])\n if len(arr) == 21:\n return max(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8], arr[9], arr[10], arr[11], arr[12], arr[13], arr[14], arr[15], arr[16], arr[17], arr[18], arr[19], arr[20])\n if len(arr) == 22:\n return max(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8], arr[9], arr[10], arr[11], arr[12], arr[13], arr[14], arr[15], arr[16], arr[17], arr[18], arr[19], arr[20], arr[21])\n if len(arr) == 23:\n return max(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8], arr[9], arr[10], arr[11], arr[12], arr[13], arr[14], arr[15], arr[16], arr[17], arr[18], arr[19], arr[20], arr[21], arr[22])\n if len(arr) == 24:\n return max(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8], arr[9], arr[10], arr[11], arr[12], arr[13], arr[14], arr[15], arr[16], arr[17], arr[18], arr[19], arr[20], arr[21], arr[22], arr[23])\n if len(arr) == 25:\n return max(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8], arr[9], arr[10], arr[11], arr[12], arr[13], arr[14], arr[15], arr[16], arr[17], arr[18], arr[19], arr[20], arr[21], arr[22], arr[23], arr[24])\n if len(arr) == 26:\n return max(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8], arr[9], arr[10], arr[11], arr[12], arr[13], arr[14], arr[15], arr[16], arr[17], arr[18], arr[19], arr[20], arr[21], arr[22], arr[23], arr[24], arr[25])\n if len(arr) == 26:\n return max(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8], arr[9], arr[10], arr[11], arr[12], arr[13], arr[14], arr[15], arr[16], arr[17], arr[18], arr[19], arr[20], arr[21], arr[22], arr[23], arr[24], arr[25], arr[26])\n if len(arr) == 27:\n return max(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8"], ["\"\"\"\nWrite a python function to convert decimal number to octal number.\nassert decimal_to_Octal(10) == 12\n\"\"\"\ndef decimal_to_Octal(decimal):\n octal = \"\"\n while decimal > 0:\n octal = str(decimal % 8) + octal\n decimal = decimal // 8\n return octal\n"], ["\"\"\"\nWrite a function to find the maximum product formed by multiplying numbers of an increasing subsequence of that array.\nassert max_product([3, 100, 4, 5, 150, 6], 6) == 45000 \n\"\"\"\ndef max_product(nums):\n max_product = 0\n for i in range(len(nums)):\n for j in range(i+1, len(nums)):\n product = nums[i] * nums[j]\n if product > max_product:\n max_product = product\n return max_product\n"], ["\"\"\"\nWrite a function to find the maximum profit earned from a maximum of k stock transactions\nassert max_profit([1, 5, 2, 3, 7, 6, 4, 5], 3) == 10\n\"\"\"\nfrom typing import List\n\n\ndef max_profit(prices: List[int]) -> int:\n if len(prices) < 2:\n return 0\n min_price = prices[0]\n max_profit = 0\n for i in range(1, len(prices)):\n if prices[i] < min_price:\n min_price = prices[i]\n else:\n max_profit = max(max_profit, prices[i] - min_price)\n return max_profit\n\n"], ["\"\"\"\nWrite a function to find the pairwise addition of the elements of the given tuples.\nassert add_pairwise((1, 5, 7, 8, 10)) == (6, 12, 15, 18)\n\"\"\"\ndef add_pairwise(tuples):\n return tuple(sum(t) for t in tuples)\n"], ["\"\"\"\nWrite a python function to find remainder of array multiplication divided by n.\nassert find_remainder([ 100, 10, 5, 25, 35, 14 ],6,11) ==9\n\"\"\"\ndef find_remainder(arr,n):\n product = 1\n for i in arr:\n product = product * i\n return product % n\n\narr = [100, 10, 5, 25, 35, 14]\nn = 6"], ["\"\"\"\nWrite a python function to check whether the given list contains consecutive numbers or not.\nassert check_Consecutive([1,2,3,4,5]) == True\n\"\"\"\ndef check_Consecutive(lst):\n for i in range(len(lst)-1):\n if lst[i+1] - lst[i] != 1:\n return False\n return True\n"], ["\"\"\"\nWrite a function to find the tuple intersection of elements in the given tuple list irrespective of their order.\nassert tuple_intersection([(3, 4), (5, 6), (9, 10), (4, 5)] , [(5, 4), (3, 4), (6, 5), (9, 11)]) == {(4, 5), (3, 4), (5, 6)}\n\"\"\"\ndef tuple_intersection(t1, t2):\n # Create a set from the first list\n set1 = set(t1)\n # Create a set from the second list\n set2 = set(t2)\n # Find the intersection of the two sets\n intersection = set1 & set2\n # Return the intersection as a list\n return list(intersection)"], ["\"\"\"\nWrite a function to replace characters in a string.\nassert replace_char(\"polygon\",'y','l')==(\"pollgon\")\n\"\"\"\ndef replace_char(s,old,new):\n return s.replace(old,new)\n"], ["\"\"\"\nWrite a function to sort counter by value.\nassert sort_counter({'Math':81, 'Physics':83, 'Chemistry':87})==[('Chemistry', 87), ('Physics', 83), ('Math', 81)]\n\"\"\"\ndef sort_counter(counter):\n return sorted(counter.items(), key=lambda x: x[1])\n"], ["\"\"\"\nWrite a python function to find the sum of the largest and smallest value in a given array.\nassert big_sum([1,2,3]) == 4\n\"\"\"\ndef find_sum(arr):\n if len(arr) == 0:\n return 0\n else:\n return max(arr) + min(arr)\n"], ["\"\"\"\nWrite a python function to convert the given string to lower case.\nassert is_lower(\"InValid\") == \"invalid\"\n\"\"\"\ndef is_lower(string):\n return string.lower() == string.lower()\n"], ["\"\"\"\nWrite a function to remove lowercase substrings from a given string.\nassert remove_lowercase(\"PYTHon\")==('PYTH')\n\"\"\"\ndef remove_lowercase(s):\n return s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') \n"], ["\"\"\"\nWrite a python function to find the first digit of a given number.\nassert first_Digit(123) == 1\n\"\"\"\ndef first_Digit(n):\n if n < 10:\n return n\n else:\n return first_Digit(n // 10) + n % 10\n"], ["\"\"\"\nWrite a python function to find the maximum occurring character in a given string.\nassert get_max_occuring_char(\"data\") == \"a\"\n\"\"\"\ndef get_max_occuring_char(s):\n char_count = {}\n for char in s:\n if char in char_count:\n char_count[char] += 1\n else:\n char_count[char] = 1\n max_char = max(char_count, key=char_count.get)\n return max_char\n"], ["\"\"\"\nWrite a function to determine if there is a subset of the given set with sum equal to the given sum.\nassert is_subset_sum([3, 34, 4, 12, 5, 2], 6, 9) == True\n\"\"\"\ndef is_subset_sum(nums, target_sum, subset_sum):\n if subset_sum > target_sum:\n return False\n if subset_sum == target_sum:\n return True\n if subset_sum < target_sum:\n return False\n for i in range(len(nums)):\n if nums[i] > target_sum:\n return False\n return True\n"], ["\"\"\"\nWrite a function to find sequences of one upper case letter followed by lower case letters in the given string by using regex.\nassert match(\"Geeks\") == 'Yes'\n\"\"\"\nimport re\n\ndef find_sequences(s):\n pattern = r'([a-z])\\1'\n matches = re.findall(pattern, s)\n return matches\n"], ["\"\"\"\nWrite a python function to find the first natural number whose factorial is divisible by x.\nassert first_Factorial_Divisible_Number(10) == 5\n\"\"\"\nfrom math import factorial\n\ndef first_Factorial_Divisible_Number(x):\n for i in range(1, x+1):\n if factorial(i) % x == 0:\n return i\n return None\n"], ["\"\"\"\nWrite a function to remove the matching tuples from the given two tuples.\nassert remove_matching_tuple([('Hello', 'dude'), ('How', 'are'), ('you', '?')], [('Hello', 'dude'), ('How', 'are')]) == [('you', '?')]\n\"\"\"\ndef remove_matching_tuple(t1, t2):\n for i in range(len(t1)):\n if t1[i] == t2[i]:\n del t1[i]\n return t1\n"], ["\"\"\"\nWrite a function to find the largest palindromic number in the given array.\nassert largest_palindrome([1, 232, 54545, 999991], 4) == 54545\n\"\"\"\ndef largest_palindrome(arr, n):\n largest = 0\n for i in range(len(arr)):\n for j in range(i+1, len(arr)):\n if arr[i] == arr[j] and arr[i] > largest:\n largest = arr[i]\n return largest\n"], ["\"\"\"\nWrite a function to compute binomial probability for the given number.\nassert binomial_probability(10, 5, 1.0/3) == 0.13656454808718185\n\"\"\"\nimport numpy as np\nimport random\n\ndef binomial_probability(n, p, q):\n \"\"\"\n Compute binomial probability for the given number.\n :param n: number of trials\n :param p: probability of success\n :param q: probability of failure\n :return: binomial probability\n \"\"\"\n return np.math.factorial(n) / (np.math.factorial(n - q) * np.math.factorial(q)) * (p ** n) * (1 - p) ** (n - q)\n\ndef binomial_probability_10_5_1_0_3():\n \"\"\"\n Compute binomial probability for the given number.\n :return: binomial probability\n \"\"\"\n return binomial_probability(10, 5, 1.0/3)\n"], ["\"\"\"\nWrite a function to sort a list of tuples in increasing order by the last element in each tuple.\nassert sort_tuple([(1, 3), (3, 2), (2, 1)] ) == [(2, 1), (3, 2), (1, 3)]\n\"\"\"\ndef sort_tuple(tuples):\n return sorted(tuples, key = lambda x: x[-1])\n"], ["\"\"\"\nWrite a function to find the area of a pentagon.\nassert area_pentagon(5)==43.01193501472417\n\"\"\"\nimport math\n\ndef area_pentagon(side):\n area = 0.5 * side * side * math.tan(math.pi/5)\n return area\n"], ["\"\"\"\nWrite a python function to find the frequency of the largest value in a given array.\nassert frequency_Of_Largest(5,[1,2,3,4,4]) == 2\n\"\"\"\ndef frequency_Of_Largest(arr):\n max_val = max(arr)\n freq = arr.count(max_val)\n return freq\n\narr = [1,2,3,4,4]"], ["\"\"\"\nWrite a function to extract all the pairs which are symmetric in the given tuple list.\nassert extract_symmetric([(6, 7), (2, 3), (7, 6), (9, 8), (10, 2), (8, 9)] ) == {(8, 9), (6, 7)}\n\"\"\"\ndef extract_symmetric(t):\n pairs = []\n for i in range(len(t)):\n for j in range(i+1, len(t)):\n if t[i] == t[j]:\n pairs.append((t[i], t[j]))\n return pairs\n"], ["\"\"\"\nWrite a function to find the sum of geometric progression series.\nassert sum_gp(1,5,2)==31\n\"\"\"\ndef sum_gp(n,r):\n sum=0\n for i in range(1,r+1):\n sum+=n\n return sum\n"], ["\"\"\"\nWrite a function to search an element in the given array by using binary search.\nassert binary_search([1,2,3,5,8], 6) == False\n\"\"\"\ndef binary_search(arr, x):\n low = 0\n high = len(arr) - 1\n while low <= high:\n mid = (low + high) // 2\n if arr[mid] == x:\n return True\n elif arr[mid] < x:\n low = mid + 1\n else:\n high = mid - 1\n return False\n\narr = [1,2,3,5,8]\nx = 6"], ["\"\"\"\nWrite a function to calculate a grid of hexagon coordinates where function returns a list of lists containing 6 tuples of x, y point coordinates.\nassert calculate_polygons(1,1, 4, 4, 3)==[[(-5.0, -4.196152422706632), (-5.0, -0.7320508075688767), (-2.0, 1.0), (1.0, -0.7320508075688767), (1.0, -4.196152422706632), (-2.0, -5.928203230275509), (-5.0, -4.196152422706632)], [(1.0, -4.196152422706632), (1.0, -0.7320508075688767), (4.0, 1.0), (7.0, -0.7320508075688767), (7.0, -4.196152422706632), (4.0, -5.928203230275509), (1.0, -4.196152422706632)], [(7.0, -4.196152422706632), (7.0, -0.7320508075688767), (10.0, 1.0), (13.0, -0.7320508075688767), (13.0, -4.196152422706632), (10.0, -5.928203230275509), (7.0, -4.196152422706632)], [(-2.0, 1.0000000000000004), (-2.0, 4.464101615137755), (1.0, 6.196152422706632), (4.0, 4.464101615137755), (4.0, 1.0000000000000004), (1.0, -0.7320508075688767), (-2.0, 1.0000000000000004)], [(4.0, 1.0000000000000004), (4.0, 4.464101615137755), (7.0, 6.196152422706632), (10.0, 4.464101615137755), (10.0, 1.0000000000000004), (7.0, -0.7320508075688767), (4.0, 1.0000000000000004)], [(-5.0, 6.196152422706632), (-5.0, 9.660254037844387), (-2.0, 11.392304845413264), (1.0, 9.660254037844387), (1.0, 6.196152422706632), (-2.0, 4.464101615137755), (-5.0, 6.196152422706632)], [(1.0, 6.196152422706632), (1.0, 9.660254037844387), (4.0, 11.392304845413264), (7.0, 9.660254037844387), (7.0, 6.196152422706632), (4.0, 4.464101615137755), (1.0, 6.196152422706632)], [(7.0, 6.196152422706632), (7.0, 9.660254037844387), (10.0, 11.392304845413264), (13.0, 9.660254037844387), (13.0, 6.196152422706632), (10.0, 4.464101615137755), (7.0, 6.196152422706632)], [(-2.0, 11.392304845413264), (-2.0, 14.85640646055102), (1.0, 16.588457268119896), (4.0, 14.85640646055102), (4.0, 11.392304845413264), (1.0, 9.660254037844387), (-2.0, 11.392304845413264)], [(4.0, 11.392304845413264), (4.0, 14.85640646055102), (7.0, 16.588457268119896), (10.0, 14.85640646055102), (10.0, 11.392304845413264), (7.0, 9.660254037844387), (4.0, 11.392304845413264)]]\n\"\"\"\ndef calculate_polygons(n, x1, y1, x2, y2, x3, y3, x4, y4):\n # Initialize the list to store the coordinates\n coordinates = []\n\n # Calculate the coordinates for each hexagon\n for i in range(n):\n # Calculate the coordinates for the current hexagon\n hexagon_coordinates = []\n for j in range(6):\n # Calculate the coordinates for the current hexagon\n x = x1 + (j * (x2 - x1) / (n - 1))\n y = y1 + (j * (y2 - y1) / (n - 1))\n hexagon_coordinates.append((x, y))\n\n # Append the hexagon coordinates to the list\n coordinates.append(hexagon_coordinates)\n\n return coordinates\n\n# Test the function"], ["\"\"\"\nWrite a function to convert the given binary tuple to integer.\nassert binary_to_integer((1, 1, 0, 1, 0, 0, 1)) == '105'\n\"\"\"\ndef binary_to_integer(binary_tuple):\n binary_tuple = binary_tuple[::-1]\n binary_tuple = binary_tuple.replace('0', '')\n binary_tuple = binary_tuple.replace('1', '')\n binary_tuple = binary_tuple.replace('10', '1')\n binary_tuple = binary_tuple.replace('11', '0')\n binary_tuple = int(binary_tuple, 2)\n return str(binary_tuple)\n"], ["\"\"\"\nWrite a function to remove lowercase substrings from a given string by using regex.\nassert remove_lowercase('KDeoALOklOOHserfLoAJSIskdsf') == 'KDALOOOHLAJSI'\n\"\"\"\ndef remove_lowercase(s):\n return s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '').replace('o', '').replace('u', '') + s.replace('a', '').replace('e', '').replace('i', '')."], ["\"\"\"\nWrite a function to find the smallest integers from a given list of numbers using heap queue algorithm.\nassert heap_queue_smallest( [25, 35, 22, 85, 14, 65, 75, 25, 58],3)==[14, 22, 25] \n\"\"\"\nfrom heapq import heappush, heappop\n\ndef heap_queue_smallest(nums, n):\n heap = []\n for i in range(n):\n heappush(heap, nums[i])\n for i in range(n-1, 0, -1):\n nums[i-1], nums[0] = nums[0], nums[i-1]\n heappop(heap)\n return nums\n\nnums = [25, 35, 22, 85, 14, 65, 75, 25, 58]"], ["\"\"\"\nWrite a function to find the surface area of a cone.\nassert surfacearea_cone(5,12)==282.7433388230814\n\"\"\"\nimport math\n\ndef surfacearea_cone(r,h):\n \"\"\"\n :param r: radius of the cone\n :param h: height of the cone\n :return: surface area of the cone\n \"\"\"\n return math.pi * r * r + math.pi * r * h\n\ndef main():\n r = 5\n h = 12\n print(surfacearea_cone(r,h))\n"], ["\"\"\"\nWrite a python function to find gcd of two positive integers.\nassert gcd(12, 17) == 1\n\"\"\"\ndef gcd(a, b):\n while b != 0:\n a, b = b, a % b\n return a\n"], ["\"\"\"\nWrite a function to find the diameter of a circle.\nassert diameter_circle(10)==20\n\"\"\"\nimport math\n\ndef diameter_circle(radius):\n diameter = 2 * radius\n return diameter\n\nradius = 10"], ["\"\"\"\nWrite a function to concatenate all elements of the given list into a string.\nassert concatenate_elements(['hello','there','have','a','rocky','day'] ) == ' hello there have a rocky day'\n\"\"\"\ndef concatenate_elements(lst):\n return ' '.join(lst)\n"], ["\"\"\"\nWrite a python function to find common divisor between two numbers in a given pair.\nassert num_comm_div(2,4) == 2\n\"\"\"\ndef common_divisor(num1, num2):\n if num1 == num2:\n return 0\n else:\n return num1 % num2\n"], ["\"\"\"\nWrite a python function to find remainder of two numbers.\nassert find(3,3) == 0\n\"\"\"\ndef find(a,b):\n return a % b\n"], ["\"\"\"\nWrite a function to add consecutive numbers of a given list.\nassert add_consecutive_nums([1, 1, 3, 4, 4, 5, 6, 7])==[2, 4, 7, 8, 9, 11, 13]\n\"\"\"\ndef add_consecutive_nums(nums):\n result = []\n for i in range(len(nums)):\n if i == 0 or nums[i] != nums[i-1] + 1:\n result.append(nums[i])\n return result\n"], ["\"\"\"\nWrite a python function to find the cube sum of first n natural numbers.\nassert sum_Of_Series(5) == 225\n\"\"\"\ndef cube_sum(n):\n sum = 0\n for i in range(1, n+1):\n sum += i**3\n return sum\n"], ["\"\"\"\nWrite a function to move all zeroes to the end of the given array.\nassert re_order([6, 0, 8, 2, 3, 0, 4, 0, 1]) == [6, 8, 2, 3, 4, 1, 0, 0, 0]\n\"\"\"\ndef re_order(arr):\n arr = arr.copy()\n for i in range(len(arr)):\n if arr[i] == 0:\n arr.insert(i, 0)\n arr.pop()\n return arr\n"], ["\"\"\"\nWrite a function to calculate the permutation coefficient of given p(n, k).\nassert permutation_coefficient(10, 2) == 90\n\"\"\"\nfrom math import factorial\n\ndef permutation_coefficient(n, k):\n \"\"\"\n Calculate the permutation coefficient of given p(n, k).\n \"\"\"\n return factorial(n) // (factorial(n - k) * factorial(k))\n"], ["\"\"\"\nWrite a function to remove specific words from a given list.\nassert remove_words(['red', 'green', 'blue', 'white', 'black', 'orange'],['white', 'orange'])==['red', 'green', 'blue', 'black']\n\"\"\"\ndef remove_words(list1, words):\n list1 = [word for word in list1 if word not in words]\n return list1\n\nremove_words(['red', 'green', 'blue', 'white', 'black', 'orange'],['white', 'orange']) == ['red', 'green', 'blue', 'black']"], ["\"\"\"\nWrite a function to check if the common elements between two given lists are in the same order or not.\nassert same_order([\"red\",\"green\",\"black\",\"orange\"],[\"red\",\"pink\",\"green\",\"white\",\"black\"])==True\n\"\"\"\ndef same_order(list1, list2):\n list1.sort()\n list2.sort()\n if list1 == list2:\n return True\n else:\n return False\n"], ["\"\"\"\nWrite a python function to find the average of odd numbers till a given odd number.\nassert average_Odd(9) == 5\n\"\"\"\ndef average_Odd(n):\n sum = 0\n for i in range(1, n+1):\n if i % 2 != 0:\n sum += i\n return sum / n\n"], ["\"\"\"\nWrite a function to find the number of subsequences having product smaller than k for the given non negative array.\nassert no_of_subsequences([1,2,3,4], 10) == 11\n\"\"\"\ndef no_of_subsequences(arr, k):\n count = 0\n for i in range(len(arr)):\n for j in range(i+1, len(arr)):\n product = arr[i] * arr[j]\n if product < k:\n count += 1\n return count\n\narr = [1,2,3,4]\nk = 10"]] \ No newline at end of file