diff --git "a/all/mbpp_structured.json" "b/all/mbpp_structured.json" new file mode 100644--- /dev/null +++ "b/all/mbpp_structured.json" @@ -0,0 +1,13618 @@ +{ + "Source": "https://arxiv.org/pdf/2108.07732.pdf", + "Categories": [ + { + "Math complexity": 2, + "Language complexity": 7, + "Domain knowledge complexity": 8 + } + ], + "Instances": [ + { + "Input": "Write a function to find the minimum cost path to reach (m, n) from (0, 0) for the given cost matrix cost[][] and a position (m, n) in cost[][].", + "Output Program": [ + "R = 3\r\nC = 3\r\ndef min_cost(cost, m, n): \r\n\ttc = [[0 for x in range(C)] for x in range(R)] \r\n\ttc[0][0] = cost[0][0] \r\n\tfor i in range(1, m+1): \r\n\t\ttc[i][0] = tc[i-1][0] + cost[i][0] \r\n\tfor j in range(1, n+1): \r\n\t\ttc[0][j] = tc[0][j-1] + cost[0][j] \r\n\tfor i in range(1, m+1): \r\n\t\tfor j in range(1, n+1): \r\n\t\t\ttc[i][j] = min(tc[i-1][j-1], tc[i-1][j], tc[i][j-1]) + cost[i][j] \r\n\treturn tc[m][n]" + ], + "Output Answer": [ + "R = 3\r\nC = 3\r\ndef min_cost(cost, m, n): \r\n\ttc = [[0 for x in range(C)] for x in range(R)] \r\n\ttc[0][0] = cost[0][0] \r\n\tfor i in range(1, m+1): \r\n\t\ttc[i][0] = tc[i-1][0] + cost[i][0] \r\n\tfor j in range(1, n+1): \r\n\t\ttc[0][j] = tc[0][j-1] + cost[0][j] \r\n\tfor i in range(1, m+1): \r\n\t\tfor j in range(1, n+1): \r\n\t\t\ttc[i][j] = min(tc[i-1][j-1], tc[i-1][j], tc[i][j-1]) + cost[i][j] \r\n\treturn tc[m][n]" + ], + "split": "few" + }, + { + "Input": "Write a function to find the similar elements from the given two tuple lists.", + "Output Program": [ + "def similar_elements(test_tup1, test_tup2):\r\n res = tuple(set(test_tup1) & set(test_tup2))\r\n return (res) " + ], + "Output Answer": [ + "def similar_elements(test_tup1, test_tup2):\r\n res = tuple(set(test_tup1) & set(test_tup2))\r\n return (res) " + ], + "split": "few" + }, + { + "Input": "Write a python function to identify non-prime numbers.", + "Output Program": [ + "import math\r\ndef is_not_prime(n):\r\n result = False\r\n for i in range(2,int(math.sqrt(n)) + 1):\r\n if n % i == 0:\r\n result = True\r\n return result" + ], + "Output Answer": [ + "import math\r\ndef is_not_prime(n):\r\n result = False\r\n for i in range(2,int(math.sqrt(n)) + 1):\r\n if n % i == 0:\r\n result = True\r\n return result" + ], + "split": "few" + }, + { + "Input": "Write a function to find the largest integers from a given list of numbers using heap queue algorithm.", + "Output Program": [ + "import heapq as hq\r\ndef heap_queue_largest(nums,n):\r\n largest_nums = hq.nlargest(n, nums)\r\n return largest_nums" + ], + "Output Answer": [ + "import heapq as hq\r\ndef heap_queue_largest(nums,n):\r\n largest_nums = hq.nlargest(n, nums)\r\n return largest_nums" + ], + "split": "few" + }, + { + "Input": "Write a function to find the number of ways to fill it with 2 x 1 dominoes for the given 3 x n board.", + "Output Program": [ + "def count_ways(n): \r\n\tA = [0] * (n + 1) \r\n\tB = [0] * (n + 1) \r\n\tA[0] = 1\r\n\tA[1] = 0\r\n\tB[0] = 0\r\n\tB[1] = 1\r\n\tfor i in range(2, n+1): \r\n\t\tA[i] = A[i - 2] + 2 * B[i - 1] \r\n\t\tB[i] = A[i - 1] + B[i - 2] \r\n\treturn A[n] " + ], + "Output Answer": [ + "def count_ways(n): \r\n\tA = [0] * (n + 1) \r\n\tB = [0] * (n + 1) \r\n\tA[0] = 1\r\n\tA[1] = 0\r\n\tB[0] = 0\r\n\tB[1] = 1\r\n\tfor i in range(2, n+1): \r\n\t\tA[i] = A[i - 2] + 2 * B[i - 1] \r\n\t\tB[i] = A[i - 1] + B[i - 2] \r\n\treturn A[n] " + ], + "split": "few" + }, + { + "Input": "Write a python function to check whether the two numbers differ at one bit position only or not.", + "Output Program": [ + "def is_Power_Of_Two (x): \r\n return x and (not(x & (x - 1))) \r\ndef differ_At_One_Bit_Pos(a,b): \r\n return is_Power_Of_Two(a ^ b)" + ], + "Output Answer": [ + "def is_Power_Of_Two (x): \r\n return x and (not(x & (x - 1))) \r\ndef differ_At_One_Bit_Pos(a,b): \r\n return is_Power_Of_Two(a ^ b)" + ], + "split": "few" + }, + { + "Input": "Write a function to find all words which are at least 4 characters long in a string by using regex.", + "Output Program": [ + "import re\r\ndef find_char_long(text):\r\n return (re.findall(r\"\\b\\w{4,}\\b\", text))" + ], + "Output Answer": [ + "import re\r\ndef find_char_long(text):\r\n return (re.findall(r\"\\b\\w{4,}\\b\", text))" + ], + "split": "few" + }, + { + "Input": "Write a function to find squares of individual elements in a list using lambda function.", + "Output Program": [ + "def square_nums(nums):\r\n square_nums = list(map(lambda x: x ** 2, nums))\r\n return square_nums" + ], + "Output Answer": [ + "def square_nums(nums):\r\n square_nums = list(map(lambda x: x ** 2, nums))\r\n return square_nums" + ], + "split": "few" + }, + { + "Input": "Write a python function to find the minimum number of rotations required to get the same string.", + "Output Program": [ + "def find_Rotations(str): \r\n tmp = str + str\r\n n = len(str) \r\n for i in range(1,n + 1): \r\n substring = tmp[i: i+n] \r\n if (str == substring): \r\n return i \r\n return n " + ], + "Output Answer": [ + "def find_Rotations(str): \r\n tmp = str + str\r\n n = len(str) \r\n for i in range(1,n + 1): \r\n substring = tmp[i: i+n] \r\n if (str == substring): \r\n return i \r\n return n " + ], + "split": "few" + }, + { + "Input": "Write a function to get the n smallest items from a dataset.", + "Output Program": [ + "import heapq\r\ndef small_nnum(list1,n):\r\n smallest=heapq.nsmallest(n,list1)\r\n return smallest" + ], + "Output Answer": [ + "import heapq\r\ndef small_nnum(list1,n):\r\n smallest=heapq.nsmallest(n,list1)\r\n return smallest" + ], + "split": "few" + }, + { + "Input": "Write a python function to remove first and last occurrence of a given character from the string.", + "Output Program": [ + "def remove_Occ(s,ch): \r\n for i in range(len(s)): \r\n if (s[i] == ch): \r\n s = s[0 : i] + s[i + 1:] \r\n break\r\n for i in range(len(s) - 1,-1,-1): \r\n if (s[i] == ch): \r\n s = s[0 : i] + s[i + 1:] \r\n break\r\n return s " + ], + "Output Answer": [ + "def remove_Occ(s,ch): \r\n for i in range(len(s)): \r\n if (s[i] == ch): \r\n s = s[0 : i] + s[i + 1:] \r\n break\r\n for i in range(len(s) - 1,-1,-1): \r\n if (s[i] == ch): \r\n s = s[0 : i] + s[i + 1:] \r\n break\r\n return s " + ], + "split": "test" + }, + { + "Input": "Write a function to sort a given matrix in ascending order according to the sum of its rows.", + "Output Program": [ + "def sort_matrix(M):\r\n result = sorted(M, key=sum)\r\n return result" + ], + "Output Answer": [ + "def sort_matrix(M):\r\n result = sorted(M, key=sum)\r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a function to count the most common words in a dictionary.", + "Output Program": [ + "from collections import Counter\r\ndef count_common(words):\r\n word_counts = Counter(words)\r\n top_four = word_counts.most_common(4)\r\n return (top_four)\r\n" + ], + "Output Answer": [ + "from collections import Counter\r\ndef count_common(words):\r\n word_counts = Counter(words)\r\n top_four = word_counts.most_common(4)\r\n return (top_four)\r\n" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the volume of a triangular prism.", + "Output Program": [ + "def find_Volume(l,b,h) : \r\n return ((l * b * h) / 2) " + ], + "Output Answer": [ + "def find_Volume(l,b,h) : \r\n return ((l * b * h) / 2) " + ], + "split": "test" + }, + { + "Input": "Write a function to split a string at lowercase letters.", + "Output Program": [ + "import re\r\ndef split_lowerstring(text):\r\n return (re.findall('[a-z][^a-z]*', text))" + ], + "Output Answer": [ + "import re\r\ndef split_lowerstring(text):\r\n return (re.findall('[a-z][^a-z]*', text))" + ], + "split": "test" + }, + { + "Input": "Write a function to find sequences of lowercase letters joined with an underscore.", + "Output Program": [ + "import re\r\ndef text_lowercase_underscore(text):\r\n patterns = '^[a-z]+_[a-z]+$'\r\n if re.search(patterns, text):\r\n return 'Found a match!'\r\n else:\r\n return('Not matched!')" + ], + "Output Answer": [ + "import re\r\ndef text_lowercase_underscore(text):\r\n patterns = '^[a-z]+_[a-z]+$'\r\n if re.search(patterns, text):\r\n return 'Found a match!'\r\n else:\r\n return('Not matched!')" + ], + "split": "test" + }, + { + "Input": "Write a function to find the perimeter of a square.", + "Output Program": [ + "def square_perimeter(a):\r\n perimeter=4*a\r\n return perimeter" + ], + "Output Answer": [ + "def square_perimeter(a):\r\n perimeter=4*a\r\n return perimeter" + ], + "split": "test" + }, + { + "Input": "Write a function to remove characters from the first string which are present in the second string.", + "Output Program": [ + "NO_OF_CHARS = 256\r\ndef str_to_list(string): \r\n\ttemp = [] \r\n\tfor x in string: \r\n\t\ttemp.append(x) \r\n\treturn temp \r\ndef lst_to_string(List): \r\n\treturn ''.join(List) \r\ndef get_char_count_array(string): \r\n\tcount = [0] * NO_OF_CHARS \r\n\tfor i in string: \r\n\t\tcount[ord(i)] += 1\r\n\treturn count \r\ndef remove_dirty_chars(string, second_string): \r\n\tcount = get_char_count_array(second_string) \r\n\tip_ind = 0\r\n\tres_ind = 0\r\n\ttemp = '' \r\n\tstr_list = str_to_list(string) \r\n\twhile ip_ind != len(str_list): \r\n\t\ttemp = str_list[ip_ind] \r\n\t\tif count[ord(temp)] == 0: \r\n\t\t\tstr_list[res_ind] = str_list[ip_ind] \r\n\t\t\tres_ind += 1\r\n\t\tip_ind+=1\r\n\treturn lst_to_string(str_list[0:res_ind]) " + ], + "Output Answer": [ + "NO_OF_CHARS = 256\r\ndef str_to_list(string): \r\n\ttemp = [] \r\n\tfor x in string: \r\n\t\ttemp.append(x) \r\n\treturn temp \r\ndef lst_to_string(List): \r\n\treturn ''.join(List) \r\ndef get_char_count_array(string): \r\n\tcount = [0] * NO_OF_CHARS \r\n\tfor i in string: \r\n\t\tcount[ord(i)] += 1\r\n\treturn count \r\ndef remove_dirty_chars(string, second_string): \r\n\tcount = get_char_count_array(second_string) \r\n\tip_ind = 0\r\n\tres_ind = 0\r\n\ttemp = '' \r\n\tstr_list = str_to_list(string) \r\n\twhile ip_ind != len(str_list): \r\n\t\ttemp = str_list[ip_ind] \r\n\t\tif count[ord(temp)] == 0: \r\n\t\t\tstr_list[res_ind] = str_list[ip_ind] \r\n\t\t\tres_ind += 1\r\n\t\tip_ind+=1\r\n\treturn lst_to_string(str_list[0:res_ind]) " + ], + "split": "test" + }, + { + "Input": "Write a function to find whether a given array of integers contains any duplicate element.", + "Output Program": [ + "def test_duplicate(arraynums):\r\n nums_set = set(arraynums) \r\n return len(arraynums) != len(nums_set) " + ], + "Output Answer": [ + "def test_duplicate(arraynums):\r\n nums_set = set(arraynums) \r\n return len(arraynums) != len(nums_set) " + ], + "split": "test" + }, + { + "Input": "Write a function to check if the given number is woodball or not.", + "Output Program": [ + "def is_woodall(x): \r\n\tif (x % 2 == 0): \r\n\t\treturn False\r\n\tif (x == 1): \r\n\t\treturn True\r\n\tx = x + 1 \r\n\tp = 0\r\n\twhile (x % 2 == 0): \r\n\t\tx = x/2\r\n\t\tp = p + 1\r\n\t\tif (p == x): \r\n\t\t\treturn True\r\n\treturn False" + ], + "Output Answer": [ + "def is_woodall(x): \r\n\tif (x % 2 == 0): \r\n\t\treturn False\r\n\tif (x == 1): \r\n\t\treturn True\r\n\tx = x + 1 \r\n\tp = 0\r\n\twhile (x % 2 == 0): \r\n\t\tx = x/2\r\n\t\tp = p + 1\r\n\t\tif (p == x): \r\n\t\t\treturn True\r\n\treturn False" + ], + "split": "test" + }, + { + "Input": "Write a function to find m number of multiples of n.", + "Output Program": [ + "def multiples_of_num(m,n): \r\n multiples_of_num= list(range(n,(m+1)*n, n)) \r\n return list(multiples_of_num)" + ], + "Output Answer": [ + "def multiples_of_num(m,n): \r\n multiples_of_num= list(range(n,(m+1)*n, n)) \r\n return list(multiples_of_num)" + ], + "split": "test" + }, + { + "Input": "Write a function to find the first duplicate element in a given array of integers.", + "Output Program": [ + "def find_first_duplicate(nums):\r\n num_set = set()\r\n no_duplicate = -1\r\n\r\n for i in range(len(nums)):\r\n\r\n if nums[i] in num_set:\r\n return nums[i]\r\n else:\r\n num_set.add(nums[i])\r\n\r\n return no_duplicate" + ], + "Output Answer": [ + "def find_first_duplicate(nums):\r\n num_set = set()\r\n no_duplicate = -1\r\n\r\n for i in range(len(nums)):\r\n\r\n if nums[i] in num_set:\r\n return nums[i]\r\n else:\r\n num_set.add(nums[i])\r\n\r\n return no_duplicate" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the maximum sum of elements of list in a list of lists.", + "Output Program": [ + "def maximum_Sum(list1): \r\n maxi = -100000\r\n for x in list1: \r\n sum = 0 \r\n for y in x: \r\n sum+= y \r\n maxi = max(sum,maxi) \r\n return maxi " + ], + "Output Answer": [ + "def maximum_Sum(list1): \r\n maxi = -100000\r\n for x in list1: \r\n sum = 0 \r\n for y in x: \r\n sum+= y \r\n maxi = max(sum,maxi) \r\n return maxi " + ], + "split": "test" + }, + { + "Input": "Write a function to convert the given binary number to its decimal equivalent.", + "Output Program": [ + "def binary_to_decimal(binary): \r\n binary1 = binary \r\n decimal, i, n = 0, 0, 0\r\n while(binary != 0): \r\n dec = binary % 10\r\n decimal = decimal + dec * pow(2, i) \r\n binary = binary//10\r\n i += 1\r\n return (decimal)" + ], + "Output Answer": [ + "def binary_to_decimal(binary): \r\n binary1 = binary \r\n decimal, i, n = 0, 0, 0\r\n while(binary != 0): \r\n dec = binary % 10\r\n decimal = decimal + dec * pow(2, i) \r\n binary = binary//10\r\n i += 1\r\n return (decimal)" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the product of non-repeated elements in a given array.", + "Output Program": [ + "def find_Product(arr,n): \r\n arr.sort() \r\n prod = 1\r\n for i in range(0,n,1): \r\n if (arr[i - 1] != arr[i]): \r\n prod = prod * arr[i] \r\n return prod; " + ], + "Output Answer": [ + "def find_Product(arr,n): \r\n arr.sort() \r\n prod = 1\r\n for i in range(0,n,1): \r\n if (arr[i - 1] != arr[i]): \r\n prod = prod * arr[i] \r\n return prod; " + ], + "split": "test" + }, + { + "Input": "Write a function to check if the given tuple list has all k elements.", + "Output Program": [ + "def check_k_elements(test_list, K):\r\n res = True\r\n for tup in test_list:\r\n for ele in tup:\r\n if ele != K:\r\n res = False\r\n return (res) " + ], + "Output Answer": [ + "def check_k_elements(test_list, K):\r\n res = True\r\n for tup in test_list:\r\n for ele in tup:\r\n if ele != K:\r\n res = False\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a python function to remove all digits from a list of strings.", + "Output Program": [ + "import re \r\ndef remove(list): \r\n pattern = '[0-9]'\r\n list = [re.sub(pattern, '', i) for i in list] \r\n return list" + ], + "Output Answer": [ + "import re \r\ndef remove(list): \r\n pattern = '[0-9]'\r\n list = [re.sub(pattern, '', i) for i in list] \r\n return list" + ], + "split": "test" + }, + { + "Input": "Write a python function to find binomial co-efficient.", + "Output Program": [ + "def binomial_Coeff(n,k): \r\n if k > n : \r\n return 0\r\n if k==0 or k ==n : \r\n return 1 \r\n return binomial_Coeff(n-1,k-1) + binomial_Coeff(n-1,k) " + ], + "Output Answer": [ + "def binomial_Coeff(n,k): \r\n if k > n : \r\n return 0\r\n if k==0 or k ==n : \r\n return 1 \r\n return binomial_Coeff(n-1,k-1) + binomial_Coeff(n-1,k) " + ], + "split": "test" + }, + { + "Input": "Write a python function to find the element occurring odd number of times.", + "Output Program": [ + "def get_Odd_Occurrence(arr,arr_size): \r\n for i in range(0,arr_size): \r\n count = 0\r\n for j in range(0,arr_size): \r\n if arr[i] == arr[j]: \r\n count+=1 \r\n if (count % 2 != 0): \r\n return arr[i] \r\n return -1" + ], + "Output Answer": [ + "def get_Odd_Occurrence(arr,arr_size): \r\n for i in range(0,arr_size): \r\n count = 0\r\n for j in range(0,arr_size): \r\n if arr[i] == arr[j]: \r\n count+=1 \r\n if (count % 2 != 0): \r\n return arr[i] \r\n return -1" + ], + "split": "test" + }, + { + "Input": "Write a python function to count all the substrings starting and ending with same characters.", + "Output Program": [ + "def check_Equality(s): \r\n return (ord(s[0]) == ord(s[len(s) - 1])); \r\ndef count_Substring_With_Equal_Ends(s): \r\n result = 0; \r\n n = len(s); \r\n for i in range(n): \r\n for j in range(1,n-i+1): \r\n if (check_Equality(s[i:i+j])): \r\n result+=1; \r\n return result; " + ], + "Output Answer": [ + "def check_Equality(s): \r\n return (ord(s[0]) == ord(s[len(s) - 1])); \r\ndef count_Substring_With_Equal_Ends(s): \r\n result = 0; \r\n n = len(s); \r\n for i in range(n): \r\n for j in range(1,n-i+1): \r\n if (check_Equality(s[i:i+j])): \r\n result+=1; \r\n return result; " + ], + "split": "test" + }, + { + "Input": "Write a function to find the top k integers that occur most frequently from given lists of sorted and distinct integers using heap queue algorithm.", + "Output Program": [ + "def func(nums, k):\r\n import collections\r\n d = collections.defaultdict(int)\r\n for row in nums:\r\n for i in row:\r\n d[i] += 1\r\n temp = []\r\n import heapq\r\n for key, v in d.items():\r\n if len(temp) < k:\r\n temp.append((v, key))\r\n if len(temp) == k:\r\n heapq.heapify(temp)\r\n else:\r\n if v > temp[0][0]:\r\n heapq.heappop(temp)\r\n heapq.heappush(temp, (v, key))\r\n result = []\r\n while temp:\r\n v, key = heapq.heappop(temp)\r\n result.append(key)\r\n return result" + ], + "Output Answer": [ + "def func(nums, k):\r\n import collections\r\n d = collections.defaultdict(int)\r\n for row in nums:\r\n for i in row:\r\n d[i] += 1\r\n temp = []\r\n import heapq\r\n for key, v in d.items():\r\n if len(temp) < k:\r\n temp.append((v, key))\r\n if len(temp) == k:\r\n heapq.heapify(temp)\r\n else:\r\n if v > temp[0][0]:\r\n heapq.heappop(temp)\r\n heapq.heappush(temp, (v, key))\r\n result = []\r\n while temp:\r\n v, key = heapq.heappop(temp)\r\n result.append(key)\r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the largest prime factor of a given number.", + "Output Program": [ + "import math \r\ndef max_Prime_Factors (n): \r\n maxPrime = -1 \r\n while n%2 == 0: \r\n maxPrime = 2\r\n n >>= 1 \r\n for i in range(3,int(math.sqrt(n))+1,2): \r\n while n % i == 0: \r\n maxPrime = i \r\n n = n / i \r\n if n > 2: \r\n maxPrime = n \r\n return int(maxPrime)" + ], + "Output Answer": [ + "import math \r\ndef max_Prime_Factors (n): \r\n maxPrime = -1 \r\n while n%2 == 0: \r\n maxPrime = 2\r\n n >>= 1 \r\n for i in range(3,int(math.sqrt(n))+1,2): \r\n while n % i == 0: \r\n maxPrime = i \r\n n = n / i \r\n if n > 2: \r\n maxPrime = n \r\n return int(maxPrime)" + ], + "split": "test" + }, + { + "Input": "Write a python function to convert a decimal number to binary number.", + "Output Program": [ + "def decimal_To_Binary(N): \r\n B_Number = 0\r\n cnt = 0\r\n while (N != 0): \r\n rem = N % 2\r\n c = pow(10,cnt) \r\n B_Number += rem*c \r\n N //= 2 \r\n cnt += 1\r\n return B_Number " + ], + "Output Answer": [ + "def decimal_To_Binary(N): \r\n B_Number = 0\r\n cnt = 0\r\n while (N != 0): \r\n rem = N % 2\r\n c = pow(10,cnt) \r\n B_Number += rem*c \r\n N //= 2 \r\n cnt += 1\r\n return B_Number " + ], + "split": "test" + }, + { + "Input": "Write a python function to find the missing number in a sorted array.", + "Output Program": [ + "def find_missing(ar,N): \r\n l = 0\r\n r = N - 1\r\n while (l <= r): \r\n mid = (l + r) / 2\r\n mid= int (mid) \r\n if (ar[mid] != mid + 1 and ar[mid - 1] == mid): \r\n return (mid + 1) \r\n elif (ar[mid] != mid + 1): \r\n r = mid - 1 \r\n else: \r\n l = mid + 1\r\n return (-1) " + ], + "Output Answer": [ + "def find_missing(ar,N): \r\n l = 0\r\n r = N - 1\r\n while (l <= r): \r\n mid = (l + r) / 2\r\n mid= int (mid) \r\n if (ar[mid] != mid + 1 and ar[mid - 1] == mid): \r\n return (mid + 1) \r\n elif (ar[mid] != mid + 1): \r\n r = mid - 1 \r\n else: \r\n l = mid + 1\r\n return (-1) " + ], + "split": "test" + }, + { + "Input": "Write a function to find the n-th rectangular number.", + "Output Program": [ + "def find_rect_num(n):\r\n return n*(n + 1) " + ], + "Output Answer": [ + "def find_rect_num(n):\r\n return n*(n + 1) " + ], + "split": "test" + }, + { + "Input": "Write a python function to find the nth digit in the proper fraction of two given numbers.", + "Output Program": [ + "def find_Nth_Digit(p,q,N) : \r\n while (N > 0) : \r\n N -= 1; \r\n p *= 10; \r\n res = p // q; \r\n p %= q; \r\n return res; " + ], + "Output Answer": [ + "def find_Nth_Digit(p,q,N) : \r\n while (N > 0) : \r\n N -= 1; \r\n p *= 10; \r\n res = p // q; \r\n p %= q; \r\n return res; " + ], + "split": "test" + }, + { + "Input": "Write a function to sort a given mixed list of integers and strings.", + "Output Program": [ + "def sort_mixed_list(mixed_list):\r\n int_part = sorted([i for i in mixed_list if type(i) is int])\r\n str_part = sorted([i for i in mixed_list if type(i) is str])\r\n return int_part + str_part" + ], + "Output Answer": [ + "def sort_mixed_list(mixed_list):\r\n int_part = sorted([i for i in mixed_list if type(i) is int])\r\n str_part = sorted([i for i in mixed_list if type(i) is str])\r\n return int_part + str_part" + ], + "split": "test" + }, + { + "Input": "Write a function to find the division of first even and odd number of a given list.", + "Output Program": [ + "def div_even_odd(list1):\r\n first_even = next((el for el in list1 if el%2==0),-1)\r\n first_odd = next((el for el in list1 if el%2!=0),-1)\r\n return (first_even/first_odd)" + ], + "Output Answer": [ + "def div_even_odd(list1):\r\n first_even = next((el for el in list1 if el%2==0),-1)\r\n first_odd = next((el for el in list1 if el%2!=0),-1)\r\n return (first_even/first_odd)" + ], + "split": "test" + }, + { + "Input": "Write 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.", + "Output Program": [ + "import heapq\r\nfrom collections import Counter\r\ndef rearange_string(S):\r\n ctr = Counter(S)\r\n heap = [(-value, key) for key, value in ctr.items()]\r\n heapq.heapify(heap)\r\n if (-heap[0][0]) * 2 > len(S) + 1: \r\n return \"\"\r\n ans = []\r\n while len(heap) >= 2:\r\n nct1, char1 = heapq.heappop(heap)\r\n nct2, char2 = heapq.heappop(heap)\r\n ans.extend([char1, char2])\r\n if nct1 + 1: heapq.heappush(heap, (nct1 + 1, char1))\r\n if nct2 + 1: heapq.heappush(heap, (nct2 + 1, char2))\r\n return \"\".join(ans) + (heap[0][1] if heap else \"\")" + ], + "Output Answer": [ + "import heapq\r\nfrom collections import Counter\r\ndef rearange_string(S):\r\n ctr = Counter(S)\r\n heap = [(-value, key) for key, value in ctr.items()]\r\n heapq.heapify(heap)\r\n if (-heap[0][0]) * 2 > len(S) + 1: \r\n return \"\"\r\n ans = []\r\n while len(heap) >= 2:\r\n nct1, char1 = heapq.heappop(heap)\r\n nct2, char2 = heapq.heappop(heap)\r\n ans.extend([char1, char2])\r\n if nct1 + 1: heapq.heappush(heap, (nct1 + 1, char1))\r\n if nct2 + 1: heapq.heappush(heap, (nct2 + 1, char2))\r\n return \"\".join(ans) + (heap[0][1] if heap else \"\")" + ], + "split": "test" + }, + { + "Input": "Write a function to find frequency of the elements in a given list of lists using collections module.", + "Output Program": [ + "from collections import Counter\r\nfrom itertools import chain\r\ndef freq_element(nums):\r\n result = Counter(chain.from_iterable(nums))\r\n return result" + ], + "Output Answer": [ + "from collections import Counter\r\nfrom itertools import chain\r\ndef freq_element(nums):\r\n result = Counter(chain.from_iterable(nums))\r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a function to filter even numbers using lambda function.", + "Output Program": [ + "def filter_evennumbers(nums):\r\n even_nums = list(filter(lambda x: x%2 == 0, nums))\r\n return even_nums" + ], + "Output Answer": [ + "def filter_evennumbers(nums):\r\n even_nums = list(filter(lambda x: x%2 == 0, nums))\r\n return even_nums" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the sum of repeated elements in a given array.", + "Output Program": [ + "def find_Sum(arr,n): \r\n return sum([x for x in arr if arr.count(x) > 1])" + ], + "Output Answer": [ + "def find_Sum(arr,n): \r\n return sum([x for x in arr if arr.count(x) > 1])" + ], + "split": "test" + }, + { + "Input": "Write a function to find sequences of lowercase letters joined with an underscore using regex.", + "Output Program": [ + "import re\r\ndef text_match(text):\r\n patterns = '^[a-z]+_[a-z]+$'\r\n if re.search(patterns, text):\r\n return ('Found a match!')\r\n else:\r\n return ('Not matched!')" + ], + "Output Answer": [ + "import re\r\ndef text_match(text):\r\n patterns = '^[a-z]+_[a-z]+$'\r\n if re.search(patterns, text):\r\n return ('Found a match!')\r\n else:\r\n return ('Not matched!')" + ], + "split": "test" + }, + { + "Input": "Write a function that matches a word at the beginning of a string.", + "Output Program": [ + "import re\r\ndef text_match_string(text):\r\n patterns = '^\\w+'\r\n if re.search(patterns, text):\r\n return 'Found a match!'\r\n else:\r\n return 'Not matched!'" + ], + "Output Answer": [ + "import re\r\ndef text_match_string(text):\r\n patterns = '^\\w+'\r\n if re.search(patterns, text):\r\n return 'Found a match!'\r\n else:\r\n return 'Not matched!'" + ], + "split": "test" + }, + { + "Input": "Write a function to find the gcd of the given array elements.", + "Output Program": [ + "def find_gcd(x, y): \r\n\twhile(y): \r\n\t\tx, y = y, x % y \r\n\treturn x \r\ndef get_gcd(l):\r\n num1 = l[0]\r\n num2 = l[1]\r\n gcd = find_gcd(num1, num2)\r\n for i in range(2, len(l)):\r\n gcd = find_gcd(gcd, l[i])\r\n return gcd" + ], + "Output Answer": [ + "def find_gcd(x, y): \r\n\twhile(y): \r\n\t\tx, y = y, x % y \r\n\treturn x \r\ndef get_gcd(l):\r\n num1 = l[0]\r\n num2 = l[1]\r\n gcd = find_gcd(num1, num2)\r\n for i in range(2, len(l)):\r\n gcd = find_gcd(gcd, l[i])\r\n return gcd" + ], + "split": "test" + }, + { + "Input": "Write a python function to determine whether all the numbers are different from each other are not.", + "Output Program": [ + "def test_distinct(data):\r\n if len(data) == len(set(data)):\r\n return True\r\n else:\r\n return False;" + ], + "Output Answer": [ + "def test_distinct(data):\r\n if len(data) == len(set(data)):\r\n return True\r\n else:\r\n return False;" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the last digit when factorial of a divides factorial of b.", + "Output Program": [ + "def compute_Last_Digit(A,B): \r\n variable = 1\r\n if (A == B): \r\n return 1\r\n elif ((B - A) >= 5): \r\n return 0\r\n else: \r\n for i in range(A + 1,B + 1): \r\n variable = (variable * (i % 10)) % 10\r\n return variable % 10" + ], + "Output Answer": [ + "def compute_Last_Digit(A,B): \r\n variable = 1\r\n if (A == B): \r\n return 1\r\n elif ((B - A) >= 5): \r\n return 0\r\n else: \r\n for i in range(A + 1,B + 1): \r\n variable = (variable * (i % 10)) % 10\r\n return variable % 10" + ], + "split": "test" + }, + { + "Input": "Write a python function to set all odd bits of a given number.", + "Output Program": [ + "def odd_bit_set_number(n):\r\n count = 0;res = 0;temp = n\r\n while temp > 0:\r\n if count % 2 == 0:\r\n res |= (1 << count)\r\n count += 1\r\n temp >>= 1\r\n return (n | res)" + ], + "Output Answer": [ + "def odd_bit_set_number(n):\r\n count = 0;res = 0;temp = n\r\n while temp > 0:\r\n if count % 2 == 0:\r\n res |= (1 << count)\r\n count += 1\r\n temp >>= 1\r\n return (n | res)" + ], + "split": "test" + }, + { + "Input": "Write a function to extract every first or specified element from a given two-dimensional list.", + "Output Program": [ + "def specified_element(nums, N):\r\n result = [i[N] for i in nums]\r\n return result\r\n " + ], + "Output Answer": [ + "def specified_element(nums, N):\r\n result = [i[N] for i in nums]\r\n return result\r\n " + ], + "split": "test" + }, + { + "Input": "Write a function to find the list with minimum length using lambda function.", + "Output Program": [ + "def min_length_list(input_list):\r\n min_length = min(len(x) for x in input_list ) \r\n min_list = min(input_list, key = lambda i: len(i))\r\n return(min_length, min_list)" + ], + "Output Answer": [ + "def min_length_list(input_list):\r\n min_length = min(len(x) for x in input_list ) \r\n min_list = min(input_list, key = lambda i: len(i))\r\n return(min_length, min_list)" + ], + "split": "test" + }, + { + "Input": "Write a function to print check if the triangle is equilateral or not.", + "Output Program": [ + "def check_equilateral(x,y,z):\r\n if x == y == z:\r\n\t return True\r\n else:\r\n return False" + ], + "Output Answer": [ + "def check_equilateral(x,y,z):\r\n if x == y == z:\r\n\t return True\r\n else:\r\n return False" + ], + "split": "test" + }, + { + "Input": "Write a function to caluclate area of a parallelogram.", + "Output Program": [ + "def parallelogram_area(b,h):\r\n area=b*h\r\n return area" + ], + "Output Answer": [ + "def parallelogram_area(b,h):\r\n area=b*h\r\n return area" + ], + "split": "test" + }, + { + "Input": "Write a python function to check whether the first and last characters of a given string are equal or not.", + "Output Program": [ + "def check_Equality(str):\r\n if (str[0] == str[-1]): \r\n return (\"Equal\") \r\n else: \r\n return (\"Not Equal\") " + ], + "Output Answer": [ + "def check_Equality(str):\r\n if (str[0] == str[-1]): \r\n return (\"Equal\") \r\n else: \r\n return (\"Not Equal\") " + ], + "split": "test" + }, + { + "Input": "Write a function to sort the given array by using counting sort.", + "Output Program": [ + "def counting_sort(my_list):\r\n max_value = 0\r\n for i in range(len(my_list)):\r\n if my_list[i] > max_value:\r\n max_value = my_list[i]\r\n buckets = [0] * (max_value + 1)\r\n for i in my_list:\r\n buckets[i] += 1\r\n i = 0\r\n for j in range(max_value + 1):\r\n for a in range(buckets[j]):\r\n my_list[i] = j\r\n i += 1\r\n return my_list" + ], + "Output Answer": [ + "def counting_sort(my_list):\r\n max_value = 0\r\n for i in range(len(my_list)):\r\n if my_list[i] > max_value:\r\n max_value = my_list[i]\r\n buckets = [0] * (max_value + 1)\r\n for i in my_list:\r\n buckets[i] += 1\r\n i = 0\r\n for j in range(max_value + 1):\r\n for a in range(buckets[j]):\r\n my_list[i] = j\r\n i += 1\r\n return my_list" + ], + "split": "test" + }, + { + "Input": "Write a function to find t-nth term of geometric series.", + "Output Program": [ + "import math\r\ndef tn_gp(a,n,r):\r\n tn = a * (math.pow(r, n - 1))\r\n return tn" + ], + "Output Answer": [ + "import math\r\ndef tn_gp(a,n,r):\r\n tn = a * (math.pow(r, n - 1))\r\n return tn" + ], + "split": "test" + }, + { + "Input": "Write a python function to check if a given number is one less than twice its reverse.", + "Output Program": [ + "def rev(num): \r\n rev_num = 0\r\n while (num > 0): \r\n rev_num = (rev_num * 10 + num % 10) \r\n num = num // 10 \r\n return rev_num \r\ndef check(n): \r\n return (2 * rev(n) == n + 1) " + ], + "Output Answer": [ + "def rev(num): \r\n rev_num = 0\r\n while (num > 0): \r\n rev_num = (rev_num * 10 + num % 10) \r\n num = num // 10 \r\n return rev_num \r\ndef check(n): \r\n return (2 * rev(n) == n + 1) " + ], + "split": "test" + }, + { + "Input": "Write a python function to find the largest number that can be formed with the given digits.", + "Output Program": [ + "def find_Max_Num(arr,n) : \r\n arr.sort(reverse = True) \r\n num = arr[0] \r\n for i in range(1,n) : \r\n num = num * 10 + arr[i] \r\n return num " + ], + "Output Answer": [ + "def find_Max_Num(arr,n) : \r\n arr.sort(reverse = True) \r\n num = arr[0] \r\n for i in range(1,n) : \r\n num = num * 10 + arr[i] \r\n return num " + ], + "split": "test" + }, + { + "Input": "Write a python function to check whether the given two integers have opposite sign or not.", + "Output Program": [ + "def opposite_Signs(x,y): \r\n return ((x ^ y) < 0); " + ], + "Output Answer": [ + "def opposite_Signs(x,y): \r\n return ((x ^ y) < 0); " + ], + "split": "test" + }, + { + "Input": "Write a function to find the nth octagonal number.", + "Output Program": [ + "def is_octagonal(n): \r\n\treturn 3 * n * n - 2 * n " + ], + "Output Answer": [ + "def is_octagonal(n): \r\n\treturn 3 * n * n - 2 * n " + ], + "split": "test" + }, + { + "Input": "Write a function to find the maximum length of the subsequence with difference between adjacent elements for the given array.", + "Output Program": [ + "def max_len_sub( arr, n): \r\n\tmls=[] \r\n\tmax = 0\r\n\tfor i in range(n): \r\n\t\tmls.append(1) \r\n\tfor i in range(n): \r\n\t\tfor j in range(i): \r\n\t\t\tif (abs(arr[i] - arr[j]) <= 1 and mls[i] < mls[j] + 1): \r\n\t\t\t\tmls[i] = mls[j] + 1\r\n\tfor i in range(n): \r\n\t\tif (max < mls[i]): \r\n\t\t\tmax = mls[i] \r\n\treturn max" + ], + "Output Answer": [ + "def max_len_sub( arr, n): \r\n\tmls=[] \r\n\tmax = 0\r\n\tfor i in range(n): \r\n\t\tmls.append(1) \r\n\tfor i in range(n): \r\n\t\tfor j in range(i): \r\n\t\t\tif (abs(arr[i] - arr[j]) <= 1 and mls[i] < mls[j] + 1): \r\n\t\t\t\tmls[i] = mls[j] + 1\r\n\tfor i in range(n): \r\n\t\tif (max < mls[i]): \r\n\t\t\tmax = mls[i] \r\n\treturn max" + ], + "split": "test" + }, + { + "Input": "Write a python function to count number of substrings with the sum of digits equal to their length.", + "Output Program": [ + "from collections import defaultdict\r\ndef count_Substrings(s,n):\r\n count,sum = 0,0\r\n mp = defaultdict(lambda : 0)\r\n mp[0] += 1\r\n for i in range(n):\r\n sum += ord(s[i]) - ord('0')\r\n count += mp[sum - (i + 1)]\r\n mp[sum - (i + 1)] += 1\r\n return count" + ], + "Output Answer": [ + "from collections import defaultdict\r\ndef count_Substrings(s,n):\r\n count,sum = 0,0\r\n mp = defaultdict(lambda : 0)\r\n mp[0] += 1\r\n for i in range(n):\r\n sum += ord(s[i]) - ord('0')\r\n count += mp[sum - (i + 1)]\r\n mp[sum - (i + 1)] += 1\r\n return count" + ], + "split": "test" + }, + { + "Input": "Write a python function to find smallest number in a list.", + "Output Program": [ + "def smallest_num(xs):\n return min(xs)\n" + ], + "Output Answer": [ + "def smallest_num(xs):\n return min(xs)\n" + ], + "split": "test" + }, + { + "Input": "Write a function to find the maximum difference between available pairs in the given tuple list.", + "Output Program": [ + "def max_difference(test_list):\r\n temp = [abs(b - a) for a, b in test_list]\r\n res = max(temp)\r\n return (res) " + ], + "Output Answer": [ + "def max_difference(test_list):\r\n temp = [abs(b - a) for a, b in test_list]\r\n res = max(temp)\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a function to sort a list of tuples using lambda.", + "Output Program": [ + "def subject_marks(subjectmarks):\r\n#subject_marks = [('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)])\r\n subjectmarks.sort(key = lambda x: x[1])\r\n return subjectmarks" + ], + "Output Answer": [ + "def subject_marks(subjectmarks):\r\n#subject_marks = [('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)])\r\n subjectmarks.sort(key = lambda x: x[1])\r\n return subjectmarks" + ], + "split": "test" + }, + { + "Input": "Write a function of recursion list sum.", + "Output Program": [ + "def recursive_list_sum(data_list):\r\n\ttotal = 0\r\n\tfor element in data_list:\r\n\t\tif type(element) == type([]):\r\n\t\t\ttotal = total + recursive_list_sum(element)\r\n\t\telse:\r\n\t\t\ttotal = total + element\r\n\treturn total" + ], + "Output Answer": [ + "def recursive_list_sum(data_list):\r\n\ttotal = 0\r\n\tfor element in data_list:\r\n\t\tif type(element) == type([]):\r\n\t\t\ttotal = total + recursive_list_sum(element)\r\n\t\telse:\r\n\t\t\ttotal = total + element\r\n\treturn total" + ], + "split": "test" + }, + { + "Input": "Write a python function to count positive numbers in a list.", + "Output Program": [ + "def pos_count(list):\r\n pos_count= 0\r\n for num in list: \r\n if num >= 0: \r\n pos_count += 1\r\n return pos_count " + ], + "Output Answer": [ + "def pos_count(list):\r\n pos_count= 0\r\n for num in list: \r\n if num >= 0: \r\n pos_count += 1\r\n return pos_count " + ], + "split": "test" + }, + { + "Input": "Write a function to find the number of ways to partition a set of bell numbers.", + "Output Program": [ + "def bell_number(n): \r\n bell = [[0 for i in range(n+1)] for j in range(n+1)] \r\n bell[0][0] = 1\r\n for i in range(1, n+1): \r\n bell[i][0] = bell[i-1][i-1] \r\n for j in range(1, i+1): \r\n bell[i][j] = bell[i-1][j-1] + bell[i][j-1] \r\n return bell[n][0] " + ], + "Output Answer": [ + "def bell_number(n): \r\n bell = [[0 for i in range(n+1)] for j in range(n+1)] \r\n bell[0][0] = 1\r\n for i in range(1, n+1): \r\n bell[i][0] = bell[i-1][i-1] \r\n for j in range(1, i+1): \r\n bell[i][j] = bell[i-1][j-1] + bell[i][j-1] \r\n return bell[n][0] " + ], + "split": "test" + }, + { + "Input": "Write a python function to check whether the given array is monotonic or not.", + "Output Program": [ + "def is_Monotonic(A): \r\n return (all(A[i] <= A[i + 1] for i in range(len(A) - 1)) or\r\n all(A[i] >= A[i + 1] for i in range(len(A) - 1))) " + ], + "Output Answer": [ + "def is_Monotonic(A): \r\n return (all(A[i] <= A[i + 1] for i in range(len(A) - 1)) or\r\n all(A[i] >= A[i + 1] for i in range(len(A) - 1))) " + ], + "split": "test" + }, + { + "Input": "Write a function to check whether a list contains the given sublist or not.", + "Output Program": [ + "def is_sublist(l, s):\r\n\tsub_set = False\r\n\tif s == []:\r\n\t\tsub_set = True\r\n\telif s == l:\r\n\t\tsub_set = True\r\n\telif len(s) > len(l):\r\n\t\tsub_set = False\r\n\telse:\r\n\t\tfor i in range(len(l)):\r\n\t\t\tif l[i] == s[0]:\r\n\t\t\t\tn = 1\r\n\t\t\t\twhile (n < len(s)) and (l[i+n] == s[n]):\r\n\t\t\t\t\tn += 1\t\t\t\t\r\n\t\t\t\tif n == len(s):\r\n\t\t\t\t\tsub_set = True\r\n\treturn sub_set" + ], + "Output Answer": [ + "def is_sublist(l, s):\r\n\tsub_set = False\r\n\tif s == []:\r\n\t\tsub_set = True\r\n\telif s == l:\r\n\t\tsub_set = True\r\n\telif len(s) > len(l):\r\n\t\tsub_set = False\r\n\telse:\r\n\t\tfor i in range(len(l)):\r\n\t\t\tif l[i] == s[0]:\r\n\t\t\t\tn = 1\r\n\t\t\t\twhile (n < len(s)) and (l[i+n] == s[n]):\r\n\t\t\t\t\tn += 1\t\t\t\t\r\n\t\t\t\tif n == len(s):\r\n\t\t\t\t\tsub_set = True\r\n\treturn sub_set" + ], + "split": "test" + }, + { + "Input": "Write a function to find whether all the given tuples have equal length or not.", + "Output Program": [ + "def find_equal_tuple(Input, k):\r\n flag = 1\r\n for tuple in Input:\r\n if len(tuple) != k:\r\n flag = 0\r\n break\r\n return flag\r\ndef get_equal(Input, k):\r\n if find_equal_tuple(Input, k) == 1:\r\n return (\"All tuples have same length\")\r\n else:\r\n return (\"All tuples do not have same length\")" + ], + "Output Answer": [ + "def find_equal_tuple(Input, k):\r\n flag = 1\r\n for tuple in Input:\r\n if len(tuple) != k:\r\n flag = 0\r\n break\r\n return flag\r\ndef get_equal(Input, k):\r\n if find_equal_tuple(Input, k) == 1:\r\n return (\"All tuples have same length\")\r\n else:\r\n return (\"All tuples do not have same length\")" + ], + "split": "test" + }, + { + "Input": "Write a function to sort a list of elements using comb sort.", + "Output Program": [ + "def comb_sort(nums):\r\n shrink_fact = 1.3\r\n gaps = len(nums)\r\n swapped = True\r\n i = 0\r\n while gaps > 1 or swapped:\r\n gaps = int(float(gaps) / shrink_fact)\r\n swapped = False\r\n i = 0\r\n while gaps + i < len(nums):\r\n if nums[i] > nums[i+gaps]:\r\n nums[i], nums[i+gaps] = nums[i+gaps], nums[i]\r\n swapped = True\r\n i += 1\r\n return nums" + ], + "Output Answer": [ + "def comb_sort(nums):\r\n shrink_fact = 1.3\r\n gaps = len(nums)\r\n swapped = True\r\n i = 0\r\n while gaps > 1 or swapped:\r\n gaps = int(float(gaps) / shrink_fact)\r\n swapped = False\r\n i = 0\r\n while gaps + i < len(nums):\r\n if nums[i] > nums[i+gaps]:\r\n nums[i], nums[i+gaps] = nums[i+gaps], nums[i]\r\n swapped = True\r\n i += 1\r\n return nums" + ], + "split": "test" + }, + { + "Input": "Write a python function to check whether the given number can be represented as difference of two squares or not.", + "Output Program": [ + "def dif_Square(n): \r\n if (n % 4 != 2): \r\n return True\r\n return False" + ], + "Output Answer": [ + "def dif_Square(n): \r\n if (n % 4 != 2): \r\n return True\r\n return False" + ], + "split": "test" + }, + { + "Input": "Write a function to split the given string with multiple delimiters by using regex.", + "Output Program": [ + "import re\r\ndef multiple_split(text):\r\n return (re.split('; |, |\\*|\\n',text))" + ], + "Output Answer": [ + "import re\r\ndef multiple_split(text):\r\n return (re.split('; |, |\\*|\\n',text))" + ], + "split": "test" + }, + { + "Input": "Write a function to check whether it follows the sequence given in the patterns array.", + "Output Program": [ + "def is_samepatterns(colors, patterns): \r\n if len(colors) != len(patterns):\r\n return False \r\n sdict = {}\r\n pset = set()\r\n sset = set() \r\n for i in range(len(patterns)):\r\n pset.add(patterns[i])\r\n sset.add(colors[i])\r\n if patterns[i] not in sdict.keys():\r\n sdict[patterns[i]] = []\r\n\r\n keys = sdict[patterns[i]]\r\n keys.append(colors[i])\r\n sdict[patterns[i]] = keys\r\n\r\n if len(pset) != len(sset):\r\n return False \r\n\r\n for values in sdict.values():\r\n\r\n for i in range(len(values) - 1):\r\n if values[i] != values[i+1]:\r\n return False\r\n\r\n return True" + ], + "Output Answer": [ + "def is_samepatterns(colors, patterns): \r\n if len(colors) != len(patterns):\r\n return False \r\n sdict = {}\r\n pset = set()\r\n sset = set() \r\n for i in range(len(patterns)):\r\n pset.add(patterns[i])\r\n sset.add(colors[i])\r\n if patterns[i] not in sdict.keys():\r\n sdict[patterns[i]] = []\r\n\r\n keys = sdict[patterns[i]]\r\n keys.append(colors[i])\r\n sdict[patterns[i]] = keys\r\n\r\n if len(pset) != len(sset):\r\n return False \r\n\r\n for values in sdict.values():\r\n\r\n for i in range(len(values) - 1):\r\n if values[i] != values[i+1]:\r\n return False\r\n\r\n return True" + ], + "split": "test" + }, + { + "Input": "Write a function to find tuples which have all elements divisible by k from the given list of tuples.", + "Output Program": [ + "def find_tuples(test_list, K):\r\n res = [sub for sub in test_list if all(ele % K == 0 for ele in sub)]\r\n return (str(res)) " + ], + "Output Answer": [ + "def find_tuples(test_list, K):\r\n res = [sub for sub in test_list if all(ele % K == 0 for ele in sub)]\r\n return (str(res)) " + ], + "split": "test" + }, + { + "Input": "Write a python function to count the number of squares in a rectangle.", + "Output Program": [ + "def count_Squares(m,n):\r\n if(n < m):\r\n temp = m\r\n m = n\r\n n = temp\r\n return ((m * (m + 1) * (2 * m + 1) / 6 + (n - m) * m * (m + 1) / 2))", + "def count_Squares(m,n): \r\n if (n < m): \r\n temp = m \r\n m = n \r\n n = temp \r\n return n * (n + 1) * (3 * m - n + 1) // 6" + ], + "Output Answer": [ + "def count_Squares(m,n):\r\n if(n < m):\r\n temp = m\r\n m = n\r\n n = temp\r\n return ((m * (m + 1) * (2 * m + 1) / 6 + (n - m) * m * (m + 1) / 2))", + "def count_Squares(m,n): \r\n if (n < m): \r\n temp = m \r\n m = n \r\n n = temp \r\n return n * (n + 1) * (3 * m - n + 1) // 6" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the difference between sum of even and odd digits.", + "Output Program": [ + "def is_Diff(n): \r\n return (n % 11 == 0) " + ], + "Output Answer": [ + "def is_Diff(n): \r\n return (n % 11 == 0) " + ], + "split": "test" + }, + { + "Input": "Write a python function to find number of integers with odd number of set bits.", + "Output Program": [ + "def count_With_Odd_SetBits(n): \r\n if (n % 2 != 0): \r\n return (n + 1) / 2\r\n count = bin(n).count('1') \r\n ans = n / 2\r\n if (count % 2 != 0): \r\n ans += 1\r\n return ans " + ], + "Output Answer": [ + "def count_With_Odd_SetBits(n): \r\n if (n % 2 != 0): \r\n return (n + 1) / 2\r\n count = bin(n).count('1') \r\n ans = n / 2\r\n if (count % 2 != 0): \r\n ans += 1\r\n return ans " + ], + "split": "test" + }, + { + "Input": "Write a python function to check whether the length of the word is odd or not.", + "Output Program": [ + "def word_len(s): \r\n s = s.split(' ') \r\n for word in s: \r\n if len(word)%2!=0: \r\n return True \r\n else:\r\n return False" + ], + "Output Answer": [ + "def word_len(s): \r\n s = s.split(' ') \r\n for word in s: \r\n if len(word)%2!=0: \r\n return True \r\n else:\r\n return False" + ], + "split": "test" + }, + { + "Input": "Write a function to find the nth tetrahedral number.", + "Output Program": [ + "def tetrahedral_number(n): \r\n\treturn (n * (n + 1) * (n + 2)) / 6" + ], + "Output Answer": [ + "def tetrahedral_number(n): \r\n\treturn (n * (n + 1) * (n + 2)) / 6" + ], + "split": "test" + }, + { + "Input": "Write a function to zip the two given tuples.", + "Output Program": [ + "def zip_tuples(test_tup1, test_tup2):\r\n res = []\r\n for i, j in enumerate(test_tup1):\r\n res.append((j, test_tup2[i % len(test_tup2)])) \r\n return (res) " + ], + "Output Answer": [ + "def zip_tuples(test_tup1, test_tup2):\r\n res = []\r\n for i, j in enumerate(test_tup1):\r\n res.append((j, test_tup2[i % len(test_tup2)])) \r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a function to find the volume of a sphere.", + "Output Program": [ + "import math\r\ndef volume_sphere(r):\r\n volume=(4/3)*math.pi*r*r*r\r\n return volume" + ], + "Output Answer": [ + "import math\r\ndef volume_sphere(r):\r\n volume=(4/3)*math.pi*r*r*r\r\n return volume" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the character made by adding all the characters of the given string.", + "Output Program": [ + "def get_Char(strr): \r\n summ = 0\r\n for i in range(len(strr)): \r\n summ += (ord(strr[i]) - ord('a') + 1) \r\n if (summ % 26 == 0): \r\n return ord('z') \r\n else: \r\n summ = summ % 26\r\n return chr(ord('a') + summ - 1)" + ], + "Output Answer": [ + "def get_Char(strr): \r\n summ = 0\r\n for i in range(len(strr)): \r\n summ += (ord(strr[i]) - ord('a') + 1) \r\n if (summ % 26 == 0): \r\n return ord('z') \r\n else: \r\n summ = summ % 26\r\n return chr(ord('a') + summ - 1)" + ], + "split": "test" + }, + { + "Input": "Write a function to find the n-th number in newman conway sequence.", + "Output Program": [ + "def sequence(n): \r\n\tif n == 1 or n == 2: \r\n\t\treturn 1\r\n\telse: \r\n\t\treturn sequence(sequence(n-1)) + sequence(n-sequence(n-1))" + ], + "Output Answer": [ + "def sequence(n): \r\n\tif n == 1 or n == 2: \r\n\t\treturn 1\r\n\telse: \r\n\t\treturn sequence(sequence(n-1)) + sequence(n-sequence(n-1))" + ], + "split": "test" + }, + { + "Input": "Write a function to find the surface area of a sphere.", + "Output Program": [ + "import math\r\ndef surfacearea_sphere(r):\r\n surfacearea=4*math.pi*r*r\r\n return surfacearea" + ], + "Output Answer": [ + "import math\r\ndef surfacearea_sphere(r):\r\n surfacearea=4*math.pi*r*r\r\n return surfacearea" + ], + "split": "test" + }, + { + "Input": "Write a function to find nth centered hexagonal number.", + "Output Program": [ + "def centered_hexagonal_number(n):\r\n return 3 * n * (n - 1) + 1" + ], + "Output Answer": [ + "def centered_hexagonal_number(n):\r\n return 3 * n * (n - 1) + 1" + ], + "split": "test" + }, + { + "Input": "Write a function to merge three dictionaries into a single expression.", + "Output Program": [ + "import collections as ct\r\ndef merge_dictionaries_three(dict1,dict2, dict3):\r\n merged_dict = dict(ct.ChainMap({},dict1,dict2,dict3))\r\n return merged_dict" + ], + "Output Answer": [ + "import collections as ct\r\ndef merge_dictionaries_three(dict1,dict2, dict3):\r\n merged_dict = dict(ct.ChainMap({},dict1,dict2,dict3))\r\n return merged_dict" + ], + "split": "test" + }, + { + "Input": "Write a function to get the frequency of the elements in a list.", + "Output Program": [ + "import collections\r\ndef freq_count(list1):\r\n freq_count= collections.Counter(list1)\r\n return freq_count" + ], + "Output Answer": [ + "import collections\r\ndef freq_count(list1):\r\n freq_count= collections.Counter(list1)\r\n return freq_count" + ], + "split": "test" + }, + { + "Input": "Write a function to find the closest smaller number than n.", + "Output Program": [ + "def closest_num(N):\r\n return (N - 1)" + ], + "Output Answer": [ + "def closest_num(N):\r\n return (N - 1)" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the length of the longest word.", + "Output Program": [ + "def len_log(list1):\r\n max=len(list1[0])\r\n for i in list1:\r\n if len(i)>max:\r\n max=len(i)\r\n return max" + ], + "Output Answer": [ + "def len_log(list1):\r\n max=len(list1[0])\r\n for i in list1:\r\n if len(i)>max:\r\n max=len(i)\r\n return max" + ], + "split": "test" + }, + { + "Input": "Write a function to check if a substring is present in a given list of string values.", + "Output Program": [ + "def find_substring(str1, sub_str):\r\n if any(sub_str in s for s in str1):\r\n return True\r\n return False" + ], + "Output Answer": [ + "def find_substring(str1, sub_str):\r\n if any(sub_str in s for s in str1):\r\n return True\r\n return False" + ], + "split": "test" + }, + { + "Input": "Write a function to check whether the given number is undulating or not.", + "Output Program": [ + "def is_undulating(n): \r\n\tif (len(n) <= 2): \r\n\t\treturn False\r\n\tfor i in range(2, len(n)): \r\n\t\tif (n[i - 2] != n[i]): \r\n\t\t\treturn False\r\n\treturn True" + ], + "Output Answer": [ + "def is_undulating(n): \r\n\tif (len(n) <= 2): \r\n\t\treturn False\r\n\tfor i in range(2, len(n)): \r\n\t\tif (n[i - 2] != n[i]): \r\n\t\t\treturn False\r\n\treturn True" + ], + "split": "test" + }, + { + "Input": "Write a function to calculate the value of 'a' to the power 'b'.", + "Output Program": [ + "def power(a,b):\r\n\tif b==0:\r\n\t\treturn 1\r\n\telif a==0:\r\n\t\treturn 0\r\n\telif b==1:\r\n\t\treturn a\r\n\telse:\r\n\t\treturn a*power(a,b-1)" + ], + "Output Answer": [ + "def power(a,b):\r\n\tif b==0:\r\n\t\treturn 1\r\n\telif a==0:\r\n\t\treturn 0\r\n\telif b==1:\r\n\t\treturn a\r\n\telse:\r\n\t\treturn a*power(a,b-1)" + ], + "split": "test" + }, + { + "Input": "Write a function to extract the index minimum value record from the given tuples.", + "Output Program": [ + "from operator import itemgetter \r\ndef index_minimum(test_list):\r\n res = min(test_list, key = itemgetter(1))[0]\r\n return (res) " + ], + "Output Answer": [ + "from operator import itemgetter \r\ndef index_minimum(test_list):\r\n res = min(test_list, key = itemgetter(1))[0]\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a python function to find the minimum length of sublist.", + "Output Program": [ + "def Find_Min_Length(lst): \r\n minLength = min(len(x) for x in lst )\r\n return minLength " + ], + "Output Answer": [ + "def Find_Min_Length(lst): \r\n minLength = min(len(x) for x in lst )\r\n return minLength " + ], + "split": "test" + }, + { + "Input": "Write a python function to find the number of divisors of a given integer.", + "Output Program": [ + "def divisor(n):\r\n for i in range(n):\r\n x = len([i for i in range(1,n+1) if not n % i])\r\n return x" + ], + "Output Answer": [ + "def divisor(n):\r\n for i in range(n):\r\n x = len([i for i in range(1,n+1) if not n % i])\r\n return x" + ], + "split": "test" + }, + { + "Input": "Write a function to find frequency count of list of lists.", + "Output Program": [ + "def frequency_lists(list1):\r\n list1 = [item for sublist in list1 for item in sublist]\r\n dic_data = {}\r\n for num in list1:\r\n if num in dic_data.keys():\r\n dic_data[num] += 1\r\n else:\r\n key = num\r\n value = 1\r\n dic_data[key] = value\r\n return dic_data\r\n" + ], + "Output Answer": [ + "def frequency_lists(list1):\r\n list1 = [item for sublist in list1 for item in sublist]\r\n dic_data = {}\r\n for num in list1:\r\n if num in dic_data.keys():\r\n dic_data[num] += 1\r\n else:\r\n key = num\r\n value = 1\r\n dic_data[key] = value\r\n return dic_data\r\n" + ], + "split": "test" + }, + { + "Input": "Write a function to multiply all the numbers in a list and divide with the length of the list.", + "Output Program": [ + "def multiply_num(numbers): \r\n total = 1\r\n for x in numbers:\r\n total *= x \r\n return total/len(numbers) " + ], + "Output Answer": [ + "def multiply_num(numbers): \r\n total = 1\r\n for x in numbers:\r\n total *= x \r\n return total/len(numbers) " + ], + "split": "test" + }, + { + "Input": "Write a function to convert the given decimal number to its binary equivalent.", + "Output Program": [ + "def decimal_to_binary(n): \r\n return bin(n).replace(\"0b\",\"\") " + ], + "Output Answer": [ + "def decimal_to_binary(n): \r\n return bin(n).replace(\"0b\",\"\") " + ], + "split": "test" + }, + { + "Input": "Write a function to find the next smallest palindrome of a specified number.", + "Output Program": [ + "import sys\r\ndef next_smallest_palindrome(num):\r\n numstr = str(num)\r\n for i in range(num+1,sys.maxsize):\r\n if str(i) == str(i)[::-1]:\r\n return i" + ], + "Output Answer": [ + "import sys\r\ndef next_smallest_palindrome(num):\r\n numstr = str(num)\r\n for i in range(num+1,sys.maxsize):\r\n if str(i) == str(i)[::-1]:\r\n return i" + ], + "split": "test" + }, + { + "Input": "Write a function to find the kth element in the given array.", + "Output Program": [ + "def kth_element(arr, n, k):\r\n for i in range(n):\r\n for j in range(0, n-i-1):\r\n if arr[j] > arr[j+1]:\r\n arr[j], arr[j+1] == arr[j+1], arr[j]\r\n return arr[k-1]" + ], + "Output Answer": [ + "def kth_element(arr, n, k):\r\n for i in range(n):\r\n for j in range(0, n-i-1):\r\n if arr[j] > arr[j+1]:\r\n arr[j], arr[j+1] == arr[j+1], arr[j]\r\n return arr[k-1]" + ], + "split": "test" + }, + { + "Input": "Write a function to convert snake case string to camel case string.", + "Output Program": [ + "def snake_to_camel(word):\r\n import re\r\n return ''.join(x.capitalize() or '_' for x in word.split('_'))" + ], + "Output Answer": [ + "def snake_to_camel(word):\r\n import re\r\n return ''.join(x.capitalize() or '_' for x in word.split('_'))" + ], + "split": "test" + }, + { + "Input": "Write a function to find eulerian number a(n, m).", + "Output Program": [ + "def eulerian_num(n, m): \r\n\tif (m >= n or n == 0): \r\n\t\treturn 0 \r\n\tif (m == 0): \r\n\t\treturn 1 \r\n\treturn ((n - m) * eulerian_num(n - 1, m - 1) +(m + 1) * eulerian_num(n - 1, m))" + ], + "Output Answer": [ + "def eulerian_num(n, m): \r\n\tif (m >= n or n == 0): \r\n\t\treturn 0 \r\n\tif (m == 0): \r\n\t\treturn 1 \r\n\treturn ((n - m) * eulerian_num(n - 1, m - 1) +(m + 1) * eulerian_num(n - 1, m))" + ], + "split": "test" + }, + { + "Input": "Write a function to sort each sublist of strings in a given list of lists using lambda function.", + "Output Program": [ + "def sort_sublists(input_list):\r\n result = [sorted(x, key = lambda x:x[0]) for x in input_list] \r\n return result\r" + ], + "Output Answer": [ + "def sort_sublists(input_list):\r\n result = [sorted(x, key = lambda x:x[0]) for x in input_list] \r\n return result\r" + ], + "split": "test" + }, + { + "Input": "Write a python function to count true booleans in the given list.", + "Output Program": [ + "def count(lst): \r\n return sum(lst) " + ], + "Output Answer": [ + "def count(lst): \r\n return sum(lst) " + ], + "split": "test" + }, + { + "Input": "Write a function to add the given list to the given tuples.", + "Output Program": [ + "def add_lists(test_list, test_tup):\r\n res = tuple(list(test_tup) + test_list)\r\n return (res) " + ], + "Output Answer": [ + "def add_lists(test_list, test_tup):\r\n res = tuple(list(test_tup) + test_list)\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a python function to count hexadecimal numbers for a given range.", + "Output Program": [ + "def count_Hexadecimal(L,R) : \r\n count = 0; \r\n for i in range(L,R + 1) : \r\n if (i >= 10 and i <= 15) : \r\n count += 1; \r\n elif (i > 15) : \r\n k = i; \r\n while (k != 0) : \r\n if (k % 16 >= 10) : \r\n count += 1; \r\n k = k // 16; \r\n return count; " + ], + "Output Answer": [ + "def count_Hexadecimal(L,R) : \r\n count = 0; \r\n for i in range(L,R + 1) : \r\n if (i >= 10 and i <= 15) : \r\n count += 1; \r\n elif (i > 15) : \r\n k = i; \r\n while (k != 0) : \r\n if (k % 16 >= 10) : \r\n count += 1; \r\n k = k // 16; \r\n return count; " + ], + "split": "test" + }, + { + "Input": "Write a function to merge multiple sorted inputs into a single sorted iterator using heap queue algorithm.", + "Output Program": [ + "import heapq\r\ndef merge_sorted_list(num1,num2,num3):\r\n num1=sorted(num1)\r\n num2=sorted(num2)\r\n num3=sorted(num3)\r\n result = heapq.merge(num1,num2,num3)\r\n return list(result)" + ], + "Output Answer": [ + "import heapq\r\ndef merge_sorted_list(num1,num2,num3):\r\n num1=sorted(num1)\r\n num2=sorted(num2)\r\n num3=sorted(num3)\r\n result = heapq.merge(num1,num2,num3)\r\n return list(result)" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the count of rotations of a binary string with odd value.", + "Output Program": [ + "def odd_Equivalent(s,n): \r\n count=0\r\n for i in range(0,n): \r\n if (s[i] == '1'): \r\n count = count + 1\r\n return count " + ], + "Output Answer": [ + "def odd_Equivalent(s,n): \r\n count=0\r\n for i in range(0,n): \r\n if (s[i] == '1'): \r\n count = count + 1\r\n return count " + ], + "split": "test" + }, + { + "Input": "Write a function to extract the ranges that are missing from the given list with the given start range and end range values.", + "Output Program": [ + "def extract_missing(test_list, strt_val, stop_val):\r\n res = []\r\n for sub in test_list:\r\n if sub[0] > strt_val:\r\n res.append((strt_val, sub[0]))\r\n strt_val = sub[1]\r\n if strt_val < stop_val:\r\n res.append((strt_val, stop_val))\r\n return (res) " + ], + "Output Answer": [ + "def extract_missing(test_list, strt_val, stop_val):\r\n res = []\r\n for sub in test_list:\r\n if sub[0] > strt_val:\r\n res.append((strt_val, sub[0]))\r\n strt_val = sub[1]\r\n if strt_val < stop_val:\r\n res.append((strt_val, stop_val))\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a function to find common elements in given nested lists. * list item * list item * list item * list item", + "Output Program": [ + "def common_in_nested_lists(nestedlist):\r\n result = list(set.intersection(*map(set, nestedlist)))\r\n return result" + ], + "Output Answer": [ + "def common_in_nested_lists(nestedlist):\r\n result = list(set.intersection(*map(set, nestedlist)))\r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the perimeter of a cylinder.", + "Output Program": [ + "def perimeter(diameter,height) : \r\n return 2*(diameter+height) " + ], + "Output Answer": [ + "def perimeter(diameter,height) : \r\n return 2*(diameter+height) " + ], + "split": "test" + }, + { + "Input": "Write a function to check if a string represents an integer or not.", + "Output Program": [ + "def check_integer(text):\r\n text = text.strip()\r\n if len(text) < 1:\r\n return None\r\n else:\r\n if all(text[i] in \"0123456789\" for i in range(len(text))):\r\n return True\r\n elif (text[0] in \"+-\") and \\\r\n all(text[i] in \"0123456789\" for i in range(1,len(text))):\r\n return True\r\n else:\r\n return False" + ], + "Output Answer": [ + "def check_integer(text):\r\n text = text.strip()\r\n if len(text) < 1:\r\n return None\r\n else:\r\n if all(text[i] in \"0123456789\" for i in range(len(text))):\r\n return True\r\n elif (text[0] in \"+-\") and \\\r\n all(text[i] in \"0123456789\" for i in range(1,len(text))):\r\n return True\r\n else:\r\n return False" + ], + "split": "test" + }, + { + "Input": "Write a function to assign frequency to each tuple in the given tuple list.", + "Output Program": [ + "from collections import Counter \r\ndef assign_freq(test_list):\r\n res = [(*key, val) for key, val in Counter(test_list).items()]\r\n return (str(res)) " + ], + "Output Answer": [ + "from collections import Counter \r\ndef assign_freq(test_list):\r\n res = [(*key, val) for key, val in Counter(test_list).items()]\r\n return (str(res)) " + ], + "split": "test" + }, + { + "Input": "Write a function to check whether all dictionaries in a list are empty or not.", + "Output Program": [ + "def empty_dit(list1):\r\n empty_dit=all(not d for d in list1)\r\n return empty_dit" + ], + "Output Answer": [ + "def empty_dit(list1):\r\n empty_dit=all(not d for d in list1)\r\n return empty_dit" + ], + "split": "test" + }, + { + "Input": "Write a function to convert a given tuple of positive integers into an integer.", + "Output Program": [ + "def tuple_to_int(nums):\r\n result = int(''.join(map(str,nums)))\r\n return result" + ], + "Output Answer": [ + "def tuple_to_int(nums):\r\n result = int(''.join(map(str,nums)))\r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a function to convert all possible convertible elements in the list to float.", + "Output Program": [ + "def list_to_float(test_list):\r\n res = []\r\n for tup in test_list:\r\n temp = []\r\n for ele in tup:\r\n if ele.isalpha():\r\n temp.append(ele)\r\n else:\r\n temp.append(float(ele))\r\n res.append((temp[0],temp[1])) \r\n return (str(res)) " + ], + "Output Answer": [ + "def list_to_float(test_list):\r\n res = []\r\n for tup in test_list:\r\n temp = []\r\n for ele in tup:\r\n if ele.isalpha():\r\n temp.append(ele)\r\n else:\r\n temp.append(float(ele))\r\n res.append((temp[0],temp[1])) \r\n return (str(res)) " + ], + "split": "test" + }, + { + "Input": "[link text](https:// [link text](https:// [link text](https://)))write a function to convert a string to a list.", + "Output Program": [ + "def string_to_list(string): \r\n lst = list(string.split(\" \")) \r\n return lst" + ], + "Output Answer": [ + "def string_to_list(string): \r\n lst = list(string.split(\" \")) \r\n return lst" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the element that appears only once in a sorted array.", + "Output Program": [ + "def search(arr,n) :\r\n XOR = 0\r\n for i in range(n) :\r\n XOR = XOR ^ arr[i]\r\n return (XOR)" + ], + "Output Answer": [ + "def search(arr,n) :\r\n XOR = 0\r\n for i in range(n) :\r\n XOR = XOR ^ arr[i]\r\n return (XOR)" + ], + "split": "test" + }, + { + "Input": "Write a function to find the maximum product from the pairs of tuples within a given list.", + "Output Program": [ + "def max_product_tuple(list1):\r\n result_max = max([abs(x * y) for x, y in list1] )\r\n return result_max" + ], + "Output Answer": [ + "def max_product_tuple(list1):\r\n result_max = max([abs(x * y) for x, y in list1] )\r\n return result_max" + ], + "split": "test" + }, + { + "Input": "Write a function to find the triplet with sum of the given array", + "Output Program": [ + "def check_triplet(A, n, sum, count):\r\n if count == 3 and sum == 0:\r\n return True\r\n if count == 3 or n == 0 or sum < 0:\r\n return False\r\n return check_triplet(A, n - 1, sum - A[n - 1], count + 1) or\\\r\n check_triplet(A, n - 1, sum, count)" + ], + "Output Answer": [ + "def check_triplet(A, n, sum, count):\r\n if count == 3 and sum == 0:\r\n return True\r\n if count == 3 or n == 0 or sum < 0:\r\n return False\r\n return check_triplet(A, n - 1, sum - A[n - 1], count + 1) or\\\r\n check_triplet(A, n - 1, sum, count)" + ], + "split": "test" + }, + { + "Input": "Write a function to find n\u2019th smart number.", + "Output Program": [ + "MAX = 3000 \r\ndef smartNumber(n): \r\n\tprimes = [0] * MAX \r\n\tresult = [] \r\n\tfor i in range(2, MAX): \r\n\t\tif (primes[i] == 0): \r\n\t\t\tprimes[i] = 1 \r\n\t\t\tj = i * 2 \r\n\t\t\twhile (j < MAX): \r\n\t\t\t\tprimes[j] -= 1 \r\n\t\t\t\tif ( (primes[j] + 3) == 0): \r\n\t\t\t\t\tresult.append(j) \r\n\t\t\t\tj = j + i \r\n\tresult.sort() \r\n\treturn result[n - 1] " + ], + "Output Answer": [ + "MAX = 3000 \r\ndef smartNumber(n): \r\n\tprimes = [0] * MAX \r\n\tresult = [] \r\n\tfor i in range(2, MAX): \r\n\t\tif (primes[i] == 0): \r\n\t\t\tprimes[i] = 1 \r\n\t\t\tj = i * 2 \r\n\t\t\twhile (j < MAX): \r\n\t\t\t\tprimes[j] -= 1 \r\n\t\t\t\tif ( (primes[j] + 3) == 0): \r\n\t\t\t\t\tresult.append(j) \r\n\t\t\t\tj = j + i \r\n\tresult.sort() \r\n\treturn result[n - 1] " + ], + "split": "test" + }, + { + "Input": "Write a function to sum all amicable numbers from 1 to a specified number.", + "Output Program": [ + "def amicable_numbers_sum(limit):\r\n if not isinstance(limit, int):\r\n return \"Input is not an integer!\"\r\n if limit < 1:\r\n return \"Input must be bigger than 0!\"\r\n amicables = set()\r\n for num in range(2, limit+1):\r\n if num in amicables:\r\n continue\r\n sum_fact = sum([fact for fact in range(1, num) if num % fact == 0])\r\n sum_fact2 = sum([fact for fact in range(1, sum_fact) if sum_fact % fact == 0])\r\n if num == sum_fact2 and num != sum_fact:\r\n amicables.add(num)\r\n amicables.add(sum_fact2)\r\n return sum(amicables)" + ], + "Output Answer": [ + "def amicable_numbers_sum(limit):\r\n if not isinstance(limit, int):\r\n return \"Input is not an integer!\"\r\n if limit < 1:\r\n return \"Input must be bigger than 0!\"\r\n amicables = set()\r\n for num in range(2, limit+1):\r\n if num in amicables:\r\n continue\r\n sum_fact = sum([fact for fact in range(1, num) if num % fact == 0])\r\n sum_fact2 = sum([fact for fact in range(1, sum_fact) if sum_fact % fact == 0])\r\n if num == sum_fact2 and num != sum_fact:\r\n amicables.add(num)\r\n amicables.add(sum_fact2)\r\n return sum(amicables)" + ], + "split": "test" + }, + { + "Input": "Write a function to get the angle of a complex number.", + "Output Program": [ + "import cmath\r\ndef angle_complex(a,b):\r\n cn=complex(a,b)\r\n angle=cmath.phase(a+b)\r\n return angle" + ], + "Output Answer": [ + "import cmath\r\ndef angle_complex(a,b):\r\n cn=complex(a,b)\r\n angle=cmath.phase(a+b)\r\n return angle" + ], + "split": "test" + }, + { + "Input": "Write 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.", + "Output Program": [ + "def find_length(string, n): \r\n\tcurrent_sum = 0\r\n\tmax_sum = 0\r\n\tfor i in range(n): \r\n\t\tcurrent_sum += (1 if string[i] == '0' else -1) \r\n\t\tif current_sum < 0: \r\n\t\t\tcurrent_sum = 0\r\n\t\tmax_sum = max(current_sum, max_sum) \r\n\treturn max_sum if max_sum else 0" + ], + "Output Answer": [ + "def find_length(string, n): \r\n\tcurrent_sum = 0\r\n\tmax_sum = 0\r\n\tfor i in range(n): \r\n\t\tcurrent_sum += (1 if string[i] == '0' else -1) \r\n\t\tif current_sum < 0: \r\n\t\t\tcurrent_sum = 0\r\n\t\tmax_sum = max(current_sum, max_sum) \r\n\treturn max_sum if max_sum else 0" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the sum of common divisors of two given numbers.", + "Output Program": [ + "def sum(a,b): \r\n sum = 0\r\n for i in range (1,min(a,b)): \r\n if (a % i == 0 and b % i == 0): \r\n sum += i \r\n return sum" + ], + "Output Answer": [ + "def sum(a,b): \r\n sum = 0\r\n for i in range (1,min(a,b)): \r\n if (a % i == 0 and b % i == 0): \r\n sum += i \r\n return sum" + ], + "split": "test" + }, + { + "Input": "Write a function to multiply two integers without using the * operator in python.", + "Output Program": [ + "def multiply_int(x, y):\r\n if y < 0:\r\n return -multiply_int(x, -y)\r\n elif y == 0:\r\n return 0\r\n elif y == 1:\r\n return x\r\n else:\r\n return x + multiply_int(x, y - 1)" + ], + "Output Answer": [ + "def multiply_int(x, y):\r\n if y < 0:\r\n return -multiply_int(x, -y)\r\n elif y == 0:\r\n return 0\r\n elif y == 1:\r\n return x\r\n else:\r\n return x + multiply_int(x, y - 1)" + ], + "split": "test" + }, + { + "Input": "Write a function to shortlist words that are longer than n from a given list of words.", + "Output Program": [ + "def long_words(n, str):\r\n word_len = []\r\n txt = str.split(\" \")\r\n for x in txt:\r\n if len(x) > n:\r\n word_len.append(x)\r\n return word_len\t" + ], + "Output Answer": [ + "def long_words(n, str):\r\n word_len = []\r\n txt = str.split(\" \")\r\n for x in txt:\r\n if len(x) > n:\r\n word_len.append(x)\r\n return word_len\t" + ], + "split": "test" + }, + { + "Input": "Write a function to calculate magic square.", + "Output Program": [ + "def magic_square_test(my_matrix):\r\n iSize = len(my_matrix[0])\r\n sum_list = []\r\n sum_list.extend([sum (lines) for lines in my_matrix]) \r\n for col in range(iSize):\r\n sum_list.append(sum(row[col] for row in my_matrix))\r\n result1 = 0\r\n for i in range(0,iSize):\r\n result1 +=my_matrix[i][i]\r\n sum_list.append(result1) \r\n result2 = 0\r\n for i in range(iSize-1,-1,-1):\r\n result2 +=my_matrix[i][i]\r\n sum_list.append(result2)\r\n if len(set(sum_list))>1:\r\n return False\r\n return True" + ], + "Output Answer": [ + "def magic_square_test(my_matrix):\r\n iSize = len(my_matrix[0])\r\n sum_list = []\r\n sum_list.extend([sum (lines) for lines in my_matrix]) \r\n for col in range(iSize):\r\n sum_list.append(sum(row[col] for row in my_matrix))\r\n result1 = 0\r\n for i in range(0,iSize):\r\n result1 +=my_matrix[i][i]\r\n sum_list.append(result1) \r\n result2 = 0\r\n for i in range(iSize-1,-1,-1):\r\n result2 +=my_matrix[i][i]\r\n sum_list.append(result2)\r\n if len(set(sum_list))>1:\r\n return False\r\n return True" + ], + "split": "test" + }, + { + "Input": "Write a function to find the item with maximum frequency in a given list.", + "Output Program": [ + "from collections import defaultdict\r\ndef max_occurrences(nums):\r\n dict = defaultdict(int)\r\n for i in nums:\r\n dict[i] += 1\r\n result = max(dict.items(), key=lambda x: x[1]) \r\n return result" + ], + "Output Answer": [ + "from collections import defaultdict\r\ndef max_occurrences(nums):\r\n dict = defaultdict(int)\r\n for i in nums:\r\n dict[i] += 1\r\n result = max(dict.items(), key=lambda x: x[1]) \r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a python function to reverse only the vowels of a given string.", + "Output Program": [ + "def reverse_vowels(str1):\r\n\tvowels = \"\"\r\n\tfor char in str1:\r\n\t\tif char in \"aeiouAEIOU\":\r\n\t\t\tvowels += char\r\n\tresult_string = \"\"\r\n\tfor char in str1:\r\n\t\tif char in \"aeiouAEIOU\":\r\n\t\t\tresult_string += vowels[-1]\r\n\t\t\tvowels = vowels[:-1]\r\n\t\telse:\r\n\t\t\tresult_string += char\r\n\treturn result_string" + ], + "Output Answer": [ + "def reverse_vowels(str1):\r\n\tvowels = \"\"\r\n\tfor char in str1:\r\n\t\tif char in \"aeiouAEIOU\":\r\n\t\t\tvowels += char\r\n\tresult_string = \"\"\r\n\tfor char in str1:\r\n\t\tif char in \"aeiouAEIOU\":\r\n\t\t\tresult_string += vowels[-1]\r\n\t\t\tvowels = vowels[:-1]\r\n\t\telse:\r\n\t\t\tresult_string += char\r\n\treturn result_string" + ], + "split": "test" + }, + { + "Input": "Write a function to convert tuple to a string.", + "Output Program": [ + "def tup_string(tup1):\r\n str = ''.join(tup1)\r\n return str" + ], + "Output Answer": [ + "def tup_string(tup1):\r\n str = ''.join(tup1)\r\n return str" + ], + "split": "test" + }, + { + "Input": "Write a function to calculate the sum of the negative numbers of a given list of numbers using lambda function.", + "Output Program": [ + "def sum_negativenum(nums):\r\n sum_negativenum = list(filter(lambda nums:nums<0,nums))\r\n return sum(sum_negativenum)" + ], + "Output Answer": [ + "def sum_negativenum(nums):\r\n sum_negativenum = list(filter(lambda nums:nums<0,nums))\r\n return sum(sum_negativenum)" + ], + "split": "test" + }, + { + "Input": "Write a python function to check whether the last element of given array is even or odd after performing an operation p times.", + "Output Program": [ + "def check_last (arr,n,p): \r\n _sum = 0\r\n for i in range(n): \r\n _sum = _sum + arr[i] \r\n if p == 1: \r\n if _sum % 2 == 0: \r\n return \"ODD\"\r\n else: \r\n return \"EVEN\"\r\n return \"EVEN\"\r\n " + ], + "Output Answer": [ + "def check_last (arr,n,p): \r\n _sum = 0\r\n for i in range(n): \r\n _sum = _sum + arr[i] \r\n if p == 1: \r\n if _sum % 2 == 0: \r\n return \"ODD\"\r\n else: \r\n return \"EVEN\"\r\n return \"EVEN\"\r\n " + ], + "split": "test" + }, + { + "Input": "Write a function to find the nth hexagonal number.", + "Output Program": [ + "def hexagonal_num(n): \r\n\treturn n*(2*n - 1) " + ], + "Output Answer": [ + "def hexagonal_num(n): \r\n\treturn n*(2*n - 1) " + ], + "split": "test" + }, + { + "Input": "Write a function to calculate electricity bill.", + "Output Program": [ + "def cal_electbill(units):\r\n if(units < 50):\r\n amount = units * 2.60\r\n surcharge = 25\r\n elif(units <= 100):\r\n amount = 130 + ((units - 50) * 3.25)\r\n surcharge = 35\r\n elif(units <= 200):\r\n amount = 130 + 162.50 + ((units - 100) * 5.26)\r\n surcharge = 45\r\n else:\r\n amount = 130 + 162.50 + 526 + ((units - 200) * 8.45)\r\n surcharge = 75\r\n total = amount + surcharge\r\n return total" + ], + "Output Answer": [ + "def cal_electbill(units):\r\n if(units < 50):\r\n amount = units * 2.60\r\n surcharge = 25\r\n elif(units <= 100):\r\n amount = 130 + ((units - 50) * 3.25)\r\n surcharge = 35\r\n elif(units <= 200):\r\n amount = 130 + 162.50 + ((units - 100) * 5.26)\r\n surcharge = 45\r\n else:\r\n amount = 130 + 162.50 + 526 + ((units - 200) * 8.45)\r\n surcharge = 75\r\n total = amount + surcharge\r\n return total" + ], + "split": "test" + }, + { + "Input": "Write a function to find the ration of zeroes in an array of integers.", + "Output Program": [ + "from array import array\r\ndef zero_count(nums):\r\n n = len(nums)\r\n n1 = 0\r\n for x in nums:\r\n if x == 0:\r\n n1 += 1\r\n else:\r\n None\r\n return round(n1/n,2)" + ], + "Output Answer": [ + "from array import array\r\ndef zero_count(nums):\r\n n = len(nums)\r\n n1 = 0\r\n for x in nums:\r\n if x == 0:\r\n n1 += 1\r\n else:\r\n None\r\n return round(n1/n,2)" + ], + "split": "test" + }, + { + "Input": "Write a python function to check whether the given number can be represented as sum of non-zero powers of 2 or not.", + "Output Program": [ + "def is_Sum_Of_Powers_Of_Two(n): \r\n if (n % 2 == 1): \r\n return False\r\n else: \r\n return True" + ], + "Output Answer": [ + "def is_Sum_Of_Powers_Of_Two(n): \r\n if (n % 2 == 1): \r\n return False\r\n else: \r\n return True" + ], + "split": "test" + }, + { + "Input": "Write a function to find the circumference of a circle.", + "Output Program": [ + "def circle_circumference(r):\r\n perimeter=2*3.1415*r\r\n return perimeter" + ], + "Output Answer": [ + "def circle_circumference(r):\r\n perimeter=2*3.1415*r\r\n return perimeter" + ], + "split": "test" + }, + { + "Input": "Write a function to extract elements that occur singly in the given tuple list.", + "Output Program": [ + "def extract_singly(test_list):\r\n res = []\r\n temp = set()\r\n for inner in test_list:\r\n for ele in inner:\r\n if not ele in temp:\r\n temp.add(ele)\r\n res.append(ele)\r\n return (res) " + ], + "Output Answer": [ + "def extract_singly(test_list):\r\n res = []\r\n temp = set()\r\n for inner in test_list:\r\n for ele in inner:\r\n if not ele in temp:\r\n temp.add(ele)\r\n res.append(ele)\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a function to sort a list of elements using pancake sort.", + "Output Program": [ + "def pancake_sort(nums):\r\n arr_len = len(nums)\r\n while arr_len > 1:\r\n mi = nums.index(max(nums[0:arr_len]))\r\n nums = nums[mi::-1] + nums[mi+1:len(nums)]\r\n nums = nums[arr_len-1::-1] + nums[arr_len:len(nums)]\r\n arr_len -= 1\r\n return nums" + ], + "Output Answer": [ + "def pancake_sort(nums):\r\n arr_len = len(nums)\r\n while arr_len > 1:\r\n mi = nums.index(max(nums[0:arr_len]))\r\n nums = nums[mi::-1] + nums[mi+1:len(nums)]\r\n nums = nums[arr_len-1::-1] + nums[arr_len:len(nums)]\r\n arr_len -= 1\r\n return nums" + ], + "split": "test" + }, + { + "Input": "Write a function to count the same pair in three given lists.", + "Output Program": [ + "def count_samepair(list1,list2,list3):\r\n result = sum(m == n == o for m, n, o in zip(list1,list2,list3))\r\n return result" + ], + "Output Answer": [ + "def count_samepair(list1,list2,list3):\r\n result = sum(m == n == o for m, n, o in zip(list1,list2,list3))\r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a function to find number of lists present in the given tuple.", + "Output Program": [ + "def find_lists(Input): \r\n\tif isinstance(Input, list): \r\n\t\treturn 1\r\n\telse: \r\n\t\treturn len(Input) " + ], + "Output Answer": [ + "def find_lists(Input): \r\n\tif isinstance(Input, list): \r\n\t\treturn 1\r\n\telse: \r\n\t\treturn len(Input) " + ], + "split": "test" + }, + { + "Input": "Write a python function to find the sum of absolute differences in all pairs of the given array.", + "Output Program": [ + "def sum_Pairs(arr,n): \r\n sum = 0\r\n for i in range(n - 1,-1,-1): \r\n sum += i*arr[i] - (n-1-i) * arr[i] \r\n return sum" + ], + "Output Answer": [ + "def sum_Pairs(arr,n): \r\n sum = 0\r\n for i in range(n - 1,-1,-1): \r\n sum += i*arr[i] - (n-1-i) * arr[i] \r\n return sum" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the maximum difference between any two elements in a given array.", + "Output Program": [ + "def max_Abs_Diff(arr,n): \r\n minEle = arr[0] \r\n maxEle = arr[0] \r\n for i in range(1, n): \r\n minEle = min(minEle,arr[i]) \r\n maxEle = max(maxEle,arr[i]) \r\n return (maxEle - minEle) " + ], + "Output Answer": [ + "def max_Abs_Diff(arr,n): \r\n minEle = arr[0] \r\n maxEle = arr[0] \r\n for i in range(1, n): \r\n minEle = min(minEle,arr[i]) \r\n maxEle = max(maxEle,arr[i]) \r\n return (maxEle - minEle) " + ], + "split": "test" + }, + { + "Input": "Write a function to find the ascii value of total characters in a string.", + "Output Program": [ + "def ascii_value_string(str1):\r\n for i in range(len(str1)):\r\n return ord(str1[i])" + ], + "Output Answer": [ + "def ascii_value_string(str1):\r\n for i in range(len(str1)):\r\n return ord(str1[i])" + ], + "split": "test" + }, + { + "Input": "Write a function to find the maximum total path sum in the given triangle.", + "Output Program": [ + "def max_path_sum(tri, m, n): \r\n\tfor i in range(m-1, -1, -1): \r\n\t\tfor j in range(i+1): \r\n\t\t\tif (tri[i+1][j] > tri[i+1][j+1]): \r\n\t\t\t\ttri[i][j] += tri[i+1][j] \r\n\t\t\telse: \r\n\t\t\t\ttri[i][j] += tri[i+1][j+1] \r\n\treturn tri[0][0]" + ], + "Output Answer": [ + "def max_path_sum(tri, m, n): \r\n\tfor i in range(m-1, -1, -1): \r\n\t\tfor j in range(i+1): \r\n\t\t\tif (tri[i+1][j] > tri[i+1][j+1]): \r\n\t\t\t\ttri[i][j] += tri[i+1][j] \r\n\t\t\telse: \r\n\t\t\t\ttri[i][j] += tri[i+1][j+1] \r\n\treturn tri[0][0]" + ], + "split": "test" + }, + { + "Input": "Write a function to divide a number into two parts such that the sum of digits is maximum.", + "Output Program": [ + "def sum_digits_single(x) : \r\n ans = 0\r\n while x : \r\n ans += x % 10\r\n x //= 10 \r\n return ans \r\ndef closest(x) : \r\n ans = 0\r\n while (ans * 10 + 9 <= x) : \r\n ans = ans * 10 + 9 \r\n return ans \r\ndef sum_digits_twoparts(N) : \r\n A = closest(N) \r\n return sum_digits_single(A) + sum_digits_single(N - A) " + ], + "Output Answer": [ + "def sum_digits_single(x) : \r\n ans = 0\r\n while x : \r\n ans += x % 10\r\n x //= 10 \r\n return ans \r\ndef closest(x) : \r\n ans = 0\r\n while (ans * 10 + 9 <= x) : \r\n ans = ans * 10 + 9 \r\n return ans \r\ndef sum_digits_twoparts(N) : \r\n A = closest(N) \r\n return sum_digits_single(A) + sum_digits_single(N - A) " + ], + "split": "test" + }, + { + "Input": "Write a function to find the longest subsequence such that the difference between adjacents is one for the given array.", + "Output Program": [ + "def longest_subseq_with_diff_one(arr, n): \r\n\tdp = [1 for i in range(n)] \r\n\tfor i in range(n): \r\n\t\tfor j in range(i): \r\n\t\t\tif ((arr[i] == arr[j]+1) or (arr[i] == arr[j]-1)): \r\n\t\t\t\tdp[i] = max(dp[i], dp[j]+1) \r\n\tresult = 1\r\n\tfor i in range(n): \r\n\t\tif (result < dp[i]): \r\n\t\t\tresult = dp[i] \r\n\treturn result" + ], + "Output Answer": [ + "def longest_subseq_with_diff_one(arr, n): \r\n\tdp = [1 for i in range(n)] \r\n\tfor i in range(n): \r\n\t\tfor j in range(i): \r\n\t\t\tif ((arr[i] == arr[j]+1) or (arr[i] == arr[j]-1)): \r\n\t\t\t\tdp[i] = max(dp[i], dp[j]+1) \r\n\tresult = 1\r\n\tfor i in range(n): \r\n\t\tif (result < dp[i]): \r\n\t\t\tresult = dp[i] \r\n\treturn result" + ], + "split": "test" + }, + { + "Input": "Write a python function to find whether the given number is present in the infinite sequence or not.", + "Output Program": [ + "def does_Contain_B(a,b,c): \r\n if (a == b): \r\n return True\r\n if ((b - a) * c > 0 and (b - a) % c == 0): \r\n return True\r\n return False" + ], + "Output Answer": [ + "def does_Contain_B(a,b,c): \r\n if (a == b): \r\n return True\r\n if ((b - a) * c > 0 and (b - a) % c == 0): \r\n return True\r\n return False" + ], + "split": "test" + }, + { + "Input": "Write a python function to check whether the given number is co-prime or not.", + "Output Program": [ + "def gcd(p,q):\r\n while q != 0:\r\n p, q = q,p%q\r\n return p\r\ndef is_coprime(x,y):\r\n return gcd(x,y) == 1" + ], + "Output Answer": [ + "def gcd(p,q):\r\n while q != 0:\r\n p, q = q,p%q\r\n return p\r\ndef is_coprime(x,y):\r\n return gcd(x,y) == 1" + ], + "split": "test" + }, + { + "Input": "Write a function to sort the given array by using merge sort.", + "Output Program": [ + "def merge(a,b):\r\n c = []\r\n while len(a) != 0 and len(b) != 0:\r\n if a[0] < b[0]:\r\n c.append(a[0])\r\n a.remove(a[0])\r\n else:\r\n c.append(b[0])\r\n b.remove(b[0])\r\n if len(a) == 0:\r\n c += b\r\n else:\r\n c += a\r\n return c\r\ndef merge_sort(x):\r\n if len(x) == 0 or len(x) == 1:\r\n return x\r\n else:\r\n middle = len(x)//2\r\n a = merge_sort(x[:middle])\r\n b = merge_sort(x[middle:])\r\n return merge(a,b)\r\n" + ], + "Output Answer": [ + "def merge(a,b):\r\n c = []\r\n while len(a) != 0 and len(b) != 0:\r\n if a[0] < b[0]:\r\n c.append(a[0])\r\n a.remove(a[0])\r\n else:\r\n c.append(b[0])\r\n b.remove(b[0])\r\n if len(a) == 0:\r\n c += b\r\n else:\r\n c += a\r\n return c\r\ndef merge_sort(x):\r\n if len(x) == 0 or len(x) == 1:\r\n return x\r\n else:\r\n middle = len(x)//2\r\n a = merge_sort(x[:middle])\r\n b = merge_sort(x[middle:])\r\n return merge(a,b)\r\n" + ], + "split": "test" + }, + { + "Input": "Write a function to find the vertex of a parabola.", + "Output Program": [ + "def parabola_vertex(a, b, c): \r\n vertex=(((-b / (2 * a)),(((4 * a * c) - (b * b)) / (4 * a))))\r\n return vertex" + ], + "Output Answer": [ + "def parabola_vertex(a, b, c): \r\n vertex=(((-b / (2 * a)),(((4 * a * c) - (b * b)) / (4 * a))))\r\n return vertex" + ], + "split": "test" + }, + { + "Input": "Write a function to extract every specified element from a given two dimensional list.", + "Output Program": [ + "def specified_element(nums, N):\r\n result = [i[N] for i in nums]\r\n return result" + ], + "Output Answer": [ + "def specified_element(nums, N):\r\n result = [i[N] for i in nums]\r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a python function to toggle all even bits of a given number.", + "Output Program": [ + "def even_bit_toggle_number(n) : \r\n res = 0; count = 0; temp = n \r\n while (temp > 0) : \r\n if (count % 2 == 1) : \r\n res = res | (1 << count) \r\n count = count + 1\r\n temp >>= 1 \r\n return n ^ res " + ], + "Output Answer": [ + "def even_bit_toggle_number(n) : \r\n res = 0; count = 0; temp = n \r\n while (temp > 0) : \r\n if (count % 2 == 1) : \r\n res = res | (1 << count) \r\n count = count + 1\r\n temp >>= 1 \r\n return n ^ res " + ], + "split": "test" + }, + { + "Input": "Write a function to convert a tuple of string values to a tuple of integer values.", + "Output Program": [ + "def tuple_int_str(tuple_str):\r\n result = tuple((int(x[0]), int(x[1])) for x in tuple_str)\r\n return result" + ], + "Output Answer": [ + "def tuple_int_str(tuple_str):\r\n result = tuple((int(x[0]), int(x[1])) for x in tuple_str)\r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a function to reflect the run-length encoding from a list.", + "Output Program": [ + "from itertools import groupby\r\ndef encode_list(list1):\r\n return [[len(list(group)), key] for key, group in groupby(list1)]" + ], + "Output Answer": [ + "from itertools import groupby\r\ndef encode_list(list1):\r\n return [[len(list(group)), key] for key, group in groupby(list1)]" + ], + "split": "test" + }, + { + "Input": "Write a python function to find k number of operations required to make all elements equal.", + "Output Program": [ + "def min_Ops(arr,n,k): \r\n max1 = max(arr) \r\n res = 0\r\n for i in range(0,n): \r\n if ((max1 - arr[i]) % k != 0): \r\n return -1 \r\n else: \r\n res += (max1 - arr[i]) / k \r\n return int(res) " + ], + "Output Answer": [ + "def min_Ops(arr,n,k): \r\n max1 = max(arr) \r\n res = 0\r\n for i in range(0,n): \r\n if ((max1 - arr[i]) % k != 0): \r\n return -1 \r\n else: \r\n res += (max1 - arr[i]) / k \r\n return int(res) " + ], + "split": "test" + }, + { + "Input": "Write a function to print the season for the given month and day.", + "Output Program": [ + "def month_season(month,days):\r\n if month in ('January', 'February', 'March'):\r\n\t season = 'winter'\r\n elif month in ('April', 'May', 'June'):\r\n\t season = 'spring'\r\n elif month in ('July', 'August', 'September'):\r\n\t season = 'summer'\r\n else:\r\n\t season = 'autumn'\r\n if (month == 'March') and (days > 19):\r\n\t season = 'spring'\r\n elif (month == 'June') and (days > 20):\r\n\t season = 'summer'\r\n elif (month == 'September') and (days > 21):\r\n\t season = 'autumn'\r\n elif (month == 'October') and (days > 21):\r\n\t season = 'autumn'\r\n elif (month == 'November') and (days > 21):\r\n\t season = 'autumn'\r\n elif (month == 'December') and (days > 20):\r\n\t season = 'winter'\r\n return season" + ], + "Output Answer": [ + "def month_season(month,days):\r\n if month in ('January', 'February', 'March'):\r\n\t season = 'winter'\r\n elif month in ('April', 'May', 'June'):\r\n\t season = 'spring'\r\n elif month in ('July', 'August', 'September'):\r\n\t season = 'summer'\r\n else:\r\n\t season = 'autumn'\r\n if (month == 'March') and (days > 19):\r\n\t season = 'spring'\r\n elif (month == 'June') and (days > 20):\r\n\t season = 'summer'\r\n elif (month == 'September') and (days > 21):\r\n\t season = 'autumn'\r\n elif (month == 'October') and (days > 21):\r\n\t season = 'autumn'\r\n elif (month == 'November') and (days > 21):\r\n\t season = 'autumn'\r\n elif (month == 'December') and (days > 20):\r\n\t season = 'winter'\r\n return season" + ], + "split": "test" + }, + { + "Input": "Write a function to find x and y that satisfies ax + by = n.", + "Output Program": [ + "def solution (a, b, n): \r\n\ti = 0\r\n\twhile i * a <= n: \r\n\t\tif (n - (i * a)) % b == 0: \r\n\t\t\treturn (\"x = \",i ,\", y = \", \r\n\t\t\tint((n - (i * a)) / b)) \r\n\t\t\treturn 0\r\n\t\ti = i + 1\r\n\treturn (\"No solution\") " + ], + "Output Answer": [ + "def solution (a, b, n): \r\n\ti = 0\r\n\twhile i * a <= n: \r\n\t\tif (n - (i * a)) % b == 0: \r\n\t\t\treturn (\"x = \",i ,\", y = \", \r\n\t\t\tint((n - (i * a)) / b)) \r\n\t\t\treturn 0\r\n\t\ti = i + 1\r\n\treturn (\"No solution\") " + ], + "split": "test" + }, + { + "Input": "Write a function to remove all elements from a given list present in another list.", + "Output Program": [ + "def remove_elements(list1, list2):\r\n result = [x for x in list1 if x not in list2]\r\n return result" + ], + "Output Answer": [ + "def remove_elements(list1, list2):\r\n result = [x for x in list1 if x not in list2]\r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a function to calculate the sum of the positive integers of n+(n-2)+(n-4)... (until n-x =< 0).", + "Output Program": [ + "def sum_series(n):\r\n if n < 1:\r\n return 0\r\n else:\r\n return n + sum_series(n - 2)" + ], + "Output Answer": [ + "def sum_series(n):\r\n if n < 1:\r\n return 0\r\n else:\r\n return n + sum_series(n - 2)" + ], + "split": "test" + }, + { + "Input": "Write a function to calculate the area of a regular polygon.", + "Output Program": [ + "from math import tan, pi\r\ndef area_polygon(s,l):\r\n area = s * (l ** 2) / (4 * tan(pi / s))\r\n return area" + ], + "Output Answer": [ + "from math import tan, pi\r\ndef area_polygon(s,l):\r\n area = s * (l ** 2) / (4 * tan(pi / s))\r\n return area" + ], + "split": "test" + }, + { + "Input": "Write a python function to check whether the sum of divisors are same or not.", + "Output Program": [ + "import math \r\ndef divSum(n): \r\n sum = 1; \r\n i = 2; \r\n while(i * i <= n): \r\n if (n % i == 0): \r\n sum = (sum + i +math.floor(n / i)); \r\n i += 1; \r\n return sum; \r\ndef areEquivalent(num1,num2): \r\n return divSum(num1) == divSum(num2); " + ], + "Output Answer": [ + "import math \r\ndef divSum(n): \r\n sum = 1; \r\n i = 2; \r\n while(i * i <= n): \r\n if (n % i == 0): \r\n sum = (sum + i +math.floor(n / i)); \r\n i += 1; \r\n return sum; \r\ndef areEquivalent(num1,num2): \r\n return divSum(num1) == divSum(num2); " + ], + "split": "test" + }, + { + "Input": "Write a python function to count characters at same position in a given string (lower and uppercase characters) as in english alphabet.", + "Output Program": [ + "def count_char_position(str1): \r\n count_chars = 0\r\n for i in range(len(str1)):\r\n if ((i == ord(str1[i]) - ord('A')) or \r\n (i == ord(str1[i]) - ord('a'))): \r\n count_chars += 1\r\n return count_chars " + ], + "Output Answer": [ + "def count_char_position(str1): \r\n count_chars = 0\r\n for i in range(len(str1)):\r\n if ((i == ord(str1[i]) - ord('A')) or \r\n (i == ord(str1[i]) - ord('a'))): \r\n count_chars += 1\r\n return count_chars " + ], + "split": "test" + }, + { + "Input": "Write a python function to count the pairs with xor as an even number.", + "Output Program": [ + "def find_even_Pair(A,N): \r\n evenPair = 0\r\n for i in range(0,N): \r\n for j in range(i+1,N): \r\n if ((A[i] ^ A[j]) % 2 == 0): \r\n evenPair+=1\r\n return evenPair; " + ], + "Output Answer": [ + "def find_even_Pair(A,N): \r\n evenPair = 0\r\n for i in range(0,N): \r\n for j in range(i+1,N): \r\n if ((A[i] ^ A[j]) % 2 == 0): \r\n evenPair+=1\r\n return evenPair; " + ], + "split": "test" + }, + { + "Input": "Write a python function to find smallest power of 2 greater than or equal to n.", + "Output Program": [ + "def next_Power_Of_2(n): \r\n count = 0; \r\n if (n and not(n & (n - 1))): \r\n return n \r\n while( n != 0): \r\n n >>= 1\r\n count += 1\r\n return 1 << count; " + ], + "Output Answer": [ + "def next_Power_Of_2(n): \r\n count = 0; \r\n if (n and not(n & (n - 1))): \r\n return n \r\n while( n != 0): \r\n n >>= 1\r\n count += 1\r\n return 1 << count; " + ], + "split": "test" + }, + { + "Input": "Write a python function to find the frequency of a number in a given array.", + "Output Program": [ + "def frequency(a,x): \r\n count = 0 \r\n for i in a: \r\n if i == x: count += 1\r\n return count " + ], + "Output Answer": [ + "def frequency(a,x): \r\n count = 0 \r\n for i in a: \r\n if i == x: count += 1\r\n return count " + ], + "split": "test" + }, + { + "Input": "Write a function to calculate the nth pell number.", + "Output Program": [ + "def get_pell(n): \r\n\tif (n <= 2): \r\n\t\treturn n \r\n\ta = 1\r\n\tb = 2\r\n\tfor i in range(3, n+1): \r\n\t\tc = 2 * b + a \r\n\t\ta = b \r\n\t\tb = c \r\n\treturn b " + ], + "Output Answer": [ + "def get_pell(n): \r\n\tif (n <= 2): \r\n\t\treturn n \r\n\ta = 1\r\n\tb = 2\r\n\tfor i in range(3, n+1): \r\n\t\tc = 2 * b + a \r\n\t\ta = b \r\n\t\tb = c \r\n\treturn b " + ], + "split": "test" + }, + { + "Input": "Write a function to find sum of the numbers in a list between the indices of a specified range.", + "Output Program": [ + "def sum_range_list(list1, m, n): \r\n sum_range = 0 \r\n for i in range(m, n+1, 1): \r\n sum_range += list1[i] \r\n return sum_range " + ], + "Output Answer": [ + "def sum_range_list(list1, m, n): \r\n sum_range = 0 \r\n for i in range(m, n+1, 1): \r\n sum_range += list1[i] \r\n return sum_range " + ], + "split": "test" + }, + { + "Input": "Write a function to find the perimeter of a pentagon.", + "Output Program": [ + "import math\r\ndef perimeter_pentagon(a):\r\n perimeter=(5*a)\r\n return perimeter" + ], + "Output Answer": [ + "import math\r\ndef perimeter_pentagon(a):\r\n perimeter=(5*a)\r\n return perimeter" + ], + "split": "test" + }, + { + "Input": "Write 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", + "Output Program": [ + "def count_occurance(s):\r\n count=0\r\n for i in range(len(s)):\r\n if (s[i]== 's' and s[i+1]=='t' and s[i+2]== 'd'):\r\n count = count + 1\r\n return count" + ], + "Output Answer": [ + "def count_occurance(s):\r\n count=0\r\n for i in range(len(s)):\r\n if (s[i]== 's' and s[i+1]=='t' and s[i+2]== 'd'):\r\n count = count + 1\r\n return count" + ], + "split": "test" + }, + { + "Input": "Write a function to remove everything except alphanumeric characters from a string.", + "Output Program": [ + "import re\r\ndef remove_splchar(text): \r\n pattern = re.compile('[\\W_]+')\r\n return (pattern.sub('', text))" + ], + "Output Answer": [ + "import re\r\ndef remove_splchar(text): \r\n pattern = re.compile('[\\W_]+')\r\n return (pattern.sub('', text))" + ], + "split": "test" + }, + { + "Input": "Write a function to group a sequence of key-value pairs into a dictionary of lists.", + "Output Program": [ + "def group_keyvalue(l):\r\n result = {}\r\n for k, v in l:\r\n result.setdefault(k, []).append(v)\r\n return result" + ], + "Output Answer": [ + "def group_keyvalue(l):\r\n result = {}\r\n for k, v in l:\r\n result.setdefault(k, []).append(v)\r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a function to verify validity of a string of parentheses.", + "Output Program": [ + "def is_valid_parenthese( str1):\r\n stack, pchar = [], {\"(\": \")\", \"{\": \"}\", \"[\": \"]\"}\r\n for parenthese in str1:\r\n if parenthese in pchar:\r\n stack.append(parenthese)\r\n elif len(stack) == 0 or pchar[stack.pop()] != parenthese:\r\n return False\r\n return len(stack) == 0" + ], + "Output Answer": [ + "def is_valid_parenthese( str1):\r\n stack, pchar = [], {\"(\": \")\", \"{\": \"}\", \"[\": \"]\"}\r\n for parenthese in str1:\r\n if parenthese in pchar:\r\n stack.append(parenthese)\r\n elif len(stack) == 0 or pchar[stack.pop()] != parenthese:\r\n return False\r\n return len(stack) == 0" + ], + "split": "test" + }, + { + "Input": "Write a function to find the perimeter of a triangle.", + "Output Program": [ + "def perimeter_triangle(a,b,c):\r\n perimeter=a+b+c\r\n return perimeter" + ], + "Output Answer": [ + "def perimeter_triangle(a,b,c):\r\n perimeter=a+b+c\r\n return perimeter" + ], + "split": "test" + }, + { + "Input": "Write a python function to find two distinct numbers such that their lcm lies within the given range.", + "Output Program": [ + "def answer(L,R): \r\n if (2 * L <= R): \r\n return (L ,2*L)\r\n else: \r\n return (-1) " + ], + "Output Answer": [ + "def answer(L,R): \r\n if (2 * L <= R): \r\n return (L ,2*L)\r\n else: \r\n return (-1) " + ], + "split": "test" + }, + { + "Input": "Write a function to search some literals strings in a string.", + "Output Program": [ + "import re\r\ndef string_literals(patterns,text):\r\n for pattern in patterns:\r\n if re.search(pattern, text):\r\n return ('Matched!')\r\n else:\r\n return ('Not Matched!')" + ], + "Output Answer": [ + "import re\r\ndef string_literals(patterns,text):\r\n for pattern in patterns:\r\n if re.search(pattern, text):\r\n return ('Matched!')\r\n else:\r\n return ('Not Matched!')" + ], + "split": "test" + }, + { + "Input": "Write a function to find if the given number is a keith number or not.", + "Output Program": [ + "def is_num_keith(x): \r\n\tterms = [] \r\n\ttemp = x \r\n\tn = 0 \r\n\twhile (temp > 0): \r\n\t\tterms.append(temp % 10) \r\n\t\ttemp = int(temp / 10) \r\n\t\tn+=1 \r\n\tterms.reverse() \r\n\tnext_term = 0 \r\n\ti = n \r\n\twhile (next_term < x): \r\n\t\tnext_term = 0 \r\n\t\tfor j in range(1,n+1): \r\n\t\t\tnext_term += terms[i - j] \r\n\t\tterms.append(next_term) \r\n\t\ti+=1 \r\n\treturn (next_term == x) " + ], + "Output Answer": [ + "def is_num_keith(x): \r\n\tterms = [] \r\n\ttemp = x \r\n\tn = 0 \r\n\twhile (temp > 0): \r\n\t\tterms.append(temp % 10) \r\n\t\ttemp = int(temp / 10) \r\n\t\tn+=1 \r\n\tterms.reverse() \r\n\tnext_term = 0 \r\n\ti = n \r\n\twhile (next_term < x): \r\n\t\tnext_term = 0 \r\n\t\tfor j in range(1,n+1): \r\n\t\t\tnext_term += terms[i - j] \r\n\t\tterms.append(next_term) \r\n\t\ti+=1 \r\n\treturn (next_term == x) " + ], + "split": "test" + }, + { + "Input": "Write a function to calculate distance between two points using latitude and longitude.", + "Output Program": [ + "from math import radians, sin, cos, acos\r\ndef distance_lat_long(slat,slon,elat,elon):\r\n dist = 6371.01 * acos(sin(slat)*sin(elat) + cos(slat)*cos(elat)*cos(slon - elon))\r\n return dist" + ], + "Output Answer": [ + "from math import radians, sin, cos, acos\r\ndef distance_lat_long(slat,slon,elat,elon):\r\n dist = 6371.01 * acos(sin(slat)*sin(elat) + cos(slat)*cos(elat)*cos(slon - elon))\r\n return dist" + ], + "split": "test" + }, + { + "Input": "Write a function to find the longest common prefix in the given set of strings.", + "Output Program": [ + "def common_prefix_util(str1, str2): \r\n\tresult = \"\"; \r\n\tn1 = len(str1) \r\n\tn2 = len(str2) \r\n\ti = 0\r\n\tj = 0\r\n\twhile i <= n1 - 1 and j <= n2 - 1: \r\n\t\tif (str1[i] != str2[j]): \r\n\t\t\tbreak\r\n\t\tresult += str1[i] \r\n\t\ti += 1\r\n\t\tj += 1\r\n\treturn (result) \r\ndef common_prefix (arr, n): \r\n\tprefix = arr[0] \r\n\tfor i in range (1, n): \r\n\t\tprefix = common_prefix_util(prefix, arr[i]) \r\n\treturn (prefix) " + ], + "Output Answer": [ + "def common_prefix_util(str1, str2): \r\n\tresult = \"\"; \r\n\tn1 = len(str1) \r\n\tn2 = len(str2) \r\n\ti = 0\r\n\tj = 0\r\n\twhile i <= n1 - 1 and j <= n2 - 1: \r\n\t\tif (str1[i] != str2[j]): \r\n\t\t\tbreak\r\n\t\tresult += str1[i] \r\n\t\ti += 1\r\n\t\tj += 1\r\n\treturn (result) \r\ndef common_prefix (arr, n): \r\n\tprefix = arr[0] \r\n\tfor i in range (1, n): \r\n\t\tprefix = common_prefix_util(prefix, arr[i]) \r\n\treturn (prefix) " + ], + "split": "test" + }, + { + "Input": "Write a function to find uppercase, lowercase, special character and numeric values using regex.", + "Output Program": [ + "import re\r\ndef find_character(string):\r\n uppercase_characters = re.findall(r\"[A-Z]\", string) \r\n lowercase_characters = re.findall(r\"[a-z]\", string) \r\n numerical_characters = re.findall(r\"[0-9]\", string) \r\n special_characters = re.findall(r\"[, .!?]\", string) \r\n return uppercase_characters, lowercase_characters, numerical_characters, special_characters" + ], + "Output Answer": [ + "import re\r\ndef find_character(string):\r\n uppercase_characters = re.findall(r\"[A-Z]\", string) \r\n lowercase_characters = re.findall(r\"[a-z]\", string) \r\n numerical_characters = re.findall(r\"[0-9]\", string) \r\n special_characters = re.findall(r\"[, .!?]\", string) \r\n return uppercase_characters, lowercase_characters, numerical_characters, special_characters" + ], + "split": "test" + }, + { + "Input": "Write a function to count all the distinct pairs having a difference of k in any array.", + "Output Program": [ + "def count_pairs(arr, n, k):\r\n count=0;\r\n for i in range(0,n):\r\n for j in range(i+1, n):\r\n if arr[i] - arr[j] == k or arr[j] - arr[i] == k:\r\n count += 1\r\n return count" + ], + "Output Answer": [ + "def count_pairs(arr, n, k):\r\n count=0;\r\n for i in range(0,n):\r\n for j in range(i+1, n):\r\n if arr[i] - arr[j] == k or arr[j] - arr[i] == k:\r\n count += 1\r\n return count" + ], + "split": "test" + }, + { + "Input": "Write a function to find all the values in a list that are greater than a specified number.", + "Output Program": [ + "def greater_specificnum(list,num):\r\n greater_specificnum=all(x >= num for x in list)\r\n return greater_specificnum" + ], + "Output Answer": [ + "def greater_specificnum(list,num):\r\n greater_specificnum=all(x >= num for x in list)\r\n return greater_specificnum" + ], + "split": "test" + }, + { + "Input": "Write a function to find the focus of a parabola.", + "Output Program": [ + "def parabola_focus(a, b, c): \r\n focus= (((-b / (2 * a)),(((4 * a * c) - (b * b) + 1) / (4 * a))))\r\n return focus" + ], + "Output Answer": [ + "def parabola_focus(a, b, c): \r\n focus= (((-b / (2 * a)),(((4 * a * c) - (b * b) + 1) / (4 * a))))\r\n return focus" + ], + "split": "test" + }, + { + "Input": "Write a function to search some literals strings in a string by using regex.", + "Output Program": [ + "import re\r\ndef check_literals(text, patterns):\r\n for pattern in patterns:\r\n if re.search(pattern, text):\r\n return ('Matched!')\r\n else:\r\n return ('Not Matched!')" + ], + "Output Answer": [ + "import re\r\ndef check_literals(text, patterns):\r\n for pattern in patterns:\r\n if re.search(pattern, text):\r\n return ('Matched!')\r\n else:\r\n return ('Not Matched!')" + ], + "split": "test" + }, + { + "Input": "Write a function to find the longest common subsequence for the given two sequences.", + "Output Program": [ + "def longest_common_subsequence(X, Y, m, n): \r\n if m == 0 or n == 0: \r\n return 0 \r\n elif X[m-1] == Y[n-1]: \r\n return 1 + longest_common_subsequence(X, Y, m-1, n-1) \r\n else: \r\n return max(longest_common_subsequence(X, Y, m, n-1), longest_common_subsequence(X, Y, m-1, n))" + ], + "Output Answer": [ + "def longest_common_subsequence(X, Y, m, n): \r\n if m == 0 or n == 0: \r\n return 0 \r\n elif X[m-1] == Y[n-1]: \r\n return 1 + longest_common_subsequence(X, Y, m-1, n-1) \r\n else: \r\n return max(longest_common_subsequence(X, Y, m, n-1), longest_common_subsequence(X, Y, m-1, n))" + ], + "split": "test" + }, + { + "Input": "Write a python function to check whether the given number can be represented by product of two squares or not.", + "Output Program": [ + "def prod_Square(n):\r\n for i in range(2,(n) + 1):\r\n if (i*i < (n+1)):\r\n for j in range(2,n + 1):\r\n if ((i*i*j*j) == n):\r\n return True;\r\n return False;" + ], + "Output Answer": [ + "def prod_Square(n):\r\n for i in range(2,(n) + 1):\r\n if (i*i < (n+1)):\r\n for j in range(2,n + 1):\r\n if ((i*i*j*j) == n):\r\n return True;\r\n return False;" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the first missing positive number.", + "Output Program": [ + "def first_Missing_Positive(arr,n): \r\n ptr = 0\r\n for i in range(n):\r\n if arr[i] == 1:\r\n ptr = 1\r\n break\r\n if ptr == 0:\r\n return(1)\r\n for i in range(n):\r\n if arr[i] <= 0 or arr[i] > n:\r\n arr[i] = 1\r\n for i in range(n):\r\n arr[(arr[i] - 1) % n] += n\r\n for i in range(n):\r\n if arr[i] <= n:\r\n return(i + 1)\r\n return(n + 1)" + ], + "Output Answer": [ + "def first_Missing_Positive(arr,n): \r\n ptr = 0\r\n for i in range(n):\r\n if arr[i] == 1:\r\n ptr = 1\r\n break\r\n if ptr == 0:\r\n return(1)\r\n for i in range(n):\r\n if arr[i] <= 0 or arr[i] > n:\r\n arr[i] = 1\r\n for i in range(n):\r\n arr[(arr[i] - 1) % n] += n\r\n for i in range(n):\r\n if arr[i] <= n:\r\n return(i + 1)\r\n return(n + 1)" + ], + "split": "test" + }, + { + "Input": "Write a python function to count the number of integral co-ordinates that lie inside a square.", + "Output Program": [ + "def count_Intgral_Points(x1,y1,x2,y2): \r\n return ((y2 - y1 - 1) * (x2 - x1 - 1)) " + ], + "Output Answer": [ + "def count_Intgral_Points(x1,y1,x2,y2): \r\n return ((y2 - y1 - 1) * (x2 - x1 - 1)) " + ], + "split": "test" + }, + { + "Input": "Write a function to check whether the given month name contains 30 days or not.", + "Output Program": [ + "def check_monthnumber(monthname3):\r\n if monthname3 ==\"April\" or monthname3== \"June\" or monthname3== \"September\" or monthname3== \"November\":\r\n return True\r\n else:\r\n return False" + ], + "Output Answer": [ + "def check_monthnumber(monthname3):\r\n if monthname3 ==\"April\" or monthname3== \"June\" or monthname3== \"September\" or monthname3== \"November\":\r\n return True\r\n else:\r\n return False" + ], + "split": "test" + }, + { + "Input": "Write a python function to check whether a string has atleast one letter and one number.", + "Output Program": [ + "def check_String(str): \r\n flag_l = False\r\n flag_n = False\r\n for i in str: \r\n if i.isalpha(): \r\n flag_l = True \r\n if i.isdigit(): \r\n flag_n = True\r\n return flag_l and flag_n " + ], + "Output Answer": [ + "def check_String(str): \r\n flag_l = False\r\n flag_n = False\r\n for i in str: \r\n if i.isalpha(): \r\n flag_l = True \r\n if i.isdigit(): \r\n flag_n = True\r\n return flag_l and flag_n " + ], + "split": "test" + }, + { + "Input": "Write a function to remove the duplicates from the given tuple.", + "Output Program": [ + "def remove_tuple(test_tup):\r\n res = tuple(set(test_tup))\r\n return (res) " + ], + "Output Answer": [ + "def remove_tuple(test_tup):\r\n res = tuple(set(test_tup))\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a python function to convert octal number to decimal number.", + "Output Program": [ + "def octal_To_Decimal(n): \r\n num = n; \r\n dec_value = 0; \r\n base = 1; \r\n temp = num; \r\n while (temp): \r\n last_digit = temp % 10; \r\n temp = int(temp / 10); \r\n dec_value += last_digit*base; \r\n base = base * 8; \r\n return dec_value; " + ], + "Output Answer": [ + "def octal_To_Decimal(n): \r\n num = n; \r\n dec_value = 0; \r\n base = 1; \r\n temp = num; \r\n while (temp): \r\n last_digit = temp % 10; \r\n temp = int(temp / 10); \r\n dec_value += last_digit*base; \r\n base = base * 8; \r\n return dec_value; " + ], + "split": "test" + }, + { + "Input": "Write a python function to find the first position of an element in a sorted array.", + "Output Program": [ + "def first(arr,x,n): \r\n low = 0\r\n high = n - 1\r\n res = -1 \r\n while (low <= high):\r\n mid = (low + high) // 2 \r\n if arr[mid] > x:\r\n high = mid - 1\r\n elif arr[mid] < x:\r\n low = mid + 1\r\n else:\r\n res = mid\r\n high = mid - 1\r\n return res" + ], + "Output Answer": [ + "def first(arr,x,n): \r\n low = 0\r\n high = n - 1\r\n res = -1 \r\n while (low <= high):\r\n mid = (low + high) // 2 \r\n if arr[mid] > x:\r\n high = mid - 1\r\n elif arr[mid] < x:\r\n low = mid + 1\r\n else:\r\n res = mid\r\n high = mid - 1\r\n return res" + ], + "split": "test" + }, + { + "Input": "Write a function to remove all the tuples with length k.", + "Output Program": [ + "def remove_tuples(test_list, K):\r\n res = [ele for ele in test_list if len(ele) != K]\r\n return (res) " + ], + "Output Answer": [ + "def remove_tuples(test_list, K):\r\n res = [ele for ele in test_list if len(ele) != K]\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a function to perform the exponentiation of the given two tuples.", + "Output Program": [ + "def find_exponentio(test_tup1, test_tup2):\r\n res = tuple(ele1 ** ele2 for ele1, ele2 in zip(test_tup1, test_tup2))\r\n return (res)\r\n" + ], + "Output Answer": [ + "def find_exponentio(test_tup1, test_tup2):\r\n res = tuple(ele1 ** ele2 for ele1, ele2 in zip(test_tup1, test_tup2))\r\n return (res)\r\n" + ], + "split": "test" + }, + { + "Input": "Write a function to find the largest triangle that can be inscribed in an ellipse.", + "Output Program": [ + "import math\r\ndef largest_triangle(a,b): \r\n if (a < 0 or b < 0): \r\n return -1 \r\n area = (3 * math.sqrt(3) * pow(a, 2)) / (4 * b); \r\n return area " + ], + "Output Answer": [ + "import math\r\ndef largest_triangle(a,b): \r\n if (a < 0 or b < 0): \r\n return -1 \r\n area = (3 * math.sqrt(3) * pow(a, 2)) / (4 * b); \r\n return area " + ], + "split": "test" + }, + { + "Input": "Write a python function to find highest power of 2 less than or equal to given number.", + "Output Program": [ + "def highest_Power_of_2(n): \r\n res = 0; \r\n for i in range(n, 0, -1): \r\n if ((i & (i - 1)) == 0): \r\n res = i; \r\n break; \r\n return res; " + ], + "Output Answer": [ + "def highest_Power_of_2(n): \r\n res = 0; \r\n for i in range(n, 0, -1): \r\n if ((i & (i - 1)) == 0): \r\n res = i; \r\n break; \r\n return res; " + ], + "split": "test" + }, + { + "Input": "Write a function to find all index positions of the maximum values in a given list.", + "Output Program": [ + "def position_max(list1):\r\n max_val = max(list1)\r\n max_result = [i for i, j in enumerate(list1) if j == max_val]\r\n return max_result" + ], + "Output Answer": [ + "def position_max(list1):\r\n max_val = max(list1)\r\n max_result = [i for i, j in enumerate(list1) if j == max_val]\r\n return max_result" + ], + "split": "test" + }, + { + "Input": "Write a python function to check whether the elements in a list are same or not.", + "Output Program": [ + "def chkList(lst): \r\n return len(set(lst)) == 1" + ], + "Output Answer": [ + "def chkList(lst): \r\n return len(set(lst)) == 1" + ], + "split": "test" + }, + { + "Input": "Write a function to remove even characters in a string.", + "Output Program": [ + "def remove_even(str1):\r\n str2 = ''\r\n for i in range(1, len(str1) + 1):\r\n if(i % 2 != 0):\r\n str2 = str2 + str1[i - 1]\r\n return str2" + ], + "Output Answer": [ + "def remove_even(str1):\r\n str2 = ''\r\n for i in range(1, len(str1) + 1):\r\n if(i % 2 != 0):\r\n str2 = str2 + str1[i - 1]\r\n return str2" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the hamming distance between given two integers.", + "Output Program": [ + "def hamming_Distance(n1,n2) : \r\n x = n1 ^ n2 \r\n setBits = 0\r\n while (x > 0) : \r\n setBits += x & 1\r\n x >>= 1\r\n return setBits " + ], + "Output Answer": [ + "def hamming_Distance(n1,n2) : \r\n x = n1 ^ n2 \r\n setBits = 0\r\n while (x > 0) : \r\n setBits += x & 1\r\n x >>= 1\r\n return setBits " + ], + "split": "test" + }, + { + "Input": "Write a python function to count the occurrence of a given character in a string.", + "Output Program": [ + "def count(s,c) : \r\n res = 0 \r\n for i in range(len(s)) : \r\n if (s[i] == c): \r\n res = res + 1\r\n return res " + ], + "Output Answer": [ + "def count(s,c) : \r\n res = 0 \r\n for i in range(len(s)) : \r\n if (s[i] == c): \r\n res = res + 1\r\n return res " + ], + "split": "test" + }, + { + "Input": "Write a function to find the inversions of tuple elements in the given tuple list.", + "Output Program": [ + "def inversion_elements(test_tup):\r\n res = tuple(list(map(lambda x: ~x, list(test_tup))))\r\n return (res) " + ], + "Output Answer": [ + "def inversion_elements(test_tup):\r\n res = tuple(list(map(lambda x: ~x, list(test_tup))))\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a function to perform the adjacent element concatenation in the given tuples.", + "Output Program": [ + "def concatenate_elements(test_tup):\r\n res = tuple(i + j for i, j in zip(test_tup, test_tup[1:]))\r\n return (res) " + ], + "Output Answer": [ + "def concatenate_elements(test_tup):\r\n res = tuple(i + j for i, j in zip(test_tup, test_tup[1:]))\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a function to count the longest repeating subsequences such that the two subsequences don\u2019t have same string characters at same positions.", + "Output Program": [ + "def find_longest_repeating_subseq(str): \r\n\tn = len(str) \r\n\tdp = [[0 for k in range(n+1)] for l in range(n+1)] \r\n\tfor i in range(1, n+1): \r\n\t\tfor j in range(1, n+1): \r\n\t\t\tif (str[i-1] == str[j-1] and i != j): \r\n\t\t\t\tdp[i][j] = 1 + dp[i-1][j-1] \r\n\t\t\telse: \r\n\t\t\t\tdp[i][j] = max(dp[i][j-1], dp[i-1][j]) \r\n\treturn dp[n][n]" + ], + "Output Answer": [ + "def find_longest_repeating_subseq(str): \r\n\tn = len(str) \r\n\tdp = [[0 for k in range(n+1)] for l in range(n+1)] \r\n\tfor i in range(1, n+1): \r\n\t\tfor j in range(1, n+1): \r\n\t\t\tif (str[i-1] == str[j-1] and i != j): \r\n\t\t\t\tdp[i][j] = 1 + dp[i-1][j-1] \r\n\t\t\telse: \r\n\t\t\t\tdp[i][j] = max(dp[i][j-1], dp[i-1][j]) \r\n\treturn dp[n][n]" + ], + "split": "test" + }, + { + "Input": "Write a function to check the given decimal with a precision of 2 by using regex.", + "Output Program": [ + "import re\r\ndef is_decimal(num):\r\n num_fetch = re.compile(r\"\"\"^[0-9]+(\\.[0-9]{1,2})?$\"\"\")\r\n result = num_fetch.search(num)\r\n return bool(result)" + ], + "Output Answer": [ + "import re\r\ndef is_decimal(num):\r\n num_fetch = re.compile(r\"\"\"^[0-9]+(\\.[0-9]{1,2})?$\"\"\")\r\n result = num_fetch.search(num)\r\n return bool(result)" + ], + "split": "test" + }, + { + "Input": "Write a function to delete the smallest element from the given heap and then insert a new item.", + "Output Program": [ + "import heapq as hq\r\ndef heap_replace(heap,a):\r\n hq.heapify(heap)\r\n hq.heapreplace(heap, a)\r\n return heap" + ], + "Output Answer": [ + "import heapq as hq\r\ndef heap_replace(heap,a):\r\n hq.heapify(heap)\r\n hq.heapreplace(heap, a)\r\n return heap" + ], + "split": "test" + }, + { + "Input": "Write 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.", + "Output Program": [ + "import re\r\ndef is_allowed_specific_char(string):\r\n get_char = re.compile(r'[^a-zA-Z0-9.]')\r\n string = get_char.search(string)\r\n return not bool(string)" + ], + "Output Answer": [ + "import re\r\ndef is_allowed_specific_char(string):\r\n get_char = re.compile(r'[^a-zA-Z0-9.]')\r\n string = get_char.search(string)\r\n return not bool(string)" + ], + "split": "test" + }, + { + "Input": "Write a python function to count numbers whose oth and nth bits are set.", + "Output Program": [ + "def count_Num(n): \r\n if (n == 1): \r\n return 1\r\n count = pow(2,n - 2) \r\n return count " + ], + "Output Answer": [ + "def count_Num(n): \r\n if (n == 1): \r\n return 1\r\n count = pow(2,n - 2) \r\n return count " + ], + "split": "test" + }, + { + "Input": "Write a python function to find the sum of fourth power of n natural numbers.", + "Output Program": [ + "import math \r\ndef fourth_Power_Sum(n): \r\n sum = 0\r\n for i in range(1,n+1) : \r\n sum = sum + (i*i*i*i) \r\n return sum" + ], + "Output Answer": [ + "import math \r\ndef fourth_Power_Sum(n): \r\n sum = 0\r\n for i in range(1,n+1) : \r\n sum = sum + (i*i*i*i) \r\n return sum" + ], + "split": "test" + }, + { + "Input": "Write a function to perform the concatenation of two string tuples.", + "Output Program": [ + "def concatenate_strings(test_tup1, test_tup2):\r\n res = tuple(ele1 + ele2 for ele1, ele2 in zip(test_tup1, test_tup2))\r\n return (res) " + ], + "Output Answer": [ + "def concatenate_strings(test_tup1, test_tup2):\r\n res = tuple(ele1 + ele2 for ele1, ele2 in zip(test_tup1, test_tup2))\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a function to convert radians to degrees.", + "Output Program": [ + "import math\r\ndef degree_radian(radian):\r\n degree = radian*(180/math.pi)\r\n return degree" + ], + "Output Answer": [ + "import math\r\ndef degree_radian(radian):\r\n degree = radian*(180/math.pi)\r\n return degree" + ], + "split": "test" + }, + { + "Input": "Write a function to decode a run-length encoded given list.", + "Output Program": [ + "def decode_list(alist):\r\n def aux(g):\r\n if isinstance(g, list):\r\n return [(g[1], range(g[0]))]\r\n else:\r\n return [(g, [0])]\r\n return [x for g in alist for x, R in aux(g) for i in R]" + ], + "Output Answer": [ + "def decode_list(alist):\r\n def aux(g):\r\n if isinstance(g, list):\r\n return [(g[1], range(g[0]))]\r\n else:\r\n return [(g, [0])]\r\n return [x for g in alist for x, R in aux(g) for i in R]" + ], + "split": "test" + }, + { + "Input": "Write a function to check if a nested list is a subset of another nested list.", + "Output Program": [ + "def check_subset(list1,list2): \r\n return all(map(list1.__contains__,list2)) ", + "def check_subset_list(list1, list2): \r\n l1, l2 = list1[0], list2[0] \r\n exist = True\r\n for i in list2: \r\n if i not in list1: \r\n exist = False\r\n return exist " + ], + "Output Answer": [ + "def check_subset(list1,list2): \r\n return all(map(list1.__contains__,list2)) ", + "def check_subset_list(list1, list2): \r\n l1, l2 = list1[0], list2[0] \r\n exist = True\r\n for i in list2: \r\n if i not in list1: \r\n exist = False\r\n return exist " + ], + "split": "train" + }, + { + "Input": "Write a python function to find the first repeated character in a given string.", + "Output Program": [ + "def first_repeated_char(str1):\r\n for index,c in enumerate(str1):\r\n if str1[:index+1].count(c) > 1:\r\n return c \r\n return \"None\"", + "def first_Repeated_Char(str): \r\n h = {}\r\n for ch in str:\r\n if ch in h: \r\n return ch;\r\n else: \r\n h[ch] = 0\r\n return '\\0'" + ], + "Output Answer": [ + "def first_repeated_char(str1):\r\n for index,c in enumerate(str1):\r\n if str1[:index+1].count(c) > 1:\r\n return c \r\n return \"None\"", + "def first_Repeated_Char(str): \r\n h = {}\r\n for ch in str:\r\n if ch in h: \r\n return ch;\r\n else: \r\n h[ch] = 0\r\n return '\\0'" + ], + "split": "train" + }, + { + "Input": "Write a python function to find the minimum operations required to make two numbers equal.", + "Output Program": [ + "import math \r\ndef min_Operations(A,B): \r\n if (A > B): \r\n swap(A,B) \r\n B = B // math.gcd(A,B); \r\n return B - 1" + ], + "Output Answer": [ + "import math \r\ndef min_Operations(A,B): \r\n if (A > B): \r\n swap(A,B) \r\n B = B // math.gcd(A,B); \r\n return B - 1" + ], + "split": "test" + }, + { + "Input": "Write a function to extract maximum and minimum k elements in the given tuple.", + "Output Program": [ + "\r\ndef extract_min_max(test_tup, K):\r\n res = []\r\n test_tup = list(test_tup)\r\n temp = sorted(test_tup)\r\n for idx, val in enumerate(temp):\r\n if idx < K or idx >= len(temp) - K:\r\n res.append(val)\r\n res = tuple(res)\r\n return (res) " + ], + "Output Answer": [ + "\r\ndef extract_min_max(test_tup, K):\r\n res = []\r\n test_tup = list(test_tup)\r\n temp = sorted(test_tup)\r\n for idx, val in enumerate(temp):\r\n if idx < K or idx >= len(temp) - K:\r\n res.append(val)\r\n res = tuple(res)\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a function to replace maximum n occurrences of spaces, commas, or dots with a colon.", + "Output Program": [ + "import re\r\ndef replace_max_specialchar(text,n):\r\n return (re.sub(\"[ ,.]\", \":\", text, n))" + ], + "Output Answer": [ + "import re\r\ndef replace_max_specialchar(text,n):\r\n return (re.sub(\"[ ,.]\", \":\", text, n))" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the first even number in a given list of numbers.", + "Output Program": [ + "def first_even(nums):\r\n first_even = next((el for el in nums if el%2==0),-1)\r\n return first_even" + ], + "Output Answer": [ + "def first_even(nums):\r\n first_even = next((el for el in nums if el%2==0),-1)\r\n return first_even" + ], + "split": "test" + }, + { + "Input": "Write a function to check if all the elements in tuple have same data type or not.", + "Output Program": [ + "def check_type(test_tuple):\r\n res = True\r\n for ele in test_tuple:\r\n if not isinstance(ele, type(test_tuple[0])):\r\n res = False\r\n break\r\n return (res) " + ], + "Output Answer": [ + "def check_type(test_tuple):\r\n res = True\r\n for ele in test_tuple:\r\n if not isinstance(ele, type(test_tuple[0])):\r\n res = False\r\n break\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a function to check for majority element in the given sorted array.", + "Output Program": [ + "def is_majority(arr, n, x):\r\n\ti = binary_search(arr, 0, n-1, x)\r\n\tif i == -1:\r\n\t\treturn False\r\n\tif ((i + n//2) <= (n -1)) and arr[i + n//2] == x:\r\n\t\treturn True\r\n\telse:\r\n\t\treturn False\r\ndef binary_search(arr, low, high, x):\r\n\tif high >= low:\r\n\t\tmid = (low + high)//2 \r\n\t\tif (mid == 0 or x > arr[mid-1]) and (arr[mid] == x):\r\n\t\t\treturn mid\r\n\t\telif x > arr[mid]:\r\n\t\t\treturn binary_search(arr, (mid + 1), high, x)\r\n\t\telse:\r\n\t\t\treturn binary_search(arr, low, (mid -1), x)\r\n\treturn -1" + ], + "Output Answer": [ + "def is_majority(arr, n, x):\r\n\ti = binary_search(arr, 0, n-1, x)\r\n\tif i == -1:\r\n\t\treturn False\r\n\tif ((i + n//2) <= (n -1)) and arr[i + n//2] == x:\r\n\t\treturn True\r\n\telse:\r\n\t\treturn False\r\ndef binary_search(arr, low, high, x):\r\n\tif high >= low:\r\n\t\tmid = (low + high)//2 \r\n\t\tif (mid == 0 or x > arr[mid-1]) and (arr[mid] == x):\r\n\t\t\treturn mid\r\n\t\telif x > arr[mid]:\r\n\t\t\treturn binary_search(arr, (mid + 1), high, x)\r\n\t\telse:\r\n\t\t\treturn binary_search(arr, low, (mid -1), x)\r\n\treturn -1" + ], + "split": "test" + }, + { + "Input": "Write a python function to count set bits of a given number.", + "Output Program": [ + "def count_Set_Bits(n): \r\n count = 0\r\n while (n): \r\n count += n & 1\r\n n >>= 1\r\n return count " + ], + "Output Answer": [ + "def count_Set_Bits(n): \r\n count = 0\r\n while (n): \r\n count += n & 1\r\n n >>= 1\r\n return count " + ], + "split": "test" + }, + { + "Input": "Write a python function to find the minimum element in a sorted and rotated array.", + "Output Program": [ + "def find_Min(arr,low,high): \r\n while (low < high): \r\n mid = low + (high - low) // 2; \r\n if (arr[mid] == arr[high]): \r\n high -= 1; \r\n elif (arr[mid] > arr[high]): \r\n low = mid + 1; \r\n else: \r\n high = mid; \r\n return arr[high]; " + ], + "Output Answer": [ + "def find_Min(arr,low,high): \r\n while (low < high): \r\n mid = low + (high - low) // 2; \r\n if (arr[mid] == arr[high]): \r\n high -= 1; \r\n elif (arr[mid] > arr[high]): \r\n low = mid + 1; \r\n else: \r\n high = mid; \r\n return arr[high]; " + ], + "split": "test" + }, + { + "Input": "Write a python function to remove the characters which have odd index values of a given string.", + "Output Program": [ + "def odd_values_string(str):\r\n result = \"\" \r\n for i in range(len(str)):\r\n if i % 2 == 0:\r\n result = result + str[i]\r\n return result" + ], + "Output Answer": [ + "def odd_values_string(str):\r\n result = \"\" \r\n for i in range(len(str)):\r\n if i % 2 == 0:\r\n result = result + str[i]\r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a function to find minimum of three numbers.", + "Output Program": [ + "def min_of_three(a,b,c): \r\n if (a <= b) and (a <= c): \r\n smallest = a \r\n elif (b <= a) and (b <= c): \r\n smallest = b \r\n else: \r\n smallest = c \r\n return smallest " + ], + "Output Answer": [ + "def min_of_three(a,b,c): \r\n if (a <= b) and (a <= c): \r\n smallest = a \r\n elif (b <= a) and (b <= c): \r\n smallest = b \r\n else: \r\n smallest = c \r\n return smallest " + ], + "split": "test" + }, + { + "Input": "Write a python function to check whether all the bits are unset in the given range or not.", + "Output Program": [ + "def all_Bits_Set_In_The_Given_Range(n,l,r): \r\n num = (((1 << r) - 1) ^ ((1 << (l - 1)) - 1)) \r\n new_num = n & num\r\n if (new_num == 0): \r\n return True\r\n return False" + ], + "Output Answer": [ + "def all_Bits_Set_In_The_Given_Range(n,l,r): \r\n num = (((1 << r) - 1) ^ ((1 << (l - 1)) - 1)) \r\n new_num = n & num\r\n if (new_num == 0): \r\n return True\r\n return False" + ], + "split": "test" + }, + { + "Input": "Write a function to re-arrange the elements of the given array so that all negative elements appear before positive ones.", + "Output Program": [ + "def re_arrange_array(arr, n):\r\n j=0\r\n for i in range(0, n):\r\n if (arr[i] < 0):\r\n temp = arr[i]\r\n arr[i] = arr[j]\r\n arr[j] = temp\r\n j = j + 1\r\n return arr" + ], + "Output Answer": [ + "def re_arrange_array(arr, n):\r\n j=0\r\n for i in range(0, n):\r\n if (arr[i] < 0):\r\n temp = arr[i]\r\n arr[i] = arr[j]\r\n arr[j] = temp\r\n j = j + 1\r\n return arr" + ], + "split": "test" + }, + { + "Input": "Write a function to replace blank spaces with any character in a string.", + "Output Program": [ + "def replace_blank(str1,char):\r\n str2 = str1.replace(' ', char)\r\n return str2" + ], + "Output Answer": [ + "def replace_blank(str1,char):\r\n str2 = str1.replace(' ', char)\r\n return str2" + ], + "split": "test" + }, + { + "Input": "Write a function to find the maximum sum in the given right triangle of numbers.", + "Output Program": [ + "def max_sum(tri, n): \r\n\tif n > 1: \r\n\t\ttri[1][1] = tri[1][1]+tri[0][0] \r\n\t\ttri[1][0] = tri[1][0]+tri[0][0] \r\n\tfor i in range(2, n): \r\n\t\ttri[i][0] = tri[i][0] + tri[i-1][0] \r\n\t\ttri[i][i] = tri[i][i] + tri[i-1][i-1] \r\n\t\tfor j in range(1, i): \r\n\t\t\tif tri[i][j]+tri[i-1][j-1] >= tri[i][j]+tri[i-1][j]: \r\n\t\t\t\ttri[i][j] = tri[i][j] + tri[i-1][j-1] \r\n\t\t\telse: \r\n\t\t\t\ttri[i][j] = tri[i][j]+tri[i-1][j] \r\n\treturn (max(tri[n-1]))" + ], + "Output Answer": [ + "def max_sum(tri, n): \r\n\tif n > 1: \r\n\t\ttri[1][1] = tri[1][1]+tri[0][0] \r\n\t\ttri[1][0] = tri[1][0]+tri[0][0] \r\n\tfor i in range(2, n): \r\n\t\ttri[i][0] = tri[i][0] + tri[i-1][0] \r\n\t\ttri[i][i] = tri[i][i] + tri[i-1][i-1] \r\n\t\tfor j in range(1, i): \r\n\t\t\tif tri[i][j]+tri[i-1][j-1] >= tri[i][j]+tri[i-1][j]: \r\n\t\t\t\ttri[i][j] = tri[i][j] + tri[i-1][j-1] \r\n\t\t\telse: \r\n\t\t\t\ttri[i][j] = tri[i][j]+tri[i-1][j] \r\n\treturn (max(tri[n-1]))" + ], + "split": "test" + }, + { + "Input": "Write a function to get the n largest items from a dataset.", + "Output Program": [ + "import heapq\r\ndef larg_nnum(list1,n):\r\n largest=heapq.nlargest(n,list1)\r\n return largest" + ], + "Output Answer": [ + "import heapq\r\ndef larg_nnum(list1,n):\r\n largest=heapq.nlargest(n,list1)\r\n return largest" + ], + "split": "test" + }, + { + "Input": "Write a function to find the lateral surface area of a cylinder.", + "Output Program": [ + "def lateralsuface_cylinder(r,h):\r\n lateralsurface= 2*3.1415*r*h\r\n return lateralsurface" + ], + "Output Answer": [ + "def lateralsuface_cylinder(r,h):\r\n lateralsurface= 2*3.1415*r*h\r\n return lateralsurface" + ], + "split": "test" + }, + { + "Input": "Write a function to find the volume of a cube.", + "Output Program": [ + "def volume_cube(l):\r\n volume = l * l * l\r\n return volume" + ], + "Output Answer": [ + "def volume_cube(l):\r\n volume = l * l * l\r\n return volume" + ], + "split": "test" + }, + { + "Input": "Write a python function to set all even bits of a given number.", + "Output Program": [ + "def even_bit_set_number(n): \r\n count = 0;res = 0;temp = n \r\n while(temp > 0): \r\n if (count % 2 == 1): \r\n res |= (1 << count)\r\n count+=1\r\n temp >>= 1\r\n return (n | res) " + ], + "Output Answer": [ + "def even_bit_set_number(n): \r\n count = 0;res = 0;temp = n \r\n while(temp > 0): \r\n if (count % 2 == 1): \r\n res |= (1 << count)\r\n count+=1\r\n temp >>= 1\r\n return (n | res) " + ], + "split": "test" + }, + { + "Input": "Write a python function to count the maximum number of equilateral triangles that can be formed within a given equilateral triangle.", + "Output Program": [ + "def No_of_Triangle(N,K):\r\n if (N < K):\r\n return -1;\r\n else:\r\n Tri_up = 0;\r\n Tri_up = ((N - K + 1) *(N - K + 2)) // 2;\r\n Tri_down = 0;\r\n Tri_down = ((N - 2 * K + 1) *(N - 2 * K + 2)) // 2;\r\n return Tri_up + Tri_down;" + ], + "Output Answer": [ + "def No_of_Triangle(N,K):\r\n if (N < K):\r\n return -1;\r\n else:\r\n Tri_up = 0;\r\n Tri_up = ((N - K + 1) *(N - K + 2)) // 2;\r\n Tri_down = 0;\r\n Tri_down = ((N - 2 * K + 1) *(N - 2 * K + 2)) // 2;\r\n return Tri_up + Tri_down;" + ], + "split": "test" + }, + { + "Input": "Write a function to check the occurrences of records which occur similar times in the given tuples.", + "Output Program": [ + "from collections import Counter \r\ndef check_occurences(test_list):\r\n res = dict(Counter(tuple(ele) for ele in map(sorted, test_list)))\r\n return (res) " + ], + "Output Answer": [ + "from collections import Counter \r\ndef check_occurences(test_list):\r\n res = dict(Counter(tuple(ele) for ele in map(sorted, test_list)))\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a python function to count number of non-empty substrings of a given string.", + "Output Program": [ + "def number_of_substrings(str): \r\n\tstr_len = len(str); \r\n\treturn int(str_len * (str_len + 1) / 2); " + ], + "Output Answer": [ + "def number_of_substrings(str): \r\n\tstr_len = len(str); \r\n\treturn int(str_len * (str_len + 1) / 2); " + ], + "split": "test" + }, + { + "Input": "Write 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.", + "Output Program": [ + "def get_total_number_of_sequences(m,n): \r\n\tT=[[0 for i in range(n+1)] for i in range(m+1)] \r\n\tfor i in range(m+1): \r\n\t\tfor j in range(n+1): \r\n\t\t\tif i==0 or j==0: \r\n\t\t\t\tT[i][j]=0\r\n\t\t\telif i arr[j] and MSIBS[i] < MSIBS[j] + arr[i]: \r\n\t\t\t\tMSIBS[i] = MSIBS[j] + arr[i] \r\n\tMSDBS = arr[:] \r\n\tfor i in range(1, n + 1): \r\n\t\tfor j in range(1, i): \r\n\t\t\tif arr[-i] > arr[-j] and MSDBS[-i] < MSDBS[-j] + arr[-i]: \r\n\t\t\t\tMSDBS[-i] = MSDBS[-j] + arr[-i] \r\n\tmax_sum = float(\"-Inf\") \r\n\tfor i, j, k in zip(MSIBS, MSDBS, arr): \r\n\t\tmax_sum = max(max_sum, i + j - k) \r\n\treturn max_sum" + ], + "Output Answer": [ + "def max_sum(arr, n): \r\n\tMSIBS = arr[:] \r\n\tfor i in range(n): \r\n\t\tfor j in range(0, i): \r\n\t\t\tif arr[i] > arr[j] and MSIBS[i] < MSIBS[j] + arr[i]: \r\n\t\t\t\tMSIBS[i] = MSIBS[j] + arr[i] \r\n\tMSDBS = arr[:] \r\n\tfor i in range(1, n + 1): \r\n\t\tfor j in range(1, i): \r\n\t\t\tif arr[-i] > arr[-j] and MSDBS[-i] < MSDBS[-j] + arr[-i]: \r\n\t\t\t\tMSDBS[-i] = MSDBS[-j] + arr[-i] \r\n\tmax_sum = float(\"-Inf\") \r\n\tfor i, j, k in zip(MSIBS, MSDBS, arr): \r\n\t\tmax_sum = max(max_sum, i + j - k) \r\n\treturn max_sum" + ], + "split": "test" + }, + { + "Input": "Write a function for computing square roots using the babylonian method.", + "Output Program": [ + "def babylonian_squareroot(number):\r\n if(number == 0):\r\n return 0;\r\n g = number/2.0;\r\n g2 = g + 1;\r\n while(g != g2):\r\n n = number/ g;\r\n g2 = g;\r\n g = (g + n)/2;\r\n return g;" + ], + "Output Answer": [ + "def babylonian_squareroot(number):\r\n if(number == 0):\r\n return 0;\r\n g = number/2.0;\r\n g2 = g + 1;\r\n while(g != g2):\r\n n = number/ g;\r\n g2 = g;\r\n g = (g + n)/2;\r\n return g;" + ], + "split": "test" + }, + { + "Input": "Write a function to find the longest palindromic subsequence in the given string.", + "Output Program": [ + "def lps(str): \r\n\tn = len(str) \r\n\tL = [[0 for x in range(n)] for x in range(n)] \r\n\tfor i in range(n): \r\n\t\tL[i][i] = 1\r\n\tfor cl in range(2, n+1): \r\n\t\tfor i in range(n-cl+1): \r\n\t\t\tj = i+cl-1\r\n\t\t\tif str[i] == str[j] and cl == 2: \r\n\t\t\t\tL[i][j] = 2\r\n\t\t\telif str[i] == str[j]: \r\n\t\t\t\tL[i][j] = L[i+1][j-1] + 2\r\n\t\t\telse: \r\n\t\t\t\tL[i][j] = max(L[i][j-1], L[i+1][j]); \r\n\treturn L[0][n-1]" + ], + "Output Answer": [ + "def lps(str): \r\n\tn = len(str) \r\n\tL = [[0 for x in range(n)] for x in range(n)] \r\n\tfor i in range(n): \r\n\t\tL[i][i] = 1\r\n\tfor cl in range(2, n+1): \r\n\t\tfor i in range(n-cl+1): \r\n\t\t\tj = i+cl-1\r\n\t\t\tif str[i] == str[j] and cl == 2: \r\n\t\t\t\tL[i][j] = 2\r\n\t\t\telif str[i] == str[j]: \r\n\t\t\t\tL[i][j] = L[i+1][j-1] + 2\r\n\t\t\telse: \r\n\t\t\t\tL[i][j] = max(L[i][j-1], L[i+1][j]); \r\n\treturn L[0][n-1]" + ], + "split": "test" + }, + { + "Input": "Write a function to calculate the harmonic sum of n-1.", + "Output Program": [ + "def harmonic_sum(n):\r\n if n < 2:\r\n return 1\r\n else:\r\n return 1 / n + (harmonic_sum(n - 1)) ", + "def harmonic_sum(n):\r\n if n < 2:\r\n return 1\r\n else:\r\n return 1 / n + (harmonic_sum(n - 1))" + ], + "Output Answer": [ + "def harmonic_sum(n):\r\n if n < 2:\r\n return 1\r\n else:\r\n return 1 / n + (harmonic_sum(n - 1)) ", + "def harmonic_sum(n):\r\n if n < 2:\r\n return 1\r\n else:\r\n return 1 / n + (harmonic_sum(n - 1))" + ], + "split": "train" + }, + { + "Input": "Write a function to find the intersection of two arrays using lambda function.", + "Output Program": [ + "def intersection_array(array_nums1,array_nums2):\r\n result = list(filter(lambda x: x in array_nums1, array_nums2)) \r\n return result" + ], + "Output Answer": [ + "def intersection_array(array_nums1,array_nums2):\r\n result = list(filter(lambda x: x in array_nums1, array_nums2)) \r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a python function to count the occcurences of an element in a tuple.", + "Output Program": [ + "def count_X(tup, x): \r\n count = 0\r\n for ele in tup: \r\n if (ele == x): \r\n count = count + 1\r\n return count " + ], + "Output Answer": [ + "def count_X(tup, x): \r\n count = 0\r\n for ele in tup: \r\n if (ele == x): \r\n count = count + 1\r\n return count " + ], + "split": "test" + }, + { + "Input": "Write a function to insert an element before each element of a list.", + "Output Program": [ + "def insert_element(list,element):\r\n list = [v for elt in list for v in (element, elt)]\r\n return list" + ], + "Output Answer": [ + "def insert_element(list,element):\r\n list = [v for elt in list for v in (element, elt)]\r\n return list" + ], + "split": "test" + }, + { + "Input": "Write a python function to convert complex numbers to polar coordinates.", + "Output Program": [ + "import cmath \r\ndef convert(numbers): \r\n num = cmath.polar(numbers) \r\n return (num) " + ], + "Output Answer": [ + "import cmath \r\ndef convert(numbers): \r\n num = cmath.polar(numbers) \r\n return (num) " + ], + "split": "test" + }, + { + "Input": "Write a python function to count integers from a given list.", + "Output Program": [ + "def count_integer(list1):\r\n ctr = 0\r\n for i in list1:\r\n if isinstance(i, int):\r\n ctr = ctr + 1\r\n return ctr" + ], + "Output Answer": [ + "def count_integer(list1):\r\n ctr = 0\r\n for i in list1:\r\n if isinstance(i, int):\r\n ctr = ctr + 1\r\n return ctr" + ], + "split": "test" + }, + { + "Input": "Write a function to find all words starting with 'a' or 'e' in a given string.", + "Output Program": [ + "import re\r\ndef words_ae(text):\r\n list = re.findall(\"[ae]\\w+\", text)\r\n return list" + ], + "Output Answer": [ + "import re\r\ndef words_ae(text):\r\n list = re.findall(\"[ae]\\w+\", text)\r\n return list" + ], + "split": "test" + }, + { + "Input": "Write a function to choose specified number of colours from three different colours and generate all the combinations with repetitions.", + "Output Program": [ + "from itertools import combinations_with_replacement \r\ndef combinations_colors(l, n):\r\n return list(combinations_with_replacement(l,n))\r" + ], + "Output Answer": [ + "from itertools import combinations_with_replacement \r\ndef combinations_colors(l, n):\r\n return list(combinations_with_replacement(l,n))\r" + ], + "split": "test" + }, + { + "Input": "Write a python function to count the number of prime numbers less than a given non-negative number.", + "Output Program": [ + "def count_Primes_nums(n):\r\n ctr = 0\r\n for num in range(n):\r\n if num <= 1:\r\n continue\r\n for i in range(2,num):\r\n if (num % i) == 0:\r\n break\r\n else:\r\n ctr += 1\r\n return ctr" + ], + "Output Answer": [ + "def count_Primes_nums(n):\r\n ctr = 0\r\n for num in range(n):\r\n if num <= 1:\r\n continue\r\n for i in range(2,num):\r\n if (num % i) == 0:\r\n break\r\n else:\r\n ctr += 1\r\n return ctr" + ], + "split": "test" + }, + { + "Input": "Write a function to swap two numbers.", + "Output Program": [ + "def swap_numbers(a,b):\r\n temp = a\r\n a = b\r\n b = temp\r\n return (a,b)" + ], + "Output Answer": [ + "def swap_numbers(a,b):\r\n temp = a\r\n a = b\r\n b = temp\r\n return (a,b)" + ], + "split": "test" + }, + { + "Input": "Write a function to find number of odd elements in the given list using lambda function.", + "Output Program": [ + "def count_odd(array_nums):\r\n count_odd = len(list(filter(lambda x: (x%2 != 0) , array_nums)))\r\n return count_odd" + ], + "Output Answer": [ + "def count_odd(array_nums):\r\n count_odd = len(list(filter(lambda x: (x%2 != 0) , array_nums)))\r\n return count_odd" + ], + "split": "test" + }, + { + "Input": "Write a function to maximize the given two tuples.", + "Output Program": [ + "def maximize_elements(test_tup1, test_tup2):\r\n res = tuple(tuple(max(a, b) for a, b in zip(tup1, tup2))\r\n for tup1, tup2 in zip(test_tup1, test_tup2))\r\n return (res) " + ], + "Output Answer": [ + "def maximize_elements(test_tup1, test_tup2):\r\n res = tuple(tuple(max(a, b) for a, b in zip(tup1, tup2))\r\n for tup1, tup2 in zip(test_tup1, test_tup2))\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a function to find the nth newman\u2013shanks\u2013williams prime number.", + "Output Program": [ + "def newman_prime(n): \r\n\tif n == 0 or n == 1: \r\n\t\treturn 1\r\n\treturn 2 * newman_prime(n - 1) + newman_prime(n - 2)" + ], + "Output Answer": [ + "def newman_prime(n): \r\n\tif n == 0 or n == 1: \r\n\t\treturn 1\r\n\treturn 2 * newman_prime(n - 1) + newman_prime(n - 2)" + ], + "split": "test" + }, + { + "Input": "Write a function to perform mathematical division operation across the given tuples.", + "Output Program": [ + "def division_elements(test_tup1, test_tup2):\r\n res = tuple(ele1 // ele2 for ele1, ele2 in zip(test_tup1, test_tup2))\r\n return (res) " + ], + "Output Answer": [ + "def division_elements(test_tup1, test_tup2):\r\n res = tuple(ele1 // ele2 for ele1, ele2 in zip(test_tup1, test_tup2))\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a function to split a given list into two parts where the length of the first part of the list is given.", + "Output Program": [ + "def split_two_parts(list1, L):\r\n return list1[:L], list1[L:]" + ], + "Output Answer": [ + "def split_two_parts(list1, L):\r\n return list1[:L], list1[L:]" + ], + "split": "test" + }, + { + "Input": "Write a function to merge two dictionaries.", + "Output Program": [ + "def merge_dict(d1,d2):\r\n d = d1.copy()\r\n d.update(d2)\r\n return d" + ], + "Output Answer": [ + "def merge_dict(d1,d2):\r\n d = d1.copy()\r\n d.update(d2)\r\n return d" + ], + "split": "test" + }, + { + "Input": "Write a function to calculate a dog's age in dog's years.", + "Output Program": [ + "def dog_age(h_age):\r\n if h_age < 0:\r\n \texit()\r\n elif h_age <= 2:\r\n\t d_age = h_age * 10.5\r\n else:\r\n\t d_age = 21 + (h_age - 2)*4\r\n return d_age" + ], + "Output Answer": [ + "def dog_age(h_age):\r\n if h_age < 0:\r\n \texit()\r\n elif h_age <= 2:\r\n\t d_age = h_age * 10.5\r\n else:\r\n\t d_age = 21 + (h_age - 2)*4\r\n return d_age" + ], + "split": "test" + }, + { + "Input": "Write a function to split a list for every nth element.", + "Output Program": [ + "def list_split(S, step):\r\n return [S[i::step] for i in range(step)]" + ], + "Output Answer": [ + "def list_split(S, step):\r\n return [S[i::step] for i in range(step)]" + ], + "split": "test" + }, + { + "Input": "Write a function to find the lateral surface area of a cube.", + "Output Program": [ + "def lateralsurface_cube(l):\r\n LSA = 4 * (l * l)\r\n return LSA" + ], + "Output Answer": [ + "def lateralsurface_cube(l):\r\n LSA = 4 * (l * l)\r\n return LSA" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the sum of squares of first n odd natural numbers.", + "Output Program": [ + "def square_Sum(n): \r\n return int(n*(4*n*n-1)/3) " + ], + "Output Answer": [ + "def square_Sum(n): \r\n return int(n*(4*n*n-1)/3) " + ], + "split": "test" + }, + { + "Input": "Write a function to find the n'th star number.", + "Output Program": [ + "def find_star_num(n): \r\n\treturn (6 * n * (n - 1) + 1) " + ], + "Output Answer": [ + "def find_star_num(n): \r\n\treturn (6 * n * (n - 1) + 1) " + ], + "split": "test" + }, + { + "Input": "Write a function to find the ascii value of a character.", + "Output Program": [ + "def ascii_value(k):\r\n ch=k\r\n return ord(ch)" + ], + "Output Answer": [ + "def ascii_value(k):\r\n ch=k\r\n return ord(ch)" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the sum of even numbers at even positions.", + "Output Program": [ + "def sum_even_and_even_index(arr,n): \r\n i = 0\r\n sum = 0\r\n for i in range(0,n,2): \r\n if (arr[i] % 2 == 0) : \r\n sum += arr[i] \r\n return sum" + ], + "Output Answer": [ + "def sum_even_and_even_index(arr,n): \r\n i = 0\r\n sum = 0\r\n for i in range(0,n,2): \r\n if (arr[i] % 2 == 0) : \r\n sum += arr[i] \r\n return sum" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the sum of fifth power of first n even natural numbers.", + "Output Program": [ + "def even_Power_Sum(n): \r\n sum = 0; \r\n for i in range(1,n+1): \r\n j = 2*i; \r\n sum = sum + (j*j*j*j*j); \r\n return sum; " + ], + "Output Answer": [ + "def even_Power_Sum(n): \r\n sum = 0; \r\n for i in range(1,n+1): \r\n j = 2*i; \r\n sum = sum + (j*j*j*j*j); \r\n return sum; " + ], + "split": "test" + }, + { + "Input": "Write a function to perfom the rear element extraction from list of tuples records.", + "Output Program": [ + "def rear_extract(test_list):\r\n res = [lis[-1] for lis in test_list]\r\n return (res) " + ], + "Output Answer": [ + "def rear_extract(test_list):\r\n res = [lis[-1] for lis in test_list]\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a function to substract the contents of one tuple with corresponding index of other tuple.", + "Output Program": [ + "def substract_elements(test_tup1, test_tup2):\r\n res = tuple(map(lambda i, j: i - j, test_tup1, test_tup2))\r\n return (res) " + ], + "Output Answer": [ + "def substract_elements(test_tup1, test_tup2):\r\n res = tuple(map(lambda i, j: i - j, test_tup1, test_tup2))\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a python function to find sum of even index binomial coefficients.", + "Output Program": [ + "import math \r\ndef even_binomial_Coeff_Sum( n): \r\n return (1 << (n - 1)) " + ], + "Output Answer": [ + "import math \r\ndef even_binomial_Coeff_Sum( n): \r\n return (1 << (n - 1)) " + ], + "split": "test" + }, + { + "Input": "Write a python function to find the position of the last removed element from the given array.", + "Output Program": [ + "import math as mt \r\ndef get_Position(a,n,m): \r\n for i in range(n): \r\n a[i] = (a[i] // m + (a[i] % m != 0)) \r\n result,maxx = -1,-1\r\n for i in range(n - 1,-1,-1): \r\n if (maxx < a[i]): \r\n maxx = a[i] \r\n result = i \r\n return result + 1" + ], + "Output Answer": [ + "import math as mt \r\ndef get_Position(a,n,m): \r\n for i in range(n): \r\n a[i] = (a[i] // m + (a[i] % m != 0)) \r\n result,maxx = -1,-1\r\n for i in range(n - 1,-1,-1): \r\n if (maxx < a[i]): \r\n maxx = a[i] \r\n result = i \r\n return result + 1" + ], + "split": "test" + }, + { + "Input": "Write a function to find the volume of a cylinder.", + "Output Program": [ + "def volume_cylinder(r,h):\r\n volume=3.1415*r*r*h\r\n return volume" + ], + "Output Answer": [ + "def volume_cylinder(r,h):\r\n volume=3.1415*r*r*h\r\n return volume" + ], + "split": "test" + }, + { + "Input": "Write a function to filter a dictionary based on values.", + "Output Program": [ + "def dict_filter(dict,n):\r\n result = {key:value for (key, value) in dict.items() if value >=n}\r\n return result" + ], + "Output Answer": [ + "def dict_filter(dict,n):\r\n result = {key:value for (key, value) in dict.items() if value >=n}\r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a function to find the element count that occurs before the record in the given tuple.", + "Output Program": [ + "def count_first_elements(test_tup):\r\n for count, ele in enumerate(test_tup):\r\n if isinstance(ele, tuple):\r\n break\r\n return (count) " + ], + "Output Answer": [ + "def count_first_elements(test_tup):\r\n for count, ele in enumerate(test_tup):\r\n if isinstance(ele, tuple):\r\n break\r\n return (count) " + ], + "split": "test" + }, + { + "Input": "Write a function to find the nth decagonal number.", + "Output Program": [ + "def is_num_decagonal(n): \r\n\treturn 4 * n * n - 3 * n " + ], + "Output Answer": [ + "def is_num_decagonal(n): \r\n\treturn 4 * n * n - 3 * n " + ], + "split": "test" + }, + { + "Input": "Write a function to search an element in the given array by using sequential search.", + "Output Program": [ + "def sequential_search(dlist, item):\r\n pos = 0\r\n found = False\r\n while pos < len(dlist) and not found:\r\n if dlist[pos] == item:\r\n found = True\r\n else:\r\n pos = pos + 1\r\n return found, pos" + ], + "Output Answer": [ + "def sequential_search(dlist, item):\r\n pos = 0\r\n found = False\r\n while pos < len(dlist) and not found:\r\n if dlist[pos] == item:\r\n found = True\r\n else:\r\n pos = pos + 1\r\n return found, pos" + ], + "split": "test" + }, + { + "Input": "Write a python function to check if the elements of a given list are unique or not.", + "Output Program": [ + "def all_unique(test_list):\r\n if len(test_list) > len(set(test_list)):\r\n return False\r\n return True" + ], + "Output Answer": [ + "def all_unique(test_list):\r\n if len(test_list) > len(set(test_list)):\r\n return False\r\n return True" + ], + "split": "test" + }, + { + "Input": "Write a function to substaract two lists using map and lambda function.", + "Output Program": [ + "def sub_list(nums1,nums2):\r\n result = map(lambda x, y: x - y, nums1, nums2)\r\n return list(result)" + ], + "Output Answer": [ + "def sub_list(nums1,nums2):\r\n result = map(lambda x, y: x - y, nums1, nums2)\r\n return list(result)" + ], + "split": "test" + }, + { + "Input": "Write a python function to check whether the frequency of each digit is less than or equal to the digit itself.", + "Output Program": [ + "def validate(n): \r\n for i in range(10): \r\n temp = n; \r\n count = 0; \r\n while (temp): \r\n if (temp % 10 == i): \r\n count+=1; \r\n if (count > i): \r\n return False\r\n temp //= 10; \r\n return True" + ], + "Output Answer": [ + "def validate(n): \r\n for i in range(10): \r\n temp = n; \r\n count = 0; \r\n while (temp): \r\n if (temp % 10 == i): \r\n count+=1; \r\n if (count > i): \r\n return False\r\n temp //= 10; \r\n return True" + ], + "split": "test" + }, + { + "Input": "Write a function to check whether all items of a list are equal to a given string.", + "Output Program": [ + "def check_element(list,element):\r\n check_element=all(v== element for v in list)\r\n return check_element" + ], + "Output Answer": [ + "def check_element(list,element):\r\n check_element=all(v== element for v in list)\r\n return check_element" + ], + "split": "test" + }, + { + "Input": "Write a function that matches a string that has an a followed by two to three 'b'.", + "Output Program": [ + "import re\r\ndef text_match_two_three(text):\r\n patterns = 'ab{2,3}'\r\n if re.search(patterns, text):\r\n return 'Found a match!'\r\n else:\r\n return('Not matched!')" + ], + "Output Answer": [ + "import re\r\ndef text_match_two_three(text):\r\n patterns = 'ab{2,3}'\r\n if re.search(patterns, text):\r\n return 'Found a match!'\r\n else:\r\n return('Not matched!')" + ], + "split": "test" + }, + { + "Input": "Write a function to find the largest sum of contiguous array in the modified array which is formed by repeating the given array k times.", + "Output Program": [ + "def max_sub_array_sum_repeated(a, n, k): \r\n\tmax_so_far = -2147483648\r\n\tmax_ending_here = 0\r\n\tfor i in range(n*k): \r\n\t\tmax_ending_here = max_ending_here + a[i%n] \r\n\t\tif (max_so_far < max_ending_here): \r\n\t\t\tmax_so_far = max_ending_here \r\n\t\tif (max_ending_here < 0): \r\n\t\t\tmax_ending_here = 0\r\n\treturn max_so_far" + ], + "Output Answer": [ + "def max_sub_array_sum_repeated(a, n, k): \r\n\tmax_so_far = -2147483648\r\n\tmax_ending_here = 0\r\n\tfor i in range(n*k): \r\n\t\tmax_ending_here = max_ending_here + a[i%n] \r\n\t\tif (max_so_far < max_ending_here): \r\n\t\t\tmax_so_far = max_ending_here \r\n\t\tif (max_ending_here < 0): \r\n\t\t\tmax_ending_here = 0\r\n\treturn max_so_far" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the sum of squares of first n even natural numbers.", + "Output Program": [ + "def square_Sum(n): \r\n return int(2*n*(n+1)*(2*n+1)/3)" + ], + "Output Answer": [ + "def square_Sum(n): \r\n return int(2*n*(n+1)*(2*n+1)/3)" + ], + "split": "test" + }, + { + "Input": "Write a function to count array elements having modular inverse under given prime number p equal to itself.", + "Output Program": [ + "def modular_inverse(arr, N, P):\r\n\tcurrent_element = 0\r\n\tfor i in range(0, N):\r\n\t\tif ((arr[i] * arr[i]) % P == 1):\r\n\t\t\tcurrent_element = current_element + 1\r\n\treturn current_element" + ], + "Output Answer": [ + "def modular_inverse(arr, N, P):\r\n\tcurrent_element = 0\r\n\tfor i in range(0, N):\r\n\t\tif ((arr[i] * arr[i]) % P == 1):\r\n\t\t\tcurrent_element = current_element + 1\r\n\treturn current_element" + ], + "split": "test" + }, + { + "Input": "Write a python function to calculate the number of odd days in a given year.", + "Output Program": [ + "def odd_Days(N): \r\n hund1 = N // 100\r\n hund4 = N // 400\r\n leap = N >> 2\r\n ordd = N - leap \r\n if (hund1): \r\n ordd += hund1 \r\n leap -= hund1 \r\n if (hund4): \r\n ordd -= hund4 \r\n leap += hund4 \r\n days = ordd + leap * 2\r\n odd = days % 7\r\n return odd " + ], + "Output Answer": [ + "def odd_Days(N): \r\n hund1 = N // 100\r\n hund4 = N // 400\r\n leap = N >> 2\r\n ordd = N - leap \r\n if (hund1): \r\n ordd += hund1 \r\n leap -= hund1 \r\n if (hund4): \r\n ordd -= hund4 \r\n leap += hund4 \r\n days = ordd + leap * 2\r\n odd = days % 7\r\n return odd " + ], + "split": "test" + }, + { + "Input": "Write a function to find the list of lists with maximum length.", + "Output Program": [ + "def max_length(list1):\r\n max_length = max(len(x) for x in list1 ) \r\n max_list = max((x) for x in list1)\r\n return(max_length, max_list)" + ], + "Output Answer": [ + "def max_length(list1):\r\n max_length = max(len(x) for x in list1 ) \r\n max_list = max((x) for x in list1)\r\n return(max_length, max_list)" + ], + "split": "test" + }, + { + "Input": "Write 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.", + "Output Program": [ + "def count_no_of_ways(n, k): \r\n\tdp = [0] * (n + 1) \r\n\ttotal = k \r\n\tmod = 1000000007\r\n\tdp[1] = k \r\n\tdp[2] = k * k\t \r\n\tfor i in range(3,n+1): \r\n\t\tdp[i] = ((k - 1) * (dp[i - 1] + dp[i - 2])) % mod \r\n\treturn dp[n]" + ], + "Output Answer": [ + "def count_no_of_ways(n, k): \r\n\tdp = [0] * (n + 1) \r\n\ttotal = k \r\n\tmod = 1000000007\r\n\tdp[1] = k \r\n\tdp[2] = k * k\t \r\n\tfor i in range(3,n+1): \r\n\t\tdp[i] = ((k - 1) * (dp[i - 1] + dp[i - 2])) % mod \r\n\treturn dp[n]" + ], + "split": "test" + }, + { + "Input": "Write a python function to find quotient of two numbers.", + "Output Program": [ + "def find(n,m): \r\n q = n//m \r\n return (q)" + ], + "Output Answer": [ + "def find(n,m): \r\n q = n//m \r\n return (q)" + ], + "split": "test" + }, + { + "Input": "Write a function to find the third side of a right angled triangle.", + "Output Program": [ + "import math\r\ndef otherside_rightangle(w,h):\r\n s=math.sqrt((w*w)+(h*h))\r\n return s" + ], + "Output Answer": [ + "import math\r\ndef otherside_rightangle(w,h):\r\n s=math.sqrt((w*w)+(h*h))\r\n return s" + ], + "split": "test" + }, + { + "Input": "Write a function to find the maximum value in a given heterogeneous list.", + "Output Program": [ + "def max_val(listval):\r\n max_val = max(i for i in listval if isinstance(i, int)) \r\n return(max_val)" + ], + "Output Answer": [ + "def max_val(listval):\r\n max_val = max(i for i in listval if isinstance(i, int)) \r\n return(max_val)" + ], + "split": "test" + }, + { + "Input": "Write a function to return the sum of all divisors of a number.", + "Output Program": [ + "def sum_div(number):\r\n divisors = [1]\r\n for i in range(2, number):\r\n if (number % i)==0:\r\n divisors.append(i)\r\n return sum(divisors)" + ], + "Output Answer": [ + "def sum_div(number):\r\n divisors = [1]\r\n for i in range(2, number):\r\n if (number % i)==0:\r\n divisors.append(i)\r\n return sum(divisors)" + ], + "split": "test" + }, + { + "Input": "Write a python function to count inversions in an array.", + "Output Program": [ + "def get_Inv_Count(arr,n): \r\n inv_count = 0\r\n for i in range(n): \r\n for j in range(i + 1,n): \r\n if (arr[i] > arr[j]): \r\n inv_count += 1\r\n return inv_count " + ], + "Output Answer": [ + "def get_Inv_Count(arr,n): \r\n inv_count = 0\r\n for i in range(n): \r\n for j in range(i + 1,n): \r\n if (arr[i] > arr[j]): \r\n inv_count += 1\r\n return inv_count " + ], + "split": "test" + }, + { + "Input": "Write a function to flatten a given nested list structure.", + "Output Program": [ + "def flatten_list(list1):\r\n result_list = []\r\n if not list1: return result_list\r\n stack = [list(list1)]\r\n while stack:\r\n c_num = stack.pop()\r\n next = c_num.pop()\r\n if c_num: stack.append(c_num)\r\n if isinstance(next, list):\r\n if next: stack.append(list(next))\r\n else: result_list.append(next)\r\n result_list.reverse()\r\n return result_list " + ], + "Output Answer": [ + "def flatten_list(list1):\r\n result_list = []\r\n if not list1: return result_list\r\n stack = [list(list1)]\r\n while stack:\r\n c_num = stack.pop()\r\n next = c_num.pop()\r\n if c_num: stack.append(c_num)\r\n if isinstance(next, list):\r\n if next: stack.append(list(next))\r\n else: result_list.append(next)\r\n result_list.reverse()\r\n return result_list " + ], + "split": "test" + }, + { + "Input": "Write a function to find the nested list elements which are present in another list.", + "Output Program": [ + "def intersection_nested_lists(l1, l2):\r\n result = [[n for n in lst if n in l1] for lst in l2]\r\n return result" + ], + "Output Answer": [ + "def intersection_nested_lists(l1, l2):\r\n result = [[n for n in lst if n in l1] for lst in l2]\r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a function to calculate the maximum aggregate from the list of tuples.", + "Output Program": [ + "from collections import defaultdict\r\ndef max_aggregate(stdata):\r\n temp = defaultdict(int)\r\n for name, marks in stdata:\r\n temp[name] += marks\r\n return max(temp.items(), key=lambda x: x[1])" + ], + "Output Answer": [ + "from collections import defaultdict\r\ndef max_aggregate(stdata):\r\n temp = defaultdict(int)\r\n for name, marks in stdata:\r\n temp[name] += marks\r\n return max(temp.items(), key=lambda x: x[1])" + ], + "split": "test" + }, + { + "Input": "Write 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.", + "Output Program": [ + "def count_binary_seq(n): \r\n\tnCr = 1\r\n\tres = 1\r\n\tfor r in range(1, n + 1): \r\n\t\tnCr = (nCr * (n + 1 - r)) / r \r\n\t\tres += nCr * nCr \r\n\treturn res " + ], + "Output Answer": [ + "def count_binary_seq(n): \r\n\tnCr = 1\r\n\tres = 1\r\n\tfor r in range(1, n + 1): \r\n\t\tnCr = (nCr * (n + 1 - r)) / r \r\n\t\tres += nCr * nCr \r\n\treturn res " + ], + "split": "test" + }, + { + "Input": "Write a function to find the depth of a dictionary.", + "Output Program": [ + "def dict_depth(d):\r\n if isinstance(d, dict):\r\n return 1 + (max(map(dict_depth, d.values())) if d else 0)\r\n return 0" + ], + "Output Answer": [ + "def dict_depth(d):\r\n if isinstance(d, dict):\r\n return 1 + (max(map(dict_depth, d.values())) if d else 0)\r\n return 0" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the most significant bit number which is also a set bit.", + "Output Program": [ + "def set_Bit_Number(n): \r\n if (n == 0): \r\n return 0; \r\n msb = 0; \r\n n = int(n / 2); \r\n while (n > 0): \r\n n = int(n / 2); \r\n msb += 1; \r\n return (1 << msb)" + ], + "Output Answer": [ + "def set_Bit_Number(n): \r\n if (n == 0): \r\n return 0; \r\n msb = 0; \r\n n = int(n / 2); \r\n while (n > 0): \r\n n = int(n / 2); \r\n msb += 1; \r\n return (1 << msb)" + ], + "split": "test" + }, + { + "Input": "Write a python function to check whether the count of inversion of two types are same or not.", + "Output Program": [ + "import sys \r\ndef solve(a,n): \r\n mx = -sys.maxsize - 1\r\n for j in range(1,n): \r\n if (mx > a[j]): \r\n return False \r\n mx = max(mx,a[j - 1]) \r\n return True" + ], + "Output Answer": [ + "import sys \r\ndef solve(a,n): \r\n mx = -sys.maxsize - 1\r\n for j in range(1,n): \r\n if (mx > a[j]): \r\n return False \r\n mx = max(mx,a[j - 1]) \r\n return True" + ], + "split": "test" + }, + { + "Input": "Write a python function to find element at a given index after number of rotations.", + "Output Program": [ + "def find_Element(arr,ranges,rotations,index) : \r\n for i in range(rotations - 1,-1,-1 ) : \r\n left = ranges[i][0] \r\n right = ranges[i][1] \r\n if (left <= index and right >= index) : \r\n if (index == left) : \r\n index = right \r\n else : \r\n index = index - 1 \r\n return arr[index] " + ], + "Output Answer": [ + "def find_Element(arr,ranges,rotations,index) : \r\n for i in range(rotations - 1,-1,-1 ) : \r\n left = ranges[i][0] \r\n right = ranges[i][1] \r\n if (left <= index and right >= index) : \r\n if (index == left) : \r\n index = right \r\n else : \r\n index = index - 1 \r\n return arr[index] " + ], + "split": "test" + }, + { + "Input": "Write a function to match two words from a list of words starting with letter 'p'.", + "Output Program": [ + "import re\r\ndef start_withp(words):\r\n for w in words:\r\n m = re.match(\"(P\\w+)\\W(P\\w+)\", w)\r\n if m:\r\n return m.groups()" + ], + "Output Answer": [ + "import re\r\ndef start_withp(words):\r\n for w in words:\r\n m = re.match(\"(P\\w+)\\W(P\\w+)\", w)\r\n if m:\r\n return m.groups()" + ], + "split": "test" + }, + { + "Input": "Write 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 .", + "Output Program": [ + "def max_sum_increasing_subseq(a, n, index, k):\r\n\tdp = [[0 for i in range(n)] \r\n\t\t\tfor i in range(n)]\r\n\tfor i in range(n):\r\n\t\tif a[i] > a[0]:\r\n\t\t\tdp[0][i] = a[i] + a[0]\r\n\t\telse:\r\n\t\t\tdp[0][i] = a[i]\r\n\tfor i in range(1, n):\r\n\t\tfor j in range(n):\r\n\t\t\tif a[j] > a[i] and j > i:\r\n\t\t\t\tif dp[i - 1][i] + a[j] > dp[i - 1][j]:\r\n\t\t\t\t\tdp[i][j] = dp[i - 1][i] + a[j]\r\n\t\t\t\telse:\r\n\t\t\t\t\tdp[i][j] = dp[i - 1][j]\r\n\t\t\telse:\r\n\t\t\t\tdp[i][j] = dp[i - 1][j]\r\n\treturn dp[index][k]" + ], + "Output Answer": [ + "def max_sum_increasing_subseq(a, n, index, k):\r\n\tdp = [[0 for i in range(n)] \r\n\t\t\tfor i in range(n)]\r\n\tfor i in range(n):\r\n\t\tif a[i] > a[0]:\r\n\t\t\tdp[0][i] = a[i] + a[0]\r\n\t\telse:\r\n\t\t\tdp[0][i] = a[i]\r\n\tfor i in range(1, n):\r\n\t\tfor j in range(n):\r\n\t\t\tif a[j] > a[i] and j > i:\r\n\t\t\t\tif dp[i - 1][i] + a[j] > dp[i - 1][j]:\r\n\t\t\t\t\tdp[i][j] = dp[i - 1][i] + a[j]\r\n\t\t\t\telse:\r\n\t\t\t\t\tdp[i][j] = dp[i - 1][j]\r\n\t\t\telse:\r\n\t\t\t\tdp[i][j] = dp[i - 1][j]\r\n\treturn dp[index][k]" + ], + "split": "test" + }, + { + "Input": "Write a function to get a colon of a tuple.", + "Output Program": [ + "from copy import deepcopy\r\ndef colon_tuplex(tuplex,m,n):\r\n tuplex_colon = deepcopy(tuplex)\r\n tuplex_colon[m].append(n)\r\n return tuplex_colon" + ], + "Output Answer": [ + "from copy import deepcopy\r\ndef colon_tuplex(tuplex,m,n):\r\n tuplex_colon = deepcopy(tuplex)\r\n tuplex_colon[m].append(n)\r\n return tuplex_colon" + ], + "split": "test" + }, + { + "Input": "Write a function to find the specified number of largest products from two given lists.", + "Output Program": [ + "def large_product(nums1, nums2, N):\r\n result = sorted([x*y for x in nums1 for y in nums2], reverse=True)[:N]\r\n return result" + ], + "Output Answer": [ + "def large_product(nums1, nums2, N):\r\n result = sorted([x*y for x in nums1 for y in nums2], reverse=True)[:N]\r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the maximum of two numbers.", + "Output Program": [ + "def maximum(a,b): \r\n if a >= b: \r\n return a \r\n else: \r\n return b " + ], + "Output Answer": [ + "def maximum(a,b): \r\n if a >= b: \r\n return a \r\n else: \r\n return b " + ], + "split": "test" + }, + { + "Input": "Write a function to convert a given string to a tuple.", + "Output Program": [ + "def string_to_tuple(str1):\r\n result = tuple(x for x in str1 if not x.isspace()) \r\n return result" + ], + "Output Answer": [ + "def string_to_tuple(str1):\r\n result = tuple(x for x in str1 if not x.isspace()) \r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a python function to set the left most unset bit.", + "Output Program": [ + "def set_left_most_unset_bit(n): \r\n if not (n & (n + 1)): \r\n return n \r\n pos, temp, count = 0, n, 0 \r\n while temp: \r\n if not (temp & 1): \r\n pos = count \r\n count += 1; temp>>=1\r\n return (n | (1 << (pos))) " + ], + "Output Answer": [ + "def set_left_most_unset_bit(n): \r\n if not (n & (n + 1)): \r\n return n \r\n pos, temp, count = 0, n, 0 \r\n while temp: \r\n if not (temp & 1): \r\n pos = count \r\n count += 1; temp>>=1\r\n return (n | (1 << (pos))) " + ], + "split": "test" + }, + { + "Input": "Write a function to find the volume of a cone.", + "Output Program": [ + "import math\r\ndef volume_cone(r,h):\r\n volume = (1.0/3) * math.pi * r * r * h\r\n return volume" + ], + "Output Answer": [ + "import math\r\ndef volume_cone(r,h):\r\n volume = (1.0/3) * math.pi * r * r * h\r\n return volume" + ], + "split": "test" + }, + { + "Input": "Write a python function to print positive numbers in a list.", + "Output Program": [ + "def pos_nos(list1):\r\n for num in list1: \r\n if num >= 0: \r\n return num " + ], + "Output Answer": [ + "def pos_nos(list1):\r\n for num in list1: \r\n if num >= 0: \r\n return num " + ], + "split": "test" + }, + { + "Input": "Write 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.", + "Output Program": [ + "def max_sum_rectangular_grid(grid, n) : \r\n\tincl = max(grid[0][0], grid[1][0]) \r\n\texcl = 0\r\n\tfor i in range(1, n) : \r\n\t\texcl_new = max(excl, incl) \r\n\t\tincl = excl + max(grid[0][i], grid[1][i]) \r\n\t\texcl = excl_new \r\n\treturn max(excl, incl)" + ], + "Output Answer": [ + "def max_sum_rectangular_grid(grid, n) : \r\n\tincl = max(grid[0][0], grid[1][0]) \r\n\texcl = 0\r\n\tfor i in range(1, n) : \r\n\t\texcl_new = max(excl, incl) \r\n\t\tincl = excl + max(grid[0][i], grid[1][i]) \r\n\t\texcl = excl_new \r\n\treturn max(excl, incl)" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the first maximum length of even word.", + "Output Program": [ + "def find_Max_Len_Even(str): \r\n n = len(str) \r\n i = 0\r\n currlen = 0\r\n maxlen = 0\r\n st = -1\r\n while (i < n): \r\n if (str[i] == ' '): \r\n if (currlen % 2 == 0): \r\n if (maxlen < currlen): \r\n maxlen = currlen \r\n st = i - currlen \r\n currlen = 0 \r\n else : \r\n currlen += 1\r\n i += 1\r\n if (currlen % 2 == 0): \r\n if (maxlen < currlen): \r\n maxlen = currlen \r\n st = i - currlen \r\n if (st == -1): \r\n return \"-1\" \r\n return str[st: st + maxlen] " + ], + "Output Answer": [ + "def find_Max_Len_Even(str): \r\n n = len(str) \r\n i = 0\r\n currlen = 0\r\n maxlen = 0\r\n st = -1\r\n while (i < n): \r\n if (str[i] == ' '): \r\n if (currlen % 2 == 0): \r\n if (maxlen < currlen): \r\n maxlen = currlen \r\n st = i - currlen \r\n currlen = 0 \r\n else : \r\n currlen += 1\r\n i += 1\r\n if (currlen % 2 == 0): \r\n if (maxlen < currlen): \r\n maxlen = currlen \r\n st = i - currlen \r\n if (st == -1): \r\n return \"-1\" \r\n return str[st: st + maxlen] " + ], + "split": "test" + }, + { + "Input": "Write a function to find the index of the last occurrence of a given number in a sorted array.", + "Output Program": [ + "def find_last_occurrence(A, x):\r\n (left, right) = (0, len(A) - 1)\r\n result = -1\r\n while left <= right:\r\n mid = (left + right) // 2\r\n if x == A[mid]:\r\n result = mid\r\n left = mid + 1\r\n elif x < A[mid]:\r\n right = mid - 1\r\n else:\r\n left = mid + 1\r\n return result " + ], + "Output Answer": [ + "def find_last_occurrence(A, x):\r\n (left, right) = (0, len(A) - 1)\r\n result = -1\r\n while left <= right:\r\n mid = (left + right) // 2\r\n if x == A[mid]:\r\n result = mid\r\n left = mid + 1\r\n elif x < A[mid]:\r\n right = mid - 1\r\n else:\r\n left = mid + 1\r\n return result " + ], + "split": "test" + }, + { + "Input": "Write a function to reflect the modified run-length encoding from a list.", + "Output Program": [ + "from itertools import groupby\r\ndef modified_encode(alist):\r\n def ctr_ele(el):\r\n if len(el)>1: return [len(el), el[0]]\r\n else: return el[0]\r\n return [ctr_ele(list(group)) for key, group in groupby(alist)]" + ], + "Output Answer": [ + "from itertools import groupby\r\ndef modified_encode(alist):\r\n def ctr_ele(el):\r\n if len(el)>1: return [len(el), el[0]]\r\n else: return el[0]\r\n return [ctr_ele(list(group)) for key, group in groupby(alist)]" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the maximum volume of a cuboid with given sum of sides.", + "Output Program": [ + "def max_volume (s): \r\n maxvalue = 0\r\n i = 1\r\n for i in range(s - 1): \r\n j = 1\r\n for j in range(s): \r\n k = s - i - j \r\n maxvalue = max(maxvalue, i * j * k) \r\n return maxvalue " + ], + "Output Answer": [ + "def max_volume (s): \r\n maxvalue = 0\r\n i = 1\r\n for i in range(s - 1): \r\n j = 1\r\n for j in range(s): \r\n k = s - i - j \r\n maxvalue = max(maxvalue, i * j * k) \r\n return maxvalue " + ], + "split": "test" + }, + { + "Input": "Write a function to find all five characters long word in the given string by using regex.", + "Output Program": [ + "import re\r\ndef find_long_word(text):\r\n return (re.findall(r\"\\b\\w{5}\\b\", text))" + ], + "Output Answer": [ + "import re\r\ndef find_long_word(text):\r\n return (re.findall(r\"\\b\\w{5}\\b\", text))" + ], + "split": "test" + }, + { + "Input": "Write a function to calculate the difference between the squared sum of first n natural numbers and the sum of squared first n natural numbers.", + "Output Program": [ + "def sum_difference(n):\r\n sumofsquares = 0\r\n squareofsum = 0\r\n for num in range(1, n+1):\r\n sumofsquares += num * num\r\n squareofsum += num\r\n squareofsum = squareofsum ** 2\r\n return squareofsum - sumofsquares" + ], + "Output Answer": [ + "def sum_difference(n):\r\n sumofsquares = 0\r\n squareofsum = 0\r\n for num in range(1, n+1):\r\n sumofsquares += num * num\r\n squareofsum += num\r\n squareofsum = squareofsum ** 2\r\n return squareofsum - sumofsquares" + ], + "split": "test" + }, + { + "Input": "Write a function to find the demlo number for the given number.", + "Output Program": [ + "def find_demlo(s): \r\n\tl = len(s) \r\n\tres = \"\" \r\n\tfor i in range(1,l+1): \r\n\t\tres = res + str(i) \r\n\tfor i in range(l-1,0,-1): \r\n\t\tres = res + str(i) \r\n\treturn res \t" + ], + "Output Answer": [ + "def find_demlo(s): \r\n\tl = len(s) \r\n\tres = \"\" \r\n\tfor i in range(1,l+1): \r\n\t\tres = res + str(i) \r\n\tfor i in range(l-1,0,-1): \r\n\t\tres = res + str(i) \r\n\treturn res \t" + ], + "split": "test" + }, + { + "Input": "Write a function to find all index positions of the minimum values in a given list.", + "Output Program": [ + "def position_min(list1):\r\n min_val = min(list1)\r\n min_result = [i for i, j in enumerate(list1) if j == min_val]\r\n return min_result" + ], + "Output Answer": [ + "def position_min(list1):\r\n min_val = min(list1)\r\n min_result = [i for i, j in enumerate(list1) if j == min_val]\r\n return min_result" + ], + "split": "test" + }, + { + "Input": "Write a function to re-arrange the given array in alternating positive and negative items.", + "Output Program": [ + "def right_rotate(arr, n, out_of_place, cur):\r\n\ttemp = arr[cur]\r\n\tfor i in range(cur, out_of_place, -1):\r\n\t\tarr[i] = arr[i - 1]\r\n\tarr[out_of_place] = temp\r\n\treturn arr\r\ndef re_arrange(arr, n):\r\n\tout_of_place = -1\r\n\tfor index in range(n):\r\n\t\tif (out_of_place >= 0):\r\n\t\t\tif ((arr[index] >= 0 and arr[out_of_place] < 0) or\r\n\t\t\t(arr[index] < 0 and arr[out_of_place] >= 0)):\r\n\t\t\t\tarr = right_rotate(arr, n, out_of_place, index)\r\n\t\t\t\tif (index-out_of_place > 2):\r\n\t\t\t\t\tout_of_place += 2\r\n\t\t\t\telse:\r\n\t\t\t\t\tout_of_place = - 1\r\n\t\tif (out_of_place == -1):\r\n\t\t\tif ((arr[index] >= 0 and index % 2 == 0) or\r\n\t\t\t (arr[index] < 0 and index % 2 == 1)):\r\n\t\t\t\tout_of_place = index\r\n\treturn arr" + ], + "Output Answer": [ + "def right_rotate(arr, n, out_of_place, cur):\r\n\ttemp = arr[cur]\r\n\tfor i in range(cur, out_of_place, -1):\r\n\t\tarr[i] = arr[i - 1]\r\n\tarr[out_of_place] = temp\r\n\treturn arr\r\ndef re_arrange(arr, n):\r\n\tout_of_place = -1\r\n\tfor index in range(n):\r\n\t\tif (out_of_place >= 0):\r\n\t\t\tif ((arr[index] >= 0 and arr[out_of_place] < 0) or\r\n\t\t\t(arr[index] < 0 and arr[out_of_place] >= 0)):\r\n\t\t\t\tarr = right_rotate(arr, n, out_of_place, index)\r\n\t\t\t\tif (index-out_of_place > 2):\r\n\t\t\t\t\tout_of_place += 2\r\n\t\t\t\telse:\r\n\t\t\t\t\tout_of_place = - 1\r\n\t\tif (out_of_place == -1):\r\n\t\t\tif ((arr[index] >= 0 and index % 2 == 0) or\r\n\t\t\t (arr[index] < 0 and index % 2 == 1)):\r\n\t\t\t\tout_of_place = index\r\n\treturn arr" + ], + "split": "test" + }, + { + "Input": "Write a function to extract the sum of alternate chains of tuples.", + "Output Program": [ + "def sum_of_alternates(test_tuple):\r\n sum1 = 0\r\n sum2 = 0\r\n for idx, ele in enumerate(test_tuple):\r\n if idx % 2:\r\n sum1 += ele\r\n else:\r\n sum2 += ele\r\n return ((sum1),(sum2)) " + ], + "Output Answer": [ + "def sum_of_alternates(test_tuple):\r\n sum1 = 0\r\n sum2 = 0\r\n for idx, ele in enumerate(test_tuple):\r\n if idx % 2:\r\n sum1 += ele\r\n else:\r\n sum2 += ele\r\n return ((sum1),(sum2)) " + ], + "split": "test" + }, + { + "Input": "Write a python function to find the minimum number of squares whose sum is equal to a given number.", + "Output Program": [ + "def get_Min_Squares(n):\r\n if n <= 3:\r\n return n;\r\n res = n \r\n for x in range(1,n + 1):\r\n temp = x * x;\r\n if temp > n:\r\n break\r\n else:\r\n res = min(res,1 + get_Min_Squares(n - temp)) \r\n return res;" + ], + "Output Answer": [ + "def get_Min_Squares(n):\r\n if n <= 3:\r\n return n;\r\n res = n \r\n for x in range(1,n + 1):\r\n temp = x * x;\r\n if temp > n:\r\n break\r\n else:\r\n res = min(res,1 + get_Min_Squares(n - temp)) \r\n return res;" + ], + "split": "test" + }, + { + "Input": "Write a function to get the word with most number of occurrences in the given strings list.", + "Output Program": [ + "from collections import defaultdict \r\n\r\ndef most_occurrences(test_list):\r\n temp = defaultdict(int)\r\n for sub in test_list:\r\n for wrd in sub.split():\r\n temp[wrd] += 1\r\n res = max(temp, key=temp.get)\r\n return (str(res)) " + ], + "Output Answer": [ + "from collections import defaultdict \r\n\r\ndef most_occurrences(test_list):\r\n temp = defaultdict(int)\r\n for sub in test_list:\r\n for wrd in sub.split():\r\n temp[wrd] += 1\r\n res = max(temp, key=temp.get)\r\n return (str(res)) " + ], + "split": "test" + }, + { + "Input": "Write a function to print check if the triangle is isosceles or not.", + "Output Program": [ + "def check_isosceles(x,y,z):\r\n if x==y or y==z or z==x:\r\n\t return True\r\n else:\r\n return False" + ], + "Output Answer": [ + "def check_isosceles(x,y,z):\r\n if x==y or y==z or z==x:\r\n\t return True\r\n else:\r\n return False" + ], + "split": "test" + }, + { + "Input": "Write a function to rotate a given list by specified number of items to the left direction.", + "Output Program": [ + "def rotate_left(list1,m,n):\r\n result = list1[m:]+list1[:n]\r\n return result" + ], + "Output Answer": [ + "def rotate_left(list1,m,n):\r\n result = list1[m:]+list1[:n]\r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a python function to count negative numbers in a list.", + "Output Program": [ + "def neg_count(list):\r\n neg_count= 0\r\n for num in list: \r\n if num <= 0: \r\n neg_count += 1\r\n return neg_count " + ], + "Output Answer": [ + "def neg_count(list):\r\n neg_count= 0\r\n for num in list: \r\n if num <= 0: \r\n neg_count += 1\r\n return neg_count " + ], + "split": "test" + }, + { + "Input": "Write a function to find all three, four, five characters long words in the given string by using regex.", + "Output Program": [ + "import re\r\ndef find_char(text):\r\n return (re.findall(r\"\\b\\w{3,5}\\b\", text))" + ], + "Output Answer": [ + "import re\r\ndef find_char(text):\r\n return (re.findall(r\"\\b\\w{3,5}\\b\", text))" + ], + "split": "test" + }, + { + "Input": "Write a python function to count unset bits of a given number.", + "Output Program": [ + "def count_unset_bits(n): \r\n count = 0\r\n x = 1\r\n while(x < n + 1): \r\n if ((x & n) == 0): \r\n count += 1\r\n x = x << 1\r\n return count " + ], + "Output Answer": [ + "def count_unset_bits(n): \r\n count = 0\r\n x = 1\r\n while(x < n + 1): \r\n if ((x & n) == 0): \r\n count += 1\r\n x = x << 1\r\n return count " + ], + "split": "test" + }, + { + "Input": "Write a function to count character frequency of a given string.", + "Output Program": [ + "def char_frequency(str1):\r\n dict = {}\r\n for n in str1:\r\n keys = dict.keys()\r\n if n in keys:\r\n dict[n] += 1\r\n else:\r\n dict[n] = 1\r\n return dict" + ], + "Output Answer": [ + "def char_frequency(str1):\r\n dict = {}\r\n for n in str1:\r\n keys = dict.keys()\r\n if n in keys:\r\n dict[n] += 1\r\n else:\r\n dict[n] = 1\r\n return dict" + ], + "split": "test" + }, + { + "Input": "Write a python function to sort a list according to the second element in sublist.", + "Output Program": [ + "def Sort(sub_li): \r\n sub_li.sort(key = lambda x: x[1]) \r\n return sub_li " + ], + "Output Answer": [ + "def Sort(sub_li): \r\n sub_li.sort(key = lambda x: x[1]) \r\n return sub_li " + ], + "split": "test" + }, + { + "Input": "Write a python function to check whether the triangle is valid or not if sides are given.", + "Output Program": [ + "def check_Validity(a,b,c): \r\n if (a + b <= c) or (a + c <= b) or (b + c <= a) : \r\n return False\r\n else: \r\n return True " + ], + "Output Answer": [ + "def check_Validity(a,b,c): \r\n if (a + b <= c) or (a + c <= b) or (b + c <= a) : \r\n return False\r\n else: \r\n return True " + ], + "split": "test" + }, + { + "Input": "Write a function to find the sum of arithmetic progression.", + "Output Program": [ + "def ap_sum(a,n,d):\r\n total = (n * (2 * a + (n - 1) * d)) / 2\r\n return total" + ], + "Output Answer": [ + "def ap_sum(a,n,d):\r\n total = (n * (2 * a + (n - 1) * d)) / 2\r\n return total" + ], + "split": "test" + }, + { + "Input": "Write a function to check whether the given month name contains 28 days or not.", + "Output Program": [ + "def check_monthnum(monthname1):\r\n if monthname1 == \"February\":\r\n return True\r\n else:\r\n return False" + ], + "Output Answer": [ + "def check_monthnum(monthname1):\r\n if monthname1 == \"February\":\r\n return True\r\n else:\r\n return False" + ], + "split": "test" + }, + { + "Input": "Write a function that matches a word at the end of a string, with optional punctuation.", + "Output Program": [ + "import re\r\ndef text_match_word(text):\r\n patterns = '\\w+\\S*$'\r\n if re.search(patterns, text):\r\n return 'Found a match!'\r\n else:\r\n return 'Not matched!'" + ], + "Output Answer": [ + "import re\r\ndef text_match_word(text):\r\n patterns = '\\w+\\S*$'\r\n if re.search(patterns, text):\r\n return 'Found a match!'\r\n else:\r\n return 'Not matched!'" + ], + "split": "test" + }, + { + "Input": "Write a python function to count the number of substrings with same first and last characters.", + "Output Program": [ + "def check_Equality(s): \r\n return (ord(s[0]) == ord(s[len(s) - 1])); \r\ndef count_Substring_With_Equal_Ends(s): \r\n result = 0; \r\n n = len(s); \r\n for i in range(n):\r\n for j in range(1,n-i+1): \r\n if (check_Equality(s[i:i+j])): \r\n result+=1; \r\n return result; " + ], + "Output Answer": [ + "def check_Equality(s): \r\n return (ord(s[0]) == ord(s[len(s) - 1])); \r\ndef count_Substring_With_Equal_Ends(s): \r\n result = 0; \r\n n = len(s); \r\n for i in range(n):\r\n for j in range(1,n-i+1): \r\n if (check_Equality(s[i:i+j])): \r\n result+=1; \r\n return result; " + ], + "split": "test" + }, + { + "Input": "Write a python function to find the maximum occuring divisor in an interval.", + "Output Program": [ + "def find_Divisor(x,y): \r\n if (x==y): \r\n return y \r\n return 2" + ], + "Output Answer": [ + "def find_Divisor(x,y): \r\n if (x==y): \r\n return y \r\n return 2" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the sum of the three lowest positive numbers from a given list of numbers.", + "Output Program": [ + "def sum_three_smallest_nums(lst):\r\n\treturn sum(sorted([x for x in lst if x > 0])[:3])" + ], + "Output Answer": [ + "def sum_three_smallest_nums(lst):\r\n\treturn sum(sorted([x for x in lst if x > 0])[:3])" + ], + "split": "test" + }, + { + "Input": "Write a function to convert the given set into tuples.", + "Output Program": [ + "def set_to_tuple(s):\r\n t = tuple(s)\r\n return (t)" + ], + "Output Answer": [ + "def set_to_tuple(s):\r\n t = tuple(s)\r\n return (t)" + ], + "split": "test" + }, + { + "Input": "Write a function to find the smallest range that includes at-least one element from each of the given arrays.", + "Output Program": [ + "from heapq import heappop, heappush\r\nclass Node:\r\n def __init__(self, value, list_num, index):\r\n self.value = value\r\n self.list_num = list_num\r\n self.index = index\r\n def __lt__(self, other):\r\n return self.value < other.value\r\ndef find_minimum_range(list):\r\n high = float('-inf')\r\n p = (0, float('inf'))\r\n pq = []\r\n for i in range(len(list)):\r\n heappush(pq, Node(list[i][0], i, 0))\r\n high = max(high, list[i][0])\r\n while True:\r\n top = heappop(pq)\r\n low = top.value\r\n i = top.list_num\r\n j = top.index\r\n if high - low < p[1] - p[0]:\r\n p = (low, high)\r\n if j == len(list[i]) - 1:\r\n return p\r\n heappush(pq, Node(list[i][j + 1], i, j + 1))\r\n high = max(high, list[i][j + 1])" + ], + "Output Answer": [ + "from heapq import heappop, heappush\r\nclass Node:\r\n def __init__(self, value, list_num, index):\r\n self.value = value\r\n self.list_num = list_num\r\n self.index = index\r\n def __lt__(self, other):\r\n return self.value < other.value\r\ndef find_minimum_range(list):\r\n high = float('-inf')\r\n p = (0, float('inf'))\r\n pq = []\r\n for i in range(len(list)):\r\n heappush(pq, Node(list[i][0], i, 0))\r\n high = max(high, list[i][0])\r\n while True:\r\n top = heappop(pq)\r\n low = top.value\r\n i = top.list_num\r\n j = top.index\r\n if high - low < p[1] - p[0]:\r\n p = (low, high)\r\n if j == len(list[i]) - 1:\r\n return p\r\n heappush(pq, Node(list[i][j + 1], i, j + 1))\r\n high = max(high, list[i][j + 1])" + ], + "split": "test" + }, + { + "Input": "Write a function to calculate the number of digits and letters in a string.", + "Output Program": [ + "def dig_let(s):\r\n d=l=0\r\n for c in s:\r\n if c.isdigit():\r\n d=d+1\r\n elif c.isalpha():\r\n l=l+1\r\n else:\r\n pass\r\n return (l,d)" + ], + "Output Answer": [ + "def dig_let(s):\r\n d=l=0\r\n for c in s:\r\n if c.isdigit():\r\n d=d+1\r\n elif c.isalpha():\r\n l=l+1\r\n else:\r\n pass\r\n return (l,d)" + ], + "split": "test" + }, + { + "Input": "Write a python function to find number of elements with odd factors in a given range.", + "Output Program": [ + "def count_Odd_Squares(n,m): \r\n return int(m**0.5) - int((n-1)**0.5) " + ], + "Output Answer": [ + "def count_Odd_Squares(n,m): \r\n return int(m**0.5) - int((n-1)**0.5) " + ], + "split": "test" + }, + { + "Input": "Write a function to find the difference between two consecutive numbers in a given list.", + "Output Program": [ + "def diff_consecutivenums(nums):\r\n result = [b-a for a, b in zip(nums[:-1], nums[1:])]\r\n return result" + ], + "Output Answer": [ + "def diff_consecutivenums(nums):\r\n result = [b-a for a, b in zip(nums[:-1], nums[1:])]\r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a function to find entringer number e(n, k).", + "Output Program": [ + "def zigzag(n, k): \r\n\tif (n == 0 and k == 0): \r\n\t\treturn 1\r\n\tif (k == 0): \r\n\t\treturn 0\r\n\treturn zigzag(n, k - 1) + zigzag(n - 1, n - k)" + ], + "Output Answer": [ + "def zigzag(n, k): \r\n\tif (n == 0 and k == 0): \r\n\t\treturn 1\r\n\tif (k == 0): \r\n\t\treturn 0\r\n\treturn zigzag(n, k - 1) + zigzag(n - 1, n - k)" + ], + "split": "test" + }, + { + "Input": "Write a function to count sequences of given length having non-negative prefix sums that can be generated by given values.", + "Output Program": [ + "def bin_coff(n, r): \r\n\tval = 1\r\n\tif (r > (n - r)): \r\n\t\tr = (n - r) \r\n\tfor i in range(0, r): \r\n\t\tval *= (n - i) \r\n\t\tval //= (i + 1) \r\n\treturn val \r\ndef find_ways(M): \r\n\tn = M // 2\r\n\ta = bin_coff(2 * n, n) \r\n\tb = a // (n + 1) \r\n\treturn (b) " + ], + "Output Answer": [ + "def bin_coff(n, r): \r\n\tval = 1\r\n\tif (r > (n - r)): \r\n\t\tr = (n - r) \r\n\tfor i in range(0, r): \r\n\t\tval *= (n - i) \r\n\t\tval //= (i + 1) \r\n\treturn val \r\ndef find_ways(M): \r\n\tn = M // 2\r\n\ta = bin_coff(2 * n, n) \r\n\tb = a // (n + 1) \r\n\treturn (b) " + ], + "split": "test" + }, + { + "Input": "Write a python function to check whether the given string is a binary string or not.", + "Output Program": [ + "def check(string) :\r\n p = set(string) \r\n s = {'0', '1'} \r\n if s == p or p == {'0'} or p == {'1'}: \r\n return (\"Yes\") \r\n else : \r\n return (\"No\") " + ], + "Output Answer": [ + "def check(string) :\r\n p = set(string) \r\n s = {'0', '1'} \r\n if s == p or p == {'0'} or p == {'1'}: \r\n return (\"Yes\") \r\n else : \r\n return (\"No\") " + ], + "split": "test" + }, + { + "Input": "Write a python function to minimize the length of the string by removing occurrence of only one character.", + "Output Program": [ + "def minimum_Length(s) : \r\n maxOcc = 0\r\n n = len(s) \r\n arr = [0]*26\r\n for i in range(n) : \r\n arr[ord(s[i]) -ord('a')] += 1\r\n for i in range(26) : \r\n if arr[i] > maxOcc : \r\n maxOcc = arr[i] \r\n return n - maxOcc " + ], + "Output Answer": [ + "def minimum_Length(s) : \r\n maxOcc = 0\r\n n = len(s) \r\n arr = [0]*26\r\n for i in range(n) : \r\n arr[ord(s[i]) -ord('a')] += 1\r\n for i in range(26) : \r\n if arr[i] > maxOcc : \r\n maxOcc = arr[i] \r\n return n - maxOcc " + ], + "split": "test" + }, + { + "Input": "Write a python function to find the first element occurring k times in a given array.", + "Output Program": [ + "def first_Element(arr,n,k): \r\n count_map = {}; \r\n for i in range(0, n): \r\n if(arr[i] in count_map.keys()): \r\n count_map[arr[i]] += 1\r\n else: \r\n count_map[arr[i]] = 1\r\n i += 1\r\n for i in range(0, n): \r\n if (count_map[arr[i]] == k): \r\n return arr[i] \r\n i += 1 \r\n return -1" + ], + "Output Answer": [ + "def first_Element(arr,n,k): \r\n count_map = {}; \r\n for i in range(0, n): \r\n if(arr[i] in count_map.keys()): \r\n count_map[arr[i]] += 1\r\n else: \r\n count_map[arr[i]] = 1\r\n i += 1\r\n for i in range(0, n): \r\n if (count_map[arr[i]] == k): \r\n return arr[i] \r\n i += 1 \r\n return -1" + ], + "split": "test" + }, + { + "Input": "Write a python function to check whether all the characters in a given string are unique.", + "Output Program": [ + "def unique_Characters(str):\r\n for i in range(len(str)):\r\n for j in range(i + 1,len(str)): \r\n if (str[i] == str[j]):\r\n return False;\r\n return True;" + ], + "Output Answer": [ + "def unique_Characters(str):\r\n for i in range(len(str)):\r\n for j in range(i + 1,len(str)): \r\n if (str[i] == str[j]):\r\n return False;\r\n return True;" + ], + "split": "test" + }, + { + "Input": "Write a function to remove a specified column from a given nested list.", + "Output Program": [ + "def remove_column(list1, n):\r\n for i in list1: \r\n del i[n] \r\n return list1" + ], + "Output Answer": [ + "def remove_column(list1, n):\r\n for i in list1: \r\n del i[n] \r\n return list1" + ], + "split": "test" + }, + { + "Input": "Write a function to find t-nth term of arithemetic progression.", + "Output Program": [ + "def tn_ap(a,n,d):\r\n tn = a + (n - 1) * d\r\n return tn" + ], + "Output Answer": [ + "def tn_ap(a,n,d):\r\n tn = a + (n - 1) * d\r\n return tn" + ], + "split": "test" + }, + { + "Input": "Write a python function to count the number of rectangles in a circle of radius r.", + "Output Program": [ + "def count_Rectangles(radius): \r\n rectangles = 0 \r\n diameter = 2 * radius \r\n diameterSquare = diameter * diameter \r\n for a in range(1, 2 * radius): \r\n for b in range(1, 2 * radius): \r\n diagnalLengthSquare = (a * a + b * b) \r\n if (diagnalLengthSquare <= diameterSquare) : \r\n rectangles += 1\r\n return rectangles " + ], + "Output Answer": [ + "def count_Rectangles(radius): \r\n rectangles = 0 \r\n diameter = 2 * radius \r\n diameterSquare = diameter * diameter \r\n for a in range(1, 2 * radius): \r\n for b in range(1, 2 * radius): \r\n diagnalLengthSquare = (a * a + b * b) \r\n if (diagnalLengthSquare <= diameterSquare) : \r\n rectangles += 1\r\n return rectangles " + ], + "split": "test" + }, + { + "Input": "Write a function to find the third angle of a triangle using two angles.", + "Output Program": [ + "def find_angle(a,b):\r\n c = 180 - (a + b)\r\n return c\r\n" + ], + "Output Answer": [ + "def find_angle(a,b):\r\n c = 180 - (a + b)\r\n return c\r\n" + ], + "split": "test" + }, + { + "Input": "Write a function to find the maximum element of all the given tuple records.", + "Output Program": [ + "def find_max(test_list):\r\n res = max(int(j) for i in test_list for j in i)\r\n return (res) " + ], + "Output Answer": [ + "def find_max(test_list):\r\n res = max(int(j) for i in test_list for j in i)\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a function to find modulo division of two lists using map and lambda function.", + "Output Program": [ + "def moddiv_list(nums1,nums2):\r\n result = map(lambda x, y: x % y, nums1, nums2)\r\n return list(result)" + ], + "Output Answer": [ + "def moddiv_list(nums1,nums2):\r\n result = map(lambda x, y: x % y, nums1, nums2)\r\n return list(result)" + ], + "split": "test" + }, + { + "Input": "Write a python function to check whether one root of the quadratic equation is twice of the other or not.", + "Output Program": [ + "def Check_Solution(a,b,c): \r\n if (2*b*b == 9*a*c): \r\n return (\"Yes\"); \r\n else: \r\n return (\"No\"); " + ], + "Output Answer": [ + "def Check_Solution(a,b,c): \r\n if (2*b*b == 9*a*c): \r\n return (\"Yes\"); \r\n else: \r\n return (\"No\"); " + ], + "split": "test" + }, + { + "Input": "Write a function to find the n\u2019th carol number.", + "Output Program": [ + "def get_carol(n): \r\n\tresult = (2**n) - 1\r\n\treturn result * result - 2" + ], + "Output Answer": [ + "def get_carol(n): \r\n\tresult = (2**n) - 1\r\n\treturn result * result - 2" + ], + "split": "test" + }, + { + "Input": "Write a function to remove empty lists from a given list of lists.", + "Output Program": [ + "def remove_empty(list1):\r\n remove_empty = [x for x in list1 if x]\r\n return remove_empty" + ], + "Output Answer": [ + "def remove_empty(list1):\r\n remove_empty = [x for x in list1 if x]\r\n return remove_empty" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the item with maximum occurrences in a given list.", + "Output Program": [ + "def max_occurrences(nums):\r\n max_val = 0\r\n result = nums[0] \r\n for i in nums:\r\n occu = nums.count(i)\r\n if occu > max_val:\r\n max_val = occu\r\n result = i \r\n return result" + ], + "Output Answer": [ + "def max_occurrences(nums):\r\n max_val = 0\r\n result = nums[0] \r\n for i in nums:\r\n occu = nums.count(i)\r\n if occu > max_val:\r\n max_val = occu\r\n result = i \r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a function to add the k elements to each element in the tuple.", + "Output Program": [ + "def add_K_element(test_list, K):\r\n res = [tuple(j + K for j in sub ) for sub in test_list]\r\n return (res) " + ], + "Output Answer": [ + "def add_K_element(test_list, K):\r\n res = [tuple(j + K for j in sub ) for sub in test_list]\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a function to find the number of flips required to make the given binary string a sequence of alternate characters.", + "Output Program": [ + "def make_flip(ch): \r\n\treturn '1' if (ch == '0') else '0'\r\ndef get_flip_with_starting_charcter(str, expected): \r\n\tflip_count = 0\r\n\tfor i in range(len( str)): \r\n\t\tif (str[i] != expected): \r\n\t\t\tflip_count += 1\r\n\t\texpected = make_flip(expected) \r\n\treturn flip_count \r\ndef min_flip_to_make_string_alternate(str): \r\n\treturn min(get_flip_with_starting_charcter(str, '0'),get_flip_with_starting_charcter(str, '1')) " + ], + "Output Answer": [ + "def make_flip(ch): \r\n\treturn '1' if (ch == '0') else '0'\r\ndef get_flip_with_starting_charcter(str, expected): \r\n\tflip_count = 0\r\n\tfor i in range(len( str)): \r\n\t\tif (str[i] != expected): \r\n\t\t\tflip_count += 1\r\n\t\texpected = make_flip(expected) \r\n\treturn flip_count \r\ndef min_flip_to_make_string_alternate(str): \r\n\treturn min(get_flip_with_starting_charcter(str, '0'),get_flip_with_starting_charcter(str, '1')) " + ], + "split": "test" + }, + { + "Input": "Write a python function to count the number of digits of a given number.", + "Output Program": [ + "def count_Digit(n):\r\n count = 0\r\n while n != 0:\r\n n //= 10\r\n count += 1\r\n return count" + ], + "Output Answer": [ + "def count_Digit(n):\r\n count = 0\r\n while n != 0:\r\n n //= 10\r\n count += 1\r\n return count" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the largest product of the pair of adjacent elements from a given list of integers.", + "Output Program": [ + "def adjacent_num_product(list_nums):\r\n return max(a*b for a, b in zip(list_nums, list_nums[1:]))" + ], + "Output Answer": [ + "def adjacent_num_product(list_nums):\r\n return max(a*b for a, b in zip(list_nums, list_nums[1:]))" + ], + "split": "test" + }, + { + "Input": "Write a function to check if a binary tree is balanced or not.", + "Output Program": [ + "class Node: \r\n\tdef __init__(self, data): \r\n\t\tself.data = data \r\n\t\tself.left = None\r\n\t\tself.right = None\r\ndef get_height(root): \r\n\tif root is None: \r\n\t\treturn 0\r\n\treturn max(get_height(root.left), get_height(root.right)) + 1\r\ndef is_tree_balanced(root): \r\n\tif root is None: \r\n\t\treturn True\r\n\tlh = get_height(root.left) \r\n\trh = get_height(root.right) \r\n\tif (abs(lh - rh) <= 1) and is_tree_balanced( \r\n\troot.left) is True and is_tree_balanced( root.right) is True: \r\n\t\treturn True\r\n\treturn False" + ], + "Output Answer": [ + "class Node: \r\n\tdef __init__(self, data): \r\n\t\tself.data = data \r\n\t\tself.left = None\r\n\t\tself.right = None\r\ndef get_height(root): \r\n\tif root is None: \r\n\t\treturn 0\r\n\treturn max(get_height(root.left), get_height(root.right)) + 1\r\ndef is_tree_balanced(root): \r\n\tif root is None: \r\n\t\treturn True\r\n\tlh = get_height(root.left) \r\n\trh = get_height(root.right) \r\n\tif (abs(lh - rh) <= 1) and is_tree_balanced( \r\n\troot.left) is True and is_tree_balanced( root.right) is True: \r\n\t\treturn True\r\n\treturn False" + ], + "split": "test" + }, + { + "Input": "Write a function to repeat the given tuple n times.", + "Output Program": [ + "def repeat_tuples(test_tup, N):\r\n res = ((test_tup, ) * N)\r\n return (res) " + ], + "Output Answer": [ + "def repeat_tuples(test_tup, N):\r\n res = ((test_tup, ) * N)\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a function to find the lateral surface area of cuboid", + "Output Program": [ + "def lateralsurface_cuboid(l,w,h):\r\n LSA = 2*h*(l+w)\r\n return LSA" + ], + "Output Answer": [ + "def lateralsurface_cuboid(l,w,h):\r\n LSA = 2*h*(l+w)\r\n return LSA" + ], + "split": "test" + }, + { + "Input": "Write a function to sort a tuple by its float element.", + "Output Program": [ + "def float_sort(price):\r\n float_sort=sorted(price, key=lambda x: float(x[1]), reverse=True)\r\n return float_sort" + ], + "Output Answer": [ + "def float_sort(price):\r\n float_sort=sorted(price, key=lambda x: float(x[1]), reverse=True)\r\n return float_sort" + ], + "split": "test" + }, + { + "Input": "Write a function to find the smallest missing element in a sorted array.", + "Output Program": [ + "def smallest_missing(A, left_element, right_element):\r\n if left_element > right_element:\r\n return left_element\r\n mid = left_element + (right_element - left_element) // 2\r\n if A[mid] == mid:\r\n return smallest_missing(A, mid + 1, right_element)\r\n else:\r\n return smallest_missing(A, left_element, mid - 1)" + ], + "Output Answer": [ + "def smallest_missing(A, left_element, right_element):\r\n if left_element > right_element:\r\n return left_element\r\n mid = left_element + (right_element - left_element) // 2\r\n if A[mid] == mid:\r\n return smallest_missing(A, mid + 1, right_element)\r\n else:\r\n return smallest_missing(A, left_element, mid - 1)" + ], + "split": "test" + }, + { + "Input": "Write a function to sort a given list of elements in ascending order using heap queue algorithm.", + "Output Program": [ + "import heapq as hq\r\ndef heap_assending(nums):\r\n hq.heapify(nums)\r\n s_result = [hq.heappop(nums) for i in range(len(nums))]\r\n return s_result" + ], + "Output Answer": [ + "import heapq as hq\r\ndef heap_assending(nums):\r\n hq.heapify(nums)\r\n s_result = [hq.heappop(nums) for i in range(len(nums))]\r\n return s_result" + ], + "split": "test" + }, + { + "Input": "Write a function to find the volume of a cuboid.", + "Output Program": [ + "def volume_cuboid(l,w,h):\r\n volume=l*w*h\r\n return volume" + ], + "Output Answer": [ + "def volume_cuboid(l,w,h):\r\n volume=l*w*h\r\n return volume" + ], + "split": "test" + }, + { + "Input": "Write a function to print all permutations of a given string including duplicates.", + "Output Program": [ + "def permute_string(str):\r\n if len(str) == 0:\r\n return ['']\r\n prev_list = permute_string(str[1:len(str)])\r\n next_list = []\r\n for i in range(0,len(prev_list)):\r\n for j in range(0,len(str)):\r\n new_str = prev_list[i][0:j]+str[0]+prev_list[i][j:len(str)-1]\r\n if new_str not in next_list:\r\n next_list.append(new_str)\r\n return next_list" + ], + "Output Answer": [ + "def permute_string(str):\r\n if len(str) == 0:\r\n return ['']\r\n prev_list = permute_string(str[1:len(str)])\r\n next_list = []\r\n for i in range(0,len(prev_list)):\r\n for j in range(0,len(str)):\r\n new_str = prev_list[i][0:j]+str[0]+prev_list[i][j:len(str)-1]\r\n if new_str not in next_list:\r\n next_list.append(new_str)\r\n return next_list" + ], + "split": "test" + }, + { + "Input": "Write a function to round the given number to the nearest multiple of a specific number.", + "Output Program": [ + "def round_num(n,m):\r\n a = (n //m) * m\r\n b = a + m\r\n return (b if n - a > b - n else a)" + ], + "Output Answer": [ + "def round_num(n,m):\r\n a = (n //m) * m\r\n b = a + m\r\n return (b if n - a > b - n else a)" + ], + "split": "test" + }, + { + "Input": "Write a function to remove tuple elements that occur more than once and replace the duplicates with some custom value.", + "Output Program": [ + "def remove_replica(test_tup):\r\n temp = set()\r\n res = tuple(ele if ele not in temp and not temp.add(ele) \r\n\t\t\t\telse 'MSP' for ele in test_tup)\r\n return (res)" + ], + "Output Answer": [ + "def remove_replica(test_tup):\r\n temp = set()\r\n res = tuple(ele if ele not in temp and not temp.add(ele) \r\n\t\t\t\telse 'MSP' for ele in test_tup)\r\n return (res)" + ], + "split": "test" + }, + { + "Input": "Write a python function to remove all occurrences of a character in a given string.", + "Output Program": [ + "def remove_Char(s,c) : \r\n counts = s.count(c) \r\n s = list(s) \r\n while counts : \r\n s.remove(c) \r\n counts -= 1 \r\n s = '' . join(s) \r\n return (s) " + ], + "Output Answer": [ + "def remove_Char(s,c) : \r\n counts = s.count(c) \r\n s = list(s) \r\n while counts : \r\n s.remove(c) \r\n counts -= 1 \r\n s = '' . join(s) \r\n return (s) " + ], + "split": "test" + }, + { + "Input": "Write a python function to shift last element to first position in the given list.", + "Output Program": [ + "def move_first(test_list):\r\n test_list = test_list[-1:] + test_list[:-1] \r\n return test_list" + ], + "Output Answer": [ + "def move_first(test_list):\r\n test_list = test_list[-1:] + test_list[:-1] \r\n return test_list" + ], + "split": "test" + }, + { + "Input": "Write a function to find the surface area of a cuboid.", + "Output Program": [ + "def surfacearea_cuboid(l,w,h):\r\n SA = 2*(l*w + l * h + w * h)\r\n return SA" + ], + "Output Answer": [ + "def surfacearea_cuboid(l,w,h):\r\n SA = 2*(l*w + l * h + w * h)\r\n return SA" + ], + "split": "test" + }, + { + "Input": "Write a function to generate a two-dimensional array.", + "Output Program": [ + "def multi_list(rownum,colnum):\r\n multi_list = [[0 for col in range(colnum)] for row in range(rownum)]\r\n for row in range(rownum):\r\n for col in range(colnum):\r\n multi_list[row][col]= row*col\r\n return multi_list\r\n" + ], + "Output Answer": [ + "def multi_list(rownum,colnum):\r\n multi_list = [[0 for col in range(colnum)] for row in range(rownum)]\r\n for row in range(rownum):\r\n for col in range(colnum):\r\n multi_list[row][col]= row*col\r\n return multi_list\r\n" + ], + "split": "test" + }, + { + "Input": "Write a function to sort a list of lists by a given index of the inner list.", + "Output Program": [ + "from operator import itemgetter\r\ndef index_on_inner_list(list_data, index_no):\r\n result = sorted(list_data, key=itemgetter(index_no))\r\n return result" + ], + "Output Answer": [ + "from operator import itemgetter\r\ndef index_on_inner_list(list_data, index_no):\r\n result = sorted(list_data, key=itemgetter(index_no))\r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a function to find the number of rotations in a circularly sorted array.", + "Output Program": [ + "def find_rotation_count(A):\r\n (left, right) = (0, len(A) - 1)\r\n while left <= right:\r\n if A[left] <= A[right]:\r\n return left\r\n mid = (left + right) // 2\r\n next = (mid + 1) % len(A)\r\n prev = (mid - 1 + len(A)) % len(A)\r\n if A[mid] <= A[next] and A[mid] <= A[prev]:\r\n return mid\r\n elif A[mid] <= A[right]:\r\n right = mid - 1\r\n elif A[mid] >= A[left]:\r\n left = mid + 1\r\n return -1" + ], + "Output Answer": [ + "def find_rotation_count(A):\r\n (left, right) = (0, len(A) - 1)\r\n while left <= right:\r\n if A[left] <= A[right]:\r\n return left\r\n mid = (left + right) // 2\r\n next = (mid + 1) % len(A)\r\n prev = (mid - 1 + len(A)) % len(A)\r\n if A[mid] <= A[next] and A[mid] <= A[prev]:\r\n return mid\r\n elif A[mid] <= A[right]:\r\n right = mid - 1\r\n elif A[mid] >= A[left]:\r\n left = mid + 1\r\n return -1" + ], + "split": "test" + }, + { + "Input": "Write a python function to toggle all odd bits of a given number.", + "Output Program": [ + "def even_bit_toggle_number(n) : \r\n res = 0; count = 0; temp = n \r\n while(temp > 0 ) : \r\n if (count % 2 == 0) : \r\n res = res | (1 << count) \r\n count = count + 1\r\n temp >>= 1 \r\n return n ^ res " + ], + "Output Answer": [ + "def even_bit_toggle_number(n) : \r\n res = 0; count = 0; temp = n \r\n while(temp > 0 ) : \r\n if (count % 2 == 0) : \r\n res = res | (1 << count) \r\n count = count + 1\r\n temp >>= 1 \r\n return n ^ res " + ], + "split": "test" + }, + { + "Input": "Write a python function to find the frequency of the smallest value in a given array.", + "Output Program": [ + "def frequency_Of_Smallest(n,arr): \r\n mn = arr[0] \r\n freq = 1\r\n for i in range(1,n): \r\n if (arr[i] < mn): \r\n mn = arr[i] \r\n freq = 1\r\n elif (arr[i] == mn): \r\n freq += 1\r\n return freq " + ], + "Output Answer": [ + "def frequency_Of_Smallest(n,arr): \r\n mn = arr[0] \r\n freq = 1\r\n for i in range(1,n): \r\n if (arr[i] < mn): \r\n mn = arr[i] \r\n freq = 1\r\n elif (arr[i] == mn): \r\n freq += 1\r\n return freq " + ], + "split": "test" + }, + { + "Input": "Write a function to find the n'th perrin number using recursion.", + "Output Program": [ + "def get_perrin(n):\r\n if (n == 0):\r\n return 3\r\n if (n == 1):\r\n return 0\r\n if (n == 2):\r\n return 2 \r\n return get_perrin(n - 2) + get_perrin(n - 3)" + ], + "Output Answer": [ + "def get_perrin(n):\r\n if (n == 0):\r\n return 3\r\n if (n == 1):\r\n return 0\r\n if (n == 2):\r\n return 2 \r\n return get_perrin(n - 2) + get_perrin(n - 3)" + ], + "split": "test" + }, + { + "Input": "Write a function to find out the minimum no of swaps required for bracket balancing in the given string.", + "Output Program": [ + "def swap_count(s):\r\n\tchars = s\r\n\tcount_left = 0\r\n\tcount_right = 0\r\n\tswap = 0\r\n\timbalance = 0; \r\n\tfor i in range(len(chars)):\r\n\t\tif chars[i] == '[':\r\n\t\t\tcount_left += 1\r\n\t\t\tif imbalance > 0:\r\n\t\t\t\tswap += imbalance\r\n\t\t\t\timbalance -= 1\r\n\t\telif chars[i] == ']':\r\n\t\t\tcount_right += 1\r\n\t\t\timbalance = (count_right - count_left) \r\n\treturn swap" + ], + "Output Answer": [ + "def swap_count(s):\r\n\tchars = s\r\n\tcount_left = 0\r\n\tcount_right = 0\r\n\tswap = 0\r\n\timbalance = 0; \r\n\tfor i in range(len(chars)):\r\n\t\tif chars[i] == '[':\r\n\t\t\tcount_left += 1\r\n\t\t\tif imbalance > 0:\r\n\t\t\t\tswap += imbalance\r\n\t\t\t\timbalance -= 1\r\n\t\telif chars[i] == ']':\r\n\t\t\tcount_right += 1\r\n\t\t\timbalance = (count_right - count_left) \r\n\treturn swap" + ], + "split": "test" + }, + { + "Input": "Write a python function to check whether the hexadecimal number is even or odd.", + "Output Program": [ + "def even_or_odd(N): \r\n l = len(N) \r\n if (N[l-1] =='0'or N[l-1] =='2'or \r\n N[l-1] =='4'or N[l-1] =='6'or \r\n N[l-1] =='8'or N[l-1] =='A'or \r\n N[l-1] =='C'or N[l-1] =='E'): \r\n return (\"Even\") \r\n else: \r\n return (\"Odd\") " + ], + "Output Answer": [ + "def even_or_odd(N): \r\n l = len(N) \r\n if (N[l-1] =='0'or N[l-1] =='2'or \r\n N[l-1] =='4'or N[l-1] =='6'or \r\n N[l-1] =='8'or N[l-1] =='A'or \r\n N[l-1] =='C'or N[l-1] =='E'): \r\n return (\"Even\") \r\n else: \r\n return (\"Odd\") " + ], + "split": "test" + }, + { + "Input": "Write a python function to find the highest power of 2 that is less than or equal to n.", + "Output Program": [ + "def highest_Power_of_2(n): \r\n res = 0; \r\n for i in range(n, 0, -1): \r\n if ((i & (i - 1)) == 0): \r\n res = i; \r\n break; \r\n return res; " + ], + "Output Answer": [ + "def highest_Power_of_2(n): \r\n res = 0; \r\n for i in range(n, 0, -1): \r\n if ((i & (i - 1)) == 0): \r\n res = i; \r\n break; \r\n return res; " + ], + "split": "test" + }, + { + "Input": "Write a function to find the n'th lucas number.", + "Output Program": [ + "def find_lucas(n): \r\n\tif (n == 0): \r\n\t\treturn 2\r\n\tif (n == 1): \r\n\t\treturn 1\r\n\treturn find_lucas(n - 1) + find_lucas(n - 2) " + ], + "Output Answer": [ + "def find_lucas(n): \r\n\tif (n == 0): \r\n\t\treturn 2\r\n\tif (n == 1): \r\n\t\treturn 1\r\n\treturn find_lucas(n - 1) + find_lucas(n - 2) " + ], + "split": "test" + }, + { + "Input": "Write a function to insert a given string at the beginning of all items in a list.", + "Output Program": [ + "def add_string(list,string):\r\n add_string=[string.format(i) for i in list]\r\n return add_string" + ], + "Output Answer": [ + "def add_string(list,string):\r\n add_string=[string.format(i) for i in list]\r\n return add_string" + ], + "split": "test" + }, + { + "Input": "Write a function to convert more than one list to nested dictionary.", + "Output Program": [ + "def convert_list_dictionary(l1, l2, l3):\r\n result = [{x: {y: z}} for (x, y, z) in zip(l1, l2, l3)]\r\n return result" + ], + "Output Answer": [ + "def convert_list_dictionary(l1, l2, l3):\r\n result = [{x: {y: z}} for (x, y, z) in zip(l1, l2, l3)]\r\n return result" + ], + "split": "test" + }, + { + "Input": "Write 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).", + "Output Program": [ + "def get_max_sum (n):\r\n\tres = list()\r\n\tres.append(0)\r\n\tres.append(1)\r\n\ti = 2\r\n\twhile i b:\r\n if a < c:\r\n median = a\r\n elif b > c:\r\n median = b\r\n else:\r\n median = c\r\n else:\r\n if a > c:\r\n median = a\r\n elif b < c:\r\n median = b\r\n else:\r\n median = c\r\n return median" + ], + "Output Answer": [ + "def median_numbers(a,b,c):\r\n if a > b:\r\n if a < c:\r\n median = a\r\n elif b > c:\r\n median = b\r\n else:\r\n median = c\r\n else:\r\n if a > c:\r\n median = a\r\n elif b < c:\r\n median = b\r\n else:\r\n median = c\r\n return median" + ], + "split": "test" + }, + { + "Input": "Write a function to compute the sum of digits of each number of a given list.", + "Output Program": [ + "def sum_of_digits(nums):\r\n return sum(int(el) for n in nums for el in str(n) if el.isdigit())" + ], + "Output Answer": [ + "def sum_of_digits(nums):\r\n return sum(int(el) for n in nums for el in str(n) if el.isdigit())" + ], + "split": "test" + }, + { + "Input": "Write a function to perform the mathematical bitwise xor operation across the given tuples.", + "Output Program": [ + "def bitwise_xor(test_tup1, test_tup2):\r\n res = tuple(ele1 ^ ele2 for ele1, ele2 in zip(test_tup1, test_tup2))\r\n return (res) " + ], + "Output Answer": [ + "def bitwise_xor(test_tup1, test_tup2):\r\n res = tuple(ele1 ^ ele2 for ele1, ele2 in zip(test_tup1, test_tup2))\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a function to extract the frequency of unique tuples in the given list order irrespective.", + "Output Program": [ + "def extract_freq(test_list):\r\n res = len(list(set(tuple(sorted(sub)) for sub in test_list)))\r\n return (res)" + ], + "Output Answer": [ + "def extract_freq(test_list):\r\n res = len(list(set(tuple(sorted(sub)) for sub in test_list)))\r\n return (res)" + ], + "split": "test" + }, + { + "Input": "Write a function to perform index wise addition of tuple elements in the given two nested tuples.", + "Output Program": [ + "def add_nested_tuples(test_tup1, test_tup2):\r\n res = tuple(tuple(a + b for a, b in zip(tup1, tup2))\r\n for tup1, tup2 in zip(test_tup1, test_tup2))\r\n return (res) " + ], + "Output Answer": [ + "def add_nested_tuples(test_tup1, test_tup2):\r\n res = tuple(tuple(a + b for a, b in zip(tup1, tup2))\r\n for tup1, tup2 in zip(test_tup1, test_tup2))\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a function to compute the value of ncr%p.", + "Output Program": [ + "def ncr_modp(n, r, p): \r\n C = [0 for i in range(r+1)] \r\n C[0] = 1\r\n for i in range(1, n+1): \r\n for j in range(min(i, r), 0, -1): \r\n C[j] = (C[j] + C[j-1]) % p \r\n return C[r] " + ], + "Output Answer": [ + "def ncr_modp(n, r, p): \r\n C = [0 for i in range(r+1)] \r\n C[0] = 1\r\n for i in range(1, n+1): \r\n for j in range(min(i, r), 0, -1): \r\n C[j] = (C[j] + C[j-1]) % p \r\n return C[r] " + ], + "split": "test" + }, + { + "Input": "Write a function to check if a url is valid or not using regex.", + "Output Program": [ + "import re\r\ndef is_valid_URL(str):\r\n\tregex = (\"((http|https)://)(www.)?\" +\r\n\t\t\t\"[a-zA-Z0-9@:%._\\\\+~#?&//=]\" +\r\n\t\t\t\"{2,256}\\\\.[a-z]\" +\r\n\t\t\t\"{2,6}\\\\b([-a-zA-Z0-9@:%\" +\r\n\t\t\t\"._\\\\+~#?&//=]*)\")\r\n\tp = re.compile(regex)\r\n\tif (str == None):\r\n\t\treturn False\r\n\tif(re.search(p, str)):\r\n\t\treturn True\r\n\telse:\r\n\t\treturn False" + ], + "Output Answer": [ + "import re\r\ndef is_valid_URL(str):\r\n\tregex = (\"((http|https)://)(www.)?\" +\r\n\t\t\t\"[a-zA-Z0-9@:%._\\\\+~#?&//=]\" +\r\n\t\t\t\"{2,256}\\\\.[a-z]\" +\r\n\t\t\t\"{2,6}\\\\b([-a-zA-Z0-9@:%\" +\r\n\t\t\t\"._\\\\+~#?&//=]*)\")\r\n\tp = re.compile(regex)\r\n\tif (str == None):\r\n\t\treturn False\r\n\tif(re.search(p, str)):\r\n\t\treturn True\r\n\telse:\r\n\t\treturn False" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the minimum of two numbers.", + "Output Program": [ + "def minimum(a,b): \r\n if a <= b: \r\n return a \r\n else: \r\n return b " + ], + "Output Answer": [ + "def minimum(a,b): \r\n if a <= b: \r\n return a \r\n else: \r\n return b " + ], + "split": "test" + }, + { + "Input": "Write a function to check whether an element exists within a tuple.", + "Output Program": [ + "def check_tuplex(tuplex,tuple1): \r\n if tuple1 in tuplex:\r\n return True\r\n else:\r\n return False" + ], + "Output Answer": [ + "def check_tuplex(tuplex,tuple1): \r\n if tuple1 in tuplex:\r\n return True\r\n else:\r\n return False" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the parity of a given number.", + "Output Program": [ + "def find_Parity(x): \r\n y = x ^ (x >> 1); \r\n y = y ^ (y >> 2); \r\n y = y ^ (y >> 4); \r\n y = y ^ (y >> 8); \r\n y = y ^ (y >> 16); \r\n if (y & 1): \r\n return (\"Odd Parity\"); \r\n return (\"Even Parity\"); " + ], + "Output Answer": [ + "def find_Parity(x): \r\n y = x ^ (x >> 1); \r\n y = y ^ (y >> 2); \r\n y = y ^ (y >> 4); \r\n y = y ^ (y >> 8); \r\n y = y ^ (y >> 16); \r\n if (y & 1): \r\n return (\"Odd Parity\"); \r\n return (\"Even Parity\"); " + ], + "split": "test" + }, + { + "Input": "Write a function to create the next bigger number by rearranging the digits of a given number.", + "Output Program": [ + "def rearrange_bigger(n):\r\n nums = list(str(n))\r\n for i in range(len(nums)-2,-1,-1):\r\n if nums[i] < nums[i+1]:\r\n z = nums[i:]\r\n y = min(filter(lambda x: x > z[0], z))\r\n z.remove(y)\r\n z.sort()\r\n nums[i:] = [y] + z\r\n return int(\"\".join(nums))\r\n return False" + ], + "Output Answer": [ + "def rearrange_bigger(n):\r\n nums = list(str(n))\r\n for i in range(len(nums)-2,-1,-1):\r\n if nums[i] < nums[i+1]:\r\n z = nums[i:]\r\n y = min(filter(lambda x: x > z[0], z))\r\n z.remove(y)\r\n z.sort()\r\n nums[i:] = [y] + z\r\n return int(\"\".join(nums))\r\n return False" + ], + "split": "test" + }, + { + "Input": "Write a function to find k number of pairs which consist of one element from the first array and one element from the second array.", + "Output Program": [ + "import heapq\r\ndef k_smallest_pairs(nums1, nums2, k):\r\n queue = []\r\n def push(i, j):\r\n if i < len(nums1) and j < len(nums2):\r\n heapq.heappush(queue, [nums1[i] + nums2[j], i, j])\r\n push(0, 0)\r\n pairs = []\r\n while queue and len(pairs) < k:\r\n _, i, j = heapq.heappop(queue)\r\n pairs.append([nums1[i], nums2[j]])\r\n push(i, j + 1)\r\n if j == 0:\r\n push(i + 1, 0)\r\n return pairs" + ], + "Output Answer": [ + "import heapq\r\ndef k_smallest_pairs(nums1, nums2, k):\r\n queue = []\r\n def push(i, j):\r\n if i < len(nums1) and j < len(nums2):\r\n heapq.heappush(queue, [nums1[i] + nums2[j], i, j])\r\n push(0, 0)\r\n pairs = []\r\n while queue and len(pairs) < k:\r\n _, i, j = heapq.heappop(queue)\r\n pairs.append([nums1[i], nums2[j]])\r\n push(i, j + 1)\r\n if j == 0:\r\n push(i + 1, 0)\r\n return pairs" + ], + "split": "test" + }, + { + "Input": "Write a function to find the minimum product from the pairs of tuples within a given list.", + "Output Program": [ + "def min_product_tuple(list1):\r\n result_min = min([abs(x * y) for x, y in list1] )\r\n return result_min" + ], + "Output Answer": [ + "def min_product_tuple(list1):\r\n result_min = min([abs(x * y) for x, y in list1] )\r\n return result_min" + ], + "split": "test" + }, + { + "Input": "Write a function to find the minimum value in a given heterogeneous list.", + "Output Program": [ + "def min_val(listval):\r\n min_val = min(i for i in listval if isinstance(i, int))\r\n return min_val" + ], + "Output Answer": [ + "def min_val(listval):\r\n min_val = min(i for i in listval if isinstance(i, int))\r\n return min_val" + ], + "split": "test" + }, + { + "Input": "Write a function to convert the given snake case string to camel case string by using regex.", + "Output Program": [ + "import re\r\ndef snake_to_camel(word):\r\n return ''.join(x.capitalize() or '_' for x in word.split('_'))" + ], + "Output Answer": [ + "import re\r\ndef snake_to_camel(word):\r\n return ''.join(x.capitalize() or '_' for x in word.split('_'))" + ], + "split": "test" + }, + { + "Input": "Write a python function to remove odd numbers from a given list.", + "Output Program": [ + "def remove_odd(l):\r\n for i in l:\r\n if i % 2 != 0:\r\n l.remove(i)\r\n return l" + ], + "Output Answer": [ + "def remove_odd(l):\r\n for i in l:\r\n if i % 2 != 0:\r\n l.remove(i)\r\n return l" + ], + "split": "test" + }, + { + "Input": "Write a function to extract the nth element from a given list of tuples.", + "Output Program": [ + "def extract_nth_element(list1, n):\r\n result = [x[n] for x in list1]\r\n return result" + ], + "Output Answer": [ + "def extract_nth_element(list1, n):\r\n result = [x[n] for x in list1]\r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a python function to check whether the value exists in a sequence or not.", + "Output Program": [ + "def overlapping(list1,list2): \r\n c=0\r\n d=0\r\n for i in list1: \r\n c+=1\r\n for i in list2: \r\n d+=1\r\n for i in range(0,c): \r\n for j in range(0,d): \r\n if(list1[i]==list2[j]): \r\n return 1\r\n return 0" + ], + "Output Answer": [ + "def overlapping(list1,list2): \r\n c=0\r\n d=0\r\n for i in list1: \r\n c+=1\r\n for i in list2: \r\n d+=1\r\n for i in range(0,c): \r\n for j in range(0,d): \r\n if(list1[i]==list2[j]): \r\n return 1\r\n return 0" + ], + "split": "test" + }, + { + "Input": "Write a python function to find a pair with highest product from a given array of integers.", + "Output Program": [ + "def max_Product(arr): \r\n arr_len = len(arr) \r\n if (arr_len < 2): \r\n return (\"No pairs exists\") \r\n x = arr[0]; y = arr[1] \r\n for i in range(0,arr_len): \r\n for j in range(i + 1,arr_len): \r\n if (arr[i] * arr[j] > x * y): \r\n x = arr[i]; y = arr[j] \r\n return x,y " + ], + "Output Answer": [ + "def max_Product(arr): \r\n arr_len = len(arr) \r\n if (arr_len < 2): \r\n return (\"No pairs exists\") \r\n x = arr[0]; y = arr[1] \r\n for i in range(0,arr_len): \r\n for j in range(i + 1,arr_len): \r\n if (arr[i] * arr[j] > x * y): \r\n x = arr[i]; y = arr[j] \r\n return x,y " + ], + "split": "test" + }, + { + "Input": "Write 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.", + "Output Program": [ + "MAX = 1000000\r\ndef breakSum(n): \r\n\tdp = [0]*(n+1) \r\n\tdp[0] = 0\r\n\tdp[1] = 1\r\n\tfor i in range(2, n+1): \r\n\t\tdp[i] = max(dp[int(i/2)] + dp[int(i/3)] + dp[int(i/4)], i); \r\n\treturn dp[n]" + ], + "Output Answer": [ + "MAX = 1000000\r\ndef breakSum(n): \r\n\tdp = [0]*(n+1) \r\n\tdp[0] = 0\r\n\tdp[1] = 1\r\n\tfor i in range(2, n+1): \r\n\t\tdp[i] = max(dp[int(i/2)] + dp[int(i/3)] + dp[int(i/4)], i); \r\n\treturn dp[n]" + ], + "split": "test" + }, + { + "Input": "Write a function to find common first element in given list of tuple.", + "Output Program": [ + "def group_tuples(Input): \r\n\tout = {} \r\n\tfor elem in Input: \r\n\t\ttry: \r\n\t\t\tout[elem[0]].extend(elem[1:]) \r\n\t\texcept KeyError: \r\n\t\t\tout[elem[0]] = list(elem) \r\n\treturn [tuple(values) for values in out.values()] " + ], + "Output Answer": [ + "def group_tuples(Input): \r\n\tout = {} \r\n\tfor elem in Input: \r\n\t\ttry: \r\n\t\t\tout[elem[0]].extend(elem[1:]) \r\n\t\texcept KeyError: \r\n\t\t\tout[elem[0]] = list(elem) \r\n\treturn [tuple(values) for values in out.values()] " + ], + "split": "test" + }, + { + "Input": "Write a python function to find the sublist having maximum length.", + "Output Program": [ + "def Find_Max(lst): \r\n maxList = max((x) for x in lst) \r\n return maxList" + ], + "Output Answer": [ + "def Find_Max(lst): \r\n maxList = max((x) for x in lst) \r\n return maxList" + ], + "split": "test" + }, + { + "Input": "Write a function to round every number of a given list of numbers and print the total sum multiplied by the length of the list.", + "Output Program": [ + "def round_and_sum(list1):\r\n lenght=len(list1)\r\n round_and_sum=sum(list(map(round,list1))* lenght)\r\n return round_and_sum" + ], + "Output Answer": [ + "def round_and_sum(list1):\r\n lenght=len(list1)\r\n round_and_sum=sum(list(map(round,list1))* lenght)\r\n return round_and_sum" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the cube sum of first n even natural numbers.", + "Output Program": [ + "def cube_Sum(n): \r\n sum = 0\r\n for i in range(1,n + 1): \r\n sum += (2*i)*(2*i)*(2*i) \r\n return sum" + ], + "Output Answer": [ + "def cube_Sum(n): \r\n sum = 0\r\n for i in range(1,n + 1): \r\n sum += (2*i)*(2*i)*(2*i) \r\n return sum" + ], + "split": "test" + }, + { + "Input": "Write a function to concatenate each element of tuple by the delimiter.", + "Output Program": [ + "def concatenate_tuple(test_tup):\r\n delim = \"-\"\r\n res = ''.join([str(ele) + delim for ele in test_tup])\r\n res = res[ : len(res) - len(delim)]\r\n return (str(res)) " + ], + "Output Answer": [ + "def concatenate_tuple(test_tup):\r\n delim = \"-\"\r\n res = ''.join([str(ele) + delim for ele in test_tup])\r\n res = res[ : len(res) - len(delim)]\r\n return (str(res)) " + ], + "split": "test" + }, + { + "Input": "Write a python function to find the average of cubes of first n natural numbers.", + "Output Program": [ + "def find_Average_Of_Cube(n): \r\n sum = 0\r\n for i in range(1, n + 1): \r\n sum += i * i * i \r\n return round(sum / n, 6) " + ], + "Output Answer": [ + "def find_Average_Of_Cube(n): \r\n sum = 0\r\n for i in range(1, n + 1): \r\n sum += i * i * i \r\n return round(sum / n, 6) " + ], + "split": "test" + }, + { + "Input": "Write a function to solve gold mine problem.", + "Output Program": [ + "def get_maxgold(gold, m, n): \r\n goldTable = [[0 for i in range(n)] \r\n for j in range(m)] \r\n for col in range(n-1, -1, -1): \r\n for row in range(m): \r\n if (col == n-1): \r\n right = 0\r\n else: \r\n right = goldTable[row][col+1] \r\n if (row == 0 or col == n-1): \r\n right_up = 0\r\n else: \r\n right_up = goldTable[row-1][col+1] \r\n if (row == m-1 or col == n-1): \r\n right_down = 0\r\n else: \r\n right_down = goldTable[row+1][col+1] \r\n goldTable[row][col] = gold[row][col] + max(right, right_up, right_down) \r\n res = goldTable[0][0] \r\n for i in range(1, m): \r\n res = max(res, goldTable[i][0]) \r\n return res " + ], + "Output Answer": [ + "def get_maxgold(gold, m, n): \r\n goldTable = [[0 for i in range(n)] \r\n for j in range(m)] \r\n for col in range(n-1, -1, -1): \r\n for row in range(m): \r\n if (col == n-1): \r\n right = 0\r\n else: \r\n right = goldTable[row][col+1] \r\n if (row == 0 or col == n-1): \r\n right_up = 0\r\n else: \r\n right_up = goldTable[row-1][col+1] \r\n if (row == m-1 or col == n-1): \r\n right_down = 0\r\n else: \r\n right_down = goldTable[row+1][col+1] \r\n goldTable[row][col] = gold[row][col] + max(right, right_up, right_down) \r\n res = goldTable[0][0] \r\n for i in range(1, m): \r\n res = max(res, goldTable[i][0]) \r\n return res " + ], + "split": "test" + }, + { + "Input": "Write a function to extract only the rear index element of each string in the given tuple.", + "Output Program": [ + "def extract_rear(test_tuple):\r\n res = list(sub[len(sub) - 1] for sub in test_tuple)\r\n return (res) " + ], + "Output Answer": [ + "def extract_rear(test_tuple):\r\n res = list(sub[len(sub) - 1] for sub in test_tuple)\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a function to count the number of sublists containing a particular element.", + "Output Program": [ + "def count_element_in_list(list1, x): \r\n ctr = 0\r\n for i in range(len(list1)): \r\n if x in list1[i]: \r\n ctr+= 1 \r\n return ctr" + ], + "Output Answer": [ + "def count_element_in_list(list1, x): \r\n ctr = 0\r\n for i in range(len(list1)): \r\n if x in list1[i]: \r\n ctr+= 1 \r\n return ctr" + ], + "split": "test" + }, + { + "Input": "Write a function to filter odd numbers using lambda function.", + "Output Program": [ + "def filter_oddnumbers(nums):\r\n odd_nums = list(filter(lambda x: x%2 != 0, nums))\r\n return odd_nums" + ], + "Output Answer": [ + "def filter_oddnumbers(nums):\r\n odd_nums = list(filter(lambda x: x%2 != 0, nums))\r\n return odd_nums" + ], + "split": "test" + }, + { + "Input": "Write a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format by using regex.", + "Output Program": [ + "import re\r\ndef change_date_format(dt):\r\n return re.sub(r'(\\d{4})-(\\d{1,2})-(\\d{1,2})', '\\\\3-\\\\2-\\\\1', dt)" + ], + "Output Answer": [ + "import re\r\ndef change_date_format(dt):\r\n return re.sub(r'(\\d{4})-(\\d{1,2})-(\\d{1,2})', '\\\\3-\\\\2-\\\\1', dt)" + ], + "split": "test" + }, + { + "Input": "Write a function to sort the given array by using shell sort.", + "Output Program": [ + "def shell_sort(my_list):\r\n gap = len(my_list) // 2\r\n while gap > 0:\r\n for i in range(gap, len(my_list)):\r\n current_item = my_list[i]\r\n j = i\r\n while j >= gap and my_list[j - gap] > current_item:\r\n my_list[j] = my_list[j - gap]\r\n j -= gap\r\n my_list[j] = current_item\r\n gap //= 2\r\n\r\n return my_list" + ], + "Output Answer": [ + "def shell_sort(my_list):\r\n gap = len(my_list) // 2\r\n while gap > 0:\r\n for i in range(gap, len(my_list)):\r\n current_item = my_list[i]\r\n j = i\r\n while j >= gap and my_list[j - gap] > current_item:\r\n my_list[j] = my_list[j - gap]\r\n j -= gap\r\n my_list[j] = current_item\r\n gap //= 2\r\n\r\n return my_list" + ], + "split": "test" + }, + { + "Input": "Write a function to extract the elementwise and tuples from the given two tuples.", + "Output Program": [ + "def and_tuples(test_tup1, test_tup2):\r\n res = tuple(ele1 & ele2 for ele1, ele2 in zip(test_tup1, test_tup2))\r\n return (res) " + ], + "Output Answer": [ + "def and_tuples(test_tup1, test_tup2):\r\n res = tuple(ele1 & ele2 for ele1, ele2 in zip(test_tup1, test_tup2))\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a function to find the directrix of a parabola.", + "Output Program": [ + "def parabola_directrix(a, b, c): \r\n directrix=((int)(c - ((b * b) + 1) * 4 * a ))\r\n return directrix" + ], + "Output Answer": [ + "def parabola_directrix(a, b, c): \r\n directrix=((int)(c - ((b * b) + 1) * 4 * a ))\r\n return directrix" + ], + "split": "test" + }, + { + "Input": "Write a function that takes two lists and returns true if they have at least one common element.", + "Output Program": [ + "def common_element(list1, list2):\r\n result = False\r\n for x in list1:\r\n for y in list2:\r\n if x == y:\r\n result = True\r\n return result" + ], + "Output Answer": [ + "def common_element(list1, list2):\r\n result = False\r\n for x in list1:\r\n for y in list2:\r\n if x == y:\r\n result = True\r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a function to find the median of a trapezium.", + "Output Program": [ + "def median_trapezium(base1,base2,height):\r\n median = 0.5 * (base1+ base2)\r\n return median" + ], + "Output Answer": [ + "def median_trapezium(base1,base2,height):\r\n median = 0.5 * (base1+ base2)\r\n return median" + ], + "split": "test" + }, + { + "Input": "Write a function to check whether the entered number is greater than the elements of the given array.", + "Output Program": [ + "def check_greater(arr, number):\r\n arr.sort()\r\n if number > arr[-1]:\r\n return ('Yes, the entered number is greater than those in the array')\r\n else:\r\n return ('No, entered number is less than those in the array')" + ], + "Output Answer": [ + "def check_greater(arr, number):\r\n arr.sort()\r\n if number > arr[-1]:\r\n return ('Yes, the entered number is greater than those in the array')\r\n else:\r\n return ('No, entered number is less than those in the array')" + ], + "split": "test" + }, + { + "Input": "Write a function that matches a string that has an a followed by one or more b's.", + "Output Program": [ + "import re\r\ndef text_match_one(text):\r\n patterns = 'ab+?'\r\n if re.search(patterns, text):\r\n return 'Found a match!'\r\n else:\r\n return('Not matched!')\r\n" + ], + "Output Answer": [ + "import re\r\ndef text_match_one(text):\r\n patterns = 'ab+?'\r\n if re.search(patterns, text):\r\n return 'Found a match!'\r\n else:\r\n return('Not matched!')\r\n" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the last digit of a given number.", + "Output Program": [ + "def last_Digit(n) :\r\n return (n % 10) " + ], + "Output Answer": [ + "def last_Digit(n) :\r\n return (n % 10) " + ], + "split": "test" + }, + { + "Input": "Write a python function to print negative numbers in a list.", + "Output Program": [ + "def neg_nos(list1):\r\n for num in list1: \r\n if num < 0: \r\n return num " + ], + "Output Answer": [ + "def neg_nos(list1):\r\n for num in list1: \r\n if num < 0: \r\n return num " + ], + "split": "test" + }, + { + "Input": "Write a function to remove odd characters in a string.", + "Output Program": [ + "def remove_odd(str1):\r\n str2 = ''\r\n for i in range(1, len(str1) + 1):\r\n if(i % 2 == 0):\r\n str2 = str2 + str1[i - 1]\r\n return str2" + ], + "Output Answer": [ + "def remove_odd(str1):\r\n str2 = ''\r\n for i in range(1, len(str1) + 1):\r\n if(i % 2 == 0):\r\n str2 = str2 + str1[i - 1]\r\n return str2" + ], + "split": "test" + }, + { + "Input": "Write a function to count bidirectional tuple pairs.", + "Output Program": [ + "def count_bidirectional(test_list):\r\n res = 0\r\n for idx in range(0, len(test_list)):\r\n for iidx in range(idx + 1, len(test_list)):\r\n if test_list[iidx][0] == test_list[idx][1] and test_list[idx][1] == test_list[iidx][0]:\r\n res += 1\r\n return (str(res)) " + ], + "Output Answer": [ + "def count_bidirectional(test_list):\r\n res = 0\r\n for idx in range(0, len(test_list)):\r\n for iidx in range(idx + 1, len(test_list)):\r\n if test_list[iidx][0] == test_list[idx][1] and test_list[idx][1] == test_list[iidx][0]:\r\n res += 1\r\n return (str(res)) " + ], + "split": "test" + }, + { + "Input": "Write a function to convert a list of multiple integers into a single integer.", + "Output Program": [ + "def multiple_to_single(L):\r\n x = int(\"\".join(map(str, L)))\r\n return x" + ], + "Output Answer": [ + "def multiple_to_single(L):\r\n x = int(\"\".join(map(str, L)))\r\n return x" + ], + "split": "test" + }, + { + "Input": "Write a function to find all adverbs and their positions in a given sentence.", + "Output Program": [ + "import re\r\ndef find_adverb_position(text):\r\n for m in re.finditer(r\"\\w+ly\", text):\r\n return (m.start(), m.end(), m.group(0))" + ], + "Output Answer": [ + "import re\r\ndef find_adverb_position(text):\r\n for m in re.finditer(r\"\\w+ly\", text):\r\n return (m.start(), m.end(), m.group(0))" + ], + "split": "test" + }, + { + "Input": "Write a function to find the surface area of a cube.", + "Output Program": [ + "def surfacearea_cube(l):\r\n surfacearea= 6*l*l\r\n return surfacearea" + ], + "Output Answer": [ + "def surfacearea_cube(l):\r\n surfacearea= 6*l*l\r\n return surfacearea" + ], + "split": "test" + }, + { + "Input": "Write a function to find the ration of positive numbers in an array of integers.", + "Output Program": [ + "from array import array\r\ndef positive_count(nums):\r\n n = len(nums)\r\n n1 = 0\r\n for x in nums:\r\n if x > 0:\r\n n1 += 1\r\n else:\r\n None\r\n return round(n1/n,2)" + ], + "Output Answer": [ + "from array import array\r\ndef positive_count(nums):\r\n n = len(nums)\r\n n1 = 0\r\n for x in nums:\r\n if x > 0:\r\n n1 += 1\r\n else:\r\n None\r\n return round(n1/n,2)" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the largest negative number from the given list.", + "Output Program": [ + "def largest_neg(list1): \r\n max = list1[0] \r\n for x in list1: \r\n if x < max : \r\n max = x \r\n return max" + ], + "Output Answer": [ + "def largest_neg(list1): \r\n max = list1[0] \r\n for x in list1: \r\n if x < max : \r\n max = x \r\n return max" + ], + "split": "test" + }, + { + "Input": "Write a function to trim each tuple by k in the given tuple list.", + "Output Program": [ + "def trim_tuple(test_list, K):\r\n res = []\r\n for ele in test_list:\r\n N = len(ele)\r\n res.append(tuple(list(ele)[K: N - K]))\r\n return (str(res)) " + ], + "Output Answer": [ + "def trim_tuple(test_list, K):\r\n res = []\r\n for ele in test_list:\r\n N = len(ele)\r\n res.append(tuple(list(ele)[K: N - K]))\r\n return (str(res)) " + ], + "split": "test" + }, + { + "Input": "Write a function to perform index wise multiplication of tuple elements in the given two tuples.", + "Output Program": [ + "def index_multiplication(test_tup1, test_tup2):\r\n res = tuple(tuple(a * b for a, b in zip(tup1, tup2))\r\n for tup1, tup2 in zip(test_tup1, test_tup2))\r\n return (res) " + ], + "Output Answer": [ + "def index_multiplication(test_tup1, test_tup2):\r\n res = tuple(tuple(a * b for a, b in zip(tup1, tup2))\r\n for tup1, tup2 in zip(test_tup1, test_tup2))\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a python function to count the occurence of all elements of list in a tuple.", + "Output Program": [ + "from collections import Counter \r\ndef count_Occurrence(tup, lst): \r\n count = 0\r\n for item in tup: \r\n if item in lst: \r\n count+= 1 \r\n return count " + ], + "Output Answer": [ + "from collections import Counter \r\ndef count_Occurrence(tup, lst): \r\n count = 0\r\n for item in tup: \r\n if item in lst: \r\n count+= 1 \r\n return count " + ], + "split": "test" + }, + { + "Input": "Write a function to find cubes of individual elements in a list using lambda function.", + "Output Program": [ + "def cube_nums(nums):\r\n cube_nums = list(map(lambda x: x ** 3, nums))\r\n return cube_nums" + ], + "Output Answer": [ + "def cube_nums(nums):\r\n cube_nums = list(map(lambda x: x ** 3, nums))\r\n return cube_nums" + ], + "split": "test" + }, + { + "Input": "Write a function to calculate the sum of perrin numbers.", + "Output Program": [ + "def cal_sum(n): \r\n\ta = 3\r\n\tb = 0\r\n\tc = 2\r\n\tif (n == 0): \r\n\t\treturn 3\r\n\tif (n == 1): \r\n\t\treturn 3\r\n\tif (n == 2): \r\n\t\treturn 5\r\n\tsum = 5\r\n\twhile (n > 2): \r\n\t\td = a + b \r\n\t\tsum = sum + d \r\n\t\ta = b \r\n\t\tb = c \r\n\t\tc = d \r\n\t\tn = n-1\r\n\treturn sum" + ], + "Output Answer": [ + "def cal_sum(n): \r\n\ta = 3\r\n\tb = 0\r\n\tc = 2\r\n\tif (n == 0): \r\n\t\treturn 3\r\n\tif (n == 1): \r\n\t\treturn 3\r\n\tif (n == 2): \r\n\t\treturn 5\r\n\tsum = 5\r\n\twhile (n > 2): \r\n\t\td = a + b \r\n\t\tsum = sum + d \r\n\t\ta = b \r\n\t\tb = c \r\n\t\tc = d \r\n\t\tn = n-1\r\n\treturn sum" + ], + "split": "test" + }, + { + "Input": "Write a python function to check whether the triangle is valid or not if 3 points are given.", + "Output Program": [ + "def check_Triangle(x1,y1,x2,y2,x3,y3): \r\n a = (x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2)) \r\n if a == 0: \r\n return ('No') \r\n else: \r\n return ('Yes') " + ], + "Output Answer": [ + "def check_Triangle(x1,y1,x2,y2,x3,y3): \r\n a = (x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2)) \r\n if a == 0: \r\n return ('No') \r\n else: \r\n return ('Yes') " + ], + "split": "test" + }, + { + "Input": "Write a function to extract specified size of strings from a give list of string values.", + "Output Program": [ + "def extract_string(str, l):\r\n result = [e for e in str if len(e) == l] \r\n return result" + ], + "Output Answer": [ + "def extract_string(str, l):\r\n result = [e for e in str if len(e) == l] \r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a function to remove all whitespaces from the given string using regex.", + "Output Program": [ + "import re\r\ndef remove_whitespaces(text1):\r\n return (re.sub(r'\\s+', '',text1))" + ], + "Output Answer": [ + "import re\r\ndef remove_whitespaces(text1):\r\n return (re.sub(r'\\s+', '',text1))" + ], + "split": "test" + }, + { + "Input": "Write a function that gives loss amount if the given amount has loss else return none.", + "Output Program": [ + "def loss_amount(actual_cost,sale_amount): \r\n if(sale_amount > actual_cost):\r\n amount = sale_amount - actual_cost\r\n return amount\r\n else:\r\n return None" + ], + "Output Answer": [ + "def loss_amount(actual_cost,sale_amount): \r\n if(sale_amount > actual_cost):\r\n amount = sale_amount - actual_cost\r\n return amount\r\n else:\r\n return None" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the sum of even factors of a number.", + "Output Program": [ + "import math \r\ndef sumofFactors(n) : \r\n if (n % 2 != 0) : \r\n return 0\r\n res = 1\r\n for i in range(2, (int)(math.sqrt(n)) + 1) : \r\n count = 0\r\n curr_sum = 1\r\n curr_term = 1\r\n while (n % i == 0) : \r\n count= count + 1\r\n n = n // i \r\n if (i == 2 and count == 1) : \r\n curr_sum = 0\r\n curr_term = curr_term * i \r\n curr_sum = curr_sum + curr_term \r\n res = res * curr_sum \r\n if (n >= 2) : \r\n res = res * (1 + n) \r\n return res " + ], + "Output Answer": [ + "import math \r\ndef sumofFactors(n) : \r\n if (n % 2 != 0) : \r\n return 0\r\n res = 1\r\n for i in range(2, (int)(math.sqrt(n)) + 1) : \r\n count = 0\r\n curr_sum = 1\r\n curr_term = 1\r\n while (n % i == 0) : \r\n count= count + 1\r\n n = n // i \r\n if (i == 2 and count == 1) : \r\n curr_sum = 0\r\n curr_term = curr_term * i \r\n curr_sum = curr_sum + curr_term \r\n res = res * curr_sum \r\n if (n >= 2) : \r\n res = res * (1 + n) \r\n return res " + ], + "split": "test" + }, + { + "Input": "Write a function that matches a word containing 'z'.", + "Output Program": [ + "import re\r\ndef text_match_wordz(text):\r\n patterns = '\\w*z.\\w*'\r\n if re.search(patterns, text):\r\n return 'Found a match!'\r\n else:\r\n return('Not matched!')" + ], + "Output Answer": [ + "import re\r\ndef text_match_wordz(text):\r\n patterns = '\\w*z.\\w*'\r\n if re.search(patterns, text):\r\n return 'Found a match!'\r\n else:\r\n return('Not matched!')" + ], + "split": "test" + }, + { + "Input": "Write a function to check whether the given month number contains 31 days or not.", + "Output Program": [ + "def check_monthnumb_number(monthnum2):\r\n if(monthnum2==1 or monthnum2==3 or monthnum2==5 or monthnum2==7 or monthnum2==8 or monthnum2==10 or monthnum2==12):\r\n return True\r\n else:\r\n return False" + ], + "Output Answer": [ + "def check_monthnumb_number(monthnum2):\r\n if(monthnum2==1 or monthnum2==3 or monthnum2==5 or monthnum2==7 or monthnum2==8 or monthnum2==10 or monthnum2==12):\r\n return True\r\n else:\r\n return False" + ], + "split": "test" + }, + { + "Input": "Write a function to reverse strings in a given list of string values.", + "Output Program": [ + "def reverse_string_list(stringlist):\r\n result = [x[::-1] for x in stringlist]\r\n return result" + ], + "Output Answer": [ + "def reverse_string_list(stringlist):\r\n result = [x[::-1] for x in stringlist]\r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the sublist having minimum length.", + "Output Program": [ + "def Find_Min(lst): \r\n minList = min((x) for x in lst) \r\n return minList" + ], + "Output Answer": [ + "def Find_Min(lst): \r\n minList = min((x) for x in lst) \r\n return minList" + ], + "split": "test" + }, + { + "Input": "Write a function to find the area of a rectangle.", + "Output Program": [ + "def rectangle_area(l,b):\r\n area=l*b\r\n return area" + ], + "Output Answer": [ + "def rectangle_area(l,b):\r\n area=l*b\r\n return area" + ], + "split": "test" + }, + { + "Input": "Write a function to remove uppercase substrings from a given string by using regex.", + "Output Program": [ + "import re\r\ndef remove_uppercase(str1):\r\n remove_upper = lambda text: re.sub('[A-Z]', '', text)\r\n result = remove_upper(str1)\r\n return (result)" + ], + "Output Answer": [ + "import re\r\ndef remove_uppercase(str1):\r\n remove_upper = lambda text: re.sub('[A-Z]', '', text)\r\n result = remove_upper(str1)\r\n return (result)" + ], + "split": "test" + }, + { + "Input": "Write a python function to get the first element of each sublist.", + "Output Program": [ + "def Extract(lst): \r\n return [item[0] for item in lst] " + ], + "Output Answer": [ + "def Extract(lst): \r\n return [item[0] for item in lst] " + ], + "split": "test" + }, + { + "Input": "Write a python function to count the upper case characters in a given string.", + "Output Program": [ + "def upper_ctr(str):\r\n upper_ctr = 0\r\n for i in range(len(str)):\r\n if str[i] >= 'A' and str[i] <= 'Z': upper_ctr += 1\r\n return upper_ctr" + ], + "Output Answer": [ + "def upper_ctr(str):\r\n upper_ctr = 0\r\n for i in range(len(str)):\r\n if str[i] >= 'A' and str[i] <= 'Z': upper_ctr += 1\r\n return upper_ctr" + ], + "split": "test" + }, + { + "Input": "Write a function to find all possible combinations of the elements of a given list.", + "Output Program": [ + "def combinations_list(list1):\r\n if len(list1) == 0:\r\n return [[]]\r\n result = []\r\n for el in combinations_list(list1[1:]):\r\n result += [el, el+[list1[0]]]\r\n return result" + ], + "Output Answer": [ + "def combinations_list(list1):\r\n if len(list1) == 0:\r\n return [[]]\r\n result = []\r\n for el in combinations_list(list1[1:]):\r\n result += [el, el+[list1[0]]]\r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a function to find the maximum product subarray of the given array.", + "Output Program": [ + "def max_subarray_product(arr):\r\n\tn = len(arr)\r\n\tmax_ending_here = 1\r\n\tmin_ending_here = 1\r\n\tmax_so_far = 0\r\n\tflag = 0\r\n\tfor i in range(0, n):\r\n\t\tif arr[i] > 0:\r\n\t\t\tmax_ending_here = max_ending_here * arr[i]\r\n\t\t\tmin_ending_here = min (min_ending_here * arr[i], 1)\r\n\t\t\tflag = 1\r\n\t\telif arr[i] == 0:\r\n\t\t\tmax_ending_here = 1\r\n\t\t\tmin_ending_here = 1\r\n\t\telse:\r\n\t\t\ttemp = max_ending_here\r\n\t\t\tmax_ending_here = max (min_ending_here * arr[i], 1)\r\n\t\t\tmin_ending_here = temp * arr[i]\r\n\t\tif (max_so_far < max_ending_here):\r\n\t\t\tmax_so_far = max_ending_here\r\n\tif flag == 0 and max_so_far == 0:\r\n\t\treturn 0\r\n\treturn max_so_far" + ], + "Output Answer": [ + "def max_subarray_product(arr):\r\n\tn = len(arr)\r\n\tmax_ending_here = 1\r\n\tmin_ending_here = 1\r\n\tmax_so_far = 0\r\n\tflag = 0\r\n\tfor i in range(0, n):\r\n\t\tif arr[i] > 0:\r\n\t\t\tmax_ending_here = max_ending_here * arr[i]\r\n\t\t\tmin_ending_here = min (min_ending_here * arr[i], 1)\r\n\t\t\tflag = 1\r\n\t\telif arr[i] == 0:\r\n\t\t\tmax_ending_here = 1\r\n\t\t\tmin_ending_here = 1\r\n\t\telse:\r\n\t\t\ttemp = max_ending_here\r\n\t\t\tmax_ending_here = max (min_ending_here * arr[i], 1)\r\n\t\t\tmin_ending_here = temp * arr[i]\r\n\t\tif (max_so_far < max_ending_here):\r\n\t\t\tmax_so_far = max_ending_here\r\n\tif flag == 0 and max_so_far == 0:\r\n\t\treturn 0\r\n\treturn max_so_far" + ], + "split": "test" + }, + { + "Input": "Write a function to check if all values are same in a dictionary.", + "Output Program": [ + "def check_value(dict, n):\r\n result = all(x == n for x in dict.values()) \r\n return result" + ], + "Output Answer": [ + "def check_value(dict, n):\r\n result = all(x == n for x in dict.values()) \r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a function to drop empty items from a given dictionary.", + "Output Program": [ + "def drop_empty(dict1):\r\n dict1 = {key:value for (key, value) in dict1.items() if value is not None}\r\n return dict1" + ], + "Output Answer": [ + "def drop_empty(dict1):\r\n dict1 = {key:value for (key, value) in dict1.items() if value is not None}\r\n return dict1" + ], + "split": "test" + }, + { + "Input": "Write a function to find the peak element in the given array.", + "Output Program": [ + "def find_peak_util(arr, low, high, n): \r\n\tmid = low + (high - low)/2\r\n\tmid = int(mid) \r\n\tif ((mid == 0 or arr[mid - 1] <= arr[mid]) and\r\n\t\t(mid == n - 1 or arr[mid + 1] <= arr[mid])): \r\n\t\treturn mid \r\n\telif (mid > 0 and arr[mid - 1] > arr[mid]): \r\n\t\treturn find_peak_util(arr, low, (mid - 1), n) \r\n\telse: \r\n\t\treturn find_peak_util(arr, (mid + 1), high, n) \r\ndef find_peak(arr, n): \r\n\treturn find_peak_util(arr, 0, n - 1, n) " + ], + "Output Answer": [ + "def find_peak_util(arr, low, high, n): \r\n\tmid = low + (high - low)/2\r\n\tmid = int(mid) \r\n\tif ((mid == 0 or arr[mid - 1] <= arr[mid]) and\r\n\t\t(mid == n - 1 or arr[mid + 1] <= arr[mid])): \r\n\t\treturn mid \r\n\telif (mid > 0 and arr[mid - 1] > arr[mid]): \r\n\t\treturn find_peak_util(arr, low, (mid - 1), n) \r\n\telse: \r\n\t\treturn find_peak_util(arr, (mid + 1), high, n) \r\ndef find_peak(arr, n): \r\n\treturn find_peak_util(arr, 0, n - 1, n) " + ], + "split": "test" + }, + { + "Input": "Write a python function to convert decimal number to octal number.", + "Output Program": [ + "def decimal_to_Octal(deciNum):\r\n octalNum = 0\r\n countval = 1;\r\n dNo = deciNum;\r\n while (deciNum!= 0):\r\n remainder= deciNum % 8;\r\n octalNum+= remainder*countval;\r\n countval= countval*10;\r\n deciNum //= 8; \r\n return (octalNum)" + ], + "Output Answer": [ + "def decimal_to_Octal(deciNum):\r\n octalNum = 0\r\n countval = 1;\r\n dNo = deciNum;\r\n while (deciNum!= 0):\r\n remainder= deciNum % 8;\r\n octalNum+= remainder*countval;\r\n countval= countval*10;\r\n deciNum //= 8; \r\n return (octalNum)" + ], + "split": "test" + }, + { + "Input": "Write a function to find the maximum product formed by multiplying numbers of an increasing subsequence of that array.", + "Output Program": [ + "def max_product(arr, n ): \r\n\tmpis =[0] * (n) \r\n\tfor i in range(n): \r\n\t\tmpis[i] = arr[i] \r\n\tfor i in range(1, n): \r\n\t\tfor j in range(i): \r\n\t\t\tif (arr[i] > arr[j] and\r\n\t\t\t\t\tmpis[i] < (mpis[j] * arr[i])): \r\n\t\t\t\t\t\tmpis[i] = mpis[j] * arr[i] \r\n\treturn max(mpis)" + ], + "Output Answer": [ + "def max_product(arr, n ): \r\n\tmpis =[0] * (n) \r\n\tfor i in range(n): \r\n\t\tmpis[i] = arr[i] \r\n\tfor i in range(1, n): \r\n\t\tfor j in range(i): \r\n\t\t\tif (arr[i] > arr[j] and\r\n\t\t\t\t\tmpis[i] < (mpis[j] * arr[i])): \r\n\t\t\t\t\t\tmpis[i] = mpis[j] * arr[i] \r\n\treturn max(mpis)" + ], + "split": "test" + }, + { + "Input": "Write a function to find the maximum profit earned from a maximum of k stock transactions", + "Output Program": [ + "def max_profit(price, k):\r\n n = len(price)\r\n final_profit = [[None for x in range(n)] for y in range(k + 1)]\r\n for i in range(k + 1):\r\n for j in range(n):\r\n if i == 0 or j == 0:\r\n final_profit[i][j] = 0\r\n else:\r\n max_so_far = 0\r\n for x in range(j):\r\n curr_price = price[j] - price[x] + final_profit[i-1][x]\r\n if max_so_far < curr_price:\r\n max_so_far = curr_price\r\n final_profit[i][j] = max(final_profit[i][j-1], max_so_far)\r\n return final_profit[k][n-1]" + ], + "Output Answer": [ + "def max_profit(price, k):\r\n n = len(price)\r\n final_profit = [[None for x in range(n)] for y in range(k + 1)]\r\n for i in range(k + 1):\r\n for j in range(n):\r\n if i == 0 or j == 0:\r\n final_profit[i][j] = 0\r\n else:\r\n max_so_far = 0\r\n for x in range(j):\r\n curr_price = price[j] - price[x] + final_profit[i-1][x]\r\n if max_so_far < curr_price:\r\n max_so_far = curr_price\r\n final_profit[i][j] = max(final_profit[i][j-1], max_so_far)\r\n return final_profit[k][n-1]" + ], + "split": "test" + }, + { + "Input": "Write a function to find the pairwise addition of the elements of the given tuples.", + "Output Program": [ + "def add_pairwise(test_tup):\r\n res = tuple(i + j for i, j in zip(test_tup, test_tup[1:]))\r\n return (res) " + ], + "Output Answer": [ + "def add_pairwise(test_tup):\r\n res = tuple(i + j for i, j in zip(test_tup, test_tup[1:]))\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a python function to find remainder of array multiplication divided by n.", + "Output Program": [ + "def find_remainder(arr, lens, n): \r\n mul = 1\r\n for i in range(lens): \r\n mul = (mul * (arr[i] % n)) % n \r\n return mul % n " + ], + "Output Answer": [ + "def find_remainder(arr, lens, n): \r\n mul = 1\r\n for i in range(lens): \r\n mul = (mul * (arr[i] % n)) % n \r\n return mul % n " + ], + "split": "test" + }, + { + "Input": "Write a python function to check whether the given list contains consecutive numbers or not.", + "Output Program": [ + "def check_Consecutive(l): \r\n return sorted(l) == list(range(min(l),max(l)+1)) " + ], + "Output Answer": [ + "def check_Consecutive(l): \r\n return sorted(l) == list(range(min(l),max(l)+1)) " + ], + "split": "test" + }, + { + "Input": "Write a function to find the tuple intersection of elements in the given tuple list irrespective of their order.", + "Output Program": [ + "def tuple_intersection(test_list1, test_list2):\r\n res = set([tuple(sorted(ele)) for ele in test_list1]) & set([tuple(sorted(ele)) for ele in test_list2])\r\n return (res)" + ], + "Output Answer": [ + "def tuple_intersection(test_list1, test_list2):\r\n res = set([tuple(sorted(ele)) for ele in test_list1]) & set([tuple(sorted(ele)) for ele in test_list2])\r\n return (res)" + ], + "split": "test" + }, + { + "Input": "Write a function to replace characters in a string.", + "Output Program": [ + "def replace_char(str1,ch,newch):\r\n str2 = str1.replace(ch, newch)\r\n return str2" + ], + "Output Answer": [ + "def replace_char(str1,ch,newch):\r\n str2 = str1.replace(ch, newch)\r\n return str2" + ], + "split": "test" + }, + { + "Input": "Write a function to sort counter by value.", + "Output Program": [ + "from collections import Counter\r\ndef sort_counter(dict1):\r\n x = Counter(dict1)\r\n sort_counter=x.most_common()\r\n return sort_counter" + ], + "Output Answer": [ + "from collections import Counter\r\ndef sort_counter(dict1):\r\n x = Counter(dict1)\r\n sort_counter=x.most_common()\r\n return sort_counter" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the sum of the largest and smallest value in a given array.", + "Output Program": [ + "def big_sum(nums):\r\n sum= max(nums)+min(nums)\r\n return sum" + ], + "Output Answer": [ + "def big_sum(nums):\r\n sum= max(nums)+min(nums)\r\n return sum" + ], + "split": "test" + }, + { + "Input": "Write a python function to convert the given string to lower case.", + "Output Program": [ + "def is_lower(string):\r\n return (string.lower())" + ], + "Output Answer": [ + "def is_lower(string):\r\n return (string.lower())" + ], + "split": "test" + }, + { + "Input": "Write a function to remove lowercase substrings from a given string.", + "Output Program": [ + "import re\r\ndef remove_lowercase(str1):\r\n remove_lower = lambda text: re.sub('[a-z]', '', text)\r\n result = remove_lower(str1)\r\n return result" + ], + "Output Answer": [ + "import re\r\ndef remove_lowercase(str1):\r\n remove_lower = lambda text: re.sub('[a-z]', '', text)\r\n result = remove_lower(str1)\r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the first digit of a given number.", + "Output Program": [ + "def first_Digit(n) : \r\n while n >= 10: \r\n n = n / 10; \r\n return int(n) " + ], + "Output Answer": [ + "def first_Digit(n) : \r\n while n >= 10: \r\n n = n / 10; \r\n return int(n) " + ], + "split": "test" + }, + { + "Input": "Write a python function to find the maximum occurring character in a given string.", + "Output Program": [ + "def get_max_occuring_char(str1):\r\n ASCII_SIZE = 256\r\n ctr = [0] * ASCII_SIZE\r\n max = -1\r\n ch = ''\r\n for i in str1:\r\n ctr[ord(i)]+=1;\r\n for i in str1:\r\n if max < ctr[ord(i)]:\r\n max = ctr[ord(i)]\r\n ch = i\r\n return ch" + ], + "Output Answer": [ + "def get_max_occuring_char(str1):\r\n ASCII_SIZE = 256\r\n ctr = [0] * ASCII_SIZE\r\n max = -1\r\n ch = ''\r\n for i in str1:\r\n ctr[ord(i)]+=1;\r\n for i in str1:\r\n if max < ctr[ord(i)]:\r\n max = ctr[ord(i)]\r\n ch = i\r\n return ch" + ], + "split": "test" + }, + { + "Input": "Write a function to determine if there is a subset of the given set with sum equal to the given sum.", + "Output Program": [ + "def is_subset_sum(set, n, sum):\r\n\tif (sum == 0):\r\n\t\treturn True\r\n\tif (n == 0):\r\n\t\treturn False\r\n\tif (set[n - 1] > sum):\r\n\t\treturn is_subset_sum(set, n - 1, sum)\r\n\treturn is_subset_sum(set, n-1, sum) or is_subset_sum(set, n-1, sum-set[n-1])" + ], + "Output Answer": [ + "def is_subset_sum(set, n, sum):\r\n\tif (sum == 0):\r\n\t\treturn True\r\n\tif (n == 0):\r\n\t\treturn False\r\n\tif (set[n - 1] > sum):\r\n\t\treturn is_subset_sum(set, n - 1, sum)\r\n\treturn is_subset_sum(set, n-1, sum) or is_subset_sum(set, n-1, sum-set[n-1])" + ], + "split": "test" + }, + { + "Input": "Write a function to find sequences of one upper case letter followed by lower case letters in the given string by using regex.", + "Output Program": [ + "import re \r\ndef match(text): \r\n\t\tpattern = '[A-Z]+[a-z]+$'\r\n\t\tif re.search(pattern, text): \r\n\t\t\t\treturn('Yes') \r\n\t\telse: \r\n\t\t\t\treturn('No') " + ], + "Output Answer": [ + "import re \r\ndef match(text): \r\n\t\tpattern = '[A-Z]+[a-z]+$'\r\n\t\tif re.search(pattern, text): \r\n\t\t\t\treturn('Yes') \r\n\t\telse: \r\n\t\t\t\treturn('No') " + ], + "split": "test" + }, + { + "Input": "Write a python function to find the first natural number whose factorial is divisible by x.", + "Output Program": [ + "def first_Factorial_Divisible_Number(x): \r\n i = 1;\r\n fact = 1; \r\n for i in range(1,x): \r\n fact = fact * i \r\n if (fact % x == 0): \r\n break\r\n return i " + ], + "Output Answer": [ + "def first_Factorial_Divisible_Number(x): \r\n i = 1;\r\n fact = 1; \r\n for i in range(1,x): \r\n fact = fact * i \r\n if (fact % x == 0): \r\n break\r\n return i " + ], + "split": "test" + }, + { + "Input": "Write a function to remove the matching tuples from the given two tuples.", + "Output Program": [ + "def remove_matching_tuple(test_list1, test_list2):\r\n res = [sub for sub in test_list1 if sub not in test_list2]\r\n return (res) " + ], + "Output Answer": [ + "def remove_matching_tuple(test_list1, test_list2):\r\n res = [sub for sub in test_list1 if sub not in test_list2]\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a function to find the largest palindromic number in the given array.", + "Output Program": [ + "def is_palindrome(n) : \r\n\tdivisor = 1\r\n\twhile (n / divisor >= 10) : \r\n\t\tdivisor *= 10\r\n\twhile (n != 0) : \r\n\t\tleading = n // divisor \r\n\t\ttrailing = n % 10\r\n\t\tif (leading != trailing) : \r\n\t\t\treturn False\r\n\t\tn = (n % divisor) // 10\r\n\t\tdivisor = divisor // 100\r\n\treturn True\r\ndef largest_palindrome(A, n) : \r\n\tA.sort() \r\n\tfor i in range(n - 1, -1, -1) : \r\n\t\tif (is_palindrome(A[i])) : \r\n\t\t\treturn A[i] \r\n\treturn -1" + ], + "Output Answer": [ + "def is_palindrome(n) : \r\n\tdivisor = 1\r\n\twhile (n / divisor >= 10) : \r\n\t\tdivisor *= 10\r\n\twhile (n != 0) : \r\n\t\tleading = n // divisor \r\n\t\ttrailing = n % 10\r\n\t\tif (leading != trailing) : \r\n\t\t\treturn False\r\n\t\tn = (n % divisor) // 10\r\n\t\tdivisor = divisor // 100\r\n\treturn True\r\ndef largest_palindrome(A, n) : \r\n\tA.sort() \r\n\tfor i in range(n - 1, -1, -1) : \r\n\t\tif (is_palindrome(A[i])) : \r\n\t\t\treturn A[i] \r\n\treturn -1" + ], + "split": "test" + }, + { + "Input": "Write a function to compute binomial probability for the given number.", + "Output Program": [ + "def nCr(n, r): \r\n\tif (r > n / 2): \r\n\t\tr = n - r \r\n\tanswer = 1 \r\n\tfor i in range(1, r + 1): \r\n\t\tanswer *= (n - r + i) \r\n\t\tanswer /= i \r\n\treturn answer \r\ndef binomial_probability(n, k, p): \r\n\treturn (nCr(n, k) * pow(p, k) *\tpow(1 - p, n - k)) " + ], + "Output Answer": [ + "def nCr(n, r): \r\n\tif (r > n / 2): \r\n\t\tr = n - r \r\n\tanswer = 1 \r\n\tfor i in range(1, r + 1): \r\n\t\tanswer *= (n - r + i) \r\n\t\tanswer /= i \r\n\treturn answer \r\ndef binomial_probability(n, k, p): \r\n\treturn (nCr(n, k) * pow(p, k) *\tpow(1 - p, n - k)) " + ], + "split": "test" + }, + { + "Input": "Write a function to sort a list of tuples in increasing order by the last element in each tuple.", + "Output Program": [ + "def sort_tuple(tup): \r\n\tlst = len(tup) \r\n\tfor i in range(0, lst): \r\n\t\tfor j in range(0, lst-i-1): \r\n\t\t\tif (tup[j][-1] > tup[j + 1][-1]): \r\n\t\t\t\ttemp = tup[j] \r\n\t\t\t\ttup[j]= tup[j + 1] \r\n\t\t\t\ttup[j + 1]= temp \r\n\treturn tup" + ], + "Output Answer": [ + "def sort_tuple(tup): \r\n\tlst = len(tup) \r\n\tfor i in range(0, lst): \r\n\t\tfor j in range(0, lst-i-1): \r\n\t\t\tif (tup[j][-1] > tup[j + 1][-1]): \r\n\t\t\t\ttemp = tup[j] \r\n\t\t\t\ttup[j]= tup[j + 1] \r\n\t\t\t\ttup[j + 1]= temp \r\n\treturn tup" + ], + "split": "test" + }, + { + "Input": "Write a function to find the area of a pentagon.", + "Output Program": [ + "import math\r\ndef area_pentagon(a):\r\n area=(math.sqrt(5*(5+2*math.sqrt(5)))*pow(a,2))/4.0\r\n return area" + ], + "Output Answer": [ + "import math\r\ndef area_pentagon(a):\r\n area=(math.sqrt(5*(5+2*math.sqrt(5)))*pow(a,2))/4.0\r\n return area" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the frequency of the largest value in a given array.", + "Output Program": [ + "def frequency_Of_Largest(n,arr): \r\n mn = arr[0] \r\n freq = 1\r\n for i in range(1,n): \r\n if (arr[i] >mn): \r\n mn = arr[i] \r\n freq = 1\r\n elif (arr[i] == mn): \r\n freq += 1\r\n return freq " + ], + "Output Answer": [ + "def frequency_Of_Largest(n,arr): \r\n mn = arr[0] \r\n freq = 1\r\n for i in range(1,n): \r\n if (arr[i] >mn): \r\n mn = arr[i] \r\n freq = 1\r\n elif (arr[i] == mn): \r\n freq += 1\r\n return freq " + ], + "split": "test" + }, + { + "Input": "Write a function to extract all the pairs which are symmetric in the given tuple list.", + "Output Program": [ + "def extract_symmetric(test_list):\r\n temp = set(test_list) & {(b, a) for a, b in test_list}\r\n res = {(a, b) for a, b in temp if a < b}\r\n return (res) " + ], + "Output Answer": [ + "def extract_symmetric(test_list):\r\n temp = set(test_list) & {(b, a) for a, b in test_list}\r\n res = {(a, b) for a, b in temp if a < b}\r\n return (res) " + ], + "split": "test" + }, + { + "Input": "Write a function to find the sum of geometric progression series.", + "Output Program": [ + "import math\r\ndef sum_gp(a,n,r):\r\n total = (a * (1 - math.pow(r, n ))) / (1- r)\r\n return total" + ], + "Output Answer": [ + "import math\r\ndef sum_gp(a,n,r):\r\n total = (a * (1 - math.pow(r, n ))) / (1- r)\r\n return total" + ], + "split": "test" + }, + { + "Input": "Write a function to search an element in the given array by using binary search.", + "Output Program": [ + "def binary_search(item_list,item):\r\n\tfirst = 0\r\n\tlast = len(item_list)-1\r\n\tfound = False\r\n\twhile( first<=last and not found):\r\n\t\tmid = (first + last)//2\r\n\t\tif item_list[mid] == item :\r\n\t\t\tfound = True\r\n\t\telse:\r\n\t\t\tif item < item_list[mid]:\r\n\t\t\t\tlast = mid - 1\r\n\t\t\telse:\r\n\t\t\t\tfirst = mid + 1\t\r\n\treturn found" + ], + "Output Answer": [ + "def binary_search(item_list,item):\r\n\tfirst = 0\r\n\tlast = len(item_list)-1\r\n\tfound = False\r\n\twhile( first<=last and not found):\r\n\t\tmid = (first + last)//2\r\n\t\tif item_list[mid] == item :\r\n\t\t\tfound = True\r\n\t\telse:\r\n\t\t\tif item < item_list[mid]:\r\n\t\t\t\tlast = mid - 1\r\n\t\t\telse:\r\n\t\t\t\tfirst = mid + 1\t\r\n\treturn found" + ], + "split": "test" + }, + { + "Input": "Write a function to calculate a grid of hexagon coordinates where function returns a list of lists containing 6 tuples of x, y point coordinates.", + "Output Program": [ + "import math\r\ndef calculate_polygons(startx, starty, endx, endy, radius):\r\n sl = (2 * radius) * math.tan(math.pi / 6)\r\n p = sl * 0.5\r\n b = sl * math.cos(math.radians(30))\r\n w = b * 2\r\n h = 2 * sl \r\n startx = startx - w\r\n starty = starty - h\r\n endx = endx + w\r\n endy = endy + h\r\n origx = startx\r\n origy = starty\r\n xoffset = b\r\n yoffset = 3 * p\r\n polygons = []\r\n row = 1\r\n counter = 0\r\n while starty < endy:\r\n if row % 2 == 0:\r\n startx = origx + xoffset\r\n else:\r\n startx = origx\r\n while startx < endx:\r\n p1x = startx\r\n p1y = starty + p\r\n p2x = startx\r\n p2y = starty + (3 * p)\r\n p3x = startx + b\r\n p3y = starty + h\r\n p4x = startx + w\r\n p4y = starty + (3 * p)\r\n p5x = startx + w\r\n p5y = starty + p\r\n p6x = startx + b\r\n p6y = starty\r\n poly = [\r\n (p1x, p1y),\r\n (p2x, p2y),\r\n (p3x, p3y),\r\n (p4x, p4y),\r\n (p5x, p5y),\r\n (p6x, p6y),\r\n (p1x, p1y)]\r\n polygons.append(poly)\r\n counter += 1\r\n startx += w\r\n starty += yoffset\r\n row += 1\r\n return polygons" + ], + "Output Answer": [ + "import math\r\ndef calculate_polygons(startx, starty, endx, endy, radius):\r\n sl = (2 * radius) * math.tan(math.pi / 6)\r\n p = sl * 0.5\r\n b = sl * math.cos(math.radians(30))\r\n w = b * 2\r\n h = 2 * sl \r\n startx = startx - w\r\n starty = starty - h\r\n endx = endx + w\r\n endy = endy + h\r\n origx = startx\r\n origy = starty\r\n xoffset = b\r\n yoffset = 3 * p\r\n polygons = []\r\n row = 1\r\n counter = 0\r\n while starty < endy:\r\n if row % 2 == 0:\r\n startx = origx + xoffset\r\n else:\r\n startx = origx\r\n while startx < endx:\r\n p1x = startx\r\n p1y = starty + p\r\n p2x = startx\r\n p2y = starty + (3 * p)\r\n p3x = startx + b\r\n p3y = starty + h\r\n p4x = startx + w\r\n p4y = starty + (3 * p)\r\n p5x = startx + w\r\n p5y = starty + p\r\n p6x = startx + b\r\n p6y = starty\r\n poly = [\r\n (p1x, p1y),\r\n (p2x, p2y),\r\n (p3x, p3y),\r\n (p4x, p4y),\r\n (p5x, p5y),\r\n (p6x, p6y),\r\n (p1x, p1y)]\r\n polygons.append(poly)\r\n counter += 1\r\n startx += w\r\n starty += yoffset\r\n row += 1\r\n return polygons" + ], + "split": "test" + }, + { + "Input": "Write a function to convert the given binary tuple to integer.", + "Output Program": [ + "def binary_to_integer(test_tup):\r\n res = int(\"\".join(str(ele) for ele in test_tup), 2)\r\n return (str(res)) " + ], + "Output Answer": [ + "def binary_to_integer(test_tup):\r\n res = int(\"\".join(str(ele) for ele in test_tup), 2)\r\n return (str(res)) " + ], + "split": "test" + }, + { + "Input": "Write a function to remove lowercase substrings from a given string by using regex.", + "Output Program": [ + "import re\r\ndef remove_lowercase(str1):\r\n remove_lower = lambda text: re.sub('[a-z]', '', text)\r\n result = remove_lower(str1)\r\n return (result)" + ], + "Output Answer": [ + "import re\r\ndef remove_lowercase(str1):\r\n remove_lower = lambda text: re.sub('[a-z]', '', text)\r\n result = remove_lower(str1)\r\n return (result)" + ], + "split": "test" + }, + { + "Input": "Write a function to find the smallest integers from a given list of numbers using heap queue algorithm.", + "Output Program": [ + "import heapq as hq\r\ndef heap_queue_smallest(nums,n):\r\n smallest_nums = hq.nsmallest(n, nums)\r\n return smallest_nums" + ], + "Output Answer": [ + "import heapq as hq\r\ndef heap_queue_smallest(nums,n):\r\n smallest_nums = hq.nsmallest(n, nums)\r\n return smallest_nums" + ], + "split": "test" + }, + { + "Input": "Write a function to find the surface area of a cone.", + "Output Program": [ + "import math\r\ndef surfacearea_cone(r,h):\r\n l = math.sqrt(r * r + h * h)\r\n SA = math.pi * r * (r + l)\r\n return SA" + ], + "Output Answer": [ + "import math\r\ndef surfacearea_cone(r,h):\r\n l = math.sqrt(r * r + h * h)\r\n SA = math.pi * r * (r + l)\r\n return SA" + ], + "split": "test" + }, + { + "Input": "Write a python function to find gcd of two positive integers.", + "Output Program": [ + "def gcd(x, y):\r\n gcd = 1\r\n if x % y == 0:\r\n return y\r\n for k in range(int(y / 2), 0, -1):\r\n if x % k == 0 and y % k == 0:\r\n gcd = k\r\n break \r\n return gcd" + ], + "Output Answer": [ + "def gcd(x, y):\r\n gcd = 1\r\n if x % y == 0:\r\n return y\r\n for k in range(int(y / 2), 0, -1):\r\n if x % k == 0 and y % k == 0:\r\n gcd = k\r\n break \r\n return gcd" + ], + "split": "test" + }, + { + "Input": "Write a function to find the diameter of a circle.", + "Output Program": [ + "def diameter_circle(r):\r\n diameter=2*r\r\n return diameter" + ], + "Output Answer": [ + "def diameter_circle(r):\r\n diameter=2*r\r\n return diameter" + ], + "split": "test" + }, + { + "Input": "Write a function to concatenate all elements of the given list into a string.", + "Output Program": [ + "def concatenate_elements(list):\r\n ans = ' '\r\n for i in list:\r\n ans = ans+ ' '+i\r\n return (ans) " + ], + "Output Answer": [ + "def concatenate_elements(list):\r\n ans = ' '\r\n for i in list:\r\n ans = ans+ ' '+i\r\n return (ans) " + ], + "split": "test" + }, + { + "Input": "Write a python function to find common divisor between two numbers in a given pair.", + "Output Program": [ + "def ngcd(x,y):\r\n i=1\r\n while(i<=x and i<=y):\r\n if(x%i==0 and y%i == 0):\r\n gcd=i;\r\n i+=1\r\n return gcd;\r\ndef num_comm_div(x,y):\r\n n = ngcd(x,y)\r\n result = 0\r\n z = int(n**0.5)\r\n i = 1\r\n while(i <= z):\r\n if(n % i == 0):\r\n result += 2 \r\n if(i == n/i):\r\n result-=1\r\n i+=1\r\n return result" + ], + "Output Answer": [ + "def ngcd(x,y):\r\n i=1\r\n while(i<=x and i<=y):\r\n if(x%i==0 and y%i == 0):\r\n gcd=i;\r\n i+=1\r\n return gcd;\r\ndef num_comm_div(x,y):\r\n n = ngcd(x,y)\r\n result = 0\r\n z = int(n**0.5)\r\n i = 1\r\n while(i <= z):\r\n if(n % i == 0):\r\n result += 2 \r\n if(i == n/i):\r\n result-=1\r\n i+=1\r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a python function to find remainder of two numbers.", + "Output Program": [ + "def find(n,m):\r\n r = n%m\r\n return (r)" + ], + "Output Answer": [ + "def find(n,m):\r\n r = n%m\r\n return (r)" + ], + "split": "test" + }, + { + "Input": "Write a function to add consecutive numbers of a given list.", + "Output Program": [ + "def add_consecutive_nums(nums):\r\n result = [b+a for a, b in zip(nums[:-1], nums[1:])]\r\n return result" + ], + "Output Answer": [ + "def add_consecutive_nums(nums):\r\n result = [b+a for a, b in zip(nums[:-1], nums[1:])]\r\n return result" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the cube sum of first n natural numbers.", + "Output Program": [ + "def sum_Of_Series(n): \r\n sum = 0\r\n for i in range(1,n + 1): \r\n sum += i * i*i \r\n return sum" + ], + "Output Answer": [ + "def sum_Of_Series(n): \r\n sum = 0\r\n for i in range(1,n + 1): \r\n sum += i * i*i \r\n return sum" + ], + "split": "test" + }, + { + "Input": "Write a function to move all zeroes to the end of the given array.", + "Output Program": [ + "def re_order(A):\r\n k = 0\r\n for i in A:\r\n if i:\r\n A[k] = i\r\n k = k + 1\r\n for i in range(k, len(A)):\r\n A[i] = 0\r\n return A" + ], + "Output Answer": [ + "def re_order(A):\r\n k = 0\r\n for i in A:\r\n if i:\r\n A[k] = i\r\n k = k + 1\r\n for i in range(k, len(A)):\r\n A[i] = 0\r\n return A" + ], + "split": "test" + }, + { + "Input": "Write a function to calculate the permutation coefficient of given p(n, k).", + "Output Program": [ + "def permutation_coefficient(n, k): \r\n\tP = [[0 for i in range(k + 1)] \r\n\t\t\tfor j in range(n + 1)] \r\n\tfor i in range(n + 1): \r\n\t\tfor j in range(min(i, k) + 1): \r\n\t\t\tif (j == 0): \r\n\t\t\t\tP[i][j] = 1\r\n\t\t\telse: \r\n\t\t\t\tP[i][j] = P[i - 1][j] + ( \r\n\t\t\t\t\t\tj * P[i - 1][j - 1]) \r\n\t\t\tif (j < k): \r\n\t\t\t\tP[i][j + 1] = 0\r\n\treturn P[n][k] " + ], + "Output Answer": [ + "def permutation_coefficient(n, k): \r\n\tP = [[0 for i in range(k + 1)] \r\n\t\t\tfor j in range(n + 1)] \r\n\tfor i in range(n + 1): \r\n\t\tfor j in range(min(i, k) + 1): \r\n\t\t\tif (j == 0): \r\n\t\t\t\tP[i][j] = 1\r\n\t\t\telse: \r\n\t\t\t\tP[i][j] = P[i - 1][j] + ( \r\n\t\t\t\t\t\tj * P[i - 1][j - 1]) \r\n\t\t\tif (j < k): \r\n\t\t\t\tP[i][j + 1] = 0\r\n\treturn P[n][k] " + ], + "split": "test" + }, + { + "Input": "Write a function to remove specific words from a given list.", + "Output Program": [ + "def remove_words(list1, removewords):\r\n for word in list(list1):\r\n if word in removewords:\r\n list1.remove(word)\r\n return list1 " + ], + "Output Answer": [ + "def remove_words(list1, removewords):\r\n for word in list(list1):\r\n if word in removewords:\r\n list1.remove(word)\r\n return list1 " + ], + "split": "test" + }, + { + "Input": "Write a function to check if the common elements between two given lists are in the same order or not.", + "Output Program": [ + "def same_order(l1, l2):\r\n common_elements = set(l1) & set(l2)\r\n l1 = [e for e in l1 if e in common_elements]\r\n l2 = [e for e in l2 if e in common_elements]\r\n return l1 == l2" + ], + "Output Answer": [ + "def same_order(l1, l2):\r\n common_elements = set(l1) & set(l2)\r\n l1 = [e for e in l1 if e in common_elements]\r\n l2 = [e for e in l2 if e in common_elements]\r\n return l1 == l2" + ], + "split": "test" + }, + { + "Input": "Write a python function to find the average of odd numbers till a given odd number.", + "Output Program": [ + "def average_Odd(n) : \r\n if (n%2==0) : \r\n return (\"Invalid Input\") \r\n return -1 \r\n sm =0\r\n count =0\r\n while (n>=1) : \r\n count=count+1\r\n sm = sm + n \r\n n = n-2\r\n return sm//count " + ], + "Output Answer": [ + "def average_Odd(n) : \r\n if (n%2==0) : \r\n return (\"Invalid Input\") \r\n return -1 \r\n sm =0\r\n count =0\r\n while (n>=1) : \r\n count=count+1\r\n sm = sm + n \r\n n = n-2\r\n return sm//count " + ], + "split": "test" + }, + { + "Input": "Write a function to find the number of subsequences having product smaller than k for the given non negative array.", + "Output Program": [ + "def no_of_subsequences(arr, k): \r\n\tn = len(arr) \r\n\tdp = [[0 for i in range(n + 1)] \r\n\t\t\tfor j in range(k + 1)] \r\n\tfor i in range(1, k + 1): \r\n\t\tfor j in range(1, n + 1): \r\n\t\t\tdp[i][j] = dp[i][j - 1] \r\n\t\t\tif arr[j - 1] <= i and arr[j - 1] > 0: \r\n\t\t\t\tdp[i][j] += dp[i // arr[j - 1]][j - 1] + 1\r\n\treturn dp[k][n]" + ], + "Output Answer": [ + "def no_of_subsequences(arr, k): \r\n\tn = len(arr) \r\n\tdp = [[0 for i in range(n + 1)] \r\n\t\t\tfor j in range(k + 1)] \r\n\tfor i in range(1, k + 1): \r\n\t\tfor j in range(1, n + 1): \r\n\t\t\tdp[i][j] = dp[i][j - 1] \r\n\t\t\tif arr[j - 1] <= i and arr[j - 1] > 0: \r\n\t\t\t\tdp[i][j] += dp[i // arr[j - 1]][j - 1] + 1\r\n\treturn dp[k][n]" + ], + "split": "test" + }, + { + "Input": "Write a python function to find minimum sum of factors of a given number.", + "Output Program": [ + "def find_Min_Sum(num): \r\n sum = 0\r\n i = 2\r\n while(i * i <= num): \r\n while(num % i == 0): \r\n sum += i \r\n num /= i \r\n i += 1\r\n sum += num \r\n return sum" + ], + "Output Answer": [ + "def find_Min_Sum(num): \r\n sum = 0\r\n i = 2\r\n while(i * i <= num): \r\n while(num % i == 0): \r\n sum += i \r\n num /= i \r\n i += 1\r\n sum += num \r\n return sum" + ], + "split": "dev" + }, + { + "Input": "Write a function to count the element frequency in the mixed nested tuple.", + "Output Program": [ + "def flatten(test_tuple): \r\n\tfor tup in test_tuple: \r\n\t\tif isinstance(tup, tuple): \r\n\t\t\tyield from flatten(tup) \r\n\t\telse: \r\n\t\t\tyield tup \r\ndef count_element_freq(test_tuple):\r\n res = {}\r\n for ele in flatten(test_tuple):\r\n if ele not in res:\r\n res[ele] = 0\r\n res[ele] += 1\r\n return (res) " + ], + "Output Answer": [ + "def flatten(test_tuple): \r\n\tfor tup in test_tuple: \r\n\t\tif isinstance(tup, tuple): \r\n\t\t\tyield from flatten(tup) \r\n\t\telse: \r\n\t\t\tyield tup \r\ndef count_element_freq(test_tuple):\r\n res = {}\r\n for ele in flatten(test_tuple):\r\n if ele not in res:\r\n res[ele] = 0\r\n res[ele] += 1\r\n return (res) " + ], + "split": "dev" + }, + { + "Input": "Write a function to convert tuple into list by adding the given string after every element.", + "Output Program": [ + "def add_str(test_tup, K):\r\n res = [ele for sub in test_tup for ele in (sub, K)]\r\n return (res) " + ], + "Output Answer": [ + "def add_str(test_tup, K):\r\n res = [ele for sub in test_tup for ele in (sub, K)]\r\n return (res) " + ], + "split": "dev" + }, + { + "Input": "Write a function to find the summation of tuple elements in the given tuple list.", + "Output Program": [ + "def sum_elements(test_tup):\r\n res = sum(list(test_tup))\r\n return (res) " + ], + "Output Answer": [ + "def sum_elements(test_tup):\r\n res = sum(list(test_tup))\r\n return (res) " + ], + "split": "dev" + }, + { + "Input": "Write a function to check if there is a subset with sum divisible by m.", + "Output Program": [ + "def modular_sum(arr, n, m): \r\n\tif (n > m): \r\n\t\treturn True\r\n\tDP = [False for i in range(m)] \r\n\tfor i in range(n): \r\n\t\tif (DP[0]): \r\n\t\t\treturn True\r\n\t\ttemp = [False for i in range(m)] \r\n\t\tfor j in range(m): \r\n\t\t\tif (DP[j] == True): \r\n\t\t\t\tif (DP[(j + arr[i]) % m] == False): \r\n\t\t\t\t\ttemp[(j + arr[i]) % m] = True\r\n\t\tfor j in range(m): \r\n\t\t\tif (temp[j]): \r\n\t\t\t\tDP[j] = True\r\n\t\tDP[arr[i] % m] = True\r\n\treturn DP[0]" + ], + "Output Answer": [ + "def modular_sum(arr, n, m): \r\n\tif (n > m): \r\n\t\treturn True\r\n\tDP = [False for i in range(m)] \r\n\tfor i in range(n): \r\n\t\tif (DP[0]): \r\n\t\t\treturn True\r\n\t\ttemp = [False for i in range(m)] \r\n\t\tfor j in range(m): \r\n\t\t\tif (DP[j] == True): \r\n\t\t\t\tif (DP[(j + arr[i]) % m] == False): \r\n\t\t\t\t\ttemp[(j + arr[i]) % m] = True\r\n\t\tfor j in range(m): \r\n\t\t\tif (temp[j]): \r\n\t\t\t\tDP[j] = True\r\n\t\tDP[arr[i] % m] = True\r\n\treturn DP[0]" + ], + "split": "dev" + }, + { + "Input": "Write a function to sort a list of elements using radix sort.", + "Output Program": [ + "def radix_sort(nums):\r\n RADIX = 10\r\n placement = 1\r\n max_digit = max(nums)\r\n\r\n while placement < max_digit:\r\n buckets = [list() for _ in range( RADIX )]\r\n for i in nums:\r\n tmp = int((i / placement) % RADIX)\r\n buckets[tmp].append(i)\r\n a = 0\r\n for b in range( RADIX ):\r\n buck = buckets[b]\r\n for i in buck:\r\n nums[a] = i\r\n a += 1\r\n placement *= RADIX\r\n return nums" + ], + "Output Answer": [ + "def radix_sort(nums):\r\n RADIX = 10\r\n placement = 1\r\n max_digit = max(nums)\r\n\r\n while placement < max_digit:\r\n buckets = [list() for _ in range( RADIX )]\r\n for i in nums:\r\n tmp = int((i / placement) % RADIX)\r\n buckets[tmp].append(i)\r\n a = 0\r\n for b in range( RADIX ):\r\n buck = buckets[b]\r\n for i in buck:\r\n nums[a] = i\r\n a += 1\r\n placement *= RADIX\r\n return nums" + ], + "split": "dev" + }, + { + "Input": "Write a python function to find the largest postive number from the given list.", + "Output Program": [ + "def largest_pos(list1): \r\n max = list1[0] \r\n for x in list1: \r\n if x > max : \r\n max = x \r\n return max" + ], + "Output Answer": [ + "def largest_pos(list1): \r\n max = list1[0] \r\n for x in list1: \r\n if x > max : \r\n max = x \r\n return max" + ], + "split": "dev" + }, + { + "Input": "Write a function to find the square root of a perfect number.", + "Output Program": [ + "import math\r\ndef sqrt_root(num):\r\n sqrt_root = math.pow(num, 0.5)\r\n return sqrt_root " + ], + "Output Answer": [ + "import math\r\ndef sqrt_root(num):\r\n sqrt_root = math.pow(num, 0.5)\r\n return sqrt_root " + ], + "split": "dev" + }, + { + "Input": "Write a function to calculate volume of a tetrahedron.", + "Output Program": [ + "import math\r\ndef volume_tetrahedron(num):\r\n\tvolume = (num ** 3 / (6 * math.sqrt(2)))\t\r\n\treturn round(volume, 2)" + ], + "Output Answer": [ + "import math\r\ndef volume_tetrahedron(num):\r\n\tvolume = (num ** 3 / (6 * math.sqrt(2)))\t\r\n\treturn round(volume, 2)" + ], + "split": "dev" + }, + { + "Input": "Write a function to find the lcm of the given array elements.", + "Output Program": [ + "def find_lcm(num1, num2): \r\n\tif(num1>num2): \r\n\t\tnum = num1 \r\n\t\tden = num2 \r\n\telse: \r\n\t\tnum = num2 \r\n\t\tden = num1 \r\n\trem = num % den \r\n\twhile (rem != 0): \r\n\t\tnum = den \r\n\t\tden = rem \r\n\t\trem = num % den \r\n\tgcd = den \r\n\tlcm = int(int(num1 * num2)/int(gcd)) \r\n\treturn lcm \r\ndef get_lcm(l):\r\n num1 = l[0]\r\n num2 = l[1]\r\n lcm = find_lcm(num1, num2)\r\n for i in range(2, len(l)):\r\n lcm = find_lcm(lcm, l[i])\r\n return lcm " + ], + "Output Answer": [ + "def find_lcm(num1, num2): \r\n\tif(num1>num2): \r\n\t\tnum = num1 \r\n\t\tden = num2 \r\n\telse: \r\n\t\tnum = num2 \r\n\t\tden = num1 \r\n\trem = num % den \r\n\twhile (rem != 0): \r\n\t\tnum = den \r\n\t\tden = rem \r\n\t\trem = num % den \r\n\tgcd = den \r\n\tlcm = int(int(num1 * num2)/int(gcd)) \r\n\treturn lcm \r\ndef get_lcm(l):\r\n num1 = l[0]\r\n num2 = l[1]\r\n lcm = find_lcm(num1, num2)\r\n for i in range(2, len(l)):\r\n lcm = find_lcm(lcm, l[i])\r\n return lcm " + ], + "split": "dev" + }, + { + "Input": "Write a function to print check if the triangle is scalene or not.", + "Output Program": [ + "def check_isosceles(x,y,z):\r\n if x!=y & y!=z & z!=x:\r\n\t return True\r\n else:\r\n return False" + ], + "Output Answer": [ + "def check_isosceles(x,y,z):\r\n if x!=y & y!=z & z!=x:\r\n\t return True\r\n else:\r\n return False" + ], + "split": "dev" + }, + { + "Input": "Write a function to find the longest bitonic subsequence for the given array.", + "Output Program": [ + "def lbs(arr): \r\n\tn = len(arr) \r\n\tlis = [1 for i in range(n+1)] \r\n\tfor i in range(1 , n): \r\n\t\tfor j in range(0 , i): \r\n\t\t\tif ((arr[i] > arr[j]) and (lis[i] < lis[j] +1)): \r\n\t\t\t\tlis[i] = lis[j] + 1\r\n\tlds = [1 for i in range(n+1)] \r\n\tfor i in reversed(range(n-1)): \r\n\t\tfor j in reversed(range(i-1 ,n)): \r\n\t\t\tif(arr[i] > arr[j] and lds[i] < lds[j] + 1): \r\n\t\t\t\tlds[i] = lds[j] + 1\r\n\tmaximum = lis[0] + lds[0] - 1\r\n\tfor i in range(1 , n): \r\n\t\tmaximum = max((lis[i] + lds[i]-1), maximum) \r\n\treturn maximum" + ], + "Output Answer": [ + "def lbs(arr): \r\n\tn = len(arr) \r\n\tlis = [1 for i in range(n+1)] \r\n\tfor i in range(1 , n): \r\n\t\tfor j in range(0 , i): \r\n\t\t\tif ((arr[i] > arr[j]) and (lis[i] < lis[j] +1)): \r\n\t\t\t\tlis[i] = lis[j] + 1\r\n\tlds = [1 for i in range(n+1)] \r\n\tfor i in reversed(range(n-1)): \r\n\t\tfor j in reversed(range(i-1 ,n)): \r\n\t\t\tif(arr[i] > arr[j] and lds[i] < lds[j] + 1): \r\n\t\t\t\tlds[i] = lds[j] + 1\r\n\tmaximum = lis[0] + lds[0] - 1\r\n\tfor i in range(1 , n): \r\n\t\tmaximum = max((lis[i] + lds[i]-1), maximum) \r\n\treturn maximum" + ], + "split": "dev" + }, + { + "Input": "Write a function to check whether a given string has a capital letter, a lower case letter, a number and specified length using lambda function.", + "Output Program": [ + "def check_string(str1):\r\n messg = [\r\n lambda str1: any(x.isupper() for x in str1) or 'String must have 1 upper case character.',\r\n lambda str1: any(x.islower() for x in str1) or 'String must have 1 lower case character.',\r\n lambda str1: any(x.isdigit() for x in str1) or 'String must have 1 number.',\r\n lambda str1: len(str1) >= 7 or 'String length should be atleast 8.',]\r\n result = [x for x in [i(str1) for i in messg] if x != True]\r\n if not result:\r\n result.append('Valid string.')\r\n return result " + ], + "Output Answer": [ + "def check_string(str1):\r\n messg = [\r\n lambda str1: any(x.isupper() for x in str1) or 'String must have 1 upper case character.',\r\n lambda str1: any(x.islower() for x in str1) or 'String must have 1 lower case character.',\r\n lambda str1: any(x.isdigit() for x in str1) or 'String must have 1 number.',\r\n lambda str1: len(str1) >= 7 or 'String length should be atleast 8.',]\r\n result = [x for x in [i(str1) for i in messg] if x != True]\r\n if not result:\r\n result.append('Valid string.')\r\n return result " + ], + "split": "dev" + }, + { + "Input": "Write a function to find the sum of maximum increasing subsequence of the given array.", + "Output Program": [ + "def max_sum_increasing_subsequence(arr, n): \r\n\tmax = 0\r\n\tmsis = [0 for x in range(n)] \r\n\tfor i in range(n): \r\n\t\tmsis[i] = arr[i] \r\n\tfor i in range(1, n): \r\n\t\tfor j in range(i): \r\n\t\t\tif (arr[i] > arr[j] and\r\n\t\t\t\tmsis[i] < msis[j] + arr[i]): \r\n\t\t\t\tmsis[i] = msis[j] + arr[i] \r\n\tfor i in range(n): \r\n\t\tif max < msis[i]: \r\n\t\t\tmax = msis[i] \r\n\treturn max" + ], + "Output Answer": [ + "def max_sum_increasing_subsequence(arr, n): \r\n\tmax = 0\r\n\tmsis = [0 for x in range(n)] \r\n\tfor i in range(n): \r\n\t\tmsis[i] = arr[i] \r\n\tfor i in range(1, n): \r\n\t\tfor j in range(i): \r\n\t\t\tif (arr[i] > arr[j] and\r\n\t\t\t\tmsis[i] < msis[j] + arr[i]): \r\n\t\t\t\tmsis[i] = msis[j] + arr[i] \r\n\tfor i in range(n): \r\n\t\tif max < msis[i]: \r\n\t\t\tmax = msis[i] \r\n\treturn max" + ], + "split": "dev" + }, + { + "Input": "Write a python function to check whether two given lines are parallel or not.", + "Output Program": [ + "def parallel_lines(line1, line2):\r\n return line1[0]/line1[1] == line2[0]/line2[1]" + ], + "Output Answer": [ + "def parallel_lines(line1, line2):\r\n return line1[0]/line1[1] == line2[0]/line2[1]" + ], + "split": "dev" + }, + { + "Input": "Write a python function to capitalize first and last letters of each word of a given string.", + "Output Program": [ + "def capitalize_first_last_letters(str1):\r\n str1 = result = str1.title()\r\n result = \"\"\r\n for word in str1.split():\r\n result += word[:-1] + word[-1].upper() + \" \"\r\n return result[:-1] " + ], + "Output Answer": [ + "def capitalize_first_last_letters(str1):\r\n str1 = result = str1.title()\r\n result = \"\"\r\n for word in str1.split():\r\n result += word[:-1] + word[-1].upper() + \" \"\r\n return result[:-1] " + ], + "split": "dev" + }, + { + "Input": "Write a function to find all pairs in an integer array whose sum is equal to a given number.", + "Output Program": [ + "def get_pairs_count(arr, n, sum):\r\n count = 0 \r\n for i in range(0, n):\r\n for j in range(i + 1, n):\r\n if arr[i] + arr[j] == sum:\r\n count += 1\r\n return count" + ], + "Output Answer": [ + "def get_pairs_count(arr, n, sum):\r\n count = 0 \r\n for i in range(0, n):\r\n for j in range(i + 1, n):\r\n if arr[i] + arr[j] == sum:\r\n count += 1\r\n return count" + ], + "split": "dev" + }, + { + "Input": "Write a function to find the list of lists with minimum length.", + "Output Program": [ + "def min_length(list1):\r\n min_length = min(len(x) for x in list1 ) \r\n min_list = min((x) for x in list1)\r\n return(min_length, min_list) " + ], + "Output Answer": [ + "def min_length(list1):\r\n min_length = min(len(x) for x in list1 ) \r\n min_list = min((x) for x in list1)\r\n return(min_length, min_list) " + ], + "split": "dev" + }, + { + "Input": "Write a function to find the nth jacobsthal-lucas number.", + "Output Program": [ + "def jacobsthal_lucas(n): \r\n\tdp=[0] * (n + 1) \r\n\tdp[0] = 2\r\n\tdp[1] = 1\r\n\tfor i in range(2, n+1): \r\n\t\tdp[i] = dp[i - 1] + 2 * dp[i - 2]; \r\n\treturn dp[n]" + ], + "Output Answer": [ + "def jacobsthal_lucas(n): \r\n\tdp=[0] * (n + 1) \r\n\tdp[0] = 2\r\n\tdp[1] = 1\r\n\tfor i in range(2, n+1): \r\n\t\tdp[i] = dp[i - 1] + 2 * dp[i - 2]; \r\n\treturn dp[n]" + ], + "split": "dev" + }, + { + "Input": "Write a function to find the ration of negative numbers in an array of integers.", + "Output Program": [ + "from array import array\r\ndef negative_count(nums):\r\n n = len(nums)\r\n n1 = 0\r\n for x in nums:\r\n if x < 0:\r\n n1 += 1\r\n else:\r\n None\r\n return round(n1/n,2)" + ], + "Output Answer": [ + "from array import array\r\ndef negative_count(nums):\r\n n = len(nums)\r\n n1 = 0\r\n for x in nums:\r\n if x < 0:\r\n n1 += 1\r\n else:\r\n None\r\n return round(n1/n,2)" + ], + "split": "dev" + }, + { + "Input": "Write a function to find minimum number of coins that make a given value.", + "Output Program": [ + "import sys \r\ndef min_coins(coins, m, V): \r\n if (V == 0): \r\n return 0\r\n res = sys.maxsize \r\n for i in range(0, m): \r\n if (coins[i] <= V): \r\n sub_res = min_coins(coins, m, V-coins[i]) \r\n if (sub_res != sys.maxsize and sub_res + 1 < res): \r\n res = sub_res + 1 \r\n return res " + ], + "Output Answer": [ + "import sys \r\ndef min_coins(coins, m, V): \r\n if (V == 0): \r\n return 0\r\n res = sys.maxsize \r\n for i in range(0, m): \r\n if (coins[i] <= V): \r\n sub_res = min_coins(coins, m, V-coins[i]) \r\n if (sub_res != sys.maxsize and sub_res + 1 < res): \r\n res = sub_res + 1 \r\n return res " + ], + "split": "dev" + }, + { + "Input": "Write a function to check if the two given strings are permutations of each other.", + "Output Program": [ + "def check_permutation(str1, str2):\r\n n1=len(str1)\r\n n2=len(str2)\r\n if(n1!=n2):\r\n return False\r\n a=sorted(str1)\r\n str1=\" \".join(a)\r\n b=sorted(str2)\r\n str2=\" \".join(b)\r\n for i in range(0, n1, 1):\r\n if(str1[i] != str2[i]):\r\n return False\r\n return True" + ], + "Output Answer": [ + "def check_permutation(str1, str2):\r\n n1=len(str1)\r\n n2=len(str2)\r\n if(n1!=n2):\r\n return False\r\n a=sorted(str1)\r\n str1=\" \".join(a)\r\n b=sorted(str2)\r\n str2=\" \".join(b)\r\n for i in range(0, n1, 1):\r\n if(str1[i] != str2[i]):\r\n return False\r\n return True" + ], + "split": "dev" + }, + { + "Input": "Write a function to remove particular data type elements from the given tuple.", + "Output Program": [ + "def remove_datatype(test_tuple, data_type):\r\n res = []\r\n for ele in test_tuple:\r\n if not isinstance(ele, data_type):\r\n res.append(ele)\r\n return (res) " + ], + "Output Answer": [ + "def remove_datatype(test_tuple, data_type):\r\n res = []\r\n for ele in test_tuple:\r\n if not isinstance(ele, data_type):\r\n res.append(ele)\r\n return (res) " + ], + "split": "dev" + }, + { + "Input": "Write a function to search a literals string in a string and also find the location within the original string where the pattern occurs.", + "Output Program": [ + "import re\r\ndef search_literal(pattern,text):\r\n match = re.search(pattern, text)\r\n s = match.start()\r\n e = match.end()\r\n return (s, e)" + ], + "Output Answer": [ + "import re\r\ndef search_literal(pattern,text):\r\n match = re.search(pattern, text)\r\n s = match.start()\r\n e = match.end()\r\n return (s, e)" + ], + "split": "dev" + }, + { + "Input": "Write a function to find the top or bottom surface area of a cylinder.", + "Output Program": [ + "def topbottom_surfacearea(r):\r\n toporbottomarea=3.1415*r*r\r\n return toporbottomarea" + ], + "Output Answer": [ + "def topbottom_surfacearea(r):\r\n toporbottomarea=3.1415*r*r\r\n return toporbottomarea" + ], + "split": "dev" + }, + { + "Input": "Write a function to select the nth items of a list.", + "Output Program": [ + "def nth_items(list,n):\r\n return list[::n]" + ], + "Output Answer": [ + "def nth_items(list,n):\r\n return list[::n]" + ], + "split": "dev" + }, + { + "Input": "Write a python function to find the first repeated word in a given string.", + "Output Program": [ + "def first_repeated_word(str1):\r\n temp = set()\r\n for word in str1.split():\r\n if word in temp:\r\n return word;\r\n else:\r\n temp.add(word)\r\n return 'None'" + ], + "Output Answer": [ + "def first_repeated_word(str1):\r\n temp = set()\r\n for word in str1.split():\r\n if word in temp:\r\n return word;\r\n else:\r\n temp.add(word)\r\n return 'None'" + ], + "split": "dev" + }, + { + "Input": "Write a python function to convert a given string list to a tuple.", + "Output Program": [ + "def string_list_to_tuple(str1):\r\n result = tuple(x for x in str1 if not x.isspace()) \r\n return result" + ], + "Output Answer": [ + "def string_list_to_tuple(str1):\r\n result = tuple(x for x in str1 if not x.isspace()) \r\n return result" + ], + "split": "dev" + }, + { + "Input": "Write a function to create a list containing the power of said number in bases raised to the corresponding number in the index using map function.", + "Output Program": [ + "def basesnum_coresspondingnum(bases_num,index):\r\n result = list(map(pow, bases_num, index))\r\n return result" + ], + "Output Answer": [ + "def basesnum_coresspondingnum(bases_num,index):\r\n result = list(map(pow, bases_num, index))\r\n return result" + ], + "split": "dev" + }, + { + "Input": "Write a python function to find the difference between highest and least frequencies in a given array.", + "Output Program": [ + "def find_Diff(arr,n): \r\n arr.sort() \r\n count = 0; max_count = 0; min_count = n \r\n for i in range(0,(n-1)): \r\n if arr[i] == arr[i + 1]: \r\n count += 1\r\n continue\r\n else: \r\n max_count = max(max_count,count) \r\n min_count = min(min_count,count) \r\n count = 0\r\n return max_count - min_count " + ], + "Output Answer": [ + "def find_Diff(arr,n): \r\n arr.sort() \r\n count = 0; max_count = 0; min_count = n \r\n for i in range(0,(n-1)): \r\n if arr[i] == arr[i + 1]: \r\n count += 1\r\n continue\r\n else: \r\n max_count = max(max_count,count) \r\n min_count = min(min_count,count) \r\n count = 0\r\n return max_count - min_count " + ], + "split": "dev" + }, + { + "Input": "Write a function to find if the given number is abundant or not.", + "Output Program": [ + "import math \r\ndef get_sum(n): \r\n\tsum = 0\r\n\ti = 1\r\n\twhile i <= (math.sqrt(n)): \r\n\t\tif n%i == 0: \r\n\t\t\tif n/i == i : \r\n\t\t\t\tsum = sum + i \r\n\t\t\telse: \r\n\t\t\t\tsum = sum + i \r\n\t\t\t\tsum = sum + (n / i ) \r\n\t\ti = i + 1\r\n\tsum = sum - n \r\n\treturn sum\r\ndef check_abundant(n): \r\n\tif (get_sum(n) > n): \r\n\t\treturn True\r\n\telse: \r\n\t\treturn False" + ], + "Output Answer": [ + "import math \r\ndef get_sum(n): \r\n\tsum = 0\r\n\ti = 1\r\n\twhile i <= (math.sqrt(n)): \r\n\t\tif n%i == 0: \r\n\t\t\tif n/i == i : \r\n\t\t\t\tsum = sum + i \r\n\t\t\telse: \r\n\t\t\t\tsum = sum + i \r\n\t\t\t\tsum = sum + (n / i ) \r\n\t\ti = i + 1\r\n\tsum = sum - n \r\n\treturn sum\r\ndef check_abundant(n): \r\n\tif (get_sum(n) > n): \r\n\t\treturn True\r\n\telse: \r\n\t\treturn False" + ], + "split": "dev" + }, + { + "Input": "Write a function to replace all occurrences of spaces, commas, or dots with a colon in the given string by using regex.", + "Output Program": [ + "import re\r\ndef fill_spaces(text):\r\n return (re.sub(\"[ ,.]\", \":\", text))" + ], + "Output Answer": [ + "import re\r\ndef fill_spaces(text):\r\n return (re.sub(\"[ ,.]\", \":\", text))" + ], + "split": "dev" + }, + { + "Input": "Write a function to add two numbers and print number of digits of sum.", + "Output Program": [ + "def count_digits(num1,num2):\r\n number=num1+num2\r\n count = 0\r\n while(number > 0):\r\n number = number // 10\r\n count = count + 1\r\n return count" + ], + "Output Answer": [ + "def count_digits(num1,num2):\r\n number=num1+num2\r\n count = 0\r\n while(number > 0):\r\n number = number // 10\r\n count = count + 1\r\n return count" + ], + "split": "dev" + }, + { + "Input": "Write a function to flatten the tuple list to a string.", + "Output Program": [ + "def flatten_tuple(test_list):\r\n res = ' '.join([idx for tup in test_list for idx in tup])\r\n return (res) " + ], + "Output Answer": [ + "def flatten_tuple(test_list):\r\n res = ' '.join([idx for tup in test_list for idx in tup])\r\n return (res) " + ], + "split": "dev" + }, + { + "Input": "Write a python function to toggle only first and last bits of a given number.", + "Output Program": [ + "def take_L_and_F_set_bits(n) : \r\n n = n | n >> 1\r\n n = n | n >> 2\r\n n = n | n >> 4\r\n n = n | n >> 8\r\n n = n | n >> 16 \r\n return ((n + 1) >> 1) + 1 \r\ndef toggle_F_and_L_bits(n) : \r\n if (n == 1) : \r\n return 0 \r\n return n ^ take_L_and_F_set_bits(n) " + ], + "Output Answer": [ + "def take_L_and_F_set_bits(n) : \r\n n = n | n >> 1\r\n n = n | n >> 2\r\n n = n | n >> 4\r\n n = n | n >> 8\r\n n = n | n >> 16 \r\n return ((n + 1) >> 1) + 1 \r\ndef toggle_F_and_L_bits(n) : \r\n if (n == 1) : \r\n return 0 \r\n return n ^ take_L_and_F_set_bits(n) " + ], + "split": "dev" + }, + { + "Input": "Write a function to find the last occurrence of a character in a string.", + "Output Program": [ + "def last_occurence_char(string,char):\r\n flag = -1\r\n for i in range(len(string)):\r\n if(string[i] == char):\r\n flag = i\r\n if(flag == -1):\r\n return None\r\n else:\r\n return flag + 1" + ], + "Output Answer": [ + "def last_occurence_char(string,char):\r\n flag = -1\r\n for i in range(len(string)):\r\n if(string[i] == char):\r\n flag = i\r\n if(flag == -1):\r\n return None\r\n else:\r\n return flag + 1" + ], + "split": "dev" + }, + { + "Input": "Write a python function to find the sum of hamming distances of all consecutive numbers from o to n.", + "Output Program": [ + "def Total_Hamming_Distance(n): \r\n i = 1\r\n sum = 0\r\n while (n // i > 0): \r\n sum = sum + n // i \r\n i = i * 2 \r\n return sum" + ], + "Output Answer": [ + "def Total_Hamming_Distance(n): \r\n i = 1\r\n sum = 0\r\n while (n // i > 0): \r\n sum = sum + n // i \r\n i = i * 2 \r\n return sum" + ], + "split": "dev" + }, + { + "Input": "Write a function to find the length of the longest increasing subsequence of the given sequence.", + "Output Program": [ + "def longest_increasing_subsequence(arr): \r\n\tn = len(arr) \r\n\tlongest_increasing_subsequence = [1]*n \r\n\tfor i in range (1 , n): \r\n\t\tfor j in range(0 , i): \r\n\t\t\tif arr[i] > arr[j] and longest_increasing_subsequence[i]< longest_increasing_subsequence[j] + 1 : \r\n\t\t\t\tlongest_increasing_subsequence[i] = longest_increasing_subsequence[j]+1\r\n\tmaximum = 0\r\n\tfor i in range(n): \r\n\t\tmaximum = max(maximum , longest_increasing_subsequence[i]) \r\n\treturn maximum" + ], + "Output Answer": [ + "def longest_increasing_subsequence(arr): \r\n\tn = len(arr) \r\n\tlongest_increasing_subsequence = [1]*n \r\n\tfor i in range (1 , n): \r\n\t\tfor j in range(0 , i): \r\n\t\t\tif arr[i] > arr[j] and longest_increasing_subsequence[i]< longest_increasing_subsequence[j] + 1 : \r\n\t\t\t\tlongest_increasing_subsequence[i] = longest_increasing_subsequence[j]+1\r\n\tmaximum = 0\r\n\tfor i in range(n): \r\n\t\tmaximum = max(maximum , longest_increasing_subsequence[i]) \r\n\treturn maximum" + ], + "split": "dev" + }, + { + "Input": "Write a python function to find the sum of fifth power of first n odd natural numbers.", + "Output Program": [ + "def odd_Num_Sum(n) : \r\n j = 0\r\n sm = 0\r\n for i in range(1,n+1) : \r\n j = (2*i-1) \r\n sm = sm + (j*j*j*j*j) \r\n return sm " + ], + "Output Answer": [ + "def odd_Num_Sum(n) : \r\n j = 0\r\n sm = 0\r\n for i in range(1,n+1) : \r\n j = (2*i-1) \r\n sm = sm + (j*j*j*j*j) \r\n return sm " + ], + "split": "dev" + }, + { + "Input": "Write a python function to find the maximum element in a sorted and rotated array.", + "Output Program": [ + "def find_Max(arr,low,high): \r\n if (high < low): \r\n return arr[0] \r\n if (high == low): \r\n return arr[low] \r\n mid = low + (high - low) // 2 \r\n if (mid < high and arr[mid + 1] < arr[mid]): \r\n return arr[mid] \r\n if (mid > low and arr[mid] < arr[mid - 1]): \r\n return arr[mid - 1] \r\n if (arr[low] > arr[mid]): \r\n return find_Max(arr,low,mid - 1) \r\n else: \r\n return find_Max(arr,mid + 1,high) " + ], + "Output Answer": [ + "def find_Max(arr,low,high): \r\n if (high < low): \r\n return arr[0] \r\n if (high == low): \r\n return arr[low] \r\n mid = low + (high - low) // 2 \r\n if (mid < high and arr[mid + 1] < arr[mid]): \r\n return arr[mid] \r\n if (mid > low and arr[mid] < arr[mid - 1]): \r\n return arr[mid - 1] \r\n if (arr[low] > arr[mid]): \r\n return find_Max(arr,low,mid - 1) \r\n else: \r\n return find_Max(arr,mid + 1,high) " + ], + "split": "dev" + }, + { + "Input": "Write a function to extract a specified column from a given nested list.", + "Output Program": [ + "def extract_column(list1, n):\r\n result = [i.pop(n) for i in list1]\r\n return result " + ], + "Output Answer": [ + "def extract_column(list1, n):\r\n result = [i.pop(n) for i in list1]\r\n return result " + ], + "split": "dev" + }, + { + "Input": "Write a python function to check whether a given sequence is linear or not.", + "Output Program": [ + "def Seq_Linear(seq_nums):\r\n seq_nums = [seq_nums[x] - seq_nums[x-1] for x in range(1, len(seq_nums))]\r\n if len(set(seq_nums)) == 1: \r\n return \"Linear Sequence\"\r\n else:\r\n return \"Non Linear Sequence\"" + ], + "Output Answer": [ + "def Seq_Linear(seq_nums):\r\n seq_nums = [seq_nums[x] - seq_nums[x-1] for x in range(1, len(seq_nums))]\r\n if len(set(seq_nums)) == 1: \r\n return \"Linear Sequence\"\r\n else:\r\n return \"Non Linear Sequence\"" + ], + "split": "dev" + }, + { + "Input": "Write a function to convert the given tuple to a floating-point number.", + "Output Program": [ + "def tuple_to_float(test_tup):\r\n res = float('.'.join(str(ele) for ele in test_tup))\r\n return (res) " + ], + "Output Answer": [ + "def tuple_to_float(test_tup):\r\n res = float('.'.join(str(ele) for ele in test_tup))\r\n return (res) " + ], + "split": "dev" + }, + { + "Input": "Write a python function to find odd numbers from a mixed list.", + "Output Program": [ + "def Split(list): \r\n od_li = [] \r\n for i in list: \r\n if (i % 2 != 0): \r\n od_li.append(i) \r\n return od_li" + ], + "Output Answer": [ + "def Split(list): \r\n od_li = [] \r\n for i in list: \r\n if (i % 2 != 0): \r\n od_li.append(i) \r\n return od_li" + ], + "split": "dev" + }, + { + "Input": "Write a python function to find the difference between sum of cubes of first n natural numbers and the sum of first n natural numbers.", + "Output Program": [ + "def difference(n) : \r\n S = (n*(n + 1))//2; \r\n res = S*(S-1); \r\n return res; " + ], + "Output Answer": [ + "def difference(n) : \r\n S = (n*(n + 1))//2; \r\n res = S*(S-1); \r\n return res; " + ], + "split": "dev" + }, + { + "Input": "Write a python function to count the pairs with xor as an odd number.", + "Output Program": [ + "def find_Odd_Pair(A,N) : \r\n oddPair = 0\r\n for i in range(0,N) : \r\n for j in range(i+1,N) : \r\n if ((A[i] ^ A[j]) % 2 != 0): \r\n oddPair+=1 \r\n return oddPair " + ], + "Output Answer": [ + "def find_Odd_Pair(A,N) : \r\n oddPair = 0\r\n for i in range(0,N) : \r\n for j in range(i+1,N) : \r\n if ((A[i] ^ A[j]) % 2 != 0): \r\n oddPair+=1 \r\n return oddPair " + ], + "split": "dev" + }, + { + "Input": "Write a function to toggle characters case in a string.", + "Output Program": [ + "def toggle_string(string):\r\n string1 = string.swapcase()\r\n return string1" + ], + "Output Answer": [ + "def toggle_string(string):\r\n string1 = string.swapcase()\r\n return string1" + ], + "split": "dev" + }, + { + "Input": "Write a python function to find the digit distance between two integers.", + "Output Program": [ + "def digit_distance_nums(n1, n2):\r\n return sum(map(int,str(abs(n1-n2))))" + ], + "Output Answer": [ + "def digit_distance_nums(n1, n2):\r\n return sum(map(int,str(abs(n1-n2))))" + ], + "split": "dev" + }, + { + "Input": "Write a function to find the largest sum of contiguous subarray in the given array.", + "Output Program": [ + "def max_sub_array_sum(a, size):\r\n max_so_far = 0\r\n max_ending_here = 0\r\n for i in range(0, size):\r\n max_ending_here = max_ending_here + a[i]\r\n if max_ending_here < 0:\r\n max_ending_here = 0\r\n elif (max_so_far < max_ending_here):\r\n max_so_far = max_ending_here\r\n return max_so_far" + ], + "Output Answer": [ + "def max_sub_array_sum(a, size):\r\n max_so_far = 0\r\n max_ending_here = 0\r\n for i in range(0, size):\r\n max_ending_here = max_ending_here + a[i]\r\n if max_ending_here < 0:\r\n max_ending_here = 0\r\n elif (max_so_far < max_ending_here):\r\n max_so_far = max_ending_here\r\n return max_so_far" + ], + "split": "dev" + }, + { + "Input": "Write a function to find the union of elements of the given tuples.", + "Output Program": [ + "def union_elements(test_tup1, test_tup2):\r\n res = tuple(set(test_tup1 + test_tup2))\r\n return (res) " + ], + "Output Answer": [ + "def union_elements(test_tup1, test_tup2):\r\n res = tuple(set(test_tup1 + test_tup2))\r\n return (res) " + ], + "split": "dev" + }, + { + "Input": "Write a function to assign with each element, its pair elements from other similar pairs in the given tuple.", + "Output Program": [ + "def assign_elements(test_list):\r\n res = dict()\r\n for key, val in test_list:\r\n res.setdefault(val, [])\r\n res.setdefault(key, []).append(val)\r\n return (res) " + ], + "Output Answer": [ + "def assign_elements(test_list):\r\n res = dict()\r\n for key, val in test_list:\r\n res.setdefault(val, [])\r\n res.setdefault(key, []).append(val)\r\n return (res) " + ], + "split": "dev" + }, + { + "Input": "Write a python function to find the maximum length of sublist.", + "Output Program": [ + "def Find_Max_Length(lst): \r\n maxLength = max(len(x) for x in lst )\r\n return maxLength " + ], + "Output Answer": [ + "def Find_Max_Length(lst): \r\n maxLength = max(len(x) for x in lst )\r\n return maxLength " + ], + "split": "dev" + }, + { + "Input": "Write a function to extract values between quotation marks of a string.", + "Output Program": [ + "import re\r\ndef extract_values(text):\r\n return (re.findall(r'\"(.*?)\"', text))" + ], + "Output Answer": [ + "import re\r\ndef extract_values(text):\r\n return (re.findall(r'\"(.*?)\"', text))" + ], + "split": "dev" + }, + { + "Input": "Write a python function to count unequal element pairs from the given array.", + "Output Program": [ + "def count_Pairs(arr,n): \r\n cnt = 0; \r\n for i in range(n): \r\n for j in range(i + 1,n): \r\n if (arr[i] != arr[j]): \r\n cnt += 1; \r\n return cnt; " + ], + "Output Answer": [ + "def count_Pairs(arr,n): \r\n cnt = 0; \r\n for i in range(n): \r\n for j in range(i + 1,n): \r\n if (arr[i] != arr[j]): \r\n cnt += 1; \r\n return cnt; " + ], + "split": "dev" + }, + { + "Input": "Write a python function to split a string into characters.", + "Output Program": [ + "def split(word): \r\n return [char for char in word] " + ], + "Output Answer": [ + "def split(word): \r\n return [char for char in word] " + ], + "split": "dev" + }, + { + "Input": "Write a function to get the sum of a non-negative integer.", + "Output Program": [ + "def sum_digits(n):\r\n if n == 0:\r\n return 0\r\n else:\r\n return n % 10 + sum_digits(int(n / 10))" + ], + "Output Answer": [ + "def sum_digits(n):\r\n if n == 0:\r\n return 0\r\n else:\r\n return n % 10 + sum_digits(int(n / 10))" + ], + "split": "dev" + }, + { + "Input": "Write a function to check whether a specified list is sorted or not.", + "Output Program": [ + "def issort_list(list1):\r\n result = all(list1[i] <= list1[i+1] for i in range(len(list1)-1))\r\n return result" + ], + "Output Answer": [ + "def issort_list(list1):\r\n result = all(list1[i] <= list1[i+1] for i in range(len(list1)-1))\r\n return result" + ], + "split": "dev" + }, + { + "Input": "Write a function to create a list of empty dictionaries.", + "Output Program": [ + "def empty_list(length):\r\n empty_list = [{} for _ in range(length)]\r\n return empty_list" + ], + "Output Answer": [ + "def empty_list(length):\r\n empty_list = [{} for _ in range(length)]\r\n return empty_list" + ], + "split": "dev" + }, + { + "Input": "Write a function to sort each sublist of strings in a given list of lists.", + "Output Program": [ + "def sort_sublists(list1):\r\n result = list(map(sorted,list1)) \r\n return result" + ], + "Output Answer": [ + "def sort_sublists(list1):\r\n result = list(map(sorted,list1)) \r\n return result" + ], + "split": "dev" + }, + { + "Input": "Write a function to remove words from a given list of strings containing a character or string.", + "Output Program": [ + "def remove_words(list1, charlist):\r\n new_list = []\r\n for line in list1:\r\n new_words = ' '.join([word for word in line.split() if not any([phrase in word for phrase in charlist])])\r\n new_list.append(new_words)\r\n return new_list" + ], + "Output Answer": [ + "def remove_words(list1, charlist):\r\n new_list = []\r\n for line in list1:\r\n new_words = ' '.join([word for word in line.split() if not any([phrase in word for phrase in charlist])])\r\n new_list.append(new_words)\r\n return new_list" + ], + "split": "dev" + }, + { + "Input": "Write a function to find maximum possible sum of disjoint pairs for the given array of integers and a number k.", + "Output Program": [ + "def max_sum_pair_diff_lessthan_K(arr, N, K): \r\n\tarr.sort() \r\n\tdp = [0] * N \r\n\tdp[0] = 0\r\n\tfor i in range(1, N): \r\n\t\tdp[i] = dp[i-1] \r\n\t\tif (arr[i] - arr[i-1] < K): \r\n\t\t\tif (i >= 2): \r\n\t\t\t\tdp[i] = max(dp[i], dp[i-2] + arr[i] + arr[i-1]); \r\n\t\t\telse: \r\n\t\t\t\tdp[i] = max(dp[i], arr[i] + arr[i-1]); \r\n\treturn dp[N - 1]" + ], + "Output Answer": [ + "def max_sum_pair_diff_lessthan_K(arr, N, K): \r\n\tarr.sort() \r\n\tdp = [0] * N \r\n\tdp[0] = 0\r\n\tfor i in range(1, N): \r\n\t\tdp[i] = dp[i-1] \r\n\t\tif (arr[i] - arr[i-1] < K): \r\n\t\t\tif (i >= 2): \r\n\t\t\t\tdp[i] = max(dp[i], dp[i-2] + arr[i] + arr[i-1]); \r\n\t\t\telse: \r\n\t\t\t\tdp[i] = max(dp[i], arr[i] + arr[i-1]); \r\n\treturn dp[N - 1]" + ], + "split": "dev" + }, + { + "Input": "Write a python function to remove two duplicate numbers from a given number of lists.", + "Output Program": [ + "def two_unique_nums(nums):\r\n return [i for i in nums if nums.count(i)==1]" + ], + "Output Answer": [ + "def two_unique_nums(nums):\r\n return [i for i in nums if nums.count(i)==1]" + ], + "split": "dev" + }, + { + "Input": "Write a python function to calculate the product of the unique numbers of a given list.", + "Output Program": [ + "def unique_product(list_data):\r\n temp = list(set(list_data))\r\n p = 1\r\n for i in temp:\r\n p *= i\r\n return p" + ], + "Output Answer": [ + "def unique_product(list_data):\r\n temp = list(set(list_data))\r\n p = 1\r\n for i in temp:\r\n p *= i\r\n return p" + ], + "split": "dev" + }, + { + "Input": "Write a function to find the surface area of a cylinder.", + "Output Program": [ + "def surfacearea_cylinder(r,h):\r\n surfacearea=((2*3.1415*r*r) +(2*3.1415*r*h))\r\n return surfacearea" + ], + "Output Answer": [ + "def surfacearea_cylinder(r,h):\r\n surfacearea=((2*3.1415*r*r) +(2*3.1415*r*h))\r\n return surfacearea" + ], + "split": "dev" + }, + { + "Input": "Write a python function to find nth number in a sequence which is not a multiple of a given number.", + "Output Program": [ + "def count_no (A,N,L,R): \r\n count = 0\r\n for i in range (L,R + 1): \r\n if (i % A != 0): \r\n count += 1\r\n if (count == N): \r\n break\r\n return (i) " + ], + "Output Answer": [ + "def count_no (A,N,L,R): \r\n count = 0\r\n for i in range (L,R + 1): \r\n if (i % A != 0): \r\n count += 1\r\n if (count == N): \r\n break\r\n return (i) " + ], + "split": "dev" + }, + { + "Input": "Write a python function to check whether an array is subarray of another or not.", + "Output Program": [ + "def is_Sub_Array(A,B,n,m): \r\n i = 0; j = 0; \r\n while (i < n and j < m): \r\n if (A[i] == B[j]): \r\n i += 1; \r\n j += 1; \r\n if (j == m): \r\n return True; \r\n else: \r\n i = i - j + 1; \r\n j = 0; \r\n return False; " + ], + "Output Answer": [ + "def is_Sub_Array(A,B,n,m): \r\n i = 0; j = 0; \r\n while (i < n and j < m): \r\n if (A[i] == B[j]): \r\n i += 1; \r\n j += 1; \r\n if (j == m): \r\n return True; \r\n else: \r\n i = i - j + 1; \r\n j = 0; \r\n return False; " + ], + "split": "dev" + }, + { + "Input": "Write a python function to find the last digit in factorial of a given number.", + "Output Program": [ + "def last_Digit_Factorial(n): \r\n if (n == 0): return 1\r\n elif (n <= 2): return n \r\n elif (n == 3): return 6\r\n elif (n == 4): return 4 \r\n else: \r\n return 0" + ], + "Output Answer": [ + "def last_Digit_Factorial(n): \r\n if (n == 0): return 1\r\n elif (n <= 2): return n \r\n elif (n == 3): return 6\r\n elif (n == 4): return 4 \r\n else: \r\n return 0" + ], + "split": "dev" + }, + { + "Input": "Write a function to interleave lists of the same length.", + "Output Program": [ + "def interleave_lists(list1,list2,list3):\r\n result = [el for pair in zip(list1, list2, list3) for el in pair]\r\n return result" + ], + "Output Answer": [ + "def interleave_lists(list1,list2,list3):\r\n result = [el for pair in zip(list1, list2, list3) for el in pair]\r\n return result" + ], + "split": "dev" + }, + { + "Input": "Write a function to find the dissimilar elements in the given two tuples.", + "Output Program": [ + "def find_dissimilar(test_tup1, test_tup2):\r\n res = tuple(set(test_tup1) ^ set(test_tup2))\r\n return (res) " + ], + "Output Answer": [ + "def find_dissimilar(test_tup1, test_tup2):\r\n res = tuple(set(test_tup1) ^ set(test_tup2))\r\n return (res) " + ], + "split": "dev" + }, + { + "Input": "Write a function to extract the even elements in the nested mixed tuple.", + "Output Program": [ + "def even_ele(test_tuple, even_fnc): \r\n\tres = tuple() \r\n\tfor ele in test_tuple: \r\n\t\tif isinstance(ele, tuple): \r\n\t\t\tres += (even_ele(ele, even_fnc), ) \r\n\t\telif even_fnc(ele): \r\n\t\t\tres += (ele, ) \r\n\treturn res \r\ndef extract_even(test_tuple):\r\n res = even_ele(test_tuple, lambda x: x % 2 == 0)\r\n return (res) " + ], + "Output Answer": [ + "def even_ele(test_tuple, even_fnc): \r\n\tres = tuple() \r\n\tfor ele in test_tuple: \r\n\t\tif isinstance(ele, tuple): \r\n\t\t\tres += (even_ele(ele, even_fnc), ) \r\n\t\telif even_fnc(ele): \r\n\t\t\tres += (ele, ) \r\n\treturn res \r\ndef extract_even(test_tuple):\r\n res = even_ele(test_tuple, lambda x: x % 2 == 0)\r\n return (res) " + ], + "split": "dev" + }, + { + "Input": "Write a python function to find the surface area of the square pyramid.", + "Output Program": [ + "def surface_Area(b,s): \r\n return 2 * b * s + pow(b,2) " + ], + "Output Answer": [ + "def surface_Area(b,s): \r\n return 2 * b * s + pow(b,2) " + ], + "split": "dev" + }, + { + "Input": "Write a function to check if a dictionary is empty or not.", + "Output Program": [ + "def my_dict(dict1):\r\n if bool(dict1):\r\n return False\r\n else:\r\n return True" + ], + "Output Answer": [ + "def my_dict(dict1):\r\n if bool(dict1):\r\n return False\r\n else:\r\n return True" + ], + "split": "dev" + }, + { + "Input": "Write a function for nth catalan number.", + "Output Program": [ + "def catalan_number(num):\r\n if num <=1:\r\n return 1 \r\n res_num = 0\r\n for i in range(num):\r\n res_num += catalan_number(i) * catalan_number(num-i-1)\r\n return res_num" + ], + "Output Answer": [ + "def catalan_number(num):\r\n if num <=1:\r\n return 1 \r\n res_num = 0\r\n for i in range(num):\r\n res_num += catalan_number(i) * catalan_number(num-i-1)\r\n return res_num" + ], + "split": "dev" + }, + { + "Input": "Write a function to find all adverbs and their positions in a given sentence by using regex.", + "Output Program": [ + "import re\r\ndef find_adverbs(text):\r\n for m in re.finditer(r\"\\w+ly\", text):\r\n return ('%d-%d: %s' % (m.start(), m.end(), m.group(0)))" + ], + "Output Answer": [ + "import re\r\ndef find_adverbs(text):\r\n for m in re.finditer(r\"\\w+ly\", text):\r\n return ('%d-%d: %s' % (m.start(), m.end(), m.group(0)))" + ], + "split": "dev" + }, + { + "Input": "Write a function to find the n - expensive price items from a given dataset using heap queue algorithm.", + "Output Program": [ + "import heapq\r\ndef expensive_items(items,n):\r\n expensive_items = heapq.nlargest(n, items, key=lambda s: s['price'])\r\n return expensive_items" + ], + "Output Answer": [ + "import heapq\r\ndef expensive_items(items,n):\r\n expensive_items = heapq.nlargest(n, items, key=lambda s: s['price'])\r\n return expensive_items" + ], + "split": "dev" + }, + { + "Input": "Write a python function to split the array and add the first part to the end.", + "Output Program": [ + "def split_Arr(a,n,k): \r\n b = a[:k] \r\n return (a[k::]+b[::]) " + ], + "Output Answer": [ + "def split_Arr(a,n,k): \r\n b = a[:k] \r\n return (a[k::]+b[::]) " + ], + "split": "dev" + }, + { + "Input": "Write a function to convert a list to a tuple.", + "Output Program": [ + "def list_tuple(listx):\r\n tuplex = tuple(listx)\r\n return tuplex" + ], + "Output Answer": [ + "def list_tuple(listx):\r\n tuplex = tuple(listx)\r\n return tuplex" + ], + "split": "dev" + }, + { + "Input": "Write a python function to find the difference between largest and smallest value in a given array.", + "Output Program": [ + "def big_diff(nums):\r\n diff= max(nums)-min(nums)\r\n return diff" + ], + "Output Answer": [ + "def big_diff(nums):\r\n diff= max(nums)-min(nums)\r\n return diff" + ], + "split": "dev" + }, + { + "Input": "Write a function to find perfect squares between two given numbers.", + "Output Program": [ + "def perfect_squares(a, b):\r\n lists=[]\r\n for i in range (a,b+1):\r\n j = 1;\r\n while j*j <= i:\r\n if j*j == i:\r\n lists.append(i) \r\n j = j+1\r\n i = i+1\r\n return lists" + ], + "Output Answer": [ + "def perfect_squares(a, b):\r\n lists=[]\r\n for i in range (a,b+1):\r\n j = 1;\r\n while j*j <= i:\r\n if j*j == i:\r\n lists.append(i) \r\n j = j+1\r\n i = i+1\r\n return lists" + ], + "split": "dev" + }, + { + "Input": "Write a function to convert polar coordinates to rectangular coordinates.", + "Output Program": [ + "import cmath\r\ndef polar_rect(x,y):\r\n cn = complex(x,y)\r\n cn=cmath.polar(cn)\r\n cn1 = cmath.rect(2, cmath.pi)\r\n return (cn,cn1)" + ], + "Output Answer": [ + "import cmath\r\ndef polar_rect(x,y):\r\n cn = complex(x,y)\r\n cn=cmath.polar(cn)\r\n cn1 = cmath.rect(2, cmath.pi)\r\n return (cn,cn1)" + ], + "split": "dev" + }, + { + "Input": "Write a python function to interchange the first and last elements in a list.", + "Output Program": [ + "def swap_List(newList): \r\n size = len(newList) \r\n temp = newList[0] \r\n newList[0] = newList[size - 1] \r\n newList[size - 1] = temp \r\n return newList " + ], + "Output Answer": [ + "def swap_List(newList): \r\n size = len(newList) \r\n temp = newList[0] \r\n newList[0] = newList[size - 1] \r\n newList[size - 1] = temp \r\n return newList " + ], + "split": "dev" + }, + { + "Input": "Write a python function to find sum of product of binomial co-efficients.", + "Output Program": [ + "def binomial_Coeff(n,k): \r\n C = [0] * (k + 1); \r\n C[0] = 1; # nC0 is 1 \r\n for i in range(1,n + 1): \r\n for j in range(min(i, k),0,-1): \r\n C[j] = C[j] + C[j - 1]; \r\n return C[k]; \r\ndef sum_Of_product(n): \r\n return binomial_Coeff(2 * n,n - 1); " + ], + "Output Answer": [ + "def binomial_Coeff(n,k): \r\n C = [0] * (k + 1); \r\n C[0] = 1; # nC0 is 1 \r\n for i in range(1,n + 1): \r\n for j in range(min(i, k),0,-1): \r\n C[j] = C[j] + C[j - 1]; \r\n return C[k]; \r\ndef sum_Of_product(n): \r\n return binomial_Coeff(2 * n,n - 1); " + ], + "split": "dev" + }, + { + "Input": "Write a function to remove leading zeroes from an ip address.", + "Output Program": [ + "import re\r\ndef removezero_ip(ip):\r\n string = re.sub('\\.[0]*', '.', ip)\r\n return string\r" + ], + "Output Answer": [ + "import re\r\ndef removezero_ip(ip):\r\n string = re.sub('\\.[0]*', '.', ip)\r\n return string\r" + ], + "split": "dev" + }, + { + "Input": "Write a function to find the difference of first even and odd number of a given list.", + "Output Program": [ + "def diff_even_odd(list1):\r\n first_even = next((el for el in list1 if el%2==0),-1)\r\n first_odd = next((el for el in list1 if el%2!=0),-1)\r\n return (first_even-first_odd)" + ], + "Output Answer": [ + "def diff_even_odd(list1):\r\n first_even = next((el for el in list1 if el%2==0),-1)\r\n first_odd = next((el for el in list1 if el%2!=0),-1)\r\n return (first_even-first_odd)" + ], + "split": "dev" + }, + { + "Input": "Write a python function to count minimum number of swaps required to convert one binary string to another.", + "Output Program": [ + "def min_Swaps(str1,str2) : \r\n count = 0\r\n for i in range(len(str1)) : \r\n if str1[i] != str2[i] : \r\n count += 1\r\n if count % 2 == 0 : \r\n return (count // 2) \r\n else : \r\n return (\"Not Possible\") " + ], + "Output Answer": [ + "def min_Swaps(str1,str2) : \r\n count = 0\r\n for i in range(len(str1)) : \r\n if str1[i] != str2[i] : \r\n count += 1\r\n if count % 2 == 0 : \r\n return (count // 2) \r\n else : \r\n return (\"Not Possible\") " + ], + "split": "dev" + }, + { + "Input": "Write a function to find the size of the given tuple.", + "Output Program": [ + "import sys \r\ndef tuple_size(tuple_list):\r\n return (sys.getsizeof(tuple_list)) " + ], + "Output Answer": [ + "import sys \r\ndef tuple_size(tuple_list):\r\n return (sys.getsizeof(tuple_list)) " + ], + "split": "dev" + }, + { + "Input": "Write a function to find kth element from the given two sorted arrays.", + "Output Program": [ + "def find_kth(arr1, arr2, m, n, k):\r\n\tsorted1 = [0] * (m + n)\r\n\ti = 0\r\n\tj = 0\r\n\td = 0\r\n\twhile (i < m and j < n):\r\n\t\tif (arr1[i] < arr2[j]):\r\n\t\t\tsorted1[d] = arr1[i]\r\n\t\t\ti += 1\r\n\t\telse:\r\n\t\t\tsorted1[d] = arr2[j]\r\n\t\t\tj += 1\r\n\t\td += 1\r\n\twhile (i < m):\r\n\t\tsorted1[d] = arr1[i]\r\n\t\td += 1\r\n\t\ti += 1\r\n\twhile (j < n):\r\n\t\tsorted1[d] = arr2[j]\r\n\t\td += 1\r\n\t\tj += 1\r\n\treturn sorted1[k - 1]" + ], + "Output Answer": [ + "def find_kth(arr1, arr2, m, n, k):\r\n\tsorted1 = [0] * (m + n)\r\n\ti = 0\r\n\tj = 0\r\n\td = 0\r\n\twhile (i < m and j < n):\r\n\t\tif (arr1[i] < arr2[j]):\r\n\t\t\tsorted1[d] = arr1[i]\r\n\t\t\ti += 1\r\n\t\telse:\r\n\t\t\tsorted1[d] = arr2[j]\r\n\t\t\tj += 1\r\n\t\td += 1\r\n\twhile (i < m):\r\n\t\tsorted1[d] = arr1[i]\r\n\t\td += 1\r\n\t\ti += 1\r\n\twhile (j < n):\r\n\t\tsorted1[d] = arr2[j]\r\n\t\td += 1\r\n\t\tj += 1\r\n\treturn sorted1[k - 1]" + ], + "split": "dev" + }, + { + "Input": "Write a function to check whether the given number is armstrong or not.", + "Output Program": [ + "def armstrong_number(number):\r\n sum = 0\r\n times = 0\r\n temp = number\r\n while temp > 0:\r\n times = times + 1\r\n temp = temp // 10\r\n temp = number\r\n while temp > 0:\r\n reminder = temp % 10\r\n sum = sum + (reminder ** times)\r\n temp //= 10\r\n if number == sum:\r\n return True\r\n else:\r\n return False" + ], + "Output Answer": [ + "def armstrong_number(number):\r\n sum = 0\r\n times = 0\r\n temp = number\r\n while temp > 0:\r\n times = times + 1\r\n temp = temp // 10\r\n temp = number\r\n while temp > 0:\r\n reminder = temp % 10\r\n sum = sum + (reminder ** times)\r\n temp //= 10\r\n if number == sum:\r\n return True\r\n else:\r\n return False" + ], + "split": "dev" + }, + { + "Input": "Write a function to find sum and average of first n natural numbers.", + "Output Program": [ + "def sum_average(number):\r\n total = 0\r\n for value in range(1, number + 1):\r\n total = total + value\r\n average = total / number\r\n return (total,average)" + ], + "Output Answer": [ + "def sum_average(number):\r\n total = 0\r\n for value in range(1, number + 1):\r\n total = total + value\r\n average = total / number\r\n return (total,average)" + ], + "split": "dev" + }, + { + "Input": "Write a python function to check whether the given number is even or not using bitwise operator.", + "Output Program": [ + "def is_Even(n) : \r\n if (n^1 == n+1) :\r\n return True; \r\n else :\r\n return False; " + ], + "Output Answer": [ + "def is_Even(n) : \r\n if (n^1 == n+1) :\r\n return True; \r\n else :\r\n return False; " + ], + "split": "dev" + }, + { + "Input": "Write a function to find the longest chain which can be formed from the given set of pairs.", + "Output Program": [ + "class Pair(object): \r\n\tdef __init__(self, a, b): \r\n\t\tself.a = a \r\n\t\tself.b = b \r\ndef max_chain_length(arr, n): \r\n\tmax = 0\r\n\tmcl = [1 for i in range(n)] \r\n\tfor i in range(1, n): \r\n\t\tfor j in range(0, i): \r\n\t\t\tif (arr[i].a > arr[j].b and\r\n\t\t\t\tmcl[i] < mcl[j] + 1): \r\n\t\t\t\tmcl[i] = mcl[j] + 1\r\n\tfor i in range(n): \r\n\t\tif (max < mcl[i]): \r\n\t\t\tmax = mcl[i] \r\n\treturn max" + ], + "Output Answer": [ + "class Pair(object): \r\n\tdef __init__(self, a, b): \r\n\t\tself.a = a \r\n\t\tself.b = b \r\ndef max_chain_length(arr, n): \r\n\tmax = 0\r\n\tmcl = [1 for i in range(n)] \r\n\tfor i in range(1, n): \r\n\t\tfor j in range(0, i): \r\n\t\t\tif (arr[i].a > arr[j].b and\r\n\t\t\t\tmcl[i] < mcl[j] + 1): \r\n\t\t\t\tmcl[i] = mcl[j] + 1\r\n\tfor i in range(n): \r\n\t\tif (max < mcl[i]): \r\n\t\t\tmax = mcl[i] \r\n\treturn max" + ], + "split": "train" + }, + { + "Input": "Write a function to get a lucid number smaller than or equal to n.", + "Output Program": [ + "def get_ludic(n):\r\n\tludics = []\r\n\tfor i in range(1, n + 1):\r\n\t\tludics.append(i)\r\n\tindex = 1\r\n\twhile(index != len(ludics)):\r\n\t\tfirst_ludic = ludics[index]\r\n\t\tremove_index = index + first_ludic\r\n\t\twhile(remove_index < len(ludics)):\r\n\t\t\tludics.remove(ludics[remove_index])\r\n\t\t\tremove_index = remove_index + first_ludic - 1\r\n\t\tindex += 1\r\n\treturn ludics" + ], + "Output Answer": [ + "def get_ludic(n):\r\n\tludics = []\r\n\tfor i in range(1, n + 1):\r\n\t\tludics.append(i)\r\n\tindex = 1\r\n\twhile(index != len(ludics)):\r\n\t\tfirst_ludic = ludics[index]\r\n\t\tremove_index = index + first_ludic\r\n\t\twhile(remove_index < len(ludics)):\r\n\t\t\tludics.remove(ludics[remove_index])\r\n\t\t\tremove_index = remove_index + first_ludic - 1\r\n\t\tindex += 1\r\n\treturn ludics" + ], + "split": "train" + }, + { + "Input": "Write a function to reverse words in a given string.", + "Output Program": [ + "def reverse_words(s):\r\n return ' '.join(reversed(s.split()))" + ], + "Output Answer": [ + "def reverse_words(s):\r\n return ' '.join(reversed(s.split()))" + ], + "split": "train" + }, + { + "Input": "Write a function to check if the given integer is a prime number.", + "Output Program": [ + "def prime_num(num):\r\n if num >=1:\r\n for i in range(2, num//2):\r\n if (num % i) == 0:\r\n return False\r\n else:\r\n return True\r\n else:\r\n return False" + ], + "Output Answer": [ + "def prime_num(num):\r\n if num >=1:\r\n for i in range(2, num//2):\r\n if (num % i) == 0:\r\n return False\r\n else:\r\n return True\r\n else:\r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a function to convert degrees to radians.", + "Output Program": [ + "import math\r\ndef radian_degree(degree):\r\n radian = degree*(math.pi/180)\r\n return radian" + ], + "Output Answer": [ + "import math\r\ndef radian_degree(degree):\r\n radian = degree*(math.pi/180)\r\n return radian" + ], + "split": "train" + }, + { + "Input": "Write a function to search a literals string in a string and also find the location within the original string where the pattern occurs by using regex.", + "Output Program": [ + "import re\r\npattern = 'fox'\r\ntext = 'The quick brown fox jumps over the lazy dog.'\r\ndef find_literals(text, pattern):\r\n match = re.search(pattern, text)\r\n s = match.start()\r\n e = match.end()\r\n return (match.re.pattern, s, e)" + ], + "Output Answer": [ + "import re\r\npattern = 'fox'\r\ntext = 'The quick brown fox jumps over the lazy dog.'\r\ndef find_literals(text, pattern):\r\n match = re.search(pattern, text)\r\n s = match.start()\r\n e = match.end()\r\n return (match.re.pattern, s, e)" + ], + "split": "train" + }, + { + "Input": "Write a python function to find nth bell number.", + "Output Program": [ + "def bell_Number(n): \r\n bell = [[0 for i in range(n+1)] for j in range(n+1)] \r\n bell[0][0] = 1\r\n for i in range(1, n+1):\r\n bell[i][0] = bell[i-1][i-1]\r\n for j in range(1, i+1): \r\n bell[i][j] = bell[i-1][j-1] + bell[i][j-1] \r\n return bell[n][0] " + ], + "Output Answer": [ + "def bell_Number(n): \r\n bell = [[0 for i in range(n+1)] for j in range(n+1)] \r\n bell[0][0] = 1\r\n for i in range(1, n+1):\r\n bell[i][0] = bell[i-1][i-1]\r\n for j in range(1, i+1): \r\n bell[i][j] = bell[i-1][j-1] + bell[i][j-1] \r\n return bell[n][0] " + ], + "split": "train" + }, + { + "Input": "Write a python function to find minimum possible value for the given periodic function.", + "Output Program": [ + "def floor_Min(A,B,N):\r\n x = max(B - 1,N)\r\n return (A*x) // B" + ], + "Output Answer": [ + "def floor_Min(A,B,N):\r\n x = max(B - 1,N)\r\n return (A*x) // B" + ], + "split": "train" + }, + { + "Input": "Write a python function to remove the k'th element from a given list.", + "Output Program": [ + "def remove_kth_element(list1, L):\r\n return list1[:L-1] + list1[L:]" + ], + "Output Answer": [ + "def remove_kth_element(list1, L):\r\n return list1[:L-1] + list1[L:]" + ], + "split": "train" + }, + { + "Input": "Write a function to find the maximum of nth column from the given tuple list.", + "Output Program": [ + "def max_of_nth(test_list, N):\r\n res = max([sub[N] for sub in test_list])\r\n return (res) " + ], + "Output Answer": [ + "def max_of_nth(test_list, N):\r\n res = max([sub[N] for sub in test_list])\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a python function to merge the first and last elements separately in a list of lists.", + "Output Program": [ + "def merge(lst): \r\n return [list(ele) for ele in list(zip(*lst))] " + ], + "Output Answer": [ + "def merge(lst): \r\n return [list(ele) for ele in list(zip(*lst))] " + ], + "split": "train" + }, + { + "Input": "Write a function to find the maximum value in record list as tuple attribute in the given tuple list.", + "Output Program": [ + "def maximum_value(test_list):\r\n res = [(key, max(lst)) for key, lst in test_list]\r\n return (res) " + ], + "Output Answer": [ + "def maximum_value(test_list):\r\n res = [(key, max(lst)) for key, lst in test_list]\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a function to find the cumulative sum of all the values that are present in the given tuple list.", + "Output Program": [ + "def cummulative_sum(test_list):\r\n res = sum(map(sum, test_list))\r\n return (res)" + ], + "Output Answer": [ + "def cummulative_sum(test_list):\r\n res = sum(map(sum, test_list))\r\n return (res)" + ], + "split": "train" + }, + { + "Input": "Write a function to find average value of the numbers in a given tuple of tuples.", + "Output Program": [ + "def average_tuple(nums):\r\n result = [sum(x) / len(x) for x in zip(*nums)]\r\n return result" + ], + "Output Answer": [ + "def average_tuple(nums):\r\n result = [sum(x) / len(x) for x in zip(*nums)]\r\n return result" + ], + "split": "train" + }, + { + "Input": "Write a function to perfom the modulo of tuple elements in the given two tuples.", + "Output Program": [ + "def tuple_modulo(test_tup1, test_tup2):\r\n res = tuple(ele1 % ele2 for ele1, ele2 in zip(test_tup1, test_tup2)) \r\n return (res) " + ], + "Output Answer": [ + "def tuple_modulo(test_tup1, test_tup2):\r\n res = tuple(ele1 % ele2 for ele1, ele2 in zip(test_tup1, test_tup2)) \r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a function to check for the number of jumps required of given length to reach a point of form (d, 0) from origin in a 2d plane.", + "Output Program": [ + "def min_Jumps(a, b, d): \r\n temp = a \r\n a = min(a, b) \r\n b = max(temp, b) \r\n if (d >= b): \r\n return (d + b - 1) / b \r\n if (d == 0): \r\n return 0\r\n if (d == a): \r\n return 1\r\n else:\r\n return 2" + ], + "Output Answer": [ + "def min_Jumps(a, b, d): \r\n temp = a \r\n a = min(a, b) \r\n b = max(temp, b) \r\n if (d >= b): \r\n return (d + b - 1) / b \r\n if (d == 0): \r\n return 0\r\n if (d == a): \r\n return 1\r\n else:\r\n return 2" + ], + "split": "train" + }, + { + "Input": "Write a function to divide two lists using map and lambda function.", + "Output Program": [ + "def div_list(nums1,nums2):\r\n result = map(lambda x, y: x / y, nums1, nums2)\r\n return list(result)" + ], + "Output Answer": [ + "def div_list(nums1,nums2):\r\n result = map(lambda x, y: x / y, nums1, nums2)\r\n return list(result)" + ], + "split": "train" + }, + { + "Input": "Write a function to move all the numbers in it to the given string.", + "Output Program": [ + "def move_num(test_str):\r\n res = ''\r\n dig = ''\r\n for ele in test_str:\r\n if ele.isdigit():\r\n dig += ele\r\n else:\r\n res += ele\r\n res += dig\r\n return (res) " + ], + "Output Answer": [ + "def move_num(test_str):\r\n res = ''\r\n dig = ''\r\n for ele in test_str:\r\n if ele.isdigit():\r\n dig += ele\r\n else:\r\n res += ele\r\n res += dig\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a function to find the largest subset where each pair is divisible.", + "Output Program": [ + "def largest_subset(a, n):\r\n\tdp = [0 for i in range(n)]\r\n\tdp[n - 1] = 1; \r\n\tfor i in range(n - 2, -1, -1):\r\n\t\tmxm = 0;\r\n\t\tfor j in range(i + 1, n):\r\n\t\t\tif a[j] % a[i] == 0 or a[i] % a[j] == 0:\r\n\t\t\t\tmxm = max(mxm, dp[j])\r\n\t\tdp[i] = 1 + mxm\r\n\treturn max(dp)" + ], + "Output Answer": [ + "def largest_subset(a, n):\r\n\tdp = [0 for i in range(n)]\r\n\tdp[n - 1] = 1; \r\n\tfor i in range(n - 2, -1, -1):\r\n\t\tmxm = 0;\r\n\t\tfor j in range(i + 1, n):\r\n\t\t\tif a[j] % a[i] == 0 or a[i] % a[j] == 0:\r\n\t\t\t\tmxm = max(mxm, dp[j])\r\n\t\tdp[i] = 1 + mxm\r\n\treturn max(dp)" + ], + "split": "train" + }, + { + "Input": "Write a function to increment the numeric values in the given strings by k.", + "Output Program": [ + "def increment_numerics(test_list, K):\r\n res = [str(int(ele) + K) if ele.isdigit() else ele for ele in test_list]\r\n return res " + ], + "Output Answer": [ + "def increment_numerics(test_list, K):\r\n res = [str(int(ele) + K) if ele.isdigit() else ele for ele in test_list]\r\n return res " + ], + "split": "train" + }, + { + "Input": "Write a function to find the median of two sorted arrays of same size.", + "Output Program": [ + "def get_median(arr1, arr2, n):\r\n i = 0\r\n j = 0\r\n m1 = -1\r\n m2 = -1\r\n count = 0\r\n while count < n + 1:\r\n count += 1\r\n if i == n:\r\n m1 = m2\r\n m2 = arr2[0]\r\n break\r\n elif j == n:\r\n m1 = m2\r\n m2 = arr1[0]\r\n break\r\n if arr1[i] <= arr2[j]:\r\n m1 = m2\r\n m2 = arr1[i]\r\n i += 1\r\n else:\r\n m1 = m2\r\n m2 = arr2[j]\r\n j += 1\r\n return (m1 + m2)/2" + ], + "Output Answer": [ + "def get_median(arr1, arr2, n):\r\n i = 0\r\n j = 0\r\n m1 = -1\r\n m2 = -1\r\n count = 0\r\n while count < n + 1:\r\n count += 1\r\n if i == n:\r\n m1 = m2\r\n m2 = arr2[0]\r\n break\r\n elif j == n:\r\n m1 = m2\r\n m2 = arr1[0]\r\n break\r\n if arr1[i] <= arr2[j]:\r\n m1 = m2\r\n m2 = arr1[i]\r\n i += 1\r\n else:\r\n m1 = m2\r\n m2 = arr2[j]\r\n j += 1\r\n return (m1 + m2)/2" + ], + "split": "train" + }, + { + "Input": "Write a function to find the n-th power of individual elements in a list using lambda function.", + "Output Program": [ + "def nth_nums(nums,n):\r\n nth_nums = list(map(lambda x: x ** n, nums))\r\n return nth_nums" + ], + "Output Answer": [ + "def nth_nums(nums,n):\r\n nth_nums = list(map(lambda x: x ** n, nums))\r\n return nth_nums" + ], + "split": "train" + }, + { + "Input": "Write a python function to convert the given string to upper case.", + "Output Program": [ + "def is_upper(string):\r\n return (string.upper())" + ], + "Output Answer": [ + "def is_upper(string):\r\n return (string.upper())" + ], + "split": "train" + }, + { + "Input": "Write a python function to interchange first and last elements in a given list.", + "Output Program": [ + "def swap_List(newList): \r\n size = len(newList) \r\n temp = newList[0] \r\n newList[0] = newList[size - 1] \r\n newList[size - 1] = temp \r\n return newList " + ], + "Output Answer": [ + "def swap_List(newList): \r\n size = len(newList) \r\n temp = newList[0] \r\n newList[0] = newList[size - 1] \r\n newList[size - 1] = temp \r\n return newList " + ], + "split": "train" + }, + { + "Input": "Write a python function to find the largest triangle that can be inscribed in the semicircle.", + "Output Program": [ + "def triangle_area(r) : \r\n if r < 0 : \r\n return -1\r\n return r * r " + ], + "Output Answer": [ + "def triangle_area(r) : \r\n if r < 0 : \r\n return -1\r\n return r * r " + ], + "split": "train" + }, + { + "Input": "Write a python function to find the smallest missing number from the given array.", + "Output Program": [ + "def find_First_Missing(array,start,end): \r\n if (start > end): \r\n return end + 1\r\n if (start != array[start]): \r\n return start; \r\n mid = int((start + end) / 2) \r\n if (array[mid] == mid): \r\n return find_First_Missing(array,mid+1,end) \r\n return find_First_Missing(array,start,mid) " + ], + "Output Answer": [ + "def find_First_Missing(array,start,end): \r\n if (start > end): \r\n return end + 1\r\n if (start != array[start]): \r\n return start; \r\n mid = int((start + end) / 2) \r\n if (array[mid] == mid): \r\n return find_First_Missing(array,mid+1,end) \r\n return find_First_Missing(array,start,mid) " + ], + "split": "train" + }, + { + "Input": "Write a function to replace all spaces in the given string with character * list item * list item * list item * list item '%20'.", + "Output Program": [ + "MAX=1000;\r\ndef replace_spaces(string):\r\n string=string.strip()\r\n i=len(string)\r\n space_count=string.count(' ')\r\n new_length = i + space_count*2\r\n if new_length > MAX:\r\n return -1\r\n index = new_length-1\r\n string=list(string)\r\n for f in range(i-2, new_length-2):\r\n string.append('0')\r\n for j in range(i-1, 0, -1):\r\n if string[j] == ' ':\r\n string[index] = '0'\r\n string[index-1] = '2'\r\n string[index-2] = '%'\r\n index=index-3\r\n else:\r\n string[index] = string[j]\r\n index -= 1\r\n return ''.join(string)" + ], + "Output Answer": [ + "MAX=1000;\r\ndef replace_spaces(string):\r\n string=string.strip()\r\n i=len(string)\r\n space_count=string.count(' ')\r\n new_length = i + space_count*2\r\n if new_length > MAX:\r\n return -1\r\n index = new_length-1\r\n string=list(string)\r\n for f in range(i-2, new_length-2):\r\n string.append('0')\r\n for j in range(i-1, 0, -1):\r\n if string[j] == ' ':\r\n string[index] = '0'\r\n string[index-1] = '2'\r\n string[index-2] = '%'\r\n index=index-3\r\n else:\r\n string[index] = string[j]\r\n index -= 1\r\n return ''.join(string)" + ], + "split": "train" + }, + { + "Input": "Write a python function to find even numbers from a mixed list.", + "Output Program": [ + "def Split(list): \r\n ev_li = [] \r\n for i in list: \r\n if (i % 2 == 0): \r\n ev_li.append(i) \r\n return ev_li" + ], + "Output Answer": [ + "def Split(list): \r\n ev_li = [] \r\n for i in list: \r\n if (i % 2 == 0): \r\n ev_li.append(i) \r\n return ev_li" + ], + "split": "train" + }, + { + "Input": "Write a function to extract all the adjacent coordinates of the given coordinate tuple.", + "Output Program": [ + "def adjac(ele, sub = []): \r\n if not ele: \r\n yield sub \r\n else: \r\n yield from [idx for j in range(ele[0] - 1, ele[0] + 2) \r\n for idx in adjac(ele[1:], sub + [j])] \r\ndef get_coordinates(test_tup):\r\n res = list(adjac(test_tup))\r\n return (res) " + ], + "Output Answer": [ + "def adjac(ele, sub = []): \r\n if not ele: \r\n yield sub \r\n else: \r\n yield from [idx for j in range(ele[0] - 1, ele[0] + 2) \r\n for idx in adjac(ele[1:], sub + [j])] \r\ndef get_coordinates(test_tup):\r\n res = list(adjac(test_tup))\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a function to replace whitespaces with an underscore and vice versa in a given string by using regex.", + "Output Program": [ + "import re\r\ntext = 'Python Exercises'\r\ndef replace_spaces(text):\r\n text =text.replace (\" \", \"_\")\r\n return (text)\r\n text =text.replace (\"_\", \" \")\r\n return (text)" + ], + "Output Answer": [ + "import re\r\ntext = 'Python Exercises'\r\ndef replace_spaces(text):\r\n text =text.replace (\" \", \"_\")\r\n return (text)\r\n text =text.replace (\"_\", \" \")\r\n return (text)" + ], + "split": "train" + }, + { + "Input": "Write a python function to move all zeroes to the end of the given list.", + "Output Program": [ + "def move_zero(num_list):\r\n a = [0 for i in range(num_list.count(0))]\r\n x = [ i for i in num_list if i != 0]\r\n x.extend(a)\r\n return (x)" + ], + "Output Answer": [ + "def move_zero(num_list):\r\n a = [0 for i in range(num_list.count(0))]\r\n x = [ i for i in num_list if i != 0]\r\n x.extend(a)\r\n return (x)" + ], + "split": "train" + }, + { + "Input": "Write a python function to find the sum of xor of all pairs of numbers in the given array.", + "Output Program": [ + "def pair_OR_Sum(arr,n) : \r\n ans = 0 \r\n for i in range(0,n) : \r\n for j in range(i + 1,n) : \r\n ans = ans + (arr[i] ^ arr[j]) \r\n return ans " + ], + "Output Answer": [ + "def pair_OR_Sum(arr,n) : \r\n ans = 0 \r\n for i in range(0,n) : \r\n for j in range(i + 1,n) : \r\n ans = ans + (arr[i] ^ arr[j]) \r\n return ans " + ], + "split": "train" + }, + { + "Input": "Write a python function to find the sum of fourth power of first n even natural numbers.", + "Output Program": [ + "def even_Power_Sum(n): \r\n sum = 0; \r\n for i in range(1,n + 1): \r\n j = 2*i; \r\n sum = sum + (j*j*j*j); \r\n return sum; " + ], + "Output Answer": [ + "def even_Power_Sum(n): \r\n sum = 0; \r\n for i in range(1,n + 1): \r\n j = 2*i; \r\n sum = sum + (j*j*j*j); \r\n return sum; " + ], + "split": "train" + }, + { + "Input": "Write a function to push all values into a heap and then pop off the smallest values one at a time.", + "Output Program": [ + "import heapq as hq\r\ndef heap_sort(iterable):\r\n h = []\r\n for value in iterable:\r\n hq.heappush(h, value)\r\n return [hq.heappop(h) for i in range(len(h))]" + ], + "Output Answer": [ + "import heapq as hq\r\ndef heap_sort(iterable):\r\n h = []\r\n for value in iterable:\r\n hq.heappush(h, value)\r\n return [hq.heappop(h) for i in range(len(h))]" + ], + "split": "train" + }, + { + "Input": "Write a python function to check if roots of a quadratic equation are reciprocal of each other or not.", + "Output Program": [ + "def Check_Solution(a,b,c): \r\n if (a == c): \r\n return (\"Yes\"); \r\n else: \r\n return (\"No\"); " + ], + "Output Answer": [ + "def Check_Solution(a,b,c): \r\n if (a == c): \r\n return (\"Yes\"); \r\n else: \r\n return (\"No\"); " + ], + "split": "train" + }, + { + "Input": "Write a function to check whether the given amount has no profit and no loss", + "Output Program": [ + "def noprofit_noloss(actual_cost,sale_amount): \r\n if(sale_amount == actual_cost):\r\n return True\r\n else:\r\n return False" + ], + "Output Answer": [ + "def noprofit_noloss(actual_cost,sale_amount): \r\n if(sale_amount == actual_cost):\r\n return True\r\n else:\r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a function to calculate wind chill index.", + "Output Program": [ + "import math\r\ndef wind_chill(v,t):\r\n windchill = 13.12 + 0.6215*t - 11.37*math.pow(v, 0.16) + 0.3965*t*math.pow(v, 0.16)\r\n return int(round(windchill, 0))" + ], + "Output Answer": [ + "import math\r\ndef wind_chill(v,t):\r\n windchill = 13.12 + 0.6215*t - 11.37*math.pow(v, 0.16) + 0.3965*t*math.pow(v, 0.16)\r\n return int(round(windchill, 0))" + ], + "split": "train" + }, + { + "Input": "Write a function to sum the length of the names of a given list of names after removing the names that start with a lowercase letter.", + "Output Program": [ + "def sample_nam(sample_names):\r\n sample_names=list(filter(lambda el:el[0].isupper() and el[1:].islower(),sample_names))\r\n return len(''.join(sample_names))" + ], + "Output Answer": [ + "def sample_nam(sample_names):\r\n sample_names=list(filter(lambda el:el[0].isupper() and el[1:].islower(),sample_names))\r\n return len(''.join(sample_names))" + ], + "split": "train" + }, + { + "Input": "Write a function to remove the parenthesis area in a string.", + "Output Program": [ + "import re\r\ndef remove_parenthesis(items):\r\n for item in items:\r\n return (re.sub(r\" ?\\([^)]+\\)\", \"\", item))" + ], + "Output Answer": [ + "import re\r\ndef remove_parenthesis(items):\r\n for item in items:\r\n return (re.sub(r\" ?\\([^)]+\\)\", \"\", item))" + ], + "split": "train" + }, + { + "Input": "Write a function to find the nth nonagonal number.", + "Output Program": [ + "def is_nonagonal(n): \r\n\treturn int(n * (7 * n - 5) / 2) " + ], + "Output Answer": [ + "def is_nonagonal(n): \r\n\treturn int(n * (7 * n - 5) / 2) " + ], + "split": "train" + }, + { + "Input": "Write a function to remove similar rows from the given tuple matrix.", + "Output Program": [ + "def remove_similar_row(test_list):\r\n res = set([tuple(set(sub)) for sub in test_list])\r\n return (res) " + ], + "Output Answer": [ + "def remove_similar_row(test_list):\r\n res = set([tuple(set(sub)) for sub in test_list])\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a function that matches a word containing 'z', not at the start or end of the word.", + "Output Program": [ + "import re\r\ndef text_match_wordz_middle(text):\r\n patterns = '\\Bz\\B'\r\n if re.search(patterns, text):\r\n return 'Found a match!'\r\n else:\r\n return('Not matched!')" + ], + "Output Answer": [ + "import re\r\ndef text_match_wordz_middle(text):\r\n patterns = '\\Bz\\B'\r\n if re.search(patterns, text):\r\n return 'Found a match!'\r\n else:\r\n return('Not matched!')" + ], + "split": "train" + }, + { + "Input": "Write a python function to reverse an array upto a given position.", + "Output Program": [ + "def reverse_Array_Upto_K(input, k): \r\n return (input[k-1::-1] + input[k:]) " + ], + "Output Answer": [ + "def reverse_Array_Upto_K(input, k): \r\n return (input[k-1::-1] + input[k:]) " + ], + "split": "train" + }, + { + "Input": "Write a function to find the product of it\u2019s kth index in the given tuples.", + "Output Program": [ + "def get_product(val) : \r\n\tres = 1\r\n\tfor ele in val: \r\n\t\tres *= ele \r\n\treturn res \r\ndef find_k_product(test_list, K):\r\n res = get_product([sub[K] for sub in test_list])\r\n return (res) " + ], + "Output Answer": [ + "def get_product(val) : \r\n\tres = 1\r\n\tfor ele in val: \r\n\t\tres *= ele \r\n\treturn res \r\ndef find_k_product(test_list, K):\r\n res = get_product([sub[K] for sub in test_list])\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a python function to count number of cubes of size k in a cube of size n.", + "Output Program": [ + "def No_of_cubes(N,K):\r\n No = 0\r\n No = (N - K + 1)\r\n No = pow(No, 3)\r\n return No" + ], + "Output Answer": [ + "def No_of_cubes(N,K):\r\n No = 0\r\n No = (N - K + 1)\r\n No = pow(No, 3)\r\n return No" + ], + "split": "train" + }, + { + "Input": "Write a function to split a string at uppercase letters.", + "Output Program": [ + "import re\r\ndef split_upperstring(text):\r\n return (re.findall('[A-Z][^A-Z]*', text))" + ], + "Output Answer": [ + "import re\r\ndef split_upperstring(text):\r\n return (re.findall('[A-Z][^A-Z]*', text))" + ], + "split": "train" + }, + { + "Input": "Write a function to exchange the position of every n-th value with (n+1)th value and (n+1)th value with n-th value in a given list.", + "Output Program": [ + "from itertools import zip_longest, chain, tee\r\ndef exchange_elements(lst):\r\n lst1, lst2 = tee(iter(lst), 2)\r\n return list(chain.from_iterable(zip_longest(lst[1::2], lst[::2])))" + ], + "Output Answer": [ + "from itertools import zip_longest, chain, tee\r\ndef exchange_elements(lst):\r\n lst1, lst2 = tee(iter(lst), 2)\r\n return list(chain.from_iterable(zip_longest(lst[1::2], lst[::2])))" + ], + "split": "train" + }, + { + "Input": "Write a python function to calculate the sum of the numbers in a list between the indices of a specified range.", + "Output Program": [ + "def sum_Range_list(nums, m, n): \r\n sum_range = 0 \r\n for i in range(m, n+1, 1): \r\n sum_range += nums[i] \r\n return sum_range " + ], + "Output Answer": [ + "def sum_Range_list(nums, m, n): \r\n sum_range = 0 \r\n for i in range(m, n+1, 1): \r\n sum_range += nums[i] \r\n return sum_range " + ], + "split": "train" + }, + { + "Input": "Write a python function to check whether the given two arrays are equal or not.", + "Output Program": [ + "def are_Equal(arr1,arr2,n,m):\r\n if (n != m):\r\n return False\r\n arr1.sort()\r\n arr2.sort()\r\n for i in range(0,n - 1):\r\n if (arr1[i] != arr2[i]):\r\n return False\r\n return True" + ], + "Output Answer": [ + "def are_Equal(arr1,arr2,n,m):\r\n if (n != m):\r\n return False\r\n arr1.sort()\r\n arr2.sort()\r\n for i in range(0,n - 1):\r\n if (arr1[i] != arr2[i]):\r\n return False\r\n return True" + ], + "split": "train" + }, + { + "Input": "Write a function to check if one tuple is a subset of another tuple.", + "Output Program": [ + "def check_subset(test_tup1, test_tup2):\r\n res = set(test_tup2).issubset(test_tup1)\r\n return (res) " + ], + "Output Answer": [ + "def check_subset(test_tup1, test_tup2):\r\n res = set(test_tup2).issubset(test_tup1)\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a function to flatten the given tuple matrix into the tuple list with each tuple representing each column.", + "Output Program": [ + "def matrix_to_list(test_list):\r\n temp = [ele for sub in test_list for ele in sub]\r\n res = list(zip(*temp))\r\n return (str(res))" + ], + "Output Answer": [ + "def matrix_to_list(test_list):\r\n temp = [ele for sub in test_list for ele in sub]\r\n res = list(zip(*temp))\r\n return (str(res))" + ], + "split": "train" + }, + { + "Input": "Write a function to group a sequence of key-value pairs into a dictionary of lists using collections module.", + "Output Program": [ + "from collections import defaultdict\r\ndef grouping_dictionary(l):\r\n d = defaultdict(list)\r\n for k, v in l:\r\n d[k].append(v)\r\n return d" + ], + "Output Answer": [ + "from collections import defaultdict\r\ndef grouping_dictionary(l):\r\n d = defaultdict(list)\r\n for k, v in l:\r\n d[k].append(v)\r\n return d" + ], + "split": "train" + }, + { + "Input": "Write a function to find the perimeter of a rectangle.", + "Output Program": [ + "def rectangle_perimeter(l,b):\r\n perimeter=2*(l+b)\r\n return perimeter" + ], + "Output Answer": [ + "def rectangle_perimeter(l,b):\r\n perimeter=2*(l+b)\r\n return perimeter" + ], + "split": "train" + }, + { + "Input": "Write a python function to find the sum of fifth power of n natural numbers.", + "Output Program": [ + "def fifth_Power_Sum(n) : \r\n sm = 0 \r\n for i in range(1,n+1) : \r\n sm = sm + (i*i*i*i*i) \r\n return sm " + ], + "Output Answer": [ + "def fifth_Power_Sum(n) : \r\n sm = 0 \r\n for i in range(1,n+1) : \r\n sm = sm + (i*i*i*i*i) \r\n return sm " + ], + "split": "train" + }, + { + "Input": "Write a python function to find the minimum sum of absolute differences of two arrays.", + "Output Program": [ + "def find_Min_Sum(a,b,n): \r\n a.sort() \r\n b.sort() \r\n sum = 0 \r\n for i in range(n): \r\n sum = sum + abs(a[i] - b[i]) \r\n return sum" + ], + "Output Answer": [ + "def find_Min_Sum(a,b,n): \r\n a.sort() \r\n b.sort() \r\n sum = 0 \r\n for i in range(n): \r\n sum = sum + abs(a[i] - b[i]) \r\n return sum" + ], + "split": "train" + }, + { + "Input": "Write a python function to find the first digit in factorial of a given number.", + "Output Program": [ + "import math \r\ndef first_Digit(n) : \r\n fact = 1\r\n for i in range(2,n + 1) : \r\n fact = fact * i \r\n while (fact % 10 == 0) : \r\n fact = int(fact / 10) \r\n while (fact >= 10) : \r\n fact = int(fact / 10) \r\n return math.floor(fact) " + ], + "Output Answer": [ + "import math \r\ndef first_Digit(n) : \r\n fact = 1\r\n for i in range(2,n + 1) : \r\n fact = fact * i \r\n while (fact % 10 == 0) : \r\n fact = int(fact / 10) \r\n while (fact >= 10) : \r\n fact = int(fact / 10) \r\n return math.floor(fact) " + ], + "split": "train" + }, + { + "Input": "Write a function to find the item with maximum occurrences in a given list.", + "Output Program": [ + "def max_occurrences(list1):\r\n max_val = 0\r\n result = list1[0] \r\n for i in list1:\r\n occu = list1.count(i)\r\n if occu > max_val:\r\n max_val = occu\r\n result = i \r\n return result" + ], + "Output Answer": [ + "def max_occurrences(list1):\r\n max_val = 0\r\n result = list1[0] \r\n for i in list1:\r\n occu = list1.count(i)\r\n if occu > max_val:\r\n max_val = occu\r\n result = i \r\n return result" + ], + "split": "train" + }, + { + "Input": "Write a python function to print duplicants from a list of integers.", + "Output Program": [ + "def Repeat(x): \r\n _size = len(x) \r\n repeated = [] \r\n for i in range(_size): \r\n k = i + 1\r\n for j in range(k, _size): \r\n if x[i] == x[j] and x[i] not in repeated: \r\n repeated.append(x[i]) \r\n return repeated " + ], + "Output Answer": [ + "def Repeat(x): \r\n _size = len(x) \r\n repeated = [] \r\n for i in range(_size): \r\n k = i + 1\r\n for j in range(k, _size): \r\n if x[i] == x[j] and x[i] not in repeated: \r\n repeated.append(x[i]) \r\n return repeated " + ], + "split": "train" + }, + { + "Input": "Write a python function to choose points from two ranges such that no point lies in both the ranges.", + "Output Program": [ + "def find_Points(l1,r1,l2,r2): \r\n x = min(l1,l2) if (l1 != l2) else -1\r\n y = max(r1,r2) if (r1 != r2) else -1\r\n return (x,y)" + ], + "Output Answer": [ + "def find_Points(l1,r1,l2,r2): \r\n x = min(l1,l2) if (l1 != l2) else -1\r\n y = max(r1,r2) if (r1 != r2) else -1\r\n return (x,y)" + ], + "split": "train" + }, + { + "Input": "Write a function to find the maximum sum that can be formed which has no three consecutive elements present.", + "Output Program": [ + "def max_sum_of_three_consecutive(arr, n): \r\n\tsum = [0 for k in range(n)] \r\n\tif n >= 1: \r\n\t\tsum[0] = arr[0] \r\n\tif n >= 2: \r\n\t\tsum[1] = arr[0] + arr[1] \r\n\tif n > 2: \r\n\t\tsum[2] = max(sum[1], max(arr[1] + arr[2], arr[0] + arr[2])) \r\n\tfor i in range(3, n): \r\n\t\tsum[i] = max(max(sum[i-1], sum[i-2] + arr[i]), arr[i] + arr[i-1] + sum[i-3]) \r\n\treturn sum[n-1]" + ], + "Output Answer": [ + "def max_sum_of_three_consecutive(arr, n): \r\n\tsum = [0 for k in range(n)] \r\n\tif n >= 1: \r\n\t\tsum[0] = arr[0] \r\n\tif n >= 2: \r\n\t\tsum[1] = arr[0] + arr[1] \r\n\tif n > 2: \r\n\t\tsum[2] = max(sum[1], max(arr[1] + arr[2], arr[0] + arr[2])) \r\n\tfor i in range(3, n): \r\n\t\tsum[i] = max(max(sum[i-1], sum[i-2] + arr[i]), arr[i] + arr[i-1] + sum[i-3]) \r\n\treturn sum[n-1]" + ], + "split": "train" + }, + { + "Input": "Write a function to sort a list in a dictionary.", + "Output Program": [ + "def sorted_dict(dict1):\r\n sorted_dict = {x: sorted(y) for x, y in dict1.items()}\r\n return sorted_dict" + ], + "Output Answer": [ + "def sorted_dict(dict1):\r\n sorted_dict = {x: sorted(y) for x, y in dict1.items()}\r\n return sorted_dict" + ], + "split": "train" + }, + { + "Input": "Write a function to find the largest possible value of k such that k modulo x is y.", + "Output Program": [ + "import sys \r\ndef find_max_val(n, x, y): \r\n\tans = -sys.maxsize \r\n\tfor k in range(n + 1): \r\n\t\tif (k % x == y): \r\n\t\t\tans = max(ans, k) \r\n\treturn (ans if (ans >= 0 and\r\n\t\t\t\t\tans <= n) else -1) " + ], + "Output Answer": [ + "import sys \r\ndef find_max_val(n, x, y): \r\n\tans = -sys.maxsize \r\n\tfor k in range(n + 1): \r\n\t\tif (k % x == y): \r\n\t\t\tans = max(ans, k) \r\n\treturn (ans if (ans >= 0 and\r\n\t\t\t\t\tans <= n) else -1) " + ], + "split": "train" + }, + { + "Input": "Write a python function to find the average of even numbers till a given even number.", + "Output Program": [ + "def average_Even(n) : \r\n if (n% 2!= 0) : \r\n return (\"Invalid Input\") \r\n return -1 \r\n sm = 0\r\n count = 0\r\n while (n>= 2) : \r\n count = count+1\r\n sm = sm+n \r\n n = n-2\r\n return sm // count " + ], + "Output Answer": [ + "def average_Even(n) : \r\n if (n% 2!= 0) : \r\n return (\"Invalid Input\") \r\n return -1 \r\n sm = 0\r\n count = 0\r\n while (n>= 2) : \r\n count = count+1\r\n sm = sm+n \r\n n = n-2\r\n return sm // count " + ], + "split": "train" + }, + { + "Input": "Write a python function to shift first element to the end of given list.", + "Output Program": [ + "def move_last(num_list):\r\n a = [num_list[0] for i in range(num_list.count(num_list[0]))]\r\n x = [ i for i in num_list if i != num_list[0]]\r\n x.extend(a)\r\n return (x)" + ], + "Output Answer": [ + "def move_last(num_list):\r\n a = [num_list[0] for i in range(num_list.count(num_list[0]))]\r\n x = [ i for i in num_list if i != num_list[0]]\r\n x.extend(a)\r\n return (x)" + ], + "split": "train" + }, + { + "Input": "Write a function to count occurrence of a character in a string.", + "Output Program": [ + "def count_char(string,char):\r\n count = 0\r\n for i in range(len(string)):\r\n if(string[i] == char):\r\n count = count + 1\r\n return count" + ], + "Output Answer": [ + "def count_char(string,char):\r\n count = 0\r\n for i in range(len(string)):\r\n if(string[i] == char):\r\n count = count + 1\r\n return count" + ], + "split": "train" + }, + { + "Input": "Write a python function to count number of vowels in the string.", + "Output Program": [ + "def Check_Vow(string, vowels): \r\n final = [each for each in string if each in vowels] \r\n return(len(final)) \r\n" + ], + "Output Answer": [ + "def Check_Vow(string, vowels): \r\n final = [each for each in string if each in vowels] \r\n return(len(final)) \r\n" + ], + "split": "train" + }, + { + "Input": "Write a python function to replace multiple occurence of character by single.", + "Output Program": [ + "import re \r\ndef replace(string, char): \r\n pattern = char + '{2,}'\r\n string = re.sub(pattern, char, string) \r\n return string " + ], + "Output Answer": [ + "import re \r\ndef replace(string, char): \r\n pattern = char + '{2,}'\r\n string = re.sub(pattern, char, string) \r\n return string " + ], + "split": "train" + }, + { + "Input": "Write a function to check whether the given ip address is valid or not using regex.", + "Output Program": [ + "import re \r\nregex = '''^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.( \r\n\t\t\t25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.( \r\n\t\t\t25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.( \r\n\t\t\t25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$'''\r\ndef check_IP(Ip): \r\n\tif(re.search(regex, Ip)): \r\n\t\treturn (\"Valid IP address\") \r\n\telse: \r\n\t\treturn (\"Invalid IP address\") " + ], + "Output Answer": [ + "import re \r\nregex = '''^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.( \r\n\t\t\t25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.( \r\n\t\t\t25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.( \r\n\t\t\t25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$'''\r\ndef check_IP(Ip): \r\n\tif(re.search(regex, Ip)): \r\n\t\treturn (\"Valid IP address\") \r\n\telse: \r\n\t\treturn (\"Invalid IP address\") " + ], + "split": "train" + }, + { + "Input": "Write a python function to check whether a sequence of numbers has a decreasing trend or not.", + "Output Program": [ + "def decreasing_trend(nums):\r\n if (sorted(nums)== nums):\r\n return True\r\n else:\r\n return False" + ], + "Output Answer": [ + "def decreasing_trend(nums):\r\n if (sorted(nums)== nums):\r\n return True\r\n else:\r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a python function to set the right most unset bit.", + "Output Program": [ + "import math \r\ndef get_Pos_Of_Right_most_Set_Bit(n): \r\n return int(math.log2(n&-n)+1) \r\ndef set_Right_most_Unset_Bit(n): \r\n if (n == 0): \r\n return 1\r\n if ((n & (n + 1)) == 0): \r\n return n \r\n pos = get_Pos_Of_Right_most_Set_Bit(~n) \r\n return ((1 << (pos - 1)) | n) " + ], + "Output Answer": [ + "import math \r\ndef get_Pos_Of_Right_most_Set_Bit(n): \r\n return int(math.log2(n&-n)+1) \r\ndef set_Right_most_Unset_Bit(n): \r\n if (n == 0): \r\n return 1\r\n if ((n & (n + 1)) == 0): \r\n return n \r\n pos = get_Pos_Of_Right_most_Set_Bit(~n) \r\n return ((1 << (pos - 1)) | n) " + ], + "split": "train" + }, + { + "Input": "Write a function to find maximum of three numbers.", + "Output Program": [ + "def max_of_three(num1,num2,num3): \r\n if (num1 >= num2) and (num1 >= num3):\r\n lnum = num1\r\n elif (num2 >= num1) and (num2 >= num3):\r\n lnum = num2\r\n else:\r\n lnum = num3\r\n return lnum" + ], + "Output Answer": [ + "def max_of_three(num1,num2,num3): \r\n if (num1 >= num2) and (num1 >= num3):\r\n lnum = num1\r\n elif (num2 >= num1) and (num2 >= num3):\r\n lnum = num2\r\n else:\r\n lnum = num3\r\n return lnum" + ], + "split": "train" + }, + { + "Input": "Write a python function to convert a list of multiple integers into a single integer.", + "Output Program": [ + "def convert(list): \r\n s = [str(i) for i in list] \r\n res = int(\"\".join(s)) \r\n return (res) " + ], + "Output Answer": [ + "def convert(list): \r\n s = [str(i) for i in list] \r\n res = int(\"\".join(s)) \r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a function to remove duplicate words from a given string using collections module.", + "Output Program": [ + "from collections import OrderedDict\r\ndef remove_duplicate(string):\r\n result = ' '.join(OrderedDict((w,w) for w in string.split()).keys())\r\n return result" + ], + "Output Answer": [ + "from collections import OrderedDict\r\ndef remove_duplicate(string):\r\n result = ' '.join(OrderedDict((w,w) for w in string.split()).keys())\r\n return result" + ], + "split": "train" + }, + { + "Input": "Write a function to add two integers. however, if the sum is between the given range it will return 20.", + "Output Program": [ + "def sum_nums(x, y,m,n):\r\n sum_nums= x + y\r\n if sum_nums in range(m, n):\r\n return 20\r\n else:\r\n return sum_nums" + ], + "Output Answer": [ + "def sum_nums(x, y,m,n):\r\n sum_nums= x + y\r\n if sum_nums in range(m, n):\r\n return 20\r\n else:\r\n return sum_nums" + ], + "split": "train" + }, + { + "Input": "Write a function to remove everything except alphanumeric characters from the given string by using regex.", + "Output Program": [ + "import re\r\ndef remove_extra_char(text1):\r\n pattern = re.compile('[\\W_]+')\r\n return (pattern.sub('', text1))" + ], + "Output Answer": [ + "import re\r\ndef remove_extra_char(text1):\r\n pattern = re.compile('[\\W_]+')\r\n return (pattern.sub('', text1))" + ], + "split": "train" + }, + { + "Input": "Write a function to check if the triangle is valid or not.", + "Output Program": [ + "def validity_triangle(a,b,c):\r\n total = a + b + c\r\n if total == 180:\r\n return True\r\n else:\r\n return False" + ], + "Output Answer": [ + "def validity_triangle(a,b,c):\r\n total = a + b + c\r\n if total == 180:\r\n return True\r\n else:\r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a python function to remove spaces from a given string.", + "Output Program": [ + "def remove_spaces(str1):\r\n str1 = str1.replace(' ','')\r\n return str1" + ], + "Output Answer": [ + "def remove_spaces(str1):\r\n str1 = str1.replace(' ','')\r\n return str1" + ], + "split": "train" + }, + { + "Input": "Write a function to access dictionary key\u2019s element by index.", + "Output Program": [ + "def access_key(ditionary,key):\r\n return list(ditionary)[key]" + ], + "Output Answer": [ + "def access_key(ditionary,key):\r\n return list(ditionary)[key]" + ], + "split": "train" + }, + { + "Input": "Write a python function to check whether a sequence of numbers has an increasing trend or not.", + "Output Program": [ + "def increasing_trend(nums):\r\n if (sorted(nums)== nums):\r\n return True\r\n else:\r\n return False" + ], + "Output Answer": [ + "def increasing_trend(nums):\r\n if (sorted(nums)== nums):\r\n return True\r\n else:\r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a python function to find the smallest prime divisor of a number.", + "Output Program": [ + "def smallest_Divisor(n): \r\n if (n % 2 == 0): \r\n return 2; \r\n i = 3; \r\n while (i*i <= n): \r\n if (n % i == 0): \r\n return i; \r\n i += 2; \r\n return n; " + ], + "Output Answer": [ + "def smallest_Divisor(n): \r\n if (n % 2 == 0): \r\n return 2; \r\n i = 3; \r\n while (i*i <= n): \r\n if (n % i == 0): \r\n return i; \r\n i += 2; \r\n return n; " + ], + "split": "train" + }, + { + "Input": "Write a function to multiply two lists using map and lambda function.", + "Output Program": [ + "def mul_list(nums1,nums2):\r\n result = map(lambda x, y: x * y, nums1, nums2)\r\n return list(result)" + ], + "Output Answer": [ + "def mul_list(nums1,nums2):\r\n result = map(lambda x, y: x * y, nums1, nums2)\r\n return list(result)" + ], + "split": "train" + }, + { + "Input": "Write a python function to check whether the given number can be represented by sum of two squares or not.", + "Output Program": [ + "def sum_Square(n) : \r\n i = 1 \r\n while i*i <= n : \r\n j = 1\r\n while (j*j <= n) : \r\n if (i*i+j*j == n) : \r\n return True\r\n j = j+1\r\n i = i+1 \r\n return False" + ], + "Output Answer": [ + "def sum_Square(n) : \r\n i = 1 \r\n while i*i <= n : \r\n j = 1\r\n while (j*j <= n) : \r\n if (i*i+j*j == n) : \r\n return True\r\n j = j+1\r\n i = i+1 \r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a python function to count occurences of a character in a repeated string.", + "Output Program": [ + "def count_Char(str,x): \r\n count = 0\r\n for i in range(len(str)): \r\n if (str[i] == x) : \r\n count += 1\r\n n = 10\r\n repititions = n // len(str) \r\n count = count * repititions \r\n l = n % len(str) \r\n for i in range(l): \r\n if (str[i] == x): \r\n count += 1\r\n return count " + ], + "Output Answer": [ + "def count_Char(str,x): \r\n count = 0\r\n for i in range(len(str)): \r\n if (str[i] == x) : \r\n count += 1\r\n n = 10\r\n repititions = n // len(str) \r\n count = count * repititions \r\n l = n % len(str) \r\n for i in range(l): \r\n if (str[i] == x): \r\n count += 1\r\n return count " + ], + "split": "train" + }, + { + "Input": "Write a python function to find sum of prime numbers between 1 to n.", + "Output Program": [ + "def sum_Of_Primes(n): \r\n prime = [True] * (n + 1) \r\n p = 2\r\n while p * p <= n: \r\n if prime[p] == True: \r\n i = p * 2\r\n while i <= n: \r\n prime[i] = False\r\n i += p \r\n p += 1 \r\n sum = 0\r\n for i in range (2,n + 1): \r\n if(prime[i]): \r\n sum += i \r\n return sum" + ], + "Output Answer": [ + "def sum_Of_Primes(n): \r\n prime = [True] * (n + 1) \r\n p = 2\r\n while p * p <= n: \r\n if prime[p] == True: \r\n i = p * 2\r\n while i <= n: \r\n prime[i] = False\r\n i += p \r\n p += 1 \r\n sum = 0\r\n for i in range (2,n + 1): \r\n if(prime[i]): \r\n sum += i \r\n return sum" + ], + "split": "train" + }, + { + "Input": "Write a function to find the frequency of each element in the given list.", + "Output Program": [ + "from collections import defaultdict \r\ndef freq_element(test_tup):\r\n res = defaultdict(int)\r\n for ele in test_tup:\r\n res[ele] += 1\r\n return (str(dict(res))) " + ], + "Output Answer": [ + "from collections import defaultdict \r\ndef freq_element(test_tup):\r\n res = defaultdict(int)\r\n for ele in test_tup:\r\n res[ele] += 1\r\n return (str(dict(res))) " + ], + "split": "train" + }, + { + "Input": "Write a function to find the greatest common divisor (gcd) of two integers by using recursion.", + "Output Program": [ + "def recur_gcd(a, b):\r\n\tlow = min(a, b)\r\n\thigh = max(a, b)\r\n\tif low == 0:\r\n\t\treturn high\r\n\telif low == 1:\r\n\t\treturn 1\r\n\telse:\r\n\t\treturn recur_gcd(low, high%low)" + ], + "Output Answer": [ + "def recur_gcd(a, b):\r\n\tlow = min(a, b)\r\n\thigh = max(a, b)\r\n\tif low == 0:\r\n\t\treturn high\r\n\telif low == 1:\r\n\t\treturn 1\r\n\telse:\r\n\t\treturn recur_gcd(low, high%low)" + ], + "split": "train" + }, + { + "Input": "Write a function to get the length of a complex number.", + "Output Program": [ + "import cmath\r\ndef len_complex(a,b):\r\n cn=complex(a,b)\r\n length=abs(cn)\r\n return length" + ], + "Output Answer": [ + "import cmath\r\ndef len_complex(a,b):\r\n cn=complex(a,b)\r\n length=abs(cn)\r\n return length" + ], + "split": "train" + }, + { + "Input": "## write a function to find the minimum number of jumps to reach the end of the array for the given array of integers where each element represents the max number of steps that can be made forward from that element. > indented block > indented block", + "Output Program": [ + "def min_jumps(arr, n):\r\n\tjumps = [0 for i in range(n)]\r\n\tif (n == 0) or (arr[0] == 0):\r\n\t\treturn float('inf')\r\n\tjumps[0] = 0\r\n\tfor i in range(1, n):\r\n\t\tjumps[i] = float('inf')\r\n\t\tfor j in range(i):\r\n\t\t\tif (i <= j + arr[j]) and (jumps[j] != float('inf')):\r\n\t\t\t\tjumps[i] = min(jumps[i], jumps[j] + 1)\r\n\t\t\t\tbreak\r\n\treturn jumps[n-1]" + ], + "Output Answer": [ + "def min_jumps(arr, n):\r\n\tjumps = [0 for i in range(n)]\r\n\tif (n == 0) or (arr[0] == 0):\r\n\t\treturn float('inf')\r\n\tjumps[0] = 0\r\n\tfor i in range(1, n):\r\n\t\tjumps[i] = float('inf')\r\n\t\tfor j in range(i):\r\n\t\t\tif (i <= j + arr[j]) and (jumps[j] != float('inf')):\r\n\t\t\t\tjumps[i] = min(jumps[i], jumps[j] + 1)\r\n\t\t\t\tbreak\r\n\treturn jumps[n-1]" + ], + "split": "train" + }, + { + "Input": "Write a function to multiply consecutive numbers of a given list.", + "Output Program": [ + "def mul_consecutive_nums(nums):\r\n result = [b*a for a, b in zip(nums[:-1], nums[1:])]\r\n return result" + ], + "Output Answer": [ + "def mul_consecutive_nums(nums):\r\n result = [b*a for a, b in zip(nums[:-1], nums[1:])]\r\n return result" + ], + "split": "train" + }, + { + "Input": "Write a function to group the 1st elements on the basis of 2nd elements in the given tuple list.", + "Output Program": [ + "from itertools import groupby \r\ndef group_element(test_list):\r\n res = dict()\r\n for key, val in groupby(sorted(test_list, key = lambda ele: ele[1]), key = lambda ele: ele[1]):\r\n res[key] = [ele[0] for ele in val] \r\n return (res)\r\n" + ], + "Output Answer": [ + "from itertools import groupby \r\ndef group_element(test_list):\r\n res = dict()\r\n for key, val in groupby(sorted(test_list, key = lambda ele: ele[1]), key = lambda ele: ele[1]):\r\n res[key] = [ele[0] for ele in val] \r\n return (res)\r\n" + ], + "split": "train" + }, + { + "Input": "Write a python function to find the last two digits in factorial of a given number.", + "Output Program": [ + "def last_Two_Digits(N): \r\n if (N >= 10): \r\n return\r\n fac = 1\r\n for i in range(1,N + 1): \r\n fac = (fac * i) % 100\r\n return (fac) " + ], + "Output Answer": [ + "def last_Two_Digits(N): \r\n if (N >= 10): \r\n return\r\n fac = 1\r\n for i in range(1,N + 1): \r\n fac = (fac * i) % 100\r\n return (fac) " + ], + "split": "train" + }, + { + "Input": "Write a function to remove multiple spaces in a string by using regex.", + "Output Program": [ + "import re\r\ndef remove_multiple_spaces(text1):\r\n return (re.sub(' +',' ',text1))" + ], + "Output Answer": [ + "import re\r\ndef remove_multiple_spaces(text1):\r\n return (re.sub(' +',' ',text1))" + ], + "split": "train" + }, + { + "Input": "Write a function to extract unique values from the given dictionary values.", + "Output Program": [ + "def extract_unique(test_dict):\r\n res = list(sorted({ele for val in test_dict.values() for ele in val}))\r\n return res" + ], + "Output Answer": [ + "def extract_unique(test_dict):\r\n res = list(sorted({ele for val in test_dict.values() for ele in val}))\r\n return res" + ], + "split": "train" + }, + { + "Input": "Write a function to check if each element of the second tuple is greater than its corresponding index in the first tuple.", + "Output Program": [ + "def check_greater(test_tup1, test_tup2):\r\n res = all(x < y for x, y in zip(test_tup1, test_tup2))\r\n return (res) " + ], + "Output Answer": [ + "def check_greater(test_tup1, test_tup2):\r\n res = all(x < y for x, y in zip(test_tup1, test_tup2))\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a function to zip two given lists of lists.", + "Output Program": [ + "def zip_list(list1,list2): \r\n result = list(map(list.__add__, list1, list2)) \r\n return result" + ], + "Output Answer": [ + "def zip_list(list1,list2): \r\n result = list(map(list.__add__, list1, list2)) \r\n return result" + ], + "split": "train" + }, + { + "Input": "Write a function to find number of even elements in the given list using lambda function.", + "Output Program": [ + "def count_even(array_nums):\r\n count_even = len(list(filter(lambda x: (x%2 == 0) , array_nums)))\r\n return count_even" + ], + "Output Answer": [ + "def count_even(array_nums):\r\n count_even = len(list(filter(lambda x: (x%2 == 0) , array_nums)))\r\n return count_even" + ], + "split": "train" + }, + { + "Input": "Write a function to sort dictionary items by tuple product of keys for the given dictionary with tuple keys.", + "Output Program": [ + "def sort_dict_item(test_dict):\r\n res = {key: test_dict[key] for key in sorted(test_dict.keys(), key = lambda ele: ele[1] * ele[0])}\r\n return (res) \r\n" + ], + "Output Answer": [ + "def sort_dict_item(test_dict):\r\n res = {key: test_dict[key] for key in sorted(test_dict.keys(), key = lambda ele: ele[1] * ele[0])}\r\n return (res) \r\n" + ], + "split": "train" + }, + { + "Input": "Write a python function to find the minimum number of swaps required to convert one binary string to another.", + "Output Program": [ + "def min_Swaps(str1,str2) : \r\n count = 0\r\n for i in range(len(str1)) : \r\n if str1[i] != str2[i] : \r\n count += 1\r\n if count % 2 == 0 : \r\n return (count // 2) \r\n else : \r\n return (\"Not Possible\") " + ], + "Output Answer": [ + "def min_Swaps(str1,str2) : \r\n count = 0\r\n for i in range(len(str1)) : \r\n if str1[i] != str2[i] : \r\n count += 1\r\n if count % 2 == 0 : \r\n return (count // 2) \r\n else : \r\n return (\"Not Possible\") " + ], + "split": "train" + }, + { + "Input": "Write a function to count the number of elements in a list which are within a specific range.", + "Output Program": [ + "def count_range_in_list(li, min, max):\r\n\tctr = 0\r\n\tfor x in li:\r\n\t\tif min <= x <= max:\r\n\t\t\tctr += 1\r\n\treturn ctr" + ], + "Output Answer": [ + "def count_range_in_list(li, min, max):\r\n\tctr = 0\r\n\tfor x in li:\r\n\t\tif min <= x <= max:\r\n\t\t\tctr += 1\r\n\treturn ctr" + ], + "split": "train" + }, + { + "Input": "Write a function to find the equilibrium index of the given array.", + "Output Program": [ + "def equilibrium_index(arr):\r\n total_sum = sum(arr)\r\n left_sum=0\r\n for i, num in enumerate(arr):\r\n total_sum -= num\r\n if left_sum == total_sum:\r\n return i\r\n left_sum += num\r\n return -1" + ], + "Output Answer": [ + "def equilibrium_index(arr):\r\n total_sum = sum(arr)\r\n left_sum=0\r\n for i, num in enumerate(arr):\r\n total_sum -= num\r\n if left_sum == total_sum:\r\n return i\r\n left_sum += num\r\n return -1" + ], + "split": "train" + }, + { + "Input": "Write a function to find the minimum number of elements that should be removed such that amax-amin<=k.", + "Output Program": [ + "def find_ind(key, i, n, \r\n\t\t\tk, arr):\r\n\tind = -1\r\n\tstart = i + 1\r\n\tend = n - 1;\r\n\twhile (start < end):\r\n\t\tmid = int(start +\r\n\t\t\t\t(end - start) / 2)\r\n\t\tif (arr[mid] - key <= k):\r\n\t\t\tind = mid\r\n\t\t\tstart = mid + 1\r\n\t\telse:\r\n\t\t\tend = mid\r\n\treturn ind\r\ndef removals(arr, n, k):\r\n\tans = n - 1\r\n\tarr.sort()\r\n\tfor i in range(0, n):\r\n\t\tj = find_ind(arr[i], i, \r\n\t\t\t\t\tn, k, arr)\r\n\t\tif (j != -1):\r\n\t\t\tans = min(ans, n -\r\n\t\t\t\t\t\t(j - i + 1))\r\n\treturn ans" + ], + "Output Answer": [ + "def find_ind(key, i, n, \r\n\t\t\tk, arr):\r\n\tind = -1\r\n\tstart = i + 1\r\n\tend = n - 1;\r\n\twhile (start < end):\r\n\t\tmid = int(start +\r\n\t\t\t\t(end - start) / 2)\r\n\t\tif (arr[mid] - key <= k):\r\n\t\t\tind = mid\r\n\t\t\tstart = mid + 1\r\n\t\telse:\r\n\t\t\tend = mid\r\n\treturn ind\r\ndef removals(arr, n, k):\r\n\tans = n - 1\r\n\tarr.sort()\r\n\tfor i in range(0, n):\r\n\t\tj = find_ind(arr[i], i, \r\n\t\t\t\t\tn, k, arr)\r\n\t\tif (j != -1):\r\n\t\t\tans = min(ans, n -\r\n\t\t\t\t\t\t(j - i + 1))\r\n\treturn ans" + ], + "split": "train" + }, + { + "Input": "Write a function to check whether the given key is present in the dictionary or not.", + "Output Program": [ + "def is_key_present(d,x):\r\n if x in d:\r\n return True\r\n else:\r\n return False" + ], + "Output Answer": [ + "def is_key_present(d,x):\r\n if x in d:\r\n return True\r\n else:\r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a function to sort a list of lists by length and value.", + "Output Program": [ + "def sort_sublists(list1):\r\n list1.sort() \r\n list1.sort(key=len)\r\n return list1" + ], + "Output Answer": [ + "def sort_sublists(list1):\r\n list1.sort() \r\n list1.sort(key=len)\r\n return list1" + ], + "split": "train" + }, + { + "Input": "Write a function to find whether an array is subset of another array.", + "Output Program": [ + "def is_subset(arr1, m, arr2, n): \r\n\thashset = set() \r\n\tfor i in range(0, m): \r\n\t\thashset.add(arr1[i]) \r\n\tfor i in range(0, n): \r\n\t\tif arr2[i] in hashset: \r\n\t\t\tcontinue\r\n\t\telse: \r\n\t\t\treturn False\r\n\treturn True\t\t" + ], + "Output Answer": [ + "def is_subset(arr1, m, arr2, n): \r\n\thashset = set() \r\n\tfor i in range(0, m): \r\n\t\thashset.add(arr1[i]) \r\n\tfor i in range(0, n): \r\n\t\tif arr2[i] in hashset: \r\n\t\t\tcontinue\r\n\t\telse: \r\n\t\t\treturn False\r\n\treturn True\t\t" + ], + "split": "train" + }, + { + "Input": "Write a python function to count the total set bits from 1 to n.", + "Output Program": [ + "def count_Set_Bits(n) : \r\n n += 1; \r\n powerOf2 = 2; \r\n cnt = n // 2; \r\n while (powerOf2 <= n) : \r\n totalPairs = n // powerOf2; \r\n cnt += (totalPairs // 2) * powerOf2; \r\n if (totalPairs & 1) : \r\n cnt += (n % powerOf2) \r\n else : \r\n cnt += 0\r\n powerOf2 <<= 1; \r\n return cnt; " + ], + "Output Answer": [ + "def count_Set_Bits(n) : \r\n n += 1; \r\n powerOf2 = 2; \r\n cnt = n // 2; \r\n while (powerOf2 <= n) : \r\n totalPairs = n // powerOf2; \r\n cnt += (totalPairs // 2) * powerOf2; \r\n if (totalPairs & 1) : \r\n cnt += (n % powerOf2) \r\n else : \r\n cnt += 0\r\n powerOf2 <<= 1; \r\n return cnt; " + ], + "split": "train" + }, + { + "Input": "Write a python function to convert a string to a list.", + "Output Program": [ + "def Convert(string): \r\n li = list(string.split(\" \")) \r\n return li " + ], + "Output Answer": [ + "def Convert(string): \r\n li = list(string.split(\" \")) \r\n return li " + ], + "split": "train" + }, + { + "Input": "Write a function to count unique keys for each value present in the tuple.", + "Output Program": [ + "from collections import defaultdict \r\ndef get_unique(test_list):\r\n res = defaultdict(list)\r\n for sub in test_list:\r\n res[sub[1]].append(sub[0])\r\n res = dict(res)\r\n res_dict = dict()\r\n for key in res:\r\n res_dict[key] = len(list(set(res[key])))\r\n return (str(res_dict)) " + ], + "Output Answer": [ + "from collections import defaultdict \r\ndef get_unique(test_list):\r\n res = defaultdict(list)\r\n for sub in test_list:\r\n res[sub[1]].append(sub[0])\r\n res = dict(res)\r\n res_dict = dict()\r\n for key in res:\r\n res_dict[key] = len(list(set(res[key])))\r\n return (str(res_dict)) " + ], + "split": "train" + }, + { + "Input": "Write a function to access the initial and last data of the given tuple record.", + "Output Program": [ + "def front_and_rear(test_tup):\r\n res = (test_tup[0], test_tup[-1])\r\n return (res) " + ], + "Output Answer": [ + "def front_and_rear(test_tup):\r\n res = (test_tup[0], test_tup[-1])\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a python function to check whether the product of digits of a number at even and odd places is equal or not.", + "Output Program": [ + "def product_Equal(n): \r\n if n < 10: \r\n return False\r\n prodOdd = 1; prodEven = 1\r\n while n > 0: \r\n digit = n % 10\r\n prodOdd *= digit \r\n n = n//10\r\n if n == 0: \r\n break; \r\n digit = n % 10\r\n prodEven *= digit \r\n n = n//10\r\n if prodOdd == prodEven: \r\n return True\r\n return False" + ], + "Output Answer": [ + "def product_Equal(n): \r\n if n < 10: \r\n return False\r\n prodOdd = 1; prodEven = 1\r\n while n > 0: \r\n digit = n % 10\r\n prodOdd *= digit \r\n n = n//10\r\n if n == 0: \r\n break; \r\n digit = n % 10\r\n prodEven *= digit \r\n n = n//10\r\n if prodOdd == prodEven: \r\n return True\r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a function to remove duplicates from a list of lists.", + "Output Program": [ + "import itertools\r\ndef remove_duplicate(list1):\r\n list.sort(list1)\r\n remove_duplicate = list(list1 for list1,_ in itertools.groupby(list1))\r\n return remove_duplicate" + ], + "Output Answer": [ + "import itertools\r\ndef remove_duplicate(list1):\r\n list.sort(list1)\r\n remove_duplicate = list(list1 for list1,_ in itertools.groupby(list1))\r\n return remove_duplicate" + ], + "split": "train" + }, + { + "Input": "Write a function to check if the given tuple contains all valid values or not.", + "Output Program": [ + "def check_valid(test_tup):\r\n res = not any(map(lambda ele: not ele, test_tup))\r\n return (res) " + ], + "Output Answer": [ + "def check_valid(test_tup):\r\n res = not any(map(lambda ele: not ele, test_tup))\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a python function to count the number of distinct power of prime factor of given number.", + "Output Program": [ + "def count_Fac(n): \r\n m = n \r\n count = 0\r\n i = 2\r\n while((i * i) <= m): \r\n total = 0\r\n while (n % i == 0): \r\n n /= i \r\n total += 1 \r\n temp = 0\r\n j = 1\r\n while((temp + j) <= total): \r\n temp += j \r\n count += 1\r\n j += 1 \r\n i += 1\r\n if (n != 1): \r\n count += 1 \r\n return count " + ], + "Output Answer": [ + "def count_Fac(n): \r\n m = n \r\n count = 0\r\n i = 2\r\n while((i * i) <= m): \r\n total = 0\r\n while (n % i == 0): \r\n n /= i \r\n total += 1 \r\n temp = 0\r\n j = 1\r\n while((temp + j) <= total): \r\n temp += j \r\n count += 1\r\n j += 1 \r\n i += 1\r\n if (n != 1): \r\n count += 1 \r\n return count " + ], + "split": "train" + }, + { + "Input": "Write a function to convert the given string of integers into a tuple.", + "Output Program": [ + "def str_to_tuple(test_str):\r\n res = tuple(map(int, test_str.split(', ')))\r\n return (res) " + ], + "Output Answer": [ + "def str_to_tuple(test_str):\r\n res = tuple(map(int, test_str.split(', ')))\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a function to find the perimeter of a rombus.", + "Output Program": [ + "def rombus_perimeter(a):\r\n perimeter=4*a\r\n return perimeter" + ], + "Output Answer": [ + "def rombus_perimeter(a):\r\n perimeter=4*a\r\n return perimeter" + ], + "split": "train" + }, + { + "Input": "Write a function to calculate the standard deviation.", + "Output Program": [ + "import math\r\nimport sys\r\ndef sd_calc(data):\r\n n = len(data)\r\n if n <= 1:\r\n return 0.0\r\n mean, sd = avg_calc(data), 0.0\r\n for el in data:\r\n sd += (float(el) - mean)**2\r\n sd = math.sqrt(sd / float(n-1))\r\n return sd\r\ndef avg_calc(ls):\r\n n, mean = len(ls), 0.0\r\n if n <= 1:\r\n return ls[0]\r\n for el in ls:\r\n mean = mean + float(el)\r\n mean = mean / float(n)\r\n return mean" + ], + "Output Answer": [ + "import math\r\nimport sys\r\ndef sd_calc(data):\r\n n = len(data)\r\n if n <= 1:\r\n return 0.0\r\n mean, sd = avg_calc(data), 0.0\r\n for el in data:\r\n sd += (float(el) - mean)**2\r\n sd = math.sqrt(sd / float(n-1))\r\n return sd\r\ndef avg_calc(ls):\r\n n, mean = len(ls), 0.0\r\n if n <= 1:\r\n return ls[0]\r\n for el in ls:\r\n mean = mean + float(el)\r\n mean = mean / float(n)\r\n return mean" + ], + "split": "train" + }, + { + "Input": "Write a function to create a list taking alternate elements from another given list.", + "Output Program": [ + "def alternate_elements(list1):\r\n result=[]\r\n for item in list1[::2]:\r\n result.append(item)\r\n return result " + ], + "Output Answer": [ + "def alternate_elements(list1):\r\n result=[]\r\n for item in list1[::2]:\r\n result.append(item)\r\n return result " + ], + "split": "train" + }, + { + "Input": "Write a function that matches a string that has an a followed by zero or more b's.", + "Output Program": [ + "import re\r\ndef text_match(text):\r\n patterns = 'ab*?'\r\n if re.search(patterns, text):\r\n return 'Found a match!'\r\n else:\r\n return('Not matched!')" + ], + "Output Answer": [ + "import re\r\ndef text_match(text):\r\n patterns = 'ab*?'\r\n if re.search(patterns, text):\r\n return 'Found a match!'\r\n else:\r\n return('Not matched!')" + ], + "split": "train" + }, + { + "Input": "Write a function to add a dictionary to the tuple.", + "Output Program": [ + "def add_dict_to_tuple(test_tup, test_dict):\r\n test_tup = list(test_tup)\r\n test_tup.append(test_dict)\r\n test_tup = tuple(test_tup)\r\n return (test_tup) " + ], + "Output Answer": [ + "def add_dict_to_tuple(test_tup, test_dict):\r\n test_tup = list(test_tup)\r\n test_tup.append(test_dict)\r\n test_tup = tuple(test_tup)\r\n return (test_tup) " + ], + "split": "train" + }, + { + "Input": "Write a function to find a path with the maximum average over all existing paths for the given square matrix of size n*n.", + "Output Program": [ + "M = 100\r\ndef maxAverageOfPath(cost, N): \r\n\tdp = [[0 for i in range(N + 1)] for j in range(N + 1)] \r\n\tdp[0][0] = cost[0][0] \r\n\tfor i in range(1, N): \r\n\t\tdp[i][0] = dp[i - 1][0] + cost[i][0] \r\n\tfor j in range(1, N): \r\n\t\tdp[0][j] = dp[0][j - 1] + cost[0][j] \r\n\tfor i in range(1, N): \r\n\t\tfor j in range(1, N): \r\n\t\t\tdp[i][j] = max(dp[i - 1][j], \r\n\t\t\t\t\t\tdp[i][j - 1]) + cost[i][j] \r\n\treturn dp[N - 1][N - 1] / (2 * N - 1)" + ], + "Output Answer": [ + "M = 100\r\ndef maxAverageOfPath(cost, N): \r\n\tdp = [[0 for i in range(N + 1)] for j in range(N + 1)] \r\n\tdp[0][0] = cost[0][0] \r\n\tfor i in range(1, N): \r\n\t\tdp[i][0] = dp[i - 1][0] + cost[i][0] \r\n\tfor j in range(1, N): \r\n\t\tdp[0][j] = dp[0][j - 1] + cost[0][j] \r\n\tfor i in range(1, N): \r\n\t\tfor j in range(1, N): \r\n\t\t\tdp[i][j] = max(dp[i - 1][j], \r\n\t\t\t\t\t\tdp[i][j - 1]) + cost[i][j] \r\n\treturn dp[N - 1][N - 1] / (2 * N - 1)" + ], + "split": "train" + }, + { + "Input": "Write a function to filter the height and width of students which are stored in a dictionary.", + "Output Program": [ + "def filter_data(students,h,w):\r\n result = {k: s for k, s in students.items() if s[0] >=h and s[1] >=w}\r\n return result " + ], + "Output Answer": [ + "def filter_data(students,h,w):\r\n result = {k: s for k, s in students.items() if s[0] >=h and s[1] >=w}\r\n return result " + ], + "split": "train" + }, + { + "Input": "Write a function to count the same pair in two given lists using map function.", + "Output Program": [ + "from operator import eq\r\ndef count_same_pair(nums1, nums2):\r\n result = sum(map(eq, nums1, nums2))\r\n return result" + ], + "Output Answer": [ + "from operator import eq\r\ndef count_same_pair(nums1, nums2):\r\n result = sum(map(eq, nums1, nums2))\r\n return result" + ], + "split": "train" + }, + { + "Input": "Write a function to calculate the sum of all digits of the base to the specified power.", + "Output Program": [ + "def power_base_sum(base, power):\r\n return sum([int(i) for i in str(pow(base, power))])" + ], + "Output Answer": [ + "def power_base_sum(base, power):\r\n return sum([int(i) for i in str(pow(base, power))])" + ], + "split": "train" + }, + { + "Input": "Write a function to extract values between quotation marks of the given string by using regex.", + "Output Program": [ + "import re\r\ndef extract_quotation(text1):\r\n return (re.findall(r'\"(.*?)\"', text1))" + ], + "Output Answer": [ + "import re\r\ndef extract_quotation(text1):\r\n return (re.findall(r'\"(.*?)\"', text1))" + ], + "split": "train" + }, + { + "Input": "Write a function to multiply the adjacent elements of the given tuple.", + "Output Program": [ + "def multiply_elements(test_tup):\r\n res = tuple(i * j for i, j in zip(test_tup, test_tup[1:]))\r\n return (res) " + ], + "Output Answer": [ + "def multiply_elements(test_tup):\r\n res = tuple(i * j for i, j in zip(test_tup, test_tup[1:]))\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a function to remove all characters except letters and numbers using regex", + "Output Program": [ + "import re \r\ndef remove_char(S):\r\n result = re.sub('[\\W_]+', '', S) \r\n return result" + ], + "Output Answer": [ + "import re \r\ndef remove_char(S):\r\n result = re.sub('[\\W_]+', '', S) \r\n return result" + ], + "split": "train" + }, + { + "Input": "Write a function to sum elements in two lists.", + "Output Program": [ + "def sum_list(lst1,lst2):\r\n res_list = [lst1[i] + lst2[i] for i in range(len(lst1))] \r\n return res_list" + ], + "Output Answer": [ + "def sum_list(lst1,lst2):\r\n res_list = [lst1[i] + lst2[i] for i in range(len(lst1))] \r\n return res_list" + ], + "split": "train" + }, + { + "Input": "Write a function to add two lists using map and lambda function.", + "Output Program": [ + "def add_list(nums1,nums2):\r\n result = map(lambda x, y: x + y, nums1, nums2)\r\n return list(result)" + ], + "Output Answer": [ + "def add_list(nums1,nums2):\r\n result = map(lambda x, y: x + y, nums1, nums2)\r\n return list(result)" + ], + "split": "train" + }, + { + "Input": "Write a function to remove consecutive duplicates of a given list.", + "Output Program": [ + "from itertools import groupby\r\ndef consecutive_duplicates(nums):\r\n return [key for key, group in groupby(nums)] " + ], + "Output Answer": [ + "from itertools import groupby\r\ndef consecutive_duplicates(nums):\r\n return [key for key, group in groupby(nums)] " + ], + "split": "train" + }, + { + "Input": "Write a function to find the lateral surface area of a cone.", + "Output Program": [ + "import math\r\ndef lateralsurface_cone(r,h):\r\n l = math.sqrt(r * r + h * h)\r\n LSA = math.pi * r * l\r\n return LSA" + ], + "Output Answer": [ + "import math\r\ndef lateralsurface_cone(r,h):\r\n l = math.sqrt(r * r + h * h)\r\n LSA = math.pi * r * l\r\n return LSA" + ], + "split": "train" + }, + { + "Input": "Write a function to replace all occurrences of spaces, commas, or dots with a colon.", + "Output Program": [ + "import re\r\ndef replace_specialchar(text):\r\n return (re.sub(\"[ ,.]\", \":\", text))\r" + ], + "Output Answer": [ + "import re\r\ndef replace_specialchar(text):\r\n return (re.sub(\"[ ,.]\", \":\", text))\r" + ], + "split": "train" + }, + { + "Input": "Write a function to find the index of the first occurrence of a given number in a sorted array.", + "Output Program": [ + "def find_first_occurrence(A, x):\r\n (left, right) = (0, len(A) - 1)\r\n result = -1\r\n while left <= right:\r\n mid = (left + right) // 2\r\n if x == A[mid]:\r\n result = mid\r\n right = mid - 1\r\n elif x < A[mid]:\r\n right = mid - 1\r\n else:\r\n left = mid + 1\r\n return result" + ], + "Output Answer": [ + "def find_first_occurrence(A, x):\r\n (left, right) = (0, len(A) - 1)\r\n result = -1\r\n while left <= right:\r\n mid = (left + right) // 2\r\n if x == A[mid]:\r\n result = mid\r\n right = mid - 1\r\n elif x < A[mid]:\r\n right = mid - 1\r\n else:\r\n left = mid + 1\r\n return result" + ], + "split": "train" + }, + { + "Input": "Write a python function to find sum of products of all possible subarrays.", + "Output Program": [ + "def sum_Of_Subarray_Prod(arr,n):\r\n ans = 0\r\n res = 0\r\n i = n - 1\r\n while (i >= 0):\r\n incr = arr[i]*(1 + res)\r\n ans += incr\r\n res = incr\r\n i -= 1\r\n return (ans)" + ], + "Output Answer": [ + "def sum_Of_Subarray_Prod(arr,n):\r\n ans = 0\r\n res = 0\r\n i = n - 1\r\n while (i >= 0):\r\n incr = arr[i]*(1 + res)\r\n ans += incr\r\n res = incr\r\n i -= 1\r\n return (ans)" + ], + "split": "train" + }, + { + "Input": "Write a python function to toggle bits of the number except the first and the last bit.", + "Output Program": [ + "def set_middle_bits(n): \r\n n |= n >> 1; \r\n n |= n >> 2; \r\n n |= n >> 4; \r\n n |= n >> 8; \r\n n |= n >> 16; \r\n return (n >> 1) ^ 1\r\ndef toggle_middle_bits(n): \r\n if (n == 1): \r\n return 1\r\n return n ^ set_middle_bits(n) " + ], + "Output Answer": [ + "def set_middle_bits(n): \r\n n |= n >> 1; \r\n n |= n >> 2; \r\n n |= n >> 4; \r\n n |= n >> 8; \r\n n |= n >> 16; \r\n return (n >> 1) ^ 1\r\ndef toggle_middle_bits(n): \r\n if (n == 1): \r\n return 1\r\n return n ^ set_middle_bits(n) " + ], + "split": "train" + }, + { + "Input": "Write a function to locate the left insertion point for a specified value in sorted order.", + "Output Program": [ + "import bisect\r\ndef left_insertion(a, x):\r\n i = bisect.bisect_left(a, x)\r\n return i" + ], + "Output Answer": [ + "import bisect\r\ndef left_insertion(a, x):\r\n i = bisect.bisect_left(a, x)\r\n return i" + ], + "split": "train" + }, + { + "Input": "Write a function to check whether the given string is starting with a vowel or not using regex.", + "Output Program": [ + "import re \r\nregex = '^[aeiouAEIOU][A-Za-z0-9_]*'\r\ndef check_str(string): \r\n\tif(re.search(regex, string)): \r\n\t\treturn (\"Valid\") \r\n\telse: \r\n\t\treturn (\"Invalid\") " + ], + "Output Answer": [ + "import re \r\nregex = '^[aeiouAEIOU][A-Za-z0-9_]*'\r\ndef check_str(string): \r\n\tif(re.search(regex, string)): \r\n\t\treturn (\"Valid\") \r\n\telse: \r\n\t\treturn (\"Invalid\") " + ], + "split": "train" + }, + { + "Input": "Write a function to calculate the geometric sum of n-1.", + "Output Program": [ + "def geometric_sum(n):\r\n if n < 0:\r\n return 0\r\n else:\r\n return 1 / (pow(2, n)) + geometric_sum(n - 1)" + ], + "Output Answer": [ + "def geometric_sum(n):\r\n if n < 0:\r\n return 0\r\n else:\r\n return 1 / (pow(2, n)) + geometric_sum(n - 1)" + ], + "split": "train" + }, + { + "Input": "Write a python function to find the index of smallest triangular number with n digits.", + "Output Program": [ + "import math \r\ndef find_Index(n): \r\n x = math.sqrt(2 * math.pow(10,(n - 1))); \r\n return round(x); " + ], + "Output Answer": [ + "import math \r\ndef find_Index(n): \r\n x = math.sqrt(2 * math.pow(10,(n - 1))); \r\n return round(x); " + ], + "split": "train" + }, + { + "Input": "Write a function to convert the given tuple to a key-value dictionary using adjacent elements.", + "Output Program": [ + "def tuple_to_dict(test_tup):\r\n res = dict(test_tup[idx : idx + 2] for idx in range(0, len(test_tup), 2))\r\n return (res) " + ], + "Output Answer": [ + "def tuple_to_dict(test_tup):\r\n res = dict(test_tup[idx : idx + 2] for idx in range(0, len(test_tup), 2))\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a python function to check whether all the characters are same or not.", + "Output Program": [ + "def all_Characters_Same(s) :\r\n n = len(s)\r\n for i in range(1,n) :\r\n if s[i] != s[0] :\r\n return False\r\n return True" + ], + "Output Answer": [ + "def all_Characters_Same(s) :\r\n n = len(s)\r\n for i in range(1,n) :\r\n if s[i] != s[0] :\r\n return False\r\n return True" + ], + "split": "train" + }, + { + "Input": "Write a function to caluclate the area of a tetrahedron.", + "Output Program": [ + "import math\r\ndef area_tetrahedron(side):\r\n area = math.sqrt(3)*(side*side)\r\n return area" + ], + "Output Answer": [ + "import math\r\ndef area_tetrahedron(side):\r\n area = math.sqrt(3)*(side*side)\r\n return area" + ], + "split": "train" + }, + { + "Input": "Write a function to rotate a given list by specified number of items to the right direction.", + "Output Program": [ + "def rotate_right(list1,m,n):\r\n result = list1[-(m):]+list1[:-(n)]\r\n return result" + ], + "Output Answer": [ + "def rotate_right(list1,m,n):\r\n result = list1[-(m):]+list1[:-(n)]\r\n return result" + ], + "split": "train" + }, + { + "Input": "Write a function to check if the given tuple has any none value or not.", + "Output Program": [ + "def check_none(test_tup):\r\n res = any(map(lambda ele: ele is None, test_tup))\r\n return (res) " + ], + "Output Answer": [ + "def check_none(test_tup):\r\n res = any(map(lambda ele: ele is None, test_tup))\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a function to find numbers within a given range where every number is divisible by every digit it contains.", + "Output Program": [ + "def divisible_by_digits(startnum, endnum):\r\n return [n for n in range(startnum, endnum+1) \\\r\n if not any(map(lambda x: int(x) == 0 or n%int(x) != 0, str(n)))]" + ], + "Output Answer": [ + "def divisible_by_digits(startnum, endnum):\r\n return [n for n in range(startnum, endnum+1) \\\r\n if not any(map(lambda x: int(x) == 0 or n%int(x) != 0, str(n)))]" + ], + "split": "train" + }, + { + "Input": "Write a function to find area of a sector.", + "Output Program": [ + "def sector_area(r,a):\r\n pi=22/7\r\n if a >= 360:\r\n return None\r\n sectorarea = (pi*r**2) * (a/360)\r\n return sectorarea" + ], + "Output Answer": [ + "def sector_area(r,a):\r\n pi=22/7\r\n if a >= 360:\r\n return None\r\n sectorarea = (pi*r**2) * (a/360)\r\n return sectorarea" + ], + "split": "train" + }, + { + "Input": "Write a function to find the longest common subsequence for the given three string sequence.", + "Output Program": [ + "def lcs_of_three(X, Y, Z, m, n, o): \r\n\tL = [[[0 for i in range(o+1)] for j in range(n+1)] \r\n\t\tfor k in range(m+1)] \r\n\tfor i in range(m+1): \r\n\t\tfor j in range(n+1): \r\n\t\t\tfor k in range(o+1): \r\n\t\t\t\tif (i == 0 or j == 0 or k == 0): \r\n\t\t\t\t\tL[i][j][k] = 0\r\n\t\t\t\telif (X[i-1] == Y[j-1] and\r\n\t\t\t\t\tX[i-1] == Z[k-1]): \r\n\t\t\t\t\tL[i][j][k] = L[i-1][j-1][k-1] + 1\r\n\t\t\t\telse: \r\n\t\t\t\t\tL[i][j][k] = max(max(L[i-1][j][k], \r\n\t\t\t\t\tL[i][j-1][k]), \r\n\t\t\t\t\t\t\t\t\tL[i][j][k-1]) \r\n\treturn L[m][n][o]" + ], + "Output Answer": [ + "def lcs_of_three(X, Y, Z, m, n, o): \r\n\tL = [[[0 for i in range(o+1)] for j in range(n+1)] \r\n\t\tfor k in range(m+1)] \r\n\tfor i in range(m+1): \r\n\t\tfor j in range(n+1): \r\n\t\t\tfor k in range(o+1): \r\n\t\t\t\tif (i == 0 or j == 0 or k == 0): \r\n\t\t\t\t\tL[i][j][k] = 0\r\n\t\t\t\telif (X[i-1] == Y[j-1] and\r\n\t\t\t\t\tX[i-1] == Z[k-1]): \r\n\t\t\t\t\tL[i][j][k] = L[i-1][j-1][k-1] + 1\r\n\t\t\t\telse: \r\n\t\t\t\t\tL[i][j][k] = max(max(L[i-1][j][k], \r\n\t\t\t\t\tL[i][j-1][k]), \r\n\t\t\t\t\t\t\t\t\tL[i][j][k-1]) \r\n\treturn L[m][n][o]" + ], + "split": "train" + }, + { + "Input": "Write a function to put spaces between words starting with capital letters in a given string by using regex.", + "Output Program": [ + "import re\r\ndef capital_words_spaces(str1):\r\n return re.sub(r\"(\\w)([A-Z])\", r\"\\1 \\2\", str1)" + ], + "Output Answer": [ + "import re\r\ndef capital_words_spaces(str1):\r\n return re.sub(r\"(\\w)([A-Z])\", r\"\\1 \\2\", str1)" + ], + "split": "train" + }, + { + "Input": "Write a function to sort a given list of strings of numbers numerically.", + "Output Program": [ + "def sort_numeric_strings(nums_str):\r\n result = [int(x) for x in nums_str]\r\n result.sort()\r\n return result" + ], + "Output Answer": [ + "def sort_numeric_strings(nums_str):\r\n result = [int(x) for x in nums_str]\r\n result.sort()\r\n return result" + ], + "split": "train" + }, + { + "Input": "Write a function to add the given tuple to the given list.", + "Output Program": [ + "def add_tuple(test_list, test_tup):\r\n test_list += test_tup\r\n return (test_list) " + ], + "Output Answer": [ + "def add_tuple(test_list, test_tup):\r\n test_list += test_tup\r\n return (test_list) " + ], + "split": "train" + }, + { + "Input": "Write a function to check if the given array represents min heap or not.", + "Output Program": [ + "def check_min_heap(arr, i):\r\n if 2 * i + 2 > len(arr):\r\n return True\r\n left_child = (arr[i] <= arr[2 * i + 1]) and check_min_heap(arr, 2 * i + 1)\r\n right_child = (2 * i + 2 == len(arr)) or (arr[i] <= arr[2 * i + 2] \r\n and check_min_heap(arr, 2 * i + 2))\r\n return left_child and right_child" + ], + "Output Answer": [ + "def check_min_heap(arr, i):\r\n if 2 * i + 2 > len(arr):\r\n return True\r\n left_child = (arr[i] <= arr[2 * i + 1]) and check_min_heap(arr, 2 * i + 1)\r\n right_child = (2 * i + 2 == len(arr)) or (arr[i] <= arr[2 * i + 2] \r\n and check_min_heap(arr, 2 * i + 2))\r\n return left_child and right_child" + ], + "split": "train" + }, + { + "Input": "Write a function to find the nth jacobsthal number.", + "Output Program": [ + "def jacobsthal_num(n): \r\n\tdp = [0] * (n + 1) \r\n\tdp[0] = 0\r\n\tdp[1] = 1\r\n\tfor i in range(2, n+1): \r\n\t\tdp[i] = dp[i - 1] + 2 * dp[i - 2] \r\n\treturn dp[n]" + ], + "Output Answer": [ + "def jacobsthal_num(n): \r\n\tdp = [0] * (n + 1) \r\n\tdp[0] = 0\r\n\tdp[1] = 1\r\n\tfor i in range(2, n+1): \r\n\t\tdp[i] = dp[i - 1] + 2 * dp[i - 2] \r\n\treturn dp[n]" + ], + "split": "train" + }, + { + "Input": "Write a function to find minimum k records from tuple list.", + "Output Program": [ + "def min_k(test_list, K):\r\n res = sorted(test_list, key = lambda x: x[1])[:K]\r\n return (res) " + ], + "Output Answer": [ + "def min_k(test_list, K):\r\n res = sorted(test_list, key = lambda x: x[1])[:K]\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a function to find common index elements from three lists.", + "Output Program": [ + "def extract_index_list(l1, l2, l3):\r\n result = []\r\n for m, n, o in zip(l1, l2, l3):\r\n if (m == n == o):\r\n result.append(m)\r\n return result" + ], + "Output Answer": [ + "def extract_index_list(l1, l2, l3):\r\n result = []\r\n for m, n, o in zip(l1, l2, l3):\r\n if (m == n == o):\r\n result.append(m)\r\n return result" + ], + "split": "train" + }, + { + "Input": "Write a function to find the second smallest number in a list.", + "Output Program": [ + "def second_smallest(numbers):\r\n if (len(numbers)<2):\r\n return\r\n if ((len(numbers)==2) and (numbers[0] == numbers[1]) ):\r\n return\r\n dup_items = set()\r\n uniq_items = []\r\n for x in numbers:\r\n if x not in dup_items:\r\n uniq_items.append(x)\r\n dup_items.add(x)\r\n uniq_items.sort() \r\n return uniq_items[1] " + ], + "Output Answer": [ + "def second_smallest(numbers):\r\n if (len(numbers)<2):\r\n return\r\n if ((len(numbers)==2) and (numbers[0] == numbers[1]) ):\r\n return\r\n dup_items = set()\r\n uniq_items = []\r\n for x in numbers:\r\n if x not in dup_items:\r\n uniq_items.append(x)\r\n dup_items.add(x)\r\n uniq_items.sort() \r\n return uniq_items[1] " + ], + "split": "train" + }, + { + "Input": "Write a function that matches a string that has an a followed by zero or one 'b'.", + "Output Program": [ + "import re\r\ndef text_match_zero_one(text):\r\n patterns = 'ab?'\r\n if re.search(patterns, text):\r\n return 'Found a match!'\r\n else:\r\n return('Not matched!')" + ], + "Output Answer": [ + "import re\r\ndef text_match_zero_one(text):\r\n patterns = 'ab?'\r\n if re.search(patterns, text):\r\n return 'Found a match!'\r\n else:\r\n return('Not matched!')" + ], + "split": "train" + }, + { + "Input": "Write a function to count the pairs of reverse strings in the given string list.", + "Output Program": [ + "def count_reverse_pairs(test_list):\r\n res = sum([1 for idx in range(0, len(test_list)) for idxn in range(idx, len( \r\n\ttest_list)) if test_list[idxn] == str(''.join(list(reversed(test_list[idx]))))]) \r\n return str(res)" + ], + "Output Answer": [ + "def count_reverse_pairs(test_list):\r\n res = sum([1 for idx in range(0, len(test_list)) for idxn in range(idx, len( \r\n\ttest_list)) if test_list[idxn] == str(''.join(list(reversed(test_list[idx]))))]) \r\n return str(res)" + ], + "split": "train" + }, + { + "Input": "Write a function to count number of unique lists within a list.", + "Output Program": [ + "def unique_sublists(list1):\r\n result ={}\r\n for l in list1: \r\n result.setdefault(tuple(l), list()).append(1) \r\n for a, b in result.items(): \r\n result[a] = sum(b)\r\n return result" + ], + "Output Answer": [ + "def unique_sublists(list1):\r\n result ={}\r\n for l in list1: \r\n result.setdefault(tuple(l), list()).append(1) \r\n for a, b in result.items(): \r\n result[a] = sum(b)\r\n return result" + ], + "split": "train" + }, + { + "Input": "Write a function to check a decimal with a precision of 2.", + "Output Program": [ + "def is_decimal(num):\r\n import re\r\n dnumre = re.compile(r\"\"\"^[0-9]+(\\.[0-9]{1,2})?$\"\"\")\r\n result = dnumre.search(num)\r\n return bool(result)" + ], + "Output Answer": [ + "def is_decimal(num):\r\n import re\r\n dnumre = re.compile(r\"\"\"^[0-9]+(\\.[0-9]{1,2})?$\"\"\")\r\n result = dnumre.search(num)\r\n return bool(result)" + ], + "split": "train" + }, + { + "Input": "Write a python function to check whether an array contains only one distinct element or not.", + "Output Program": [ + "def unique_Element(arr,n):\r\n s = set(arr)\r\n if (len(s) == 1):\r\n return ('YES')\r\n else:\r\n return ('NO')" + ], + "Output Answer": [ + "def unique_Element(arr,n):\r\n s = set(arr)\r\n if (len(s) == 1):\r\n return ('YES')\r\n else:\r\n return ('NO')" + ], + "split": "train" + }, + { + "Input": "Write a function to caluclate arc length of an angle.", + "Output Program": [ + "def arc_length(d,a):\r\n pi=22/7\r\n if a >= 360:\r\n return None\r\n arclength = (pi*d) * (a/360)\r\n return arclength" + ], + "Output Answer": [ + "def arc_length(d,a):\r\n pi=22/7\r\n if a >= 360:\r\n return None\r\n arclength = (pi*d) * (a/360)\r\n return arclength" + ], + "split": "train" + }, + { + "Input": "Write a function to check whether the given month number contains 30 days or not.", + "Output Program": [ + "def check_monthnumber_number(monthnum3):\r\n if(monthnum3==4 or monthnum3==6 or monthnum3==9 or monthnum3==11):\r\n return True\r\n else:\r\n return False" + ], + "Output Answer": [ + "def check_monthnumber_number(monthnum3):\r\n if(monthnum3==4 or monthnum3==6 or monthnum3==9 or monthnum3==11):\r\n return True\r\n else:\r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a python function to find the minimum difference between any two elements in a given array.", + "Output Program": [ + "def find_Min_Diff(arr,n): \r\n arr = sorted(arr) \r\n diff = 10**20 \r\n for i in range(n-1): \r\n if arr[i+1] - arr[i] < diff: \r\n diff = arr[i+1] - arr[i] \r\n return diff " + ], + "Output Answer": [ + "def find_Min_Diff(arr,n): \r\n arr = sorted(arr) \r\n diff = 10**20 \r\n for i in range(n-1): \r\n if arr[i+1] - arr[i] < diff: \r\n diff = arr[i+1] - arr[i] \r\n return diff " + ], + "split": "train" + }, + { + "Input": "Write a python function to count numeric values in a given string.", + "Output Program": [ + "def number_ctr(str):\r\n number_ctr= 0\r\n for i in range(len(str)):\r\n if str[i] >= '0' and str[i] <= '9': number_ctr += 1 \r\n return number_ctr" + ], + "Output Answer": [ + "def number_ctr(str):\r\n number_ctr= 0\r\n for i in range(len(str)):\r\n if str[i] >= '0' and str[i] <= '9': number_ctr += 1 \r\n return number_ctr" + ], + "split": "train" + }, + { + "Input": "Write a function to find nth polite number.", + "Output Program": [ + "import math \r\ndef is_polite(n): \r\n\tn = n + 1\r\n\treturn (int)(n+(math.log((n + math.log(n, 2)), 2))) " + ], + "Output Answer": [ + "import math \r\ndef is_polite(n): \r\n\tn = n + 1\r\n\treturn (int)(n+(math.log((n + math.log(n, 2)), 2))) " + ], + "split": "train" + }, + { + "Input": "Write a function to iterate over all pairs of consecutive items in a given list.", + "Output Program": [ + "def pair_wise(l1):\r\n temp = []\r\n for i in range(len(l1) - 1):\r\n current_element, next_element = l1[i], l1[i + 1]\r\n x = (current_element, next_element)\r\n temp.append(x)\r\n return temp" + ], + "Output Answer": [ + "def pair_wise(l1):\r\n temp = []\r\n for i in range(len(l1) - 1):\r\n current_element, next_element = l1[i], l1[i + 1]\r\n x = (current_element, next_element)\r\n temp.append(x)\r\n return temp" + ], + "split": "train" + }, + { + "Input": "Write a python function to count the number of pairs whose sum is equal to \u2018sum\u2019.", + "Output Program": [ + "def get_Pairs_Count(arr,n,sum):\r\n count = 0 \r\n for i in range(0,n):\r\n for j in range(i + 1,n):\r\n if arr[i] + arr[j] == sum:\r\n count += 1\r\n return count" + ], + "Output Answer": [ + "def get_Pairs_Count(arr,n,sum):\r\n count = 0 \r\n for i in range(0,n):\r\n for j in range(i + 1,n):\r\n if arr[i] + arr[j] == sum:\r\n count += 1\r\n return count" + ], + "split": "train" + }, + { + "Input": "Write a python function to check for odd parity of a given number.", + "Output Program": [ + "def check_Odd_Parity(x): \r\n parity = 0\r\n while (x != 0): \r\n x = x & (x - 1) \r\n parity += 1\r\n if (parity % 2 == 1): \r\n return True\r\n else: \r\n return False" + ], + "Output Answer": [ + "def check_Odd_Parity(x): \r\n parity = 0\r\n while (x != 0): \r\n x = x & (x - 1) \r\n parity += 1\r\n if (parity % 2 == 1): \r\n return True\r\n else: \r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a python function to get the difference between two lists.", + "Output Program": [ + "def Diff(li1,li2):\r\n return (list(list(set(li1)-set(li2)) + list(set(li2)-set(li1))))\r\n " + ], + "Output Answer": [ + "def Diff(li1,li2):\r\n return (list(list(set(li1)-set(li2)) + list(set(li2)-set(li1))))\r\n " + ], + "split": "train" + }, + { + "Input": "Write a python function to find the sum of fourth power of first n odd natural numbers.", + "Output Program": [ + "def odd_Num_Sum(n) : \r\n j = 0\r\n sm = 0\r\n for i in range(1,n + 1) : \r\n j = (2*i-1) \r\n sm = sm + (j*j*j*j) \r\n return sm " + ], + "Output Answer": [ + "def odd_Num_Sum(n) : \r\n j = 0\r\n sm = 0\r\n for i in range(1,n + 1) : \r\n j = (2*i-1) \r\n sm = sm + (j*j*j*j) \r\n return sm " + ], + "split": "train" + }, + { + "Input": "Write a function to check if the given expression is balanced or not.", + "Output Program": [ + "from collections import deque\r\ndef check_expression(exp):\r\n if len(exp) & 1:\r\n return False\r\n stack = deque()\r\n for ch in exp:\r\n if ch == '(' or ch == '{' or ch == '[':\r\n stack.append(ch)\r\n if ch == ')' or ch == '}' or ch == ']':\r\n if not stack:\r\n return False\r\n top = stack.pop()\r\n if (top == '(' and ch != ')') or (top == '{' and ch != '}' or (top == '[' and ch != ']')):\r\n return False\r\n return not stack" + ], + "Output Answer": [ + "from collections import deque\r\ndef check_expression(exp):\r\n if len(exp) & 1:\r\n return False\r\n stack = deque()\r\n for ch in exp:\r\n if ch == '(' or ch == '{' or ch == '[':\r\n stack.append(ch)\r\n if ch == ')' or ch == '}' or ch == ']':\r\n if not stack:\r\n return False\r\n top = stack.pop()\r\n if (top == '(' and ch != ')') or (top == '{' and ch != '}' or (top == '[' and ch != ']')):\r\n return False\r\n return not stack" + ], + "split": "train" + }, + { + "Input": "Write a function to remove all the words with k length in the given string.", + "Output Program": [ + "def remove_length(test_str, K):\r\n temp = test_str.split()\r\n res = [ele for ele in temp if len(ele) != K]\r\n res = ' '.join(res)\r\n return (res) " + ], + "Output Answer": [ + "def remove_length(test_str, K):\r\n temp = test_str.split()\r\n res = [ele for ele in temp if len(ele) != K]\r\n res = ' '.join(res)\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a function to find the occurrence and position of the substrings within a string.", + "Output Program": [ + "import re\r\ndef occurance_substring(text,pattern):\r\n for match in re.finditer(pattern, text):\r\n s = match.start()\r\n e = match.end()\r\n return (text[s:e], s, e)" + ], + "Output Answer": [ + "import re\r\ndef occurance_substring(text,pattern):\r\n for match in re.finditer(pattern, text):\r\n s = match.start()\r\n e = match.end()\r\n return (text[s:e], s, e)" + ], + "split": "train" + }, + { + "Input": "Write a function to check if the string is a valid email address or not using regex.", + "Output Program": [ + "import re \r\nregex = '^[a-z0-9]+[\\._]?[a-z0-9]+[@]\\w+[.]\\w{2,3}$'\r\ndef check_email(email): \r\n\tif(re.search(regex,email)): \r\n\t\treturn (\"Valid Email\") \r\n\telse: \r\n\t\treturn (\"Invalid Email\") " + ], + "Output Answer": [ + "import re \r\nregex = '^[a-z0-9]+[\\._]?[a-z0-9]+[@]\\w+[.]\\w{2,3}$'\r\ndef check_email(email): \r\n\tif(re.search(regex,email)): \r\n\t\treturn (\"Valid Email\") \r\n\telse: \r\n\t\treturn (\"Invalid Email\") " + ], + "split": "train" + }, + { + "Input": "Write a python function to check whether every odd index contains odd numbers of a given list.", + "Output Program": [ + "def odd_position(nums):\r\n\treturn all(nums[i]%2==i%2 for i in range(len(nums)))" + ], + "Output Answer": [ + "def odd_position(nums):\r\n\treturn all(nums[i]%2==i%2 for i in range(len(nums)))" + ], + "split": "train" + }, + { + "Input": "Write a function to count those characters which have vowels as their neighbors in the given string.", + "Output Program": [ + "def count_vowels(test_str):\r\n res = 0\r\n vow_list = ['a', 'e', 'i', 'o', 'u']\r\n for idx in range(1, len(test_str) - 1):\r\n if test_str[idx] not in vow_list and (test_str[idx - 1] in vow_list or test_str[idx + 1] in vow_list):\r\n res += 1\r\n if test_str[0] not in vow_list and test_str[1] in vow_list:\r\n res += 1\r\n if test_str[-1] not in vow_list and test_str[-2] in vow_list:\r\n res += 1\r\n return (res) " + ], + "Output Answer": [ + "def count_vowels(test_str):\r\n res = 0\r\n vow_list = ['a', 'e', 'i', 'o', 'u']\r\n for idx in range(1, len(test_str) - 1):\r\n if test_str[idx] not in vow_list and (test_str[idx - 1] in vow_list or test_str[idx + 1] in vow_list):\r\n res += 1\r\n if test_str[0] not in vow_list and test_str[1] in vow_list:\r\n res += 1\r\n if test_str[-1] not in vow_list and test_str[-2] in vow_list:\r\n res += 1\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a python function to find the sum of non-repeated elements in a given array.", + "Output Program": [ + "def find_Sum(arr,n): \r\n arr.sort() \r\n sum = arr[0] \r\n for i in range(0,n-1): \r\n if (arr[i] != arr[i+1]): \r\n sum = sum + arr[i+1] \r\n return sum" + ], + "Output Answer": [ + "def find_Sum(arr,n): \r\n arr.sort() \r\n sum = arr[0] \r\n for i in range(0,n-1): \r\n if (arr[i] != arr[i+1]): \r\n sum = sum + arr[i+1] \r\n return sum" + ], + "split": "train" + }, + { + "Input": "Write a function to pack consecutive duplicates of a given list elements into sublists.", + "Output Program": [ + "from itertools import groupby\r\ndef pack_consecutive_duplicates(list1):\r\n return [list(group) for key, group in groupby(list1)]" + ], + "Output Answer": [ + "from itertools import groupby\r\ndef pack_consecutive_duplicates(list1):\r\n return [list(group) for key, group in groupby(list1)]" + ], + "split": "train" + }, + { + "Input": "Write a function to count the number of unique lists within a list.", + "Output Program": [ + "def unique_sublists(list1):\r\n result ={}\r\n for l in list1: \r\n result.setdefault(tuple(l), list()).append(1) \r\n for a, b in result.items(): \r\n result[a] = sum(b)\r\n return result" + ], + "Output Answer": [ + "def unique_sublists(list1):\r\n result ={}\r\n for l in list1: \r\n result.setdefault(tuple(l), list()).append(1) \r\n for a, b in result.items(): \r\n result[a] = sum(b)\r\n return result" + ], + "split": "train" + }, + { + "Input": "Write a function to find the combinations of sums with tuples in the given tuple list.", + "Output Program": [ + "from itertools import combinations \r\ndef find_combinations(test_list):\r\n res = [(b1 + a1, b2 + a2) for (a1, a2), (b1, b2) in combinations(test_list, 2)]\r\n return (res) " + ], + "Output Answer": [ + "from itertools import combinations \r\ndef find_combinations(test_list):\r\n res = [(b1 + a1, b2 + a2) for (a1, a2), (b1, b2) in combinations(test_list, 2)]\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a python function to check whether the count of divisors is even or odd.", + "Output Program": [ + "import math \r\ndef count_Divisors(n) : \r\n count = 0\r\n for i in range(1, (int)(math.sqrt(n)) + 2) : \r\n if (n % i == 0) : \r\n if( n // i == i) : \r\n count = count + 1\r\n else : \r\n count = count + 2\r\n if (count % 2 == 0) : \r\n return (\"Even\") \r\n else : \r\n return (\"Odd\") " + ], + "Output Answer": [ + "import math \r\ndef count_Divisors(n) : \r\n count = 0\r\n for i in range(1, (int)(math.sqrt(n)) + 2) : \r\n if (n % i == 0) : \r\n if( n // i == i) : \r\n count = count + 1\r\n else : \r\n count = count + 2\r\n if (count % 2 == 0) : \r\n return (\"Even\") \r\n else : \r\n return (\"Odd\") " + ], + "split": "train" + }, + { + "Input": "Write a python function to find the sum of all odd length subarrays.", + "Output Program": [ + "def Odd_Length_Sum(arr):\r\n Sum = 0\r\n l = len(arr)\r\n for i in range(l):\r\n Sum += ((((i + 1) *(l - i) + 1) // 2) * arr[i])\r\n return Sum" + ], + "Output Answer": [ + "def Odd_Length_Sum(arr):\r\n Sum = 0\r\n l = len(arr)\r\n for i in range(l):\r\n Sum += ((((i + 1) *(l - i) + 1) // 2) * arr[i])\r\n return Sum" + ], + "split": "train" + }, + { + "Input": "Write a function to convert rgb color to hsv color.", + "Output Program": [ + "def rgb_to_hsv(r, g, b):\r\n r, g, b = r/255.0, g/255.0, b/255.0\r\n mx = max(r, g, b)\r\n mn = min(r, g, b)\r\n df = mx-mn\r\n if mx == mn:\r\n h = 0\r\n elif mx == r:\r\n h = (60 * ((g-b)/df) + 360) % 360\r\n elif mx == g:\r\n h = (60 * ((b-r)/df) + 120) % 360\r\n elif mx == b:\r\n h = (60 * ((r-g)/df) + 240) % 360\r\n if mx == 0:\r\n s = 0\r\n else:\r\n s = (df/mx)*100\r\n v = mx*100\r\n return h, s, v" + ], + "Output Answer": [ + "def rgb_to_hsv(r, g, b):\r\n r, g, b = r/255.0, g/255.0, b/255.0\r\n mx = max(r, g, b)\r\n mn = min(r, g, b)\r\n df = mx-mn\r\n if mx == mn:\r\n h = 0\r\n elif mx == r:\r\n h = (60 * ((g-b)/df) + 360) % 360\r\n elif mx == g:\r\n h = (60 * ((b-r)/df) + 120) % 360\r\n elif mx == b:\r\n h = (60 * ((r-g)/df) + 240) % 360\r\n if mx == 0:\r\n s = 0\r\n else:\r\n s = (df/mx)*100\r\n v = mx*100\r\n return h, s, v" + ], + "split": "train" + }, + { + "Input": "Write a function to find the product of first even and odd number of a given list.", + "Output Program": [ + "def mul_even_odd(list1):\r\n first_even = next((el for el in list1 if el%2==0),-1)\r\n first_odd = next((el for el in list1 if el%2!=0),-1)\r\n return (first_even*first_odd)" + ], + "Output Answer": [ + "def mul_even_odd(list1):\r\n first_even = next((el for el in list1 if el%2==0),-1)\r\n first_odd = next((el for el in list1 if el%2!=0),-1)\r\n return (first_even*first_odd)" + ], + "split": "train" + }, + { + "Input": "Write a function to convert tuple string to integer tuple.", + "Output Program": [ + "def tuple_str_int(test_str):\r\n res = tuple(int(num) for num in test_str.replace('(', '').replace(')', '').replace('...', '').split(', '))\r\n return (res) " + ], + "Output Answer": [ + "def tuple_str_int(test_str):\r\n res = tuple(int(num) for num in test_str.replace('(', '').replace(')', '').replace('...', '').split(', '))\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a function to locate the right insertion point for a specified value in sorted order.", + "Output Program": [ + "import bisect\r\ndef right_insertion(a, x):\r\n i = bisect.bisect_right(a, x)\r\n return i" + ], + "Output Answer": [ + "import bisect\r\ndef right_insertion(a, x):\r\n i = bisect.bisect_right(a, x)\r\n return i" + ], + "split": "train" + }, + { + "Input": "Write a function that matches a string that has an a followed by three 'b'.", + "Output Program": [ + "import re\r\ndef text_match_three(text):\r\n patterns = 'ab{3}?'\r\n if re.search(patterns, text):\r\n return 'Found a match!'\r\n else:\r\n return('Not matched!')" + ], + "Output Answer": [ + "import re\r\ndef text_match_three(text):\r\n patterns = 'ab{3}?'\r\n if re.search(patterns, text):\r\n return 'Found a match!'\r\n else:\r\n return('Not matched!')" + ], + "split": "train" + }, + { + "Input": "Write a function to create a new tuple from the given string and list.", + "Output Program": [ + "def new_tuple(test_list, test_str):\r\n res = tuple(test_list + [test_str])\r\n return (res) " + ], + "Output Answer": [ + "def new_tuple(test_list, test_str):\r\n res = tuple(test_list + [test_str])\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a function to calculate the perimeter of a regular polygon.", + "Output Program": [ + "from math import tan, pi\r\ndef perimeter_polygon(s,l):\r\n perimeter = s*l\r\n return perimeter" + ], + "Output Answer": [ + "from math import tan, pi\r\ndef perimeter_polygon(s,l):\r\n perimeter = s*l\r\n return perimeter" + ], + "split": "train" + }, + { + "Input": "Write a python function to check whether every even index contains even numbers of a given list.", + "Output Program": [ + "def even_position(nums):\r\n\treturn all(nums[i]%2==i%2 for i in range(len(nums)))" + ], + "Output Answer": [ + "def even_position(nums):\r\n\treturn all(nums[i]%2==i%2 for i in range(len(nums)))" + ], + "split": "train" + }, + { + "Input": "Write a function to remove the nested record from the given tuple.", + "Output Program": [ + "def remove_nested(test_tup):\r\n res = tuple()\r\n for count, ele in enumerate(test_tup):\r\n if not isinstance(ele, tuple):\r\n res = res + (ele, )\r\n return (res) " + ], + "Output Answer": [ + "def remove_nested(test_tup):\r\n res = tuple()\r\n for count, ele in enumerate(test_tup):\r\n if not isinstance(ele, tuple):\r\n res = res + (ele, )\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a python function to count the number of lists in a given number of lists.", + "Output Program": [ + "def count_list(input_list): \r\n return len(input_list)" + ], + "Output Answer": [ + "def count_list(input_list): \r\n return len(input_list)" + ], + "split": "train" + }, + { + "Input": "Write a python function to find the last position of an element in a sorted array.", + "Output Program": [ + "def last(arr,x,n):\r\n low = 0\r\n high = n - 1\r\n res = -1 \r\n while (low <= high):\r\n mid = (low + high) // 2 \r\n if arr[mid] > x:\r\n high = mid - 1\r\n elif arr[mid] < x:\r\n low = mid + 1\r\n else:\r\n res = mid\r\n low = mid + 1\r\n return res" + ], + "Output Answer": [ + "def last(arr,x,n):\r\n low = 0\r\n high = n - 1\r\n res = -1 \r\n while (low <= high):\r\n mid = (low + high) // 2 \r\n if arr[mid] > x:\r\n high = mid - 1\r\n elif arr[mid] < x:\r\n low = mid + 1\r\n else:\r\n res = mid\r\n low = mid + 1\r\n return res" + ], + "split": "train" + }, + { + "Input": "Write a function that matches a string that has an 'a' followed by anything, ending in 'b'.", + "Output Program": [ + "import re\r\ndef text_starta_endb(text):\r\n patterns = 'a.*?b$'\r\n if re.search(patterns, text):\r\n return 'Found a match!'\r\n else:\r\n return('Not matched!')" + ], + "Output Answer": [ + "import re\r\ndef text_starta_endb(text):\r\n patterns = 'a.*?b$'\r\n if re.search(patterns, text):\r\n return 'Found a match!'\r\n else:\r\n return('Not matched!')" + ], + "split": "train" + }, + { + "Input": "Write a function to find the n - cheap price items from a given dataset using heap queue algorithm.", + "Output Program": [ + "import heapq\r\ndef cheap_items(items,n):\r\n cheap_items = heapq.nsmallest(n, items, key=lambda s: s['price'])\r\n return cheap_items" + ], + "Output Answer": [ + "import heapq\r\ndef cheap_items(items,n):\r\n cheap_items = heapq.nsmallest(n, items, key=lambda s: s['price'])\r\n return cheap_items" + ], + "split": "train" + }, + { + "Input": "Write function to find the sum of all items in the given dictionary.", + "Output Program": [ + "def return_sum(dict):\r\n sum = 0\r\n for i in dict.values():\r\n sum = sum + i\r\n return sum" + ], + "Output Answer": [ + "def return_sum(dict):\r\n sum = 0\r\n for i in dict.values():\r\n sum = sum + i\r\n return sum" + ], + "split": "train" + }, + { + "Input": "Write a python function to find the sum of all odd natural numbers within the range l and r.", + "Output Program": [ + "def sum_Odd(n): \r\n terms = (n + 1)//2\r\n sum1 = terms * terms \r\n return sum1 \r\ndef sum_in_Range(l,r): \r\n return sum_Odd(r) - sum_Odd(l - 1)" + ], + "Output Answer": [ + "def sum_Odd(n): \r\n terms = (n + 1)//2\r\n sum1 = terms * terms \r\n return sum1 \r\ndef sum_in_Range(l,r): \r\n return sum_Odd(r) - sum_Odd(l - 1)" + ], + "split": "train" + }, + { + "Input": "Write a python function to find the sum of an array.", + "Output Program": [ + "def _sum(arr): \r\n sum=0\r\n for i in arr: \r\n sum = sum + i \r\n return(sum) " + ], + "Output Answer": [ + "def _sum(arr): \r\n sum=0\r\n for i in arr: \r\n sum = sum + i \r\n return(sum) " + ], + "split": "train" + }, + { + "Input": "Write a python function to left rotate the bits of a given number.", + "Output Program": [ + "INT_BITS = 32\r\ndef left_Rotate(n,d): \r\n return (n << d)|(n >> (INT_BITS - d)) " + ], + "Output Answer": [ + "INT_BITS = 32\r\ndef left_Rotate(n,d): \r\n return (n << d)|(n >> (INT_BITS - d)) " + ], + "split": "train" + }, + { + "Input": "Write a function to remove all whitespaces from a string.", + "Output Program": [ + "import re\r\ndef remove_all_spaces(text):\r\n return (re.sub(r'\\s+', '',text))" + ], + "Output Answer": [ + "import re\r\ndef remove_all_spaces(text):\r\n return (re.sub(r'\\s+', '',text))" + ], + "split": "train" + }, + { + "Input": "Write a python function to count the number of equal numbers from three given integers.", + "Output Program": [ + "def test_three_equal(x,y,z):\r\n result= set([x,y,z])\r\n if len(result)==3:\r\n return 0\r\n else:\r\n return (4-len(result))" + ], + "Output Answer": [ + "def test_three_equal(x,y,z):\r\n result= set([x,y,z])\r\n if len(result)==3:\r\n return 0\r\n else:\r\n return (4-len(result))" + ], + "split": "train" + }, + { + "Input": "Write a python function to count the number of rotations required to generate a sorted array.", + "Output Program": [ + "def count_Rotation(arr,n): \r\n for i in range (1,n): \r\n if (arr[i] < arr[i - 1]): \r\n return i \r\n return 0" + ], + "Output Answer": [ + "def count_Rotation(arr,n): \r\n for i in range (1,n): \r\n if (arr[i] < arr[i - 1]): \r\n return i \r\n return 0" + ], + "split": "train" + }, + { + "Input": "Write a python function to check whether the given number is a perfect square or not.", + "Output Program": [ + "def is_Perfect_Square(n) :\r\n i = 1\r\n while (i * i<= n):\r\n if ((n % i == 0) and (n / i == i)):\r\n return True \r\n i = i + 1\r\n return False" + ], + "Output Answer": [ + "def is_Perfect_Square(n) :\r\n i = 1\r\n while (i * i<= n):\r\n if ((n % i == 0) and (n / i == i)):\r\n return True \r\n i = i + 1\r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a python function to check whether the product of numbers is even or not.", + "Output Program": [ + "def is_Product_Even(arr,n): \r\n for i in range(0,n): \r\n if ((arr[i] & 1) == 0): \r\n return True\r\n return False" + ], + "Output Answer": [ + "def is_Product_Even(arr,n): \r\n for i in range(0,n): \r\n if ((arr[i] & 1) == 0): \r\n return True\r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a function to find the list in a list of lists whose sum of elements is the highest.", + "Output Program": [ + "def max_sum_list(lists):\r\n return max(lists, key=sum)" + ], + "Output Answer": [ + "def max_sum_list(lists):\r\n return max(lists, key=sum)" + ], + "split": "train" + }, + { + "Input": "Write a function to find maximum run of uppercase characters in the given string.", + "Output Program": [ + "def max_run_uppercase(test_str):\r\n cnt = 0\r\n res = 0\r\n for idx in range(0, len(test_str)):\r\n if test_str[idx].isupper():\r\n cnt += 1\r\n else:\r\n res = cnt\r\n cnt = 0\r\n if test_str[len(test_str) - 1].isupper():\r\n res = cnt\r\n return (res)" + ], + "Output Answer": [ + "def max_run_uppercase(test_str):\r\n cnt = 0\r\n res = 0\r\n for idx in range(0, len(test_str)):\r\n if test_str[idx].isupper():\r\n cnt += 1\r\n else:\r\n res = cnt\r\n cnt = 0\r\n if test_str[len(test_str) - 1].isupper():\r\n res = cnt\r\n return (res)" + ], + "split": "train" + }, + { + "Input": "Write a python function to find the first odd number in a given list of numbers.", + "Output Program": [ + "def first_odd(nums):\r\n first_odd = next((el for el in nums if el%2!=0),-1)\r\n return first_odd" + ], + "Output Answer": [ + "def first_odd(nums):\r\n first_odd = next((el for el in nums if el%2!=0),-1)\r\n return first_odd" + ], + "split": "train" + }, + { + "Input": "Write a function to check if the given tuples contain the k or not.", + "Output Program": [ + "def check_K(test_tup, K):\r\n res = False\r\n for ele in test_tup:\r\n if ele == K:\r\n res = True\r\n break\r\n return (res) " + ], + "Output Answer": [ + "def check_K(test_tup, K):\r\n res = False\r\n for ele in test_tup:\r\n if ele == K:\r\n res = True\r\n break\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a function to check if each element of second tuple is smaller than its corresponding index in first tuple.", + "Output Program": [ + "def check_smaller(test_tup1, test_tup2):\r\n res = all(x > y for x, y in zip(test_tup1, test_tup2))\r\n return (res) " + ], + "Output Answer": [ + "def check_smaller(test_tup1, test_tup2):\r\n res = all(x > y for x, y in zip(test_tup1, test_tup2))\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a function to iterate over elements repeating each as many times as its count.", + "Output Program": [ + "from collections import Counter\r\ndef count_variable(a,b,c,d):\r\n c = Counter(p=a, q=b, r=c, s=d)\r\n return list(c.elements())" + ], + "Output Answer": [ + "from collections import Counter\r\ndef count_variable(a,b,c,d):\r\n c = Counter(p=a, q=b, r=c, s=d)\r\n return list(c.elements())" + ], + "split": "train" + }, + { + "Input": "Write a function to check if two lists of tuples are identical or not.", + "Output Program": [ + "def check_identical(test_list1, test_list2):\r\n res = test_list1 == test_list2\r\n return (res) " + ], + "Output Answer": [ + "def check_identical(test_list1, test_list2):\r\n res = test_list1 == test_list2\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a function to abbreviate 'road' as 'rd.' in a given string.", + "Output Program": [ + "import re\r\ndef road_rd(street):\r\n return (re.sub('Road$', 'Rd.', street))" + ], + "Output Answer": [ + "import re\r\ndef road_rd(street):\r\n return (re.sub('Road$', 'Rd.', street))" + ], + "split": "train" + }, + { + "Input": "Write a function to find length of the string.", + "Output Program": [ + "def string_length(str1):\r\n count = 0\r\n for char in str1:\r\n count += 1\r\n return count" + ], + "Output Answer": [ + "def string_length(str1):\r\n count = 0\r\n for char in str1:\r\n count += 1\r\n return count" + ], + "split": "train" + }, + { + "Input": "Write a function to find the area of a rombus.", + "Output Program": [ + "def rombus_area(p,q):\r\n area=(p*q)/2\r\n return area" + ], + "Output Answer": [ + "def rombus_area(p,q):\r\n area=(p*q)/2\r\n return area" + ], + "split": "train" + }, + { + "Input": "Write a function to sort the given array without using any sorting algorithm. the given array consists of only 0, 1, and 2.", + "Output Program": [ + "def sort_by_dnf(arr, n):\r\n low=0\r\n mid=0\r\n high=n-1\r\n while mid <= high:\r\n if arr[mid] == 0:\r\n arr[low], arr[mid] = arr[mid], arr[low]\r\n low = low + 1\r\n mid = mid + 1\r\n elif arr[mid] == 1:\r\n mid = mid + 1\r\n else:\r\n arr[mid], arr[high] = arr[high], arr[mid]\r\n high = high - 1\r\n return arr" + ], + "Output Answer": [ + "def sort_by_dnf(arr, n):\r\n low=0\r\n mid=0\r\n high=n-1\r\n while mid <= high:\r\n if arr[mid] == 0:\r\n arr[low], arr[mid] = arr[mid], arr[low]\r\n low = low + 1\r\n mid = mid + 1\r\n elif arr[mid] == 1:\r\n mid = mid + 1\r\n else:\r\n arr[mid], arr[high] = arr[high], arr[mid]\r\n high = high - 1\r\n return arr" + ], + "split": "train" + }, + { + "Input": "Write a function to clear the values of the given tuples.", + "Output Program": [ + "def clear_tuple(test_tup):\r\n temp = list(test_tup)\r\n temp.clear()\r\n test_tup = tuple(temp)\r\n return (test_tup) " + ], + "Output Answer": [ + "def clear_tuple(test_tup):\r\n temp = list(test_tup)\r\n temp.clear()\r\n test_tup = tuple(temp)\r\n return (test_tup) " + ], + "split": "train" + }, + { + "Input": "Write a function to find numbers divisible by m or n from a list of numbers using lambda function.", + "Output Program": [ + "def div_of_nums(nums,m,n):\r\n result = list(filter(lambda x: (x % m == 0 or x % n == 0), nums)) \r\n return result" + ], + "Output Answer": [ + "def div_of_nums(nums,m,n):\r\n result = list(filter(lambda x: (x % m == 0 or x % n == 0), nums)) \r\n return result" + ], + "split": "train" + }, + { + "Input": "Write a python function to count lower case letters in a given string.", + "Output Program": [ + "def lower_ctr(str):\r\n lower_ctr= 0\r\n for i in range(len(str)):\r\n if str[i] >= 'a' and str[i] <= 'z': lower_ctr += 1 \r\n return lower_ctr" + ], + "Output Answer": [ + "def lower_ctr(str):\r\n lower_ctr= 0\r\n for i in range(len(str)):\r\n if str[i] >= 'a' and str[i] <= 'z': lower_ctr += 1 \r\n return lower_ctr" + ], + "split": "train" + }, + { + "Input": "Write a function to count the frequency of consecutive duplicate elements in a given list of numbers.", + "Output Program": [ + "def count_duplic(lists):\r\n element = []\r\n frequency = []\r\n if not lists:\r\n return element\r\n running_count = 1\r\n for i in range(len(lists)-1):\r\n if lists[i] == lists[i+1]:\r\n running_count += 1\r\n else:\r\n frequency.append(running_count)\r\n element.append(lists[i])\r\n running_count = 1\r\n frequency.append(running_count)\r\n element.append(lists[i+1])\r\n return element,frequency\r\n" + ], + "Output Answer": [ + "def count_duplic(lists):\r\n element = []\r\n frequency = []\r\n if not lists:\r\n return element\r\n running_count = 1\r\n for i in range(len(lists)-1):\r\n if lists[i] == lists[i+1]:\r\n running_count += 1\r\n else:\r\n frequency.append(running_count)\r\n element.append(lists[i])\r\n running_count = 1\r\n frequency.append(running_count)\r\n element.append(lists[i+1])\r\n return element,frequency\r\n" + ], + "split": "train" + }, + { + "Input": "Write a function to check whether the given month number contains 28 days or not.", + "Output Program": [ + "def check_monthnum_number(monthnum1):\r\n if monthnum1 == 2:\r\n return True\r\n else:\r\n return False" + ], + "Output Answer": [ + "def check_monthnum_number(monthnum1):\r\n if monthnum1 == 2:\r\n return True\r\n else:\r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a function to merge two dictionaries into a single expression.", + "Output Program": [ + "import collections as ct\r\ndef merge_dictionaries(dict1,dict2):\r\n merged_dict = dict(ct.ChainMap({}, dict1, dict2))\r\n return merged_dict" + ], + "Output Answer": [ + "import collections as ct\r\ndef merge_dictionaries(dict1,dict2):\r\n merged_dict = dict(ct.ChainMap({}, dict1, dict2))\r\n return merged_dict" + ], + "split": "train" + }, + { + "Input": "Write a function to return true if the password is valid.", + "Output Program": [ + "import re\r\ndef pass_validity(p):\r\n x = True\r\n while x: \r\n if (len(p)<6 or len(p)>12):\r\n break\r\n elif not re.search(\"[a-z]\",p):\r\n break\r\n elif not re.search(\"[0-9]\",p):\r\n break\r\n elif not re.search(\"[A-Z]\",p):\r\n break\r\n elif not re.search(\"[$#@]\",p):\r\n break\r\n elif re.search(\"\\s\",p):\r\n break\r\n else:\r\n return True\r\n x=False\r\n break\r\n\r\n if x:\r\n return False" + ], + "Output Answer": [ + "import re\r\ndef pass_validity(p):\r\n x = True\r\n while x: \r\n if (len(p)<6 or len(p)>12):\r\n break\r\n elif not re.search(\"[a-z]\",p):\r\n break\r\n elif not re.search(\"[0-9]\",p):\r\n break\r\n elif not re.search(\"[A-Z]\",p):\r\n break\r\n elif not re.search(\"[$#@]\",p):\r\n break\r\n elif re.search(\"\\s\",p):\r\n break\r\n else:\r\n return True\r\n x=False\r\n break\r\n\r\n if x:\r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a function to check if the given string starts with a substring using regex.", + "Output Program": [ + "import re \r\ndef check_substring(string, sample) : \r\n if (sample in string): \r\n y = \"\\A\" + sample \r\n x = re.search(y, string) \r\n if x : \r\n return (\"string starts with the given substring\") \r\n else : \r\n return (\"string doesnt start with the given substring\") \r\n else : \r\n return (\"entered string isnt a substring\")" + ], + "Output Answer": [ + "import re \r\ndef check_substring(string, sample) : \r\n if (sample in string): \r\n y = \"\\A\" + sample \r\n x = re.search(y, string) \r\n if x : \r\n return (\"string starts with the given substring\") \r\n else : \r\n return (\"string doesnt start with the given substring\") \r\n else : \r\n return (\"entered string isnt a substring\")" + ], + "split": "train" + }, + { + "Input": "Write a python function to remove even numbers from a given list.", + "Output Program": [ + "def remove_even(l):\r\n for i in l:\r\n if i % 2 == 0:\r\n l.remove(i)\r\n return l" + ], + "Output Answer": [ + "def remove_even(l):\r\n for i in l:\r\n if i % 2 == 0:\r\n l.remove(i)\r\n return l" + ], + "split": "train" + }, + { + "Input": "Write a python function to access multiple elements of specified index from a given list.", + "Output Program": [ + "def access_elements(nums, list_index):\r\n result = [nums[i] for i in list_index]\r\n return result" + ], + "Output Answer": [ + "def access_elements(nums, list_index):\r\n result = [nums[i] for i in list_index]\r\n return result" + ], + "split": "train" + }, + { + "Input": "Write a python function to find the type of triangle from the given sides.", + "Output Program": [ + "def check_Type_Of_Triangle(a,b,c): \r\n sqa = pow(a,2) \r\n sqb = pow(b,2) \r\n sqc = pow(c,2) \r\n if (sqa == sqa + sqb or sqb == sqa + sqc or sqc == sqa + sqb): \r\n return (\"Right-angled Triangle\") \r\n elif (sqa > sqc + sqb or sqb > sqa + sqc or sqc > sqa + sqb): \r\n return (\"Obtuse-angled Triangle\") \r\n else: \r\n return (\"Acute-angled Triangle\") " + ], + "Output Answer": [ + "def check_Type_Of_Triangle(a,b,c): \r\n sqa = pow(a,2) \r\n sqb = pow(b,2) \r\n sqc = pow(c,2) \r\n if (sqa == sqa + sqb or sqb == sqa + sqc or sqc == sqa + sqb): \r\n return (\"Right-angled Triangle\") \r\n elif (sqa > sqc + sqb or sqb > sqa + sqc or sqc > sqa + sqb): \r\n return (\"Obtuse-angled Triangle\") \r\n else: \r\n return (\"Acute-angled Triangle\") " + ], + "split": "train" + }, + { + "Input": "Write a function to sum a specific column of a list in a given list of lists.", + "Output Program": [ + "def sum_column(list1, C):\r\n result = sum(row[C] for row in list1)\r\n return result" + ], + "Output Answer": [ + "def sum_column(list1, C):\r\n result = sum(row[C] for row in list1)\r\n return result" + ], + "split": "train" + }, + { + "Input": "Write a function to count alphabets,digits and special charactes in a given string.", + "Output Program": [ + "def count_alpha_dig_spl(string):\r\n alphabets=digits = special = 0\r\n for i in range(len(string)):\r\n if(string[i].isalpha()):\r\n alphabets = alphabets + 1\r\n elif(string[i].isdigit()):\r\n digits = digits + 1\r\n else:\r\n special = special + 1\r\n return (alphabets,digits,special) " + ], + "Output Answer": [ + "def count_alpha_dig_spl(string):\r\n alphabets=digits = special = 0\r\n for i in range(len(string)):\r\n if(string[i].isalpha()):\r\n alphabets = alphabets + 1\r\n elif(string[i].isdigit()):\r\n digits = digits + 1\r\n else:\r\n special = special + 1\r\n return (alphabets,digits,special) " + ], + "split": "train" + }, + { + "Input": "Write a function to find out the second most repeated (or frequent) string in the given sequence.", + "Output Program": [ + "from collections import Counter \r\n\t\r\ndef second_frequent(input): \r\n\tdict = Counter(input) \r\n\tvalue = sorted(dict.values(), reverse=True) \r\n\tsecond_large = value[1] \r\n\tfor (key, val) in dict.items(): \r\n\t\tif val == second_large: \r\n\t\t\treturn (key) " + ], + "Output Answer": [ + "from collections import Counter \r\n\t\r\ndef second_frequent(input): \r\n\tdict = Counter(input) \r\n\tvalue = sorted(dict.values(), reverse=True) \r\n\tsecond_large = value[1] \r\n\tfor (key, val) in dict.items(): \r\n\t\tif val == second_large: \r\n\t\t\treturn (key) " + ], + "split": "train" + }, + { + "Input": "Write a function to round up a number to specific digits.", + "Output Program": [ + "import math\r\ndef round_up(a, digits):\r\n n = 10**-digits\r\n return round(math.ceil(a / n) * n, digits)" + ], + "Output Answer": [ + "import math\r\ndef round_up(a, digits):\r\n n = 10**-digits\r\n return round(math.ceil(a / n) * n, digits)" + ], + "split": "train" + }, + { + "Input": "Write a python function to count equal element pairs from the given array.", + "Output Program": [ + "def count_Pairs(arr,n): \r\n cnt = 0; \r\n for i in range(n): \r\n for j in range(i + 1,n): \r\n if (arr[i] == arr[j]): \r\n cnt += 1; \r\n return cnt; " + ], + "Output Answer": [ + "def count_Pairs(arr,n): \r\n cnt = 0; \r\n for i in range(n): \r\n for j in range(i + 1,n): \r\n if (arr[i] == arr[j]): \r\n cnt += 1; \r\n return cnt; " + ], + "split": "train" + }, + { + "Input": "Write a function to extract the maximum numeric value from a string by using regex.", + "Output Program": [ + "import re \r\ndef extract_max(input): \r\n\tnumbers = re.findall('\\d+',input) \r\n\tnumbers = map(int,numbers) \r\n\treturn max(numbers)" + ], + "Output Answer": [ + "import re \r\ndef extract_max(input): \r\n\tnumbers = re.findall('\\d+',input) \r\n\tnumbers = map(int,numbers) \r\n\treturn max(numbers)" + ], + "split": "train" + }, + { + "Input": "Write a function to get dictionary keys as a list.", + "Output Program": [ + "def get_key(dict): \r\n list = [] \r\n for key in dict.keys(): \r\n list.append(key) \r\n return list" + ], + "Output Answer": [ + "def get_key(dict): \r\n list = [] \r\n for key in dict.keys(): \r\n list.append(key) \r\n return list" + ], + "split": "train" + }, + { + "Input": "Write a function to generate a square matrix filled with elements from 1 to n raised to the power of 2 in spiral order.", + "Output Program": [ + "def generate_matrix(n):\r\n if n<=0:\r\n return [] \r\n matrix=[row[:] for row in [[0]*n]*n] \r\n row_st=0\r\n row_ed=n-1 \r\n col_st=0\r\n col_ed=n-1\r\n current=1 \r\n while (True):\r\n if current>n*n:\r\n break\r\n for c in range (col_st, col_ed+1):\r\n matrix[row_st][c]=current\r\n current+=1\r\n row_st+=1\r\n for r in range (row_st, row_ed+1):\r\n matrix[r][col_ed]=current\r\n current+=1\r\n col_ed-=1\r\n for c in range (col_ed, col_st-1, -1):\r\n matrix[row_ed][c]=current\r\n current+=1\r\n row_ed-=1\r\n for r in range (row_ed, row_st-1, -1):\r\n matrix[r][col_st]=current\r\n current+=1\r\n col_st+=1\r\n return matrix" + ], + "Output Answer": [ + "def generate_matrix(n):\r\n if n<=0:\r\n return [] \r\n matrix=[row[:] for row in [[0]*n]*n] \r\n row_st=0\r\n row_ed=n-1 \r\n col_st=0\r\n col_ed=n-1\r\n current=1 \r\n while (True):\r\n if current>n*n:\r\n break\r\n for c in range (col_st, col_ed+1):\r\n matrix[row_st][c]=current\r\n current+=1\r\n row_st+=1\r\n for r in range (row_st, row_ed+1):\r\n matrix[r][col_ed]=current\r\n current+=1\r\n col_ed-=1\r\n for c in range (col_ed, col_st-1, -1):\r\n matrix[row_ed][c]=current\r\n current+=1\r\n row_ed-=1\r\n for r in range (row_ed, row_st-1, -1):\r\n matrix[r][col_st]=current\r\n current+=1\r\n col_st+=1\r\n return matrix" + ], + "split": "train" + }, + { + "Input": "Write a python function to find the slope of a line.", + "Output Program": [ + "def slope(x1,y1,x2,y2): \r\n return (float)(y2-y1)/(x2-x1) " + ], + "Output Answer": [ + "def slope(x1,y1,x2,y2): \r\n return (float)(y2-y1)/(x2-x1) " + ], + "split": "train" + }, + { + "Input": "Write a function to find length of the subarray having maximum sum.", + "Output Program": [ + "from sys import maxsize \r\ndef max_sub_array_sum(a,size): \r\n\tmax_so_far = -maxsize - 1\r\n\tmax_ending_here = 0\r\n\tstart = 0\r\n\tend = 0\r\n\ts = 0\r\n\tfor i in range(0,size): \r\n\t\tmax_ending_here += a[i] \r\n\t\tif max_so_far < max_ending_here: \r\n\t\t\tmax_so_far = max_ending_here \r\n\t\t\tstart = s \r\n\t\t\tend = i \r\n\t\tif max_ending_here < 0: \r\n\t\t\tmax_ending_here = 0\r\n\t\t\ts = i+1\r\n\treturn (end - start + 1)" + ], + "Output Answer": [ + "from sys import maxsize \r\ndef max_sub_array_sum(a,size): \r\n\tmax_so_far = -maxsize - 1\r\n\tmax_ending_here = 0\r\n\tstart = 0\r\n\tend = 0\r\n\ts = 0\r\n\tfor i in range(0,size): \r\n\t\tmax_ending_here += a[i] \r\n\t\tif max_so_far < max_ending_here: \r\n\t\t\tmax_so_far = max_ending_here \r\n\t\t\tstart = s \r\n\t\t\tend = i \r\n\t\tif max_ending_here < 0: \r\n\t\t\tmax_ending_here = 0\r\n\t\t\ts = i+1\r\n\treturn (end - start + 1)" + ], + "split": "train" + }, + { + "Input": "Write a python function to find the cube sum of first n odd natural numbers.", + "Output Program": [ + "def cube_Sum(n): \r\n sum = 0 \r\n for i in range(0,n) : \r\n sum += (2*i+1)*(2*i+1)*(2*i+1) \r\n return sum" + ], + "Output Answer": [ + "def cube_Sum(n): \r\n sum = 0 \r\n for i in range(0,n) : \r\n sum += (2*i+1)*(2*i+1)*(2*i+1) \r\n return sum" + ], + "split": "train" + }, + { + "Input": "Write a python function to find minimum number swaps required to make two binary strings equal.", + "Output Program": [ + "def min_Swaps(s1,s2) : \r\n c0 = 0; c1 = 0; \r\n for i in range(len(s1)) : \r\n if (s1[i] == '0' and s2[i] == '1') : \r\n c0 += 1; \r\n elif (s1[i] == '1' and s2[i] == '0') : \r\n c1 += 1; \r\n result = c0 // 2 + c1 // 2; \r\n if (c0 % 2 == 0 and c1 % 2 == 0) : \r\n return result; \r\n elif ((c0 + c1) % 2 == 0) : \r\n return result + 2; \r\n else : \r\n return -1; " + ], + "Output Answer": [ + "def min_Swaps(s1,s2) : \r\n c0 = 0; c1 = 0; \r\n for i in range(len(s1)) : \r\n if (s1[i] == '0' and s2[i] == '1') : \r\n c0 += 1; \r\n elif (s1[i] == '1' and s2[i] == '0') : \r\n c1 += 1; \r\n result = c0 // 2 + c1 // 2; \r\n if (c0 % 2 == 0 and c1 % 2 == 0) : \r\n return result; \r\n elif ((c0 + c1) % 2 == 0) : \r\n return result + 2; \r\n else : \r\n return -1; " + ], + "split": "train" + }, + { + "Input": "Write a function to sort the tuples alphabetically by the first item of each tuple.", + "Output Program": [ + "def sort_tuple(tup): \r\n\tn = len(tup) \r\n\tfor i in range(n): \r\n\t\tfor j in range(n-i-1): \r\n\t\t\tif tup[j][0] > tup[j + 1][0]: \r\n\t\t\t\ttup[j], tup[j + 1] = tup[j + 1], tup[j] \r\n\treturn tup" + ], + "Output Answer": [ + "def sort_tuple(tup): \r\n\tn = len(tup) \r\n\tfor i in range(n): \r\n\t\tfor j in range(n-i-1): \r\n\t\t\tif tup[j][0] > tup[j + 1][0]: \r\n\t\t\t\ttup[j], tup[j + 1] = tup[j + 1], tup[j] \r\n\treturn tup" + ], + "split": "train" + }, + { + "Input": "Write a python function to check whether the roots of a quadratic equation are numerically equal but opposite in sign or not.", + "Output Program": [ + "def Check_Solution(a,b,c): \r\n if b == 0: \r\n return (\"Yes\") \r\n else: \r\n return (\"No\") " + ], + "Output Answer": [ + "def Check_Solution(a,b,c): \r\n if b == 0: \r\n return (\"Yes\") \r\n else: \r\n return (\"No\") " + ], + "split": "train" + }, + { + "Input": "Write a function to count the number of inversions in the given array.", + "Output Program": [ + "def get_inv_count(arr, n): \r\n\tinv_count = 0\r\n\tfor i in range(n): \r\n\t\tfor j in range(i + 1, n): \r\n\t\t\tif (arr[i] > arr[j]): \r\n\t\t\t\tinv_count += 1\r\n\treturn inv_count " + ], + "Output Answer": [ + "def get_inv_count(arr, n): \r\n\tinv_count = 0\r\n\tfor i in range(n): \r\n\t\tfor j in range(i + 1, n): \r\n\t\t\tif (arr[i] > arr[j]): \r\n\t\t\t\tinv_count += 1\r\n\treturn inv_count " + ], + "split": "train" + }, + { + "Input": "Write a function to find the number which occurs for odd number of times in the given array.", + "Output Program": [ + "def get_odd_occurence(arr, arr_size):\r\n for i in range(0, arr_size):\r\n count = 0\r\n for j in range(0, arr_size):\r\n if arr[i] == arr[j]:\r\n count += 1\r\n if (count % 2 != 0):\r\n return arr[i]\r\n return -1" + ], + "Output Answer": [ + "def get_odd_occurence(arr, arr_size):\r\n for i in range(0, arr_size):\r\n count = 0\r\n for j in range(0, arr_size):\r\n if arr[i] == arr[j]:\r\n count += 1\r\n if (count % 2 != 0):\r\n return arr[i]\r\n return -1" + ], + "split": "train" + }, + { + "Input": "Write a function to find the nth super ugly number from a given prime list of size k using heap queue algorithm.", + "Output Program": [ + "import heapq\r\ndef nth_super_ugly_number(n, primes):\r\n uglies = [1]\r\n def gen(prime):\r\n for ugly in uglies:\r\n yield ugly * prime\r\n merged = heapq.merge(*map(gen, primes))\r\n while len(uglies) < n:\r\n ugly = next(merged)\r\n if ugly != uglies[-1]:\r\n uglies.append(ugly)\r\n return uglies[-1]" + ], + "Output Answer": [ + "import heapq\r\ndef nth_super_ugly_number(n, primes):\r\n uglies = [1]\r\n def gen(prime):\r\n for ugly in uglies:\r\n yield ugly * prime\r\n merged = heapq.merge(*map(gen, primes))\r\n while len(uglies) < n:\r\n ugly = next(merged)\r\n if ugly != uglies[-1]:\r\n uglies.append(ugly)\r\n return uglies[-1]" + ], + "split": "train" + }, + { + "Input": "Write a python function to find the kth element in an array containing odd elements first and then even elements.", + "Output Program": [ + "def get_Number(n, k): \r\n arr = [0] * n; \r\n i = 0; \r\n odd = 1; \r\n while (odd <= n): \r\n arr[i] = odd; \r\n i += 1; \r\n odd += 2;\r\n even = 2; \r\n while (even <= n): \r\n arr[i] = even; \r\n i += 1;\r\n even += 2; \r\n return arr[k - 1]; " + ], + "Output Answer": [ + "def get_Number(n, k): \r\n arr = [0] * n; \r\n i = 0; \r\n odd = 1; \r\n while (odd <= n): \r\n arr[i] = odd; \r\n i += 1; \r\n odd += 2;\r\n even = 2; \r\n while (even <= n): \r\n arr[i] = even; \r\n i += 1;\r\n even += 2; \r\n return arr[k - 1]; " + ], + "split": "train" + }, + { + "Input": "Write a python function to count the number of digits in factorial of a given number.", + "Output Program": [ + "import math \r\ndef find_Digits(n): \r\n if (n < 0): \r\n return 0;\r\n if (n <= 1): \r\n return 1; \r\n x = ((n * math.log10(n / math.e) + math.log10(2 * math.pi * n) /2.0)); \r\n return math.floor(x) + 1; " + ], + "Output Answer": [ + "import math \r\ndef find_Digits(n): \r\n if (n < 0): \r\n return 0;\r\n if (n <= 1): \r\n return 1; \r\n x = ((n * math.log10(n / math.e) + math.log10(2 * math.pi * n) /2.0)); \r\n return math.floor(x) + 1; " + ], + "split": "train" + }, + { + "Input": "Write a function to find the minimum number of platforms required for a railway/bus station.", + "Output Program": [ + "def find_platform(arr, dep, n): \r\n arr.sort() \r\n dep.sort() \r\n plat_needed = 1\r\n result = 1\r\n i = 1\r\n j = 0\r\n while (i < n and j < n): \r\n if (arr[i] <= dep[j]): \r\n plat_needed+= 1\r\n i+= 1\r\n elif (arr[i] > dep[j]): \r\n plat_needed-= 1\r\n j+= 1\r\n if (plat_needed > result): \r\n result = plat_needed \r\n return result" + ], + "Output Answer": [ + "def find_platform(arr, dep, n): \r\n arr.sort() \r\n dep.sort() \r\n plat_needed = 1\r\n result = 1\r\n i = 1\r\n j = 0\r\n while (i < n and j < n): \r\n if (arr[i] <= dep[j]): \r\n plat_needed+= 1\r\n i+= 1\r\n elif (arr[i] > dep[j]): \r\n plat_needed-= 1\r\n j+= 1\r\n if (plat_needed > result): \r\n result = plat_needed \r\n return result" + ], + "split": "train" + }, + { + "Input": "Write a python function to copy a list from a singleton tuple.", + "Output Program": [ + "def lcopy(xs):\n return xs[:]\n" + ], + "Output Answer": [ + "def lcopy(xs):\n return xs[:]\n" + ], + "split": "train" + }, + { + "Input": "Write a function to find the area of a trapezium.", + "Output Program": [ + "def area_trapezium(base1,base2,height):\r\n area = 0.5 * (base1 + base2) * height\r\n return area" + ], + "Output Answer": [ + "def area_trapezium(base1,base2,height):\r\n area = 0.5 * (base1 + base2) * height\r\n return area" + ], + "split": "train" + }, + { + "Input": "Write a python function to find sum of all prime divisors of a given number.", + "Output Program": [ + "def Sum(N): \r\n SumOfPrimeDivisors = [0]*(N + 1) \r\n for i in range(2,N + 1) : \r\n if (SumOfPrimeDivisors[i] == 0) : \r\n for j in range(i,N + 1,i) : \r\n SumOfPrimeDivisors[j] += i \r\n return SumOfPrimeDivisors[N] " + ], + "Output Answer": [ + "def Sum(N): \r\n SumOfPrimeDivisors = [0]*(N + 1) \r\n for i in range(2,N + 1) : \r\n if (SumOfPrimeDivisors[i] == 0) : \r\n for j in range(i,N + 1,i) : \r\n SumOfPrimeDivisors[j] += i \r\n return SumOfPrimeDivisors[N] " + ], + "split": "train" + }, + { + "Input": "Write a function to check if a triangle of positive area is possible with the given angles.", + "Output Program": [ + "def is_triangleexists(a,b,c): \r\n if(a != 0 and b != 0 and c != 0 and (a + b + c)== 180): \r\n if((a + b)>= c or (b + c)>= a or (a + c)>= b): \r\n return True \r\n else:\r\n return False\r\n else:\r\n return False" + ], + "Output Answer": [ + "def is_triangleexists(a,b,c): \r\n if(a != 0 and b != 0 and c != 0 and (a + b + c)== 180): \r\n if((a + b)>= c or (b + c)>= a or (a + c)>= b): \r\n return True \r\n else:\r\n return False\r\n else:\r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a python function to find sum of inverse of divisors.", + "Output Program": [ + "def Sum_of_Inverse_Divisors(N,Sum): \r\n ans = float(Sum)*1.0 /float(N); \r\n return round(ans,2); " + ], + "Output Answer": [ + "def Sum_of_Inverse_Divisors(N,Sum): \r\n ans = float(Sum)*1.0 /float(N); \r\n return round(ans,2); " + ], + "split": "train" + }, + { + "Input": "Write a python function to remove negative numbers from a list.", + "Output Program": [ + "def remove_negs(num_list): \r\n for item in num_list: \r\n if item < 0: \r\n num_list.remove(item) \r\n return num_list" + ], + "Output Answer": [ + "def remove_negs(num_list): \r\n for item in num_list: \r\n if item < 0: \r\n num_list.remove(item) \r\n return num_list" + ], + "split": "train" + }, + { + "Input": "Write a python function to find sum of odd factors of a number.", + "Output Program": [ + "import math\r\ndef sum_of_odd_Factors(n): \r\n res = 1\r\n while n % 2 == 0: \r\n n = n // 2 \r\n for i in range(3,int(math.sqrt(n) + 1)): \r\n count = 0\r\n curr_sum = 1\r\n curr_term = 1\r\n while n % i == 0: \r\n count+=1 \r\n n = n // i \r\n curr_term *= i \r\n curr_sum += curr_term \r\n res *= curr_sum \r\n if n >= 2: \r\n res *= (1 + n) \r\n return res " + ], + "Output Answer": [ + "import math\r\ndef sum_of_odd_Factors(n): \r\n res = 1\r\n while n % 2 == 0: \r\n n = n // 2 \r\n for i in range(3,int(math.sqrt(n) + 1)): \r\n count = 0\r\n curr_sum = 1\r\n curr_term = 1\r\n while n % i == 0: \r\n count+=1 \r\n n = n // i \r\n curr_term *= i \r\n curr_sum += curr_term \r\n res *= curr_sum \r\n if n >= 2: \r\n res *= (1 + n) \r\n return res " + ], + "split": "train" + }, + { + "Input": "Write a function which accepts an arbitrary list and converts it to a heap using heap queue algorithm.", + "Output Program": [ + "import heapq as hq\r\ndef raw_heap(rawheap):\r\n hq.heapify(rawheap)\r\n return rawheap" + ], + "Output Answer": [ + "import heapq as hq\r\ndef raw_heap(rawheap):\r\n hq.heapify(rawheap)\r\n return rawheap" + ], + "split": "train" + }, + { + "Input": "Write a python function to check for even parity of a given number.", + "Output Program": [ + "def check_Even_Parity(x): \r\n parity = 0\r\n while (x != 0): \r\n x = x & (x - 1) \r\n parity += 1\r\n if (parity % 2 == 0): \r\n return True\r\n else: \r\n return False" + ], + "Output Answer": [ + "def check_Even_Parity(x): \r\n parity = 0\r\n while (x != 0): \r\n x = x & (x - 1) \r\n parity += 1\r\n if (parity % 2 == 0): \r\n return True\r\n else: \r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a python function to find minimum adjacent swaps required to sort binary array.", + "Output Program": [ + "def find_Min_Swaps(arr,n) : \r\n noOfZeroes = [0] * n \r\n count = 0 \r\n noOfZeroes[n - 1] = 1 - arr[n - 1] \r\n for i in range(n-2,-1,-1) : \r\n noOfZeroes[i] = noOfZeroes[i + 1] \r\n if (arr[i] == 0) : \r\n noOfZeroes[i] = noOfZeroes[i] + 1\r\n for i in range(0,n) : \r\n if (arr[i] == 1) : \r\n count = count + noOfZeroes[i] \r\n return count " + ], + "Output Answer": [ + "def find_Min_Swaps(arr,n) : \r\n noOfZeroes = [0] * n \r\n count = 0 \r\n noOfZeroes[n - 1] = 1 - arr[n - 1] \r\n for i in range(n-2,-1,-1) : \r\n noOfZeroes[i] = noOfZeroes[i + 1] \r\n if (arr[i] == 0) : \r\n noOfZeroes[i] = noOfZeroes[i] + 1\r\n for i in range(0,n) : \r\n if (arr[i] == 1) : \r\n count = count + noOfZeroes[i] \r\n return count " + ], + "split": "train" + }, + { + "Input": "Write a function to list out the list of given strings individually using map function.", + "Output Program": [ + "def listify_list(list1):\r\n result = list(map(list,list1)) \r\n return result " + ], + "Output Answer": [ + "def listify_list(list1):\r\n result = list(map(list,list1)) \r\n return result " + ], + "split": "train" + }, + { + "Input": "Write a function to count number of lists in a given list of lists and square the count.", + "Output Program": [ + "def count_list(input_list): \r\n return (len(input_list))**2" + ], + "Output Answer": [ + "def count_list(input_list): \r\n return (len(input_list))**2" + ], + "split": "train" + }, + { + "Input": "Write a function to generate all sublists of a given list.", + "Output Program": [ + "from itertools import combinations\r\ndef sub_lists(my_list):\r\n\tsubs = []\r\n\tfor i in range(0, len(my_list)+1):\r\n\t temp = [list(x) for x in combinations(my_list, i)]\r\n\t if len(temp)>0:\r\n\t subs.extend(temp)\r\n\treturn subs" + ], + "Output Answer": [ + "from itertools import combinations\r\ndef sub_lists(my_list):\r\n\tsubs = []\r\n\tfor i in range(0, len(my_list)+1):\r\n\t temp = [list(x) for x in combinations(my_list, i)]\r\n\t if len(temp)>0:\r\n\t subs.extend(temp)\r\n\treturn subs" + ], + "split": "train" + }, + { + "Input": "Write a function to check whether the given string is ending with only alphanumeric characters or not using regex.", + "Output Program": [ + "import re \r\nregex = '[a-zA-z0-9]$'\r\ndef check_alphanumeric(string): \r\n\tif(re.search(regex, string)): \r\n\t\treturn (\"Accept\") \r\n\telse: \r\n\t\treturn (\"Discard\") " + ], + "Output Answer": [ + "import re \r\nregex = '[a-zA-z0-9]$'\r\ndef check_alphanumeric(string): \r\n\tif(re.search(regex, string)): \r\n\t\treturn (\"Accept\") \r\n\telse: \r\n\t\treturn (\"Discard\") " + ], + "split": "train" + }, + { + "Input": "Write a function to find all anagrams of a string in a given list of strings using lambda function.", + "Output Program": [ + "from collections import Counter \r\ndef anagram_lambda(texts,str):\r\n result = list(filter(lambda x: (Counter(str) == Counter(x)), texts)) \r\n return result" + ], + "Output Answer": [ + "from collections import Counter \r\ndef anagram_lambda(texts,str):\r\n result = list(filter(lambda x: (Counter(str) == Counter(x)), texts)) \r\n return result" + ], + "split": "train" + }, + { + "Input": "Write a function to find the occurrences of n most common words in a given text.", + "Output Program": [ + "from collections import Counter\r\nimport re\r\ndef n_common_words(text,n):\r\n words = re.findall('\\w+',text)\r\n n_common_words= Counter(words).most_common(n)\r\n return list(n_common_words)" + ], + "Output Answer": [ + "from collections import Counter\r\nimport re\r\ndef n_common_words(text,n):\r\n words = re.findall('\\w+',text)\r\n n_common_words= Counter(words).most_common(n)\r\n return list(n_common_words)" + ], + "split": "train" + }, + { + "Input": "Write a function to find the length of the longest sub-sequence such that elements in the subsequences are consecutive integers.", + "Output Program": [ + "def find_longest_conseq_subseq(arr, n): \r\n\tans = 0\r\n\tcount = 0\r\n\tarr.sort() \r\n\tv = [] \r\n\tv.append(arr[0]) \r\n\tfor i in range(1, n): \r\n\t\tif (arr[i] != arr[i - 1]): \r\n\t\t\tv.append(arr[i]) \r\n\tfor i in range(len(v)): \r\n\t\tif (i > 0 and v[i] == v[i - 1] + 1): \r\n\t\t\tcount += 1\r\n\t\telse: \r\n\t\t\tcount = 1\r\n\t\tans = max(ans, count) \r\n\treturn ans " + ], + "Output Answer": [ + "def find_longest_conseq_subseq(arr, n): \r\n\tans = 0\r\n\tcount = 0\r\n\tarr.sort() \r\n\tv = [] \r\n\tv.append(arr[0]) \r\n\tfor i in range(1, n): \r\n\t\tif (arr[i] != arr[i - 1]): \r\n\t\t\tv.append(arr[i]) \r\n\tfor i in range(len(v)): \r\n\t\tif (i > 0 and v[i] == v[i - 1] + 1): \r\n\t\t\tcount += 1\r\n\t\telse: \r\n\t\t\tcount = 1\r\n\t\tans = max(ans, count) \r\n\treturn ans " + ], + "split": "train" + }, + { + "Input": "Write a function to find palindromes in a given list of strings using lambda function.", + "Output Program": [ + "def palindrome_lambda(texts):\r\n result = list(filter(lambda x: (x == \"\".join(reversed(x))), texts))\r\n return result" + ], + "Output Answer": [ + "def palindrome_lambda(texts):\r\n result = list(filter(lambda x: (x == \"\".join(reversed(x))), texts))\r\n return result" + ], + "split": "train" + }, + { + "Input": "Write a function to print n-times a list using map function.", + "Output Program": [ + "def ntimes_list(nums,n):\r\n result = map(lambda x:n*x, nums) \r\n return list(result)" + ], + "Output Answer": [ + "def ntimes_list(nums,n):\r\n result = map(lambda x:n*x, nums) \r\n return list(result)" + ], + "split": "train" + }, + { + "Input": "Write a function to check whether the given month name contains 31 days or not.", + "Output Program": [ + "def check_monthnumb(monthname2):\r\n if(monthname2==\"January\" or monthname2==\"March\"or monthname2==\"May\" or monthname2==\"July\" or monthname2==\"Augest\" or monthname2==\"October\" or monthname2==\"December\"):\r\n return True\r\n else:\r\n return False" + ], + "Output Answer": [ + "def check_monthnumb(monthname2):\r\n if(monthname2==\"January\" or monthname2==\"March\"or monthname2==\"May\" or monthname2==\"July\" or monthname2==\"Augest\" or monthname2==\"October\" or monthname2==\"December\"):\r\n return True\r\n else:\r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a python function to add a minimum number such that the sum of array becomes even.", + "Output Program": [ + "def min_Num(arr,n): \r\n odd = 0\r\n for i in range(n): \r\n if (arr[i] % 2): \r\n odd += 1 \r\n if (odd % 2): \r\n return 1\r\n return 2" + ], + "Output Answer": [ + "def min_Num(arr,n): \r\n odd = 0\r\n for i in range(n): \r\n if (arr[i] % 2): \r\n odd += 1 \r\n if (odd % 2): \r\n return 1\r\n return 2" + ], + "split": "train" + }, + { + "Input": "Write a python function to find the length of the last word in a given string.", + "Output Program": [ + "def length_Of_Last_Word(a): \r\n l = 0\r\n x = a.strip() \r\n for i in range(len(x)): \r\n if x[i] == \" \": \r\n l = 0\r\n else: \r\n l += 1\r\n return l " + ], + "Output Answer": [ + "def length_Of_Last_Word(a): \r\n l = 0\r\n x = a.strip() \r\n for i in range(len(x)): \r\n if x[i] == \" \": \r\n l = 0\r\n else: \r\n l += 1\r\n return l " + ], + "split": "train" + }, + { + "Input": "Write a function to remove sublists from a given list of lists, which are outside a given range.", + "Output Program": [ + "def remove_list_range(list1, leftrange, rigthrange):\r\n result = [i for i in list1 if (min(i)>=leftrange and max(i)<=rigthrange)]\r\n return result" + ], + "Output Answer": [ + "def remove_list_range(list1, leftrange, rigthrange):\r\n result = [i for i in list1 if (min(i)>=leftrange and max(i)<=rigthrange)]\r\n return result" + ], + "split": "train" + }, + { + "Input": "Write a function to calculate the sum of the positive numbers of a given list of numbers using lambda function.", + "Output Program": [ + "def sum_positivenum(nums):\r\n sum_positivenum = list(filter(lambda nums:nums>0,nums))\r\n return sum(sum_positivenum)" + ], + "Output Answer": [ + "def sum_positivenum(nums):\r\n sum_positivenum = list(filter(lambda nums:nums>0,nums))\r\n return sum(sum_positivenum)" + ], + "split": "train" + }, + { + "Input": "Write a python function to check whether the given strings are rotations of each other or not.", + "Output Program": [ + "def are_Rotations(string1,string2): \r\n size1 = len(string1) \r\n size2 = len(string2) \r\n temp = '' \r\n if size1 != size2: \r\n return False\r\n temp = string1 + string1 \r\n if (temp.count(string2)> 0): \r\n return True\r\n else: \r\n return False" + ], + "Output Answer": [ + "def are_Rotations(string1,string2): \r\n size1 = len(string1) \r\n size2 = len(string2) \r\n temp = '' \r\n if size1 != size2: \r\n return False\r\n temp = string1 + string1 \r\n if (temp.count(string2)> 0): \r\n return True\r\n else: \r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a function to solve the fibonacci sequence using recursion.", + "Output Program": [ + "def fibonacci(n):\r\n if n == 1 or n == 2:\r\n return 1\r\n else:\r\n return (fibonacci(n - 1) + (fibonacci(n - 2)))" + ], + "Output Answer": [ + "def fibonacci(n):\r\n if n == 1 or n == 2:\r\n return 1\r\n else:\r\n return (fibonacci(n - 1) + (fibonacci(n - 2)))" + ], + "split": "train" + }, + { + "Input": "Write a python function to check if the string is a concatenation of another string.", + "Output Program": [ + "def check_Concat(str1,str2):\r\n N = len(str1)\r\n M = len(str2)\r\n if (N % M != 0):\r\n return False\r\n for i in range(N):\r\n if (str1[i] != str2[i % M]):\r\n return False \r\n return True" + ], + "Output Answer": [ + "def check_Concat(str1,str2):\r\n N = len(str1)\r\n M = len(str2)\r\n if (N % M != 0):\r\n return False\r\n for i in range(N):\r\n if (str1[i] != str2[i % M]):\r\n return False \r\n return True" + ], + "split": "train" + }, + { + "Input": "Write a function to find the minimum difference in the tuple pairs of given tuples.", + "Output Program": [ + "def min_difference(test_list):\r\n temp = [abs(b - a) for a, b in test_list]\r\n res = min(temp)\r\n return (res) " + ], + "Output Answer": [ + "def min_difference(test_list):\r\n temp = [abs(b - a) for a, b in test_list]\r\n res = min(temp)\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a python function to find lcm of two positive integers.", + "Output Program": [ + "def lcm(x, y):\r\n if x > y:\r\n z = x\r\n else:\r\n z = y\r\n while(True):\r\n if((z % x == 0) and (z % y == 0)):\r\n lcm = z\r\n break\r\n z += 1\r\n return lcm" + ], + "Output Answer": [ + "def lcm(x, y):\r\n if x > y:\r\n z = x\r\n else:\r\n z = y\r\n while(True):\r\n if((z % x == 0) and (z % y == 0)):\r\n lcm = z\r\n break\r\n z += 1\r\n return lcm" + ], + "split": "train" + }, + { + "Input": "Write a python function to sort the given string.", + "Output Program": [ + "def sort_String(str) : \r\n str = ''.join(sorted(str)) \r\n return (str) " + ], + "Output Answer": [ + "def sort_String(str) : \r\n str = ''.join(sorted(str)) \r\n return (str) " + ], + "split": "train" + }, + { + "Input": "Write a function to check if the given tuple contains only k elements.", + "Output Program": [ + "def check_tuples(test_tuple, K):\r\n res = all(ele in K for ele in test_tuple)\r\n return (res) " + ], + "Output Answer": [ + "def check_tuples(test_tuple, K):\r\n res = all(ele in K for ele in test_tuple)\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a function that matches a string that has an 'a' followed by anything, ending in 'b' by using regex.", + "Output Program": [ + "import re\r\ndef text_match(text):\r\n patterns = 'a.*?b$'\r\n if re.search(patterns, text):\r\n return ('Found a match!')\r\n else:\r\n return ('Not matched!')" + ], + "Output Answer": [ + "import re\r\ndef text_match(text):\r\n patterns = 'a.*?b$'\r\n if re.search(patterns, text):\r\n return ('Found a match!')\r\n else:\r\n return ('Not matched!')" + ], + "split": "train" + }, + { + "Input": "Write a python function to find number of solutions in quadratic equation.", + "Output Program": [ + "def Check_Solution(a,b,c) : \r\n if ((b*b) - (4*a*c)) > 0 : \r\n return (\"2 solutions\") \r\n elif ((b*b) - (4*a*c)) == 0 : \r\n return (\"1 solution\") \r\n else : \r\n return (\"No solutions\") " + ], + "Output Answer": [ + "def Check_Solution(a,b,c) : \r\n if ((b*b) - (4*a*c)) > 0 : \r\n return (\"2 solutions\") \r\n elif ((b*b) - (4*a*c)) == 0 : \r\n return (\"1 solution\") \r\n else : \r\n return (\"No solutions\") " + ], + "split": "train" + }, + { + "Input": "Write a function to find the sum of first even and odd number of a given list.", + "Output Program": [ + "def sum_even_odd(list1):\r\n first_even = next((el for el in list1 if el%2==0),-1)\r\n first_odd = next((el for el in list1 if el%2!=0),-1)\r\n return (first_even+first_odd)" + ], + "Output Answer": [ + "def sum_even_odd(list1):\r\n first_even = next((el for el in list1 if el%2==0),-1)\r\n first_odd = next((el for el in list1 if el%2!=0),-1)\r\n return (first_even+first_odd)" + ], + "split": "train" + }, + { + "Input": "Write a function to caluclate perimeter of a parallelogram.", + "Output Program": [ + "def parallelogram_perimeter(b,h):\r\n perimeter=2*(b*h)\r\n return perimeter" + ], + "Output Answer": [ + "def parallelogram_perimeter(b,h):\r\n perimeter=2*(b*h)\r\n return perimeter" + ], + "split": "train" + }, + { + "Input": "Write a function to find numbers divisible by m and n from a list of numbers using lambda function.", + "Output Program": [ + "def div_of_nums(nums,m,n):\r\n result = list(filter(lambda x: (x % m == 0 and x % n == 0), nums)) \r\n return result" + ], + "Output Answer": [ + "def div_of_nums(nums,m,n):\r\n result = list(filter(lambda x: (x % m == 0 and x % n == 0), nums)) \r\n return result" + ], + "split": "train" + }, + { + "Input": "Write a python function to check whether all the bits are within a given range or not.", + "Output Program": [ + "def all_Bits_Set_In_The_Given_Range(n,l,r): \r\n num = ((1 << r) - 1) ^ ((1 << (l - 1)) - 1) \r\n new_num = n & num \r\n if (num == new_num): \r\n return True\r\n return False" + ], + "Output Answer": [ + "def all_Bits_Set_In_The_Given_Range(n,l,r): \r\n num = ((1 << r) - 1) ^ ((1 << (l - 1)) - 1) \r\n new_num = n & num \r\n if (num == new_num): \r\n return True\r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a python function to check whether the two given strings are isomorphic to each other or not.", + "Output Program": [ + "def is_Isomorphic(str1,str2): \r\n dict_str1 = {}\r\n dict_str2 = {}\r\n for i, value in enumerate(str1):\r\n dict_str1[value] = dict_str1.get(value,[]) + [i] \r\n for j, value in enumerate(str2):\r\n dict_str2[value] = dict_str2.get(value,[]) + [j]\r\n if sorted(dict_str1.values()) == sorted(dict_str2.values()):\r\n return True\r\n else:\r\n return False" + ], + "Output Answer": [ + "def is_Isomorphic(str1,str2): \r\n dict_str1 = {}\r\n dict_str2 = {}\r\n for i, value in enumerate(str1):\r\n dict_str1[value] = dict_str1.get(value,[]) + [i] \r\n for j, value in enumerate(str2):\r\n dict_str2[value] = dict_str2.get(value,[]) + [j]\r\n if sorted(dict_str1.values()) == sorted(dict_str2.values()):\r\n return True\r\n else:\r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a function to add all the numbers in a list and divide it with the length of the list.", + "Output Program": [ + "def sum_num(numbers):\r\n total = 0\r\n for x in numbers:\r\n total += x\r\n return total/len(numbers) " + ], + "Output Answer": [ + "def sum_num(numbers):\r\n total = 0\r\n for x in numbers:\r\n total += x\r\n return total/len(numbers) " + ], + "split": "train" + }, + { + "Input": "Write a python function to check whether the given number is odd or not using bitwise operator.", + "Output Program": [ + "def is_odd(n) : \r\n if (n^1 == n-1) :\r\n return True; \r\n else :\r\n return False; " + ], + "Output Answer": [ + "def is_odd(n) : \r\n if (n^1 == n-1) :\r\n return True; \r\n else :\r\n return False; " + ], + "split": "train" + }, + { + "Input": "Write a function to substract the elements of the given nested tuples.", + "Output Program": [ + "def substract_elements(test_tup1, test_tup2):\r\n res = tuple(tuple(a - b for a, b in zip(tup1, tup2))\r\n for tup1, tup2 in zip(test_tup1, test_tup2))\r\n return (res) " + ], + "Output Answer": [ + "def substract_elements(test_tup1, test_tup2):\r\n res = tuple(tuple(a - b for a, b in zip(tup1, tup2))\r\n for tup1, tup2 in zip(test_tup1, test_tup2))\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a function to reverse each list in a given list of lists.", + "Output Program": [ + "def reverse_list_lists(lists):\r\n for l in lists:\r\n l.sort(reverse = True)\r\n return lists " + ], + "Output Answer": [ + "def reverse_list_lists(lists):\r\n for l in lists:\r\n l.sort(reverse = True)\r\n return lists " + ], + "split": "train" + }, + { + "Input": "Write a python function to find the index of an extra element present in one sorted array.", + "Output Program": [ + "def find_Extra(arr1,arr2,n) : \r\n for i in range(0, n) : \r\n if (arr1[i] != arr2[i]) : \r\n return i \r\n return n " + ], + "Output Answer": [ + "def find_Extra(arr1,arr2,n) : \r\n for i in range(0, n) : \r\n if (arr1[i] != arr2[i]) : \r\n return i \r\n return n " + ], + "split": "train" + }, + { + "Input": "Write a python function to check whether the given two numbers have same number of digits or not.", + "Output Program": [ + "def same_Length(A,B): \r\n while (A > 0 and B > 0): \r\n A = A / 10; \r\n B = B / 10; \r\n if (A == 0 and B == 0): \r\n return True; \r\n return False; " + ], + "Output Answer": [ + "def same_Length(A,B): \r\n while (A > 0 and B > 0): \r\n A = A / 10; \r\n B = B / 10; \r\n if (A == 0 and B == 0): \r\n return True; \r\n return False; " + ], + "split": "train" + }, + { + "Input": "Write a function to remove multiple spaces in a string.", + "Output Program": [ + "import re\r\ndef remove_spaces(text):\r\n return (re.sub(' +',' ',text))" + ], + "Output Answer": [ + "import re\r\ndef remove_spaces(text):\r\n return (re.sub(' +',' ',text))" + ], + "split": "train" + }, + { + "Input": "Write a python function to get the last element of each sublist.", + "Output Program": [ + "def Extract(lst): \r\n return [item[-1] for item in lst] " + ], + "Output Answer": [ + "def Extract(lst): \r\n return [item[-1] for item in lst] " + ], + "split": "train" + }, + { + "Input": "Write a function to convert the given string of float type into tuple.", + "Output Program": [ + "def float_to_tuple(test_str):\r\n res = tuple(map(float, test_str.split(', ')))\r\n return (res) " + ], + "Output Answer": [ + "def float_to_tuple(test_str):\r\n res = tuple(map(float, test_str.split(', ')))\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a function to find the maximum sum of subsequences of given array with no adjacent elements.", + "Output Program": [ + "def max_sum_subseq(A):\r\n n = len(A)\r\n if n == 1:\r\n return A[0]\r\n look_up = [None] * n\r\n look_up[0] = A[0]\r\n look_up[1] = max(A[0], A[1])\r\n for i in range(2, n):\r\n look_up[i] = max(look_up[i - 1], look_up[i - 2] + A[i])\r\n look_up[i] = max(look_up[i], A[i])\r\n return look_up[n - 1]" + ], + "Output Answer": [ + "def max_sum_subseq(A):\r\n n = len(A)\r\n if n == 1:\r\n return A[0]\r\n look_up = [None] * n\r\n look_up[0] = A[0]\r\n look_up[1] = max(A[0], A[1])\r\n for i in range(2, n):\r\n look_up[i] = max(look_up[i - 1], look_up[i - 2] + A[i])\r\n look_up[i] = max(look_up[i], A[i])\r\n return look_up[n - 1]" + ], + "split": "train" + }, + { + "Input": "Write a function to sort a list in increasing order by the last element in each tuple from a given list of non-empty tuples.", + "Output Program": [ + "def last(n):\r\n return n[-1]\r\ndef sort_list_last(tuples):\r\n return sorted(tuples, key=last)" + ], + "Output Answer": [ + "def last(n):\r\n return n[-1]\r\ndef sort_list_last(tuples):\r\n return sorted(tuples, key=last)" + ], + "split": "train" + }, + { + "Input": "Write a python function to check whether the word is present in a given sentence or not.", + "Output Program": [ + "def is_Word_Present(sentence,word): \r\n s = sentence.split(\" \") \r\n for i in s: \r\n if (i == word): \r\n return True\r\n return False" + ], + "Output Answer": [ + "def is_Word_Present(sentence,word): \r\n s = sentence.split(\" \") \r\n for i in s: \r\n if (i == word): \r\n return True\r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a function to extract specified number of elements from a given list, which follow each other continuously.", + "Output Program": [ + "from itertools import groupby \r\ndef extract_elements(numbers, n):\r\n result = [i for i, j in groupby(numbers) if len(list(j)) == n] \r\n return result" + ], + "Output Answer": [ + "from itertools import groupby \r\ndef extract_elements(numbers, n):\r\n result = [i for i, j in groupby(numbers) if len(list(j)) == n] \r\n return result" + ], + "split": "train" + }, + { + "Input": "Write a python function to check whether an array can be sorted or not by picking only the corner elements.", + "Output Program": [ + "def check(arr,n): \r\n g = 0 \r\n for i in range(1,n): \r\n if (arr[i] - arr[i - 1] > 0 and g == 1): \r\n return False\r\n if (arr[i] - arr[i] < 0): \r\n g = 1\r\n return True" + ], + "Output Answer": [ + "def check(arr,n): \r\n g = 0 \r\n for i in range(1,n): \r\n if (arr[i] - arr[i - 1] > 0 and g == 1): \r\n return False\r\n if (arr[i] - arr[i] < 0): \r\n g = 1\r\n return True" + ], + "split": "train" + }, + { + "Input": "Write a function where a string will start with a specific number.", + "Output Program": [ + "import re\r\ndef match_num(string):\r\n text = re.compile(r\"^5\")\r\n if text.match(string):\r\n return True\r\n else:\r\n return False" + ], + "Output Answer": [ + "import re\r\ndef match_num(string):\r\n text = re.compile(r\"^5\")\r\n if text.match(string):\r\n return True\r\n else:\r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a function to find the smallest multiple of the first n numbers.", + "Output Program": [ + "def smallest_multiple(n):\r\n if (n<=2):\r\n return n\r\n i = n * 2\r\n factors = [number for number in range(n, 1, -1) if number * 2 > n]\r\n while True:\r\n for a in factors:\r\n if i % a != 0:\r\n i += n\r\n break\r\n if (a == factors[-1] and i % a == 0):\r\n return i" + ], + "Output Answer": [ + "def smallest_multiple(n):\r\n if (n<=2):\r\n return n\r\n i = n * 2\r\n factors = [number for number in range(n, 1, -1) if number * 2 > n]\r\n while True:\r\n for a in factors:\r\n if i % a != 0:\r\n i += n\r\n break\r\n if (a == factors[-1] and i % a == 0):\r\n return i" + ], + "split": "train" + }, + { + "Input": "Write a function to combine two dictionaries by adding values for common keys.", + "Output Program": [ + "from collections import Counter\r\ndef add_dict(d1,d2):\r\n add_dict = Counter(d1) + Counter(d2)\r\n return add_dict" + ], + "Output Answer": [ + "from collections import Counter\r\ndef add_dict(d1,d2):\r\n add_dict = Counter(d1) + Counter(d2)\r\n return add_dict" + ], + "split": "train" + }, + { + "Input": "Write a python function to count the total unset bits from 1 to n.", + "Output Program": [ + "def count_Unset_Bits(n) : \r\n cnt = 0; \r\n for i in range(1,n + 1) : \r\n temp = i; \r\n while (temp) : \r\n if (temp % 2 == 0) : \r\n cnt += 1; \r\n temp = temp // 2; \r\n return cnt; " + ], + "Output Answer": [ + "def count_Unset_Bits(n) : \r\n cnt = 0; \r\n for i in range(1,n + 1) : \r\n temp = i; \r\n while (temp) : \r\n if (temp % 2 == 0) : \r\n cnt += 1; \r\n temp = temp // 2; \r\n return cnt; " + ], + "split": "train" + }, + { + "Input": "Write a function to return true if the given number is even else return false.", + "Output Program": [ + "def even_num(x):\r\n if x%2==0:\r\n return True\r\n else:\r\n return False" + ], + "Output Answer": [ + "def even_num(x):\r\n if x%2==0:\r\n return True\r\n else:\r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a python function to find the sum of squares of binomial co-efficients.", + "Output Program": [ + "def factorial(start,end): \r\n res = 1 \r\n for i in range(start,end + 1): \r\n res *= i \r\n return res \r\ndef sum_of_square(n): \r\n return int(factorial(n + 1, 2 * n) /factorial(1, n)) " + ], + "Output Answer": [ + "def factorial(start,end): \r\n res = 1 \r\n for i in range(start,end + 1): \r\n res *= i \r\n return res \r\ndef sum_of_square(n): \r\n return int(factorial(n + 1, 2 * n) /factorial(1, n)) " + ], + "split": "train" + }, + { + "Input": "Write a function to extract year, month and date from a url by using regex.", + "Output Program": [ + "import re\r\ndef extract_date(url):\r\n return re.findall(r'/(\\d{4})/(\\d{1,2})/(\\d{1,2})/', url)" + ], + "Output Answer": [ + "import re\r\ndef extract_date(url):\r\n return re.findall(r'/(\\d{4})/(\\d{1,2})/(\\d{1,2})/', url)" + ], + "split": "train" + }, + { + "Input": "Write a function to print the first n lucky numbers.", + "Output Program": [ + "def lucky_num(n):\r\n List=range(-1,n*n+9,2)\r\n i=2\r\n while List[i:]:List=sorted(set(List)-set(List[List[i]::List[i]]));i+=1\r\n return List[1:n+1]" + ], + "Output Answer": [ + "def lucky_num(n):\r\n List=range(-1,n*n+9,2)\r\n i=2\r\n while List[i:]:List=sorted(set(List)-set(List[List[i]::List[i]]));i+=1\r\n return List[1:n+1]" + ], + "split": "train" + }, + { + "Input": "Write a function to find the fixed point in the given array.", + "Output Program": [ + "def find_fixed_point(arr, n): \r\n\tfor i in range(n): \r\n\t\tif arr[i] is i: \r\n\t\t\treturn i \r\n\treturn -1" + ], + "Output Answer": [ + "def find_fixed_point(arr, n): \r\n\tfor i in range(n): \r\n\t\tif arr[i] is i: \r\n\t\t\treturn i \r\n\treturn -1" + ], + "split": "train" + }, + { + "Input": "Write a function to find the previous palindrome of a specified number.", + "Output Program": [ + "def previous_palindrome(num):\r\n for x in range(num-1,0,-1):\r\n if str(x) == str(x)[::-1]:\r\n return x" + ], + "Output Answer": [ + "def previous_palindrome(num):\r\n for x in range(num-1,0,-1):\r\n if str(x) == str(x)[::-1]:\r\n return x" + ], + "split": "train" + }, + { + "Input": "Write a function to validate a gregorian date.", + "Output Program": [ + "import datetime\r\ndef check_date(m, d, y):\r\n try:\r\n m, d, y = map(int, (m, d, y))\r\n datetime.date(y, m, d)\r\n return True\r\n except ValueError:\r\n return False" + ], + "Output Answer": [ + "import datetime\r\ndef check_date(m, d, y):\r\n try:\r\n m, d, y = map(int, (m, d, y))\r\n datetime.date(y, m, d)\r\n return True\r\n except ValueError:\r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a function to compute maximum product of three numbers of a given array of integers using heap queue algorithm.", + "Output Program": [ + "def maximum_product(nums):\r\n import heapq\r\n a, b = heapq.nlargest(3, nums), heapq.nsmallest(2, nums)\r\n return max(a[0] * a[1] * a[2], a[0] * b[0] * b[1])" + ], + "Output Answer": [ + "def maximum_product(nums):\r\n import heapq\r\n a, b = heapq.nlargest(3, nums), heapq.nsmallest(2, nums)\r\n return max(a[0] * a[1] * a[2], a[0] * b[0] * b[1])" + ], + "split": "train" + }, + { + "Input": "Write a function to find ln, m lobb number.", + "Output Program": [ + "def binomial_coeff(n, k): \r\n\tC = [[0 for j in range(k + 1)] \r\n\t\t\tfor i in range(n + 1)] \r\n\tfor i in range(0, n + 1): \r\n\t\tfor j in range(0, min(i, k) + 1): \r\n\t\t\tif (j == 0 or j == i): \r\n\t\t\t\tC[i][j] = 1\r\n\t\t\telse: \r\n\t\t\t\tC[i][j] = (C[i - 1][j - 1] \r\n\t\t\t\t\t\t\t+ C[i - 1][j]) \r\n\treturn C[n][k] \r\ndef lobb_num(n, m): \r\n\treturn (((2 * m + 1) *\r\n\t\tbinomial_coeff(2 * n, m + n)) \r\n\t\t\t\t\t/ (m + n + 1))" + ], + "Output Answer": [ + "def binomial_coeff(n, k): \r\n\tC = [[0 for j in range(k + 1)] \r\n\t\t\tfor i in range(n + 1)] \r\n\tfor i in range(0, n + 1): \r\n\t\tfor j in range(0, min(i, k) + 1): \r\n\t\t\tif (j == 0 or j == i): \r\n\t\t\t\tC[i][j] = 1\r\n\t\t\telse: \r\n\t\t\t\tC[i][j] = (C[i - 1][j - 1] \r\n\t\t\t\t\t\t\t+ C[i - 1][j]) \r\n\treturn C[n][k] \r\ndef lobb_num(n, m): \r\n\treturn (((2 * m + 1) *\r\n\t\tbinomial_coeff(2 * n, m + n)) \r\n\t\t\t\t\t/ (m + n + 1))" + ], + "split": "train" + }, + { + "Input": "Write a function to check for a number at the end of a string.", + "Output Program": [ + "import re\r\ndef end_num(string):\r\n text = re.compile(r\".*[0-9]$\")\r\n if text.match(string):\r\n return True\r\n else:\r\n return False" + ], + "Output Answer": [ + "import re\r\ndef end_num(string):\r\n text = re.compile(r\".*[0-9]$\")\r\n if text.match(string):\r\n return True\r\n else:\r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a python function to check whether the given string is made up of two alternating characters or not.", + "Output Program": [ + "def is_Two_Alter(s): \r\n for i in range (len( s) - 2) : \r\n if (s[i] != s[i + 2]) : \r\n return False\r\n if (s[0] == s[1]): \r\n return False\r\n return True" + ], + "Output Answer": [ + "def is_Two_Alter(s): \r\n for i in range (len( s) - 2) : \r\n if (s[i] != s[i + 2]) : \r\n return False\r\n if (s[0] == s[1]): \r\n return False\r\n return True" + ], + "split": "train" + }, + { + "Input": "Write a function to rearrange positive and negative numbers in a given array using lambda function.", + "Output Program": [ + "def rearrange_numbs(array_nums):\r\n result = sorted(array_nums, key = lambda i: 0 if i == 0 else -1 / i)\r\n return result " + ], + "Output Answer": [ + "def rearrange_numbs(array_nums):\r\n result = sorted(array_nums, key = lambda i: 0 if i == 0 else -1 / i)\r\n return result " + ], + "split": "train" + }, + { + "Input": "Write a function to find if there is a triplet in the array whose sum is equal to a given value.", + "Output Program": [ + "def find_triplet_array(A, arr_size, sum): \r\n\tfor i in range( 0, arr_size-2): \r\n\t\tfor j in range(i + 1, arr_size-1): \r\n\t\t\tfor k in range(j + 1, arr_size): \r\n\t\t\t\tif A[i] + A[j] + A[k] == sum: \r\n\t\t\t\t\treturn A[i],A[j],A[k] \r\n\t\t\t\t\treturn True\r\n\treturn False" + ], + "Output Answer": [ + "def find_triplet_array(A, arr_size, sum): \r\n\tfor i in range( 0, arr_size-2): \r\n\t\tfor j in range(i + 1, arr_size-1): \r\n\t\t\tfor k in range(j + 1, arr_size): \r\n\t\t\t\tif A[i] + A[j] + A[k] == sum: \r\n\t\t\t\t\treturn A[i],A[j],A[k] \r\n\t\t\t\t\treturn True\r\n\treturn False" + ], + "split": "train" + }, + { + "Input": "Write a function to find the sequences of one upper case letter followed by lower case letters.", + "Output Program": [ + "import re\r\ndef text_uppercase_lowercase(text):\r\n patterns = '[A-Z]+[a-z]+$'\r\n if re.search(patterns, text):\r\n return 'Found a match!'\r\n else:\r\n return ('Not matched!')" + ], + "Output Answer": [ + "import re\r\ndef text_uppercase_lowercase(text):\r\n patterns = '[A-Z]+[a-z]+$'\r\n if re.search(patterns, text):\r\n return 'Found a match!'\r\n else:\r\n return ('Not matched!')" + ], + "split": "train" + }, + { + "Input": "Write a function to count coin change.", + "Output Program": [ + "def coin_change(S, m, n): \r\n table = [[0 for x in range(m)] for x in range(n+1)] \r\n for i in range(m): \r\n table[0][i] = 1\r\n for i in range(1, n+1): \r\n for j in range(m): \r\n x = table[i - S[j]][j] if i-S[j] >= 0 else 0\r\n y = table[i][j-1] if j >= 1 else 0 \r\n table[i][j] = x + y \r\n return table[n][m-1] " + ], + "Output Answer": [ + "def coin_change(S, m, n): \r\n table = [[0 for x in range(m)] for x in range(n+1)] \r\n for i in range(m): \r\n table[0][i] = 1\r\n for i in range(1, n+1): \r\n for j in range(m): \r\n x = table[i - S[j]][j] if i-S[j] >= 0 else 0\r\n y = table[i][j-1] if j >= 1 else 0 \r\n table[i][j] = x + y \r\n return table[n][m-1] " + ], + "split": "train" + }, + { + "Input": "Write a python function to multiply all items in the list.", + "Output Program": [ + "def multiply_list(items):\r\n tot = 1\r\n for x in items:\r\n tot *= x\r\n return tot" + ], + "Output Answer": [ + "def multiply_list(items):\r\n tot = 1\r\n for x in items:\r\n tot *= x\r\n return tot" + ], + "split": "train" + }, + { + "Input": "Write a function to remove all tuples with all none values in the given tuple list.", + "Output Program": [ + "def remove_tuple(test_list):\r\n res = [sub for sub in test_list if not all(ele == None for ele in sub)]\r\n return (str(res)) " + ], + "Output Answer": [ + "def remove_tuple(test_list):\r\n res = [sub for sub in test_list if not all(ele == None for ele in sub)]\r\n return (str(res)) " + ], + "split": "train" + }, + { + "Input": "Write a function to perform chunking of tuples each of size n.", + "Output Program": [ + "def chunk_tuples(test_tup, N):\r\n res = [test_tup[i : i + N] for i in range(0, len(test_tup), N)]\r\n return (res) " + ], + "Output Answer": [ + "def chunk_tuples(test_tup, N):\r\n res = [test_tup[i : i + N] for i in range(0, len(test_tup), N)]\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a function to find a pair with the highest product from a given array of integers.", + "Output Program": [ + "def max_product(arr): \r\n arr_len = len(arr) \r\n if (arr_len < 2): \r\n return None \r\n x = arr[0]; y = arr[1] \r\n for i in range(0, arr_len): \r\n for j in range(i + 1, arr_len): \r\n if (arr[i] * arr[j] > x * y): \r\n x = arr[i]; y = arr[j] \r\n return x,y " + ], + "Output Answer": [ + "def max_product(arr): \r\n arr_len = len(arr) \r\n if (arr_len < 2): \r\n return None \r\n x = arr[0]; y = arr[1] \r\n for i in range(0, arr_len): \r\n for j in range(i + 1, arr_len): \r\n if (arr[i] * arr[j] > x * y): \r\n x = arr[i]; y = arr[j] \r\n return x,y " + ], + "split": "train" + }, + { + "Input": "Write a function to find the length of the shortest string that has both str1 and str2 as subsequences.", + "Output Program": [ + "def super_seq(X, Y, m, n):\r\n\tif (not m):\r\n\t\treturn n\r\n\tif (not n):\r\n\t\treturn m\r\n\tif (X[m - 1] == Y[n - 1]):\r\n\t\treturn 1 + super_seq(X, Y, m - 1, n - 1)\r\n\treturn 1 + min(super_seq(X, Y, m - 1, n),\tsuper_seq(X, Y, m, n - 1))" + ], + "Output Answer": [ + "def super_seq(X, Y, m, n):\r\n\tif (not m):\r\n\t\treturn n\r\n\tif (not n):\r\n\t\treturn m\r\n\tif (X[m - 1] == Y[n - 1]):\r\n\t\treturn 1 + super_seq(X, Y, m - 1, n - 1)\r\n\treturn 1 + min(super_seq(X, Y, m - 1, n),\tsuper_seq(X, Y, m, n - 1))" + ], + "split": "train" + }, + { + "Input": "Write a function to find maximum of two numbers.", + "Output Program": [ + "def max_of_two( x, y ):\r\n if x > y:\r\n return x\r\n return y" + ], + "Output Answer": [ + "def max_of_two( x, y ):\r\n if x > y:\r\n return x\r\n return y" + ], + "split": "train" + }, + { + "Input": "Write a python function to calculate the product of all the numbers of a given tuple.", + "Output Program": [ + "def mutiple_tuple(nums):\r\n temp = list(nums)\r\n product = 1 \r\n for x in temp:\r\n product *= x\r\n return product" + ], + "Output Answer": [ + "def mutiple_tuple(nums):\r\n temp = list(nums)\r\n product = 1 \r\n for x in temp:\r\n product *= x\r\n return product" + ], + "split": "train" + }, + { + "Input": "Write a function to find n-th rencontres number.", + "Output Program": [ + "def binomial_coeffi(n, k): \r\n\tif (k == 0 or k == n): \r\n\t\treturn 1\r\n\treturn (binomial_coeffi(n - 1, k - 1) \r\n\t\t+ binomial_coeffi(n - 1, k)) \r\ndef rencontres_number(n, m): \r\n\tif (n == 0 and m == 0): \r\n\t\treturn 1\r\n\tif (n == 1 and m == 0): \r\n\t\treturn 0\r\n\tif (m == 0): \r\n\t\treturn ((n - 1) * (rencontres_number(n - 1, 0)+ rencontres_number(n - 2, 0))) \r\n\treturn (binomial_coeffi(n, m) * rencontres_number(n - m, 0))" + ], + "Output Answer": [ + "def binomial_coeffi(n, k): \r\n\tif (k == 0 or k == n): \r\n\t\treturn 1\r\n\treturn (binomial_coeffi(n - 1, k - 1) \r\n\t\t+ binomial_coeffi(n - 1, k)) \r\ndef rencontres_number(n, m): \r\n\tif (n == 0 and m == 0): \r\n\t\treturn 1\r\n\tif (n == 1 and m == 0): \r\n\t\treturn 0\r\n\tif (m == 0): \r\n\t\treturn ((n - 1) * (rencontres_number(n - 1, 0)+ rencontres_number(n - 2, 0))) \r\n\treturn (binomial_coeffi(n, m) * rencontres_number(n - m, 0))" + ], + "split": "train" + }, + { + "Input": "Write a function to calculate the height of the given binary tree.", + "Output Program": [ + "class Node: \r\n\tdef __init__(self, data): \r\n\t\tself.data = data \r\n\t\tself.left = None\r\n\t\tself.right = None\r\ndef max_height(node): \r\n\tif node is None: \r\n\t\treturn 0 ; \r\n\telse : \r\n\t\tleft_height = max_height(node.left) \r\n\t\tright_height = max_height(node.right) \r\n\t\tif (left_height > right_height): \r\n\t\t\treturn left_height+1\r\n\t\telse: \r\n\t\t\treturn right_height+1" + ], + "Output Answer": [ + "class Node: \r\n\tdef __init__(self, data): \r\n\t\tself.data = data \r\n\t\tself.left = None\r\n\t\tself.right = None\r\ndef max_height(node): \r\n\tif node is None: \r\n\t\treturn 0 ; \r\n\telse : \r\n\t\tleft_height = max_height(node.left) \r\n\t\tright_height = max_height(node.right) \r\n\t\tif (left_height > right_height): \r\n\t\t\treturn left_height+1\r\n\t\telse: \r\n\t\t\treturn right_height+1" + ], + "split": "train" + }, + { + "Input": "Write a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format.", + "Output Program": [ + "import re\r\ndef change_date_format(dt):\r\n return re.sub(r'(\\d{4})-(\\d{1,2})-(\\d{1,2})', '\\\\3-\\\\2-\\\\1', dt)\r\n return change_date_format(dt)" + ], + "Output Answer": [ + "import re\r\ndef change_date_format(dt):\r\n return re.sub(r'(\\d{4})-(\\d{1,2})-(\\d{1,2})', '\\\\3-\\\\2-\\\\1', dt)\r\n return change_date_format(dt)" + ], + "split": "train" + }, + { + "Input": "Write a function to count repeated items of a tuple.", + "Output Program": [ + "def count_tuplex(tuplex,value): \r\n count = tuplex.count(value)\r\n return count" + ], + "Output Answer": [ + "def count_tuplex(tuplex,value): \r\n count = tuplex.count(value)\r\n return count" + ], + "split": "train" + }, + { + "Input": "Write a function that matches a string that has an a followed by zero or more b's by using regex.", + "Output Program": [ + "import re\r\ndef text_match(text):\r\n patterns = 'ab*?'\r\n if re.search(patterns, text):\r\n return ('Found a match!')\r\n else:\r\n return ('Not matched!')" + ], + "Output Answer": [ + "import re\r\ndef text_match(text):\r\n patterns = 'ab*?'\r\n if re.search(patterns, text):\r\n return ('Found a match!')\r\n else:\r\n return ('Not matched!')" + ], + "split": "train" + }, + { + "Input": "Write a function to calculate the sum of series 1\u00b3+2\u00b3+3\u00b3+\u2026.+n\u00b3.", + "Output Program": [ + "import math \r\ndef sum_series(number):\r\n total = 0\r\n total = math.pow((number * (number + 1)) /2, 2)\r\n return total" + ], + "Output Answer": [ + "import math \r\ndef sum_series(number):\r\n total = 0\r\n total = math.pow((number * (number + 1)) /2, 2)\r\n return total" + ], + "split": "train" + }, + { + "Input": "Write a function to remove duplicate words from a given list of strings.", + "Output Program": [ + "def remove_duplic_list(l):\r\n temp = []\r\n for x in l:\r\n if x not in temp:\r\n temp.append(x)\r\n return temp" + ], + "Output Answer": [ + "def remove_duplic_list(l):\r\n temp = []\r\n for x in l:\r\n if x not in temp:\r\n temp.append(x)\r\n return temp" + ], + "split": "train" + }, + { + "Input": "Write a function to convert camel case string to snake case string by using regex.", + "Output Program": [ + "import re\r\ndef camel_to_snake(text):\r\n str1 = re.sub('(.)([A-Z][a-z]+)', r'\\1_\\2', text)\r\n return re.sub('([a-z0-9])([A-Z])', r'\\1_\\2', str1).lower()" + ], + "Output Answer": [ + "import re\r\ndef camel_to_snake(text):\r\n str1 = re.sub('(.)([A-Z][a-z]+)', r'\\1_\\2', text)\r\n return re.sub('([a-z0-9])([A-Z])', r'\\1_\\2', str1).lower()" + ], + "split": "train" + }, + { + "Input": "Write a function to find the nth delannoy number.", + "Output Program": [ + "def dealnnoy_num(n, m): \r\n\tif (m == 0 or n == 0) : \r\n\t\treturn 1\r\n\treturn dealnnoy_num(m - 1, n) + dealnnoy_num(m - 1, n - 1) + dealnnoy_num(m, n - 1)" + ], + "Output Answer": [ + "def dealnnoy_num(n, m): \r\n\tif (m == 0 or n == 0) : \r\n\t\treturn 1\r\n\treturn dealnnoy_num(m - 1, n) + dealnnoy_num(m - 1, n - 1) + dealnnoy_num(m, n - 1)" + ], + "split": "train" + }, + { + "Input": "Write a function to calculate the sum of series 1\u00b2+2\u00b2+3\u00b2+\u2026.+n\u00b2.", + "Output Program": [ + "def series_sum(number):\r\n total = 0\r\n total = (number * (number + 1) * (2 * number + 1)) / 6\r\n return total" + ], + "Output Answer": [ + "def series_sum(number):\r\n total = 0\r\n total = (number * (number + 1) * (2 * number + 1)) / 6\r\n return total" + ], + "split": "train" + }, + { + "Input": "Write a function to re-arrange the given tuples based on the given ordered list.", + "Output Program": [ + "def re_arrange_tuples(test_list, ord_list):\r\n temp = dict(test_list)\r\n res = [(key, temp[key]) for key in ord_list]\r\n return (res) " + ], + "Output Answer": [ + "def re_arrange_tuples(test_list, ord_list):\r\n temp = dict(test_list)\r\n res = [(key, temp[key]) for key in ord_list]\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a function to count the most common character in a given string.", + "Output Program": [ + "from collections import Counter \r\ndef max_char(str1):\r\n temp = Counter(str1) \r\n max_char = max(temp, key = temp.get)\r\n return max_char" + ], + "Output Answer": [ + "from collections import Counter \r\ndef max_char(str1):\r\n temp = Counter(str1) \r\n max_char = max(temp, key = temp.get)\r\n return max_char" + ], + "split": "train" + }, + { + "Input": "Write a function to find three closest elements from three sorted arrays.", + "Output Program": [ + "import sys \r\n\r\ndef find_closet(A, B, C, p, q, r): \r\n\tdiff = sys.maxsize \r\n\tres_i = 0\r\n\tres_j = 0\r\n\tres_k = 0\r\n\ti = 0\r\n\tj = 0\r\n\tk = 0\r\n\twhile(i < p and j < q and k < r): \r\n\t\tminimum = min(A[i], min(B[j], C[k])) \r\n\t\tmaximum = max(A[i], max(B[j], C[k])); \r\n\t\tif maximum-minimum < diff: \r\n\t\t\tres_i = i \r\n\t\t\tres_j = j \r\n\t\t\tres_k = k \r\n\t\t\tdiff = maximum - minimum; \r\n\t\tif diff == 0: \r\n\t\t\tbreak\r\n\t\tif A[i] == minimum: \r\n\t\t\ti = i+1\r\n\t\telif B[j] == minimum: \r\n\t\t\tj = j+1\r\n\t\telse: \r\n\t\t\tk = k+1\r\n\treturn A[res_i],B[res_j],C[res_k]" + ], + "Output Answer": [ + "import sys \r\n\r\ndef find_closet(A, B, C, p, q, r): \r\n\tdiff = sys.maxsize \r\n\tres_i = 0\r\n\tres_j = 0\r\n\tres_k = 0\r\n\ti = 0\r\n\tj = 0\r\n\tk = 0\r\n\twhile(i < p and j < q and k < r): \r\n\t\tminimum = min(A[i], min(B[j], C[k])) \r\n\t\tmaximum = max(A[i], max(B[j], C[k])); \r\n\t\tif maximum-minimum < diff: \r\n\t\t\tres_i = i \r\n\t\t\tres_j = j \r\n\t\t\tres_k = k \r\n\t\t\tdiff = maximum - minimum; \r\n\t\tif diff == 0: \r\n\t\t\tbreak\r\n\t\tif A[i] == minimum: \r\n\t\t\ti = i+1\r\n\t\telif B[j] == minimum: \r\n\t\t\tj = j+1\r\n\t\telse: \r\n\t\t\tk = k+1\r\n\treturn A[res_i],B[res_j],C[res_k]" + ], + "split": "train" + }, + { + "Input": "Write a function to sort a list of dictionaries using lambda function.", + "Output Program": [ + "def sorted_models(models):\r\n sorted_models = sorted(models, key = lambda x: x['color'])\r\n return sorted_models" + ], + "Output Answer": [ + "def sorted_models(models):\r\n sorted_models = sorted(models, key = lambda x: x['color'])\r\n return sorted_models" + ], + "split": "train" + }, + { + "Input": "Write a function to sort the given array by using heap sort.", + "Output Program": [ + "def heap_sort(arr):\r\n heapify(arr) \r\n end = len(arr) - 1\r\n while end > 0:\r\n arr[end], arr[0] = arr[0], arr[end]\r\n shift_down(arr, 0, end - 1)\r\n end -= 1\r\n return arr\r\n\r\ndef heapify(arr):\r\n start = len(arr) // 2\r\n while start >= 0:\r\n shift_down(arr, start, len(arr) - 1)\r\n start -= 1\r\ndef shift_down(arr, start, end):\r\n root = start\r\n while root * 2 + 1 <= end:\r\n child = root * 2 + 1\r\n if child + 1 <= end and arr[child] < arr[child + 1]:\r\n child += 1\r\n if child <= end and arr[root] < arr[child]:\r\n arr[root], arr[child] = arr[child], arr[root]\r\n root = child\r\n else:\r\n return\r\n" + ], + "Output Answer": [ + "def heap_sort(arr):\r\n heapify(arr) \r\n end = len(arr) - 1\r\n while end > 0:\r\n arr[end], arr[0] = arr[0], arr[end]\r\n shift_down(arr, 0, end - 1)\r\n end -= 1\r\n return arr\r\n\r\ndef heapify(arr):\r\n start = len(arr) // 2\r\n while start >= 0:\r\n shift_down(arr, start, len(arr) - 1)\r\n start -= 1\r\ndef shift_down(arr, start, end):\r\n root = start\r\n while root * 2 + 1 <= end:\r\n child = root * 2 + 1\r\n if child + 1 <= end and arr[child] < arr[child + 1]:\r\n child += 1\r\n if child <= end and arr[root] < arr[child]:\r\n arr[root], arr[child] = arr[child], arr[root]\r\n root = child\r\n else:\r\n return\r\n" + ], + "split": "train" + }, + { + "Input": "Write a function to count the elements in a list until an element is a tuple.", + "Output Program": [ + "def count_elim(num):\r\n count_elim = 0\r\n for n in num:\r\n if isinstance(n, tuple):\r\n break\r\n count_elim += 1\r\n return count_elim" + ], + "Output Answer": [ + "def count_elim(num):\r\n count_elim = 0\r\n for n in num:\r\n if isinstance(n, tuple):\r\n break\r\n count_elim += 1\r\n return count_elim" + ], + "split": "train" + }, + { + "Input": "Write a function to check if any list element is present in the given list.", + "Output Program": [ + "def check_element(test_tup, check_list):\r\n res = False\r\n for ele in check_list:\r\n if ele in test_tup:\r\n res = True\r\n break\r\n return (res) " + ], + "Output Answer": [ + "def check_element(test_tup, check_list):\r\n res = False\r\n for ele in check_list:\r\n if ele in test_tup:\r\n res = True\r\n break\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a function to combine two given sorted lists using heapq module.", + "Output Program": [ + "from heapq import merge\r\ndef combine_lists(num1,num2):\r\n combine_lists=list(merge(num1, num2))\r\n return combine_lists" + ], + "Output Answer": [ + "from heapq import merge\r\ndef combine_lists(num1,num2):\r\n combine_lists=list(merge(num1, num2))\r\n return combine_lists" + ], + "split": "train" + }, + { + "Input": "Write a function to separate and print the numbers and their position of a given string.", + "Output Program": [ + "import re\r\ndef num_position(text):\r\n for m in re.finditer(\"\\d+\", text):\r\n return m.start()" + ], + "Output Answer": [ + "import re\r\ndef num_position(text):\r\n for m in re.finditer(\"\\d+\", text):\r\n return m.start()" + ], + "split": "train" + }, + { + "Input": "Write a function to convert the given tuples into set.", + "Output Program": [ + "def tuple_to_set(t):\r\n s = set(t)\r\n return (s) " + ], + "Output Answer": [ + "def tuple_to_set(t):\r\n s = set(t)\r\n return (s) " + ], + "split": "train" + }, + { + "Input": "Write a function to find the most common elements and their counts of a specified text.", + "Output Program": [ + "from collections import Counter \r\ndef most_common_elem(s,a):\r\n most_common_elem=Counter(s).most_common(a)\r\n return most_common_elem" + ], + "Output Answer": [ + "from collections import Counter \r\ndef most_common_elem(s,a):\r\n most_common_elem=Counter(s).most_common(a)\r\n return most_common_elem" + ], + "split": "train" + }, + { + "Input": "Write a python function to find the length of the shortest word.", + "Output Program": [ + "def len_log(list1):\r\n min=len(list1[0])\r\n for i in list1:\r\n if len(i) n- r): \r\n\t\tr = n - r \r\n\tC = [0 for i in range(r + 1)] \r\n\tC[0] = 1 \r\n\tfor i in range(1, n + 1): \r\n\t\tfor j in range(min(i, r), 0, -1): \r\n\t\t\tC[j] = (C[j] + C[j-1]) % p \r\n\treturn C[r] " + ], + "Output Answer": [ + "def nCr_mod_p(n, r, p): \r\n\tif (r > n- r): \r\n\t\tr = n - r \r\n\tC = [0 for i in range(r + 1)] \r\n\tC[0] = 1 \r\n\tfor i in range(1, n + 1): \r\n\t\tfor j in range(min(i, r), 0, -1): \r\n\t\t\tC[j] = (C[j] + C[j-1]) % p \r\n\treturn C[r] " + ], + "split": "train" + }, + { + "Input": "Write a python function to find the minimun number of subsets with distinct elements.", + "Output Program": [ + "def subset(ar, n): \r\n res = 0\r\n ar.sort() \r\n for i in range(0, n) : \r\n count = 1\r\n for i in range(n - 1): \r\n if ar[i] == ar[i + 1]: \r\n count+=1\r\n else: \r\n break \r\n res = max(res, count) \r\n return res " + ], + "Output Answer": [ + "def subset(ar, n): \r\n res = 0\r\n ar.sort() \r\n for i in range(0, n) : \r\n count = 1\r\n for i in range(n - 1): \r\n if ar[i] == ar[i + 1]: \r\n count+=1\r\n else: \r\n break \r\n res = max(res, count) \r\n return res " + ], + "split": "train" + }, + { + "Input": "Write a function that gives profit amount if the given amount has profit else return none.", + "Output Program": [ + "def profit_amount(actual_cost,sale_amount): \r\n if(actual_cost > sale_amount):\r\n amount = actual_cost - sale_amount\r\n return amount\r\n else:\r\n return None" + ], + "Output Answer": [ + "def profit_amount(actual_cost,sale_amount): \r\n if(actual_cost > sale_amount):\r\n amount = actual_cost - sale_amount\r\n return amount\r\n else:\r\n return None" + ], + "split": "train" + }, + { + "Input": "Write a function to find out, if the given number is abundant.", + "Output Program": [ + "def is_abundant(n):\r\n fctrsum = sum([fctr for fctr in range(1, n) if n % fctr == 0])\r\n return fctrsum > n" + ], + "Output Answer": [ + "def is_abundant(n):\r\n fctrsum = sum([fctr for fctr in range(1, n) if n % fctr == 0])\r\n return fctrsum > n" + ], + "split": "train" + }, + { + "Input": "Write a function to split the given string at uppercase letters by using regex.", + "Output Program": [ + "import re\r\ndef split_list(text):\r\n return (re.findall('[A-Z][^A-Z]*', text))" + ], + "Output Answer": [ + "import re\r\ndef split_list(text):\r\n return (re.findall('[A-Z][^A-Z]*', text))" + ], + "split": "train" + }, + { + "Input": "Write a python function to get the position of rightmost set bit.", + "Output Program": [ + "import math\r\ndef get_First_Set_Bit_Pos(n):\r\n return math.log2(n&-n)+1" + ], + "Output Answer": [ + "import math\r\ndef get_First_Set_Bit_Pos(n):\r\n return math.log2(n&-n)+1" + ], + "split": "train" + }, + { + "Input": "Write a function to convert an integer into a roman numeral.", + "Output Program": [ + "def int_to_roman( num):\r\n val = [1000, 900, 500, 400,100, 90, 50, 40,10, 9, 5, 4,1]\r\n syb = [\"M\", \"CM\", \"D\", \"CD\",\"C\", \"XC\", \"L\", \"XL\",\"X\", \"IX\", \"V\", \"IV\",\"I\"]\r\n roman_num = ''\r\n i = 0\r\n while num > 0:\r\n for _ in range(num // val[i]):\r\n roman_num += syb[i]\r\n num -= val[i]\r\n i += 1\r\n return roman_num" + ], + "Output Answer": [ + "def int_to_roman( num):\r\n val = [1000, 900, 500, 400,100, 90, 50, 40,10, 9, 5, 4,1]\r\n syb = [\"M\", \"CM\", \"D\", \"CD\",\"C\", \"XC\", \"L\", \"XL\",\"X\", \"IX\", \"V\", \"IV\",\"I\"]\r\n roman_num = ''\r\n i = 0\r\n while num > 0:\r\n for _ in range(num // val[i]):\r\n roman_num += syb[i]\r\n num -= val[i]\r\n i += 1\r\n return roman_num" + ], + "split": "train" + }, + { + "Input": "Write a python function to find the average of a list.", + "Output Program": [ + "def Average(lst): \r\n return sum(lst) / len(lst) " + ], + "Output Answer": [ + "def Average(lst): \r\n return sum(lst) / len(lst) " + ], + "split": "train" + }, + { + "Input": "Write a function to solve tiling problem.", + "Output Program": [ + "def get_noOfways(n):\r\n if (n == 0):\r\n return 0;\r\n if (n == 1):\r\n return 1; \r\n return get_noOfways(n - 1) + get_noOfways(n - 2);" + ], + "Output Answer": [ + "def get_noOfways(n):\r\n if (n == 0):\r\n return 0;\r\n if (n == 1):\r\n return 1; \r\n return get_noOfways(n - 1) + get_noOfways(n - 2);" + ], + "split": "train" + }, + { + "Input": "Write a function to convert a roman numeral to an integer.", + "Output Program": [ + "def roman_to_int(s):\r\n rom_val = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}\r\n int_val = 0\r\n for i in range(len(s)):\r\n if i > 0 and rom_val[s[i]] > rom_val[s[i - 1]]:\r\n int_val += rom_val[s[i]] - 2 * rom_val[s[i - 1]]\r\n else:\r\n int_val += rom_val[s[i]]\r\n return int_val" + ], + "Output Answer": [ + "def roman_to_int(s):\r\n rom_val = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}\r\n int_val = 0\r\n for i in range(len(s)):\r\n if i > 0 and rom_val[s[i]] > rom_val[s[i - 1]]:\r\n int_val += rom_val[s[i]] - 2 * rom_val[s[i - 1]]\r\n else:\r\n int_val += rom_val[s[i]]\r\n return int_val" + ], + "split": "train" + }, + { + "Input": "Write a python function to find the sum of all even natural numbers within the range l and r.", + "Output Program": [ + "def sum_Natural(n): \r\n sum = (n * (n + 1)) \r\n return int(sum) \r\ndef sum_Even(l,r): \r\n return (sum_Natural(int(r / 2)) - sum_Natural(int((l - 1) / 2))) " + ], + "Output Answer": [ + "def sum_Natural(n): \r\n sum = (n * (n + 1)) \r\n return int(sum) \r\ndef sum_Even(l,r): \r\n return (sum_Natural(int(r / 2)) - sum_Natural(int((l - 1) / 2))) " + ], + "split": "train" + }, + { + "Input": "Write a function to calculate the discriminant value.", + "Output Program": [ + "def discriminant_value(x,y,z):\r\n discriminant = (y**2) - (4*x*z)\r\n if discriminant > 0:\r\n return (\"Two solutions\",discriminant)\r\n elif discriminant == 0:\r\n return (\"one solution\",discriminant)\r\n elif discriminant < 0:\r\n return (\"no real solution\",discriminant)" + ], + "Output Answer": [ + "def discriminant_value(x,y,z):\r\n discriminant = (y**2) - (4*x*z)\r\n if discriminant > 0:\r\n return (\"Two solutions\",discriminant)\r\n elif discriminant == 0:\r\n return (\"one solution\",discriminant)\r\n elif discriminant < 0:\r\n return (\"no real solution\",discriminant)" + ], + "split": "train" + }, + { + "Input": "Write a python function to check whether the length of the word is even or not.", + "Output Program": [ + "def word_len(s): \r\n s = s.split(' ') \r\n for word in s: \r\n if len(word)%2==0: \r\n return True \r\n else:\r\n return False" + ], + "Output Answer": [ + "def word_len(s): \r\n s = s.split(' ') \r\n for word in s: \r\n if len(word)%2==0: \r\n return True \r\n else:\r\n return False" + ], + "split": "train" + }, + { + "Input": "Write a function to convert camel case string to snake case string.", + "Output Program": [ + "def camel_to_snake(text):\r\n import re\r\n str1 = re.sub('(.)([A-Z][a-z]+)', r'\\1_\\2', text)\r\n return re.sub('([a-z0-9])([A-Z])', r'\\1_\\2', str1).lower()" + ], + "Output Answer": [ + "def camel_to_snake(text):\r\n import re\r\n str1 = re.sub('(.)([A-Z][a-z]+)', r'\\1_\\2', text)\r\n return re.sub('([a-z0-9])([A-Z])', r'\\1_\\2', str1).lower()" + ], + "split": "train" + }, + { + "Input": "Write a function to remove an empty tuple from a list of tuples.", + "Output Program": [ + "def remove_empty(tuple1): #L = [(), (), ('',), ('a', 'b'), ('a', 'b', 'c'), ('d')]\r\n tuple1 = [t for t in tuple1 if t]\r\n return tuple1" + ], + "Output Answer": [ + "def remove_empty(tuple1): #L = [(), (), ('',), ('a', 'b'), ('a', 'b', 'c'), ('d')]\r\n tuple1 = [t for t in tuple1 if t]\r\n return tuple1" + ], + "split": "train" + }, + { + "Input": "Write a python function to accept the strings which contains all vowels.", + "Output Program": [ + "def check(string): \r\n if len(set(string).intersection(\"AEIOUaeiou\"))>=5: \r\n return ('accepted') \r\n else: \r\n return (\"not accepted\") " + ], + "Output Answer": [ + "def check(string): \r\n if len(set(string).intersection(\"AEIOUaeiou\"))>=5: \r\n return ('accepted') \r\n else: \r\n return (\"not accepted\") " + ], + "split": "train" + }, + { + "Input": "Write a python function to find maximum possible value for the given periodic function.", + "Output Program": [ + "def floor_Max(A,B,N):\r\n x = min(B - 1,N)\r\n return (A*x) // B" + ], + "Output Answer": [ + "def floor_Max(A,B,N):\r\n x = min(B - 1,N)\r\n return (A*x) // B" + ], + "split": "train" + }, + { + "Input": "Write a function to join the tuples if they have similar initial elements.", + "Output Program": [ + "def join_tuples(test_list):\r\n res = []\r\n for sub in test_list:\r\n if res and res[-1][0] == sub[0]:\r\n res[-1].extend(sub[1:])\r\n else:\r\n res.append([ele for ele in sub])\r\n res = list(map(tuple, res))\r\n return (res) " + ], + "Output Answer": [ + "def join_tuples(test_list):\r\n res = []\r\n for sub in test_list:\r\n if res and res[-1][0] == sub[0]:\r\n res[-1].extend(sub[1:])\r\n else:\r\n res.append([ele for ele in sub])\r\n res = list(map(tuple, res))\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a function to find minimum of two numbers.", + "Output Program": [ + "def min_of_two( x, y ):\r\n if x < y:\r\n return x\r\n return y" + ], + "Output Answer": [ + "def min_of_two( x, y ):\r\n if x < y:\r\n return x\r\n return y" + ], + "split": "train" + }, + { + "Input": "Write a function to find the maximum number of segments of lengths a, b and c that can be formed from n.", + "Output Program": [ + "def maximum_segments(n, a, b, c) : \r\n\tdp = [-1] * (n + 10) \r\n\tdp[0] = 0\r\n\tfor i in range(0, n) : \r\n\t\tif (dp[i] != -1) : \r\n\t\t\tif(i + a <= n ): \r\n\t\t\t\tdp[i + a] = max(dp[i] + 1, \r\n\t\t\t\t\t\t\tdp[i + a]) \r\n\t\t\tif(i + b <= n ): \r\n\t\t\t\tdp[i + b] = max(dp[i] + 1, \r\n\t\t\t\t\t\t\tdp[i + b]) \r\n\t\t\tif(i + c <= n ): \r\n\t\t\t\tdp[i + c] = max(dp[i] + 1, \r\n\t\t\t\t\t\t\tdp[i + c]) \r\n\treturn dp[n]" + ], + "Output Answer": [ + "def maximum_segments(n, a, b, c) : \r\n\tdp = [-1] * (n + 10) \r\n\tdp[0] = 0\r\n\tfor i in range(0, n) : \r\n\t\tif (dp[i] != -1) : \r\n\t\t\tif(i + a <= n ): \r\n\t\t\t\tdp[i + a] = max(dp[i] + 1, \r\n\t\t\t\t\t\t\tdp[i + a]) \r\n\t\t\tif(i + b <= n ): \r\n\t\t\t\tdp[i + b] = max(dp[i] + 1, \r\n\t\t\t\t\t\t\tdp[i + b]) \r\n\t\t\tif(i + c <= n ): \r\n\t\t\t\tdp[i + c] = max(dp[i] + 1, \r\n\t\t\t\t\t\t\tdp[i + c]) \r\n\treturn dp[n]" + ], + "split": "train" + }, + { + "Input": "Write a function to concatenate the given two tuples to a nested tuple.", + "Output Program": [ + "def concatenate_nested(test_tup1, test_tup2):\r\n res = test_tup1 + test_tup2\r\n return (res) " + ], + "Output Answer": [ + "def concatenate_nested(test_tup1, test_tup2):\r\n res = test_tup1 + test_tup2\r\n return (res) " + ], + "split": "train" + }, + { + "Input": "Write a python function to left rotate the string.", + "Output Program": [ + "def left_rotate(s,d):\r\n tmp = s[d : ] + s[0 : d]\r\n return tmp " + ], + "Output Answer": [ + "def left_rotate(s,d):\r\n tmp = s[d : ] + s[0 : d]\r\n return tmp " + ], + "split": "train" + }, + { + "Input": "Write a function to find the minimum total path sum in the given triangle.", + "Output Program": [ + "def min_sum_path(A): \r\n\tmemo = [None] * len(A) \r\n\tn = len(A) - 1\r\n\tfor i in range(len(A[n])): \r\n\t\tmemo[i] = A[n][i] \r\n\tfor i in range(len(A) - 2, -1,-1): \r\n\t\tfor j in range( len(A[i])): \r\n\t\t\tmemo[j] = A[i][j] + min(memo[j], \r\n\t\t\t\t\t\t\t\t\tmemo[j + 1]) \r\n\treturn memo[0]" + ], + "Output Answer": [ + "def min_sum_path(A): \r\n\tmemo = [None] * len(A) \r\n\tn = len(A) - 1\r\n\tfor i in range(len(A[n])): \r\n\t\tmemo[i] = A[n][i] \r\n\tfor i in range(len(A) - 2, -1,-1): \r\n\t\tfor j in range( len(A[i])): \r\n\t\t\tmemo[j] = A[i][j] + min(memo[j], \r\n\t\t\t\t\t\t\t\t\tmemo[j + 1]) \r\n\treturn memo[0]" + ], + "split": "train" + } + ], + "Metadata": [ + { + "Answer": "", + "Explanation": "task_id: 1test_setup_code: test_list: ['assert min_cost([[1, 2, 3], [4, 8, 2], [1, 5, 3]], 2, 2) == 8', 'assert min_cost([[2, 3, 4], [5, 9, 3], [2, 6, 4]], 2, 2) == 12', 'assert min_cost([[3, 4, 5], [6, 10, 4], [3, 7, 5]], 2, 2) == 16']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 2test_setup_code: test_list: ['assert similar_elements((3, 4, 5, 6),(5, 7, 4, 10)) == (4, 5)', 'assert similar_elements((1, 2, 3, 4),(5, 4, 3, 7)) == (3, 4)', 'assert similar_elements((11, 12, 14, 13),(17, 15, 14, 13)) == (13, 14)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 3test_setup_code: test_list: ['assert is_not_prime(2) == False', 'assert is_not_prime(10) == True', 'assert is_not_prime(35) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 4test_setup_code: test_list: ['assert heap_queue_largest( [25, 35, 22, 85, 14, 65, 75, 22, 58],3)==[85, 75, 65] ', 'assert heap_queue_largest( [25, 35, 22, 85, 14, 65, 75, 22, 58],2)==[85, 75] ', 'assert heap_queue_largest( [25, 35, 22, 85, 14, 65, 75, 22, 58],5)==[85, 75, 65, 58, 35]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 5test_setup_code: test_list: ['assert count_ways(2) == 3', 'assert count_ways(8) == 153', 'assert count_ways(12) == 2131']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 6test_setup_code: test_list: ['assert differ_At_One_Bit_Pos(13,9) == True', 'assert differ_At_One_Bit_Pos(15,8) == False', 'assert differ_At_One_Bit_Pos(2,4) == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 7test_setup_code: test_list: [\"assert find_char_long('Please move back to stream') == ['Please', 'move', 'back', 'stream']\", \"assert find_char_long('Jing Eco and Tech') == ['Jing', 'Tech']\", \"assert find_char_long('Jhingai wulu road Zone 3') == ['Jhingai', 'wulu', 'road', 'Zone']\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 8test_setup_code: test_list: ['assert square_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]', 'assert square_nums([10,20,30])==([100,400,900])', 'assert square_nums([12,15])==([144,225])']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 9test_setup_code: test_list: ['assert find_Rotations(\"aaaa\") == 1', 'assert find_Rotations(\"ab\") == 2', 'assert find_Rotations(\"abc\") == 3']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 10test_setup_code: test_list: ['assert small_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],2)==[10,20]', 'assert small_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],5)==[10,20,20,40,50]', 'assert small_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],3)==[10,20,20]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 11test_setup_code: test_list: ['assert remove_Occ(\"hello\",\"l\") == \"heo\"', 'assert remove_Occ(\"abcda\",\"a\") == \"bcd\"', 'assert remove_Occ(\"PHP\",\"P\") == \"H\"']challenge_test_list: ['assert remove_Occ(\"hellolloll\",\"l\") == \"helollol\"', 'assert remove_Occ(\"\",\"l\") == \"\"']" + }, + { + "Answer": "", + "Explanation": "task_id: 12test_setup_code: test_list: ['assert sort_matrix([[1, 2, 3], [2, 4, 5], [1, 1, 1]])==[[1, 1, 1], [1, 2, 3], [2, 4, 5]]', 'assert sort_matrix([[1, 2, 3], [-2, 4, -5], [1, -1, 1]])==[[-2, 4, -5], [1, -1, 1], [1, 2, 3]]', 'assert sort_matrix([[5,8,9],[6,4,3],[2,1,4]])==[[2, 1, 4], [6, 4, 3], [5, 8, 9]]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 13test_setup_code: test_list: ['assert 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)]', \"assert count_common(['one', 'two', 'three', 'four', 'five', 'one', 'two', 'one', 'three', 'one']) == [('one', 4), ('two', 2), ('three', 2), ('four', 1)]\", \"assert count_common(['Facebook', 'Apple', 'Amazon', 'Netflix', 'Google', 'Apple', 'Netflix', 'Amazon']) == [('Apple', 2), ('Amazon', 2), ('Netflix', 2), ('Facebook', 1)]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 14test_setup_code: test_list: ['assert find_Volume(10,8,6) == 240', 'assert find_Volume(3,2,2) == 6', 'assert find_Volume(1,2,1) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 15test_setup_code: test_list: ['assert split_lowerstring(\"AbCd\")==[\\'bC\\',\\'d\\']', 'assert split_lowerstring(\"Python\")==[\\'y\\', \\'t\\', \\'h\\', \\'o\\', \\'n\\']', 'assert split_lowerstring(\"Programming\")==[\\'r\\', \\'o\\', \\'g\\', \\'r\\', \\'a\\', \\'m\\', \\'m\\', \\'i\\', \\'n\\', \\'g\\']']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 16test_setup_code: test_list: ['assert text_lowercase_underscore(\"aab_cbbbc\")==(\\'Found a match!\\')', 'assert text_lowercase_underscore(\"aab_Abbbc\")==(\\'Not matched!\\')', 'assert text_lowercase_underscore(\"Aaab_abbbc\")==(\\'Not matched!\\')']challenge_test_list: ['assert text_lowercase_underscore(\"aab-cbbbc\")==(\\'Not matched!\\')']" + }, + { + "Answer": "", + "Explanation": "task_id: 17test_setup_code: test_list: ['assert square_perimeter(10)==40', 'assert square_perimeter(5)==20', 'assert square_perimeter(4)==16']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 18test_setup_code: test_list: ['assert remove_dirty_chars(\"probasscurve\", \"pros\") == \\'bacuve\\'', 'assert remove_dirty_chars(\"digitalindia\", \"talent\") == \\'digiidi\\'', 'assert remove_dirty_chars(\"exoticmiles\", \"toxic\") == \\'emles\\' ']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 19test_setup_code: test_list: ['assert test_duplicate(([1,2,3,4,5]))==False', 'assert test_duplicate(([1,2,3,4, 4]))==True', 'assert test_duplicate([1,1,2,2,3,3,4,4,5])==True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 20test_setup_code: test_list: ['assert is_woodall(383) == True', 'assert is_woodall(254) == False', 'assert is_woodall(200) == False']challenge_test_list: ['assert is_woodall(32212254719) == True', 'assert is_woodall(32212254718) == False', 'assert is_woodall(159) == True']" + }, + { + "Answer": "", + "Explanation": "task_id: 21test_setup_code: test_list: ['assert multiples_of_num(4,3)== [3,6,9,12]', 'assert multiples_of_num(2,5)== [5,10]', 'assert multiples_of_num(9,2)== [2,4,6,8,10,12,14,16,18]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 22test_setup_code: test_list: ['assert find_first_duplicate(([1, 2, 3, 4, 4, 5]))==4', 'assert find_first_duplicate([1, 2, 3, 4])==-1', 'assert find_first_duplicate([1, 1, 2, 3, 3, 2, 2])==1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 23test_setup_code: test_list: ['assert maximum_Sum([[1,2,3],[4,5,6],[10,11,12],[7,8,9]]) == 33', 'assert maximum_Sum([[0,1,1],[1,1,2],[3,2,1]]) == 6', 'assert maximum_Sum([[0,1,3],[1,2,1],[9,8,2],[0,1,0],[6,4,8]]) == 19']challenge_test_list: ['assert maximum_Sum([[0,-1,-1],[-1,-1,-2],[-3,-2,-1]]) == -2']" + }, + { + "Answer": "", + "Explanation": "task_id: 24test_setup_code: test_list: ['assert binary_to_decimal(100) == 4', 'assert binary_to_decimal(1011) == 11', 'assert binary_to_decimal(1101101) == 109']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 25test_setup_code: test_list: ['assert find_Product([1,1,2,3],4) == 6', 'assert find_Product([1,2,3,1,1],5) == 6', 'assert find_Product([1,1,4,5,6],5) == 120']challenge_test_list: ['assert find_Product([1,1,4,5,6,5,7,1,1,3,4],11) == 2520']" + }, + { + "Answer": "", + "Explanation": "task_id: 26test_setup_code: test_list: ['assert check_k_elements([(4, 4), (4, 4, 4), (4, 4), (4, 4, 4, 4), (4, )], 4) == True', 'assert check_k_elements([(7, 7, 7), (7, 7)], 7) == True', 'assert check_k_elements([(9, 9), (9, 9, 9, 9)], 7) == False']challenge_test_list: ['assert check_k_elements([(4, 4), (4, 4, 4), (4, 4), (4, 4, 6, 4), (4, )], 4) == False']" + }, + { + "Answer": "", + "Explanation": "task_id: 27test_setup_code: test_list: [\"assert remove(['4words', '3letters', '4digits']) == ['words', 'letters', 'digits']\", \"assert remove(['28Jan','12Jan','11Jan']) == ['Jan','Jan','Jan']\", \"assert remove(['wonder1','wonder2','wonder3']) == ['wonder','wonder','wonder']\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 28test_setup_code: test_list: ['assert binomial_Coeff(5,2) == 10', 'assert binomial_Coeff(4,3) == 4', 'assert binomial_Coeff(3,2) == 3']challenge_test_list: ['assert binomial_Coeff(14,6) == 3003']" + }, + { + "Answer": "", + "Explanation": "task_id: 29test_setup_code: test_list: ['assert get_Odd_Occurrence([1,2,3,1,2,3,1],7) == 1', 'assert get_Odd_Occurrence([1,2,3,2,3,1,3],7) == 3', 'assert get_Odd_Occurrence([2,3,5,4,5,2,4,3,5,2,4,4,2],13) == 5']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 30test_setup_code: test_list: ['assert count_Substring_With_Equal_Ends(\"abc\") == 3', 'assert count_Substring_With_Equal_Ends(\"abcda\") == 6', 'assert count_Substring_With_Equal_Ends(\"ab\") == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 31test_setup_code: test_list: ['assert 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]', 'assert 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]],1)==[1]', 'assert 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]],5)==[6, 5, 7, 8, 1]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 32test_setup_code: test_list: ['assert max_Prime_Factors(15) == 5', 'assert max_Prime_Factors(6) == 3', 'assert max_Prime_Factors(2) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 33test_setup_code: test_list: ['assert decimal_To_Binary(10) == 1010', 'assert decimal_To_Binary(1) == 1', 'assert decimal_To_Binary(20) == 10100']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 34test_setup_code: test_list: ['assert find_missing([1,2,3,5],4) == 4', 'assert find_missing([1,3,4,5],4) == 2', 'assert find_missing([1,2,3,5,6,7],5) == 4']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 35test_setup_code: test_list: ['assert find_rect_num(4) == 20', 'assert find_rect_num(5) == 30', 'assert find_rect_num(6) == 42']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 36test_setup_code: test_list: ['assert find_Nth_Digit(1,2,1) == 5', 'assert find_Nth_Digit(3,5,1) == 6', 'assert find_Nth_Digit(5,6,5) == 3']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 37test_setup_code: test_list: [\"assert sort_mixed_list([19,'red',12,'green','blue', 10,'white','green',1])==[1, 10, 12, 19, 'blue', 'green', 'green', 'red', 'white']\", \"assert sort_mixed_list([19,'red',12,'green','blue', 10,'white','green',1])==[1, 10, 12, 19, 'blue', 'green', 'green', 'red', 'white']\", \"assert sort_mixed_list([19,'red',12,'green','blue', 10,'white','green',1])==[1, 10, 12, 19, 'blue', 'green', 'green', 'red', 'white']\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 38test_setup_code: test_list: ['assert div_even_odd([1,3,5,7,4,1,6,8])==4', 'assert div_even_odd([1,2,3,4,5,6,7,8,9,10])==2', 'assert div_even_odd([1,5,7,9,10])==10']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 39test_setup_code: test_list: ['assert rearange_string(\"aab\")==(\\'aba\\')', 'assert rearange_string(\"aabb\")==(\\'abab\\')', 'assert rearange_string(\"abccdd\")==(\\'cdabcd\\')']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 40test_setup_code: test_list: ['assert 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})', 'assert freq_element([[1,2,3,4],[5,6,7,8],[9,10,11,12]])==({1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1, 12: 1})', 'assert freq_element([[15,20,30,40],[80,90,100,110],[30,30,80,90]])==({30: 3, 80: 2, 90: 2, 15: 1, 20: 1, 40: 1, 100: 1, 110: 1})']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 41test_setup_code: test_list: ['assert filter_evennumbers([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[2, 4, 6, 8, 10]', 'assert filter_evennumbers([10,20,45,67,84,93])==[10,20,84]', 'assert filter_evennumbers([5,7,9,8,6,4,3])==[8,6,4]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 42test_setup_code: test_list: ['assert find_Sum([1,2,3,1,1,4,5,6],8) == 3', 'assert find_Sum([1,2,3,1,1],5) == 3', 'assert find_Sum([1,1,2],3) == 2']challenge_test_list: ['assert find_Sum([1,1,2,3,4,5,6,3,5],9) == 18']" + }, + { + "Answer": "", + "Explanation": "task_id: 43test_setup_code: test_list: ['assert text_match(\"aab_cbbbc\") == \\'Found a match!\\'', 'assert text_match(\"aab_Abbbc\") == \\'Not matched!\\'', 'assert text_match(\"Aaab_abbbc\") == \\'Not matched!\\'']challenge_test_list: ['assert text_match(\"aab-cbbbc\") == \\'Not matched!\\'']" + }, + { + "Answer": "", + "Explanation": "task_id: 44test_setup_code: test_list: ['assert text_match_string(\" python\")==(\\'Not matched!\\')', 'assert text_match_string(\"python\")==(\\'Found a match!\\')', 'assert text_match_string(\" lang\")==(\\'Not matched!\\')']challenge_test_list: ['assert text_match_string(\"foo\")==(\\'Found a match!\\')']" + }, + { + "Answer": "", + "Explanation": "task_id: 45test_setup_code: test_list: ['assert get_gcd([2, 4, 6, 8, 16]) == 2', 'assert get_gcd([1, 2, 3]) == 1', 'assert get_gcd([2, 4, 6, 8]) == 2 ']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 46test_setup_code: test_list: ['assert test_distinct([1,5,7,9]) == True', 'assert test_distinct([2,4,5,5,7,9]) == False', 'assert test_distinct([1,2,3]) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 47test_setup_code: test_list: ['assert compute_Last_Digit(2,4) == 2', 'assert compute_Last_Digit(6,8) == 6', 'assert compute_Last_Digit(1,2) == 2']challenge_test_list: ['assert compute_Last_Digit(3,7) == 0', 'assert compute_Last_Digit(20,23) == 6', 'assert compute_Last_Digit(1021,1024) == 4']" + }, + { + "Answer": "", + "Explanation": "task_id: 48test_setup_code: test_list: ['assert odd_bit_set_number(10) == 15', 'assert odd_bit_set_number(20) == 21', 'assert odd_bit_set_number(30) == 31']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 49test_setup_code: test_list: ['assert specified_element([[1, 2, 3, 2], [4, 5, 6, 2], [7, 1, 9, 5]],0)==[1, 4, 7]', 'assert specified_element([[1, 2, 3, 2], [4, 5, 6, 2], [7, 1, 9, 5]],2)==[3, 6, 9]', 'assert specified_element([[1, 2, 3, 2], [4, 5, 6, 2], [7, 1, 9, 5]],1)==[2,5,1]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 50test_setup_code: test_list: ['assert min_length_list([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==(1, [0])', 'assert min_length_list([[1,2,3,4,5],[1,2,3,4],[1,2,3],[1,2],[1]])==(1,[1])', 'assert min_length_list([[3,4,5],[6,7,8,9],[10,11,12],[1,2]])==(2,[1,2])']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 51test_setup_code: test_list: ['assert check_equilateral(6,8,12)==False ', 'assert check_equilateral(6,6,12)==False', 'assert check_equilateral(6,6,6)==True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 52test_setup_code: test_list: ['assert parallelogram_area(10,20)==200', 'assert parallelogram_area(15,20)==300', 'assert parallelogram_area(8,9)==72']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 53test_setup_code: test_list: ['assert check_Equality(\"abcda\") == \"Equal\"', 'assert check_Equality(\"ab\") == \"Not Equal\"', 'assert check_Equality(\"mad\") == \"Not Equal\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 54test_setup_code: test_list: ['assert counting_sort([1,23,4,5,6,7,8]) == [1, 4, 5, 6, 7, 8, 23]', 'assert counting_sort([12, 9, 28, 33, 69, 45]) == [9, 12, 28, 33, 45, 69]', 'assert counting_sort([8, 4, 14, 3, 2, 1]) == [1, 2, 3, 4, 8, 14]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 55test_setup_code: test_list: ['assert tn_gp(1,5,2)==16', 'assert tn_gp(1,5,4)==256', 'assert tn_gp(2,6,3)==486']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 56test_setup_code: test_list: ['assert check(70) == False', 'assert check(23) == False', 'assert check(73) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 57test_setup_code: test_list: ['assert find_Max_Num([1,2,3],3) == 321', 'assert find_Max_Num([4,5,6,1],4) == 6541', 'assert find_Max_Num([1,2,3,9],4) == 9321']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 58test_setup_code: test_list: ['assert opposite_Signs(1,-2) == True', 'assert opposite_Signs(3,2) == False', 'assert opposite_Signs(-10,-10) == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 59test_setup_code: test_list: ['assert is_octagonal(5) == 65', 'assert is_octagonal(10) == 280', 'assert is_octagonal(15) == 645']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 60test_setup_code: test_list: ['assert max_len_sub([2, 5, 6, 3, 7, 6, 5, 8], 8) == 5', 'assert max_len_sub([-2, -1, 5, -1, 4, 0, 3], 7) == 4', 'assert max_len_sub([9, 11, 13, 15, 18], 5) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 61test_setup_code: test_list: [\"assert count_Substrings('112112',6) == 6\", \"assert count_Substrings('111',3) == 6\", \"assert count_Substrings('1101112',7) == 12\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 62test_setup_code: test_list: ['assert smallest_num([10, 20, 1, 45, 99]) == 1', 'assert smallest_num([1, 2, 3]) == 1', 'assert smallest_num([45, 46, 50, 60]) == 45']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 63test_setup_code: test_list: ['assert max_difference([(3, 5), (1, 7), (10, 3), (1, 2)]) == 7', 'assert max_difference([(4, 6), (2, 17), (9, 13), (11, 12)]) == 15', 'assert max_difference([(12, 35), (21, 27), (13, 23), (41, 22)]) == 23']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 64test_setup_code: test_list: [\"assert subject_marks([('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)])==[('Social sciences', 82), ('English', 88), ('Science', 90), ('Maths', 97)]\", \"assert subject_marks([('Telugu',49),('Hindhi',54),('Social',33)])==([('Social',33),('Telugu',49),('Hindhi',54)])\", \"assert subject_marks([('Physics',96),('Chemistry',97),('Biology',45)])==([('Biology',45),('Physics',96),('Chemistry',97)])\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 65test_setup_code: test_list: ['assert recursive_list_sum(([1, 2, [3,4],[5,6]]))==21', 'assert recursive_list_sum(([7, 10, [15,14],[19,41]]))==106', 'assert recursive_list_sum(([10, 20, [30,40],[50,60]]))==210']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 66test_setup_code: test_list: ['assert pos_count([1,-2,3,-4]) == 2', 'assert pos_count([3,4,5,-1]) == 3', 'assert pos_count([1,2,3,4]) == 4']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 67test_setup_code: test_list: ['assert bell_number(2)==2', 'assert bell_number(10)==115975', 'assert bell_number(56)==6775685320645824322581483068371419745979053216268760300']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 68test_setup_code: test_list: ['assert is_Monotonic([6, 5, 4, 4]) == True', 'assert is_Monotonic([1, 2, 2, 3]) == True', 'assert is_Monotonic([1, 3, 2]) == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 69test_setup_code: test_list: ['assert is_sublist([2,4,3,5,7],[3,7])==False', 'assert is_sublist([2,4,3,5,7],[4,3])==True', 'assert is_sublist([2,4,3,5,7],[1,6])==False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 70test_setup_code: test_list: [\"assert get_equal([(11, 22, 33), (44, 55, 66)], 3) == 'All tuples have same length'\", \"assert get_equal([(1, 2, 3), (4, 5, 6, 7)], 3) == 'All tuples do not have same length'\", \"assert get_equal([(1, 2), (3, 4)], 2) == 'All tuples have same length'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 71test_setup_code: test_list: ['assert comb_sort([5, 15, 37, 25, 79]) == [5, 15, 25, 37, 79]', 'assert comb_sort([41, 32, 15, 19, 22]) == [15, 19, 22, 32, 41]', 'assert comb_sort([99, 15, 13, 47]) == [13, 15, 47, 99]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 72test_setup_code: test_list: ['assert dif_Square(5) == True', 'assert dif_Square(10) == False', 'assert dif_Square(15) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 73test_setup_code: test_list: [\"assert multiple_split('Forces of the \\\\ndarkness*are coming into the play.') == ['Forces of the ', 'darkness', 'are coming into the play.']\", \"assert multiple_split('Mi Box runs on the \\\\n Latest android*which has google assistance and chromecast.') == ['Mi Box runs on the ', ' Latest android', 'which has google assistance and chromecast.']\", \"assert multiple_split('Certain services\\\\nare subjected to change*over the seperate subscriptions.') == ['Certain services', 'are subjected to change', 'over the seperate subscriptions.']\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 74test_setup_code: test_list: ['assert is_samepatterns([\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"])==True ', 'assert is_samepatterns([\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"])==False ', 'assert is_samepatterns([\"red\",\"green\",\"greenn\"], [\"a\",\"b\"])==False ']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 75test_setup_code: test_list: [\"assert find_tuples([(6, 24, 12), (7, 9, 6), (12, 18, 21)], 6) == '[(6, 24, 12)]'\", \"assert find_tuples([(5, 25, 30), (4, 2, 3), (7, 8, 9)], 5) == '[(5, 25, 30)]'\", \"assert find_tuples([(7, 9, 16), (8, 16, 4), (19, 17, 18)], 4) == '[(8, 16, 4)]'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 76test_setup_code: test_list: ['assert count_Squares(4,3) == 20', 'assert count_Squares(2,2) == 5', 'assert count_Squares(1,1) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 77test_setup_code: test_list: ['assert is_Diff (12345) == False', 'assert is_Diff(1212112) == True', 'assert is_Diff(1212) == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 78test_setup_code: test_list: ['assert count_With_Odd_SetBits(5) == 3', 'assert count_With_Odd_SetBits(10) == 5', 'assert count_With_Odd_SetBits(15) == 8']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 79test_setup_code: test_list: ['assert word_len(\"Hadoop\") == False', 'assert word_len(\"great\") == True', 'assert word_len(\"structure\") == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 80test_setup_code: test_list: ['assert tetrahedral_number(5) == 35.0', 'assert tetrahedral_number(6) == 56.0', 'assert tetrahedral_number(7) == 84.0']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 81test_setup_code: test_list: ['assert zip_tuples((7, 8, 4, 5, 9, 10),(1, 5, 6) ) == [(7, 1), (8, 5), (4, 6), (5, 1), (9, 5), (10, 6)]', 'assert zip_tuples((8, 9, 5, 6, 10, 11),(2, 6, 7) ) == [(8, 2), (9, 6), (5, 7), (6, 2), (10, 6), (11, 7)]', 'assert zip_tuples((9, 10, 6, 7, 11, 12),(3, 7, 8) ) == [(9, 3), (10, 7), (6, 8), (7, 3), (11, 7), (12, 8)]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 82test_setup_code: test_list: ['assert volume_sphere(10)==4188.790204786391', 'assert volume_sphere(25)==65449.84694978735', 'assert volume_sphere(20)==33510.32163829113']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 83test_setup_code: test_list: ['assert get_Char(\"abc\") == \"f\"', 'assert get_Char(\"gfg\") == \"t\"', 'assert get_Char(\"ab\") == \"c\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 84test_setup_code: test_list: ['assert sequence(10) == 6', 'assert sequence(2) == 1', 'assert sequence(3) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 85test_setup_code: test_list: ['assert surfacearea_sphere(10)==1256.6370614359173', 'assert surfacearea_sphere(15)==2827.4333882308138', 'assert surfacearea_sphere(20)==5026.548245743669']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 86test_setup_code: test_list: ['assert centered_hexagonal_number(10) == 271', 'assert centered_hexagonal_number(2) == 7', 'assert centered_hexagonal_number(9) == 217']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 87test_setup_code: test_list: ['assert merge_dictionaries_three({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" },{ \"O\": \"Orange\", \"W\": \"White\", \"B\": \"Black\" })=={\\'B\\': \\'Black\\', \\'R\\': \\'Red\\', \\'P\\': \\'Pink\\', \\'G\\': \\'Green\\', \\'W\\': \\'White\\', \\'O\\': \\'Orange\\'}', 'assert merge_dictionaries_three({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" },{\"L\":\"lavender\",\"B\":\"Blue\"})=={\\'W\\': \\'White\\', \\'P\\': \\'Pink\\', \\'B\\': \\'Black\\', \\'R\\': \\'Red\\', \\'G\\': \\'Green\\', \\'L\\': \\'lavender\\'}', 'assert merge_dictionaries_three({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" },{\"L\":\"lavender\",\"B\":\"Blue\"},{ \"G\": \"Green\", \"W\": \"White\" })=={\\'B\\': \\'Black\\', \\'P\\': \\'Pink\\', \\'R\\': \\'Red\\', \\'G\\': \\'Green\\', \\'L\\': \\'lavender\\', \\'W\\': \\'White\\'}']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 88test_setup_code: test_list: ['assert 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}) ', 'assert freq_count([1,2,3,4,3,2,4,1,3,1,4])==({1:3, 2:2,3:3,4:3}) ', 'assert freq_count([5,6,7,4,9,10,4,5,6,7,9,5])==({10:1,5:3,6:2,7:2,4:2,9:2}) ']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 89test_setup_code: test_list: ['assert closest_num(11) == 10', 'assert closest_num(7) == 6', 'assert closest_num(12) == 11']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 90test_setup_code: test_list: ['assert len_log([\"python\",\"PHP\",\"bigdata\"]) == 7', 'assert len_log([\"a\",\"ab\",\"abc\"]) == 3', 'assert len_log([\"small\",\"big\",\"tall\"]) == 5']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 91test_setup_code: test_list: ['assert find_substring([\"red\", \"black\", \"white\", \"green\", \"orange\"],\"ack\")==True', 'assert find_substring([\"red\", \"black\", \"white\", \"green\", \"orange\"],\"abc\")==False', 'assert find_substring([\"red\", \"black\", \"white\", \"green\", \"orange\"],\"ange\")==True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 92test_setup_code: test_list: ['assert is_undulating(\"1212121\") == True', 'assert is_undulating(\"1991\") == False', 'assert is_undulating(\"121\") == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 93test_setup_code: test_list: ['assert power(3,4) == 81', 'assert power(2,3) == 8', 'assert power(5,5) == 3125']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 94test_setup_code: test_list: [\"assert index_minimum([('Rash', 143), ('Manjeet', 200), ('Varsha', 100)]) == 'Varsha'\", \"assert index_minimum([('Yash', 185), ('Dawood', 125), ('Sanya', 175)]) == 'Dawood'\", \"assert index_minimum([('Sai', 345), ('Salman', 145), ('Ayesha', 96)]) == 'Ayesha'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 95test_setup_code: test_list: ['assert Find_Min_Length([[1],[1,2]]) == 1', 'assert Find_Min_Length([[1,2],[1,2,3],[1,2,3,4]]) == 2', 'assert Find_Min_Length([[3,3,3],[4,4,4,4]]) == 3']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 96test_setup_code: test_list: ['assert divisor(15) == 4 ', 'assert divisor(12) == 6', 'assert divisor(9) == 3']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 97test_setup_code: test_list: ['assert 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}', 'assert frequency_lists([[1,2,3,4],[5,6,7,8],[9,10,11,12]])=={1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1,10:1,11:1,12:1}', 'assert frequency_lists([[20,30,40,17],[18,16,14,13],[10,20,30,40]])=={20:2,30:2,40:2,17: 1,18:1, 16: 1,14: 1,13: 1, 10: 1}']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 98test_setup_code: test_list: ['assert multiply_num((8, 2, 3, -1, 7))==-67.2', 'assert multiply_num((-10,-20,-30))==-2000.0', 'assert multiply_num((19,15,18))==1710.0']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 99test_setup_code: test_list: [\"assert decimal_to_binary(8) == '1000'\", \"assert decimal_to_binary(18) == '10010'\", \"assert decimal_to_binary(7) == '111' \"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 100test_setup_code: test_list: ['assert next_smallest_palindrome(99)==101', 'assert next_smallest_palindrome(1221)==1331', 'assert next_smallest_palindrome(120)==121']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 101test_setup_code: test_list: ['assert kth_element([12,3,5,7,19], 5, 2) == 3', 'assert kth_element([17,24,8,23], 4, 3) == 8', 'assert kth_element([16,21,25,36,4], 5, 4) == 36']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 102test_setup_code: test_list: [\"assert snake_to_camel('python_program')=='PythonProgram'\", \"assert snake_to_camel('python_language')==('PythonLanguage')\", \"assert snake_to_camel('programming_language')==('ProgrammingLanguage')\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 103test_setup_code: test_list: ['assert eulerian_num(3, 1) == 4', 'assert eulerian_num(4, 1) == 11', 'assert eulerian_num(5, 3) == 26']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 104test_setup_code: test_list: ['assert sort_sublists(([\"green\", \"orange\"], [\"black\", \"white\"], [\"white\", \"black\", \"orange\"]))==[[\\'green\\', \\'orange\\'], [\\'black\\', \\'white\\'], [\\'black\\', \\'orange\\', \\'white\\']]', 'assert sort_sublists(([\" red \",\"green\" ],[\"blue \",\" black\"],[\" orange\",\"brown\"]))==[[\\' red \\', \\'green\\'], [\\' black\\', \\'blue \\'], [\\' orange\\', \\'brown\\']]', 'assert sort_sublists(([\"zilver\",\"gold\"], [\"magnesium\",\"aluminium\"], [\"steel\", \"bronze\"]))==[[\\'gold\\', \\'zilver\\'],[\\'aluminium\\', \\'magnesium\\'], [\\'bronze\\', \\'steel\\']]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 105test_setup_code: test_list: ['assert count([True,False,True]) == 2', 'assert count([False,False]) == 0', 'assert count([True,True,True]) == 3']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 106test_setup_code: test_list: ['assert add_lists([5, 6, 7], (9, 10)) == (9, 10, 5, 6, 7)', 'assert add_lists([6, 7, 8], (10, 11)) == (10, 11, 6, 7, 8)', 'assert add_lists([7, 8, 9], (11, 12)) == (11, 12, 7, 8, 9)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 107test_setup_code: test_list: ['assert count_Hexadecimal(10,15) == 6', 'assert count_Hexadecimal(2,4) == 0', 'assert count_Hexadecimal(15,16) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 108test_setup_code: test_list: ['assert 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]', 'assert merge_sorted_list([1, 3, 5, 6, 8, 9], [2, 5, 7, 11], [1, 4, 7, 8, 12])==[1, 1, 2, 3, 4, 5, 5, 6, 7, 7, 8, 8, 9, 11, 12]', 'assert merge_sorted_list([18, 14, 10, 9, 8, 7, 9, 3, 2, 4, 1],[25, 35, 22, 85, 14, 65, 75, 25, 58],[12, 74, 9, 50, 61, 41])==[1, 2, 3, 4, 7, 8, 9, 9, 9, 10, 12, 14, 14, 18, 22, 25, 25, 35, 41, 50, 58, 61, 65, 74, 75, 85]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 109test_setup_code: test_list: ['assert odd_Equivalent(\"011001\",6) == 3', 'assert odd_Equivalent(\"11011\",5) == 4', 'assert odd_Equivalent(\"1010\",4) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 110test_setup_code: test_list: ['assert extract_missing([(6, 9), (15, 34), (48, 70)], 2, 100) == [(2, 6), (9, 100), (9, 15), (34, 100), (34, 48), (70, 100)]', 'assert extract_missing([(7, 2), (15, 19), (38, 50)], 5, 60) == [(5, 7), (2, 60), (2, 15), (19, 60), (19, 38), (50, 60)]', 'assert extract_missing([(7, 2), (15, 19), (38, 50)], 1, 52) == [(1, 7), (2, 52), (2, 15), (19, 52), (19, 38), (50, 52)]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 111test_setup_code: test_list: ['assert common_in_nested_lists([[12, 18, 23, 25, 45], [7, 12, 18, 24, 28], [1, 5, 8, 12, 15, 16, 18]])==[18, 12]', 'assert common_in_nested_lists([[12, 5, 23, 25, 45], [7, 11, 5, 23, 28], [1, 5, 8, 18, 23, 16]])==[5,23]', 'assert common_in_nested_lists([[2, 3,4, 1], [4, 5], [6,4, 8],[4, 5], [6, 8,4]])==[4]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 112test_setup_code: test_list: ['assert perimeter(2,4) == 12', 'assert perimeter(1,2) == 6', 'assert perimeter(3,1) == 8']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 113test_setup_code: test_list: ['assert check_integer(\"python\")==False', 'assert check_integer(\"1\")==True', 'assert check_integer(\"12345\")==True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 114test_setup_code: test_list: [\"assert 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)]'\", \"assert assign_freq([(4, 2, 4), (7, 1), (4, 8), (4, 2, 4), (9, 2), (7, 1)] ) == '[(4, 2, 4, 2), (7, 1, 2), (4, 8, 1), (9, 2, 1)]'\", \"assert assign_freq([(11, 13, 10), (17, 21), (4, 2, 3), (17, 21), (9, 2), (4, 2, 3)] ) == '[(11, 13, 10, 1), (17, 21, 2), (4, 2, 3, 2), (9, 2, 1)]'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 115test_setup_code: test_list: ['assert empty_dit([{},{},{}])==True', 'assert empty_dit([{1,2},{},{}])==False', 'assert empty_dit({})==True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 116test_setup_code: test_list: ['assert tuple_to_int((1,2,3))==123', 'assert tuple_to_int((4,5,6))==456', 'assert tuple_to_int((5,6,7))==567']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 117test_setup_code: test_list: ['assert 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)]\\'', 'assert list_to_float( [(\"4\", \"4\"), (\"2\", \"27\"), (\"4.12\", \"9\"), (\"7\", \"11\")] ) == \\'[(4.0, 4.0), (2.0, 27.0), (4.12, 9.0), (7.0, 11.0)]\\'', 'assert list_to_float( [(\"6\", \"78\"), (\"5\", \"26.45\"), (\"1.33\", \"4\"), (\"82\", \"13\")] ) == \\'[(6.0, 78.0), (5.0, 26.45), (1.33, 4.0), (82.0, 13.0)]\\'']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 118test_setup_code: test_list: ['assert string_to_list(\"python programming\")==[\\'python\\',\\'programming\\']', 'assert string_to_list(\"lists tuples strings\")==[\\'lists\\',\\'tuples\\',\\'strings\\']', 'assert string_to_list(\"write a program\")==[\\'write\\',\\'a\\',\\'program\\']']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 119test_setup_code: test_list: ['assert search([1,1,2,2,3],5) == 3', 'assert search([1,1,3,3,4,4,5,5,7,7,8],11) == 8', 'assert search([1,2,2,3,3,4,4],7) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 120test_setup_code: test_list: ['assert max_product_tuple([(2, 7), (2, 6), (1, 8), (4, 9)] )==36', 'assert max_product_tuple([(10,20), (15,2), (5,10)] )==200', 'assert max_product_tuple([(11,44), (10,15), (20,5), (12, 9)] )==484']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 121test_setup_code: test_list: ['assert check_triplet([2, 7, 4, 0, 9, 5, 1, 3], 8, 6, 0) == True', 'assert check_triplet([1, 4, 5, 6, 7, 8, 5, 9], 8, 6, 0) == False', 'assert check_triplet([10, 4, 2, 3, 5], 5, 15, 0) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 122test_setup_code: test_list: ['assert smartNumber(1) == 30', 'assert smartNumber(50) == 273', 'assert smartNumber(1000) == 2664']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 123test_setup_code: test_list: ['assert amicable_numbers_sum(999)==504', 'assert amicable_numbers_sum(9999)==31626', 'assert amicable_numbers_sum(99)==0']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 124test_setup_code: test_list: ['assert angle_complex(0,1j)==1.5707963267948966 ', 'assert angle_complex(2,1j)==0.4636476090008061', 'assert angle_complex(0,2j)==1.5707963267948966']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 125test_setup_code: test_list: ['assert find_length(\"11000010001\", 11) == 6', 'assert find_length(\"10111\", 5) == 1', 'assert find_length(\"11011101100101\", 14) == 2 ']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 126test_setup_code: test_list: ['assert sum(10,15) == 6', 'assert sum(100,150) == 93', 'assert sum(4,6) == 3']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 127test_setup_code: test_list: ['assert multiply_int(10,20)==200', 'assert multiply_int(5,10)==50', 'assert multiply_int(4,8)==32']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 128test_setup_code: test_list: ['assert long_words(3,\"python is a programming language\")==[\\'python\\',\\'programming\\',\\'language\\']', 'assert long_words(2,\"writing a program\")==[\\'writing\\',\\'program\\']', 'assert long_words(5,\"sorting list\")==[\\'sorting\\']']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 129test_setup_code: test_list: ['assert magic_square_test([[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]])==True', 'assert magic_square_test([[2, 7, 6], [9, 5, 1], [4, 3, 8]])==True', 'assert magic_square_test([[2, 7, 6], [9, 5, 1], [4, 3, 7]])==False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 130test_setup_code: test_list: ['assert 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)', 'assert max_occurrences([2,3,8,4,7,9,8,7,9,15,14,10,12,13,16,16,18])==(8, 2)', 'assert max_occurrences([10,20,20,30,40,90,80,50,30,20,50,10])==(20, 3)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 131test_setup_code: test_list: ['assert reverse_vowels(\"Python\") == \"Python\"', 'assert reverse_vowels(\"USA\") == \"ASU\"', 'assert reverse_vowels(\"ab\") == \"ab\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 132test_setup_code: test_list: ['assert tup_string((\\'e\\', \\'x\\', \\'e\\', \\'r\\', \\'c\\', \\'i\\', \\'s\\', \\'e\\', \\'s\\'))==(\"exercises\")', 'assert tup_string((\\'p\\',\\'y\\',\\'t\\',\\'h\\',\\'o\\',\\'n\\'))==(\"python\")', 'assert tup_string((\\'p\\',\\'r\\',\\'o\\',\\'g\\',\\'r\\',\\'a\\',\\'m\\'))==(\"program\")']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 133test_setup_code: test_list: ['assert sum_negativenum([2, 4, -6, -9, 11, -12, 14, -5, 17])==-32', 'assert sum_negativenum([10,15,-14,13,-18,12,-20])==-52', 'assert sum_negativenum([19, -65, 57, 39, 152,-639, 121, 44, 90, -190])==-894']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 134test_setup_code: test_list: ['assert check_last([5,7,10],3,1) == \"ODD\"', 'assert check_last([2,3],2,3) == \"EVEN\"', 'assert check_last([1,2,3],3,1) == \"ODD\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 135test_setup_code: test_list: ['assert hexagonal_num(10) == 190', 'assert hexagonal_num(5) == 45', 'assert hexagonal_num(7) == 91']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 136test_setup_code: test_list: ['assert cal_electbill(75)==246.25', 'assert cal_electbill(265)==1442.75', 'assert cal_electbill(100)==327.5']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 137test_setup_code: test_list: ['assert zero_count([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8])==0.15', 'assert zero_count([2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==0.00', 'assert zero_count([2, 4, -6, -9, 11, -12, 14, -5, 17])==0.00']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 138test_setup_code: test_list: ['assert is_Sum_Of_Powers_Of_Two(10) == True', 'assert is_Sum_Of_Powers_Of_Two(7) == False', 'assert is_Sum_Of_Powers_Of_Two(14) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 139test_setup_code: test_list: ['assert circle_circumference(10)==62.830000000000005', 'assert circle_circumference(5)==31.415000000000003', 'assert circle_circumference(4)==25.132']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 140test_setup_code: test_list: ['assert extract_singly([(3, 4, 5), (4, 5, 7), (1, 4)]) == [3, 4, 5, 7, 1]', 'assert extract_singly([(1, 2, 3), (4, 2, 3), (7, 8)]) == [1, 2, 3, 4, 7, 8]', 'assert extract_singly([(7, 8, 9), (10, 11, 12), (10, 11)]) == [7, 8, 9, 10, 11, 12]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 141test_setup_code: test_list: ['assert pancake_sort([15, 79, 25, 38, 69]) == [15, 25, 38, 69, 79]', 'assert pancake_sort([98, 12, 54, 36, 85]) == [12, 36, 54, 85, 98]', 'assert pancake_sort([41, 42, 32, 12, 23]) == [12, 23, 32, 41, 42]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 142test_setup_code: test_list: ['assert 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', 'assert count_samepair([1,2,3,4,5,6,7,8],[2,2,3,1,2,6,7,8],[2,1,3,1,2,6,7,8])==4', 'assert count_samepair([1,2,3,4,2,6,7,8],[2,2,3,1,2,6,7,8],[2,1,3,1,2,6,7,8])==5']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 143test_setup_code: test_list: ['assert find_lists(([1, 2, 3, 4], [5, 6, 7, 8])) == 2', 'assert find_lists(([1, 2], [3, 4], [5, 6])) == 3', 'assert find_lists(([9, 8, 7, 6, 5, 4, 3, 2, 1])) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 144test_setup_code: test_list: ['assert sum_Pairs([1,8,9,15,16],5) == 74', 'assert sum_Pairs([1,2,3,4],4) == 10', 'assert sum_Pairs([1,2,3,4,5,7,9,11,14],9) == 188']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 145test_setup_code: test_list: ['assert max_Abs_Diff((2,1,5,3),4) == 4', 'assert max_Abs_Diff((9,3,2,5,1),5) == 8', 'assert max_Abs_Diff((3,2,1),3) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 146test_setup_code: test_list: ['assert ascii_value_string(\"python\")==112', 'assert ascii_value_string(\"Program\")==80', 'assert ascii_value_string(\"Language\")==76']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 147test_setup_code: test_list: ['assert max_path_sum([[1, 0, 0], [4, 8, 0], [1, 5, 3]], 2, 2) == 14', 'assert max_path_sum([[13, 0, 0], [7, 4, 0], [2, 4, 6]], 2, 2) == 24 ', 'assert max_path_sum([[2, 0, 0], [11, 18, 0], [21, 25, 33]], 2, 2) == 53']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 148test_setup_code: test_list: ['assert sum_digits_twoparts(35)==17', 'assert sum_digits_twoparts(7)==7', 'assert sum_digits_twoparts(100)==19']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 149test_setup_code: test_list: ['assert longest_subseq_with_diff_one([1, 2, 3, 4, 5, 3, 2], 7) == 6', 'assert longest_subseq_with_diff_one([10, 9, 4, 5, 4, 8, 6], 7) == 3', 'assert longest_subseq_with_diff_one([1, 2, 3, 2, 3, 7, 2, 1], 8) == 7']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 150test_setup_code: test_list: ['assert does_Contain_B(1,7,3) == True', 'assert does_Contain_B(1,-3,5) == False', 'assert does_Contain_B(3,2,5) == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 151test_setup_code: test_list: ['assert is_coprime(17,13) == True', 'assert is_coprime(15,21) == False', 'assert is_coprime(25,45) == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 152test_setup_code: test_list: ['assert merge_sort([3, 4, 2, 6, 5, 7, 1, 9]) == [1, 2, 3, 4, 5, 6, 7, 9]', 'assert merge_sort([7, 25, 45, 78, 11, 33, 19]) == [7, 11, 19, 25, 33, 45, 78]', 'assert merge_sort([3, 1, 4, 9, 8]) == [1, 3, 4, 8, 9]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 153test_setup_code: test_list: ['assert parabola_vertex(5,3,2)==(-0.3, 1.55)', 'assert parabola_vertex(9,8,4)==(-0.4444444444444444, 2.2222222222222223)', 'assert parabola_vertex(2,4,6)==(-1.0, 4.0)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 154test_setup_code: test_list: ['assert specified_element([[1, 2, 3, 2], [4, 5, 6, 2], [7, 1, 9, 5]],0)==[1, 4, 7]', 'assert specified_element([[1, 2, 3, 2], [4, 5, 6, 2], [7, 1, 9, 5]],2)==[3, 6, 9]', 'assert specified_element([[1, 2, 3, 2], [4, 5, 6, 2], [7, 1, 9, 5]],3)==[2,2,5]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 155test_setup_code: test_list: ['assert even_bit_toggle_number(10) == 0', 'assert even_bit_toggle_number(20) == 30', 'assert even_bit_toggle_number(30) == 20']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 156test_setup_code: test_list: [\"assert tuple_int_str((('333', '33'), ('1416', '55')))==((333, 33), (1416, 55))\", \"assert tuple_int_str((('999', '99'), ('1000', '500')))==((999, 99), (1000, 500))\", \"assert tuple_int_str((('666', '66'), ('1500', '555')))==((666, 66), (1500, 555))\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 157test_setup_code: test_list: ['assert 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]]', \"assert encode_list('automatically')==[[1, 'a'], [1, 'u'], [1, 't'], [1, 'o'], [1, 'm'], [1, 'a'], [1, 't'], [1, 'i'], [1, 'c'], [1, 'a'], [2, 'l'], [1, 'y']]\", \"assert encode_list('python')==[[1, 'p'], [1, 'y'], [1, 't'], [1, 'h'], [1, 'o'], [1, 'n']]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 158test_setup_code: test_list: ['assert min_Ops([2,2,2,2],4,3) == 0', 'assert min_Ops([4,2,6,8],4,3) == -1', 'assert min_Ops([21,33,9,45,63],5,6) == 24']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 159test_setup_code: test_list: [\"assert month_season('January',4)==('winter')\", \"assert month_season('October',28)==('autumn')\", \"assert month_season('June',6)==('spring')\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 160test_setup_code: test_list: [\"assert solution(2, 3, 7) == ('x = ', 2, ', y = ', 1)\", \"assert solution(4, 2, 7) == 'No solution'\", \"assert solution(1, 13, 17) == ('x = ', 4, ', y = ', 1)\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 161test_setup_code: test_list: ['assert remove_elements([1,2,3,4,5,6,7,8,9,10],[2,4,6,8])==[1, 3, 5, 7, 9, 10]', 'assert remove_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],[1, 3, 5, 7])==[2, 4, 6, 8, 9, 10]', 'assert remove_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],[5,7])==[1, 2, 3, 4, 6, 8, 9, 10]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 162test_setup_code: test_list: ['assert sum_series(6)==12', 'assert sum_series(10)==30', 'assert sum_series(9)==25']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 163test_setup_code: test_list: ['assert area_polygon(4,20)==400.00000000000006', 'assert area_polygon(10,15)==1731.1969896610804', 'assert area_polygon(9,7)==302.90938549487214']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 164test_setup_code: test_list: ['assert areEquivalent(36,57) == False', 'assert areEquivalent(2,4) == False', 'assert areEquivalent(23,47) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 165test_setup_code: test_list: ['assert count_char_position(\"xbcefg\") == 2', 'assert count_char_position(\"ABcED\") == 3', 'assert count_char_position(\"AbgdeF\") == 5']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 166test_setup_code: test_list: ['assert find_even_Pair([5,4,7,2,1],5) == 4', 'assert find_even_Pair([7,2,8,1,0,5,11],7) == 9', 'assert find_even_Pair([1,2,3],3) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 167test_setup_code: test_list: ['assert next_Power_Of_2(0) == 1', 'assert next_Power_Of_2(5) == 8', 'assert next_Power_Of_2(17) == 32']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 168test_setup_code: test_list: ['assert frequency([1,2,3],4) == 0', 'assert frequency([1,2,2,3,3,3,4],3) == 3', 'assert frequency([0,1,2,3,1,2],1) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 169test_setup_code: test_list: ['assert get_pell(4) == 12', 'assert get_pell(7) == 169', 'assert get_pell(8) == 408']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 170test_setup_code: test_list: ['assert sum_range_list( [2,1,5,6,8,3,4,9,10,11,8,12],8,10)==29', 'assert sum_range_list( [2,1,5,6,8,3,4,9,10,11,8,12],5,7)==16', 'assert sum_range_list( [2,1,5,6,8,3,4,9,10,11,8,12],7,10)==38']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 171test_setup_code: test_list: ['assert perimeter_pentagon(5)==25', 'assert perimeter_pentagon(10)==50', 'assert perimeter_pentagon(15)==75']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 172test_setup_code: test_list: ['assert count_occurance(\"letstdlenstdporstd\") == 3', 'assert count_occurance(\"truststdsolensporsd\") == 1', 'assert count_occurance(\"makestdsostdworthit\") == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 173test_setup_code: test_list: [\"assert remove_splchar('python @#&^%$*program123')==('pythonprogram123')\", \"assert remove_splchar('python %^$@!^&*() programming24%$^^() language')==('pythonprogramming24language')\", \"assert remove_splchar('python ^%&^()(+_)(_^&67) program')==('python67program')\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 174test_setup_code: test_list: [\"assert group_keyvalue([('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)])=={'yellow': [1, 3], 'blue': [2, 4], 'red': [1]}\", \"assert group_keyvalue([('python', 1), ('python', 2), ('python', 3), ('python', 4), ('python', 5)])=={'python': [1,2,3,4,5]}\", \"assert group_keyvalue([('yellow',100), ('blue', 200), ('yellow', 300), ('blue', 400), ('red', 100)])=={'yellow': [100, 300], 'blue': [200, 400], 'red': [100]}\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 175test_setup_code: test_list: ['assert is_valid_parenthese(\"(){}[]\")==True', 'assert is_valid_parenthese(\"()[{)}\")==False', 'assert is_valid_parenthese(\"()\")==True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 176test_setup_code: test_list: ['assert perimeter_triangle(10,20,30)==60', 'assert perimeter_triangle(3,4,5)==12', 'assert perimeter_triangle(25,35,45)==105']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 177test_setup_code: test_list: ['assert answer(3,8) == (3,6)', 'assert answer(2,6) == (2,4)', 'assert answer(1,3) == (1,2)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 178test_setup_code: test_list: [\"assert string_literals(['language'],'python language')==('Matched!')\", \"assert string_literals(['program'],'python language')==('Not Matched!')\", \"assert string_literals(['python'],'programming language')==('Not Matched!')\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 179test_setup_code: test_list: ['assert is_num_keith(14) == True', 'assert is_num_keith(12) == False', 'assert is_num_keith(197) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 180test_setup_code: test_list: ['assert distance_lat_long(23.5,67.5,25.5,69.5)==12179.372041317429', 'assert distance_lat_long(10.5,20.5,30.5,40.5)==6069.397933300514', 'assert distance_lat_long(10,20,30,40)==6783.751974994595']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 181test_setup_code: test_list: ['assert common_prefix([\"tablets\", \"tables\", \"taxi\", \"tamarind\"], 4) == \\'ta\\'', 'assert common_prefix([\"apples\", \"ape\", \"april\"], 3) == \\'ap\\'', 'assert common_prefix([\"teens\", \"teenager\", \"teenmar\"], 3) == \\'teen\\'']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 182test_setup_code: test_list: ['assert find_character(\"ThisIsGeeksforGeeks\") == ([\\'T\\', \\'I\\', \\'G\\', \\'G\\'], [\\'h\\', \\'i\\', \\'s\\', \\'s\\', \\'e\\', \\'e\\', \\'k\\', \\'s\\', \\'f\\', \\'o\\', \\'r\\', \\'e\\', \\'e\\', \\'k\\', \\'s\\'], [], [])', 'assert find_character(\"Hithere2\") == ([\\'H\\'], [\\'i\\', \\'t\\', \\'h\\', \\'e\\', \\'r\\', \\'e\\'], [\\'2\\'], [])', 'assert find_character(\"HeyFolks32\") == ([\\'H\\', \\'F\\'], [\\'e\\', \\'y\\', \\'o\\', \\'l\\', \\'k\\', \\'s\\'], [\\'3\\', \\'2\\'], [])']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 183test_setup_code: test_list: ['assert count_pairs([1, 5, 3, 4, 2], 5, 3) == 2', 'assert count_pairs([8, 12, 16, 4, 0, 20], 6, 4) == 5', 'assert count_pairs([2, 4, 1, 3, 4], 5, 2) == 3']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 184test_setup_code: test_list: ['assert greater_specificnum([220, 330, 500],200)==True', 'assert greater_specificnum([12, 17, 21],20)==False', 'assert greater_specificnum([1,2,3,4],10)==False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 185test_setup_code: test_list: ['assert parabola_focus(5,3,2)==(-0.3, 1.6)', 'assert parabola_focus(9,8,4)==(-0.4444444444444444, 2.25)', 'assert parabola_focus(2,4,6)==(-1.0, 4.125)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 186test_setup_code: test_list: [\"assert check_literals('The quick brown fox jumps over the lazy dog.',['fox']) == 'Matched!'\", \"assert check_literals('The quick brown fox jumps over the lazy dog.',['horse']) == 'Not Matched!'\", \"assert check_literals('The quick brown fox jumps over the lazy dog.',['lazy']) == 'Matched!'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 187test_setup_code: test_list: ['assert longest_common_subsequence(\"AGGTAB\" , \"GXTXAYB\", 6, 7) == 4', 'assert longest_common_subsequence(\"ABCDGH\" , \"AEDFHR\", 6, 6) == 3', 'assert longest_common_subsequence(\"AXYT\" , \"AYZX\", 4, 4) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 188test_setup_code: test_list: ['assert prod_Square(25) == False', 'assert prod_Square(30) == False', 'assert prod_Square(16) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 189test_setup_code: test_list: ['assert first_Missing_Positive([1,2,3,-1,5],5) == 4', 'assert first_Missing_Positive([0,-1,-2,1,5,8],6) == 2', 'assert first_Missing_Positive([0,1,2,5,-8],5) == 3']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 190test_setup_code: test_list: ['assert count_Intgral_Points(1,1,4,4) == 4', 'assert count_Intgral_Points(1,2,1,2) == 1', 'assert count_Intgral_Points(4,2,6,4) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 191test_setup_code: test_list: ['assert check_monthnumber(\"February\")==False', 'assert check_monthnumber(\"June\")==True', 'assert check_monthnumber(\"April\")==True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 192test_setup_code: test_list: [\"assert check_String('thishasboth29') == True\", \"assert check_String('python') == False\", \"assert check_String ('string') == False\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 193test_setup_code: test_list: ['assert remove_tuple((1, 3, 5, 2, 3, 5, 1, 1, 3)) == (1, 2, 3, 5)', 'assert remove_tuple((2, 3, 4, 4, 5, 6, 6, 7, 8, 8)) == (2, 3, 4, 5, 6, 7, 8)', 'assert remove_tuple((11, 12, 13, 11, 11, 12, 14, 13)) == (11, 12, 13, 14)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 194test_setup_code: test_list: ['assert octal_To_Decimal(25) == 21', 'assert octal_To_Decimal(30) == 24', 'assert octal_To_Decimal(40) == 32']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 195test_setup_code: test_list: ['assert first([1,2,3,4,5,6,6],6,6) == 5', 'assert first([1,2,2,2,3,2,2,4,2],2,9) == 1', 'assert first([1,2,3],1,3) == 0']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 196test_setup_code: test_list: ['assert remove_tuples([(4, 5), (4, ), (8, 6, 7), (1, ), (3, 4, 6, 7)] , 1) == [(4, 5), (8, 6, 7), (3, 4, 6, 7)]', 'assert remove_tuples([(4, 5), (4,5), (6, 7), (1, 2, 3), (3, 4, 6, 7)] ,2) == [(1, 2, 3), (3, 4, 6, 7)]', 'assert remove_tuples([(1, 4, 4), (4, 3), (8, 6, 7), (1, ), (3, 6, 7)] , 3) == [(4, 3), (1,)]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 197test_setup_code: test_list: ['assert find_exponentio((10, 4, 5, 6), (5, 6, 7, 5)) == (100000, 4096, 78125, 7776)', 'assert find_exponentio((11, 5, 6, 7), (6, 7, 8, 6)) == (1771561, 78125, 1679616, 117649)', 'assert find_exponentio((12, 6, 7, 8), (7, 8, 9, 7)) == (35831808, 1679616, 40353607, 2097152)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 198test_setup_code: test_list: ['assert largest_triangle(4,2)==10.392304845413264', 'assert largest_triangle(5,7)==4.639421805988064', 'assert largest_triangle(9,1)==105.2220865598093']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 199test_setup_code: test_list: ['assert highest_Power_of_2(10) == 8', 'assert highest_Power_of_2(19) == 16', 'assert highest_Power_of_2(32) == 32']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 200test_setup_code: test_list: ['assert position_max([12,33,23,10,67,89,45,667,23,12,11,10,54])==[7]', 'assert position_max([1,2,2,2,4,4,4,5,5,5,5])==[7,8,9,10]', 'assert position_max([2,1,5,6,8,3,4,9,10,11,8,12])==[11]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 201test_setup_code: test_list: [\"assert chkList(['one','one','one']) == True\", \"assert chkList(['one','Two','Three']) == False\", \"assert chkList(['bigdata','python','Django']) == False\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 202test_setup_code: test_list: ['assert remove_even(\"python\")==(\"pto\")', 'assert remove_even(\"program\")==(\"porm\")', 'assert remove_even(\"language\")==(\"lnug\")']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 203test_setup_code: test_list: ['assert hamming_Distance(4,8) == 2', 'assert hamming_Distance(2,4) == 2', 'assert hamming_Distance(1,2) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 204test_setup_code: test_list: ['assert count(\"abcc\",\"c\") == 2', 'assert count(\"ababca\",\"a\") == 3', 'assert count(\"mnmm0pm\",\"m\") == 4']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 205test_setup_code: test_list: ['assert inversion_elements((7, 8, 9, 1, 10, 7)) == (-8, -9, -10, -2, -11, -8)', 'assert inversion_elements((2, 4, 5, 6, 1, 7)) == (-3, -5, -6, -7, -2, -8)', 'assert inversion_elements((8, 9, 11, 14, 12, 13)) == (-9, -10, -12, -15, -13, -14)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 206test_setup_code: test_list: ['assert concatenate_elements((\"DSP \", \"IS \", \"BEST \", \"FOR \", \"ALL \", \"UTS\")) == (\\'DSP IS \\', \\'IS BEST \\', \\'BEST FOR \\', \\'FOR ALL \\', \\'ALL UTS\\')', 'assert concatenate_elements((\"RES \", \"IS \", \"BEST \", \"FOR \", \"ALL \", \"QESR\")) == (\\'RES IS \\', \\'IS BEST \\', \\'BEST FOR \\', \\'FOR ALL \\', \\'ALL QESR\\')', 'assert concatenate_elements((\"MSAM\", \"IS \", \"BEST \", \"FOR \", \"ALL \", \"SKD\")) == (\\'MSAMIS \\', \\'IS BEST \\', \\'BEST FOR \\', \\'FOR ALL \\', \\'ALL SKD\\')']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 207test_setup_code: test_list: ['assert find_longest_repeating_subseq(\"AABEBCDD\") == 3', 'assert find_longest_repeating_subseq(\"aabb\") == 2', 'assert find_longest_repeating_subseq(\"aab\") == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 208test_setup_code: test_list: [\"assert is_decimal('123.11') == True\", \"assert is_decimal('0.21') == True\", \"assert is_decimal('123.1214') == False\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 209test_setup_code: test_list: ['assert heap_replace( [25, 44, 68, 21, 39, 23, 89],21)==[21, 25, 23, 44, 39, 68, 89]', 'assert heap_replace([25, 44, 68, 21, 39, 23, 89],110)== [23, 25, 68, 44, 39, 110, 89]', 'assert heap_replace([25, 44, 68, 21, 39, 23, 89],500)==[23, 25, 68, 44, 39, 500, 89]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 210test_setup_code: test_list: ['assert is_allowed_specific_char(\"ABCDEFabcdef123450\") == True', 'assert is_allowed_specific_char(\"*&%@#!}{\") == False', 'assert is_allowed_specific_char(\"HELLOhowareyou98765\") == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 211test_setup_code: test_list: ['assert count_Num(2) == 1', 'assert count_Num(3) == 2', 'assert count_Num(1) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 212test_setup_code: test_list: ['assert fourth_Power_Sum(2) == 17', 'assert fourth_Power_Sum(4) == 354', 'assert fourth_Power_Sum(6) == 2275']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 213test_setup_code: test_list: ['assert concatenate_strings((\"Manjeet\", \"Nikhil\", \"Akshat\"), (\" Singh\", \" Meherwal\", \" Garg\")) == (\\'Manjeet Singh\\', \\'Nikhil Meherwal\\', \\'Akshat Garg\\')', 'assert concatenate_strings((\"Shaik\", \"Ayesha\", \"Sanya\"), (\" Dawood\", \" Begum\", \" Singh\")) == (\\'Shaik Dawood\\', \\'Ayesha Begum\\', \\'Sanya Singh\\')', 'assert concatenate_strings((\"Harpreet\", \"Priyanka\", \"Muskan\"), (\"Kour\", \" Agarwal\", \"Sethi\")) == (\\'HarpreetKour\\', \\'Priyanka Agarwal\\', \\'MuskanSethi\\')']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 214test_setup_code: test_list: ['assert degree_radian(90)==5156.620156177409', 'assert degree_radian(60)==3437.746770784939', 'assert degree_radian(120)==6875.493541569878']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 215test_setup_code: test_list: ['assert decode_list([[2, 1], 2, 3, [2, 4], 5,1])==[1,1,2,3,4,4,5,1]', \"assert decode_list(['a', 'u', 't', 'o', 'm', 'a', 't', 'i', 'c', 'a', [2, 'l'], 'y'])==['a', 'u', 't', 'o', 'm', 'a', 't', 'i', 'c', 'a', 'l', 'l', 'y']\", \"assert decode_list(['p', 'y', 't', 'h', 'o', 'n'])==['p', 'y', 't', 'h', 'o', 'n']\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 216test_setup_code: test_list: ['assert 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', 'assert check_subset_list([[2, 3, 1], [4, 5], [6, 8]],[[4, 5], [6, 8]])==True', \"assert check_subset_list([['a', 'b'], ['e'], ['c', 'd']],[['g']])==False\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 217test_setup_code: test_list: ['assert first_Repeated_Char(\"Google\") == \"o\"', 'assert first_Repeated_Char(\"data\") == \"a\"', 'assert first_Repeated_Char(\"python\") == \\'\\\\0\\'']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 218test_setup_code: test_list: ['assert min_Operations(2,4) == 1', 'assert min_Operations(4,10) == 4', 'assert min_Operations(1,4) == 3']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 219test_setup_code: test_list: ['assert extract_min_max((5, 20, 3, 7, 6, 8), 2) == (3, 5, 8, 20)', 'assert extract_min_max((4, 5, 6, 1, 2, 7), 3) == (1, 2, 4, 5, 6, 7)', 'assert extract_min_max((2, 3, 4, 8, 9, 11, 7), 4) == (2, 3, 4, 7, 8, 9, 11)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 220test_setup_code: test_list: [\"assert replace_max_specialchar('Python language, Programming language.',2)==('Python:language: Programming language.')\", \"assert replace_max_specialchar('a b c,d e f',3)==('a:b:c:d e f')\", \"assert replace_max_specialchar('ram reshma,ram rahim',1)==('ram:reshma,ram rahim')\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 221test_setup_code: test_list: ['assert first_even ([1, 3, 5, 7, 4, 1, 6, 8]) == 4', 'assert first_even([2, 3, 4]) == 2', 'assert first_even([5, 6, 7]) == 6']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 222test_setup_code: test_list: ['assert check_type((5, 6, 7, 3, 5, 6) ) == True', 'assert check_type((1, 2, \"4\") ) == False', 'assert check_type((3, 2, 1, 4, 5) ) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 223test_setup_code: test_list: ['assert is_majority([1, 2, 3, 3, 3, 3, 10], 7, 3) == True', 'assert is_majority([1, 1, 2, 4, 4, 4, 6, 6], 8, 4) == False', 'assert is_majority([1, 1, 1, 2, 2], 5, 1) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 224test_setup_code: test_list: ['assert count_Set_Bits(2) == 1', 'assert count_Set_Bits(4) == 1', 'assert count_Set_Bits(6) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 225test_setup_code: test_list: ['assert find_Min([1,2,3,4,5],0,4) == 1', 'assert find_Min([4,6,8],0,2) == 4', 'assert find_Min([2,3,5,7,9],0,4) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 226test_setup_code: test_list: [\"assert odd_values_string('abcdef') == 'ace'\", \"assert odd_values_string('python') == 'pto'\", \"assert odd_values_string('data') == 'dt'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 227test_setup_code: test_list: ['assert min_of_three(10,20,0)==0', 'assert min_of_three(19,15,18)==15', 'assert min_of_three(-10,-20,-30)==-30']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 228test_setup_code: test_list: ['assert all_Bits_Set_In_The_Given_Range(4,1,2) == True', 'assert all_Bits_Set_In_The_Given_Range(17,2,4) == True', 'assert all_Bits_Set_In_The_Given_Range(39,4,6) == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 229test_setup_code: test_list: ['assert re_arrange_array([-1, 2, -3, 4, 5, 6, -7, 8, 9], 9) == [-1, -3, -7, 4, 5, 6, 2, 8, 9]', 'assert re_arrange_array([12, -14, -26, 13, 15], 5) == [-14, -26, 12, 13, 15]', 'assert re_arrange_array([10, 24, 36, -42, -39, -78, 85], 7) == [-42, -39, -78, 10, 24, 36, 85]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 230test_setup_code: test_list: ['assert replace_blank(\"hello people\",\\'@\\')==(\"hello@people\")', 'assert replace_blank(\"python program language\",\\'$\\')==(\"python$program$language\")', 'assert replace_blank(\"blank space\",\"-\")==(\"blank-space\")']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 231test_setup_code: test_list: ['assert max_sum([[1], [2,1], [3,3,2]], 3) == 6', 'assert max_sum([[1], [1, 2], [4, 1, 12]], 3) == 15 ', 'assert max_sum([[2], [3,2], [13,23,12]], 3) == 28']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 232test_setup_code: test_list: ['assert larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],2)==[100,90]', 'assert larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],5)==[100,90,80,70,60]', 'assert larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],3)==[100,90,80]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 233test_setup_code: test_list: ['assert lateralsuface_cylinder(10,5)==314.15000000000003', 'assert lateralsuface_cylinder(4,5)==125.66000000000001', 'assert lateralsuface_cylinder(4,10)==251.32000000000002']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 234test_setup_code: test_list: ['assert volume_cube(3)==27', 'assert volume_cube(2)==8', 'assert volume_cube(5)==125']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 235test_setup_code: test_list: ['assert even_bit_set_number(10) == 10', 'assert even_bit_set_number(20) == 30', 'assert even_bit_set_number(30) == 30']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 236test_setup_code: test_list: ['assert No_of_Triangle(4,2) == 7', 'assert No_of_Triangle(4,3) == 3', 'assert No_of_Triangle(1,3) == -1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 237test_setup_code: test_list: ['assert check_occurences([(3, 1), (1, 3), (2, 5), (5, 2), (6, 3)] ) == {(1, 3): 2, (2, 5): 2, (3, 6): 1}', 'assert check_occurences([(4, 2), (2, 4), (3, 6), (6, 3), (7, 4)] ) == {(2, 4): 2, (3, 6): 2, (4, 7): 1}', 'assert check_occurences([(13, 2), (11, 23), (12, 25), (25, 12), (16, 23)] ) == {(2, 13): 1, (11, 23): 1, (12, 25): 2, (16, 23): 1}']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 238test_setup_code: test_list: ['assert number_of_substrings(\"abc\") == 6', 'assert number_of_substrings(\"abcd\") == 10', 'assert number_of_substrings(\"abcde\") == 15']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 239test_setup_code: test_list: ['assert get_total_number_of_sequences(10, 4) == 4', 'assert get_total_number_of_sequences(5, 2) == 6', 'assert get_total_number_of_sequences(16, 3) == 84']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 240test_setup_code: test_list: ['assert replace_list([1, 3, 5, 7, 9, 10],[2, 4, 6, 8])==[1, 3, 5, 7, 9, 2, 4, 6, 8]', 'assert replace_list([1,2,3,4,5],[5,6,7,8])==[1,2,3,4,5,6,7,8]', 'assert replace_list([\"red\",\"blue\",\"green\"],[\"yellow\"])==[\"red\",\"blue\",\"yellow\"]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 241test_setup_code: test_list: [\"assert array_3d(6,4,3)==[[['*', '*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*', '*']], [['*', '*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*', '*']], [['*', '*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*', '*']]]\", \"assert array_3d(5,3,4)==[[['*', '*', '*', '*', '*'], ['*', '*', '*', '*','*'], ['*', '*', '*', '*', '*']], [['*', '*', '*', '*', '*'],['*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*']], [['*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*']], [['*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*']]]\", \"assert array_3d(1,2,3)==[[['*'],['*']],[['*'],['*']],[['*'],['*']]]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 242test_setup_code: test_list: ['assert count_charac(\"python programming\")==18', 'assert count_charac(\"language\")==8', 'assert count_charac(\"words\")==5']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 243test_setup_code: test_list: [\"assert sort_on_occurence([(1, 'Jake'), (2, 'Bob'), (1, 'Cara')]) == [(1, 'Jake', 'Cara', 2), (2, 'Bob', 1)]\", \"assert sort_on_occurence([('b', 'ball'), ('a', 'arm'), ('b', 'b'), ('a', 'ant')]) == [('b', 'ball', 'b', 2), ('a', 'arm', 'ant', 2)]\", \"assert sort_on_occurence([(2, 'Mark'), (3, 'Maze'), (2, 'Sara')]) == [(2, 'Mark', 'Sara', 2), (3, 'Maze', 1)]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 244test_setup_code: test_list: ['assert next_Perfect_Square(35) == 36', 'assert next_Perfect_Square(6) == 9', 'assert next_Perfect_Square(9) == 16']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 245test_setup_code: test_list: ['assert max_sum([1, 15, 51, 45, 33, 100, 12, 18, 9], 9) == 194', 'assert max_sum([80, 60, 30, 40, 20, 10], 6) == 210', 'assert max_sum([2, 3 ,14, 16, 21, 23, 29, 30], 8) == 138']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 246test_setup_code: test_list: ['assert babylonian_squareroot(10)==3.162277660168379', 'assert babylonian_squareroot(2)==1.414213562373095', 'assert babylonian_squareroot(9)==3.0']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 247test_setup_code: test_list: ['assert lps(\"TENS FOR TENS\") == 5 ', 'assert lps(\"CARDIO FOR CARDS\") == 7', 'assert lps(\"PART OF THE JOURNEY IS PART\") == 9 ']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 248test_setup_code: test_list: ['assert harmonic_sum(7) == 2.5928571428571425', 'assert harmonic_sum(4) == 2.083333333333333', 'assert harmonic_sum(19) == 3.547739657143682']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 249test_setup_code: test_list: ['assert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[1, 2, 4, 8, 9])==[1, 2, 8, 9]', 'assert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[3,5,7,9])==[3,5,7,9]', 'assert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[10,20,30,40])==[10]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 250test_setup_code: test_list: ['assert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),4) == 0', 'assert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),10) == 3', 'assert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),8) == 4']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 251test_setup_code: test_list: [\"assert insert_element(['Red', 'Green', 'Black'] ,'c')==['c', 'Red', 'c', 'Green', 'c', 'Black'] \", \"assert insert_element(['python', 'java'] ,'program')==['program', 'python', 'program', 'java'] \", \"assert insert_element(['happy', 'sad'] ,'laugh')==['laugh', 'happy', 'laugh', 'sad'] \"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 252test_setup_code: test_list: ['assert convert(1) == (1.0, 0.0)', 'assert convert(4) == (4.0,0.0)', 'assert convert(5) == (5.0,0.0)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 253test_setup_code: test_list: [\"assert count_integer([1,2,'abc',1.2]) == 2\", 'assert count_integer([1,2,3]) == 3', 'assert count_integer([1,1.2,4,5.1]) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 254test_setup_code: test_list: ['assert words_ae(\"python programe\")==[\\'ame\\']', 'assert words_ae(\"python programe language\")==[\\'ame\\',\\'anguage\\']', 'assert words_ae(\"assert statement\")==[\\'assert\\', \\'atement\\']']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 255test_setup_code: test_list: ['assert combinations_colors( [\"Red\",\"Green\",\"Blue\"],1)==[(\\'Red\\',), (\\'Green\\',), (\\'Blue\\',)]', 'assert combinations_colors( [\"Red\",\"Green\",\"Blue\"],2)==[(\\'Red\\', \\'Red\\'), (\\'Red\\', \\'Green\\'), (\\'Red\\', \\'Blue\\'), (\\'Green\\', \\'Green\\'), (\\'Green\\', \\'Blue\\'), (\\'Blue\\', \\'Blue\\')]', 'assert combinations_colors( [\"Red\",\"Green\",\"Blue\"],3)==[(\\'Red\\', \\'Red\\', \\'Red\\'), (\\'Red\\', \\'Red\\', \\'Green\\'), (\\'Red\\', \\'Red\\', \\'Blue\\'), (\\'Red\\', \\'Green\\', \\'Green\\'), (\\'Red\\', \\'Green\\', \\'Blue\\'), (\\'Red\\', \\'Blue\\', \\'Blue\\'), (\\'Green\\', \\'Green\\', \\'Green\\'), (\\'Green\\', \\'Green\\', \\'Blue\\'), (\\'Green\\', \\'Blue\\', \\'Blue\\'), (\\'Blue\\', \\'Blue\\', \\'Blue\\')]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 256test_setup_code: test_list: ['assert count_Primes_nums(5) == 2', 'assert count_Primes_nums(10) == 4', 'assert count_Primes_nums(100) == 25']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 257test_setup_code: test_list: ['assert swap_numbers(10,20)==(20,10)', 'assert swap_numbers(15,17)==(17,15)', 'assert swap_numbers(100,200)==(200,100)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 258test_setup_code: test_list: ['assert count_odd([1, 2, 3, 5, 7, 8, 10])==4', 'assert count_odd([10,15,14,13,-18,12,-20])==2', 'assert count_odd([1, 2, 4, 8, 9])==2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 259test_setup_code: test_list: ['assert 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))', 'assert maximize_elements(((2, 4), (5, 6), (3, 10), (2, 11)), ((7, 8), (4, 10), (2, 2), (8, 4))) == ((7, 8), (5, 10), (3, 10), (8, 11))', 'assert maximize_elements(((3, 5), (6, 7), (4, 11), (3, 12)), ((8, 9), (5, 11), (3, 3), (9, 5))) == ((8, 9), (6, 11), (4, 11), (9, 12))']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 260test_setup_code: test_list: ['assert newman_prime(3) == 7 ', 'assert newman_prime(4) == 17', 'assert newman_prime(5) == 41']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 261test_setup_code: test_list: ['assert division_elements((10, 4, 6, 9),(5, 2, 3, 3)) == (2, 2, 2, 3)', 'assert division_elements((12, 6, 8, 16),(6, 3, 4, 4)) == (2, 2, 2, 4)', 'assert division_elements((20, 14, 36, 18),(5, 7, 6, 9)) == (4, 2, 6, 2)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 262test_setup_code: test_list: ['assert split_two_parts([1,1,2,3,4,4,5,1],3)==([1, 1, 2], [3, 4, 4, 5, 1])', \"assert split_two_parts(['a', 'b', 'c', 'd'],2)==(['a', 'b'], ['c', 'd'])\", \"assert split_two_parts(['p', 'y', 't', 'h', 'o', 'n'],4)==(['p', 'y', 't', 'h'], ['o', 'n'])\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 263test_setup_code: test_list: [\"assert merge_dict({'a': 100, 'b': 200},{'x': 300, 'y': 200})=={'x': 300, 'y': 200, 'a': 100, 'b': 200}\", \"assert merge_dict({'a':900,'b':900,'d':900},{'a':900,'b':900,'d':900})=={'a':900,'b':900,'d':900,'a':900,'b':900,'d':900}\", \"assert merge_dict({'a':10,'b':20},{'x':30,'y':40})=={'x':30,'y':40,'a':10,'b':20}\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 264test_setup_code: test_list: ['assert dog_age(12)==61', 'assert dog_age(15)==73', 'assert dog_age(24)==109']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 265test_setup_code: test_list: [\"assert 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']] \", 'assert list_split([1,2,3,4,5,6,7,8,9,10,11,12,13,14],3)==[[1,4,7,10,13], [2,5,8,11,14], [3,6,9,12]] ', \"assert list_split(['python','java','C','C++','DBMS','SQL'],2)==[['python', 'C', 'DBMS'], ['java', 'C++', 'SQL']] \"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 266test_setup_code: test_list: ['assert lateralsurface_cube(5)==100', 'assert lateralsurface_cube(9)==324', 'assert lateralsurface_cube(10)==400']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 267test_setup_code: test_list: ['assert square_Sum(2) == 10', 'assert square_Sum(3) == 35', 'assert square_Sum(4) == 84']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 268test_setup_code: test_list: ['assert find_star_num(3) == 37', 'assert find_star_num(4) == 73', 'assert find_star_num(5) == 121']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 269test_setup_code: test_list: [\"assert ascii_value('A')==65\", \"assert ascii_value('R')==82\", \"assert ascii_value('S')==83\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 270test_setup_code: test_list: ['assert sum_even_and_even_index([5, 6, 12, 1, 18, 8],6) == 30', 'assert sum_even_and_even_index([3, 20, 17, 9, 2, 10, 18, 13, 6, 18],10) == 26', 'assert sum_even_and_even_index([5, 6, 12, 1],4) == 12']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 271test_setup_code: test_list: ['assert even_Power_Sum(2) == 1056', 'assert even_Power_Sum(3) == 8832', 'assert even_Power_Sum(1) == 32']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 272test_setup_code: test_list: [\"assert rear_extract([(1, 'Rash', 21), (2, 'Varsha', 20), (3, 'Kil', 19)]) == [21, 20, 19]\", \"assert rear_extract([(1, 'Sai', 36), (2, 'Ayesha', 25), (3, 'Salman', 45)]) == [36, 25, 45]\", \"assert rear_extract([(1, 'Sudeep', 14), (2, 'Vandana', 36), (3, 'Dawood', 56)]) == [14, 36, 56]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 273test_setup_code: test_list: ['assert substract_elements((10, 4, 5), (2, 5, 18)) == (8, -1, -13)', 'assert substract_elements((11, 2, 3), (24, 45 ,16)) == (-13, -43, -13)', 'assert substract_elements((7, 18, 9), (10, 11, 12)) == (-3, 7, -3)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 274test_setup_code: test_list: ['assert even_binomial_Coeff_Sum(4) == 8', 'assert even_binomial_Coeff_Sum(6) == 32', 'assert even_binomial_Coeff_Sum(2) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 275test_setup_code: test_list: ['assert get_Position([2,5,4],3,2) == 2', 'assert get_Position([4,3],2,2) == 2', 'assert get_Position([1,2,3,4],4,1) == 4']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 276test_setup_code: test_list: ['assert volume_cylinder(10,5)==1570.7500000000002', 'assert volume_cylinder(4,5)==251.32000000000002', 'assert volume_cylinder(4,10)==502.64000000000004']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 277test_setup_code: test_list: [\"assert dict_filter({'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},170)=={'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190}\", \"assert dict_filter({'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},180)=={ 'Alden Cantrell': 180, 'Pierre Cox': 190}\", \"assert dict_filter({'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},190)=={ 'Pierre Cox': 190}\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 278test_setup_code: test_list: ['assert count_first_elements((1, 5, 7, (4, 6), 10) ) == 3', 'assert count_first_elements((2, 9, (5, 7), 11) ) == 2', 'assert count_first_elements((11, 15, 5, 8, (2, 3), 8) ) == 4']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 279test_setup_code: test_list: ['assert is_num_decagonal(3) == 27', 'assert is_num_decagonal(7) == 175', 'assert is_num_decagonal(10) == 370']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 280test_setup_code: test_list: ['assert sequential_search([11,23,58,31,56,77,43,12,65,19],31) == (True, 3)', 'assert sequential_search([12, 32, 45, 62, 35, 47, 44, 61],61) == (True, 7)', 'assert sequential_search([9, 10, 17, 19, 22, 39, 48, 56],48) == (True, 6)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 281test_setup_code: test_list: ['assert all_unique([1,2,3]) == True', 'assert all_unique([1,2,1,2]) == False', 'assert all_unique([1,2,3,4,5]) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 282test_setup_code: test_list: ['assert sub_list([1, 2, 3],[4,5,6])==[-3,-3,-3]', 'assert sub_list([1,2],[3,4])==[-2,-2]', 'assert sub_list([90,120],[50,70])==[40,50]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 283test_setup_code: test_list: ['assert validate(1234) == True', 'assert validate(51241) == False', 'assert validate(321) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 284test_setup_code: test_list: ['assert check_element([\"green\", \"orange\", \"black\", \"white\"],\\'blue\\')==False', 'assert check_element([1,2,3,4],7)==False', 'assert check_element([\"green\", \"green\", \"green\", \"green\"],\\'green\\')==True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 285test_setup_code: test_list: ['assert text_match_two_three(\"ac\")==(\\'Not matched!\\')', 'assert text_match_two_three(\"dc\")==(\\'Not matched!\\')', 'assert text_match_two_three(\"abbbba\")==(\\'Found a match!\\')']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 286test_setup_code: test_list: ['assert max_sub_array_sum_repeated([10, 20, -30, -1], 4, 3) == 30', 'assert max_sub_array_sum_repeated([-1, 10, 20], 3, 2) == 59', 'assert max_sub_array_sum_repeated([-1, -2, -3], 3, 3) == -1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 287test_setup_code: test_list: ['assert square_Sum(2) == 20', 'assert square_Sum(3) == 56', 'assert square_Sum(4) == 120']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 288test_setup_code: test_list: ['assert modular_inverse([ 1, 6, 4, 5 ], 4, 7) == 2', 'assert modular_inverse([1, 3, 8, 12, 12], 5, 13) == 3', 'assert modular_inverse([2, 3, 4, 5], 4, 6) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 289test_setup_code: test_list: ['assert odd_Days(100) == 5', 'assert odd_Days(50) ==6', 'assert odd_Days(75) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 290test_setup_code: test_list: ['assert max_length([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==(3, [13, 15, 17])', 'assert max_length([[1], [5, 7], [10, 12, 14,15]])==(4, [10, 12, 14,15])', 'assert max_length([[5], [15,20,25]])==(3, [15,20,25])']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 291test_setup_code: test_list: ['assert count_no_of_ways(2, 4) == 16', 'assert count_no_of_ways(3, 2) == 6', 'assert count_no_of_ways(4, 4) == 228']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 292test_setup_code: test_list: ['assert find(10,3) == 3', 'assert find(4,2) == 2', 'assert find(20,5) == 4']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 293test_setup_code: test_list: ['assert otherside_rightangle(7,8)==10.63014581273465', 'assert otherside_rightangle(3,4)==5', 'assert otherside_rightangle(7,15)==16.55294535724685']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 294test_setup_code: test_list: [\"assert max_val(['Python', 3, 2, 4, 5, 'version'])==5\", \"assert max_val(['Python', 15, 20, 25])==25\", \"assert max_val(['Python', 30, 20, 40, 50, 'version'])==50\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 295test_setup_code: test_list: ['assert sum_div(8)==7', 'assert sum_div(12)==16', 'assert sum_div(7)==1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 296test_setup_code: test_list: ['assert get_Inv_Count([1,20,6,4,5],5) == 5', 'assert get_Inv_Count([1,2,1],3) == 1', 'assert get_Inv_Count([1,2,5,6,1],5) == 3']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 297test_setup_code: test_list: ['assert 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]', 'assert flatten_list([[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]])==[10, 20, 40, 30, 56, 25, 10, 20, 33, 40]', 'assert flatten_list([[1,2,3], [4,5,6], [10,11,12], [7,8,9]])==[1, 2, 3, 4, 5, 6, 10, 11, 12, 7, 8, 9]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 298test_setup_code: test_list: ['assert 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]]', 'assert intersection_nested_lists([[2, 3, 1], [4, 5], [6, 8]], [[4, 5], [6, 8]])==[[], []]', \"assert intersection_nested_lists(['john','amal','joel','george'],[['john'],['jack','john','mary'],['howard','john'],['jude']])==[['john'], ['john'], ['john'], []]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 299test_setup_code: test_list: [\"assert max_aggregate([('Juan Whelan',90),('Sabah Colley',88),('Peter Nichols',7),('Juan Whelan',122),('Sabah Colley',84)])==('Juan Whelan', 212)\", \"assert max_aggregate([('Juan Whelan',50),('Sabah Colley',48),('Peter Nichols',37),('Juan Whelan',22),('Sabah Colley',14)])==('Juan Whelan', 72)\", \"assert max_aggregate([('Juan Whelan',10),('Sabah Colley',20),('Peter Nichols',30),('Juan Whelan',40),('Sabah Colley',50)])==('Sabah Colley', 70)\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 300test_setup_code: test_list: ['assert count_binary_seq(1) == 2.0', 'assert count_binary_seq(2) == 6.0', 'assert count_binary_seq(3) == 20.0']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 301test_setup_code: test_list: [\"assert dict_depth({'a':1, 'b': {'c': {'d': {}}}})==4\", \"assert dict_depth({'a':1, 'b': {'c':'python'}})==2\", \"assert dict_depth({1: 'Sun', 2: {3: {4:'Mon'}}})==3\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 302test_setup_code: test_list: ['assert set_Bit_Number(6) == 4', 'assert set_Bit_Number(10) == 8', 'assert set_Bit_Number(18) == 16']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 303test_setup_code: test_list: ['assert solve([1,0,2],3) == True', 'assert solve([1,2,0],3) == False', 'assert solve([1,2,1],3) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 304test_setup_code: test_list: ['assert find_Element([1,2,3,4,5],[[0,2],[0,3]],2,1) == 3', 'assert find_Element([1,2,3,4],[[0,1],[0,2]],1,2) == 3', 'assert find_Element([1,2,3,4,5,6],[[0,1],[0,2]],1,1) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 305test_setup_code: test_list: ['assert start_withp([\"Python PHP\", \"Java JavaScript\", \"c c++\"])==(\\'Python\\', \\'PHP\\')', 'assert start_withp([\"Python Programming\",\"Java Programming\"])==(\\'Python\\',\\'Programming\\')', 'assert start_withp([\"Pqrst Pqr\",\"qrstuv\"])==(\\'Pqrst\\',\\'Pqr\\')']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 306test_setup_code: test_list: ['assert max_sum_increasing_subseq([1, 101, 2, 3, 100, 4, 5 ], 7, 4, 6) == 11', 'assert max_sum_increasing_subseq([1, 101, 2, 3, 100, 4, 5 ], 7, 2, 5) == 7', 'assert max_sum_increasing_subseq([11, 15, 19, 21, 26, 28, 31], 7, 2, 4) == 71']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 307test_setup_code: test_list: ['assert colon_tuplex((\"HELLO\", 5, [], True) ,2,50)==(\"HELLO\", 5, [50], True) ', 'assert colon_tuplex((\"HELLO\", 5, [], True) ,2,100)==((\"HELLO\", 5, [100],True))', 'assert colon_tuplex((\"HELLO\", 5, [], True) ,2,500)==(\"HELLO\", 5, [500], True)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 308test_setup_code: test_list: ['assert large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],3)==[60, 54, 50]', 'assert large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],4)==[60, 54, 50, 48]', 'assert large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],5)==[60, 54, 50, 48, 45]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 309test_setup_code: test_list: ['assert maximum(5,10) == 10', 'assert maximum(-1,-2) == -1', 'assert maximum(9,7) == 9']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 310test_setup_code: test_list: ['assert string_to_tuple(\"python 3.0\")==(\\'p\\', \\'y\\', \\'t\\', \\'h\\', \\'o\\', \\'n\\', \\'3\\', \\'.\\', \\'0\\')', 'assert string_to_tuple(\"item1\")==(\\'i\\', \\'t\\', \\'e\\', \\'m\\', \\'1\\')', 'assert string_to_tuple(\"15.10\")==(\\'1\\', \\'5\\', \\'.\\', \\'1\\', \\'0\\')']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 311test_setup_code: test_list: ['assert set_left_most_unset_bit(10) == 14', 'assert set_left_most_unset_bit(12) == 14', 'assert set_left_most_unset_bit(15) == 15']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 312test_setup_code: test_list: ['assert volume_cone(5,12)==314.15926535897927', 'assert volume_cone(10,15)==1570.7963267948965', 'assert volume_cone(19,17)==6426.651371693521']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 313test_setup_code: test_list: ['assert pos_nos([-1,-2,1,2]) == 1,2', 'assert pos_nos([3,4,-5]) == 3,4', 'assert pos_nos([-2,-3,1]) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 314test_setup_code: test_list: ['assert max_sum_rectangular_grid([ [1, 4, 5], [2, 0, 0 ] ], 3) == 7', 'assert max_sum_rectangular_grid([ [ 1, 2, 3, 4, 5], [ 6, 7, 8, 9, 10] ], 5) == 24', 'assert max_sum_rectangular_grid([ [7, 9, 11, 15, 19], [21, 25, 28, 31, 32] ], 5) == 81']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 315test_setup_code: test_list: ['assert find_Max_Len_Even(\"python language\") == \"language\"', 'assert find_Max_Len_Even(\"maximum even length\") == \"length\"', 'assert find_Max_Len_Even(\"eve\") == \"-1\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 316test_setup_code: test_list: ['assert find_last_occurrence([2, 5, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 3', 'assert find_last_occurrence([2, 3, 5, 8, 6, 6, 8, 9, 9, 9], 9) == 9', 'assert find_last_occurrence([2, 2, 1, 5, 6, 6, 6, 9, 9, 9], 6) == 6']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 317test_setup_code: test_list: ['assert modified_encode([1,1,2,3,4,4,5,1])==[[2, 1], 2, 3, [2, 4], 5, 1]', \"assert modified_encode('automatically')==['a', 'u', 't', 'o', 'm', 'a', 't', 'i', 'c', 'a', [2, 'l'], 'y']\", \"assert modified_encode('python')==['p', 'y', 't', 'h', 'o', 'n']\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 318test_setup_code: test_list: ['assert max_volume(8) == 18', 'assert max_volume(4) == 2', 'assert max_volume(1) == 0']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 319test_setup_code: test_list: [\"assert find_long_word('Please move back to strem') == ['strem']\", \"assert find_long_word('4K Ultra HD streaming player') == ['Ultra']\", \"assert find_long_word('Streaming Media Player') == ['Media']\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 320test_setup_code: test_list: ['assert sum_difference(12)==5434', 'assert sum_difference(20)==41230', 'assert sum_difference(54)==2151270']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 321test_setup_code: test_list: ['assert find_demlo(\"111111\") == \\'12345654321\\'', 'assert find_demlo(\"1111\") == \\'1234321\\'', 'assert find_demlo(\"13333122222\") == \\'123456789101110987654321\\'']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 322test_setup_code: test_list: ['assert position_min([12,33,23,10,67,89,45,667,23,12,11,10,54])==[3,11]', 'assert position_min([1,2,2,2,4,4,4,5,5,5,5])==[0]', 'assert position_min([2,1,5,6,8,3,4,9,10,11,8,12])==[1]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 323test_setup_code: test_list: ['assert re_arrange([-5, -2, 5, 2, 4,\\t7, 1, 8, 0, -8], 10) == [-5, 5, -2, 2, -8, 4, 7, 1, 8, 0]', 'assert re_arrange([1, 2, 3, -4, -1, 4], 6) == [-4, 1, -1, 2, 3, 4]', 'assert re_arrange([4, 7, 9, 77, -4, 5, -3, -9], 8) == [-4, 4, -3, 7, -9, 9, 77, 5]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 324test_setup_code: test_list: ['assert sum_of_alternates((5, 6, 3, 6, 10, 34)) == (46, 18)', 'assert sum_of_alternates((1, 2, 3, 4, 5)) == (6, 9)', 'assert sum_of_alternates((6, 7, 8, 9, 4, 5)) == (21, 18)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 325test_setup_code: test_list: ['assert get_Min_Squares(6) == 3', 'assert get_Min_Squares(2) == 2', 'assert get_Min_Squares(4) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 326test_setup_code: test_list: ['assert most_occurrences([\"UTS is best for RTF\", \"RTF love UTS\", \"UTS is best\"] ) == \\'UTS\\'', 'assert most_occurrences([\"Its been a great year\", \"this year is so worse\", \"this year is okay\"] ) == \\'year\\'', 'assert most_occurrences([\"Families can be reunited\", \"people can be reunited\", \"Tasks can be achieved \"] ) == \\'can\\'']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 327test_setup_code: test_list: ['assert check_isosceles(6,8,12)==False ', 'assert check_isosceles(6,6,12)==True', 'assert check_isosceles(6,16,20)==False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 328test_setup_code: test_list: ['assert 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]', 'assert rotate_left([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],2,2)==[3, 4, 5, 6, 7, 8, 9, 10, 1, 2]', 'assert rotate_left([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],5,2)==[6, 7, 8, 9, 10, 1, 2]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 329test_setup_code: test_list: ['assert neg_count([-1,-2,3,-4,-5]) == 4', 'assert neg_count([1,2,3]) == 0', 'assert neg_count([1,2,-3,-10,20]) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 330test_setup_code: test_list: [\"assert find_char('For the four consumer complaints contact manager AKR reddy') == ['For', 'the', 'four', 'AKR', 'reddy']\", \"assert find_char('Certain service are subject to change MSR') == ['are', 'MSR']\", \"assert find_char('Third party legal desclaimers') == ['Third', 'party', 'legal']\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 331test_setup_code: test_list: ['assert count_unset_bits(2) == 1', 'assert count_unset_bits(4) == 2', 'assert count_unset_bits(6) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 332test_setup_code: test_list: [\"assert char_frequency('python')=={'p': 1, 'y': 1, 't': 1, 'h': 1, 'o': 1, 'n': 1}\", \"assert char_frequency('program')=={'p': 1, 'r': 2, 'o': 1, 'g': 1, 'a': 1, 'm': 1}\", \"assert char_frequency('language')=={'l': 1, 'a': 2, 'n': 1, 'g': 2, 'u': 1, 'e': 1}\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 333test_setup_code: test_list: [\"assert Sort([['a', 10], ['b', 5], ['c', 20], ['d', 15]]) == [['b', 5], ['a', 10], ['d', 15], ['c', 20]]\", \"assert Sort([['452', 10], ['256', 5], ['100', 20], ['135', 15]]) == [['256', 5], ['452', 10], ['135', 15], ['100', 20]]\", \"assert Sort([['rishi', 10], ['akhil', 5], ['ramya', 20], ['gaur', 15]]) == [['akhil', 5], ['rishi', 10], ['gaur', 15], ['ramya', 20]]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 334test_setup_code: test_list: ['assert check_Validity(1,2,3) == False', 'assert check_Validity(2,3,5) == False', 'assert check_Validity(7,10,5) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 335test_setup_code: test_list: ['assert ap_sum(1,5,2)==25', 'assert ap_sum(2,6,4)==72', 'assert ap_sum(1,4,5)==34']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 336test_setup_code: test_list: ['assert check_monthnum(\"February\")==True', 'assert check_monthnum(\"January\")==False', 'assert check_monthnum(\"March\")==False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 337test_setup_code: test_list: ['assert text_match_word(\"python.\")==(\\'Found a match!\\')', 'assert text_match_word(\"python.\")==(\\'Found a match!\\')', 'assert text_match_word(\" lang .\")==(\\'Not matched!\\')']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 338test_setup_code: test_list: [\"assert count_Substring_With_Equal_Ends('aba') == 4\", \"assert count_Substring_With_Equal_Ends('abcab') == 7\", \"assert count_Substring_With_Equal_Ends('abc') == 3\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 339test_setup_code: test_list: ['assert find_Divisor(2,2) == 2', 'assert find_Divisor(2,5) == 2', 'assert find_Divisor(5,10) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 340test_setup_code: test_list: ['assert sum_three_smallest_nums([10,20,30,40,50,60,7]) == 37', 'assert sum_three_smallest_nums([1,2,3,4,5]) == 6', 'assert sum_three_smallest_nums([0,1,2,3,4,5]) == 6']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 341test_setup_code: test_list: ['assert set_to_tuple({1, 2, 3, 4, 5}) == (1, 2, 3, 4, 5)', 'assert set_to_tuple({6, 7, 8, 9, 10, 11}) == (6, 7, 8, 9, 10, 11)', 'assert set_to_tuple({12, 13, 14, 15, 16}) == (12, 13, 14, 15, 16)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 342test_setup_code: test_list: ['assert find_minimum_range([[3, 6, 8, 10, 15], [1, 5, 12], [4, 8, 15, 16], [2, 6]]) == (4, 6)', 'assert find_minimum_range([[ 2, 3, 4, 8, 10, 15 ], [1, 5, 12], [7, 8, 15, 16], [3, 6]]) == (4, 7)', 'assert find_minimum_range([[4, 7, 9, 11, 16], [2, 6, 13], [5, 9, 16, 17], [3, 7]]) == (5, 7)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 343test_setup_code: test_list: ['assert dig_let(\"python\")==(6,0)', 'assert dig_let(\"program\")==(7,0)', 'assert dig_let(\"python3.0\")==(6,2)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 344test_setup_code: test_list: ['assert count_Odd_Squares(5,100) == 8', 'assert count_Odd_Squares(8,65) == 6', 'assert count_Odd_Squares(2,5) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 345test_setup_code: test_list: ['assert diff_consecutivenums([1, 1, 3, 4, 4, 5, 6, 7])==[0, 2, 1, 0, 1, 1, 1]', 'assert diff_consecutivenums([4, 5, 8, 9, 6, 10])==[1, 3, 1, -3, 4]', 'assert diff_consecutivenums([0, 1, 2, 3, 4, 4, 4, 4, 5, 7])==[1, 1, 1, 1, 0, 0, 0, 1, 2]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 346test_setup_code: test_list: ['assert zigzag(4, 3) == 5', 'assert zigzag(4, 2) == 4', 'assert zigzag(3, 1) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 347test_setup_code: test_list: ['assert count_Squares(4,3) == 20', 'assert count_Squares(1,2) == 2', 'assert count_Squares(2,2) == 5']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 348test_setup_code: test_list: ['assert find_ways(4) == 2', 'assert find_ways(6) == 5', 'assert find_ways(8) == 14']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 349test_setup_code: test_list: ['assert check(\"01010101010\") == \"Yes\"', 'assert check(\"name0\") == \"No\"', 'assert check(\"101\") == \"Yes\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 350test_setup_code: test_list: ['assert minimum_Length(\"mnm\") == 1', 'assert minimum_Length(\"abcda\") == 3', 'assert minimum_Length(\"abcb\") == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 351test_setup_code: test_list: ['assert first_Element([0,1,2,3,4,5],6,1) == 0', 'assert first_Element([1,2,1,3,4],5,2) == 1', 'assert first_Element([2,3,4,3,5,7,1,2,3,5],10,2) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 352test_setup_code: test_list: [\"assert unique_Characters('aba') == False\", \"assert unique_Characters('abc') == True\", \"assert unique_Characters('abab') == False\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 353test_setup_code: test_list: ['assert remove_column([[1, 2, 3], [2, 4, 5], [1, 1, 1]],0)==[[2, 3], [4, 5], [1, 1]]', 'assert remove_column([[1, 2, 3], [-2, 4, -5], [1, -1, 1]],2)==[[1, 2], [-2, 4], [1, -1]]', 'assert remove_column([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]],0)==[[3], [7], [3], [15, 17], [7], [11]]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 354test_setup_code: test_list: ['assert tn_ap(1,5,2)==9', 'assert tn_ap(2,6,4)==22', 'assert tn_ap(1,4,5)==16']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 355test_setup_code: test_list: ['assert count_Rectangles(2) == 8', 'assert count_Rectangles(1) == 1', 'assert count_Rectangles(0) == 0']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 356test_setup_code: test_list: ['assert find_angle(47,89)==44', 'assert find_angle(45,95)==40', 'assert find_angle(50,40)==90']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 357test_setup_code: test_list: ['assert find_max([(2, 4), (6, 7), (5, 1), (6, 10), (8, 7)]) == 10', 'assert find_max([(3, 5), (7, 8), (6, 2), (7, 11), (9, 8)]) == 11', 'assert find_max([(4, 6), (8, 9), (7, 3), (8, 12), (10, 9)]) == 12']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 358test_setup_code: test_list: ['assert moddiv_list([4,5,6],[1, 2, 3])==[0, 1, 0]', 'assert moddiv_list([3,2],[1,4])==[0, 2]', 'assert moddiv_list([90,120],[50,70])==[40, 50]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 359test_setup_code: test_list: ['assert Check_Solution(1,3,2) == \"Yes\"', 'assert Check_Solution(1,2,3) == \"No\"', 'assert Check_Solution(1,-5,6) == \"No\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 360test_setup_code: test_list: ['assert get_carol(2) == 7', 'assert get_carol(4) == 223', 'assert get_carol(5) == 959']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 361test_setup_code: test_list: [\"assert remove_empty([[], [], [], 'Red', 'Green', [1,2], 'Blue', [], []])==['Red', 'Green', [1, 2], 'Blue']\", \"assert remove_empty([[], [], [],[],[], 'Green', [1,2], 'Blue', [], []])==[ 'Green', [1, 2], 'Blue']\", \"assert remove_empty([[], [], [], 'Python',[],[], 'programming', 'language',[],[],[], [], []])==['Python', 'programming', 'language']\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 362test_setup_code: test_list: ['assert max_occurrences([1,2,3,1,2,3,12,4,2]) == 2', 'assert max_occurrences([1,2,6,7,0,1,0,1,0]) == 1,0', 'assert max_occurrences([1,2,3,1,2,4,1]) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 363test_setup_code: test_list: ['assert add_K_element([(1, 3, 4), (2, 4, 6), (3, 8, 1)], 4) == [(5, 7, 8), (6, 8, 10), (7, 12, 5)]', 'assert add_K_element([(1, 2, 3), (4, 5, 6), (7, 8, 9)], 8) == [(9, 10, 11), (12, 13, 14), (15, 16, 17)]', 'assert add_K_element([(11, 12, 13), (14, 15, 16), (17, 18, 19)], 9) == [(20, 21, 22), (23, 24, 25), (26, 27, 28)]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 364test_setup_code: test_list: ['assert min_flip_to_make_string_alternate(\"0001010111\") == 2', 'assert min_flip_to_make_string_alternate(\"001\") == 1', 'assert min_flip_to_make_string_alternate(\"010111011\") == 2 ']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 365test_setup_code: test_list: ['assert count_Digit(12345) == 5', 'assert count_Digit(11223305) == 8', 'assert count_Digit(4123459) == 7']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 366test_setup_code: test_list: ['assert adjacent_num_product([1,2,3,4,5,6]) == 30', 'assert adjacent_num_product([1,2,3,4,5]) == 20', 'assert adjacent_num_product([2,3]) == 6']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 367test_setup_code: root = Node(1) \r\nroot.left = Node(2) \r\nroot.right = Node(3) \r\nroot.left.left = Node(4) \r\nroot.left.right = Node(5) \r\nroot.left.left.left = Node(8) \r\nroot1 = Node(1) \r\nroot1.left = Node(2) \r\nroot1.right = Node(3) \r\nroot1.left.left = Node(4) \r\nroot1.left.right = Node(5) \r\nroot1.right.left = Node(6) \r\nroot1.left.left.left = Node(7)\r\nroot2 = Node(1) \r\nroot2.left = Node(2) \r\nroot2.right = Node(3) \r\nroot2.left.left = Node(4) \r\nroot2.left.right = Node(5)\r\nroot2.left.left.left = Node(7)test_list: ['assert is_tree_balanced(root) == False', 'assert is_tree_balanced(root1) == True', 'assert is_tree_balanced(root2) == False ']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 368test_setup_code: test_list: ['assert repeat_tuples((1, 3), 4) == ((1, 3), (1, 3), (1, 3), (1, 3))', 'assert repeat_tuples((1, 2), 3) == ((1, 2), (1, 2), (1, 2))', 'assert repeat_tuples((3, 4), 5) == ((3, 4), (3, 4), (3, 4), (3, 4), (3, 4))']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 369test_setup_code: test_list: ['assert lateralsurface_cuboid(8,5,6)==156', 'assert lateralsurface_cuboid(7,9,10)==320', 'assert lateralsurface_cuboid(10,20,30)==1800']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 370test_setup_code: test_list: [\"assert float_sort([('item1', '12.20'), ('item2', '15.10'), ('item3', '24.5')])==[('item3', '24.5'), ('item2', '15.10'), ('item1', '12.20')] \", \"assert float_sort([('item1', '15'), ('item2', '10'), ('item3', '20')])==[('item3', '20'), ('item1', '15'), ('item2', '10')] \", \"assert float_sort([('item1', '5'), ('item2', '10'), ('item3', '14')])==[('item3', '14'), ('item2', '10'), ('item1', '5')] \"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 371test_setup_code: test_list: ['assert smallest_missing([0, 1, 2, 3, 4, 5, 6], 0, 6) == 7', 'assert smallest_missing([0, 1, 2, 6, 9, 11, 15], 0, 6) == 3', 'assert smallest_missing([1, 2, 3, 4, 6, 9, 11, 15], 0, 7) == 0']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 372test_setup_code: test_list: ['assert heap_assending([18, 14, 10, 9, 8, 7, 9, 3, 2, 4, 1])==[1, 2, 3, 4, 7, 8, 9, 9, 10, 14, 18]', 'assert heap_assending([25, 35, 22, 85, 14, 65, 75, 25, 58])==[14, 22, 25, 25, 35, 58, 65, 75, 85]', 'assert heap_assending([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 373test_setup_code: test_list: ['assert volume_cuboid(1,2,3)==6', 'assert volume_cuboid(5,7,9)==315', 'assert volume_cuboid(10,15,21)==3150']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 374test_setup_code: test_list: [\"assert permute_string('ab')==['ab', 'ba']\", \"assert permute_string('abc')==['abc', 'bac', 'bca', 'acb', 'cab', 'cba']\", \"assert permute_string('abcd')==['abcd', 'bacd', 'bcad', 'bcda', 'acbd', 'cabd', 'cbad', 'cbda', 'acdb', 'cadb', 'cdab', 'cdba', 'abdc', 'badc', 'bdac', 'bdca', 'adbc', 'dabc', 'dbac', 'dbca', 'adcb', 'dacb', 'dcab', 'dcba']\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 375test_setup_code: test_list: ['assert round_num(4722,10)==4720', 'assert round_num(1111,5)==1110', 'assert round_num(219,2)==218']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 376test_setup_code: test_list: [\"assert remove_replica((1, 1, 4, 4, 4, 5, 5, 6, 7, 7)) == (1, 'MSP', 4, 'MSP', 'MSP', 5, 'MSP', 6, 7, 'MSP')\", \"assert remove_replica((2, 3, 4, 4, 5, 6, 6, 7, 8, 9, 9)) == (2, 3, 4, 'MSP', 5, 6, 'MSP', 7, 8, 9, 'MSP')\", \"assert remove_replica((2, 2, 5, 4, 5, 7, 5, 6, 7, 7)) == (2, 'MSP', 5, 4, 'MSP', 7, 'MSP', 6, 'MSP', 'MSP')\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 377test_setup_code: test_list: ['assert remove_Char(\"aba\",\\'a\\') == \"b\"', 'assert remove_Char(\"toggle\",\\'g\\') == \"tole\"', 'assert remove_Char(\"aabbc\",\\'b\\') == \"aac\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 378test_setup_code: test_list: ['assert move_first([1,2,3,4]) == [4,1,2,3]', 'assert move_first([0,1,2,3]) == [3,0,1,2]', 'assert move_first([9,8,7,1]) == [1,9,8,7]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 379test_setup_code: test_list: ['assert surfacearea_cuboid(1,2,3)==22', 'assert surfacearea_cuboid(5,7,9)==286', 'assert surfacearea_cuboid(10,15,21)==1350']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 380test_setup_code: test_list: ['assert multi_list(3,4)==[[0, 0, 0, 0], [0, 1, 2, 3], [0, 2, 4, 6]] ', 'assert multi_list(5,7)==[[0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 3, 4, 5, 6], [0, 2, 4, 6, 8, 10, 12], [0, 3, 6, 9, 12, 15, 18], [0, 4, 8, 12, 16, 20, 24]]', 'assert multi_list(10,15)==[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28], [0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42], [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56], [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70], [0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84], [0, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98], [0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112], [0, 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126]]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 381test_setup_code: test_list: [\"assert 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)]\", \"assert index_on_inner_list([('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,1)==[('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98), ('Brady Kent', 97, 96), ('Greyson Fulton', 98, 99)]\", \"assert index_on_inner_list([('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,2)==[('Wyatt Knott', 91, 94), ('Brady Kent', 97, 96), ('Beau Turnbull', 94, 98), ('Greyson Fulton', 98, 99)]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 382test_setup_code: test_list: ['assert find_rotation_count([8, 9, 10, 1, 2, 3, 4, 5, 6, 7]) == 3', 'assert find_rotation_count([8, 9, 10,2, 5, 6]) == 3', 'assert find_rotation_count([2, 5, 6, 8, 9, 10]) == 0']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 383test_setup_code: test_list: ['assert even_bit_toggle_number(10) == 15', 'assert even_bit_toggle_number(20) == 1', 'assert even_bit_toggle_number(30) == 11']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 384test_setup_code: test_list: ['assert frequency_Of_Smallest(5,[1,2,3,4,3]) == 1', 'assert frequency_Of_Smallest(7,[3,1,2,5,6,2,3]) == 1', 'assert frequency_Of_Smallest(7,[3,3,6,3,7,4,9]) == 3']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 385test_setup_code: test_list: ['assert get_perrin(9) == 12', 'assert get_perrin(4) == 2', 'assert get_perrin(6) == 5']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 386test_setup_code: test_list: ['assert swap_count(\"[]][][\") == 2', 'assert swap_count(\"[[][]]\") == 0', 'assert swap_count(\"[[][]]][\") == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 387test_setup_code: test_list: ['assert even_or_odd(\"AB3454D\") ==\"Odd\"', 'assert even_or_odd(\"ABC\") == \"Even\"', 'assert even_or_odd(\"AAD\") == \"Odd\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 388test_setup_code: test_list: ['assert highest_Power_of_2(10) == 8', 'assert highest_Power_of_2(19) == 16', 'assert highest_Power_of_2(32) == 32']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 389test_setup_code: test_list: ['assert find_lucas(9) == 76', 'assert find_lucas(4) == 7', 'assert find_lucas(3) == 4']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 390test_setup_code: test_list: [\"assert add_string([1,2,3,4],'temp{0}')==['temp1', 'temp2', 'temp3', 'temp4']\", \"assert add_string(['a','b','c','d'], 'python{0}')==[ 'pythona', 'pythonb', 'pythonc', 'pythond']\", \"assert add_string([5,6,7,8],'string{0}')==['string5', 'string6', 'string7', 'string8']\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 391test_setup_code: test_list: ['assert 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}}]', 'assert convert_list_dictionary([\"abc\",\"def\",\"ghi\",\"jkl\"],[\"python\",\"program\",\"language\",\"programs\"],[100,200,300,400])==[{\\'abc\\':{\\'python\\':100}},{\\'def\\':{\\'program\\':200}},{\\'ghi\\':{\\'language\\':300}},{\\'jkl\\':{\\'programs\\':400}}]', 'assert convert_list_dictionary([\"A1\",\"A2\",\"A3\",\"A4\"],[\"java\",\"C\",\"C++\",\"DBMS\"],[10,20,30,40])==[{\\'A1\\':{\\'java\\':10}},{\\'A2\\':{\\'C\\':20}},{\\'A3\\':{\\'C++\\':30}},{\\'A4\\':{\\'DBMS\\':40}}]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 392test_setup_code: test_list: ['assert get_max_sum(60) == 106', 'assert get_max_sum(10) == 12', 'assert get_max_sum(2) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 393test_setup_code: test_list: ['assert max_length_list([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==(3, [13, 15, 17])', 'assert max_length_list([[1,2,3,4,5],[1,2,3,4],[1,2,3],[1,2],[1]])==(5,[1,2,3,4,5])', 'assert max_length_list([[3,4,5],[6,7,8,9],[10,11,12]])==(4,[6,7,8,9])']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 394test_setup_code: test_list: ['assert check_distinct((1, 4, 5, 6, 1, 4)) == False', 'assert check_distinct((1, 4, 5, 6)) == True', 'assert check_distinct((2, 3, 4, 5, 6)) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 395test_setup_code: test_list: ['assert first_non_repeating_character(\"abcabc\") == None', 'assert first_non_repeating_character(\"abc\") == \"a\"', 'assert first_non_repeating_character(\"ababc\") == \"c\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 396test_setup_code: test_list: ['assert check_char(\"abba\") == \"Valid\"', 'assert check_char(\"a\") == \"Valid\"', 'assert check_char(\"abcd\") == \"Invalid\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 397test_setup_code: test_list: ['assert median_numbers(25,55,65)==55.0', 'assert median_numbers(20,10,30)==20.0', 'assert median_numbers(15,45,75)==45.0']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 398test_setup_code: test_list: ['assert sum_of_digits([10,2,56])==14', \"assert sum_of_digits([[10,20,4,5,'b',70,'a']])==19\", 'assert sum_of_digits([10,20,-4,5,-70])==19']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 399test_setup_code: test_list: ['assert bitwise_xor((10, 4, 6, 9), (5, 2, 3, 3)) == (15, 6, 5, 10)', 'assert bitwise_xor((11, 5, 7, 10), (6, 3, 4, 4)) == (13, 6, 3, 14)', 'assert bitwise_xor((12, 6, 8, 11), (7, 4, 5, 6)) == (11, 2, 13, 13)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 400test_setup_code: test_list: ['assert extract_freq([(3, 4), (1, 2), (4, 3), (5, 6)] ) == 3', 'assert extract_freq([(4, 15), (2, 3), (5, 4), (6, 7)] ) == 4', 'assert extract_freq([(5, 16), (2, 3), (6, 5), (6, 9)] ) == 4']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 401test_setup_code: test_list: ['assert 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))', 'assert add_nested_tuples(((2, 4), (5, 6), (3, 10), (2, 11)), ((7, 8), (4, 10), (2, 2), (8, 4))) == ((9, 12), (9, 16), (5, 12), (10, 15))', 'assert add_nested_tuples(((3, 5), (6, 7), (4, 11), (3, 12)), ((8, 9), (5, 11), (3, 3), (9, 5))) == ((11, 14), (11, 18), (7, 14), (12, 17))']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 402test_setup_code: test_list: ['assert ncr_modp(10,2,13)==6', 'assert ncr_modp(15,12,43)==25', 'assert ncr_modp(17,9,18)==10']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 403test_setup_code: test_list: ['assert is_valid_URL(\"https://www.google.com\") == True', 'assert is_valid_URL(\"https:/www.gmail.com\") == False', 'assert is_valid_URL(\"https:// www.redit.com\") == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 404test_setup_code: test_list: ['assert minimum(1,2) == 1', 'assert minimum(-5,-4) == -5', 'assert minimum(0,0) == 0']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 405test_setup_code: test_list: ['assert check_tuplex((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),\\'r\\')==True', 'assert check_tuplex((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),\\'5\\')==False', 'assert check_tuplex((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\",\"e\"),3)==True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 406test_setup_code: test_list: ['assert find_Parity(12) == \"Even Parity\"', 'assert find_Parity(7) == \"Odd Parity\"', 'assert find_Parity(10) == \"Even Parity\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 407test_setup_code: test_list: ['assert rearrange_bigger(12)==21', 'assert rearrange_bigger(10)==False', 'assert rearrange_bigger(102)==120']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 408test_setup_code: test_list: ['assert k_smallest_pairs([1,3,7],[2,4,6],2)==[[1, 2], [1, 4]]', 'assert k_smallest_pairs([1,3,7],[2,4,6],1)==[[1, 2]]', 'assert k_smallest_pairs([1,3,7],[2,4,6],7)==[[1, 2], [1, 4], [3, 2], [1, 6], [3, 4], [3, 6], [7, 2]]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 409test_setup_code: test_list: ['assert min_product_tuple([(2, 7), (2, 6), (1, 8), (4, 9)] )==8', 'assert min_product_tuple([(10,20), (15,2), (5,10)] )==30', 'assert min_product_tuple([(11,44), (10,15), (20,5), (12, 9)] )==100']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 410test_setup_code: test_list: [\"assert min_val(['Python', 3, 2, 4, 5, 'version'])==2\", \"assert min_val(['Python', 15, 20, 25])==15\", \"assert min_val(['Python', 30, 20, 40, 50, 'version'])==20\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 411test_setup_code: test_list: [\"assert snake_to_camel('android_tv') == 'AndroidTv'\", \"assert snake_to_camel('google_pixel') == 'GooglePixel'\", \"assert snake_to_camel('apple_watch') == 'AppleWatch'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 412test_setup_code: test_list: ['assert remove_odd([1,2,3]) == [2]', 'assert remove_odd([2,4,6]) == [2,4,6]', 'assert remove_odd([10,20,3]) == [10,20]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 413test_setup_code: test_list: [\"assert extract_nth_element([('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,0)==['Greyson Fulton', 'Brady Kent', 'Wyatt Knott', 'Beau Turnbull']\", \"assert extract_nth_element([('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,2)==[99, 96, 94, 98]\", \"assert extract_nth_element([('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)],1)==[98, 97, 91, 94]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 414test_setup_code: test_list: ['assert overlapping([1,2,3,4,5],[6,7,8,9]) == False', 'assert overlapping([1,2,3],[4,5,6]) == False', 'assert overlapping([1,4,5],[1,4,5]) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 415test_setup_code: test_list: ['assert max_Product([1,2,3,4,7,0,8,4]) == (7,8)', 'assert max_Product([0,-1,-2,-4,5,0,-6]) == (-4,-6)', 'assert max_Product([1,2,3]) == (2,3)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 416test_setup_code: test_list: ['assert breakSum(12) == 13', 'assert breakSum(24) == 27', 'assert breakSum(23) == 23']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 417test_setup_code: test_list: [\"assert group_tuples([('x', 'y'), ('x', 'z'), ('w', 't')]) == [('x', 'y', 'z'), ('w', 't')]\", \"assert group_tuples([('a', 'b'), ('a', 'c'), ('d', 'e')]) == [('a', 'b', 'c'), ('d', 'e')]\", \"assert group_tuples([('f', 'g'), ('f', 'g'), ('h', 'i')]) == [('f', 'g', 'g'), ('h', 'i')]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 418test_setup_code: test_list: [\"assert Find_Max([['A'],['A','B'],['A','B','C']]) == ['A','B','C']\", 'assert Find_Max([[1],[1,2],[1,2,3]]) == [1,2,3]', 'assert Find_Max([[1,1],[1,2,3],[1,5,6,1]]) == [1,5,6,1]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 419test_setup_code: test_list: ['assert round_and_sum([22.4, 4.0, -16.22, -9.10, 11.00, -12.22, 14.20, -5.20, 17.50])==243', 'assert round_and_sum([5,2,9,24.3,29])==345', 'assert round_and_sum([25.0,56.7,89.2])==513']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 420test_setup_code: test_list: ['assert cube_Sum(2) == 72', 'assert cube_Sum(3) == 288', 'assert cube_Sum(4) == 800']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 421test_setup_code: test_list: ['assert concatenate_tuple((\"ID\", \"is\", 4, \"UTS\") ) == \\'ID-is-4-UTS\\'', 'assert concatenate_tuple((\"QWE\", \"is\", 4, \"RTY\") ) == \\'QWE-is-4-RTY\\'', 'assert concatenate_tuple((\"ZEN\", \"is\", 4, \"OP\") ) == \\'ZEN-is-4-OP\\'']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 422test_setup_code: test_list: ['assert find_Average_Of_Cube(2) == 4.5', 'assert find_Average_Of_Cube(3) == 12', 'assert find_Average_Of_Cube(1) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 423test_setup_code: test_list: ['assert get_maxgold([[1, 3, 1, 5],[2, 2, 4, 1],[5, 0, 2, 3],[0, 6, 1, 2]],4,4)==16', 'assert get_maxgold([[10,20],[30,40]],2,2)==70', 'assert get_maxgold([[4,9],[3,7]],2,2)==13']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 424test_setup_code: test_list: [\"assert extract_rear(('Mers', 'for', 'Vers') ) == ['s', 'r', 's']\", \"assert extract_rear(('Avenge', 'for', 'People') ) == ['e', 'r', 'e']\", \"assert extract_rear(('Gotta', 'get', 'go') ) == ['a', 't', 'o']\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 425test_setup_code: test_list: ['assert count_element_in_list([[1, 3], [5, 7], [1, 11], [1, 15, 7]],1)==3', \"assert count_element_in_list([['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'A')==3\", \"assert count_element_in_list([['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'E')==1\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 426test_setup_code: test_list: ['assert filter_oddnumbers([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1,3,5,7,9]', 'assert filter_oddnumbers([10,20,45,67,84,93])==[45,67,93]', 'assert filter_oddnumbers([5,7,9,8,6,4,3])==[5,7,9,3]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 427test_setup_code: test_list: ['assert change_date_format(\"2026-01-02\") == \\'02-01-2026\\'', 'assert change_date_format(\"2020-11-13\") == \\'13-11-2020\\'', 'assert change_date_format(\"2021-04-26\") == \\'26-04-2021\\'']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 428test_setup_code: test_list: ['assert shell_sort([12, 23, 4, 5, 3, 2, 12, 81, 56, 95]) == [2, 3, 4, 5, 12, 12, 23, 56, 81, 95]', 'assert shell_sort([24, 22, 39, 34, 87, 73, 68]) == [22, 24, 34, 39, 68, 73, 87]', 'assert shell_sort([32, 30, 16, 96, 82, 83, 74]) == [16, 30, 32, 74, 82, 83, 96]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 429test_setup_code: test_list: ['assert and_tuples((10, 4, 6, 9), (5, 2, 3, 3)) == (0, 0, 2, 1)', 'assert and_tuples((1, 2, 3, 4), (5, 6, 7, 8)) == (1, 2, 3, 0)', 'assert and_tuples((8, 9, 11, 12), (7, 13, 14, 17)) == (0, 9, 10, 0)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 430test_setup_code: test_list: ['assert parabola_directrix(5,3,2)==-198', 'assert parabola_directrix(9,8,4)==-2336', 'assert parabola_directrix(2,4,6)==-130']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 431test_setup_code: test_list: ['assert common_element([1,2,3,4,5], [5,6,7,8,9])==True', 'assert common_element([1,2,3,4,5], [6,7,8,9])==None', \"assert common_element(['a','b','c'], ['d','b','e'])==True\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 432test_setup_code: test_list: ['assert median_trapezium(15,25,35)==20', 'assert median_trapezium(10,20,30)==15', 'assert median_trapezium(6,9,4)==7.5']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 433test_setup_code: test_list: [\"assert check_greater([1, 2, 3, 4, 5], 4) == 'No, entered number is less than those in the array'\", \"assert check_greater([2, 3, 4, 5, 6], 8) == 'Yes, the entered number is greater than those in the array'\", \"assert check_greater([9, 7, 4, 8, 6, 1], 11) == 'Yes, the entered number is greater than those in the array'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 434test_setup_code: test_list: ['assert text_match_one(\"ac\")==(\\'Not matched!\\')', 'assert text_match_one(\"dc\")==(\\'Not matched!\\')', 'assert text_match_one(\"abba\")==(\\'Found a match!\\')']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 435test_setup_code: test_list: ['assert last_Digit(123) == 3', 'assert last_Digit(25) == 5', 'assert last_Digit(30) == 0']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 436test_setup_code: test_list: ['assert neg_nos([-1,4,5,-6]) == -1,-6', 'assert neg_nos([-1,-2,3,4]) == -1,-2', 'assert neg_nos([-7,-6,8,9]) == -7,-6']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 437test_setup_code: test_list: ['assert remove_odd(\"python\")==(\"yhn\")', 'assert remove_odd(\"program\")==(\"rga\")', 'assert remove_odd(\"language\")==(\"agae\")']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 438test_setup_code: test_list: [\"assert count_bidirectional([(5, 6), (1, 2), (6, 5), (9, 1), (6, 5), (2, 1)] ) == '3'\", \"assert count_bidirectional([(5, 6), (1, 3), (6, 5), (9, 1), (6, 5), (2, 1)] ) == '2'\", \"assert count_bidirectional([(5, 6), (1, 2), (6, 5), (9, 2), (6, 5), (2, 1)] ) == '4'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 439test_setup_code: test_list: ['assert multiple_to_single([11, 33, 50])==113350', 'assert multiple_to_single([-1,2,3,4,5,6])==-123456', 'assert multiple_to_single([10,15,20,25])==10152025']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 440test_setup_code: test_list: ['assert find_adverb_position(\"clearly!! we can see the sky\")==(0, 7, \\'clearly\\')', 'assert find_adverb_position(\"seriously!! there are many roses\")==(0, 9, \\'seriously\\')', 'assert find_adverb_position(\"unfortunately!! sita is going to home\")==(0, 13, \\'unfortunately\\')']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 441test_setup_code: test_list: ['assert surfacearea_cube(5)==150', 'assert surfacearea_cube(3)==54', 'assert surfacearea_cube(10)==600']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 442test_setup_code: test_list: ['assert positive_count([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8])==0.54', 'assert positive_count([2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==0.69', 'assert positive_count([2, 4, -6, -9, 11, -12, 14, -5, 17])==0.56']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 443test_setup_code: test_list: ['assert largest_neg([1,2,3,-4,-6]) == -6', 'assert largest_neg([1,2,3,-8,-9]) == -9', 'assert largest_neg([1,2,3,4,-1]) == -1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 444test_setup_code: test_list: [\"assert 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,)]'\", \"assert trim_tuple([(5, 3, 2, 1, 4), (3, 4, 9, 2, 1), (9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 1) == '[(3, 2, 1), (4, 9, 2), (1, 2, 3), (8, 2, 1)]'\", \"assert trim_tuple([(7, 8, 4, 9), (11, 8, 12, 4),(4, 1, 7, 8), (3, 6, 9, 7)], 1) == '[(8, 4), (8, 12), (1, 7), (6, 9)]'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 445test_setup_code: test_list: ['assert 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))', 'assert index_multiplication(((2, 4), (5, 6), (3, 10), (2, 11)),((7, 8), (4, 10), (2, 2), (8, 4)) ) == ((14, 32), (20, 60), (6, 20), (16, 44))', 'assert index_multiplication(((3, 5), (6, 7), (4, 11), (3, 12)),((8, 9), (5, 11), (3, 3), (9, 5)) ) == ((24, 45), (30, 77), (12, 33), (27, 60))']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 446test_setup_code: test_list: [\"assert count_Occurrence(('a', 'a', 'c', 'b', 'd'),['a', 'b'] ) == 3\", 'assert count_Occurrence((1, 2, 3, 1, 4, 6, 7, 1, 4),[1, 4, 7]) == 6', 'assert count_Occurrence((1,2,3,4,5,6),[1,2]) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 447test_setup_code: test_list: ['assert cube_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]', 'assert cube_nums([10,20,30])==([1000, 8000, 27000])', 'assert cube_nums([12,15])==([1728, 3375])']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 448test_setup_code: test_list: ['assert cal_sum(9) == 49', 'assert cal_sum(10) == 66', 'assert cal_sum(11) == 88']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 449test_setup_code: test_list: [\"assert check_Triangle(1,5,2,5,4,6) == 'Yes'\", \"assert check_Triangle(1,1,1,4,1,5) == 'No'\", \"assert check_Triangle(1,1,1,1,1,1) == 'No'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 450test_setup_code: test_list: [\"assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,8)==['practice', 'solution']\", \"assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,6)==['Python']\", \"assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,9)==['exercises']\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 451test_setup_code: test_list: [\"assert remove_whitespaces(' Google Flutter ') == 'GoogleFlutter'\", \"assert remove_whitespaces(' Google Dart ') == 'GoogleDart'\", \"assert remove_whitespaces(' iOS Swift ') == 'iOSSwift'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 452test_setup_code: test_list: ['assert loss_amount(1500,1200)==None', 'assert loss_amount(100,200)==100', 'assert loss_amount(2000,5000)==3000']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 453test_setup_code: test_list: ['assert sumofFactors(18) == 26', 'assert sumofFactors(30) == 48', 'assert sumofFactors(6) == 8']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 454test_setup_code: test_list: ['assert text_match_wordz(\"pythonz.\")==(\\'Found a match!\\')', 'assert text_match_wordz(\"xyz.\")==(\\'Found a match!\\')', 'assert text_match_wordz(\" lang .\")==(\\'Not matched!\\')']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 455test_setup_code: test_list: ['assert check_monthnumb_number(5)==True', 'assert check_monthnumb_number(2)==False', 'assert check_monthnumb_number(6)==False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 456test_setup_code: test_list: [\"assert reverse_string_list(['Red', 'Green', 'Blue', 'White', 'Black'])==['deR', 'neerG', 'eulB', 'etihW', 'kcalB']\", \"assert reverse_string_list(['john','amal','joel','george'])==['nhoj','lama','leoj','egroeg']\", \"assert reverse_string_list(['jack','john','mary'])==['kcaj','nhoj','yram']\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 457test_setup_code: test_list: ['assert Find_Min([[1],[1,2],[1,2,3]]) == [1]', 'assert Find_Min([[1,1],[1,1,1],[1,2,7,8]]) == [1,1]', \"assert Find_Min([['x'],['x','y'],['x','y','z']]) == ['x']\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 458test_setup_code: test_list: ['assert rectangle_area(10,20)==200', 'assert rectangle_area(10,5)==50', 'assert rectangle_area(4,2)==8']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 459test_setup_code: test_list: [\"assert remove_uppercase('cAstyoUrFavoRitETVshoWs') == 'cstyoravoitshos'\", \"assert remove_uppercase('wAtchTheinTernEtrAdIo') == 'wtchheinerntrdo'\", \"assert remove_uppercase('VoicESeaRchAndreComMendaTionS') == 'oiceachndreomendaion'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 460test_setup_code: test_list: ['assert Extract([[1, 2], [3, 4, 5], [6, 7, 8, 9]]) == [1, 3, 6]', 'assert Extract([[1,2,3],[4, 5]]) == [1,4]', 'assert Extract([[9,8,1],[1,2]]) == [9,1]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 461test_setup_code: test_list: [\"assert upper_ctr('PYthon') == 1\", \"assert upper_ctr('BigData') == 1\", \"assert upper_ctr('program') == 0\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 462test_setup_code: test_list: [\"assert 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']]\", \"assert combinations_list(['red', 'green', 'blue', 'white', 'black', 'orange'])==[[], ['red'], ['green'], ['green', 'red'], ['blue'], ['blue', 'red'], ['blue', 'green'], ['blue', 'green', 'red'], ['white'], ['white', 'red'], ['white', 'green'], ['white', 'green', 'red'], ['white', 'blue'], ['white', 'blue', 'red'], ['white', 'blue', 'green'], ['white', 'blue', 'green', 'red'], ['black'], ['black', 'red'], ['black', 'green'], ['black', 'green', 'red'], ['black', 'blue'], ['black', 'blue', 'red'], ['black', 'blue', 'green'], ['black', 'blue', 'green', 'red'], ['black', 'white'], ['black', 'white', 'red'], ['black', 'white', 'green'], ['black', 'white', 'green', 'red'], ['black', 'white', 'blue'], ['black', 'white', 'blue', 'red'], ['black', 'white', 'blue', 'green'], ['black', 'white', 'blue', 'green', 'red'], ['orange'], ['orange', 'red'], ['orange', 'green'], ['orange', 'green', 'red'], ['orange', 'blue'], ['orange', 'blue', 'red'], ['orange', 'blue', 'green'], ['orange', 'blue', 'green', 'red'], ['orange', 'white'], ['orange', 'white', 'red'], ['orange', 'white', 'green'], ['orange', 'white', 'green', 'red'], ['orange', 'white', 'blue'], ['orange', 'white', 'blue', 'red'], ['orange', 'white', 'blue', 'green'], ['orange', 'white', 'blue', 'green', 'red'], ['orange', 'black'], ['orange', 'black', 'red'], ['orange', 'black', 'green'], ['orange', 'black', 'green', 'red'], ['orange', 'black', 'blue'], ['orange', 'black', 'blue', 'red'], ['orange', 'black', 'blue', 'green'], ['orange', 'black', 'blue', 'green', 'red'], ['orange', 'black', 'white'], ['orange', 'black', 'white', 'red'], ['orange', 'black', 'white', 'green'], ['orange', 'black', 'white', 'green', 'red'], ['orange', 'black', 'white', 'blue'], ['orange', 'black', 'white', 'blue', 'red'], ['orange', 'black', 'white', 'blue', 'green'], ['orange', 'black', 'white', 'blue', 'green', 'red']]\", \"assert combinations_list(['red', 'green', 'black', 'orange'])==[[], ['red'], ['green'], ['green', 'red'], ['black'], ['black', 'red'], ['black', 'green'], ['black', 'green', 'red'], ['orange'], ['orange', 'red'], ['orange', 'green'], ['orange', 'green', 'red'], ['orange', 'black'], ['orange', 'black', 'red'], ['orange', 'black', 'green'], ['orange', 'black', 'green', 'red']]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 463test_setup_code: test_list: ['assert max_subarray_product([1, -2, -3, 0, 7, -8, -2]) == 112', 'assert max_subarray_product([6, -3, -10, 0, 2]) == 180 ', 'assert max_subarray_product([-2, -40, 0, -2, -3]) == 80']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 464test_setup_code: test_list: [\"assert check_value({'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},10)==False\", \"assert check_value({'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},12)==True\", \"assert check_value({'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},5)==False\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 465test_setup_code: test_list: [\"assert drop_empty({'c1': 'Red', 'c2': 'Green', 'c3':None})=={'c1': 'Red', 'c2': 'Green'}\", \"assert drop_empty({'c1': 'Red', 'c2': None, 'c3':None})=={'c1': 'Red'}\", \"assert drop_empty({'c1': None, 'c2': 'Green', 'c3':None})=={ 'c2': 'Green'}\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 466test_setup_code: test_list: ['assert find_peak([1, 3, 20, 4, 1, 0], 6) == 2', 'assert find_peak([2, 3, 4, 5, 6], 5) == 4', 'assert find_peak([8, 9, 11, 12, 14, 15], 6) == 5 ']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 467test_setup_code: test_list: ['assert decimal_to_Octal(10) == 12', 'assert decimal_to_Octal(2) == 2', 'assert decimal_to_Octal(33) == 41']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 468test_setup_code: test_list: ['assert max_product([3, 100, 4, 5, 150, 6], 6) == 45000 ', 'assert max_product([4, 42, 55, 68, 80], 5) == 50265600', 'assert max_product([10, 22, 9, 33, 21, 50, 41, 60], 8) == 21780000 ']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 469test_setup_code: test_list: ['assert max_profit([1, 5, 2, 3, 7, 6, 4, 5], 3) == 10', 'assert max_profit([2, 4, 7, 5, 4, 3, 5], 2) == 7', 'assert max_profit([10, 6, 8, 4, 2], 2) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 470test_setup_code: test_list: ['assert add_pairwise((1, 5, 7, 8, 10)) == (6, 12, 15, 18)', 'assert add_pairwise((2, 6, 8, 9, 11)) == (8, 14, 17, 20)', 'assert add_pairwise((3, 7, 9, 10, 12)) == (10, 16, 19, 22)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 471test_setup_code: test_list: ['assert find_remainder([ 100, 10, 5, 25, 35, 14 ],6,11) ==9', 'assert find_remainder([1,1,1],3,1) == 0', 'assert find_remainder([1,2,1],3,2) == 0']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 472test_setup_code: test_list: ['assert check_Consecutive([1,2,3,4,5]) == True', 'assert check_Consecutive([1,2,3,5,6]) == False', 'assert check_Consecutive([1,2,1]) == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 473test_setup_code: test_list: ['assert tuple_intersection([(3, 4), (5, 6), (9, 10), (4, 5)] , [(5, 4), (3, 4), (6, 5), (9, 11)]) == {(4, 5), (3, 4), (5, 6)}', 'assert tuple_intersection([(4, 1), (7, 4), (11, 13), (17, 14)] , [(1, 4), (7, 4), (16, 12), (10, 13)]) == {(4, 7), (1, 4)}', 'assert tuple_intersection([(2, 1), (3, 2), (1, 3), (1, 4)] , [(11, 2), (2, 3), (6, 2), (1, 3)]) == {(1, 3), (2, 3)}']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 474test_setup_code: test_list: ['assert replace_char(\"polygon\",\\'y\\',\\'l\\')==(\"pollgon\")', 'assert replace_char(\"character\",\\'c\\',\\'a\\')==(\"aharaater\")', 'assert replace_char(\"python\",\\'l\\',\\'a\\')==(\"python\")']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 475test_setup_code: test_list: [\"assert sort_counter({'Math':81, 'Physics':83, 'Chemistry':87})==[('Chemistry', 87), ('Physics', 83), ('Math', 81)]\", \"assert sort_counter({'Math':400, 'Physics':300, 'Chemistry':250})==[('Math', 400), ('Physics', 300), ('Chemistry', 250)]\", \"assert sort_counter({'Math':900, 'Physics':1000, 'Chemistry':1250})==[('Chemistry', 1250), ('Physics', 1000), ('Math', 900)]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 476test_setup_code: test_list: ['assert big_sum([1,2,3]) == 4', 'assert big_sum([-1,2,3,4]) == 3', 'assert big_sum([2,3,6]) == 8']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 477test_setup_code: test_list: ['assert is_lower(\"InValid\") == \"invalid\"', 'assert is_lower(\"TruE\") == \"true\"', 'assert is_lower(\"SenTenCE\") == \"sentence\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 478test_setup_code: test_list: ['assert remove_lowercase(\"PYTHon\")==(\\'PYTH\\')', 'assert remove_lowercase(\"FInD\")==(\\'FID\\')', 'assert remove_lowercase(\"STRinG\")==(\\'STRG\\')']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 479test_setup_code: test_list: ['assert first_Digit(123) == 1', 'assert first_Digit(456) == 4', 'assert first_Digit(12) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 480test_setup_code: test_list: ['assert get_max_occuring_char(\"data\") == \"a\"', 'assert get_max_occuring_char(\"create\") == \"e\"', 'assert get_max_occuring_char(\"brilliant girl\") == \"i\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 481test_setup_code: test_list: ['assert is_subset_sum([3, 34, 4, 12, 5, 2], 6, 9) == True', 'assert is_subset_sum([3, 34, 4, 12, 5, 2], 6, 30) == False', 'assert is_subset_sum([3, 34, 4, 12, 5, 2], 6, 15) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 482test_setup_code: test_list: ['assert match(\"Geeks\") == \\'Yes\\'', 'assert match(\"geeksforGeeks\") == \\'Yes\\'', 'assert match(\"geeks\") == \\'No\\'']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 483test_setup_code: test_list: ['assert first_Factorial_Divisible_Number(10) == 5', 'assert first_Factorial_Divisible_Number(15) == 5', 'assert first_Factorial_Divisible_Number(5) == 4']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 484test_setup_code: test_list: [\"assert remove_matching_tuple([('Hello', 'dude'), ('How', 'are'), ('you', '?')], [('Hello', 'dude'), ('How', 'are')]) == [('you', '?')]\", \"assert remove_matching_tuple([('Part', 'of'), ('the', 'journey'), ('is ', 'end')], [('Journey', 'the'), ('is', 'end')]) == [('Part', 'of'), ('the', 'journey'), ('is ', 'end')]\", \"assert remove_matching_tuple([('Its', 'been'), ('a', 'long'), ('day', 'without')], [('a', 'long'), ('my', 'friend')]) == [('Its', 'been'), ('day', 'without')]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 485test_setup_code: test_list: ['assert largest_palindrome([1, 232, 54545, 999991], 4) == 54545', 'assert largest_palindrome([1, 2, 3, 4, 5, 50], 6) == 5', 'assert largest_palindrome([1, 3, 7, 9, 45], 5) == 9']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 486test_setup_code: test_list: ['assert binomial_probability(10, 5, 1.0/3) == 0.13656454808718185', 'assert binomial_probability(11, 6, 2.0/4) == 0.2255859375', 'assert binomial_probability(12, 7, 3.0/5) == 0.227030335488']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 487test_setup_code: test_list: ['assert sort_tuple([(1, 3), (3, 2), (2, 1)] ) == [(2, 1), (3, 2), (1, 3)]', 'assert sort_tuple([(2, 4), (3, 3), (1, 1)] ) == [(1, 1), (3, 3), (2, 4)]', 'assert sort_tuple([(3, 9), (6, 7), (4, 3)] ) == [(4, 3), (6, 7), (3, 9)]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 488test_setup_code: test_list: ['assert area_pentagon(5)==43.01193501472417', 'assert area_pentagon(10)==172.0477400588967', 'assert area_pentagon(15)==387.10741513251753']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 489test_setup_code: test_list: ['assert frequency_Of_Largest(5,[1,2,3,4,4]) == 2', 'assert frequency_Of_Largest(3,[5,6,5]) == 1', 'assert frequency_Of_Largest(4,[2,7,7,7]) == 3']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 490test_setup_code: test_list: ['assert extract_symmetric([(6, 7), (2, 3), (7, 6), (9, 8), (10, 2), (8, 9)] ) == {(8, 9), (6, 7)}', 'assert extract_symmetric([(7, 8), (3, 4), (8, 7), (10, 9), (11, 3), (9, 10)] ) == {(9, 10), (7, 8)}', 'assert extract_symmetric([(8, 9), (4, 5), (9, 8), (11, 10), (12, 4), (10, 11)] ) == {(8, 9), (10, 11)}']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 491test_setup_code: test_list: ['assert sum_gp(1,5,2)==31', 'assert sum_gp(1,5,4)==341', 'assert sum_gp(2,6,3)==728']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 492test_setup_code: test_list: ['assert binary_search([1,2,3,5,8], 6) == False', 'assert binary_search([7, 8, 9, 10, 13], 10) == True', 'assert binary_search([11, 13, 14, 19, 22, 36], 23) == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 493test_setup_code: test_list: ['assert 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)]]', 'assert calculate_polygons(5,4,7,9,8)==[[(-11.0, -9.856406460551018), (-11.0, -0.6188021535170058), (-3.0, 4.0), (5.0, -0.6188021535170058), (5.0, -9.856406460551018), (-3.0, -14.475208614068023), (-11.0, -9.856406460551018)], [(5.0, -9.856406460551018), (5.0, -0.6188021535170058), (13.0, 4.0), (21.0, -0.6188021535170058), (21.0, -9.856406460551018), (13.0, -14.475208614068023), (5.0, -9.856406460551018)], [(21.0, -9.856406460551018), (21.0, -0.6188021535170058), (29.0, 4.0), (37.0, -0.6188021535170058), (37.0, -9.856406460551018), (29.0, -14.475208614068023), (21.0, -9.856406460551018)], [(-3.0, 4.0), (-3.0, 13.237604307034012), (5.0, 17.856406460551018), (13.0, 13.237604307034012), (13.0, 4.0), (5.0, -0.6188021535170058), (-3.0, 4.0)], [(13.0, 4.0), (13.0, 13.237604307034012), (21.0, 17.856406460551018), (29.0, 13.237604307034012), (29.0, 4.0), (21.0, -0.6188021535170058), (13.0, 4.0)], [(-11.0, 17.856406460551018), (-11.0, 27.09401076758503), (-3.0, 31.712812921102035), (5.0, 27.09401076758503), (5.0, 17.856406460551018), (-3.0, 13.237604307034012), (-11.0, 17.856406460551018)], [(5.0, 17.856406460551018), (5.0, 27.09401076758503), (13.0, 31.712812921102035), (21.0, 27.09401076758503), (21.0, 17.856406460551018), (13.0, 13.237604307034012), (5.0, 17.856406460551018)], [(21.0, 17.856406460551018), (21.0, 27.09401076758503), (29.0, 31.712812921102035), (37.0, 27.09401076758503), (37.0, 17.856406460551018), (29.0, 13.237604307034012), (21.0, 17.856406460551018)], [(-3.0, 31.712812921102035), (-3.0, 40.95041722813605), (5.0, 45.569219381653056), (13.0, 40.95041722813605), (13.0, 31.712812921102035), (5.0, 27.09401076758503), (-3.0, 31.712812921102035)], [(13.0, 31.712812921102035), (13.0, 40.95041722813605), (21.0, 45.569219381653056), (29.0, 40.95041722813605), (29.0, 31.712812921102035), (21.0, 27.09401076758503), (13.0, 31.712812921102035)]]', 'assert calculate_polygons(9,6,4,3,2)==[[(5.0, 2.5358983848622456), (5.0, 4.8452994616207485), (7.0, 6.0), (9.0, 4.8452994616207485), (9.0, 2.5358983848622456), (7.0, 1.3811978464829942), (5.0, 2.5358983848622456)], [(7.0, 6.0), (7.0, 8.309401076758503), (9.0, 9.464101615137753), (11.0, 8.309401076758503), (11.0, 6.0), (9.0, 4.8452994616207485), (7.0, 6.0)]]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 494test_setup_code: test_list: [\"assert binary_to_integer((1, 1, 0, 1, 0, 0, 1)) == '105'\", \"assert binary_to_integer((0, 1, 1, 0, 0, 1, 0, 1)) == '101'\", \"assert binary_to_integer((1, 1, 0, 1, 0, 1)) == '53'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 495test_setup_code: test_list: [\"assert remove_lowercase('KDeoALOklOOHserfLoAJSIskdsf') == 'KDALOOOHLAJSI'\", \"assert remove_lowercase('ProducTnamEstreAmIngMediAplAYer') == 'PTEAIMAAY'\", \"assert remove_lowercase('maNufacTuredbYSheZenTechNolOGIes') == 'NTYSZTNOGI'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 496test_setup_code: test_list: ['assert heap_queue_smallest( [25, 35, 22, 85, 14, 65, 75, 25, 58],3)==[14, 22, 25] ', 'assert heap_queue_smallest( [25, 35, 22, 85, 14, 65, 75, 25, 58],2)==[14, 22]', 'assert heap_queue_smallest( [25, 35, 22, 85, 14, 65, 75, 22, 58],5)==[14, 22, 22, 25, 35]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 497test_setup_code: test_list: ['assert surfacearea_cone(5,12)==282.7433388230814', 'assert surfacearea_cone(10,15)==880.5179353159282', 'assert surfacearea_cone(19,17)==2655.923961165254']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 498test_setup_code: test_list: ['assert gcd(12, 17) == 1', 'assert gcd(4,6) == 2', 'assert gcd(2,9) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 499test_setup_code: test_list: ['assert diameter_circle(10)==20', 'assert diameter_circle(40)==80', 'assert diameter_circle(15)==30']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 500test_setup_code: test_list: [\"assert concatenate_elements(['hello','there','have','a','rocky','day'] ) == ' hello there have a rocky day'\", \"assert concatenate_elements([ 'Hi', 'there', 'How','are', 'you'] ) == ' Hi there How are you'\", \"assert concatenate_elements([ 'Part', 'of', 'the','journey', 'is', 'end'] ) == ' Part of the journey is end'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 501test_setup_code: test_list: ['assert num_comm_div(2,4) == 2', 'assert num_comm_div(2,8) == 2', 'assert num_comm_div(12,24) == 6']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 502test_setup_code: test_list: ['assert find(3,3) == 0', 'assert find(10,3) == 1', 'assert find(16,5) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 503test_setup_code: test_list: ['assert add_consecutive_nums([1, 1, 3, 4, 4, 5, 6, 7])==[2, 4, 7, 8, 9, 11, 13]', 'assert add_consecutive_nums([4, 5, 8, 9, 6, 10])==[9, 13, 17, 15, 16]', 'assert add_consecutive_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[3, 5, 7, 9, 11, 13, 15, 17, 19]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 504test_setup_code: test_list: ['assert sum_Of_Series(5) == 225', 'assert sum_Of_Series(2) == 9', 'assert sum_Of_Series(3) == 36']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 505test_setup_code: test_list: ['assert re_order([6, 0, 8, 2, 3, 0, 4, 0, 1]) == [6, 8, 2, 3, 4, 1, 0, 0, 0]', 'assert re_order([4, 0, 2, 7, 0, 9, 0, 12, 0]) == [4, 2, 7, 9, 12, 0, 0, 0, 0]', 'assert re_order([3, 11, 0, 74, 14, 0, 1, 0, 2]) == [3, 11, 74, 14, 1, 2, 0, 0, 0]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 506test_setup_code: test_list: ['assert permutation_coefficient(10, 2) == 90', 'assert permutation_coefficient(10, 3) == 720', 'assert permutation_coefficient(10, 1) == 10']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 507test_setup_code: test_list: [\"assert remove_words(['red', 'green', 'blue', 'white', 'black', 'orange'],['white', 'orange'])==['red', 'green', 'blue', 'black']\", \"assert remove_words(['red', 'green', 'blue', 'white', 'black', 'orange'],['black', 'orange'])==['red', 'green', 'blue', 'white']\", \"assert remove_words(['red', 'green', 'blue', 'white', 'black', 'orange'],['blue', 'white'])==['red', 'green', 'black', 'orange']\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 508test_setup_code: test_list: ['assert same_order([\"red\",\"green\",\"black\",\"orange\"],[\"red\",\"pink\",\"green\",\"white\",\"black\"])==True', 'assert same_order([\"red\",\"pink\",\"green\",\"white\",\"black\"],[\"white\",\"orange\",\"pink\",\"black\"])==False', 'assert same_order([\"red\",\"green\",\"black\",\"orange\"],[\"red\",\"pink\",\"green\",\"white\",\"black\"])==True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 509test_setup_code: test_list: ['assert average_Odd(9) == 5', 'assert average_Odd(5) == 3', 'assert average_Odd(11) == 6']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 510test_setup_code: test_list: ['assert no_of_subsequences([1,2,3,4], 10) == 11', 'assert no_of_subsequences([4,8,7,2], 50) == 9', 'assert no_of_subsequences([5,6,7,8], 15) == 4']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 511test_setup_code: test_list: ['assert find_Min_Sum(12) == 7', 'assert find_Min_Sum(105) == 15', 'assert find_Min_Sum(2) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 512test_setup_code: test_list: ['assert count_element_freq((5, 6, (5, 6), 7, (8, 9), 9) ) == {5: 2, 6: 2, 7: 1, 8: 1, 9: 2}', 'assert count_element_freq((6, 7, (6, 7), 8, (9, 10), 10) ) == {6: 2, 7: 2, 8: 1, 9: 1, 10: 2}', 'assert count_element_freq((7, 8, (7, 8), 9, (10, 11), 11) ) == {7: 2, 8: 2, 9: 1, 10: 1, 11: 2}']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 513test_setup_code: test_list: ['assert add_str((5, 6, 7, 4, 9) , \"FDF\") == [5, \\'FDF\\', 6, \\'FDF\\', 7, \\'FDF\\', 4, \\'FDF\\', 9, \\'FDF\\']', 'assert add_str((7, 8, 9, 10) , \"PF\") == [7, \\'PF\\', 8, \\'PF\\', 9, \\'PF\\', 10, \\'PF\\']', 'assert add_str((11, 14, 12, 1, 4) , \"JH\") == [11, \\'JH\\', 14, \\'JH\\', 12, \\'JH\\', 1, \\'JH\\', 4, \\'JH\\']']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 514test_setup_code: test_list: ['assert sum_elements((7, 8, 9, 1, 10, 7)) == 42', 'assert sum_elements((1, 2, 3, 4, 5, 6)) == 21', 'assert sum_elements((11, 12 ,13 ,45, 14)) == 95']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 515test_setup_code: test_list: ['assert modular_sum([3, 1, 7, 5], 4, 6) == True', 'assert modular_sum([1, 7], 2, 5) == False', 'assert modular_sum([1, 6], 2, 5) == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 516test_setup_code: test_list: ['assert radix_sort([15, 79, 25, 68, 37]) == [15, 25, 37, 68, 79]', 'assert radix_sort([9, 11, 8, 7, 3, 2]) == [2, 3, 7, 8, 9, 11]', 'assert radix_sort([36, 12, 24, 26, 29]) == [12, 24, 26, 29, 36]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 517test_setup_code: test_list: ['assert largest_pos([1,2,3,4,-1]) == 4', 'assert largest_pos([0,1,2,-5,-1,6]) == 6', 'assert largest_pos([0,0,1,0]) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 518test_setup_code: test_list: ['assert sqrt_root(4)==2', 'assert sqrt_root(16)==4', 'assert sqrt_root(400)==20']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 519test_setup_code: test_list: ['assert volume_tetrahedron(10)==117.85', 'assert volume_tetrahedron(15)==397.75', 'assert volume_tetrahedron(20)==942.81']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 520test_setup_code: test_list: ['assert get_lcm([2, 7, 3, 9, 4]) == 252', 'assert get_lcm([1, 2, 8, 3]) == 24', 'assert get_lcm([3, 8, 4, 10, 5]) == 120']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 521test_setup_code: test_list: ['assert check_isosceles(6,8,12)==True', 'assert check_isosceles(6,6,12)==False', 'assert check_isosceles(6,15,20)==True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 522test_setup_code: test_list: ['assert lbs([0 , 8 , 4, 12, 2, 10 , 6 , 14 , 1 , 9 , 5 , 13, 3, 11 , 7 , 15]) == 7', 'assert lbs([1, 11, 2, 10, 4, 5, 2, 1]) == 6', 'assert lbs([80, 60, 30, 40, 20, 10]) == 5']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 523test_setup_code: test_list: [\"assert check_string('python')==['String must have 1 upper case character.', 'String must have 1 number.', 'String length should be atleast 8.']\", \"assert check_string('123python')==['String must have 1 upper case character.']\", \"assert check_string('123Python')==['Valid string.']\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 524test_setup_code: test_list: ['assert max_sum_increasing_subsequence([1, 101, 2, 3, 100, 4, 5], 7) == 106', 'assert max_sum_increasing_subsequence([3, 4, 5, 10], 4) == 22', 'assert max_sum_increasing_subsequence([10, 5, 4, 3], 4) == 10']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 525test_setup_code: test_list: ['assert parallel_lines([2,3,4], [2,3,8]) == True', 'assert parallel_lines([2,3,4], [4,-3,8]) == False', 'assert parallel_lines([3,3],[5,5]) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 526test_setup_code: test_list: ['assert capitalize_first_last_letters(\"python\") == \"PythoN\"', 'assert capitalize_first_last_letters(\"bigdata\") == \"BigdatA\"', 'assert capitalize_first_last_letters(\"Hadoop\") == \"HadooP\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 527test_setup_code: test_list: ['assert get_pairs_count([1, 5, 7, -1, 5], 5, 6) == 3', 'assert get_pairs_count([1, 5, 7, -1], 4, 6) == 2', 'assert get_pairs_count([1, 1, 1, 1], 4, 2) == 6']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 528test_setup_code: test_list: ['assert min_length([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==(1, [0])', 'assert min_length([[1], [5, 7], [10, 12, 14,15]])==(1, [1])', 'assert min_length([[5], [15,20,25]])==(1, [5])']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 529test_setup_code: test_list: ['assert jacobsthal_lucas(5) == 31', 'assert jacobsthal_lucas(2) == 5', 'assert jacobsthal_lucas(4) == 17']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 530test_setup_code: test_list: ['assert negative_count([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8])==0.31', 'assert negative_count([2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==0.31', 'assert negative_count([2, 4, -6, -9, 11, -12, 14, -5, 17])==0.44']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 531test_setup_code: test_list: ['assert min_coins([9, 6, 5, 1] ,4,11)==2', 'assert min_coins([4,5,6,7,8,9],6,9)==1', 'assert min_coins([1, 2, 3],3,4)==2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 532test_setup_code: test_list: ['assert check_permutation(\"abc\", \"cba\") == True', 'assert check_permutation(\"test\", \"ttew\") == False', 'assert check_permutation(\"xxyz\", \"yxzx\") == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 533test_setup_code: test_list: ['assert remove_datatype((4, 5, 4, 7.7, 1.2), int) == [7.7, 1.2]', 'assert remove_datatype((7, 8, 9, \"SR\"), str) == [7, 8, 9]', 'assert remove_datatype((7, 1.1, 2, 2.2), float) == [7, 2]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 534test_setup_code: test_list: [\"assert search_literal('python','python programming language')==(0,6)\", \"assert search_literal('programming','python programming language')==(7,18)\", \"assert search_literal('language','python programming language')==(19,27)\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 535test_setup_code: test_list: ['assert topbottom_surfacearea(10)==314.15000000000003', 'assert topbottom_surfacearea(5)==78.53750000000001', 'assert topbottom_surfacearea(4)==50.264']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 536test_setup_code: test_list: ['assert nth_items([1, 2, 3, 4, 5, 6, 7, 8, 9],2)==[1, 3, 5, 7, 9] ', 'assert nth_items([10,15,19,17,16,18],3)==[10,17] ', 'assert nth_items([14,16,19,15,17],4)==[14,17]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 537test_setup_code: test_list: ['assert first_repeated_word(\"ab ca bc ab\") == \"ab\"', 'assert first_repeated_word(\"ab ca bc\") == \\'None\\'', 'assert first_repeated_word(\"ab ca bc ca ab bc\") == \"ca\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 538test_setup_code: test_list: ['assert string_list_to_tuple((\"python 3.0\")) == (\\'p\\', \\'y\\', \\'t\\', \\'h\\', \\'o\\', \\'n\\', \\'3\\', \\'.\\', \\'0\\')', 'assert string_list_to_tuple((\"bigdata\")) == (\\'b\\', \\'i\\', \\'g\\', \\'d\\', \\'a\\', \\'t\\', \\'a\\')', 'assert string_list_to_tuple((\"language\")) == (\\'l\\', \\'a\\', \\'n\\', \\'g\\', \\'u\\', \\'a\\', \\'g\\',\\'e\\')']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 539test_setup_code: test_list: ['assert basesnum_coresspondingnum([10, 20, 30, 40, 50, 60, 70, 80, 90, 100],[1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[10, 400, 27000, 2560000, 312500000, 46656000000, 8235430000000, 1677721600000000, 387420489000000000, 100000000000000000000]', 'assert basesnum_coresspondingnum([1, 2, 3, 4, 5, 6, 7],[10, 20, 30, 40, 50, 60, 70])==[1, 1048576, 205891132094649, 1208925819614629174706176, 88817841970012523233890533447265625, 48873677980689257489322752273774603865660850176, 143503601609868434285603076356671071740077383739246066639249]', 'assert basesnum_coresspondingnum([4, 8, 12, 16, 20, 24, 28],[3, 6, 9, 12, 15, 18, 21])==[64, 262144, 5159780352, 281474976710656, 32768000000000000000, 6979147079584381377970176, 2456510688823056210273111113728]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 540test_setup_code: test_list: ['assert find_Diff([1,1,2,2,7,8,4,5,1,4],10) == 2', 'assert find_Diff([1,7,9,2,3,3,1,3,3],9) == 3', 'assert find_Diff([1,2,1,2],4) == 0']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 541test_setup_code: test_list: ['assert check_abundant(12) == True', 'assert check_abundant(15) == False', 'assert check_abundant(18) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 542test_setup_code: test_list: [\"assert fill_spaces('Boult Curve Wireless Neckband') == 'Boult:Curve:Wireless:Neckband'\", \"assert fill_spaces('Stereo Sound Sweatproof') == 'Stereo:Sound:Sweatproof'\", \"assert fill_spaces('Probass Curve Audio') == 'Probass:Curve:Audio'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 543test_setup_code: test_list: ['assert count_digits(9875,10)==(4)', 'assert count_digits(98759853034,100)==(11)', 'assert count_digits(1234567,500)==(7)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 544test_setup_code: test_list: [\"assert flatten_tuple([('1', '4', '6'), ('5', '8'), ('2', '9'), ('1', '10')]) == '1 4 6 5 8 2 9 1 10'\", \"assert flatten_tuple([('2', '3', '4'), ('6', '9'), ('3', '2'), ('2', '11')]) == '2 3 4 6 9 3 2 2 11'\", \"assert flatten_tuple([('14', '21', '9'), ('24', '19'), ('12', '29'), ('23', '17')]) == '14 21 9 24 19 12 29 23 17'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 545test_setup_code: test_list: ['assert toggle_F_and_L_bits(10) == 3', 'assert toggle_F_and_L_bits(15) == 6', 'assert toggle_F_and_L_bits(20) == 5']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 546test_setup_code: test_list: ['assert last_occurence_char(\"hello world\",\\'l\\')==10', 'assert last_occurence_char(\"language\",\\'g\\')==7', 'assert last_occurence_char(\"little\",\\'y\\')==None']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 547test_setup_code: test_list: ['assert Total_Hamming_Distance(4) == 7', 'assert Total_Hamming_Distance(2) == 3', 'assert Total_Hamming_Distance(5) == 8']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 548test_setup_code: test_list: ['assert longest_increasing_subsequence([10, 22, 9, 33, 21, 50, 41, 60]) == 5', 'assert longest_increasing_subsequence([3, 10, 2, 1, 20]) == 3', 'assert longest_increasing_subsequence([50, 3, 10, 7, 40, 80]) == 4 ']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 549test_setup_code: test_list: ['assert odd_Num_Sum(1) == 1', 'assert odd_Num_Sum(2) == 244', 'assert odd_Num_Sum(3) == 3369']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 550test_setup_code: test_list: ['assert find_Max([2,3,5,6,9],0,4) == 9', 'assert find_Max([3,4,5,2,1],0,4) == 5', 'assert find_Max([1,2,3],0,2) == 3']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 551test_setup_code: test_list: ['assert extract_column([[1, 2, 3], [2, 4, 5], [1, 1, 1]],0)==[1, 2, 1]', 'assert extract_column([[1, 2, 3], [-2, 4, -5], [1, -1, 1]],2)==[3, -5, 1]', 'assert extract_column([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]],0)==[1, 5, 1, 13, 5, 9]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 552test_setup_code: test_list: ['assert Seq_Linear([0,2,4,6,8,10]) == \"Linear Sequence\"', 'assert Seq_Linear([1,2,3]) == \"Linear Sequence\"', 'assert Seq_Linear([1,5,2]) == \"Non Linear Sequence\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 553test_setup_code: test_list: ['assert tuple_to_float((4, 56)) == 4.56', 'assert tuple_to_float((7, 256)) == 7.256', 'assert tuple_to_float((8, 123)) == 8.123']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 554test_setup_code: test_list: ['assert Split([1,2,3,4,5,6]) == [1,3,5]', 'assert Split([10,11,12,13]) == [11,13]', 'assert Split([7,8,9,1]) == [7,9,1]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 555test_setup_code: test_list: ['assert difference(3) == 30', 'assert difference(5) == 210', 'assert difference(2) == 6']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 556test_setup_code: test_list: ['assert find_Odd_Pair([5,4,7,2,1],5) == 6', 'assert find_Odd_Pair([7,2,8,1,0,5,11],7) == 12', 'assert find_Odd_Pair([1,2,3],3) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 557test_setup_code: test_list: ['assert toggle_string(\"Python\")==(\"pYTHON\")', 'assert toggle_string(\"Pangram\")==(\"pANGRAM\")', 'assert toggle_string(\"LIttLE\")==(\"liTTle\")']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 558test_setup_code: test_list: ['assert digit_distance_nums(1,2) == 1', 'assert digit_distance_nums(23,56) == 6', 'assert digit_distance_nums(123,256) == 7']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 559test_setup_code: test_list: ['assert max_sub_array_sum([-2, -3, 4, -1, -2, 1, 5, -3], 8) == 7', 'assert max_sub_array_sum([-3, -4, 5, -2, -3, 2, 6, -4], 8) == 8', 'assert max_sub_array_sum([-4, -5, 6, -3, -4, 3, 7, -5], 8) == 10']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 560test_setup_code: test_list: ['assert union_elements((3, 4, 5, 6),(5, 7, 4, 10) ) == (3, 4, 5, 6, 7, 10)', 'assert union_elements((1, 2, 3, 4),(3, 4, 5, 6) ) == (1, 2, 3, 4, 5, 6)', 'assert union_elements((11, 12, 13, 14),(13, 15, 16, 17) ) == (11, 12, 13, 14, 15, 16, 17)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 561test_setup_code: test_list: ['assert assign_elements([(5, 3), (7, 5), (2, 7), (3, 8), (8, 4)] ) == {3: [8], 5: [3], 7: [5], 2: [7], 8: [4], 4: []}', 'assert assign_elements([(6, 4), (9, 4), (3, 8), (4, 9), (9, 5)] ) == {4: [9], 6: [4], 9: [4, 5], 8: [], 3: [8], 5: []}', 'assert assign_elements([(6, 2), (6, 8), (4, 9), (4, 9), (3, 7)] ) == {2: [], 6: [2, 8], 8: [], 9: [], 4: [9, 9], 7: [], 3: [7]}']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 562test_setup_code: test_list: ['assert Find_Max_Length([[1],[1,4],[5,6,7,8]]) == 4', 'assert Find_Max_Length([[0,1],[2,2,],[3,2,1]]) == 3', 'assert Find_Max_Length([[7],[22,23],[13,14,15],[10,20,30,40,50]]) == 5']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 563test_setup_code: test_list: ['assert extract_values(\\'\"Python\", \"PHP\", \"Java\"\\')==[\\'Python\\', \\'PHP\\', \\'Java\\']', 'assert extract_values(\\'\"python\",\"program\",\"language\"\\')==[\\'python\\',\\'program\\',\\'language\\']', 'assert extract_values(\\'\"red\",\"blue\",\"green\",\"yellow\"\\')==[\\'red\\',\\'blue\\',\\'green\\',\\'yellow\\']']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 564test_setup_code: test_list: ['assert count_Pairs([1,2,1],3) == 2', 'assert count_Pairs([1,1,1,1],4) == 0', 'assert count_Pairs([1,2,3,4,5],5) == 10']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 565test_setup_code: test_list: [\"assert split('python') == ['p','y','t','h','o','n']\", \"assert split('Name') == ['N','a','m','e']\", \"assert split('program') == ['p','r','o','g','r','a','m']\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 566test_setup_code: test_list: ['assert sum_digits(345)==12', 'assert sum_digits(12)==3', 'assert sum_digits(97)==16']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 567test_setup_code: test_list: ['assert issort_list([1,2,4,6,8,10,12,14,16,17])==True', 'assert issort_list([1, 2, 4, 6, 8, 10, 12, 14, 20, 17])==False', 'assert issort_list([1, 2, 4, 6, 8, 10,15,14,20])==False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 568test_setup_code: test_list: ['assert empty_list(5)==[{},{},{},{},{}]', 'assert empty_list(6)==[{},{},{},{},{},{}]', 'assert empty_list(7)==[{},{},{},{},{},{},{}]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 569test_setup_code: test_list: [\"assert sort_sublists([['green', 'orange'], ['black', 'white'], ['white', 'black', 'orange']])==[['green', 'orange'], ['black', 'white'], ['black', 'orange', 'white']]\", \"assert sort_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])==[['green', 'orange'], ['black'], ['green', 'orange'], ['white']]\", \"assert sort_sublists([['a','b'],['d','c'],['g','h'] , ['f','e']])==[['a', 'b'], ['c', 'd'], ['g', 'h'], ['e', 'f']]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 570test_setup_code: test_list: ['assert remove_words([\\'Red color\\', \\'Orange#\\', \\'Green\\', \\'Orange @\\', \"White\"],[\\'#\\', \\'color\\', \\'@\\'])==[\\'Red\\', \\'\\', \\'Green\\', \\'Orange\\', \\'White\\']', \"assert remove_words(['Red &', 'Orange+', 'Green', 'Orange @', 'White'],['&', '+', '@'])==['Red', '', 'Green', 'Orange', 'White']\", \"assert remove_words(['Red &', 'Orange+', 'Green', 'Orange @', 'White'],['@'])==['Red &', 'Orange+', 'Green', 'Orange', 'White']\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 571test_setup_code: test_list: ['assert max_sum_pair_diff_lessthan_K([3, 5, 10, 15, 17, 12, 9], 7, 4) == 62', 'assert max_sum_pair_diff_lessthan_K([5, 15, 10, 300], 4, 12) == 25', 'assert max_sum_pair_diff_lessthan_K([1, 2, 3, 4, 5, 6], 6, 6) == 21']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 572test_setup_code: test_list: ['assert two_unique_nums([1,2,3,2,3,4,5]) == [1, 4, 5]', 'assert two_unique_nums([1,2,3,2,4,5]) == [1, 3, 4, 5]', 'assert two_unique_nums([1,2,3,4,5]) == [1, 2, 3, 4, 5]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 573test_setup_code: test_list: ['assert unique_product([10, 20, 30, 40, 20, 50, 60, 40]) == 720000000', 'assert unique_product([1, 2, 3, 1,]) == 6', 'assert unique_product([7, 8, 9, 0, 1, 1]) == 0']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 574test_setup_code: test_list: ['assert surfacearea_cylinder(10,5)==942.45', 'assert surfacearea_cylinder(4,5)==226.18800000000002', 'assert surfacearea_cylinder(4,10)==351.848']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 575test_setup_code: test_list: ['assert count_no(2,3,1,10) == 5', 'assert count_no(3,6,4,20) == 11', 'assert count_no(5,10,4,20) == 16']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 576test_setup_code: test_list: ['assert is_Sub_Array([1,4,3,5],[1,2],4,2) == False', 'assert is_Sub_Array([1,2,1],[1,2,1],3,3) == True', 'assert is_Sub_Array([1,0,2,2],[2,2,0],4,3) ==False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 577test_setup_code: test_list: ['assert last_Digit_Factorial(4) == 4', 'assert last_Digit_Factorial(21) == 0', 'assert last_Digit_Factorial(30) == 0']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 578test_setup_code: test_list: ['assert interleave_lists([1,2,3,4,5,6,7],[10,20,30,40,50,60,70],[100,200,300,400,500,600,700])==[1, 10, 100, 2, 20, 200, 3, 30, 300, 4, 40, 400, 5, 50, 500, 6, 60, 600, 7, 70, 700]', 'assert interleave_lists([10,20],[15,2],[5,10])==[10,15,5,20,2,10]', 'assert interleave_lists([11,44], [10,15], [20,5])==[11,10,20,44,15,5]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 579test_setup_code: test_list: ['assert find_dissimilar((3, 4, 5, 6), (5, 7, 4, 10)) == (3, 6, 7, 10)', 'assert find_dissimilar((1, 2, 3, 4), (7, 2, 3, 9)) == (1, 4, 7, 9)', 'assert find_dissimilar((21, 11, 25, 26), (26, 34, 21, 36)) == (34, 36, 11, 25)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 580test_setup_code: test_list: ['assert extract_even((4, 5, (7, 6, (2, 4)), 6, 8)) == (4, (6, (2, 4)), 6, 8)', 'assert extract_even((5, 6, (8, 7, (4, 8)), 7, 9)) == (6, (8, (4, 8)))', 'assert extract_even((5, 6, (9, 8, (4, 6)), 8, 10)) == (6, (8, (4, 6)), 8, 10)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 581test_setup_code: test_list: ['assert surface_Area(3,4) == 33', 'assert surface_Area(4,5) == 56', 'assert surface_Area(1,2) == 5']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 582test_setup_code: test_list: ['assert my_dict({10})==False', 'assert my_dict({11})==False', 'assert my_dict({})==True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 583test_setup_code: test_list: ['assert catalan_number(10)==16796', 'assert catalan_number(9)==4862', 'assert catalan_number(7)==429']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 584test_setup_code: test_list: ['assert find_adverbs(\"Clearly, he has no excuse for such behavior.\") == \\'0-7: Clearly\\'', 'assert find_adverbs(\"Please handle the situation carefuly\") == \\'28-36: carefuly\\'', 'assert find_adverbs(\"Complete the task quickly\") == \\'18-25: quickly\\'']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 585test_setup_code: test_list: [\"assert expensive_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}],1)==[{'name': 'Item-2', 'price': 555.22}]\", \"assert expensive_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}, {'name': 'Item-3', 'price': 45.09}],2)==[{'name': 'Item-2', 'price': 555.22},{'name': 'Item-1', 'price': 101.1}]\", \"assert expensive_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}, {'name': 'Item-3', 'price': 45.09},{'name': 'Item-4', 'price': 22.75}],1)==[{'name': 'Item-2', 'price': 555.22}]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 586test_setup_code: test_list: ['assert split_Arr([12,10,5,6,52,36],6,2) == [5,6,52,36,12,10]', 'assert split_Arr([1,2,3,4],4,1) == [2,3,4,1]', 'assert split_Arr([0,1,2,3,4,5,6,7],8,3) == [3,4,5,6,7,0,1,2]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 587test_setup_code: test_list: ['assert list_tuple([5, 10, 7, 4, 15, 3])==(5, 10, 7, 4, 15, 3)', 'assert list_tuple([2, 4, 5, 6, 2, 3, 4, 4, 7])==(2, 4, 5, 6, 2, 3, 4, 4, 7)', 'assert list_tuple([58,44,56])==(58,44,56)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 588test_setup_code: test_list: ['assert big_diff([1,2,3,4]) == 3', 'assert big_diff([4,5,12]) == 8', 'assert big_diff([9,2,3]) == 7']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 589test_setup_code: test_list: ['assert perfect_squares(1,30)==[1, 4, 9, 16, 25]', 'assert perfect_squares(50,100)==[64, 81, 100]', 'assert perfect_squares(100,200)==[100, 121, 144, 169, 196]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 590test_setup_code: test_list: ['assert polar_rect(3,4)==((5.0, 0.9272952180016122), (-2+2.4492935982947064e-16j))', 'assert polar_rect(4,7)==((8.06225774829855, 1.0516502125483738), (-2+2.4492935982947064e-16j))', 'assert polar_rect(15,17)==((22.67156809750927, 0.8478169733934057), (-2+2.4492935982947064e-16j))']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 591test_setup_code: test_list: ['assert swap_List([12, 35, 9, 56, 24]) == [24, 35, 9, 56, 12]', 'assert swap_List([1, 2, 3]) == [3, 2, 1]', 'assert swap_List([4, 5, 6]) == [6, 5, 4]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 592test_setup_code: test_list: ['assert sum_Of_product(3) == 15', 'assert sum_Of_product(4) == 56', 'assert sum_Of_product(1) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 593test_setup_code: test_list: ['assert removezero_ip(\"216.08.094.196\")==(\\'216.8.94.196\\') ', 'assert removezero_ip(\"12.01.024\")==(\\'12.1.24\\') ', 'assert removezero_ip(\"216.08.094.0196\")==(\\'216.8.94.196\\') ']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 594test_setup_code: test_list: ['assert diff_even_odd([1,3,5,7,4,1,6,8])==3', 'assert diff_even_odd([1,2,3,4,5,6,7,8,9,10])==1', 'assert diff_even_odd([1,5,7,9,10])==9']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 595test_setup_code: test_list: ['assert min_Swaps(\"1101\",\"1110\") == 1', 'assert min_Swaps(\"111\",\"000\") == \"Not Possible\"', 'assert min_Swaps(\"111\",\"110\") == \"Not Possible\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 596test_setup_code: test_list: ['assert tuple_size((\"A\", 1, \"B\", 2, \"C\", 3) ) == 104', 'assert tuple_size((1, \"Raju\", 2, \"Nikhil\", 3, \"Deepanshu\") ) == 104', 'assert tuple_size(((1, \"Lion\"), ( 2, \"Tiger\"), (3, \"Fox\"), (4, \"Wolf\")) ) == 88']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 597test_setup_code: test_list: ['assert find_kth([2, 3, 6, 7, 9], [1, 4, 8, 10], 5, 4, 5) == 6', 'assert find_kth([100, 112, 256, 349, 770], [72, 86, 113, 119, 265, 445, 892], 5, 7, 7) == 256', 'assert find_kth([3, 4, 7, 8, 10], [2, 5, 9, 11], 5, 4, 6) == 8']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 598test_setup_code: test_list: ['assert armstrong_number(153)==True', 'assert armstrong_number(259)==False', 'assert armstrong_number(4458)==False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 599test_setup_code: test_list: ['assert sum_average(10)==(55, 5.5)', 'assert sum_average(15)==(120, 8.0)', 'assert sum_average(20)==(210, 10.5)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 600test_setup_code: test_list: ['assert is_Even(1) == False', 'assert is_Even(2) == True', 'assert is_Even(3) == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 601test_setup_code: test_list: ['assert max_chain_length([Pair(5, 24), Pair(15, 25),Pair(27, 40), Pair(50, 60)], 4) == 3', 'assert max_chain_length([Pair(1, 2), Pair(3, 4),Pair(5, 6), Pair(7, 8)], 4) == 4', 'assert max_chain_length([Pair(19, 10), Pair(11, 12),Pair(13, 14), Pair(15, 16), Pair(31, 54)], 5) == 5']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 602test_setup_code: test_list: ['assert first_repeated_char(\"abcabc\") == \"a\"', 'assert first_repeated_char(\"abc\") == \"None\"', 'assert first_repeated_char(\"123123\") == \"1\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 603test_setup_code: test_list: ['assert get_ludic(10) == [1, 2, 3, 5, 7]', 'assert get_ludic(25) == [1, 2, 3, 5, 7, 11, 13, 17, 23, 25]', 'assert get_ludic(45) == [1, 2, 3, 5, 7, 11, 13, 17, 23, 25, 29, 37, 41, 43]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 604test_setup_code: test_list: ['assert reverse_words(\"python program\")==(\"program python\")', 'assert reverse_words(\"java language\")==(\"language java\")', 'assert reverse_words(\"indian man\")==(\"man indian\")']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 605test_setup_code: test_list: ['assert prime_num(13)==True', 'assert prime_num(7)==True', 'assert prime_num(-1010)==False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 606test_setup_code: test_list: ['assert radian_degree(90)==1.5707963267948966', 'assert radian_degree(60)==1.0471975511965976', 'assert radian_degree(120)==2.0943951023931953']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 607test_setup_code: test_list: [\"assert find_literals('The quick brown fox jumps over the lazy dog.', 'fox') == ('fox', 16, 19)\", \"assert find_literals('Its been a very crazy procedure right', 'crazy') == ('crazy', 16, 21)\", \"assert find_literals('Hardest choices required strongest will', 'will') == ('will', 35, 39)\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 608test_setup_code: test_list: ['assert bell_Number(2) == 2', 'assert bell_Number(3) == 5', 'assert bell_Number(4) == 15']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 609test_setup_code: test_list: ['assert floor_Min(10,20,30) == 15', 'assert floor_Min(1,2,1) == 0', 'assert floor_Min(11,10,9) == 9']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 610test_setup_code: test_list: ['assert remove_kth_element([1,1,2,3,4,4,5,1],3)==[1, 1, 3, 4, 4, 5, 1]', 'assert remove_kth_element([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4],4)==[0, 0, 1, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4]', 'assert remove_kth_element([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10],5)==[10,10,15,19, 18, 17, 26, 26, 17, 18, 10]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 611test_setup_code: test_list: ['assert max_of_nth([(5, 6, 7), (1, 3, 5), (8, 9, 19)], 2) == 19', 'assert max_of_nth([(6, 7, 8), (2, 4, 6), (9, 10, 20)], 1) == 10', 'assert max_of_nth([(7, 8, 9), (3, 5, 7), (10, 11, 21)], 1) == 11']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 612test_setup_code: test_list: [\"assert merge([['x', 'y'], ['a', 'b'], ['m', 'n']]) == [['x', 'a', 'm'], ['y', 'b', 'n']]\", 'assert merge([[1, 2], [3, 4], [5, 6], [7, 8]]) == [[1, 3, 5, 7], [2, 4, 6, 8]]', \"assert merge([['x', 'y','z' ], ['a', 'b','c'], ['m', 'n','o']]) == [['x', 'a', 'm'], ['y', 'b', 'n'],['z', 'c','o']]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 613test_setup_code: test_list: [\"assert maximum_value([('key1', [3, 4, 5]), ('key2', [1, 4, 2]), ('key3', [9, 3])]) == [('key1', 5), ('key2', 4), ('key3', 9)]\", \"assert maximum_value([('key1', [4, 5, 6]), ('key2', [2, 5, 3]), ('key3', [10, 4])]) == [('key1', 6), ('key2', 5), ('key3', 10)]\", \"assert maximum_value([('key1', [5, 6, 7]), ('key2', [3, 6, 4]), ('key3', [11, 5])]) == [('key1', 7), ('key2', 6), ('key3', 11)]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 614test_setup_code: test_list: ['assert cummulative_sum([(1, 3), (5, 6, 7), (2, 6)]) == 30', 'assert cummulative_sum([(2, 4), (6, 7, 8), (3, 7)]) == 37', 'assert cummulative_sum([(3, 5), (7, 8, 9), (4, 8)]) == 44']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 615test_setup_code: test_list: ['assert average_tuple(((10, 10, 10, 12), (30, 45, 56, 45), (81, 80, 39, 32), (1, 2, 3, 4)))==[30.5, 34.25, 27.0, 23.25]', 'assert average_tuple(((1, 1, -5), (30, -15, 56), (81, -60, -39), (-10, 2, 3)))== [25.5, -18.0, 3.75]', 'assert average_tuple( ((100, 100, 100, 120), (300, 450, 560, 450), (810, 800, 390, 320), (10, 20, 30, 40)))==[305.0, 342.5, 270.0, 232.5]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 616test_setup_code: test_list: ['assert tuple_modulo((10, 4, 5, 6), (5, 6, 7, 5)) == (0, 4, 5, 1)', 'assert tuple_modulo((11, 5, 6, 7), (6, 7, 8, 6)) == (5, 5, 6, 1)', 'assert tuple_modulo((12, 6, 7, 8), (7, 8, 9, 7)) == (5, 6, 7, 1)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 617test_setup_code: test_list: ['assert min_Jumps(3,4,11)==3.5', 'assert min_Jumps(3,4,0)==0', 'assert min_Jumps(11,14,11)==1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 618test_setup_code: test_list: ['assert div_list([4,5,6],[1, 2, 3])==[4.0,2.5,2.0]', 'assert div_list([3,2],[1,4])==[3.0, 0.5]', 'assert div_list([90,120],[50,70])==[1.8, 1.7142857142857142]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 619test_setup_code: test_list: [\"assert move_num('I1love143you55three3000thousand') == 'Iloveyouthreethousand1143553000'\", \"assert move_num('Avengers124Assemble') == 'AvengersAssemble124'\", \"assert move_num('Its11our12path13to14see15things16do17things') == 'Itsourpathtoseethingsdothings11121314151617'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 620test_setup_code: test_list: ['assert largest_subset([ 1, 3, 6, 13, 17, 18 ], 6) == 4', 'assert largest_subset([10, 5, 3, 15, 20], 5) == 3', 'assert largest_subset([18, 1, 3, 6, 13, 17], 6) == 4']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 621test_setup_code: test_list: ['assert increment_numerics([\"MSM\", \"234\", \"is\", \"98\", \"123\", \"best\", \"4\"] , 6) == [\\'MSM\\', \\'240\\', \\'is\\', \\'104\\', \\'129\\', \\'best\\', \\'10\\']', 'assert increment_numerics([\"Dart\", \"356\", \"is\", \"88\", \"169\", \"Super\", \"6\"] , 12) == [\\'Dart\\', \\'368\\', \\'is\\', \\'100\\', \\'181\\', \\'Super\\', \\'18\\']', 'assert increment_numerics([\"Flutter\", \"451\", \"is\", \"44\", \"96\", \"Magnificent\", \"12\"] , 33) == [\\'Flutter\\', \\'484\\', \\'is\\', \\'77\\', \\'129\\', \\'Magnificent\\', \\'45\\']']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 622test_setup_code: test_list: ['assert get_median([1, 12, 15, 26, 38], [2, 13, 17, 30, 45], 5) == 16.0', 'assert get_median([2, 4, 8, 9], [7, 13, 19, 28], 4) == 8.5', 'assert get_median([3, 6, 14, 23, 36, 42], [2, 18, 27, 39, 49, 55], 6) == 25.0']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 623test_setup_code: test_list: ['assert nth_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],2)==[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]', 'assert nth_nums([10,20,30],3)==([1000, 8000, 27000])', 'assert nth_nums([12,15],5)==([248832, 759375])']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 624test_setup_code: test_list: ['assert is_upper(\"person\") ==\"PERSON\"', 'assert is_upper(\"final\") == \"FINAL\"', 'assert is_upper(\"Valid\") == \"VALID\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 625test_setup_code: test_list: ['assert swap_List([1,2,3]) == [3,2,1]', 'assert swap_List([1,2,3,4,4]) == [4,2,3,4,1]', 'assert swap_List([4,5,6]) == [6,5,4]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 626test_setup_code: test_list: ['assert triangle_area(0) == 0', 'assert triangle_area(-1) == -1', 'assert triangle_area(2) == 4']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 627test_setup_code: test_list: ['assert find_First_Missing([0,1,2,3],0,3) == 4', 'assert find_First_Missing([0,1,2,6,9],0,4) == 3', 'assert find_First_Missing([2,3,5,8,9],0,4) == 0']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 628test_setup_code: test_list: ['assert replace_spaces(\"My Name is Dawood\") == \\'My%20Name%20is%20Dawood\\'', 'assert replace_spaces(\"I am a Programmer\") == \\'I%20am%20a%20Programmer\\'', 'assert replace_spaces(\"I love Coding\") == \\'I%20love%20Coding\\'']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 629test_setup_code: test_list: ['assert Split([1,2,3,4,5]) == [2,4]', 'assert Split([4,5,6,7,8,0,1]) == [4,6,8,0]', 'assert Split ([8,12,15,19]) == [8,12]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 630test_setup_code: test_list: ['assert get_coordinates((3, 4)) == [[2, 3], [2, 4], [2, 5], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5]]', 'assert get_coordinates((4, 5)) ==[[3, 4], [3, 5], [3, 6], [4, 4], [4, 5], [4, 6], [5, 4], [5, 5], [5, 6]]', 'assert get_coordinates((5, 6)) == [[4, 5], [4, 6], [4, 7], [5, 5], [5, 6], [5, 7], [6, 5], [6, 6], [6, 7]]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 631test_setup_code: test_list: [\"assert replace_spaces('Jumanji The Jungle') == 'Jumanji_The_Jungle'\", \"assert replace_spaces('The Avengers') == 'The_Avengers'\", \"assert replace_spaces('Fast and Furious') == 'Fast_and_Furious'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 632test_setup_code: test_list: ['assert move_zero([1,0,2,0,3,4]) == [1,2,3,4,0,0]', 'assert move_zero([2,3,2,0,0,4,0,5,0]) == [2,3,2,4,5,0,0,0,0]', 'assert move_zero([0,1,0,1,1]) == [1,1,1,0,0]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 633test_setup_code: test_list: ['assert pair_OR_Sum([5,9,7,6],4) == 47', 'assert pair_OR_Sum([7,3,5],3) == 12', 'assert pair_OR_Sum([7,3],2) == 4']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 634test_setup_code: test_list: ['assert even_Power_Sum(2) == 272', 'assert even_Power_Sum(3) == 1568', 'assert even_Power_Sum(4) == 5664']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 635test_setup_code: test_list: ['assert heap_sort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]', 'assert heap_sort([25, 35, 22, 85, 14, 65, 75, 25, 58])==[14, 22, 25, 25, 35, 58, 65, 75, 85]', 'assert heap_sort( [7, 1, 9, 5])==[1,5,7,9]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 636test_setup_code: test_list: ['assert Check_Solution(2,0,2) == \"Yes\"', 'assert Check_Solution(2,-5,2) == \"Yes\"', 'assert Check_Solution(1,2,3) == \"No\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 637test_setup_code: test_list: ['assert noprofit_noloss(1500,1200)==False', 'assert noprofit_noloss(100,100)==True', 'assert noprofit_noloss(2000,5000)==False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 638test_setup_code: test_list: ['assert wind_chill(120,35)==40', 'assert wind_chill(40,70)==86', 'assert wind_chill(10,100)==116']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 639test_setup_code: test_list: [\"assert sample_nam(['sally', 'Dylan', 'rebecca', 'Diana', 'Joanne', 'keith'])==16\", 'assert sample_nam([\"php\", \"res\", \"Python\", \"abcd\", \"Java\", \"aaa\"])==10', 'assert sample_nam([\"abcd\", \"Python\", \"abba\", \"aba\"])==6']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 640test_setup_code: test_list: ['assert remove_parenthesis([\"python (chrome)\"])==(\"python\")', 'assert remove_parenthesis([\"string(.abc)\"])==(\"string\")', 'assert remove_parenthesis([\"alpha(num)\"])==(\"alpha\")']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 641test_setup_code: test_list: ['assert is_nonagonal(10) == 325', 'assert is_nonagonal(15) == 750', 'assert is_nonagonal(18) == 1089']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 642test_setup_code: test_list: ['assert remove_similar_row([[(4, 5), (3, 2)], [(2, 2), (4, 6)], [(3, 2), (4, 5)]] ) == {((4, 6), (2, 2)), ((4, 5), (3, 2))}', 'assert remove_similar_row([[(5, 6), (4, 3)], [(3, 3), (5, 7)], [(4, 3), (5, 6)]] ) == {((5, 6), (4, 3)), ((5, 7), (3, 3))}', 'assert remove_similar_row([[(6, 7), (5, 4)], [(4, 4), (6, 8)], [(5, 4), (6, 7)]] ) =={((5, 4), (6, 7)), ((4, 4), (6, 8))}']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 643test_setup_code: test_list: ['assert text_match_wordz_middle(\"pythonzabc.\")==(\\'Found a match!\\')', 'assert text_match_wordz_middle(\"xyzabc.\")==(\\'Found a match!\\')', 'assert text_match_wordz_middle(\" lang .\")==(\\'Not matched!\\')']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 644test_setup_code: test_list: ['assert reverse_Array_Upto_K([1, 2, 3, 4, 5, 6],4) == [4, 3, 2, 1, 5, 6]', 'assert reverse_Array_Upto_K([4, 5, 6, 7], 2) == [5, 4, 6, 7]', 'assert reverse_Array_Upto_K([9, 8, 7, 6, 5],3) == [7, 8, 9, 6, 5]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 645test_setup_code: test_list: ['assert find_k_product([(5, 6, 7), (1, 3, 5), (8, 9, 19)], 2) == 665', 'assert find_k_product([(6, 7, 8), (2, 4, 6), (9, 10, 20)], 1) == 280', 'assert find_k_product([(7, 8, 9), (3, 5, 7), (10, 11, 21)], 0) == 210']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 646test_setup_code: test_list: ['assert No_of_cubes(2,1) == 8', 'assert No_of_cubes(5,2) == 64', 'assert No_of_cubes(1,1) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 647test_setup_code: test_list: ['assert split_upperstring(\"PythonProgramLanguage\")==[\\'Python\\',\\'Program\\',\\'Language\\']', 'assert split_upperstring(\"PythonProgram\")==[\\'Python\\',\\'Program\\']', 'assert split_upperstring(\"ProgrammingLanguage\")==[\\'Programming\\',\\'Language\\']']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 648test_setup_code: test_list: ['assert exchange_elements([0,1,2,3,4,5])==[1, 0, 3, 2, 5, 4] ', 'assert exchange_elements([5,6,7,8,9,10])==[6,5,8,7,10,9] ', 'assert exchange_elements([25,35,45,55,75,95])==[35,25,55,45,95,75] ']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 649test_setup_code: test_list: ['assert sum_Range_list([2, 1, 5, 6, 8, 3, 4, 9, 10, 11, 8, 12],8,10) == 29', 'assert sum_Range_list([1,2,3,4,5],1,2) == 5', 'assert sum_Range_list([1,0,1,2,5,6],4,5) == 11']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 650test_setup_code: test_list: ['assert are_Equal([1,2,3],[3,2,1],3,3) == True', 'assert are_Equal([1,1,1],[2,2,2],3,3) == False', 'assert are_Equal([8,9],[4,5,6],2,3) == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 651test_setup_code: test_list: ['assert check_subset((10, 4, 5, 6), (5, 10)) == True', 'assert check_subset((1, 2, 3, 4), (5, 6)) == False', 'assert check_subset((7, 8, 9, 10), (10, 8)) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 652test_setup_code: test_list: [\"assert matrix_to_list([[(4, 5), (7, 8)], [(10, 13), (18, 17)], [(0, 4), (10, 1)]]) == '[(4, 7, 10, 18, 0, 10), (5, 8, 13, 17, 4, 1)]'\", \"assert matrix_to_list([[(5, 6), (8, 9)], [(11, 14), (19, 18)], [(1, 5), (11, 2)]]) == '[(5, 8, 11, 19, 1, 11), (6, 9, 14, 18, 5, 2)]'\", \"assert matrix_to_list([[(6, 7), (9, 10)], [(12, 15), (20, 21)], [(23, 7), (15, 8)]]) == '[(6, 9, 12, 20, 23, 15), (7, 10, 15, 21, 7, 8)]'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 653test_setup_code: test_list: [\"assert grouping_dictionary([('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)])== ({'yellow': [1, 3], 'blue': [2, 4], 'red': [1]})\", \"assert grouping_dictionary([('yellow', 10), ('blue', 20), ('yellow', 30), ('blue', 40), ('red', 10)])== ({'yellow': [10, 30], 'blue': [20, 40], 'red': [10]})\", \"assert grouping_dictionary([('yellow', 15), ('blue', 25), ('yellow', 35), ('blue', 45), ('red', 15)])== ({'yellow': [15, 35], 'blue': [25, 45], 'red': [15]})\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 654test_setup_code: test_list: ['assert rectangle_perimeter(10,20)==60', 'assert rectangle_perimeter(10,5)==30', 'assert rectangle_perimeter(4,2)==12']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 655test_setup_code: test_list: ['assert fifth_Power_Sum(2) == 33', 'assert fifth_Power_Sum(4) == 1300', 'assert fifth_Power_Sum(3) == 276']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 656test_setup_code: test_list: ['assert find_Min_Sum([3,2,1],[2,1,3],3) == 0', 'assert find_Min_Sum([1,2,3],[4,5,6],3) == 9', 'assert find_Min_Sum([4,1,8,7],[2,3,6,5],4) == 6']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 657test_setup_code: test_list: ['assert first_Digit(5) == 1', 'assert first_Digit(10) == 3', 'assert first_Digit(7) == 5']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 658test_setup_code: test_list: ['assert max_occurrences([2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,4,6,9,1,2])==2', 'assert max_occurrences([1, 3,5, 7,1, 3,13, 15, 17,5, 7,9,1, 11])==1', 'assert max_occurrences([1, 2, 3,2, 4, 5,1, 1, 1])==1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 659test_setup_code: test_list: ['assert Repeat([10, 20, 30, 20, 20, 30, 40, 50, -20, 60, 60, -20, -20]) == [20, 30, -20, 60]', 'assert Repeat([-1, 1, -1, 8]) == [-1]', 'assert Repeat([1, 2, 3, 1, 2,]) == [1, 2]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 660test_setup_code: test_list: ['assert find_Points(5,10,1,5) == (1,10)', 'assert find_Points(3,5,7,9) == (3,9)', 'assert find_Points(1,5,2,8) == (1,8)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 661test_setup_code: test_list: ['assert max_sum_of_three_consecutive([100, 1000, 100, 1000, 1], 5) == 2101', 'assert max_sum_of_three_consecutive([3000, 2000, 1000, 3, 10], 5) == 5013', 'assert max_sum_of_three_consecutive([1, 2, 3, 4, 5, 6, 7, 8], 8) == 27']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 662test_setup_code: test_list: [\"assert sorted_dict({'n1': [2, 3, 1], 'n2': [5, 1, 2], 'n3': [3, 2, 4]})=={'n1': [1, 2, 3], 'n2': [1, 2, 5], 'n3': [2, 3, 4]}\", \"assert sorted_dict({'n1': [25,37,41], 'n2': [41,54,63], 'n3': [29,38,93]})=={'n1': [25, 37, 41], 'n2': [41, 54, 63], 'n3': [29, 38, 93]}\", \"assert sorted_dict({'n1': [58,44,56], 'n2': [91,34,58], 'n3': [100,200,300]})=={'n1': [44, 56, 58], 'n2': [34, 58, 91], 'n3': [100, 200, 300]}\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 663test_setup_code: test_list: ['assert find_max_val(15, 10, 5) == 15', 'assert find_max_val(187, 10, 5) == 185', 'assert find_max_val(16, 11, 1) == 12']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 664test_setup_code: test_list: ['assert average_Even(2) == 2', 'assert average_Even(4) == 3', 'assert average_Even(100) == 51']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 665test_setup_code: test_list: ['assert move_last([1,2,3,4]) == [2,3,4,1]', 'assert move_last([2,3,4,1,5,0]) == [3,4,1,5,0,2]', 'assert move_last([5,4,3,2,1]) == [4,3,2,1,5]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 666test_setup_code: test_list: ['assert count_char(\"Python\",\\'o\\')==1', 'assert count_char(\"little\",\\'t\\')==2', 'assert count_char(\"assert\",\\'s\\')==2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 667test_setup_code: test_list: [\"assert Check_Vow('corner','AaEeIiOoUu') == 2\", \"assert Check_Vow('valid','AaEeIiOoUu') == 2\", \"assert Check_Vow('true','AaEeIiOoUu') ==2\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 668test_setup_code: test_list: [\"assert replace('peep','e') == 'pep'\", \"assert replace('Greek','e') == 'Grek'\", \"assert replace('Moon','o') == 'Mon'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 669test_setup_code: test_list: ['assert check_IP(\"192.168.0.1\") == \\'Valid IP address\\'', 'assert check_IP(\"110.234.52.124\") == \\'Valid IP address\\'', 'assert check_IP(\"366.1.2.2\") == \\'Invalid IP address\\'']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 670test_setup_code: test_list: ['assert decreasing_trend([-4,-3,-2,-1]) == True', 'assert decreasing_trend([1,2,3]) == True', 'assert decreasing_trend([3,2,1]) == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 671test_setup_code: test_list: ['assert set_Right_most_Unset_Bit(21) == 23', 'assert set_Right_most_Unset_Bit(11) == 15', 'assert set_Right_most_Unset_Bit(15) == 15']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 672test_setup_code: test_list: ['assert max_of_three(10,20,30)==30', 'assert max_of_three(55,47,39)==55', 'assert max_of_three(10,49,30)==49']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 673test_setup_code: test_list: ['assert convert([1,2,3]) == 123', 'assert convert([4,5,6]) == 456', 'assert convert([7,8,9]) == 789']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 674test_setup_code: test_list: ['assert remove_duplicate(\"Python Exercises Practice Solution Exercises\")==(\"Python Exercises Practice Solution\")', 'assert remove_duplicate(\"Python Exercises Practice Solution Python\")==(\"Python Exercises Practice Solution\")', 'assert remove_duplicate(\"Python Exercises Practice Solution Practice\")==(\"Python Exercises Practice Solution\")']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 675test_setup_code: test_list: ['assert sum_nums(2,10,11,20)==20', 'assert sum_nums(15,17,1,10)==32', 'assert sum_nums(10,15,5,30)==20']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 676test_setup_code: test_list: [\"assert remove_extra_char('**//Google Android// - 12. ') == 'GoogleAndroid12'\", \"assert remove_extra_char('****//Google Flutter//*** - 36. ') == 'GoogleFlutter36'\", \"assert remove_extra_char('**//Google Firebase// - 478. ') == 'GoogleFirebase478'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 677test_setup_code: test_list: ['assert validity_triangle(60,50,90)==False', 'assert validity_triangle(45,75,60)==True', 'assert validity_triangle(30,50,100)==True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 678test_setup_code: test_list: ['assert remove_spaces(\"a b c\") == \"abc\"', 'assert remove_spaces(\"1 2 3\") == \"123\"', 'assert remove_spaces(\" b c\") == \"bc\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 679test_setup_code: test_list: [\"assert access_key({'physics': 80, 'math': 90, 'chemistry': 86},0)== 'physics'\", \"assert access_key({'python':10, 'java': 20, 'C++':30},2)== 'C++'\", \"assert access_key({'program':15,'computer':45},1)== 'computer'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 680test_setup_code: test_list: ['assert increasing_trend([1,2,3,4]) == True', 'assert increasing_trend([4,3,2,1]) == False', 'assert increasing_trend([0,1,4,9]) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 681test_setup_code: test_list: ['assert smallest_Divisor(10) == 2', 'assert smallest_Divisor(25) == 5', 'assert smallest_Divisor(31) == 31']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 682test_setup_code: test_list: ['assert mul_list([1, 2, 3],[4,5,6])==[4,10,18]', 'assert mul_list([1,2],[3,4])==[3,8]', 'assert mul_list([90,120],[50,70])==[4500,8400]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 683test_setup_code: test_list: ['assert sum_Square(25) == True', 'assert sum_Square(24) == False', 'assert sum_Square(17) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 684test_setup_code: test_list: ['assert count_Char(\"abcac\",\\'a\\') == 4', 'assert count_Char(\"abca\",\\'c\\') == 2', 'assert count_Char(\"aba\",\\'a\\') == 7']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 685test_setup_code: test_list: ['assert sum_Of_Primes(10) == 17', 'assert sum_Of_Primes(20) == 77', 'assert sum_Of_Primes(5) == 10']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 686test_setup_code: test_list: [\"assert freq_element((4, 5, 4, 5, 6, 6, 5, 5, 4) ) == '{4: 3, 5: 4, 6: 2}'\", \"assert freq_element((7, 8, 8, 9, 4, 7, 6, 5, 4) ) == '{7: 2, 8: 2, 9: 1, 4: 2, 6: 1, 5: 1}'\", \"assert freq_element((1, 4, 3, 1, 4, 5, 2, 6, 2, 7) ) == '{1: 2, 4: 2, 3: 1, 5: 1, 2: 2, 6: 1, 7: 1}'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 687test_setup_code: test_list: ['assert recur_gcd(12,14) == 2', 'assert recur_gcd(13,17) == 1', 'assert recur_gcd(9, 3) == 3']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 688test_setup_code: test_list: ['assert len_complex(3,4)==5.0', 'assert len_complex(9,10)==13.45362404707371', 'assert len_complex(7,9)==11.40175425099138']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 689test_setup_code: test_list: ['assert min_jumps([1, 3, 6, 1, 0, 9], 6) == 3', 'assert min_jumps([1, 3, 5, 8, 9, 2, 6, 7, 6, 8, 9], 11) == 3', 'assert min_jumps([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 11) == 10']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 690test_setup_code: test_list: ['assert mul_consecutive_nums([1, 1, 3, 4, 4, 5, 6, 7])==[1, 3, 12, 16, 20, 30, 42]', 'assert mul_consecutive_nums([4, 5, 8, 9, 6, 10])==[20, 40, 72, 54, 60]', 'assert mul_consecutive_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[2, 6, 12, 20, 30, 42, 56, 72, 90]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 691test_setup_code: test_list: ['assert group_element([(6, 5), (2, 7), (2, 5), (8, 7), (9, 8), (3, 7)]) == {5: [6, 2], 7: [2, 8, 3], 8: [9]}', 'assert group_element([(7, 6), (3, 8), (3, 6), (9, 8), (10, 9), (4, 8)]) == {6: [7, 3], 8: [3, 9, 4], 9: [10]}', 'assert group_element([(8, 7), (4, 9), (4, 7), (10, 9), (11, 10), (5, 9)]) == {7: [8, 4], 9: [4, 10, 5], 10: [11]}']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 692test_setup_code: test_list: ['assert last_Two_Digits(7) == 40', 'assert last_Two_Digits(5) == 20', 'assert last_Two_Digits(2) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 693test_setup_code: test_list: [\"assert remove_multiple_spaces('Google Assistant') == 'Google Assistant'\", \"assert remove_multiple_spaces('Quad Core') == 'Quad Core'\", \"assert remove_multiple_spaces('ChromeCast Built-in') == 'ChromeCast Built-in'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 694test_setup_code: test_list: [\"assert extract_unique({'msm' : [5, 6, 7, 8],'is' : [10, 11, 7, 5],'best' : [6, 12, 10, 8],'for' : [1, 2, 5]} ) == [1, 2, 5, 6, 7, 8, 10, 11, 12]\", \"assert extract_unique({'Built' : [7, 1, 9, 4],'for' : [11, 21, 36, 14, 9],'ISP' : [4, 1, 21, 39, 47],'TV' : [1, 32, 38]} ) == [1, 4, 7, 9, 11, 14, 21, 32, 36, 38, 39, 47]\", \"assert extract_unique({'F' : [11, 13, 14, 17],'A' : [12, 11, 15, 18],'N' : [19, 21, 15, 36],'G' : [37, 36, 35]}) == [11, 12, 13, 14, 15, 17, 18, 19, 21, 35, 36, 37]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 695test_setup_code: test_list: ['assert check_greater((10, 4, 5), (13, 5, 18)) == True', 'assert check_greater((1, 2, 3), (2, 1, 4)) == False', 'assert check_greater((4, 5, 6), (5, 6, 7)) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 696test_setup_code: test_list: ['assert zip_list([[1, 3], [5, 7], [9, 11]] ,[[2, 4], [6, 8], [10, 12, 14]] )==[[1, 3, 2, 4], [5, 7, 6, 8], [9, 11, 10, 12, 14]]', 'assert zip_list([[1, 2], [3, 4], [5, 6]] ,[[7, 8], [9, 10], [11, 12]] )==[[1, 2, 7, 8], [3, 4, 9, 10], [5, 6, 11, 12]]', \"assert zip_list([['a','b'],['c','d']] , [['e','f'],['g','h']] )==[['a','b','e','f'],['c','d','g','h']]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 697test_setup_code: test_list: ['assert count_even([1, 2, 3, 5, 7, 8, 9, 10])==3', 'assert count_even([10,15,14,13,-18,12,-20])==5', 'assert count_even([1, 2, 4, 8, 9])==3']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 698test_setup_code: test_list: ['assert sort_dict_item({(5, 6) : 3, (2, 3) : 9, (8, 4): 10, (6, 4): 12} ) == {(2, 3): 9, (6, 4): 12, (5, 6): 3, (8, 4): 10}', 'assert sort_dict_item({(6, 7) : 4, (3, 4) : 10, (9, 5): 11, (7, 5): 13} ) == {(3, 4): 10, (7, 5): 13, (6, 7): 4, (9, 5): 11}', 'assert sort_dict_item({(7, 8) : 5, (4, 5) : 11, (10, 6): 12, (8, 6): 14} ) == {(4, 5): 11, (8, 6): 14, (7, 8): 5, (10, 6): 12}']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 699test_setup_code: test_list: ['assert min_Swaps(\"1101\",\"1110\") == 1', 'assert min_Swaps(\"1111\",\"0100\") == \"Not Possible\"', 'assert min_Swaps(\"1110000\",\"0001101\") == 3']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 700test_setup_code: test_list: ['assert count_range_in_list([10,20,30,40,40,40,70,80,99],40,100)==6', \"assert count_range_in_list(['a','b','c','d','e','f'],'a','e')==5\", 'assert count_range_in_list([7,8,9,15,17,19,45],15,20)==3']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 701test_setup_code: test_list: ['assert equilibrium_index([1, 2, 3, 4, 1, 2, 3]) == 3', 'assert equilibrium_index([-7, 1, 5, 2, -4, 3, 0]) == 3', 'assert equilibrium_index([1, 2, 3]) == -1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 702test_setup_code: test_list: ['assert removals([1, 3, 4, 9, 10,11, 12, 17, 20], 9, 4) == 5', 'assert removals([1, 5, 6, 2, 8], 5, 2) == 3', 'assert removals([1, 2, 3 ,4, 5, 6], 6, 3) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 703test_setup_code: test_list: ['assert is_key_present({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60},5)==True', 'assert is_key_present({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60},6)==True', 'assert is_key_present({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60},10)==False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 704test_setup_code: test_list: ['assert harmonic_sum(10)==2.9289682539682538', 'assert harmonic_sum(4)==2.083333333333333', 'assert harmonic_sum(7)==2.5928571428571425 ']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 705test_setup_code: test_list: ['assert sort_sublists([[2], [0], [1, 3], [0, 7], [9, 11], [13, 15, 17]])==[[0], [2], [0, 7], [1, 3], [9, 11], [13, 15, 17]]', 'assert sort_sublists([[1], [2, 3], [4, 5, 6], [7], [10, 11]])==[[1], [7], [2, 3], [10, 11], [4, 5, 6]]', 'assert sort_sublists([[\"python\"],[\"java\",\"C\",\"C++\"],[\"DBMS\"],[\"SQL\",\"HTML\"]])==[[\\'DBMS\\'], [\\'python\\'], [\\'SQL\\', \\'HTML\\'], [\\'java\\', \\'C\\', \\'C++\\']]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 706test_setup_code: test_list: ['assert is_subset([11, 1, 13, 21, 3, 7], 6, [11, 3, 7, 1], 4) == True', 'assert is_subset([1, 2, 3, 4, 5, 6], 6, [1, 2, 4], 3) == True', 'assert is_subset([10, 5, 2, 23, 19], 5, [19, 5, 3], 3) == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 707test_setup_code: test_list: ['assert count_Set_Bits(16) == 33', 'assert count_Set_Bits(2) == 2', 'assert count_Set_Bits(14) == 28']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 708test_setup_code: test_list: [\"assert Convert('python program') == ['python','program']\", \"assert Convert('Data Analysis') ==['Data','Analysis']\", \"assert Convert('Hadoop Training') == ['Hadoop','Training']\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 709test_setup_code: test_list: [\"assert get_unique([(3, 4), (1, 2), (2, 4), (8, 2), (7, 2), (8, 1), (9, 1), (8, 4), (10, 4)] ) == '{4: 4, 2: 3, 1: 2}'\", \"assert get_unique([(4, 5), (2, 3), (3, 5), (9, 3), (8, 3), (9, 2), (10, 2), (9, 5), (11, 5)] ) == '{5: 4, 3: 3, 2: 2}'\", \"assert get_unique([(6, 5), (3, 4), (2, 6), (11, 1), (8, 22), (8, 11), (4, 3), (14, 3), (11, 6)] ) == '{5: 1, 4: 1, 6: 2, 1: 1, 22: 1, 11: 1, 3: 2}'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 710test_setup_code: test_list: ['assert front_and_rear((10, 4, 5, 6, 7)) == (10, 7)', 'assert front_and_rear((1, 2, 3, 4, 5)) == (1, 5)', 'assert front_and_rear((6, 7, 8, 9, 10)) == (6, 10)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 711test_setup_code: test_list: ['assert product_Equal(2841) == True', 'assert product_Equal(1234) == False', 'assert product_Equal(1212) == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 712test_setup_code: test_list: ['assert remove_duplicate([[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]])==[[10, 20], [30, 56, 25], [33], [40]] ', 'assert remove_duplicate([\"a\", \"b\", \"a\", \"c\", \"c\"] )==[\"a\", \"b\", \"c\"]', 'assert remove_duplicate([1, 3, 5, 6, 3, 5, 6, 1] )==[1, 3, 5, 6]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 713test_setup_code: test_list: ['assert check_valid((True, True, True, True) ) == True', 'assert check_valid((True, False, True, True) ) == False', 'assert check_valid((True, True, True, True) ) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 714test_setup_code: test_list: ['assert count_Fac(24) == 3', 'assert count_Fac(12) == 2', 'assert count_Fac(4) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 715test_setup_code: test_list: ['assert str_to_tuple(\"1, -5, 4, 6, 7\") == (1, -5, 4, 6, 7)', 'assert str_to_tuple(\"1, 2, 3, 4, 5\") == (1, 2, 3, 4, 5)', 'assert str_to_tuple(\"4, 6, 9, 11, 13, 14\") == (4, 6, 9, 11, 13, 14)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 716test_setup_code: test_list: ['assert rombus_perimeter(10)==40', 'assert rombus_perimeter(5)==20', 'assert rombus_perimeter(4)==16']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 717test_setup_code: test_list: ['assert sd_calc([4, 2, 5, 8, 6])== 2.23606797749979', 'assert sd_calc([1,2,3,4,5,6,7])==2.160246899469287', 'assert sd_calc([5,9,10,15,6,4])==4.070217029430577']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 718test_setup_code: test_list: ['assert alternate_elements([\"red\", \"black\", \"white\", \"green\", \"orange\"])==[\\'red\\', \\'white\\', \\'orange\\']', 'assert alternate_elements([2, 0, 3, 4, 0, 2, 8, 3, 4, 2])==[2, 3, 0, 8, 4]', 'assert alternate_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1,3,5,7,9]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 719test_setup_code: test_list: ['assert text_match(\"ac\")==(\\'Found a match!\\')', 'assert text_match(\"dc\")==(\\'Not matched!\\')', 'assert text_match(\"abba\")==(\\'Found a match!\\')']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 720test_setup_code: test_list: ['assert add_dict_to_tuple((4, 5, 6), {\"MSAM\" : 1, \"is\" : 2, \"best\" : 3} ) == (4, 5, 6, {\\'MSAM\\': 1, \\'is\\': 2, \\'best\\': 3})', 'assert add_dict_to_tuple((1, 2, 3), {\"UTS\" : 2, \"is\" : 3, \"Worst\" : 4} ) == (1, 2, 3, {\\'UTS\\': 2, \\'is\\': 3, \\'Worst\\': 4})', 'assert add_dict_to_tuple((8, 9, 10), {\"POS\" : 3, \"is\" : 4, \"Okay\" : 5} ) == (8, 9, 10, {\\'POS\\': 3, \\'is\\': 4, \\'Okay\\': 5})']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 721test_setup_code: test_list: ['assert maxAverageOfPath([[1, 2, 3], [6, 5, 4], [7, 3, 9]], 3) == 5.2', 'assert maxAverageOfPath([[2, 3, 4], [7, 6, 5], [8, 4, 10]], 3) == 6.2', 'assert maxAverageOfPath([[3, 4, 5], [8, 7, 6], [9, 5, 11]], 3) == 7.2 ']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 722test_setup_code: test_list: [\"assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},6.0,70)=={'Cierra Vega': (6.2, 70)}\", \"assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},5.9,67)=={'Cierra Vega': (6.2, 70),'Kierra Gentry': (6.0, 68)}\", \"assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},5.7,64)=={'Cierra Vega': (6.2, 70),'Alden Cantrell': (5.9, 65),'Kierra Gentry': (6.0, 68),'Pierre Cox': (5.8, 66)}\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 723test_setup_code: test_list: ['assert count_same_pair([1, 2, 3, 4, 5, 6, 7, 8],[2, 2, 3, 1, 2, 6, 7, 9])==4', 'assert count_same_pair([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8],[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==11', 'assert count_same_pair([2, 4, -6, -9, 11, -12, 14, -5, 17],[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 724test_setup_code: test_list: ['assert power_base_sum(2,100)==115', 'assert power_base_sum(8,10)==37', 'assert power_base_sum(8,15)==62']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 725test_setup_code: test_list: ['assert extract_quotation(\\'Cortex \"A53\" Based \"multi\" tasking \"Processor\"\\') == [\\'A53\\', \\'multi\\', \\'Processor\\']', 'assert extract_quotation(\\'Cast your \"favorite\" entertainment \"apps\"\\') == [\\'favorite\\', \\'apps\\']', 'assert extract_quotation(\\'Watch content \"4k Ultra HD\" resolution with \"HDR 10\" Support\\') == [\\'4k Ultra HD\\', \\'HDR 10\\']']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 726test_setup_code: test_list: ['assert multiply_elements((1, 5, 7, 8, 10)) == (5, 35, 56, 80)', 'assert multiply_elements((2, 4, 5, 6, 7)) == (8, 20, 30, 42)', 'assert multiply_elements((12, 13, 14, 9, 15)) == (156, 182, 126, 135)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 727test_setup_code: test_list: ['assert remove_char(\"123abcjw:, .@! eiw\") == \\'123abcjweiw\\'', 'assert remove_char(\"Hello1234:, ! Howare33u\") == \\'Hello1234Howare33u\\'', 'assert remove_char(\"Cool543Triks@:, Make@987Trips\") == \\'Cool543TriksMake987Trips\\' ']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 728test_setup_code: test_list: ['assert sum_list([10,20,30],[15,25,35])==[25,45,65]', 'assert sum_list([1,2,3],[5,6,7])==[6,8,10]', 'assert sum_list([15,20,30],[15,45,75])==[30,65,105]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 729test_setup_code: test_list: ['assert add_list([1, 2, 3],[4,5,6])==[5, 7, 9]', 'assert add_list([1,2],[3,4])==[4,6]', 'assert add_list([10,20],[50,70])==[60,90]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 730test_setup_code: test_list: ['assert consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4 ])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4]', 'assert consecutive_duplicates([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10])==[10, 15, 19, 18, 17, 26, 17, 18, 10]', \"assert consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd'])==['a', 'b', 'c', 'd']\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 731test_setup_code: test_list: ['assert lateralsurface_cone(5,12)==204.20352248333654', 'assert lateralsurface_cone(10,15)==566.3586699569488', 'assert lateralsurface_cone(19,17)==1521.8090132193388']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 732test_setup_code: test_list: [\"assert replace_specialchar('Python language, Programming language.')==('Python:language::Programming:language:')\", \"assert replace_specialchar('a b c,d e f')==('a:b:c:d:e:f')\", \"assert replace_specialchar('ram reshma,ram rahim')==('ram:reshma:ram:rahim')\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 733test_setup_code: test_list: ['assert find_first_occurrence([2, 5, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 1', 'assert find_first_occurrence([2, 3, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 2', 'assert find_first_occurrence([2, 4, 1, 5, 6, 6, 8, 9, 9, 9], 6) == 4']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 734test_setup_code: test_list: ['assert sum_Of_Subarray_Prod([1,2,3],3) == 20', 'assert sum_Of_Subarray_Prod([1,2],2) == 5', 'assert sum_Of_Subarray_Prod([1,2,3,4],4) == 84']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 735test_setup_code: test_list: ['assert toggle_middle_bits(9) == 15', 'assert toggle_middle_bits(10) == 12', 'assert toggle_middle_bits(11) == 13']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 736test_setup_code: test_list: ['assert left_insertion([1,2,4,5],6)==4', 'assert left_insertion([1,2,4,5],3)==2', 'assert left_insertion([1,2,4,5],7)==4']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 737test_setup_code: test_list: ['assert check_str(\"annie\") == \\'Valid\\'', 'assert check_str(\"dawood\") == \\'Invalid\\'', 'assert check_str(\"Else\") == \\'Valid\\'']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 738test_setup_code: test_list: ['assert geometric_sum(7) == 1.9921875', 'assert geometric_sum(4) == 1.9375', 'assert geometric_sum(8) == 1.99609375']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 739test_setup_code: test_list: ['assert find_Index(2) == 4', 'assert find_Index(3) == 14', 'assert find_Index(4) == 45']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 740test_setup_code: test_list: ['assert tuple_to_dict((1, 5, 7, 10, 13, 5)) == {1: 5, 7: 10, 13: 5}', 'assert tuple_to_dict((1, 2, 3, 4, 5, 6)) == {1: 2, 3: 4, 5: 6}', 'assert tuple_to_dict((7, 8, 9, 10, 11, 12)) == {7: 8, 9: 10, 11: 12}']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 741test_setup_code: test_list: ['assert all_Characters_Same(\"python\") == False', 'assert all_Characters_Same(\"aaa\") == True', 'assert all_Characters_Same(\"data\") == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 742test_setup_code: test_list: ['assert area_tetrahedron(3)==15.588457268119894', 'assert area_tetrahedron(20)==692.8203230275509', 'assert area_tetrahedron(10)==173.20508075688772']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 743test_setup_code: test_list: ['assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],3,4)==[8, 9, 10, 1, 2, 3, 4, 5, 6]', 'assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],2,2)==[9, 10, 1, 2, 3, 4, 5, 6, 7, 8]', 'assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],5,2)==[6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 744test_setup_code: test_list: ['assert check_none((10, 4, 5, 6, None)) == True', 'assert check_none((7, 8, 9, 11, 14)) == False', 'assert check_none((1, 2, 3, 4, None)) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 745test_setup_code: test_list: ['assert divisible_by_digits(1,22)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]', 'assert divisible_by_digits(1,15)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15]', 'assert divisible_by_digits(20,25)==[22, 24]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 746test_setup_code: test_list: ['assert sector_area(4,45)==6.285714285714286', 'assert sector_area(9,45)==31.82142857142857', 'assert sector_area(9,360)==None']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 747test_setup_code: test_list: [\"assert lcs_of_three('AGGT12', '12TXAYB', '12XBA', 6, 7, 5) == 2\", \"assert lcs_of_three('Reels', 'Reelsfor', 'ReelsforReels', 5, 8, 13) == 5 \", \"assert lcs_of_three('abcd1e2', 'bc12ea', 'bd1ea', 7, 6, 5) == 3\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 748test_setup_code: test_list: ['assert capital_words_spaces(\"Python\") == \\'Python\\'', 'assert capital_words_spaces(\"PythonProgrammingExamples\") == \\'Python Programming Examples\\'', 'assert capital_words_spaces(\"GetReadyToBeCodingFreak\") == \\'Get Ready To Be Coding Freak\\'']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 749test_setup_code: test_list: [\"assert sort_numeric_strings( ['4','12','45','7','0','100','200','-12','-500'])==[-500, -12, 0, 4, 7, 12, 45, 100, 200]\", \"assert sort_numeric_strings(['2','3','8','4','7','9','8','2','6','5','1','6','1','2','3','4','6','9','1','2'])==[1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8, 9, 9]\", \"assert sort_numeric_strings(['1','3','5','7','1', '3','13', '15', '17','5', '7 ','9','1', '11'])==[1, 1, 1, 3, 3, 5, 5, 7, 7, 9, 11, 13, 15, 17]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 750test_setup_code: test_list: ['assert add_tuple([5, 6, 7], (9, 10)) == [5, 6, 7, 9, 10]', 'assert add_tuple([6, 7, 8], (10, 11)) == [6, 7, 8, 10, 11]', 'assert add_tuple([7, 8, 9], (11, 12)) == [7, 8, 9, 11, 12]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 751test_setup_code: test_list: ['assert check_min_heap([1, 2, 3, 4, 5, 6], 0) == True', 'assert check_min_heap([2, 3, 4, 5, 10, 15], 0) == True', 'assert check_min_heap([2, 10, 4, 5, 3, 15], 0) == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 752test_setup_code: test_list: ['assert jacobsthal_num(5) == 11', 'assert jacobsthal_num(2) == 1', 'assert jacobsthal_num(4) == 5']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 753test_setup_code: test_list: [\"assert min_k([('Manjeet', 10), ('Akshat', 4), ('Akash', 2), ('Nikhil', 8)], 2) == [('Akash', 2), ('Akshat', 4)]\", \"assert min_k([('Sanjeev', 11), ('Angat', 5), ('Akash', 3), ('Nepin', 9)], 3) == [('Akash', 3), ('Angat', 5), ('Nepin', 9)]\", \"assert min_k([('tanmay', 14), ('Amer', 11), ('Ayesha', 9), ('SKD', 16)], 1) == [('Ayesha', 9)]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 754test_setup_code: test_list: ['assert extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[1, 7]', 'assert extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 6, 5],[0, 1, 2, 3, 4, 6, 7])==[1, 6]', 'assert extract_index_list([1, 1, 3, 4, 6, 5, 6],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[1, 5]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 755test_setup_code: test_list: ['assert second_smallest([1, 2, -8, -2, 0, -2])==-2', 'assert second_smallest([1, 1, -0.5, 0, 2, -2, -2])==-0.5', 'assert second_smallest([2,2])==None']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 756test_setup_code: test_list: ['assert text_match_zero_one(\"ac\")==(\\'Found a match!\\')', 'assert text_match_zero_one(\"dc\")==(\\'Not matched!\\')', 'assert text_match_zero_one(\"abbbba\")==(\\'Found a match!\\')']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 757test_setup_code: test_list: ['assert count_reverse_pairs([\"julia\", \"best\", \"tseb\", \"for\", \"ailuj\"])== \\'2\\'', 'assert count_reverse_pairs([\"geeks\", \"best\", \"for\", \"skeeg\"]) == \\'1\\'', 'assert count_reverse_pairs([\"makes\", \"best\", \"sekam\", \"for\", \"rof\"]) == \\'2\\' ']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 758test_setup_code: test_list: ['assert unique_sublists([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]] )=={(1, 3): 2, (5, 7): 2, (13, 15, 17): 1, (9, 11): 1}', \"assert unique_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])=={('green', 'orange'): 2, ('black',): 1, ('white',): 1}\", 'assert unique_sublists([[10, 20, 30, 40], [60, 70, 50, 50], [90, 100, 200]])=={(10, 20, 30, 40): 1, (60, 70, 50, 50): 1, (90, 100, 200): 1}']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 759test_setup_code: test_list: [\"assert is_decimal('123.11')==True\", \"assert is_decimal('e666.86')==False\", \"assert is_decimal('3.124587')==False\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 760test_setup_code: test_list: [\"assert unique_Element([1,1,1],3) == 'YES'\", \"assert unique_Element([1,2,1,2],4) == 'NO'\", \"assert unique_Element([1,2,3,4,5],5) == 'NO'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 761test_setup_code: test_list: ['assert arc_length(9,45)==3.5357142857142856', 'assert arc_length(9,480)==None', 'assert arc_length(5,270)==11.785714285714285']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 762test_setup_code: test_list: ['assert check_monthnumber_number(6)==True', 'assert check_monthnumber_number(2)==False', 'assert check_monthnumber_number(12)==False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 763test_setup_code: test_list: ['assert find_Min_Diff((1,5,3,19,18,25),6) == 1', 'assert find_Min_Diff((4,3,2,6),4) == 1', 'assert find_Min_Diff((30,5,20,9),4) == 4']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 764test_setup_code: test_list: [\"assert number_ctr('program2bedone') == 1\", \"assert number_ctr('3wonders') ==1\", \"assert number_ctr('123') == 3\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 765test_setup_code: test_list: ['assert is_polite(7) == 11', 'assert is_polite(4) == 7', 'assert is_polite(9) == 13']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 766test_setup_code: test_list: ['assert pair_wise([1,1,2,3,3,4,4,5])==[(1, 1), (1, 2), (2, 3), (3, 3), (3, 4), (4, 4), (4, 5)]', 'assert pair_wise([1,5,7,9,10])==[(1, 5), (5, 7), (7, 9), (9, 10)]', 'assert pair_wise([1,2,3,4,5,6,7,8,9,10])==[(1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), (8, 9), (9, 10)]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 767test_setup_code: test_list: ['assert get_Pairs_Count([1,1,1,1],4,2) == 6', 'assert get_Pairs_Count([1,5,7,-1,5],5,6) == 3', 'assert get_Pairs_Count([1,-2,3],3,1) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 768test_setup_code: test_list: ['assert check_Odd_Parity(13) == True', 'assert check_Odd_Parity(21) == True', 'assert check_Odd_Parity(18) == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 769test_setup_code: test_list: ['assert (Diff([10, 15, 20, 25, 30, 35, 40], [25, 40, 35])) == [10, 20, 30, 15]', 'assert (Diff([1,2,3,4,5], [6,7,1])) == [2,3,4,5,6,7]', 'assert (Diff([1,2,3], [6,7,1])) == [2,3,6,7]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 770test_setup_code: test_list: ['assert odd_Num_Sum(2) == 82', 'assert odd_Num_Sum(3) == 707', 'assert odd_Num_Sum(4) == 3108']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 771test_setup_code: test_list: ['assert check_expression(\"{()}[{}]\") == True', 'assert check_expression(\"{()}[{]\") == False', 'assert check_expression(\"{()}[{}][]({})\") == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 772test_setup_code: test_list: [\"assert remove_length('The person is most value tet', 3) == 'person is most value'\", \"assert remove_length('If you told me about this ok', 4) == 'If you me about ok'\", \"assert remove_length('Forces of darkeness is come into the play', 4) == 'Forces of darkeness is the'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 773test_setup_code: test_list: [\"assert occurance_substring('python programming, python language','python')==('python', 0, 6)\", \"assert occurance_substring('python programming,programming language','programming')==('programming', 7, 18)\", \"assert occurance_substring('python programming,programming language','language')==('language', 31, 39)\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 774test_setup_code: test_list: ['assert check_email(\"ankitrai326@gmail.com\") == \\'Valid Email\\'', 'assert check_email(\"my.ownsite@ourearth.org\") == \\'Valid Email\\'', 'assert check_email(\"ankitaoie326.com\") == \\'Invalid Email\\'']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 775test_setup_code: test_list: ['assert odd_position([2,1,4,3,6,7,6,3]) == True', 'assert odd_position([4,1,2]) == True', 'assert odd_position([1,2,3]) == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 776test_setup_code: test_list: [\"assert count_vowels('bestinstareels') == 7\", \"assert count_vowels('partofthejourneyistheend') == 12\", \"assert count_vowels('amazonprime') == 5\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 777test_setup_code: test_list: ['assert find_Sum([1,2,3,1,1,4,5,6],8) == 21', 'assert find_Sum([1,10,9,4,2,10,10,45,4],9) == 71', 'assert find_Sum([12,10,9,45,2,10,10,45,10],9) == 78']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 778test_setup_code: test_list: ['assert pack_consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4])==[[0, 0], [1], [2], [3], [4, 4], [5], [6, 6, 6], [7], [8], [9], [4, 4]]', 'assert pack_consecutive_duplicates([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10])==[[10, 10], [15], [19], [18, 18], [17], [26, 26], [17], [18], [10]]', \"assert pack_consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd'])==[['a', 'a'], ['b'], ['c'], ['d', 'd']]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 779test_setup_code: test_list: ['assert unique_sublists([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]])=={(1, 3): 2, (5, 7): 2, (13, 15, 17): 1, (9, 11): 1}', \"assert unique_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])=={('green', 'orange'): 2, ('black',): 1, ('white',): 1}\", 'assert unique_sublists([[1, 2], [3, 4], [4, 5], [6, 7]])=={(1, 2): 1, (3, 4): 1, (4, 5): 1, (6, 7): 1}']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 780test_setup_code: test_list: ['assert find_combinations([(2, 4), (6, 7), (5, 1), (6, 10)]) == [(8, 11), (7, 5), (8, 14), (11, 8), (12, 17), (11, 11)]', 'assert find_combinations([(3, 5), (7, 8), (6, 2), (7, 11)]) == [(10, 13), (9, 7), (10, 16), (13, 10), (14, 19), (13, 13)]', 'assert find_combinations([(4, 6), (8, 9), (7, 3), (8, 12)]) == [(12, 15), (11, 9), (12, 18), (15, 12), (16, 21), (15, 15)]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 781test_setup_code: test_list: ['assert count_Divisors(10) == \"Even\"', 'assert count_Divisors(100) == \"Odd\"', 'assert count_Divisors(125) == \"Even\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 782test_setup_code: test_list: ['assert Odd_Length_Sum([1,2,4]) == 14', 'assert Odd_Length_Sum([1,2,1,2]) == 15', 'assert Odd_Length_Sum([1,7]) == 8']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 783test_setup_code: test_list: ['assert rgb_to_hsv(255, 255, 255)==(0, 0.0, 100.0)', 'assert rgb_to_hsv(0, 215, 0)==(120.0, 100.0, 84.31372549019608)', 'assert rgb_to_hsv(10, 215, 110)==(149.26829268292684, 95.34883720930233, 84.31372549019608)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 784test_setup_code: test_list: ['assert mul_even_odd([1,3,5,7,4,1,6,8])==4', 'assert mul_even_odd([1,2,3,4,5,6,7,8,9,10])==2', 'assert mul_even_odd([1,5,7,9,10])==10']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 785test_setup_code: test_list: ['assert tuple_str_int(\"(7, 8, 9)\") == (7, 8, 9)', 'assert tuple_str_int(\"(1, 2, 3)\") == (1, 2, 3)', 'assert tuple_str_int(\"(4, 5, 6)\") == (4, 5, 6)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 786test_setup_code: test_list: ['assert right_insertion([1,2,4,5],6)==4', 'assert right_insertion([1,2,4,5],3)==2', 'assert right_insertion([1,2,4,5],7)==4']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 787test_setup_code: test_list: ['assert text_match_three(\"ac\")==(\\'Not matched!\\')', 'assert text_match_three(\"dc\")==(\\'Not matched!\\')', 'assert text_match_three(\"abbbba\")==(\\'Found a match!\\')']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 788test_setup_code: test_list: ['assert new_tuple([\"WEB\", \"is\"], \"best\") == (\\'WEB\\', \\'is\\', \\'best\\')', 'assert new_tuple([\"We\", \"are\"], \"Developers\") == (\\'We\\', \\'are\\', \\'Developers\\')', 'assert new_tuple([\"Part\", \"is\"], \"Wrong\") == (\\'Part\\', \\'is\\', \\'Wrong\\')']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 789test_setup_code: test_list: ['assert perimeter_polygon(4,20)==80', 'assert perimeter_polygon(10,15)==150', 'assert perimeter_polygon(9,7)==63']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 790test_setup_code: test_list: ['assert even_position([3,2,1]) == False', 'assert even_position([1,2,3]) == False', 'assert even_position([2,1,4]) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 791test_setup_code: test_list: ['assert remove_nested((1, 5, 7, (4, 6), 10)) == (1, 5, 7, 10)', 'assert remove_nested((2, 6, 8, (5, 7), 11)) == (2, 6, 8, 11)', 'assert remove_nested((3, 7, 9, (6, 8), 12)) == (3, 7, 9, 12)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 792test_setup_code: test_list: ['assert count_list([[1, 3], [5, 7], [9, 11], [13, 15, 17]]) == 4', 'assert count_list([[1,2],[2,3],[4,5]]) == 3', 'assert count_list([[1,0],[2,0]]) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 793test_setup_code: test_list: ['assert last([1,2,3],1,3) == 0', 'assert last([1,1,1,2,3,4],1,6) == 2', 'assert last([2,3,2,3,6,8,9],3,8) == 3']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 794test_setup_code: test_list: ['assert text_starta_endb(\"aabbbb\")==(\\'Found a match!\\')', 'assert text_starta_endb(\"aabAbbbc\")==(\\'Not matched!\\')', 'assert text_starta_endb(\"accddbbjjj\")==(\\'Not matched!\\')']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 795test_setup_code: test_list: [\"assert cheap_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}],1)==[{'name': 'Item-1', 'price': 101.1}]\", \"assert cheap_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}],2)==[{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}]\", \"assert cheap_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}, {'name': 'Item-3', 'price': 45.09},{'name': 'Item-4', 'price': 22.75}],1)==[{'name': 'Item-4', 'price': 22.75}]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 796test_setup_code: test_list: [\"assert return_sum({'a': 100, 'b':200, 'c':300}) == 600\", \"assert return_sum({'a': 25, 'b':18, 'c':45}) == 88\", \"assert return_sum({'a': 36, 'b':39, 'c':49}) == 124\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 797test_setup_code: test_list: ['assert sum_in_Range(2,5) == 8', 'assert sum_in_Range(5,7) == 12', 'assert sum_in_Range(7,13) == 40']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 798test_setup_code: test_list: ['assert _sum([1, 2, 3]) == 6', 'assert _sum([15, 12, 13, 10]) == 50', 'assert _sum([0, 1, 2]) == 3']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 799test_setup_code: test_list: ['assert left_Rotate(16,2) == 64', 'assert left_Rotate(10,2) == 40', 'assert left_Rotate(99,3) == 792']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 800test_setup_code: test_list: [\"assert remove_all_spaces('python program')==('pythonprogram')\", \"assert remove_all_spaces('python programming language')==('pythonprogramminglanguage')\", \"assert remove_all_spaces('python program')==('pythonprogram')\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 801test_setup_code: test_list: ['assert test_three_equal(1,1,1) == 3', 'assert test_three_equal(-1,-2,-3) == 0', 'assert test_three_equal(1,2,2) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 802test_setup_code: test_list: ['assert count_Rotation([3,2,1],3) == 1', 'assert count_Rotation([4,5,1,2,3],5) == 2', 'assert count_Rotation([7,8,9,1,2,3],6) == 3']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 803test_setup_code: test_list: ['assert is_Perfect_Square(10) == False', 'assert is_Perfect_Square(36) == True', 'assert is_Perfect_Square(14) == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 804test_setup_code: test_list: ['assert is_Product_Even([1,2,3],3) == True', 'assert is_Product_Even([1,2,1,4],4) == True', 'assert is_Product_Even([1,1],2) == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 805test_setup_code: test_list: ['assert max_sum_list([[1,2,3], [4,5,6], [10,11,12], [7,8,9]])==[10, 11, 12] ', 'assert max_sum_list([[3,2,1], [6,5,4], [12,11,10]])==[12,11,10] ', 'assert max_sum_list([[2,3,1]])==[2,3,1] ']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 806test_setup_code: test_list: [\"assert max_run_uppercase('GeMKSForGERksISBESt') == 5\", \"assert max_run_uppercase('PrECIOusMOVemENTSYT') == 6\", \"assert max_run_uppercase('GooGLEFluTTER') == 4\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 807test_setup_code: test_list: ['assert first_odd([1,3,5]) == 1', 'assert first_odd([2,4,1,3]) == 1', 'assert first_odd ([8,9,1]) == 9']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 808test_setup_code: test_list: ['assert check_K((10, 4, 5, 6, 8), 6) == True', 'assert check_K((1, 2, 3, 4, 5, 6), 7) == False', 'assert check_K((7, 8, 9, 44, 11, 12), 11) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 809test_setup_code: test_list: ['assert check_smaller((1, 2, 3), (2, 3, 4)) == False', 'assert check_smaller((4, 5, 6), (3, 4, 5)) == True', 'assert check_smaller((11, 12, 13), (10, 11, 12)) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 810test_setup_code: test_list: [\"assert count_variable(4,2,0,-2)==['p', 'p', 'p', 'p', 'q', 'q'] \", \"assert count_variable(0,1,2,3)==['q', 'r', 'r', 's', 's', 's'] \", \"assert count_variable(11,15,12,23)==['p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's']\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 811test_setup_code: test_list: ['assert check_identical([(10, 4), (2, 5)], [(10, 4), (2, 5)]) == True', 'assert check_identical([(1, 2), (3, 7)], [(12, 14), (12, 45)]) == False', 'assert check_identical([(2, 14), (12, 25)], [(2, 14), (12, 25)]) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 812test_setup_code: test_list: ['assert road_rd(\"ravipadu Road\")==(\\'ravipadu Rd.\\')', 'assert road_rd(\"palnadu Road\")==(\\'palnadu Rd.\\')', 'assert road_rd(\"eshwar enclave Road\")==(\\'eshwar enclave Rd.\\')']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 813test_setup_code: test_list: [\"assert string_length('python')==6\", \"assert string_length('program')==7\", \"assert string_length('language')==8\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 814test_setup_code: test_list: ['assert rombus_area(10,20)==100', 'assert rombus_area(10,5)==25', 'assert rombus_area(4,2)==4']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 815test_setup_code: test_list: ['assert sort_by_dnf([1,2,0,1,0,1,2,1,1], 9) == [0, 0, 1, 1, 1, 1, 1, 2, 2]', 'assert sort_by_dnf([1,0,0,1,2,1,2,2,1,0], 10) == [0, 0, 0, 1, 1, 1, 1, 2, 2, 2]', 'assert sort_by_dnf([2,2,1,0,0,0,1,1,2,1], 10) == [0, 0, 0, 1, 1, 1, 1, 2, 2, 2]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 816test_setup_code: test_list: ['assert clear_tuple((1, 5, 3, 6, 8)) == ()', 'assert clear_tuple((2, 1, 4 ,5 ,6)) == ()', 'assert clear_tuple((3, 2, 5, 6, 8)) == ()']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 817test_setup_code: test_list: ['assert div_of_nums([19, 65, 57, 39, 152, 639, 121, 44, 90, 190],19,13)==[19, 65, 57, 39, 152, 190]', 'assert div_of_nums([1, 2, 3, 5, 7, 8, 10],2,5)==[2, 5, 8, 10]', 'assert div_of_nums([10,15,14,13,18,12,20],10,5)==[10, 15, 20]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 818test_setup_code: test_list: [\"assert lower_ctr('abc') == 3\", \"assert lower_ctr('string') == 6\", \"assert lower_ctr('Python') == 5\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 819test_setup_code: test_list: ['assert count_duplic([1,2,2,2,4,4,4,5,5,5,5])==([1, 2, 4, 5], [1, 3, 3, 4])', 'assert count_duplic([2,2,3,1,2,6,7,9])==([2, 3, 1, 2, 6, 7, 9], [2, 1, 1, 1, 1, 1, 1])', 'assert count_duplic([2,1,5,6,8,3,4,9,10,11,8,12])==([2, 1, 5, 6, 8, 3, 4, 9, 10, 11, 8, 12], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 820test_setup_code: test_list: ['assert check_monthnum_number(2)==True', 'assert check_monthnum_number(1)==False', 'assert check_monthnum_number(3)==False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 821test_setup_code: test_list: ['assert merge_dictionaries({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" })=={\\'B\\': \\'Black\\', \\'R\\': \\'Red\\', \\'P\\': \\'Pink\\', \\'G\\': \\'Green\\', \\'W\\': \\'White\\'}', 'assert merge_dictionaries({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" },{ \"O\": \"Orange\", \"W\": \"White\", \"B\": \"Black\" })=={\\'O\\': \\'Orange\\', \\'P\\': \\'Pink\\', \\'B\\': \\'Black\\', \\'W\\': \\'White\\', \\'R\\': \\'Red\\'}', 'assert merge_dictionaries({ \"G\": \"Green\", \"W\": \"White\" },{ \"O\": \"Orange\", \"W\": \"White\", \"B\": \"Black\" })=={\\'W\\': \\'White\\', \\'O\\': \\'Orange\\', \\'G\\': \\'Green\\', \\'B\\': \\'Black\\'}']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 822test_setup_code: test_list: ['assert pass_validity(\"password\")==False', 'assert pass_validity(\"Password@10\")==True', 'assert pass_validity(\"password@10\")==False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 823test_setup_code: test_list: ['assert check_substring(\"dreams for dreams makes life fun\", \"makes\") == \\'string doesnt start with the given substring\\'', 'assert check_substring(\"Hi there how are you Hi alex\", \"Hi\") == \\'string starts with the given substring\\'', 'assert check_substring(\"Its been a long day\", \"been\") == \\'string doesnt start with the given substring\\'']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 824test_setup_code: test_list: ['assert remove_even([1,3,5,2]) == [1,3,5]', 'assert remove_even([5,6,7]) == [5,7]', 'assert remove_even([1,2,3,4]) == [1,3]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 825test_setup_code: test_list: ['assert access_elements([2,3,8,4,7,9],[0,3,5]) == [2, 4, 9]', 'assert access_elements([1, 2, 3, 4, 5],[1,2]) == [2,3]', 'assert access_elements([1,0,2,3],[0,1]) == [1,0]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 826test_setup_code: test_list: ['assert check_Type_Of_Triangle(1,2,3) == \"Obtuse-angled Triangle\"', 'assert check_Type_Of_Triangle(2,2,2) == \"Acute-angled Triangle\"', 'assert check_Type_Of_Triangle(1,0,1) == \"Right-angled Triangle\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 827test_setup_code: test_list: ['assert sum_column( [[1,2,3,2],[4,5,6,2],[7,8,9,5],],0)==12', 'assert sum_column( [[1,2,3,2],[4,5,6,2],[7,8,9,5],],1)==15', 'assert sum_column( [[1,2,3,2],[4,5,6,2],[7,8,9,5],],3)==9']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 828test_setup_code: test_list: ['assert count_alpha_dig_spl(\"abc!@#123\")==(3,3,3)', 'assert count_alpha_dig_spl(\"dgsuy@#$%&1255\")==(5,4,5)', 'assert count_alpha_dig_spl(\"fjdsif627348#%$^&\")==(6,6,5)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 829test_setup_code: test_list: [\"assert second_frequent(['aaa','bbb','ccc','bbb','aaa','aaa']) == 'bbb'\", \"assert second_frequent(['abc','bcd','abc','bcd','bcd','bcd']) == 'abc'\", \"assert second_frequent(['cdma','gsm','hspa','gsm','cdma','cdma']) == 'gsm'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 830test_setup_code: test_list: ['assert round_up(123.01247,0)==124', 'assert round_up(123.01247,1)==123.1', 'assert round_up(123.01247,2)==123.02']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 831test_setup_code: test_list: ['assert count_Pairs([1,1,1,1],4) == 6', 'assert count_Pairs([1,5,1],3) == 1', 'assert count_Pairs([3,2,1,7,8,9],6) == 0']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 832test_setup_code: test_list: [\"assert extract_max('100klh564abc365bg') == 564\", \"assert extract_max('hello300how546mer231') == 546\", \"assert extract_max('its233beenalong343journey234') == 343\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 833test_setup_code: test_list: [\"assert get_key({1:'python',2:'java'})==[1,2]\", \"assert get_key({10:'red',20:'blue',30:'black'})==[10,20,30]\", \"assert get_key({27:'language',39:'java',44:'little'})==[27,39,44]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 834test_setup_code: test_list: ['assert generate_matrix(3)==[[1, 2, 3], [8, 9, 4], [7, 6, 5]] ', 'assert generate_matrix(2)==[[1,2],[4,3]]', 'assert generate_matrix(7)==[[1, 2, 3, 4, 5, 6, 7], [24, 25, 26, 27, 28, 29, 8], [23, 40, 41, 42, 43, 30, 9], [22, 39, 48, 49, 44, 31, 10], [21, 38, 47, 46, 45, 32, 11], [20, 37, 36, 35, 34, 33, 12], [19, 18, 17, 16, 15, 14, 13]]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 835test_setup_code: test_list: ['assert slope(4,2,2,5) == -1.5', 'assert slope(2,4,4,6) == 1', 'assert slope(1,2,4,2) == 0']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 836test_setup_code: test_list: ['assert max_sub_array_sum([-2, -3, 4, -1, -2, 1, 5, -3],8) == 5', 'assert max_sub_array_sum([1, -2, 1, 1, -2, 1],6) == 2', 'assert max_sub_array_sum([-1, -2, 3, 4, 5],5) == 3']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 837test_setup_code: test_list: ['assert cube_Sum(2) == 28', 'assert cube_Sum(3) == 153', 'assert cube_Sum(4) == 496']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 838test_setup_code: test_list: ['assert min_Swaps(\"0011\",\"1111\") == 1', 'assert min_Swaps(\"00011\",\"01001\") == 2', 'assert min_Swaps(\"111\",\"111\") == 0']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 839test_setup_code: test_list: ['assert sort_tuple([(\"Amana\", 28), (\"Zenat\", 30), (\"Abhishek\", 29),(\"Nikhil\", 21), (\"B\", \"C\")]) == [(\\'Abhishek\\', 29), (\\'Amana\\', 28), (\\'B\\', \\'C\\'), (\\'Nikhil\\', 21), (\\'Zenat\\', 30)]', 'assert sort_tuple([(\"aaaa\", 28), (\"aa\", 30), (\"bab\", 29), (\"bb\", 21), (\"csa\", \"C\")]) == [(\\'aa\\', 30), (\\'aaaa\\', 28), (\\'bab\\', 29), (\\'bb\\', 21), (\\'csa\\', \\'C\\')]', 'assert sort_tuple([(\"Sarala\", 28), (\"Ayesha\", 30), (\"Suman\", 29),(\"Sai\", 21), (\"G\", \"H\")]) == [(\\'Ayesha\\', 30), (\\'G\\', \\'H\\'), (\\'Sai\\', 21), (\\'Sarala\\', 28), (\\'Suman\\', 29)]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 840test_setup_code: test_list: ['assert Check_Solution(2,0,-1) == \"Yes\"', 'assert Check_Solution(1,-5,6) == \"No\"', 'assert Check_Solution(2,0,2) == \"Yes\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 841test_setup_code: test_list: ['assert get_inv_count([1, 20, 6, 4, 5], 5) == 5', 'assert get_inv_count([8, 4, 2, 1], 4) == 6', 'assert get_inv_count([3, 1, 2], 3) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 842test_setup_code: test_list: ['assert get_odd_occurence([2, 3, 5, 4, 5, 2, 4, 3, 5, 2, 4, 4, 2], 13) == 5', 'assert get_odd_occurence([1, 2, 3, 2, 3, 1, 3], 7) == 3', 'assert get_odd_occurence([5, 7, 2, 7, 5, 2, 5], 7) == 5']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 843test_setup_code: test_list: ['assert nth_super_ugly_number(12,[2,7,13,19])==32', 'assert nth_super_ugly_number(10,[2,7,13,19])==26', 'assert nth_super_ugly_number(100,[2,7,13,19])==5408']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 844test_setup_code: test_list: ['assert get_Number(8,5) == 2', 'assert get_Number(7,2) == 3', 'assert get_Number(5,2) == 3']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 845test_setup_code: test_list: ['assert find_Digits(7) == 4', 'assert find_Digits(5) == 3', 'assert find_Digits(4) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 846test_setup_code: test_list: ['assert find_platform([900, 940, 950, 1100, 1500, 1800],[910, 1200, 1120, 1130, 1900, 2000],6)==3', 'assert find_platform([100,200,300,400],[700,800,900,1000],4)==4', 'assert find_platform([5,6,7,8],[4,3,2,1],4)==1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 847test_setup_code: test_list: ['assert lcopy([1, 2, 3]) == [1, 2, 3]', 'assert lcopy([4, 8, 2, 10, 15, 18]) == [4, 8, 2, 10, 15, 18]', 'assert lcopy([4, 5, 6]) == [4, 5, 6]\\n']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 848test_setup_code: test_list: ['assert area_trapezium(6,9,4)==30', 'assert area_trapezium(10,20,30)==450', 'assert area_trapezium(15,25,35)==700']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 849test_setup_code: test_list: ['assert Sum(60) == 10', 'assert Sum(39) == 16', 'assert Sum(40) == 7']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 850test_setup_code: test_list: ['assert is_triangleexists(50,60,70)==True', 'assert is_triangleexists(90,45,45)==True', 'assert is_triangleexists(150,30,70)==False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 851test_setup_code: test_list: ['assert Sum_of_Inverse_Divisors(6,12) == 2', 'assert Sum_of_Inverse_Divisors(9,13) == 1.44', 'assert Sum_of_Inverse_Divisors(1,4) == 4']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 852test_setup_code: test_list: ['assert remove_negs([1,-2,3,-4]) == [1,3]', 'assert remove_negs([1,2,3,-4]) == [1,2,3]', 'assert remove_negs([4,5,-6,7,-8]) == [4,5,7]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 853test_setup_code: test_list: ['assert sum_of_odd_Factors(30) == 24', 'assert sum_of_odd_Factors(18) == 13', 'assert sum_of_odd_Factors(2) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 854test_setup_code: test_list: ['assert raw_heap([25, 44, 68, 21, 39, 23, 89])==[21, 25, 23, 44, 39, 68, 89]', 'assert raw_heap([25, 35, 22, 85, 14, 65, 75, 25, 58])== [14, 25, 22, 25, 35, 65, 75, 85, 58]', 'assert raw_heap([4, 5, 6, 2])==[2, 4, 6, 5]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 855test_setup_code: test_list: ['assert check_Even_Parity(10) == True', 'assert check_Even_Parity(11) == False', 'assert check_Even_Parity(18) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 856test_setup_code: test_list: ['assert find_Min_Swaps([1,0,1,0],4) == 3', 'assert find_Min_Swaps([0,1,0],3) == 1', 'assert find_Min_Swaps([0,0,1,1,0],5) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 857test_setup_code: test_list: [\"assert listify_list(['Red', 'Blue', 'Black', 'White', 'Pink'])==[['R', 'e', 'd'], ['B', 'l', 'u', 'e'], ['B', 'l', 'a', 'c', 'k'], ['W', 'h', 'i', 't', 'e'], ['P', 'i', 'n', 'k']]\", \"assert listify_list(['python'])==[['p', 'y', 't', 'h', 'o', 'n']]\", \"assert listify_list([' red ', 'green',' black', 'blue ',' orange', 'brown'])==[[' ', 'r', 'e', 'd', ' '], ['g', 'r', 'e', 'e', 'n'], [' ', 'b', 'l', 'a', 'c', 'k'], ['b', 'l', 'u', 'e', ' '], [' ', 'o', 'r', 'a', 'n', 'g', 'e'], ['b', 'r', 'o', 'w', 'n']]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 858test_setup_code: test_list: ['assert count_list([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==25', 'assert count_list([[1, 3], [5, 7], [9, 11], [13, 15, 17]] )==16', 'assert count_list([[2, 4], [[6,8], [4,5,8]], [10, 12, 14]])==9']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 859test_setup_code: test_list: ['assert sub_lists([10, 20, 30, 40])==[[], [10], [20], [30], [40], [10, 20], [10, 30], [10, 40], [20, 30], [20, 40], [30, 40], [10, 20, 30], [10, 20, 40], [10, 30, 40], [20, 30, 40], [10, 20, 30, 40]]', \"assert sub_lists(['X', 'Y', 'Z'])==[[], ['X'], ['Y'], ['Z'], ['X', 'Y'], ['X', 'Z'], ['Y', 'Z'], ['X', 'Y', 'Z']]\", 'assert sub_lists([1,2,3])==[[],[1],[2],[3],[1,2],[1,3],[2,3],[1,2,3]]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 860test_setup_code: test_list: ['assert check_alphanumeric(\"dawood@\") == \\'Discard\\'', 'assert check_alphanumeric(\"skdmsam326\") == \\'Accept\\'', 'assert check_alphanumeric(\"cooltricks@\") == \\'Discard\\'']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 861test_setup_code: test_list: ['assert anagram_lambda([\"bcda\", \"abce\", \"cbda\", \"cbea\", \"adcb\"],\"abcd\")==[\\'bcda\\', \\'cbda\\', \\'adcb\\']', 'assert anagram_lambda([\"recitals\",\" python\"], \"articles\" )==[\"recitals\"]', 'assert anagram_lambda([\" keep\",\" abcdef\",\" xyz\"],\" peek\")==[\" keep\"]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 862test_setup_code: test_list: ['assert n_common_words(\"python is a programming language\",1)==[(\\'python\\', 1)]', 'assert n_common_words(\"python is a programming language\",1)==[(\\'python\\', 1)]', 'assert n_common_words(\"python is a programming language\",5)==[(\\'python\\', 1),(\\'is\\', 1), (\\'a\\', 1), (\\'programming\\', 1), (\\'language\\', 1)]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 863test_setup_code: test_list: ['assert find_longest_conseq_subseq([1, 2, 2, 3], 4) == 3', 'assert find_longest_conseq_subseq([1, 9, 3, 10, 4, 20, 2], 7) == 4', 'assert find_longest_conseq_subseq([36, 41, 56, 35, 44, 33, 34, 92, 43, 32, 42], 11) == 5']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 864test_setup_code: test_list: ['assert palindrome_lambda([\"php\", \"res\", \"Python\", \"abcd\", \"Java\", \"aaa\"])==[\\'php\\', \\'aaa\\']', 'assert palindrome_lambda([\"abcd\", \"Python\", \"abba\", \"aba\"])==[\\'abba\\', \\'aba\\']', 'assert palindrome_lambda([\"abcd\", \"abbccbba\", \"abba\", \"aba\"])==[\\'abbccbba\\', \\'abba\\', \\'aba\\']']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 865test_setup_code: test_list: ['assert ntimes_list([1, 2, 3, 4, 5, 6, 7],3)==[3, 6, 9, 12, 15, 18, 21]', 'assert ntimes_list([1, 2, 3, 4, 5, 6, 7],4)==[4, 8, 12, 16, 20, 24, 28]', 'assert ntimes_list([1, 2, 3, 4, 5, 6, 7],10)==[10, 20, 30, 40, 50, 60, 70]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 866test_setup_code: test_list: ['assert check_monthnumb(\"February\")==False', 'assert check_monthnumb(\"January\")==True', 'assert check_monthnumb(\"March\")==True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 867test_setup_code: test_list: ['assert min_Num([1,2,3,4,5,6,7,8,9],9) == 1', 'assert min_Num([1,2,3,4,5,6,7,8],8) == 2', 'assert min_Num([1,2,3],3) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 868test_setup_code: test_list: ['assert length_Of_Last_Word(\"python language\") == 8', 'assert length_Of_Last_Word(\"PHP\") == 3', 'assert length_Of_Last_Word(\"\") == 0']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 869test_setup_code: test_list: ['assert remove_list_range([[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7], [9, 11], [13, 14, 15, 17]],13,17)==[[13, 14, 15, 17]]', 'assert remove_list_range([[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7], [9, 11], [13, 14, 15, 17]],1,3)==[[2], [1, 2, 3]]', 'assert remove_list_range([[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7], [9, 11], [13, 14, 15, 17]],0,7)==[[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7]]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 870test_setup_code: test_list: ['assert sum_positivenum([2, 4, -6, -9, 11, -12, 14, -5, 17])==48', 'assert sum_positivenum([10,15,-14,13,-18,12,-20])==50', 'assert sum_positivenum([19, -65, 57, 39, 152,-639, 121, 44, 90, -190])==522']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 871test_setup_code: test_list: ['assert are_Rotations(\"abc\",\"cba\") == False', 'assert are_Rotations(\"abcd\",\"cdba\") == False', 'assert are_Rotations(\"abacd\",\"cdaba\") == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 872test_setup_code: test_list: ['assert check_subset([[1, 3], [5, 7], [9, 11], [13, 15, 17]] ,[[1, 3],[13,15,17]])==True', 'assert check_subset([[1, 2], [2, 3], [3, 4], [5, 6]],[[3, 4], [5, 6]])==True', 'assert check_subset([[[1, 2], [2, 3]], [[3, 4], [5, 7]]],[[[3, 4], [5, 6]]])==False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 873test_setup_code: test_list: ['assert fibonacci(7) == 13', 'assert fibonacci(8) == 21', 'assert fibonacci(9) == 34']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 874test_setup_code: test_list: ['assert check_Concat(\"abcabcabc\",\"abc\") == True', 'assert check_Concat(\"abcab\",\"abc\") == False', 'assert check_Concat(\"aba\",\"ab\") == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 875test_setup_code: test_list: ['assert min_difference([(3, 5), (1, 7), (10, 3), (1, 2)]) == 1', 'assert min_difference([(4, 6), (12, 8), (11, 4), (2, 13)]) == 2', 'assert min_difference([(5, 17), (3, 9), (12, 5), (3, 24)]) == 6']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 876test_setup_code: test_list: ['assert lcm(4,6) == 12', 'assert lcm(15,17) == 255', 'assert lcm(2,6) == 6']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 877test_setup_code: test_list: ['assert sort_String(\"cba\") == \"abc\"', 'assert sort_String(\"data\") == \"aadt\"', 'assert sort_String(\"zxy\") == \"xyz\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 878test_setup_code: test_list: ['assert check_tuples((3, 5, 6, 5, 3, 6),[3, 6, 5]) == True', 'assert check_tuples((4, 5, 6, 4, 6, 5),[4, 5, 6]) == True', 'assert check_tuples((9, 8, 7, 6, 8, 9),[9, 8, 1]) == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 879test_setup_code: test_list: ['assert text_match(\"aabbbbd\") == \\'Not matched!\\'', 'assert text_match(\"aabAbbbc\") == \\'Not matched!\\'', 'assert text_match(\"accddbbjjjb\") == \\'Found a match!\\'']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 880test_setup_code: test_list: ['assert Check_Solution(2,5,2) == \"2 solutions\"', 'assert Check_Solution(1,1,1) == \"No solutions\"', 'assert Check_Solution(1,2,1) == \"1 solution\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 881test_setup_code: test_list: ['assert sum_even_odd([1,3,5,7,4,1,6,8])==5', 'assert sum_even_odd([1,2,3,4,5,6,7,8,9,10])==3', 'assert sum_even_odd([1,5,7,9,10])==11']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 882test_setup_code: test_list: ['assert parallelogram_perimeter(10,20)==400', 'assert parallelogram_perimeter(15,20)==600', 'assert parallelogram_perimeter(8,9)==144']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 883test_setup_code: test_list: ['assert div_of_nums([19, 65, 57, 39, 152, 639, 121, 44, 90, 190],2,4)==[ 152,44]', 'assert div_of_nums([1, 2, 3, 5, 7, 8, 10],2,5)==[10]', 'assert div_of_nums([10,15,14,13,18,12,20],10,5)==[10,20]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 884test_setup_code: test_list: ['assert all_Bits_Set_In_The_Given_Range(10,2,1) == True ', 'assert all_Bits_Set_In_The_Given_Range(5,2,4) == False', 'assert all_Bits_Set_In_The_Given_Range(22,2,3) == True ']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 885test_setup_code: test_list: ['assert is_Isomorphic(\"paper\",\"title\") == True', 'assert is_Isomorphic(\"ab\",\"ba\") == True', 'assert is_Isomorphic(\"ab\",\"aa\") == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 886test_setup_code: test_list: ['assert sum_num((8, 2, 3, 0, 7))==4.0', 'assert sum_num((-10,-20,-30))==-20.0', 'assert sum_num((19,15,18))==17.333333333333332']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 887test_setup_code: test_list: ['assert is_odd(5) == True', 'assert is_odd(6) == False', 'assert is_odd(7) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 888test_setup_code: test_list: ['assert substract_elements(((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))) == ((-5, -4), (1, -4), (1, 8), (-6, 7))', 'assert substract_elements(((13, 4), (14, 6), (13, 10), (12, 11)), ((19, 8), (14, 10), (12, 2), (18, 4))) == ((-6, -4), (0, -4), (1, 8), (-6, 7))', 'assert substract_elements(((19, 5), (18, 7), (19, 11), (17, 12)), ((12, 9), (17, 11), (13, 3), (19, 5))) == ((7, -4), (1, -4), (6, 8), (-2, 7))']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 889test_setup_code: test_list: ['assert reverse_list_lists([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]])==[[4, 3, 2, 1], [8, 7, 6, 5], [12, 11, 10, 9], [16, 15, 14, 13]]', 'assert reverse_list_lists([[1,2],[2,3],[3,4]])==[[2,1],[3,2],[4,3]]', 'assert reverse_list_lists([[10,20],[30,40]])==[[20,10],[40,30]]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 890test_setup_code: test_list: ['assert find_Extra([1,2,3,4],[1,2,3],3) == 3', 'assert find_Extra([2,4,6,8,10],[2,4,6,8],4) == 4', 'assert find_Extra([1,3,5,7,9,11],[1,3,5,7,9],5) == 5']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 891test_setup_code: test_list: ['assert same_Length(12,1) == False', 'assert same_Length(2,2) == True', 'assert same_Length(10,20) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 892test_setup_code: test_list: [\"assert remove_spaces('python program')==('python program')\", \"assert remove_spaces('python programming language')==('python programming language')\", \"assert remove_spaces('python program')==('python program')\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 893test_setup_code: test_list: ['assert Extract([[1, 2, 3], [4, 5], [6, 7, 8, 9]]) == [3, 5, 9]', \"assert Extract([['x', 'y', 'z'], ['m'], ['a', 'b'], ['u', 'v']]) == ['z', 'm', 'b', 'v']\", 'assert Extract([[1, 2, 3], [4, 5]]) == [3, 5]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 894test_setup_code: test_list: ['assert float_to_tuple(\"1.2, 1.3, 2.3, 2.4, 6.5\") == (1.2, 1.3, 2.3, 2.4, 6.5)', 'assert float_to_tuple(\"2.3, 2.4, 5.6, 5.4, 8.9\") == (2.3, 2.4, 5.6, 5.4, 8.9)', 'assert float_to_tuple(\"0.3, 0.5, 7.8, 9.4\") == (0.3, 0.5, 7.8, 9.4)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 895test_setup_code: test_list: ['assert max_sum_subseq([1, 2, 9, 4, 5, 0, 4, 11, 6]) == 26', 'assert max_sum_subseq([1, 2, 9, 5, 6, 0, 5, 12, 7]) == 28', 'assert max_sum_subseq([1, 3, 10, 5, 6, 0, 6, 14, 21]) == 44']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 896test_setup_code: test_list: ['assert sort_list_last([(2, 5), (1, 2), (4, 4), (2, 3), (2, 1)])==[(2, 1), (1, 2), (2, 3), (4, 4), (2, 5)] ', 'assert sort_list_last([(9,8), (4, 7), (3,5), (7,9), (1,2)])==[(1,2), (3,5), (4,7), (9,8), (7,9)] ', 'assert sort_list_last([(20,50), (10,20), (40,40)])==[(10,20),(40,40),(20,50)] ']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 897test_setup_code: test_list: ['assert is_Word_Present(\"machine learning\",\"machine\") == True', 'assert is_Word_Present(\"easy\",\"fun\") == False', 'assert is_Word_Present(\"python language\",\"code\") == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 898test_setup_code: test_list: ['assert extract_elements([1, 1, 3, 4, 4, 5, 6, 7],2)==[1, 4]', 'assert extract_elements([0, 1, 2, 3, 4, 4, 4, 4, 5, 7],4)==[4]', 'assert extract_elements([0,0,0,0,0],5)==[0]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 899test_setup_code: test_list: ['assert check([3,2,1,2,3,4],6) == True', 'assert check([2,1,4,5,1],5) == True', 'assert check([1,2,2,1,2,3],6) == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 900test_setup_code: test_list: [\"assert match_num('5-2345861')==True\", \"assert match_num('6-2345861')==False\", \"assert match_num('78910')==False\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 901test_setup_code: test_list: ['assert smallest_multiple(13)==360360', 'assert smallest_multiple(2)==2', 'assert smallest_multiple(1)==1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 902test_setup_code: test_list: [\"assert add_dict({'a': 100, 'b': 200, 'c':300},{'a': 300, 'b': 200, 'd':400})==({'b': 400, 'd': 400, 'a': 400, 'c': 300}) \", \"assert add_dict({'a': 500, 'b': 700, 'c':900},{'a': 500, 'b': 600, 'd':900})==({'b': 1300, 'd': 900, 'a': 1000, 'c': 900}) \", \"assert add_dict({'a':900,'b':900,'d':900},{'a':900,'b':900,'d':900})==({'b': 1800, 'd': 1800, 'a': 1800})\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 903test_setup_code: test_list: ['assert count_Unset_Bits(2) == 1', 'assert count_Unset_Bits(5) == 4', 'assert count_Unset_Bits(14) == 17']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 904test_setup_code: test_list: ['assert even_num(13.5)==False', 'assert even_num(0)==True', 'assert even_num(-9)==False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 905test_setup_code: test_list: ['assert sum_of_square(4) == 70', 'assert sum_of_square(5) == 252', 'assert sum_of_square(2) == 6']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 906test_setup_code: test_list: ['assert extract_date(\"https://www.washingtonpost.com/news/football-insider/wp/2016/09/02/odell-beckhams-fame-rests-on-one-stupid-little-ball-josh-norman-tells-author/\") == [(\\'2016\\', \\'09\\', \\'02\\')]', 'assert extract_date(\"https://www.indiatoday.in/movies/celebrities/story/wp/2020/11/03/odeof-sushant-singh-rajput-s-death-his-brother-in-law-shares-advice-for-fans-1749646/\") == [(\\'2020\\', \\'11\\', \\'03\\')]', 'assert extract_date(\"https://economictimes.indiatimes.com/news/economy/2020/12/29/finance/pension-assets-under-pfrda-touch-rs-5-32-lakh-crore/articleshow/79736619.cms\") == [(\\'2020\\', \\'12\\', \\'29\\')]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 907test_setup_code: test_list: ['assert lucky_num(10)==[1, 3, 7, 9, 13, 15, 21, 25, 31, 33] ', 'assert lucky_num(5)==[1, 3, 7, 9, 13]', 'assert lucky_num(8)==[1, 3, 7, 9, 13, 15, 21, 25]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 908test_setup_code: test_list: ['assert find_fixed_point([-10, -1, 0, 3, 10, 11, 30, 50, 100],9) == 3', 'assert find_fixed_point([1, 2, 3, 4, 5, 6, 7, 8],8) == -1', 'assert find_fixed_point([0, 2, 5, 8, 17],5) == 0']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 909test_setup_code: test_list: ['assert previous_palindrome(99)==88', 'assert previous_palindrome(1221)==1111', 'assert previous_palindrome(120)==111']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 910test_setup_code: test_list: ['assert check_date(11,11,2002)==True', 'assert check_date(13,11,2002)==False', \"assert check_date('11','11','2002')==True\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 911test_setup_code: test_list: ['assert maximum_product( [12, 74, 9, 50, 61, 41])==225700', 'assert maximum_product([25, 35, 22, 85, 14, 65, 75, 25, 58])==414375', 'assert maximum_product([18, 14, 10, 9, 8, 7, 9, 3, 2, 4, 1])==2520']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 912test_setup_code: test_list: ['assert int(lobb_num(5, 3)) == 35', 'assert int(lobb_num(3, 2)) == 5', 'assert int(lobb_num(4, 2)) == 20']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 913test_setup_code: test_list: [\"assert end_num('abcdef')==False\", \"assert end_num('abcdef7')==True\", \"assert end_num('abc')==False\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 914test_setup_code: test_list: ['assert is_Two_Alter(\"abab\") == True', 'assert is_Two_Alter(\"aaaa\") == False', 'assert is_Two_Alter(\"xyz\") == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 915test_setup_code: test_list: ['assert rearrange_numbs([-1, 2, -3, 5, 7, 8, 9, -10])==[2, 5, 7, 8, 9, -10, -3, -1]', 'assert rearrange_numbs([10,15,14,13,-18,12,-20])==[10, 12, 13, 14, 15, -20, -18]', 'assert rearrange_numbs([-20,20,-10,10,-30,30])==[10, 20, 30, -30, -20, -10]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 916test_setup_code: test_list: ['assert find_triplet_array([1, 4, 45, 6, 10, 8], 6, 22) == (4, 10, 8)', 'assert find_triplet_array([12, 3, 5, 2, 6, 9], 6, 24) == (12, 3, 9)', 'assert find_triplet_array([1, 2, 3, 4, 5], 5, 9) == (1, 3, 5)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 917test_setup_code: test_list: ['assert text_uppercase_lowercase(\"AaBbGg\")==(\\'Found a match!\\')', 'assert text_uppercase_lowercase(\"aA\")==(\\'Not matched!\\')', 'assert text_uppercase_lowercase(\"PYTHON\")==(\\'Not matched!\\')']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 918test_setup_code: test_list: ['assert coin_change([1, 2, 3],3,4)==4', 'assert coin_change([4,5,6,7,8,9],6,9)==2', 'assert coin_change([4,5,6,7,8,9],6,4)==1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 919test_setup_code: test_list: ['assert multiply_list([1,-2,3]) == -6', 'assert multiply_list([1,2,3,4]) == 24', 'assert multiply_list([3,1,2,3]) == 18']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 920test_setup_code: test_list: [\"assert remove_tuple([(None, 2), (None, None), (3, 4), (12, 3), (None, )] ) == '[(None, 2), (3, 4), (12, 3)]'\", \"assert remove_tuple([(None, None), (None, None), (3, 6), (17, 3), (None,1 )] ) == '[(3, 6), (17, 3), (None, 1)]'\", \"assert remove_tuple([(1, 2), (2, None), (3, None), (24, 3), (None, None )] ) == '[(1, 2), (2, None), (3, None), (24, 3)]'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 921test_setup_code: test_list: ['assert chunk_tuples((10, 4, 5, 6, 7, 6, 8, 3, 4), 3) == [(10, 4, 5), (6, 7, 6), (8, 3, 4)]', 'assert chunk_tuples((1, 2, 3, 4, 5, 6, 7, 8, 9), 2) == [(1, 2), (3, 4), (5, 6), (7, 8), (9,)]', 'assert chunk_tuples((11, 14, 16, 17, 19, 21, 22, 25), 4) == [(11, 14, 16, 17), (19, 21, 22, 25)]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 922test_setup_code: test_list: ['assert max_product([1, 2, 3, 4, 7, 0, 8, 4])==(7, 8)', 'assert max_product([0, -1, -2, -4, 5, 0, -6])==(-4, -6)', 'assert max_product([1, 3, 5, 6, 8, 9])==(8,9)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 923test_setup_code: test_list: ['assert super_seq(\"AGGTAB\", \"GXTXAYB\", 6, 7) == 9', 'assert super_seq(\"feek\", \"eke\", 4, 3) == 5', 'assert super_seq(\"PARRT\", \"RTA\", 5, 3) == 6']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 924test_setup_code: test_list: ['assert max_of_two(10,20)==20', 'assert max_of_two(19,15)==19', 'assert max_of_two(-10,-20)==-10']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 925test_setup_code: test_list: ['assert mutiple_tuple((4, 3, 2, 2, -1, 18)) == -864', 'assert mutiple_tuple((1,2,3)) == 6', 'assert mutiple_tuple((-2,-4,-6)) == -48']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 926test_setup_code: test_list: ['assert rencontres_number(7, 2) == 924', 'assert rencontres_number(3, 0) == 2', 'assert rencontres_number(3, 1) == 3']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 927test_setup_code: root = Node(1) \r\nroot.left = Node(2) \r\nroot.right = Node(3) \r\nroot.left.left = Node(4) \r\nroot.left.right = Node(5) \r\nroot1 = Node(1); \r\nroot1.left = Node(2); \r\nroot1.right = Node(3); \r\nroot1.left.left = Node(4); \r\nroot1.right.left = Node(5); \r\nroot1.right.right = Node(6); \r\nroot1.right.right.right= Node(7); \r\nroot1.right.right.right.right = Node(8)\r\nroot2 = Node(1) \r\nroot2.left = Node(2) \r\nroot2.right = Node(3) \r\nroot2.left.left = Node(4) \r\nroot2.left.right = Node(5)\r\nroot2.left.left.left = Node(6)\r\nroot2.left.left.right = Node(7)test_list: ['assert (max_height(root)) == 3', 'assert (max_height(root1)) == 5 ', 'assert (max_height(root2)) == 4']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 928test_setup_code: test_list: [\"assert change_date_format('2026-01-02')=='02-01-2026'\", \"assert change_date_format('2021-01-04')=='04-01-2021'\", \"assert change_date_format('2030-06-06')=='06-06-2030'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 929test_setup_code: test_list: ['assert count_tuplex((2, 4, 5, 6, 2, 3, 4, 4, 7),4)==3', 'assert count_tuplex((2, 4, 5, 6, 2, 3, 4, 4, 7),2)==2', 'assert count_tuplex((2, 4, 7, 7, 7, 3, 4, 4, 7),7)==4']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 930test_setup_code: test_list: ['assert text_match(\"msb\") == \\'Not matched!\\'', 'assert text_match(\"a0c\") == \\'Found a match!\\'', 'assert text_match(\"abbc\") == \\'Found a match!\\'']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 931test_setup_code: test_list: ['assert sum_series(7)==784', 'assert sum_series(5)==225', 'assert sum_series(15)==14400']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 932test_setup_code: test_list: ['assert remove_duplic_list([\"Python\", \"Exercises\", \"Practice\", \"Solution\", \"Exercises\"])==[\\'Python\\', \\'Exercises\\', \\'Practice\\', \\'Solution\\']', 'assert remove_duplic_list([\"Python\", \"Exercises\", \"Practice\", \"Solution\", \"Exercises\",\"Java\"])==[\\'Python\\', \\'Exercises\\', \\'Practice\\', \\'Solution\\', \\'Java\\']', 'assert remove_duplic_list([\"Python\", \"Exercises\", \"Practice\", \"Solution\", \"Exercises\",\"C++\",\"C\",\"C++\"])==[\\'Python\\', \\'Exercises\\', \\'Practice\\', \\'Solution\\',\\'C++\\',\\'C\\']']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 933test_setup_code: test_list: [\"assert camel_to_snake('GoogleAssistant') == 'google_assistant'\", \"assert camel_to_snake('ChromeCast') == 'chrome_cast'\", \"assert camel_to_snake('QuadCore') == 'quad_core'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 934test_setup_code: test_list: ['assert dealnnoy_num(3, 4) == 129', 'assert dealnnoy_num(3, 3) == 63', 'assert dealnnoy_num(4, 5) == 681']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 935test_setup_code: test_list: ['assert series_sum(6)==91', 'assert series_sum(7)==140', 'assert series_sum(12)==650']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 936test_setup_code: test_list: ['assert re_arrange_tuples([(4, 3), (1, 9), (2, 10), (3, 2)], [1, 4, 2, 3]) == [(1, 9), (4, 3), (2, 10), (3, 2)]', 'assert re_arrange_tuples([(5, 4), (2, 10), (3, 11), (4, 3)], [3, 4, 2, 3]) == [(3, 11), (4, 3), (2, 10), (3, 11)]', 'assert re_arrange_tuples([(6, 3), (3, 8), (5, 7), (2, 4)], [2, 5, 3, 6]) == [(2, 4), (5, 7), (3, 8), (6, 3)]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 937test_setup_code: test_list: ['assert max_char(\"hello world\")==(\\'l\\')', 'assert max_char(\"hello \")==(\\'l\\')', 'assert max_char(\"python pr\")==(\\'p\\')']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 938test_setup_code: test_list: ['assert find_closet([1, 4, 10],[2, 15, 20],[10, 12],3,3,2) == (10, 15, 10)', 'assert find_closet([20, 24, 100],[2, 19, 22, 79, 800],[10, 12, 23, 24, 119],3,5,5) == (24, 22, 23)', 'assert find_closet([2, 5, 11],[3, 16, 21],[11, 13],3,3,2) == (11, 16, 11)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 939test_setup_code: test_list: [\"assert sorted_models([{'make':'Nokia', 'model':216, 'color':'Black'}, {'make':'Mi Max', 'model':2, 'color':'Gold'}, {'make':'Samsung', 'model': 7, 'color':'Blue'}])==[{'make': 'Nokia', 'model': 216, 'color': 'Black'}, {'make': 'Samsung', 'model': 7, 'color': 'Blue'}, {'make': 'Mi Max', 'model': 2, 'color': 'Gold'}]\", \"assert sorted_models([{'make':'Vivo', 'model':20,'color':'Blue'},{'make': 'oppo','model':17,'color':'Gold'},{'make':'Apple','model':11,'color':'red'}])==([{'make':'Vivo', 'model':20,'color':'Blue'},{'make': 'oppo','model':17,'color':'Gold'},{'make':'Apple','model':11,'color':'red'}])\", \"assert sorted_models([{'make':'micromax','model':40,'color':'grey'},{'make':'poco','model':60,'color':'blue'}])==([{'make':'poco','model':60,'color':'blue'},{'make':'micromax','model':40,'color':'grey'}])\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 940test_setup_code: test_list: ['assert heap_sort([12, 2, 4, 5, 2, 3]) == [2, 2, 3, 4, 5, 12]', 'assert heap_sort([32, 14, 5, 6, 7, 19]) == [5, 6, 7, 14, 19, 32]', 'assert heap_sort([21, 15, 29, 78, 65]) == [15, 21, 29, 65, 78]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 941test_setup_code: test_list: ['assert count_elim([10,20,30,(10,20),40])==3', 'assert count_elim([10,(20,30),(10,20),40])==1', 'assert count_elim([(10,(20,30,(10,20),40))])==0']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 942test_setup_code: test_list: ['assert check_element((4, 5, 7, 9, 3), [6, 7, 10, 11]) == True', 'assert check_element((1, 2, 3, 4), [4, 6, 7, 8, 9]) == True', 'assert check_element((3, 2, 1, 4, 5), [9, 8, 7, 6]) == False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 943test_setup_code: test_list: ['assert combine_lists([1, 3, 5, 7, 9, 11],[0, 2, 4, 6, 8, 10])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]', 'assert combine_lists([1, 3, 5, 6, 8, 9], [2, 5, 7, 11])==[1,2,3,5,5,6,7,8,9,11]', 'assert combine_lists([1,3,7],[2,4,6])==[1,2,3,4,6,7]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 944test_setup_code: test_list: ['assert num_position(\"there are 70 flats in this apartment\")==10', 'assert num_position(\"every adult have 32 teeth\")==17', 'assert num_position(\"isha has 79 chocolates in her bag\")==9']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 945test_setup_code: test_list: [\"assert tuple_to_set(('x', 'y', 'z') ) == {'y', 'x', 'z'}\", \"assert tuple_to_set(('a', 'b', 'c') ) == {'c', 'a', 'b'}\", \"assert tuple_to_set(('z', 'd', 'e') ) == {'d', 'e', 'z'}\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 946test_setup_code: test_list: [\"assert most_common_elem('lkseropewdssafsdfafkpwe',3)==[('s', 4), ('e', 3), ('f', 3)] \", \"assert most_common_elem('lkseropewdssafsdfafkpwe',2)==[('s', 4), ('e', 3)]\", \"assert most_common_elem('lkseropewdssafsdfafkpwe',7)==[('s', 4), ('e', 3), ('f', 3), ('k', 2), ('p', 2), ('w', 2), ('d', 2)]\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 947test_setup_code: test_list: ['assert len_log([\"win\",\"lose\",\"great\"]) == 3', 'assert len_log([\"a\",\"ab\",\"abc\"]) == 1', 'assert len_log([\"12\",\"12\",\"1234\"]) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 948test_setup_code: test_list: ['assert get_item((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),3)==(\\'e\\')', 'assert get_item((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),-4)==(\\'u\\')', 'assert get_item((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),-3)==(\\'r\\')']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 949test_setup_code: test_list: [\"assert sort_list([(3, 4, 6, 723), (1, 2), (12345,), (134, 234, 34)] ) == '[(1, 2), (12345,), (3, 4, 6, 723), (134, 234, 34)]'\", \"assert sort_list([(3, 4, 8), (1, 2), (1234335,), (1345, 234, 334)] ) == '[(1, 2), (3, 4, 8), (1234335,), (1345, 234, 334)]'\", \"assert sort_list([(34, 4, 61, 723), (1, 2), (145,), (134, 23)] ) == '[(1, 2), (145,), (134, 23), (34, 4, 61, 723)]'\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 950test_setup_code: test_list: [\"assert chinese_zodiac(1997)==('Ox')\", \"assert chinese_zodiac(1998)==('Tiger')\", \"assert chinese_zodiac(1994)==('Dog')\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 951test_setup_code: test_list: ['assert max_similar_indices([(2, 4), (6, 7), (5, 1)],[(5, 4), (8, 10), (8, 14)]) == [(5, 4), (8, 10), (8, 14)]', 'assert max_similar_indices([(3, 5), (7, 8), (6, 2)],[(6, 5), (9, 11), (9, 15)]) == [(6, 5), (9, 11), (9, 15)]', 'assert max_similar_indices([(4, 6), (8, 9), (7, 3)],[(7, 6), (10, 12), (10, 16)]) == [(7, 6), (10, 12), (10, 16)]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 952test_setup_code: test_list: ['assert nCr_mod_p(10, 2, 13) == 6', 'assert nCr_mod_p(11, 3, 14) == 11', 'assert nCr_mod_p(18, 14, 19) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 953test_setup_code: test_list: ['assert subset([1, 2, 3, 4],4) == 1', 'assert subset([5, 6, 9, 3, 4, 3, 4],7) == 2', 'assert subset([1, 2, 3 ],3) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 954test_setup_code: test_list: ['assert profit_amount(1500,1200)==300', 'assert profit_amount(100,200)==None', 'assert profit_amount(2000,5000)==None']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 955test_setup_code: test_list: ['assert is_abundant(12)==True', 'assert is_abundant(13)==False', 'assert is_abundant(9)==False']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 956test_setup_code: test_list: ['assert split_list(\"LearnToBuildAnythingWithGoogle\") == [\\'Learn\\', \\'To\\', \\'Build\\', \\'Anything\\', \\'With\\', \\'Google\\']', 'assert split_list(\"ApmlifyingTheBlack+DeveloperCommunity\") == [\\'Apmlifying\\', \\'The\\', \\'Black+\\', \\'Developer\\', \\'Community\\']', 'assert split_list(\"UpdateInTheGoEcoSystem\") == [\\'Update\\', \\'In\\', \\'The\\', \\'Go\\', \\'Eco\\', \\'System\\']']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 957test_setup_code: test_list: ['assert get_First_Set_Bit_Pos(12) == 3', 'assert get_First_Set_Bit_Pos(18) == 2', 'assert get_First_Set_Bit_Pos(16) == 5']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 958test_setup_code: test_list: ['assert int_to_roman(1)==(\"I\")', 'assert int_to_roman(50)==(\"L\")', 'assert int_to_roman(4)==(\"IV\")']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 959test_setup_code: test_list: ['assert Average([15, 9, 55, 41, 35, 20, 62, 49]) == 35.75', 'assert Average([4, 5, 1, 2, 9, 7, 10, 8]) == 5.75', 'assert Average([1,2,3]) == 2']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 960test_setup_code: test_list: ['assert get_noOfways(4)==3', 'assert get_noOfways(3)==2', 'assert get_noOfways(5)==5']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 961test_setup_code: test_list: [\"assert roman_to_int('MMMCMLXXXVI')==3986\", \"assert roman_to_int('MMMM')==4000\", \"assert roman_to_int('C')==100\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 962test_setup_code: test_list: ['assert sum_Even(2,5) == 6', 'assert sum_Even(3,8) == 18', 'assert sum_Even(4,6) == 10']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 963test_setup_code: test_list: ['assert discriminant_value(4,8,2)==(\"Two solutions\",32)', 'assert discriminant_value(5,7,9)==(\"no real solution\",-131)', 'assert discriminant_value(0,0,9)==(\"one solution\",0)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 964test_setup_code: test_list: ['assert word_len(\"program\") == False', 'assert word_len(\"solution\") == True', 'assert word_len(\"data\") == True']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 965test_setup_code: test_list: [\"assert camel_to_snake('PythonProgram')==('python_program')\", \"assert camel_to_snake('pythonLanguage')==('python_language')\", \"assert camel_to_snake('ProgrammingLanguage')==('programming_language')\"]challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 966test_setup_code: test_list: [\"assert remove_empty([(), (), ('',), ('a', 'b'), ('a', 'b', 'c'), ('d')])==[('',), ('a', 'b'), ('a', 'b', 'c'), 'd'] \", 'assert remove_empty([(), (), (\\'\\',), (\"python\"), (\"program\")])==[(\\'\\',), (\"python\"), (\"program\")] ', 'assert remove_empty([(), (), (\\'\\',), (\"java\")])==[(\\'\\',),(\"java\") ] ']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 967test_setup_code: test_list: ['assert check(\"SEEquoiaL\") == \\'accepted\\'', 'assert check(\\'program\\') == \"not accepted\"', 'assert check(\\'fine\\') == \"not accepted\"']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 968test_setup_code: test_list: ['assert floor_Max(11,10,9) == 9', 'assert floor_Max(5,7,4) == 2', 'assert floor_Max(2,2,1) == 1']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 969test_setup_code: test_list: ['assert join_tuples([(5, 6), (5, 7), (6, 8), (6, 10), (7, 13)] ) == [(5, 6, 7), (6, 8, 10), (7, 13)]', 'assert join_tuples([(6, 7), (6, 8), (7, 9), (7, 11), (8, 14)] ) == [(6, 7, 8), (7, 9, 11), (8, 14)]', 'assert join_tuples([(7, 8), (7, 9), (8, 10), (8, 12), (9, 15)] ) == [(7, 8, 9), (8, 10, 12), (9, 15)]']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 970test_setup_code: test_list: ['assert min_of_two(10,20)==10', 'assert min_of_two(19,15)==15', 'assert min_of_two(-10,-20)==-20']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 971test_setup_code: test_list: ['assert maximum_segments(7, 5, 2, 5) == 2', 'assert maximum_segments(17, 2, 1, 3) == 17', 'assert maximum_segments(18, 16, 3, 6) == 6']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 972test_setup_code: test_list: ['assert concatenate_nested((3, 4), (5, 6)) == (3, 4, 5, 6)', 'assert concatenate_nested((1, 2), (3, 4)) == (1, 2, 3, 4)', 'assert concatenate_nested((4, 5), (6, 8)) == (4, 5, 6, 8)']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 973test_setup_code: test_list: ['assert left_rotate(\"python\",2) == \"thonpy\" ', 'assert left_rotate(\"bigdata\",3 ) == \"databig\" ', 'assert left_rotate(\"hadoop\",1 ) == \"adooph\" ']challenge_test_list: []" + }, + { + "Answer": "", + "Explanation": "task_id: 974test_setup_code: test_list: ['assert min_sum_path([[ 2 ], [3, 9 ], [1, 6, 7 ]]) == 6', 'assert min_sum_path([[ 2 ], [3, 7 ], [8, 5, 6 ]]) == 10 ', 'assert min_sum_path([[ 3 ], [6, 4 ], [5, 2, 7 ]]) == 9']challenge_test_list: []" + } + ] +} \ No newline at end of file