diff --git "a/data/funSigTests_prompt.json" "b/data/funSigTests_prompt.json" new file mode 100644--- /dev/null +++ "b/data/funSigTests_prompt.json" @@ -0,0 +1,374 @@ +{"task_id":601,"text":"Write a function to find the longest chain which can be formed from the given set of pairs.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the longest chain which can be formed from the given set of pairs.\n### Function signature: def max_chain_length(arr, n):\n### Tests: assert max_chain_length([Pair(5, 24), Pair(15, 25),Pair(27, 40), Pair(50, 60)], 4) == 3\n assert max_chain_length([Pair(1, 2), Pair(3, 4),Pair(5, 6), Pair(7, 8)], 4) == 4\n### Response: "} +{"task_id":602,"text":"Write a python function to find the first repeated character in a given string.","code":"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\"","test_list":["assert first_repeated_char(\"abcabc\") == \"a\"","assert first_repeated_char(\"abc\") == \"None\"","assert first_repeated_char(\"123123\") == \"1\""],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the first repeated character in a given string.\n### Function signature: def first_repeated_char(str1):\n### Tests: assert first_repeated_char(\"abcabc\") == \"a\"\n assert first_repeated_char(\"abc\") == \"None\"\n### Response: "} +{"task_id":603,"text":"Write a function to get a lucid number smaller than or equal to n.","code":"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","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to get a lucid number smaller than or equal to n.\n### Function signature: def get_ludic(n):\n### Tests: assert get_ludic(10) == [1, 2, 3, 5, 7]\n assert get_ludic(25) == [1, 2, 3, 5, 7, 11, 13, 17, 23, 25]\n### Response: "} +{"task_id":604,"text":"Write a function to reverse words in a given string.","code":"def reverse_words(s):\r\n return ' '.join(reversed(s.split()))","test_list":["assert reverse_words(\"python program\")==(\"program python\")","assert reverse_words(\"java language\")==(\"language java\")","assert reverse_words(\"indian man\")==(\"man indian\")"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to reverse words in a given string.\n### Function signature: def reverse_words(s):\n### Tests: assert reverse_words(\"python program\")==(\"program python\")\n assert reverse_words(\"java language\")==(\"language java\")\n### Response: "} +{"task_id":605,"text":"Write a function to check if the given integer is a prime number.","code":"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","test_list":["assert prime_num(13)==True","assert prime_num(7)==True","assert prime_num(-1010)==False"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check if the given integer is a prime number.\n### Function signature: def prime_num(num):\n### Tests: assert prime_num(13)==True\n assert prime_num(7)==True\n### Response: "} +{"task_id":606,"text":"Write a function to convert degrees to radians.","code":"import math\r\ndef radian_degree(degree):\r\n radian = degree*(math.pi\/180)\r\n return radian","test_list":["assert radian_degree(90)==1.5707963267948966","assert radian_degree(60)==1.0471975511965976","assert radian_degree(120)==2.0943951023931953"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to convert degrees to radians.\n### Function signature: def radian_degree(degree):\n### Tests: assert radian_degree(90)==1.5707963267948966\n assert radian_degree(60)==1.0471975511965976\n### Response: "} +{"task_id":607,"text":"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.","code":"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)","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)"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: 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.\n### Function signature: def find_literals(text, pattern):\n### Tests: assert find_literals('The quick brown fox jumps over the lazy dog.', 'fox') == ('fox', 16, 19)\n assert find_literals('Its been a very crazy procedure right', 'crazy') == ('crazy', 16, 21)\n### Response: "} +{"task_id":608,"text":"Write a python function to find nth bell number.","code":"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] ","test_list":["assert bell_Number(2) == 2","assert bell_Number(3) == 5","assert bell_Number(4) == 15"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find nth bell number.\n### Function signature: def bell_Number(n):\n### Tests: assert bell_Number(2) == 2\n assert bell_Number(3) == 5\n### Response: "} +{"task_id":609,"text":"Write a python function to find minimum possible value for the given periodic function.","code":"def floor_Min(A,B,N):\r\n x = max(B - 1,N)\r\n return (A*x) \/\/ B","test_list":["assert floor_Min(10,20,30) == 15","assert floor_Min(1,2,1) == 0","assert floor_Min(11,10,9) == 9"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find minimum possible value for the given periodic function.\n### Function signature: def floor_Min(A,B,N):\n### Tests: assert floor_Min(10,20,30) == 15\n assert floor_Min(1,2,1) == 0\n### Response: "} +{"task_id":610,"text":"Write a python function to remove the k'th element from a given list.","code":"def remove_kth_element(list1, L):\r\n return list1[:L-1] + list1[L:]","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to remove the k'th element from a given list.\n### Function signature: def remove_kth_element(list1, L):\n### Tests: assert remove_kth_element([1,1,2,3,4,4,5,1],3)==[1, 1, 3, 4, 4, 5, 1]\n 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]\n### Response: "} +{"task_id":611,"text":"Write a function to find the maximum of nth column from the given tuple list.","code":"def max_of_nth(test_list, N):\r\n res = max([sub[N] for sub in test_list])\r\n return (res) ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the maximum of nth column from the given tuple list.\n### Function signature: def max_of_nth(test_list, N):\n### Tests: assert max_of_nth([(5, 6, 7), (1, 3, 5), (8, 9, 19)], 2) == 19\n assert max_of_nth([(6, 7, 8), (2, 4, 6), (9, 10, 20)], 1) == 10\n### Response: "} +{"task_id":612,"text":"Write a python function to merge the first and last elements separately in a list of lists.","code":"def merge(lst): \r\n return [list(ele) for ele in list(zip(*lst))] ","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']]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to merge the first and last elements separately in a list of lists.\n### Function signature: def merge(lst):\n### Tests: assert merge([['x', 'y'], ['a', 'b'], ['m', 'n']]) == [['x', 'a', 'm'], ['y', 'b', 'n']]\n assert merge([[1, 2], [3, 4], [5, 6], [7, 8]]) == [[1, 3, 5, 7], [2, 4, 6, 8]]\n### Response: "} +{"task_id":613,"text":"Write a function to find the maximum value in record list as tuple attribute in the given tuple list.","code":"def maximum_value(test_list):\r\n res = [(key, max(lst)) for key, lst in test_list]\r\n return (res) ","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)]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the maximum value in record list as tuple attribute in the given tuple list.\n### Function signature: def maximum_value(test_list):\n### Tests: assert maximum_value([('key1', [3, 4, 5]), ('key2', [1, 4, 2]), ('key3', [9, 3])]) == [('key1', 5), ('key2', 4), ('key3', 9)]\n assert maximum_value([('key1', [4, 5, 6]), ('key2', [2, 5, 3]), ('key3', [10, 4])]) == [('key1', 6), ('key2', 5), ('key3', 10)]\n### Response: "} +{"task_id":614,"text":"Write a function to find the cumulative sum of all the values that are present in the given tuple list.","code":"def cummulative_sum(test_list):\r\n res = sum(map(sum, test_list))\r\n return (res)","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the cumulative sum of all the values that are present in the given tuple list.\n### Function signature: def cummulative_sum(test_list):\n### Tests: assert cummulative_sum([(1, 3), (5, 6, 7), (2, 6)]) == 30\n assert cummulative_sum([(2, 4), (6, 7, 8), (3, 7)]) == 37\n### Response: "} +{"task_id":615,"text":"Write a function to find average value of the numbers in a given tuple of tuples.","code":"def average_tuple(nums):\r\n result = [sum(x) \/ len(x) for x in zip(*nums)]\r\n return result","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find average value of the numbers in a given tuple of tuples.\n### Function signature: def average_tuple(nums):\n### Tests: assert average_tuple(((10, 10, 10, 12), (30, 45, 56, 45), (81, 80, 39, 32), (1, 2, 3, 4)))==[30.5, 34.25, 27.0, 23.25]\n assert average_tuple(((1, 1, -5), (30, -15, 56), (81, -60, -39), (-10, 2, 3)))== [25.5, -18.0, 3.75]\n### Response: "} +{"task_id":616,"text":"Write a function to perfom the modulo of tuple elements in the given two tuples.","code":"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) ","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)"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to perfom the modulo of tuple elements in the given two tuples.\n### Function signature: def tuple_modulo(test_tup1, test_tup2):\n### Tests: assert tuple_modulo((10, 4, 5, 6), (5, 6, 7, 5)) == (0, 4, 5, 1)\n assert tuple_modulo((11, 5, 6, 7), (6, 7, 8, 6)) == (5, 5, 6, 1)\n### Response: "} +{"task_id":617,"text":"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.","code":"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","test_list":["assert min_Jumps(3,4,11)==3.5","assert min_Jumps(3,4,0)==0","assert min_Jumps(11,14,11)==1"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: 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.\n### Function signature: def min_Jumps(a, b, d):\n### Tests: assert min_Jumps(3,4,11)==3.5\n assert min_Jumps(3,4,0)==0\n### Response: "} +{"task_id":618,"text":"Write a function to divide two lists using map and lambda function.","code":"def div_list(nums1,nums2):\r\n result = map(lambda x, y: x \/ y, nums1, nums2)\r\n return list(result)","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to divide two lists using map and lambda function.\n### Function signature: def div_list(nums1,nums2):\n### Tests: assert div_list([4,5,6],[1, 2, 3])==[4.0,2.5,2.0]\n assert div_list([3,2],[1,4])==[3.0, 0.5]\n### Response: "} +{"task_id":619,"text":"Write a function to move all the numbers in it to the given string.","code":"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) ","test_list":["assert move_num('I1love143you55three3000thousand') == 'Iloveyouthreethousand1143553000'","assert move_num('Avengers124Assemble') == 'AvengersAssemble124'","assert move_num('Its11our12path13to14see15things16do17things') == 'Itsourpathtoseethingsdothings11121314151617'"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to move all the numbers in it to the given string.\n### Function signature: def move_num(test_str):\n### Tests: assert move_num('I1love143you55three3000thousand') == 'Iloveyouthreethousand1143553000'\n assert move_num('Avengers124Assemble') == 'AvengersAssemble124'\n### Response: "} +{"task_id":620,"text":"Write a function to find the largest subset where each pair is divisible.","code":"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)","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the largest subset where each pair is divisible.\n### Function signature: def largest_subset(a, n):\n### Tests: assert largest_subset([ 1, 3, 6, 13, 17, 18 ], 6) == 4\n assert largest_subset([10, 5, 3, 15, 20], 5) == 3\n### Response: "} +{"task_id":621,"text":"Write a function to increment the numeric values in the given strings by k.","code":"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 ","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']"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to increment the numeric values in the given strings by k.\n### Function signature: def increment_numerics(test_list, K):\n### Tests: assert increment_numerics([\"MSM\", \"234\", \"is\", \"98\", \"123\", \"best\", \"4\"] , 6) == ['MSM', '240', 'is', '104', '129', 'best', '10']\n assert increment_numerics([\"Dart\", \"356\", \"is\", \"88\", \"169\", \"Super\", \"6\"] , 12) == ['Dart', '368', 'is', '100', '181', 'Super', '18']\n### Response: "} +{"task_id":622,"text":"Write a function to find the median of two sorted arrays of same size.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the median of two sorted arrays of same size.\n### Function signature: def get_median(arr1, arr2, n):\n### Tests: assert get_median([1, 12, 15, 26, 38], [2, 13, 17, 30, 45], 5) == 16.0\n assert get_median([2, 4, 8, 9], [7, 13, 19, 28], 4) == 8.5\n### Response: "} +{"task_id":623,"text":"Write a function to find the n-th power of individual elements in a list using lambda function.","code":"def nth_nums(nums,n):\r\n nth_nums = list(map(lambda x: x ** n, nums))\r\n return nth_nums","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])"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the n-th power of individual elements in a list using lambda function.\n### Function signature: def nth_nums(nums,n):\n### Tests: assert nth_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],2)==[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]\n assert nth_nums([10,20,30],3)==([1000, 8000, 27000])\n### Response: "} +{"task_id":624,"text":"Write a python function to convert the given string to upper case.","code":"def is_upper(string):\r\n return (string.upper())","test_list":["assert is_upper(\"person\") ==\"PERSON\"","assert is_upper(\"final\") == \"FINAL\"","assert is_upper(\"Valid\") == \"VALID\""],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to convert the given string to upper case.\n### Function signature: def is_upper(string):\n### Tests: assert is_upper(\"person\") ==\"PERSON\"\n assert is_upper(\"final\") == \"FINAL\"\n### Response: "} +{"task_id":625,"text":"Write a python function to interchange first and last elements in a given list.","code":"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 ","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to interchange first and last elements in a given list.\n### Function signature: def swap_List(newList):\n### Tests: assert swap_List([1,2,3]) == [3,2,1]\n assert swap_List([1,2,3,4,4]) == [4,2,3,4,1]\n### Response: "} +{"task_id":626,"text":"Write a python function to find the largest triangle that can be inscribed in the semicircle.","code":"def triangle_area(r) : \r\n if r < 0 : \r\n return -1\r\n return r * r ","test_list":["assert triangle_area(0) == 0","assert triangle_area(-1) == -1","assert triangle_area(2) == 4"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the largest triangle that can be inscribed in the semicircle.\n### Function signature: def triangle_area(r) :\n### Tests: assert triangle_area(0) == 0\n assert triangle_area(-1) == -1\n### Response: "} +{"task_id":627,"text":"Write a python function to find the smallest missing number from the given array.","code":"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) ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the smallest missing number from the given array.\n### Function signature: def find_First_Missing(array,start,end):\n### Tests: assert find_First_Missing([0,1,2,3],0,3) == 4\n assert find_First_Missing([0,1,2,6,9],0,4) == 3\n### Response: "} +{"task_id":628,"text":"Write a function to replace all spaces in the given string with character * list item * list item * list item * list item '%20'.","code":"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)","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'"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to replace all spaces in the given string with character * list item * list item * list item * list item '%20'.\n### Function signature: def replace_spaces(string):\n### Tests: assert replace_spaces(\"My Name is Dawood\") == 'My%20Name%20is%20Dawood'\n assert replace_spaces(\"I am a Programmer\") == 'I%20am%20a%20Programmer'\n### Response: "} +{"task_id":629,"text":"Write a python function to find even numbers from a mixed list.","code":"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","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find even numbers from a mixed list.\n### Function signature: def Split(list):\n### Tests: assert Split([1,2,3,4,5]) == [2,4]\n assert Split([4,5,6,7,8,0,1]) == [4,6,8,0]\n### Response: "} +{"task_id":630,"text":"Write a function to extract all the adjacent coordinates of the given coordinate tuple.","code":"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) ","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]]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to extract all the adjacent coordinates of the given coordinate tuple.\n### Function signature: def get_coordinates(test_tup):\n### Tests: assert get_coordinates((3, 4)) == [[2, 3], [2, 4], [2, 5], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5]]\n assert get_coordinates((4, 5)) ==[[3, 4], [3, 5], [3, 6], [4, 4], [4, 5], [4, 6], [5, 4], [5, 5], [5, 6]]\n### Response: "} +{"task_id":631,"text":"Write a function to replace whitespaces with an underscore and vice versa in a given string by using regex.","code":"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)","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'"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to replace whitespaces with an underscore and vice versa in a given string by using regex.\n### Function signature: def replace_spaces(text):\n### Tests: assert replace_spaces('Jumanji The Jungle') == 'Jumanji_The_Jungle'\n assert replace_spaces('The Avengers') == 'The_Avengers'\n### Response: "} +{"task_id":632,"text":"Write a python function to move all zeroes to the end of the given list.","code":"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)","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to move all zeroes to the end of the given list.\n### Function signature: def move_zero(num_list):\n### Tests: assert move_zero([1,0,2,0,3,4]) == [1,2,3,4,0,0]\n assert move_zero([2,3,2,0,0,4,0,5,0]) == [2,3,2,4,5,0,0,0,0]\n### Response: "} +{"task_id":633,"text":"Write a python function to find the sum of xor of all pairs of numbers in the given array.","code":"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 ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the sum of xor of all pairs of numbers in the given array.\n### Function signature: def pair_OR_Sum(arr,n) :\n### Tests: assert pair_OR_Sum([5,9,7,6],4) == 47\n assert pair_OR_Sum([7,3,5],3) == 12\n### Response: "} +{"task_id":634,"text":"Write a python function to find the sum of fourth power of first n even natural numbers.","code":"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; ","test_list":["assert even_Power_Sum(2) == 272","assert even_Power_Sum(3) == 1568","assert even_Power_Sum(4) == 5664"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the sum of fourth power of first n even natural numbers.\n### Function signature: def even_Power_Sum(n):\n### Tests: assert even_Power_Sum(2) == 272\n assert even_Power_Sum(3) == 1568\n### Response: "} +{"task_id":635,"text":"Write a function to push all values into a heap and then pop off the smallest values one at a time.","code":"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))]","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to push all values into a heap and then pop off the smallest values one at a time.\n### Function signature: def heap_sort(iterable):\n### Tests: assert heap_sort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert heap_sort([25, 35, 22, 85, 14, 65, 75, 25, 58])==[14, 22, 25, 25, 35, 58, 65, 75, 85]\n### Response: "} +{"task_id":636,"text":"Write a python function to check if roots of a quadratic equation are reciprocal of each other or not.","code":"def Check_Solution(a,b,c): \r\n if (a == c): \r\n return (\"Yes\"); \r\n else: \r\n return (\"No\"); ","test_list":["assert Check_Solution(2,0,2) == \"Yes\"","assert Check_Solution(2,-5,2) == \"Yes\"","assert Check_Solution(1,2,3) == \"No\""],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check if roots of a quadratic equation are reciprocal of each other or not.\n### Function signature: def Check_Solution(a,b,c):\n### Tests: assert Check_Solution(2,0,2) == \"Yes\"\n assert Check_Solution(2,-5,2) == \"Yes\"\n### Response: "} +{"task_id":637,"text":"Write a function to check whether the given amount has no profit and no loss","code":"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","test_list":["assert noprofit_noloss(1500,1200)==False","assert noprofit_noloss(100,100)==True","assert noprofit_noloss(2000,5000)==False"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check whether the given amount has no profit and no loss\n### Function signature: def noprofit_noloss(actual_cost,sale_amount):\n### Tests: assert noprofit_noloss(1500,1200)==False\n assert noprofit_noloss(100,100)==True\n### Response: "} +{"task_id":638,"text":"Write a function to calculate wind chill index.","code":"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))","test_list":["assert wind_chill(120,35)==40","assert wind_chill(40,70)==86","assert wind_chill(10,100)==116"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to calculate wind chill index.\n### Function signature: def wind_chill(v,t):\n### Tests: assert wind_chill(120,35)==40\n assert wind_chill(40,70)==86\n### Response: "} +{"task_id":639,"text":"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.","code":"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))","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: 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.\n### Function signature: def sample_nam(sample_names):\n### Tests: assert sample_nam(['sally', 'Dylan', 'rebecca', 'Diana', 'Joanne', 'keith'])==16\n assert sample_nam([\"php\", \"res\", \"Python\", \"abcd\", \"Java\", \"aaa\"])==10\n### Response: "} +{"task_id":640,"text":"Write a function to remove the parenthesis area in a string.","code":"import re\r\ndef remove_parenthesis(items):\r\n for item in items:\r\n return (re.sub(r\" ?\\([^)]+\\)\", \"\", item))","test_list":["assert remove_parenthesis([\"python (chrome)\"])==(\"python\")","assert remove_parenthesis([\"string(.abc)\"])==(\"string\")","assert remove_parenthesis([\"alpha(num)\"])==(\"alpha\")"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to remove the parenthesis area in a string.\n### Function signature: def remove_parenthesis(items):\n### Tests: assert remove_parenthesis([\"python (chrome)\"])==(\"python\")\n assert remove_parenthesis([\"string(.abc)\"])==(\"string\")\n### Response: "} +{"task_id":641,"text":"Write a function to find the nth nonagonal number.","code":"def is_nonagonal(n): \r\n\treturn int(n * (7 * n - 5) \/ 2) ","test_list":["assert is_nonagonal(10) == 325","assert is_nonagonal(15) == 750","assert is_nonagonal(18) == 1089"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the nth nonagonal number.\n### Function signature: def is_nonagonal(n):\n### Tests: assert is_nonagonal(10) == 325\n assert is_nonagonal(15) == 750\n### Response: "} +{"task_id":642,"text":"Write a function to remove similar rows from the given tuple matrix.","code":"def remove_similar_row(test_list):\r\n res = set(sorted([tuple(sorted(set(sub))) for sub in test_list]))\r\n return (res) ","test_list":["assert remove_similar_row([[(4, 5), (3, 2)], [(2, 2), (4, 6)], [(3, 2), (4, 5)]] ) == {((2, 2), (4, 6)), ((3, 2), (4, 5))}","assert remove_similar_row([[(5, 6), (4, 3)], [(3, 3), (5, 7)], [(4, 3), (5, 6)]] ) == {((4, 3), (5, 6)), ((3, 3), (5, 7))}","assert remove_similar_row([[(6, 7), (5, 4)], [(4, 4), (6, 8)], [(5, 4), (6, 7)]] ) =={((4, 4), (6, 8)), ((5, 4), (6, 7))}"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to remove similar rows from the given tuple matrix.\n### Function signature: def remove_similar_row(test_list):\n### Tests: assert remove_similar_row([[(4, 5), (3, 2)], [(2, 2), (4, 6)], [(3, 2), (4, 5)]] ) == {((2, 2), (4, 6)), ((3, 2), (4, 5))}\n assert remove_similar_row([[(5, 6), (4, 3)], [(3, 3), (5, 7)], [(4, 3), (5, 6)]] ) == {((4, 3), (5, 6)), ((3, 3), (5, 7))}\n### Response: "} +{"task_id":643,"text":"Write a function that matches a word containing 'z', not at the start or end of the word.","code":"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!')","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!')"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function that matches a word containing 'z', not at the start or end of the word.\n### Function signature: def text_match_wordz_middle(text):\n### Tests: assert text_match_wordz_middle(\"pythonzabc.\")==('Found a match!')\n assert text_match_wordz_middle(\"xyzabc.\")==('Found a match!')\n### Response: "} +{"task_id":644,"text":"Write a python function to reverse an array upto a given position.","code":"def reverse_Array_Upto_K(input, k): \r\n return (input[k-1::-1] + input[k:]) ","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to reverse an array upto a given position.\n### Function signature: def reverse_Array_Upto_K(input, k):\n### Tests: assert reverse_Array_Upto_K([1, 2, 3, 4, 5, 6],4) == [4, 3, 2, 1, 5, 6]\n assert reverse_Array_Upto_K([4, 5, 6, 7], 2) == [5, 4, 6, 7]\n### Response: "} +{"task_id":645,"text":"Write a function to find the product of it\u2019s kth index in the given tuples.","code":"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) ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the product of it\u2019s kth index in the given tuples.\n### Function signature: def find_k_product(test_list, K):\n### Tests: assert find_k_product([(5, 6, 7), (1, 3, 5), (8, 9, 19)], 2) == 665\n assert find_k_product([(6, 7, 8), (2, 4, 6), (9, 10, 20)], 1) == 280\n### Response: "} +{"task_id":646,"text":"Write a python function to count number of cubes of size k in a cube of size n.","code":"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","test_list":["assert No_of_cubes(2,1) == 8","assert No_of_cubes(5,2) == 64","assert No_of_cubes(1,1) == 1"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to count number of cubes of size k in a cube of size n.\n### Function signature: def No_of_cubes(N,K):\n### Tests: assert No_of_cubes(2,1) == 8\n assert No_of_cubes(5,2) == 64\n### Response: "} +{"task_id":647,"text":"Write a function to split a string at uppercase letters.","code":"import re\r\ndef split_upperstring(text):\r\n return (re.findall('[A-Z][^A-Z]*', text))","test_list":["assert split_upperstring(\"PythonProgramLanguage\")==['Python','Program','Language']","assert split_upperstring(\"PythonProgram\")==['Python','Program']","assert split_upperstring(\"ProgrammingLanguage\")==['Programming','Language']"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to split a string at uppercase letters.\n### Function signature: def split_upperstring(text):\n### Tests: assert split_upperstring(\"PythonProgramLanguage\")==['Python','Program','Language']\n assert split_upperstring(\"PythonProgram\")==['Python','Program']\n### Response: "} +{"task_id":648,"text":"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.","code":"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])))","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] "],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: 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.\n### Function signature: def exchange_elements(lst):\n### Tests: assert exchange_elements([0,1,2,3,4,5])==[1, 0, 3, 2, 5, 4] \n assert exchange_elements([5,6,7,8,9,10])==[6,5,8,7,10,9] \n### Response: "} +{"task_id":649,"text":"Write a python function to calculate the sum of the numbers in a list between the indices of a specified range.","code":"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 ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to calculate the sum of the numbers in a list between the indices of a specified range.\n### Function signature: def sum_Range_list(nums, m, n):\n### Tests: assert sum_Range_list([2, 1, 5, 6, 8, 3, 4, 9, 10, 11, 8, 12],8,10) == 29\n assert sum_Range_list([1,2,3,4,5],1,2) == 5\n### Response: "} +{"task_id":650,"text":"Write a python function to check whether the given two arrays are equal or not.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check whether the given two arrays are equal or not.\n### Function signature: def are_Equal(arr1,arr2,n,m):\n### Tests: assert are_Equal([1,2,3],[3,2,1],3,3) == True\n assert are_Equal([1,1,1],[2,2,2],3,3) == False\n### Response: "} +{"task_id":651,"text":"Write a function to check if one tuple is a subset of another tuple.","code":"def check_subset(test_tup1, test_tup2):\r\n res = set(test_tup2).issubset(test_tup1)\r\n return (res) ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check if one tuple is a subset of another tuple.\n### Function signature: def check_subset(test_tup1, test_tup2):\n### Tests: assert check_subset((10, 4, 5, 6), (5, 10)) == True\n assert check_subset((1, 2, 3, 4), (5, 6)) == False\n### Response: "} +{"task_id":652,"text":"Write a function to flatten the given tuple matrix into the tuple list with each tuple representing each column.","code":"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))","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)]'"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to flatten the given tuple matrix into the tuple list with each tuple representing each column.\n### Function signature: def matrix_to_list(test_list):\n### Tests: 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)]'\n 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)]'\n### Response: "} +{"task_id":653,"text":"Write a function to group a sequence of key-value pairs into a dictionary of lists using collections module.","code":"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","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]})"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to group a sequence of key-value pairs into a dictionary of lists using collections module.\n### Function signature: def grouping_dictionary(l):\n### Tests: assert grouping_dictionary([('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)])== ({'yellow': [1, 3], 'blue': [2, 4], 'red': [1]})\n assert grouping_dictionary([('yellow', 10), ('blue', 20), ('yellow', 30), ('blue', 40), ('red', 10)])== ({'yellow': [10, 30], 'blue': [20, 40], 'red': [10]})\n### Response: "} +{"task_id":654,"text":"Write a function to find the perimeter of a rectangle.","code":"def rectangle_perimeter(l,b):\r\n perimeter=2*(l+b)\r\n return perimeter","test_list":["assert rectangle_perimeter(10,20)==60","assert rectangle_perimeter(10,5)==30","assert rectangle_perimeter(4,2)==12"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the perimeter of a rectangle.\n### Function signature: def rectangle_perimeter(l,b):\n### Tests: assert rectangle_perimeter(10,20)==60\n assert rectangle_perimeter(10,5)==30\n### Response: "} +{"task_id":655,"text":"Write a python function to find the sum of fifth power of n natural numbers.","code":"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 ","test_list":["assert fifth_Power_Sum(2) == 33","assert fifth_Power_Sum(4) == 1300","assert fifth_Power_Sum(3) == 276"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the sum of fifth power of n natural numbers.\n### Function signature: def fifth_Power_Sum(n) :\n### Tests: assert fifth_Power_Sum(2) == 33\n assert fifth_Power_Sum(4) == 1300\n### Response: "} +{"task_id":656,"text":"Write a python function to find the minimum sum of absolute differences of two arrays.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the minimum sum of absolute differences of two arrays.\n### Function signature: def find_Min_Sum(a,b,n):\n### Tests: assert find_Min_Sum([3,2,1],[2,1,3],3) == 0\n assert find_Min_Sum([1,2,3],[4,5,6],3) == 9\n### Response: "} +{"task_id":657,"text":"Write a python function to find the first digit in factorial of a given number.","code":"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) ","test_list":["assert first_Digit(5) == 1","assert first_Digit(10) == 3","assert first_Digit(7) == 5"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the first digit in factorial of a given number.\n### Function signature: def first_Digit(n) :\n### Tests: assert first_Digit(5) == 1\n assert first_Digit(10) == 3\n### Response: "} +{"task_id":658,"text":"Write a function to find the item with maximum occurrences in a given list.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the item with maximum occurrences in a given list.\n### Function signature: def max_occurrences(list1):\n### Tests: assert max_occurrences([2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,4,6,9,1,2])==2\n assert max_occurrences([1, 3,5, 7,1, 3,13, 15, 17,5, 7,9,1, 11])==1\n### Response: "} +{"task_id":659,"text":"Write a python function to print duplicants from a list of integers.","code":"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 ","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to print duplicants from a list of integers.\n### Function signature: def Repeat(x):\n### Tests: assert Repeat([10, 20, 30, 20, 20, 30, 40, 50, -20, 60, 60, -20, -20]) == [20, 30, -20, 60]\n assert Repeat([-1, 1, -1, 8]) == [-1]\n### Response: "} +{"task_id":660,"text":"Write a python function to choose points from two ranges such that no point lies in both the ranges.","code":"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)","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)"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to choose points from two ranges such that no point lies in both the ranges.\n### Function signature: def find_Points(l1,r1,l2,r2):\n### Tests: assert find_Points(5,10,1,5) == (1,10)\n assert find_Points(3,5,7,9) == (3,9)\n### Response: "} +{"task_id":661,"text":"Write a function to find the maximum sum that can be formed which has no three consecutive elements present.","code":"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]","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the maximum sum that can be formed which has no three consecutive elements present.\n### Function signature: def max_sum_of_three_consecutive(arr, n):\n### Tests: assert max_sum_of_three_consecutive([100, 1000, 100, 1000, 1], 5) == 2101\n assert max_sum_of_three_consecutive([3000, 2000, 1000, 3, 10], 5) == 5013\n### Response: "} +{"task_id":662,"text":"Write a function to sort a list in a dictionary.","code":"def sorted_dict(dict1):\r\n sorted_dict = {x: sorted(y) for x, y in dict1.items()}\r\n return sorted_dict","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]}"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to sort a list in a dictionary.\n### Function signature: def sorted_dict(dict1):\n### Tests: 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]}\n 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]}\n### Response: "} +{"task_id":663,"text":"Write a function to find the largest possible value of k such that k modulo x is y.","code":"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) ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the largest possible value of k such that k modulo x is y.\n### Function signature: def find_max_val(n, x, y):\n### Tests: assert find_max_val(15, 10, 5) == 15\n assert find_max_val(187, 10, 5) == 185\n### Response: "} +{"task_id":664,"text":"Write a python function to find the average of even numbers till a given even number.","code":"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 ","test_list":["assert average_Even(2) == 2","assert average_Even(4) == 3","assert average_Even(100) == 51"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the average of even numbers till a given even number.\n### Function signature: def average_Even(n) :\n### Tests: assert average_Even(2) == 2\n assert average_Even(4) == 3\n### Response: "} +{"task_id":665,"text":"Write a python function to shift first element to the end of given list.","code":"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)","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to shift first element to the end of given list.\n### Function signature: def move_last(num_list):\n### Tests: assert move_last([1,2,3,4]) == [2,3,4,1]\n assert move_last([2,3,4,1,5,0]) == [3,4,1,5,0,2]\n### Response: "} +{"task_id":666,"text":"Write a function to count occurrence of a character in a string.","code":"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","test_list":["assert count_char(\"Python\",'o')==1","assert count_char(\"little\",'t')==2","assert count_char(\"assert\",'s')==2"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to count occurrence of a character in a string.\n### Function signature: def count_char(string,char):\n### Tests: assert count_char(\"Python\",'o')==1\n assert count_char(\"little\",'t')==2\n### Response: "} +{"task_id":667,"text":"Write a python function to count number of vowels in the string.","code":"def Check_Vow(string, vowels): \r\n final = [each for each in string if each in vowels] \r\n return(len(final)) \r\n","test_list":["assert Check_Vow('corner','AaEeIiOoUu') == 2","assert Check_Vow('valid','AaEeIiOoUu') == 2","assert Check_Vow('true','AaEeIiOoUu') ==2"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to count number of vowels in the string.\n### Function signature: def Check_Vow(string, vowels):\n### Tests: assert Check_Vow('corner','AaEeIiOoUu') == 2\n assert Check_Vow('valid','AaEeIiOoUu') == 2\n### Response: "} +{"task_id":668,"text":"Write a python function to replace multiple occurence of character by single.","code":"import re \r\ndef replace(string, char): \r\n pattern = char + '{2,}'\r\n string = re.sub(pattern, char, string) \r\n return string ","test_list":["assert replace('peep','e') == 'pep'","assert replace('Greek','e') == 'Grek'","assert replace('Moon','o') == 'Mon'"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to replace multiple occurence of character by single.\n### Function signature: def replace(string, char):\n### Tests: assert replace('peep','e') == 'pep'\n assert replace('Greek','e') == 'Grek'\n### Response: "} +{"task_id":669,"text":"Write a function to check whether the given ip address is valid or not using regex.","code":"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\") ","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'"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check whether the given ip address is valid or not using regex.\n### Function signature: def check_IP(Ip):\n### Tests: assert check_IP(\"192.168.0.1\") == 'Valid IP address'\n assert check_IP(\"110.234.52.124\") == 'Valid IP address'\n### Response: "} +{"task_id":670,"text":"Write a python function to check whether a sequence of numbers has a decreasing trend or not.","code":"def decreasing_trend(nums):\r\n if (sorted(nums)== nums):\r\n return True\r\n else:\r\n return False","test_list":["assert decreasing_trend([-4,-3,-2,-1]) == True","assert decreasing_trend([1,2,3]) == True","assert decreasing_trend([3,2,1]) == False"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check whether a sequence of numbers has a decreasing trend or not.\n### Function signature: def decreasing_trend(nums):\n### Tests: assert decreasing_trend([-4,-3,-2,-1]) == True\n assert decreasing_trend([1,2,3]) == True\n### Response: "} +{"task_id":671,"text":"Write a python function to set the right most unset bit.","code":"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) ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to set the right most unset bit.\n### Function signature: def set_Right_most_Unset_Bit(n):\n### Tests: assert set_Right_most_Unset_Bit(21) == 23\n assert set_Right_most_Unset_Bit(11) == 15\n### Response: "} +{"task_id":672,"text":"Write a function to find maximum of three numbers.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find maximum of three numbers.\n### Function signature: def max_of_three(num1,num2,num3):\n### Tests: assert max_of_three(10,20,30)==30\n assert max_of_three(55,47,39)==55\n### Response: "} +{"task_id":673,"text":"Write a python function to convert a list of multiple integers into a single integer.","code":"def convert(list): \r\n s = [str(i) for i in list] \r\n res = int(\"\".join(s)) \r\n return (res) ","test_list":["assert convert([1,2,3]) == 123","assert convert([4,5,6]) == 456","assert convert([7,8,9]) == 789"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to convert a list of multiple integers into a single integer.\n### Function signature: def convert(list):\n### Tests: assert convert([1,2,3]) == 123\n assert convert([4,5,6]) == 456\n### Response: "} +{"task_id":674,"text":"Write a function to remove duplicate words from a given string using collections module.","code":"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","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\")"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to remove duplicate words from a given string using collections module.\n### Function signature: def remove_duplicate(string):\n### Tests: assert remove_duplicate(\"Python Exercises Practice Solution Exercises\")==(\"Python Exercises Practice Solution\")\n assert remove_duplicate(\"Python Exercises Practice Solution Python\")==(\"Python Exercises Practice Solution\")\n### Response: "} +{"task_id":675,"text":"Write a function to add two integers. however, if the sum is between the given range it will return 20.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to add two integers. however, if the sum is between the given range it will return 20.\n### Function signature: def sum_nums(x, y,m,n):\n### Tests: assert sum_nums(2,10,11,20)==20\n assert sum_nums(15,17,1,10)==32\n### Response: "} +{"task_id":676,"text":"Write a function to remove everything except alphanumeric characters from the given string by using regex.","code":"import re\r\ndef remove_extra_char(text1):\r\n pattern = re.compile('[\\W_]+')\r\n return (pattern.sub('', text1))","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'"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to remove everything except alphanumeric characters from the given string by using regex.\n### Function signature: def remove_extra_char(text1):\n### Tests: assert remove_extra_char('**\/\/Google Android\/\/ - 12. ') == 'GoogleAndroid12'\n assert remove_extra_char('****\/\/Google Flutter\/\/*** - 36. ') == 'GoogleFlutter36'\n### Response: "} +{"task_id":677,"text":"Write a function to check if the triangle is valid or not.","code":"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","test_list":["assert validity_triangle(60,50,90)==False","assert validity_triangle(45,75,60)==True","assert validity_triangle(30,50,100)==True"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check if the triangle is valid or not.\n### Function signature: def validity_triangle(a,b,c):\n### Tests: assert validity_triangle(60,50,90)==False\n assert validity_triangle(45,75,60)==True\n### Response: "} +{"task_id":678,"text":"Write a python function to remove spaces from a given string.","code":"def remove_spaces(str1):\r\n str1 = str1.replace(' ','')\r\n return str1","test_list":["assert remove_spaces(\"a b c\") == \"abc\"","assert remove_spaces(\"1 2 3\") == \"123\"","assert remove_spaces(\" b c\") == \"bc\""],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to remove spaces from a given string.\n### Function signature: def remove_spaces(str1):\n### Tests: assert remove_spaces(\"a b c\") == \"abc\"\n assert remove_spaces(\"1 2 3\") == \"123\"\n### Response: "} +{"task_id":679,"text":"Write a function to access dictionary key\u2019s element by index.","code":"def access_key(ditionary,key):\r\n return list(ditionary)[key]","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'"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to access dictionary key\u2019s element by index.\n### Function signature: def access_key(ditionary,key):\n### Tests: assert access_key({'physics': 80, 'math': 90, 'chemistry': 86},0)== 'physics'\n assert access_key({'python':10, 'java': 20, 'C++':30},2)== 'C++'\n### Response: "} +{"task_id":680,"text":"Write a python function to check whether a sequence of numbers has an increasing trend or not.","code":"def increasing_trend(nums):\r\n if (sorted(nums)== nums):\r\n return True\r\n else:\r\n return False","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check whether a sequence of numbers has an increasing trend or not.\n### Function signature: def increasing_trend(nums):\n### Tests: assert increasing_trend([1,2,3,4]) == True\n assert increasing_trend([4,3,2,1]) == False\n### Response: "} +{"task_id":681,"text":"Write a python function to find the smallest prime divisor of a number.","code":"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; ","test_list":["assert smallest_Divisor(10) == 2","assert smallest_Divisor(25) == 5","assert smallest_Divisor(31) == 31"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the smallest prime divisor of a number.\n### Function signature: def smallest_Divisor(n):\n### Tests: assert smallest_Divisor(10) == 2\n assert smallest_Divisor(25) == 5\n### Response: "} +{"task_id":682,"text":"Write a function to multiply two lists using map and lambda function.","code":"def mul_list(nums1,nums2):\r\n result = map(lambda x, y: x * y, nums1, nums2)\r\n return list(result)","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to multiply two lists using map and lambda function.\n### Function signature: def mul_list(nums1,nums2):\n### Tests: assert mul_list([1, 2, 3],[4,5,6])==[4,10,18]\n assert mul_list([1,2],[3,4])==[3,8]\n### Response: "} +{"task_id":683,"text":"Write a python function to check whether the given number can be represented by sum of two squares or not.","code":"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","test_list":["assert sum_Square(25) == True","assert sum_Square(24) == False","assert sum_Square(17) == True"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check whether the given number can be represented by sum of two squares or not.\n### Function signature: def sum_Square(n) :\n### Tests: assert sum_Square(25) == True\n assert sum_Square(24) == False\n### Response: "} +{"task_id":684,"text":"Write a python function to count occurences of a character in a repeated string.","code":"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 ","test_list":["assert count_Char(\"abcac\",'a') == 4","assert count_Char(\"abca\",'c') == 2","assert count_Char(\"aba\",'a') == 7"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to count occurences of a character in a repeated string.\n### Function signature: def count_Char(str,x):\n### Tests: assert count_Char(\"abcac\",'a') == 4\n assert count_Char(\"abca\",'c') == 2\n### Response: "} +{"task_id":685,"text":"Write a python function to find sum of prime numbers between 1 to n.","code":"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","test_list":["assert sum_Of_Primes(10) == 17","assert sum_Of_Primes(20) == 77","assert sum_Of_Primes(5) == 10"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find sum of prime numbers between 1 to n.\n### Function signature: def sum_Of_Primes(n):\n### Tests: assert sum_Of_Primes(10) == 17\n assert sum_Of_Primes(20) == 77\n### Response: "} +{"task_id":686,"text":"Write a function to find the frequency of each element in the given list.","code":"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))) ","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}'"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the frequency of each element in the given list.\n### Function signature: def freq_element(test_tup):\n### Tests: assert freq_element((4, 5, 4, 5, 6, 6, 5, 5, 4) ) == '{4: 3, 5: 4, 6: 2}'\n assert freq_element((7, 8, 8, 9, 4, 7, 6, 5, 4) ) == '{7: 2, 8: 2, 9: 1, 4: 2, 6: 1, 5: 1}'\n### Response: "} +{"task_id":687,"text":"Write a function to find the greatest common divisor (gcd) of two integers by using recursion.","code":"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)","test_list":["assert recur_gcd(12,14) == 2","assert recur_gcd(13,17) == 1","assert recur_gcd(9, 3) == 3"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the greatest common divisor (gcd) of two integers by using recursion.\n### Function signature: def recur_gcd(a, b):\n### Tests: assert recur_gcd(12,14) == 2\n assert recur_gcd(13,17) == 1\n### Response: "} +{"task_id":688,"text":"Write a function to get the length of a complex number.","code":"import cmath\r\ndef len_complex(a,b):\r\n cn=complex(a,b)\r\n length=abs(cn)\r\n return length","test_list":["assert len_complex(3,4)==5.0","assert len_complex(9,10)==13.45362404707371","assert len_complex(7,9)==11.40175425099138"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to get the length of a complex number.\n### Function signature: def len_complex(a,b):\n### Tests: assert len_complex(3,4)==5.0\n assert len_complex(9,10)==13.45362404707371\n### Response: "} +{"task_id":689,"text":"## 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","code":"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]","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: ## 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\n### Function signature: def min_jumps(arr, n):\n### Tests: assert min_jumps([1, 3, 6, 1, 0, 9], 6) == 3\n assert min_jumps([1, 3, 5, 8, 9, 2, 6, 7, 6, 8, 9], 11) == 3\n### Response: "} +{"task_id":690,"text":"Write a function to multiply consecutive numbers of a given list.","code":"def mul_consecutive_nums(nums):\r\n result = [b*a for a, b in zip(nums[:-1], nums[1:])]\r\n return result","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to multiply consecutive numbers of a given list.\n### Function signature: def mul_consecutive_nums(nums):\n### Tests: assert mul_consecutive_nums([1, 1, 3, 4, 4, 5, 6, 7])==[1, 3, 12, 16, 20, 30, 42]\n assert mul_consecutive_nums([4, 5, 8, 9, 6, 10])==[20, 40, 72, 54, 60]\n### Response: "} +{"task_id":691,"text":"Write a function to group the 1st elements on the basis of 2nd elements in the given tuple list.","code":"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","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]}"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to group the 1st elements on the basis of 2nd elements in the given tuple list.\n### Function signature: def group_element(test_list):\n### Tests: assert group_element([(6, 5), (2, 7), (2, 5), (8, 7), (9, 8), (3, 7)]) == {5: [6, 2], 7: [2, 8, 3], 8: [9]}\n assert group_element([(7, 6), (3, 8), (3, 6), (9, 8), (10, 9), (4, 8)]) == {6: [7, 3], 8: [3, 9, 4], 9: [10]}\n### Response: "} +{"task_id":692,"text":"Write a python function to find the last two digits in factorial of a given number.","code":"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) ","test_list":["assert last_Two_Digits(7) == 40","assert last_Two_Digits(5) == 20","assert last_Two_Digits(2) == 2"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the last two digits in factorial of a given number.\n### Function signature: def last_Two_Digits(N):\n### Tests: assert last_Two_Digits(7) == 40\n assert last_Two_Digits(5) == 20\n### Response: "} +{"task_id":693,"text":"Write a function to remove multiple spaces in a string by using regex.","code":"import re\r\ndef remove_multiple_spaces(text1):\r\n return (re.sub(' +',' ',text1))","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'"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to remove multiple spaces in a string by using regex.\n### Function signature: def remove_multiple_spaces(text1):\n### Tests: assert remove_multiple_spaces('Google Assistant') == 'Google Assistant'\n assert remove_multiple_spaces('Quad Core') == 'Quad Core'\n### Response: "} +{"task_id":694,"text":"Write a function to extract unique values from the given dictionary values.","code":"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","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to extract unique values from the given dictionary values.\n### Function signature: def extract_unique(test_dict):\n### Tests: 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]\n 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]\n### Response: "} +{"task_id":695,"text":"Write a function to check if each element of the second tuple is greater than its corresponding index in the first tuple.","code":"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) ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check if each element of the second tuple is greater than its corresponding index in the first tuple.\n### Function signature: def check_greater(test_tup1, test_tup2):\n### Tests: assert check_greater((10, 4, 5), (13, 5, 18)) == True\n assert check_greater((1, 2, 3), (2, 1, 4)) == False\n### Response: "} +{"task_id":696,"text":"Write a function to zip two given lists of lists.","code":"def zip_list(list1,list2): \r\n result = list(map(list.__add__, list1, list2)) \r\n return result","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']]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to zip two given lists of lists.\n### Function signature: def zip_list(list1,list2):\n### Tests: 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]]\n 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]]\n### Response: "} +{"task_id":697,"text":"Write a function to find number of even elements in the given list using lambda function.","code":"def count_even(array_nums):\r\n count_even = len(list(filter(lambda x: (x%2 == 0) , array_nums)))\r\n return count_even","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find number of even elements in the given list using lambda function.\n### Function signature: def count_even(array_nums):\n### Tests: assert count_even([1, 2, 3, 5, 7, 8, 9, 10])==3\n assert count_even([10,15,14,13,-18,12,-20])==5\n### Response: "} +{"task_id":698,"text":"Write a function to sort dictionary items by tuple product of keys for the given dictionary with tuple keys.","code":"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","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}"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to sort dictionary items by tuple product of keys for the given dictionary with tuple keys.\n### Function signature: def sort_dict_item(test_dict):\n### Tests: 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}\n 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}\n### Response: "} +{"task_id":699,"text":"Write a python function to find the minimum number of swaps required to convert one binary string to another.","code":"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\") ","test_list":["assert min_Swaps(\"1101\",\"1110\") == 1","assert min_Swaps(\"1111\",\"0100\") == \"Not Possible\"","assert min_Swaps(\"1110000\",\"0001101\") == 3"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the minimum number of swaps required to convert one binary string to another.\n### Function signature: def min_Swaps(str1,str2) :\n### Tests: assert min_Swaps(\"1101\",\"1110\") == 1\n assert min_Swaps(\"1111\",\"0100\") == \"Not Possible\"\n### Response: "} +{"task_id":700,"text":"Write a function to count the number of elements in a list which are within a specific range.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to count the number of elements in a list which are within a specific range.\n### Function signature: def count_range_in_list(li, min, max):\n### Tests: assert count_range_in_list([10,20,30,40,40,40,70,80,99],40,100)==6\n assert count_range_in_list(['a','b','c','d','e','f'],'a','e')==5\n### Response: "} +{"task_id":701,"text":"Write a function to find the equilibrium index of the given array.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the equilibrium index of the given array.\n### Function signature: def equilibrium_index(arr):\n### Tests: assert equilibrium_index([1, 2, 3, 4, 1, 2, 3]) == 3\n assert equilibrium_index([-7, 1, 5, 2, -4, 3, 0]) == 3\n### Response: "} +{"task_id":702,"text":"Write a function to find the minimum number of elements that should be removed such that amax-amin<=k.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the minimum number of elements that should be removed such that amax-amin<=k.\n### Function signature: def removals(arr, n, k):\n### Tests: assert removals([1, 3, 4, 9, 10,11, 12, 17, 20], 9, 4) == 5\n assert removals([1, 5, 6, 2, 8], 5, 2) == 3\n### Response: "} +{"task_id":703,"text":"Write a function to check whether the given key is present in the dictionary or not.","code":"def is_key_present(d,x):\r\n if x in d:\r\n return True\r\n else:\r\n return False","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check whether the given key is present in the dictionary or not.\n### Function signature: def is_key_present(d,x):\n### Tests: assert is_key_present({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60},5)==True\n assert is_key_present({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60},6)==True\n### Response: "} +{"task_id":704,"text":"Write a function to calculate the harmonic sum of n-1.","code":"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))","test_list":["assert harmonic_sum(10)==2.9289682539682538","assert harmonic_sum(4)==2.083333333333333","assert harmonic_sum(7)==2.5928571428571425 "],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to calculate the harmonic sum of n-1.\n### Function signature: def harmonic_sum(n):\n### Tests: assert harmonic_sum(10)==2.9289682539682538\n assert harmonic_sum(4)==2.083333333333333\n### Response: "} +{"task_id":705,"text":"Write a function to sort a list of lists by length and value.","code":"def sort_sublists(list1):\r\n list1.sort() \r\n list1.sort(key=len)\r\n return list1","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++']]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to sort a list of lists by length and value.\n### Function signature: def sort_sublists(list1):\n### Tests: 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]]\n assert sort_sublists([[1], [2, 3], [4, 5, 6], [7], [10, 11]])==[[1], [7], [2, 3], [10, 11], [4, 5, 6]]\n### Response: "} +{"task_id":706,"text":"Write a function to find whether an array is subset of another array.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find whether an array is subset of another array.\n### Function signature: def is_subset(arr1, m, arr2, n):\n### Tests: assert is_subset([11, 1, 13, 21, 3, 7], 6, [11, 3, 7, 1], 4) == True\n assert is_subset([1, 2, 3, 4, 5, 6], 6, [1, 2, 4], 3) == True\n### Response: "} +{"task_id":707,"text":"Write a python function to count the total set bits from 1 to n.","code":"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; ","test_list":["assert count_Set_Bits(16) == 33","assert count_Set_Bits(2) == 2","assert count_Set_Bits(14) == 28"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to count the total set bits from 1 to n.\n### Function signature: def count_Set_Bits(n) :\n### Tests: assert count_Set_Bits(16) == 33\n assert count_Set_Bits(2) == 2\n### Response: "} +{"task_id":708,"text":"Write a python function to convert a string to a list.","code":"def Convert(string): \r\n li = list(string.split(\" \")) \r\n return li ","test_list":["assert Convert('python program') == ['python','program']","assert Convert('Data Analysis') ==['Data','Analysis']","assert Convert('Hadoop Training') == ['Hadoop','Training']"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to convert a string to a list.\n### Function signature: def Convert(string):\n### Tests: assert Convert('python program') == ['python','program']\n assert Convert('Data Analysis') ==['Data','Analysis']\n### Response: "} +{"task_id":709,"text":"Write a function to count unique keys for each value present in the tuple.","code":"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)) ","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}'"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to count unique keys for each value present in the tuple.\n### Function signature: def get_unique(test_list):\n### Tests: 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}'\n 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}'\n### Response: "} +{"task_id":710,"text":"Write a function to access the initial and last data of the given tuple record.","code":"def front_and_rear(test_tup):\r\n res = (test_tup[0], test_tup[-1])\r\n return (res) ","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)"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to access the initial and last data of the given tuple record.\n### Function signature: def front_and_rear(test_tup):\n### Tests: assert front_and_rear((10, 4, 5, 6, 7)) == (10, 7)\n assert front_and_rear((1, 2, 3, 4, 5)) == (1, 5)\n### Response: "} +{"task_id":711,"text":"Write a python function to check whether the product of digits of a number at even and odd places is equal or not.","code":"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","test_list":["assert product_Equal(2841) == True","assert product_Equal(1234) == False","assert product_Equal(1212) == False"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check whether the product of digits of a number at even and odd places is equal or not.\n### Function signature: def product_Equal(n):\n### Tests: assert product_Equal(2841) == True\n assert product_Equal(1234) == False\n### Response: "} +{"task_id":712,"text":"Write a function to remove duplicates from a list of lists.","code":"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","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to remove duplicates from a list of lists.\n### Function signature: def remove_duplicate(list1):\n### Tests: assert remove_duplicate([[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]])==[[10, 20], [30, 56, 25], [33], [40]] \n assert remove_duplicate([\"a\", \"b\", \"a\", \"c\", \"c\"] )==[\"a\", \"b\", \"c\"]\n### Response: "} +{"task_id":713,"text":"Write a function to check if the given tuple contains all valid values or not.","code":"def check_valid(test_tup):\r\n res = not any(map(lambda ele: not ele, test_tup))\r\n return (res) ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check if the given tuple contains all valid values or not.\n### Function signature: def check_valid(test_tup):\n### Tests: assert check_valid((True, True, True, True) ) == True\n assert check_valid((True, False, True, True) ) == False\n### Response: "} +{"task_id":714,"text":"Write a python function to count the number of distinct power of prime factor of given number.","code":"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 ","test_list":["assert count_Fac(24) == 3","assert count_Fac(12) == 2","assert count_Fac(4) == 1"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to count the number of distinct power of prime factor of given number.\n### Function signature: def count_Fac(n):\n### Tests: assert count_Fac(24) == 3\n assert count_Fac(12) == 2\n### Response: "} +{"task_id":715,"text":"Write a function to convert the given string of integers into a tuple.","code":"def str_to_tuple(test_str):\r\n res = tuple(map(int, test_str.split(', ')))\r\n return (res) ","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)"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to convert the given string of integers into a tuple.\n### Function signature: def str_to_tuple(test_str):\n### Tests: assert str_to_tuple(\"1, -5, 4, 6, 7\") == (1, -5, 4, 6, 7)\n assert str_to_tuple(\"1, 2, 3, 4, 5\") == (1, 2, 3, 4, 5)\n### Response: "} +{"task_id":716,"text":"Write a function to find the perimeter of a rombus.","code":"def rombus_perimeter(a):\r\n perimeter=4*a\r\n return perimeter","test_list":["assert rombus_perimeter(10)==40","assert rombus_perimeter(5)==20","assert rombus_perimeter(4)==16"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the perimeter of a rombus.\n### Function signature: def rombus_perimeter(a):\n### Tests: assert rombus_perimeter(10)==40\n assert rombus_perimeter(5)==20\n### Response: "} +{"task_id":717,"text":"Write a function to calculate the standard deviation.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to calculate the standard deviation.\n### Function signature: def avg_calc(ls):\n### Tests: assert sd_calc([4, 2, 5, 8, 6])== 2.23606797749979\n assert sd_calc([1,2,3,4,5,6,7])==2.160246899469287\n### Response: "} +{"task_id":718,"text":"Write a function to create a list taking alternate elements from another given list.","code":"def alternate_elements(list1):\r\n result=[]\r\n for item in list1[::2]:\r\n result.append(item)\r\n return result ","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to create a list taking alternate elements from another given list.\n### Function signature: def alternate_elements(list1):\n### Tests: assert alternate_elements([\"red\", \"black\", \"white\", \"green\", \"orange\"])==['red', 'white', 'orange']\n assert alternate_elements([2, 0, 3, 4, 0, 2, 8, 3, 4, 2])==[2, 3, 0, 8, 4]\n### Response: "} +{"task_id":719,"text":"Write a function that matches a string that has an a followed by zero or more b's.","code":"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!')","test_list":["assert text_match(\"ac\")==('Found a match!')","assert text_match(\"dc\")==('Not matched!')","assert text_match(\"abba\")==('Found a match!')"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function that matches a string that has an a followed by zero or more b's.\n### Function signature: def text_match(text):\n### Tests: assert text_match(\"ac\")==('Found a match!')\n assert text_match(\"dc\")==('Not matched!')\n### Response: "} +{"task_id":720,"text":"Write a function to add a dictionary to the tuple.","code":"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) ","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})"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to add a dictionary to the tuple.\n### Function signature: def add_dict_to_tuple(test_tup, test_dict):\n### Tests: assert add_dict_to_tuple((4, 5, 6), {\"MSAM\" : 1, \"is\" : 2, \"best\" : 3} ) == (4, 5, 6, {'MSAM': 1, 'is': 2, 'best': 3})\n assert add_dict_to_tuple((1, 2, 3), {\"UTS\" : 2, \"is\" : 3, \"Worst\" : 4} ) == (1, 2, 3, {'UTS': 2, 'is': 3, 'Worst': 4})\n### Response: "} +{"task_id":721,"text":"Write a function to find a path with the maximum average over all existing paths for the given square matrix of size n*n.","code":"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)","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 "],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find a path with the maximum average over all existing paths for the given square matrix of size n*n.\n### Function signature: def maxAverageOfPath(cost, N):\n### Tests: assert maxAverageOfPath([[1, 2, 3], [6, 5, 4], [7, 3, 9]], 3) == 5.2\n assert maxAverageOfPath([[2, 3, 4], [7, 6, 5], [8, 4, 10]], 3) == 6.2\n### Response: "} +{"task_id":722,"text":"Write a function to filter the height and width of students which are stored in a dictionary.","code":"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 ","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)}"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to filter the height and width of students which are stored in a dictionary.\n### Function signature: def filter_data(students,h,w):\n### Tests: assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},6.0,70)=={'Cierra Vega': (6.2, 70)}\n 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)}\n### Response: "} +{"task_id":723,"text":"Write a function to count the same pair in two given lists using map function.","code":"from operator import eq\r\ndef count_same_pair(nums1, nums2):\r\n result = sum(map(eq, nums1, nums2))\r\n return result","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to count the same pair in two given lists using map function.\n### Function signature: def count_same_pair(nums1, nums2):\n### Tests: assert count_same_pair([1, 2, 3, 4, 5, 6, 7, 8],[2, 2, 3, 1, 2, 6, 7, 9])==4\n 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\n### Response: "} +{"task_id":724,"text":"Write a function to calculate the sum of all digits of the base to the specified power.","code":"def power_base_sum(base, power):\r\n return sum([int(i) for i in str(pow(base, power))])","test_list":["assert power_base_sum(2,100)==115","assert power_base_sum(8,10)==37","assert power_base_sum(8,15)==62"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to calculate the sum of all digits of the base to the specified power.\n### Function signature: def power_base_sum(base, power):\n### Tests: assert power_base_sum(2,100)==115\n assert power_base_sum(8,10)==37\n### Response: "} +{"task_id":725,"text":"Write a function to extract values between quotation marks of the given string by using regex.","code":"import re\r\ndef extract_quotation(text1):\r\n return (re.findall(r'\"(.*?)\"', text1))","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']"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to extract values between quotation marks of the given string by using regex.\n### Function signature: def extract_quotation(text1):\n### Tests: assert extract_quotation('Cortex \"A53\" Based \"multi\" tasking \"Processor\"') == ['A53', 'multi', 'Processor']\n assert extract_quotation('Cast your \"favorite\" entertainment \"apps\"') == ['favorite', 'apps']\n### Response: "} +{"task_id":726,"text":"Write a function to multiply the adjacent elements of the given tuple.","code":"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) ","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)"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to multiply the adjacent elements of the given tuple.\n### Function signature: def multiply_elements(test_tup):\n### Tests: assert multiply_elements((1, 5, 7, 8, 10)) == (5, 35, 56, 80)\n assert multiply_elements((2, 4, 5, 6, 7)) == (8, 20, 30, 42)\n### Response: "} +{"task_id":727,"text":"Write a function to remove all characters except letters and numbers using regex","code":"import re \r\ndef remove_char(S):\r\n result = re.sub('[\\W_]+', '', S) \r\n return result","test_list":["assert remove_char(\"123abcjw:, .@! eiw\") == '123abcjweiw'","assert remove_char(\"Hello1234:, ! Howare33u\") == 'Hello1234Howare33u'","assert remove_char(\"Cool543Triks@:, Make@987Trips\") == 'Cool543TriksMake987Trips' "],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to remove all characters except letters and numbers using regex\n### Function signature: def remove_char(S):\n### Tests: assert remove_char(\"123abcjw:, .@! eiw\") == '123abcjweiw'\n assert remove_char(\"Hello1234:, ! Howare33u\") == 'Hello1234Howare33u'\n### Response: "} +{"task_id":728,"text":"Write a function to sum elements in two lists.","code":"def sum_list(lst1,lst2):\r\n res_list = [lst1[i] + lst2[i] for i in range(len(lst1))] \r\n return res_list","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to sum elements in two lists.\n### Function signature: def sum_list(lst1,lst2):\n### Tests: assert sum_list([10,20,30],[15,25,35])==[25,45,65]\n assert sum_list([1,2,3],[5,6,7])==[6,8,10]\n### Response: "} +{"task_id":729,"text":"Write a function to add two lists using map and lambda function.","code":"def add_list(nums1,nums2):\r\n result = map(lambda x, y: x + y, nums1, nums2)\r\n return list(result)","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to add two lists using map and lambda function.\n### Function signature: def add_list(nums1,nums2):\n### Tests: assert add_list([1, 2, 3],[4,5,6])==[5, 7, 9]\n assert add_list([1,2],[3,4])==[4,6]\n### Response: "} +{"task_id":730,"text":"Write a function to remove consecutive duplicates of a given list.","code":"from itertools import groupby\r\ndef consecutive_duplicates(nums):\r\n return [key for key, group in groupby(nums)] ","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']"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to remove consecutive duplicates of a given list.\n### Function signature: def consecutive_duplicates(nums):\n### Tests: assert consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4 ])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4]\n assert consecutive_duplicates([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10])==[10, 15, 19, 18, 17, 26, 17, 18, 10]\n### Response: "} +{"task_id":731,"text":"Write a function to find the lateral surface area of a cone.","code":"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","test_list":["assert lateralsurface_cone(5,12)==204.20352248333654","assert lateralsurface_cone(10,15)==566.3586699569488","assert lateralsurface_cone(19,17)==1521.8090132193388"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the lateral surface area of a cone.\n### Function signature: def lateralsurface_cone(r,h):\n### Tests: assert lateralsurface_cone(5,12)==204.20352248333654\n assert lateralsurface_cone(10,15)==566.3586699569488\n### Response: "} +{"task_id":732,"text":"Write a function to replace all occurrences of spaces, commas, or dots with a colon.","code":"import re\r\ndef replace_specialchar(text):\r\n return (re.sub(\"[ ,.]\", \":\", text))\r","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')"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to replace all occurrences of spaces, commas, or dots with a colon.\n### Function signature: def replace_specialchar(text):\n### Tests: assert replace_specialchar('Python language, Programming language.')==('Python:language::Programming:language:')\n assert replace_specialchar('a b c,d e f')==('a:b:c:d:e:f')\n### Response: "} +{"task_id":733,"text":"Write a function to find the index of the first occurrence of a given number in a sorted array.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the index of the first occurrence of a given number in a sorted array.\n### Function signature: def find_first_occurrence(A, x):\n### Tests: assert find_first_occurrence([2, 5, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 1\n assert find_first_occurrence([2, 3, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 2\n### Response: "} +{"task_id":734,"text":"Write a python function to find sum of products of all possible subarrays.","code":"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)","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find sum of products of all possible subarrays.\n### Function signature: def sum_Of_Subarray_Prod(arr,n):\n### Tests: assert sum_Of_Subarray_Prod([1,2,3],3) == 20\n assert sum_Of_Subarray_Prod([1,2],2) == 5\n### Response: "} +{"task_id":735,"text":"Write a python function to toggle bits of the number except the first and the last bit.","code":"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) ","test_list":["assert toggle_middle_bits(9) == 15","assert toggle_middle_bits(10) == 12","assert toggle_middle_bits(11) == 13"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to toggle bits of the number except the first and the last bit.\n### Function signature: def toggle_middle_bits(n):\n### Tests: assert toggle_middle_bits(9) == 15\n assert toggle_middle_bits(10) == 12\n### Response: "} +{"task_id":736,"text":"Write a function to locate the left insertion point for a specified value in sorted order.","code":"import bisect\r\ndef left_insertion(a, x):\r\n i = bisect.bisect_left(a, x)\r\n return i","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to locate the left insertion point for a specified value in sorted order.\n### Function signature: def left_insertion(a, x):\n### Tests: assert left_insertion([1,2,4,5],6)==4\n assert left_insertion([1,2,4,5],3)==2\n### Response: "} +{"task_id":737,"text":"Write a function to check whether the given string is starting with a vowel or not using regex.","code":"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\") ","test_list":["assert check_str(\"annie\") == 'Valid'","assert check_str(\"dawood\") == 'Invalid'","assert check_str(\"Else\") == 'Valid'"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check whether the given string is starting with a vowel or not using regex.\n### Function signature: def check_str(string):\n### Tests: assert check_str(\"annie\") == 'Valid'\n assert check_str(\"dawood\") == 'Invalid'\n### Response: "} +{"task_id":738,"text":"Write a function to calculate the geometric sum of n-1.","code":"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)","test_list":["assert geometric_sum(7) == 1.9921875","assert geometric_sum(4) == 1.9375","assert geometric_sum(8) == 1.99609375"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to calculate the geometric sum of n-1.\n### Function signature: def geometric_sum(n):\n### Tests: assert geometric_sum(7) == 1.9921875\n assert geometric_sum(4) == 1.9375\n### Response: "} +{"task_id":739,"text":"Write a python function to find the index of smallest triangular number with n digits.","code":"import math \r\ndef find_Index(n): \r\n x = math.sqrt(2 * math.pow(10,(n - 1))); \r\n return round(x); ","test_list":["assert find_Index(2) == 4","assert find_Index(3) == 14","assert find_Index(4) == 45"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the index of smallest triangular number with n digits.\n### Function signature: def find_Index(n):\n### Tests: assert find_Index(2) == 4\n assert find_Index(3) == 14\n### Response: "} +{"task_id":740,"text":"Write a function to convert the given tuple to a key-value dictionary using adjacent elements.","code":"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) ","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}"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to convert the given tuple to a key-value dictionary using adjacent elements.\n### Function signature: def tuple_to_dict(test_tup):\n### Tests: assert tuple_to_dict((1, 5, 7, 10, 13, 5)) == {1: 5, 7: 10, 13: 5}\n assert tuple_to_dict((1, 2, 3, 4, 5, 6)) == {1: 2, 3: 4, 5: 6}\n### Response: "} +{"task_id":741,"text":"Write a python function to check whether all the characters are same or not.","code":"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","test_list":["assert all_Characters_Same(\"python\") == False","assert all_Characters_Same(\"aaa\") == True","assert all_Characters_Same(\"data\") == False"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check whether all the characters are same or not.\n### Function signature: def all_Characters_Same(s) :\n### Tests: assert all_Characters_Same(\"python\") == False\n assert all_Characters_Same(\"aaa\") == True\n### Response: "} +{"task_id":742,"text":"Write a function to caluclate the area of a tetrahedron.","code":"import math\r\ndef area_tetrahedron(side):\r\n area = math.sqrt(3)*(side*side)\r\n return area","test_list":["assert area_tetrahedron(3)==15.588457268119894","assert area_tetrahedron(20)==692.8203230275509","assert area_tetrahedron(10)==173.20508075688772"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to caluclate the area of a tetrahedron.\n### Function signature: def area_tetrahedron(side):\n### Tests: assert area_tetrahedron(3)==15.588457268119894\n assert area_tetrahedron(20)==692.8203230275509\n### Response: "} +{"task_id":743,"text":"Write a function to rotate a given list by specified number of items to the right direction.","code":"def rotate_right(list1,m,n):\r\n result = list1[-(m):]+list1[:-(n)]\r\n return result","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to rotate a given list by specified number of items to the right direction.\n### Function signature: def rotate_right(list1,m,n):\n### Tests: assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],3,4)==[8, 9, 10, 1, 2, 3, 4, 5, 6]\n 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]\n### Response: "} +{"task_id":744,"text":"Write a function to check if the given tuple has any none value or not.","code":"def check_none(test_tup):\r\n res = any(map(lambda ele: ele is None, test_tup))\r\n return (res) ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check if the given tuple has any none value or not.\n### Function signature: def check_none(test_tup):\n### Tests: assert check_none((10, 4, 5, 6, None)) == True\n assert check_none((7, 8, 9, 11, 14)) == False\n### Response: "} +{"task_id":745,"text":"Write a function to find numbers within a given range where every number is divisible by every digit it contains.","code":"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)))]","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find numbers within a given range where every number is divisible by every digit it contains.\n### Function signature: def divisible_by_digits(startnum, endnum):\n### Tests: assert divisible_by_digits(1,22)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]\n assert divisible_by_digits(1,15)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15]\n### Response: "} +{"task_id":746,"text":"Write a function to find area of a sector.","code":"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","test_list":["assert sector_area(4,45)==6.285714285714286","assert sector_area(9,45)==31.82142857142857","assert sector_area(9,360)==None"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find area of a sector.\n### Function signature: def sector_area(r,a):\n### Tests: assert sector_area(4,45)==6.285714285714286\n assert sector_area(9,45)==31.82142857142857\n### Response: "} +{"task_id":747,"text":"Write a function to find the longest common subsequence for the given three string sequence.","code":"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]","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the longest common subsequence for the given three string sequence.\n### Function signature: def lcs_of_three(X, Y, Z, m, n, o):\n### Tests: assert lcs_of_three('AGGT12', '12TXAYB', '12XBA', 6, 7, 5) == 2\n assert lcs_of_three('Reels', 'Reelsfor', 'ReelsforReels', 5, 8, 13) == 5 \n### Response: "} +{"task_id":748,"text":"Write a function to put spaces between words starting with capital letters in a given string by using regex.","code":"import re\r\ndef capital_words_spaces(str1):\r\n return re.sub(r\"(\\w)([A-Z])\", r\"\\1 \\2\", str1)","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'"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to put spaces between words starting with capital letters in a given string by using regex.\n### Function signature: def capital_words_spaces(str1):\n### Tests: assert capital_words_spaces(\"Python\") == 'Python'\n assert capital_words_spaces(\"PythonProgrammingExamples\") == 'Python Programming Examples'\n### Response: "} +{"task_id":749,"text":"Write a function to sort a given list of strings of numbers numerically.","code":"def sort_numeric_strings(nums_str):\r\n result = [int(x) for x in nums_str]\r\n result.sort()\r\n return result","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to sort a given list of strings of numbers numerically.\n### Function signature: def sort_numeric_strings(nums_str):\n### Tests: assert sort_numeric_strings( ['4','12','45','7','0','100','200','-12','-500'])==[-500, -12, 0, 4, 7, 12, 45, 100, 200]\n 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]\n### Response: "} +{"task_id":750,"text":"Write a function to add the given tuple to the given list.","code":"def add_tuple(test_list, test_tup):\r\n test_list += test_tup\r\n return (test_list) ","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to add the given tuple to the given list.\n### Function signature: def add_tuple(test_list, test_tup):\n### Tests: assert add_tuple([5, 6, 7], (9, 10)) == [5, 6, 7, 9, 10]\n assert add_tuple([6, 7, 8], (10, 11)) == [6, 7, 8, 10, 11]\n### Response: "} +{"task_id":751,"text":"Write a function to check if the given array represents min heap or not.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check if the given array represents min heap or not.\n### Function signature: def check_min_heap(arr, i):\n### Tests: assert check_min_heap([1, 2, 3, 4, 5, 6], 0) == True\n assert check_min_heap([2, 3, 4, 5, 10, 15], 0) == True\n### Response: "} +{"task_id":752,"text":"Write a function to find the nth jacobsthal number.","code":"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]","test_list":["assert jacobsthal_num(5) == 11","assert jacobsthal_num(2) == 1","assert jacobsthal_num(4) == 5"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the nth jacobsthal number.\n### Function signature: def jacobsthal_num(n):\n### Tests: assert jacobsthal_num(5) == 11\n assert jacobsthal_num(2) == 1\n### Response: "} +{"task_id":753,"text":"Write a function to find minimum k records from tuple list.","code":"def min_k(test_list, K):\r\n res = sorted(test_list, key = lambda x: x[1])[:K]\r\n return (res) ","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)]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find minimum k records from tuple list.\n### Function signature: def min_k(test_list, K):\n### Tests: assert min_k([('Manjeet', 10), ('Akshat', 4), ('Akash', 2), ('Nikhil', 8)], 2) == [('Akash', 2), ('Akshat', 4)]\n assert min_k([('Sanjeev', 11), ('Angat', 5), ('Akash', 3), ('Nepin', 9)], 3) == [('Akash', 3), ('Angat', 5), ('Nepin', 9)]\n### Response: "} +{"task_id":754,"text":"Write a function to find common index elements from three lists.","code":"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","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find common index elements from three lists.\n### Function signature: def extract_index_list(l1, l2, l3):\n### Tests: assert extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[1, 7]\n 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]\n### Response: "} +{"task_id":755,"text":"Write a function to find the second smallest number in a list.","code":"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] ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the second smallest number in a list.\n### Function signature: def second_smallest(numbers):\n### Tests: assert second_smallest([1, 2, -8, -2, 0, -2])==-2\n assert second_smallest([1, 1, -0.5, 0, 2, -2, -2])==-0.5\n### Response: "} +{"task_id":756,"text":"Write a function that matches a string that has an a followed by zero or one 'b'.","code":"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!')","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!')"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function that matches a string that has an a followed by zero or one 'b'.\n### Function signature: def text_match_zero_one(text):\n### Tests: assert text_match_zero_one(\"ac\")==('Found a match!')\n assert text_match_zero_one(\"dc\")==('Not matched!')\n### Response: "} +{"task_id":757,"text":"Write a function to count the pairs of reverse strings in the given string list.","code":"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)","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' "],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to count the pairs of reverse strings in the given string list.\n### Function signature: def count_reverse_pairs(test_list):\n### Tests: assert count_reverse_pairs([\"julia\", \"best\", \"tseb\", \"for\", \"ailuj\"])== '2'\n assert count_reverse_pairs([\"geeks\", \"best\", \"for\", \"skeeg\"]) == '1'\n### Response: "} +{"task_id":758,"text":"Write a function to count number of unique lists within a list.","code":"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","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}"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to count number of unique lists within a list.\n### Function signature: def unique_sublists(list1):\n### Tests: assert unique_sublists([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]] )=={(1, 3): 2, (5, 7): 2, (13, 15, 17): 1, (9, 11): 1}\n assert unique_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])=={('green', 'orange'): 2, ('black',): 1, ('white',): 1}\n### Response: "} +{"task_id":759,"text":"Write a function to check a decimal with a precision of 2.","code":"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)","test_list":["assert is_decimal('123.11')==True","assert is_decimal('e666.86')==False","assert is_decimal('3.124587')==False"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check a decimal with a precision of 2.\n### Function signature: def is_decimal(num):\n### Tests: assert is_decimal('123.11')==True\n assert is_decimal('e666.86')==False\n### Response: "} +{"task_id":760,"text":"Write a python function to check whether an array contains only one distinct element or not.","code":"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')","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'"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check whether an array contains only one distinct element or not.\n### Function signature: def unique_Element(arr,n):\n### Tests: assert unique_Element([1,1,1],3) == 'YES'\n assert unique_Element([1,2,1,2],4) == 'NO'\n### Response: "} +{"task_id":761,"text":"Write a function to caluclate arc length of an angle.","code":"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","test_list":["assert arc_length(9,45)==3.5357142857142856","assert arc_length(9,480)==None","assert arc_length(5,270)==11.785714285714285"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to caluclate arc length of an angle.\n### Function signature: def arc_length(d,a):\n### Tests: assert arc_length(9,45)==3.5357142857142856\n assert arc_length(9,480)==None\n### Response: "} +{"task_id":762,"text":"Write a function to check whether the given month number contains 30 days or not.","code":"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","test_list":["assert check_monthnumber_number(6)==True","assert check_monthnumber_number(2)==False","assert check_monthnumber_number(12)==False"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check whether the given month number contains 30 days or not.\n### Function signature: def check_monthnumber_number(monthnum3):\n### Tests: assert check_monthnumber_number(6)==True\n assert check_monthnumber_number(2)==False\n### Response: "} +{"task_id":763,"text":"Write a python function to find the minimum difference between any two elements in a given array.","code":"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 ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the minimum difference between any two elements in a given array.\n### Function signature: def find_Min_Diff(arr,n):\n### Tests: assert find_Min_Diff((1,5,3,19,18,25),6) == 1\n assert find_Min_Diff((4,3,2,6),4) == 1\n### Response: "} +{"task_id":764,"text":"Write a python function to count numeric values in a given string.","code":"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","test_list":["assert number_ctr('program2bedone') == 1","assert number_ctr('3wonders') ==1","assert number_ctr('123') == 3"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to count numeric values in a given string.\n### Function signature: def number_ctr(str):\n### Tests: assert number_ctr('program2bedone') == 1\n assert number_ctr('3wonders') ==1\n### Response: "} +{"task_id":765,"text":"Write a function to find nth polite number.","code":"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))) ","test_list":["assert is_polite(7) == 11","assert is_polite(4) == 7","assert is_polite(9) == 13"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find nth polite number.\n### Function signature: def is_polite(n):\n### Tests: assert is_polite(7) == 11\n assert is_polite(4) == 7\n### Response: "} +{"task_id":766,"text":"Write a function to iterate over all pairs of consecutive items in a given list.","code":"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","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)]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to iterate over all pairs of consecutive items in a given list.\n### Function signature: def pair_wise(l1):\n### Tests: assert pair_wise([1,1,2,3,3,4,4,5])==[(1, 1), (1, 2), (2, 3), (3, 3), (3, 4), (4, 4), (4, 5)]\n assert pair_wise([1,5,7,9,10])==[(1, 5), (5, 7), (7, 9), (9, 10)]\n### Response: "} +{"task_id":767,"text":"Write a python function to count the number of pairs whose sum is equal to \u2018sum\u2019.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to count the number of pairs whose sum is equal to \u2018sum\u2019.\n### Function signature: def get_Pairs_Count(arr,n,sum):\n### Tests: assert get_Pairs_Count([1,1,1,1],4,2) == 6\n assert get_Pairs_Count([1,5,7,-1,5],5,6) == 3\n### Response: "} +{"task_id":768,"text":"Write a python function to check for odd parity of a given number.","code":"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","test_list":["assert check_Odd_Parity(13) == True","assert check_Odd_Parity(21) == True","assert check_Odd_Parity(18) == False"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check for odd parity of a given number.\n### Function signature: def check_Odd_Parity(x):\n### Tests: assert check_Odd_Parity(13) == True\n assert check_Odd_Parity(21) == True\n### Response: "} +{"task_id":769,"text":"Write a python function to get the difference between two lists.","code":"def Diff(li1,li2):\r\n return (list(list(set(li1)-set(li2)) + list(set(li2)-set(li1))))\r\n ","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to get the difference between two lists.\n### Function signature: def Diff(li1,li2):\n### Tests: assert (Diff([10, 15, 20, 25, 30, 35, 40], [25, 40, 35])) == [10, 20, 30, 15]\n assert (Diff([1,2,3,4,5], [6,7,1])) == [2,3,4,5,6,7]\n### Response: "} +{"task_id":770,"text":"Write a python function to find the sum of fourth power of first n odd natural numbers.","code":"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 ","test_list":["assert odd_Num_Sum(2) == 82","assert odd_Num_Sum(3) == 707","assert odd_Num_Sum(4) == 3108"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the sum of fourth power of first n odd natural numbers.\n### Function signature: def odd_Num_Sum(n) :\n### Tests: assert odd_Num_Sum(2) == 82\n assert odd_Num_Sum(3) == 707\n### Response: "} +{"task_id":771,"text":"Write a function to check if the given expression is balanced or not.","code":"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","test_list":["assert check_expression(\"{()}[{}]\") == True","assert check_expression(\"{()}[{]\") == False","assert check_expression(\"{()}[{}][]({})\") == True"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check if the given expression is balanced or not.\n### Function signature: def check_expression(exp):\n### Tests: assert check_expression(\"{()}[{}]\") == True\n assert check_expression(\"{()}[{]\") == False\n### Response: "} +{"task_id":772,"text":"Write a function to remove all the words with k length in the given string.","code":"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) ","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'"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to remove all the words with k length in the given string.\n### Function signature: def remove_length(test_str, K):\n### Tests: assert remove_length('The person is most value tet', 3) == 'person is most value'\n assert remove_length('If you told me about this ok', 4) == 'If you me about ok'\n### Response: "} +{"task_id":773,"text":"Write a function to find the occurrence and position of the substrings within a string.","code":"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)","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)"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the occurrence and position of the substrings within a string.\n### Function signature: def occurance_substring(text,pattern):\n### Tests: assert occurance_substring('python programming, python language','python')==('python', 0, 6)\n assert occurance_substring('python programming,programming language','programming')==('programming', 7, 18)\n### Response: "} +{"task_id":774,"text":"Write a function to check if the string is a valid email address or not using regex.","code":"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\") ","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'"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check if the string is a valid email address or not using regex.\n### Function signature: def check_email(email):\n### Tests: assert check_email(\"ankitrai326@gmail.com\") == 'Valid Email'\n assert check_email(\"my.ownsite@ourearth.org\") == 'Valid Email'\n### Response: "} +{"task_id":775,"text":"Write a python function to check whether every odd index contains odd numbers of a given list.","code":"def odd_position(nums):\r\n\treturn all(nums[i]%2==i%2 for i in range(len(nums)))","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check whether every odd index contains odd numbers of a given list.\n### Function signature: def odd_position(nums):\n### Tests: assert odd_position([2,1,4,3,6,7,6,3]) == True\n assert odd_position([4,1,2]) == True\n### Response: "} +{"task_id":776,"text":"Write a function to count those characters which have vowels as their neighbors in the given string.","code":"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) ","test_list":["assert count_vowels('bestinstareels') == 7","assert count_vowels('partofthejourneyistheend') == 12","assert count_vowels('amazonprime') == 5"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to count those characters which have vowels as their neighbors in the given string.\n### Function signature: def count_vowels(test_str):\n### Tests: assert count_vowels('bestinstareels') == 7\n assert count_vowels('partofthejourneyistheend') == 12\n### Response: "} +{"task_id":777,"text":"Write a python function to find the sum of non-repeated elements in a given array.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the sum of non-repeated elements in a given array.\n### Function signature: def find_Sum(arr,n):\n### Tests: assert find_Sum([1,2,3,1,1,4,5,6],8) == 21\n assert find_Sum([1,10,9,4,2,10,10,45,4],9) == 71\n### Response: "} +{"task_id":778,"text":"Write a function to pack consecutive duplicates of a given list elements into sublists.","code":"from itertools import groupby\r\ndef pack_consecutive_duplicates(list1):\r\n return [list(group) for key, group in groupby(list1)]","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']]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to pack consecutive duplicates of a given list elements into sublists.\n### Function signature: def pack_consecutive_duplicates(list1):\n### Tests: assert pack_consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4])==[[0, 0], [1], [2], [3], [4, 4], [5], [6, 6, 6], [7], [8], [9], [4, 4]]\n 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]]\n### Response: "} +{"task_id":779,"text":"Write a function to count the number of unique lists within a list.","code":"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","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}"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to count the number of unique lists within a list.\n### Function signature: def unique_sublists(list1):\n### Tests: assert unique_sublists([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]])=={(1, 3): 2, (5, 7): 2, (13, 15, 17): 1, (9, 11): 1}\n assert unique_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])=={('green', 'orange'): 2, ('black',): 1, ('white',): 1}\n### Response: "} +{"task_id":780,"text":"Write a function to find the combinations of sums with tuples in the given tuple list.","code":"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) ","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)]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the combinations of sums with tuples in the given tuple list.\n### Function signature: def find_combinations(test_list):\n### Tests: assert find_combinations([(2, 4), (6, 7), (5, 1), (6, 10)]) == [(8, 11), (7, 5), (8, 14), (11, 8), (12, 17), (11, 11)]\n assert find_combinations([(3, 5), (7, 8), (6, 2), (7, 11)]) == [(10, 13), (9, 7), (10, 16), (13, 10), (14, 19), (13, 13)]\n### Response: "} +{"task_id":781,"text":"Write a python function to check whether the count of divisors is even or odd.","code":"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\") ","test_list":["assert count_Divisors(10) == \"Even\"","assert count_Divisors(100) == \"Odd\"","assert count_Divisors(125) == \"Even\""],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check whether the count of divisors is even or odd.\n### Function signature: def count_Divisors(n) :\n### Tests: assert count_Divisors(10) == \"Even\"\n assert count_Divisors(100) == \"Odd\"\n### Response: "} +{"task_id":782,"text":"Write a python function to find the sum of all odd length subarrays.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the sum of all odd length subarrays.\n### Function signature: def Odd_Length_Sum(arr):\n### Tests: assert Odd_Length_Sum([1,2,4]) == 14\n assert Odd_Length_Sum([1,2,1,2]) == 15\n### Response: "} +{"task_id":783,"text":"Write a function to convert rgb color to hsv color.","code":"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","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)"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to convert rgb color to hsv color.\n### Function signature: def rgb_to_hsv(r, g, b):\n### Tests: assert rgb_to_hsv(255, 255, 255)==(0, 0.0, 100.0)\n assert rgb_to_hsv(0, 215, 0)==(120.0, 100.0, 84.31372549019608)\n### Response: "} +{"task_id":784,"text":"Write a function to find the product of first even and odd number of a given list.","code":"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)","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the product of first even and odd number of a given list.\n### Function signature: def mul_even_odd(list1):\n### Tests: assert mul_even_odd([1,3,5,7,4,1,6,8])==4\n assert mul_even_odd([1,2,3,4,5,6,7,8,9,10])==2\n### Response: "} +{"task_id":785,"text":"Write a function to convert tuple string to integer tuple.","code":"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) ","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)"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to convert tuple string to integer tuple.\n### Function signature: def tuple_str_int(test_str):\n### Tests: assert tuple_str_int(\"(7, 8, 9)\") == (7, 8, 9)\n assert tuple_str_int(\"(1, 2, 3)\") == (1, 2, 3)\n### Response: "} +{"task_id":786,"text":"Write a function to locate the right insertion point for a specified value in sorted order.","code":"import bisect\r\ndef right_insertion(a, x):\r\n i = bisect.bisect_right(a, x)\r\n return i","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to locate the right insertion point for a specified value in sorted order.\n### Function signature: def right_insertion(a, x):\n### Tests: assert right_insertion([1,2,4,5],6)==4\n assert right_insertion([1,2,4,5],3)==2\n### Response: "} +{"task_id":787,"text":"Write a function that matches a string that has an a followed by three 'b'.","code":"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!')","test_list":["assert text_match_three(\"ac\")==('Not matched!')","assert text_match_three(\"dc\")==('Not matched!')","assert text_match_three(\"abbbba\")==('Found a match!')"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function that matches a string that has an a followed by three 'b'.\n### Function signature: def text_match_three(text):\n### Tests: assert text_match_three(\"ac\")==('Not matched!')\n assert text_match_three(\"dc\")==('Not matched!')\n### Response: "} +{"task_id":788,"text":"Write a function to create a new tuple from the given string and list.","code":"def new_tuple(test_list, test_str):\r\n res = tuple(test_list + [test_str])\r\n return (res) ","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')"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to create a new tuple from the given string and list.\n### Function signature: def new_tuple(test_list, test_str):\n### Tests: assert new_tuple([\"WEB\", \"is\"], \"best\") == ('WEB', 'is', 'best')\n assert new_tuple([\"We\", \"are\"], \"Developers\") == ('We', 'are', 'Developers')\n### Response: "} +{"task_id":789,"text":"Write a function to calculate the perimeter of a regular polygon.","code":"from math import tan, pi\r\ndef perimeter_polygon(s,l):\r\n perimeter = s*l\r\n return perimeter","test_list":["assert perimeter_polygon(4,20)==80","assert perimeter_polygon(10,15)==150","assert perimeter_polygon(9,7)==63"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to calculate the perimeter of a regular polygon.\n### Function signature: def perimeter_polygon(s,l):\n### Tests: assert perimeter_polygon(4,20)==80\n assert perimeter_polygon(10,15)==150\n### Response: "} +{"task_id":790,"text":"Write a python function to check whether every even index contains even numbers of a given list.","code":"def even_position(nums):\r\n\treturn all(nums[i]%2==i%2 for i in range(len(nums)))","test_list":["assert even_position([3,2,1]) == False","assert even_position([1,2,3]) == False","assert even_position([2,1,4]) == True"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check whether every even index contains even numbers of a given list.\n### Function signature: def even_position(nums):\n### Tests: assert even_position([3,2,1]) == False\n assert even_position([1,2,3]) == False\n### Response: "} +{"task_id":791,"text":"Write a function to remove the nested record from the given tuple.","code":"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) ","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)"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to remove the nested record from the given tuple.\n### Function signature: def remove_nested(test_tup):\n### Tests: assert remove_nested((1, 5, 7, (4, 6), 10)) == (1, 5, 7, 10)\n assert remove_nested((2, 6, 8, (5, 7), 11)) == (2, 6, 8, 11)\n### Response: "} +{"task_id":792,"text":"Write a python function to count the number of lists in a given number of lists.","code":"def count_list(input_list): \r\n return len(input_list)","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to count the number of lists in a given number of lists.\n### Function signature: def count_list(input_list):\n### Tests: assert count_list([[1, 3], [5, 7], [9, 11], [13, 15, 17]]) == 4\n assert count_list([[1,2],[2,3],[4,5]]) == 3\n### Response: "} +{"task_id":793,"text":"Write a python function to find the last position of an element in a sorted array.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the last position of an element in a sorted array.\n### Function signature: def last(arr,x,n):\n### Tests: assert last([1,2,3],1,3) == 0\n assert last([1,1,1,2,3,4],1,6) == 2\n### Response: "} +{"task_id":794,"text":"Write a function that matches a string that has an 'a' followed by anything, ending in 'b'.","code":"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!')","test_list":["assert text_starta_endb(\"aabbbb\")==('Found a match!')","assert text_starta_endb(\"aabAbbbc\")==('Not matched!')","assert text_starta_endb(\"accddbbjjj\")==('Not matched!')"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function that matches a string that has an 'a' followed by anything, ending in 'b'.\n### Function signature: def text_starta_endb(text):\n### Tests: assert text_starta_endb(\"aabbbb\")==('Found a match!')\n assert text_starta_endb(\"aabAbbbc\")==('Not matched!')\n### Response: "} +{"task_id":795,"text":"Write a function to find the n - cheap price items from a given dataset using heap queue algorithm.","code":"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","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}]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the n - cheap price items from a given dataset using heap queue algorithm.\n### Function signature: def cheap_items(items,n):\n### Tests: assert cheap_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}],1)==[{'name': 'Item-1', 'price': 101.1}]\n 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}]\n### Response: "} +{"task_id":796,"text":"Write function to find the sum of all items in the given dictionary.","code":"def return_sum(dict):\r\n sum = 0\r\n for i in dict.values():\r\n sum = sum + i\r\n return sum","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write function to find the sum of all items in the given dictionary.\n### Function signature: def return_sum(dict):\n### Tests: assert return_sum({'a': 100, 'b':200, 'c':300}) == 600\n assert return_sum({'a': 25, 'b':18, 'c':45}) == 88\n### Response: "} +{"task_id":797,"text":"Write a python function to find the sum of all odd natural numbers within the range l and r.","code":"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)","test_list":["assert sum_in_Range(2,5) == 8","assert sum_in_Range(5,7) == 12","assert sum_in_Range(7,13) == 40"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the sum of all odd natural numbers within the range l and r.\n### Function signature: def sum_in_Range(l,r):\n### Tests: assert sum_in_Range(2,5) == 8\n assert sum_in_Range(5,7) == 12\n### Response: "} +{"task_id":798,"text":"Write a python function to find the sum of an array.","code":"def _sum(arr): \r\n sum=0\r\n for i in arr: \r\n sum = sum + i \r\n return(sum) ","test_list":["assert _sum([1, 2, 3]) == 6","assert _sum([15, 12, 13, 10]) == 50","assert _sum([0, 1, 2]) == 3"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the sum of an array.\n### Function signature: def _sum(arr):\n### Tests: assert _sum([1, 2, 3]) == 6\n assert _sum([15, 12, 13, 10]) == 50\n### Response: "} +{"task_id":799,"text":"Write a python function to left rotate the bits of a given number.","code":"INT_BITS = 32\r\ndef left_Rotate(n,d): \r\n return (n << d)|(n >> (INT_BITS - d)) ","test_list":["assert left_Rotate(16,2) == 64","assert left_Rotate(10,2) == 40","assert left_Rotate(99,3) == 792"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to left rotate the bits of a given number.\n### Function signature: def left_Rotate(n,d):\n### Tests: assert left_Rotate(16,2) == 64\n assert left_Rotate(10,2) == 40\n### Response: "} +{"task_id":800,"text":"Write a function to remove all whitespaces from a string.","code":"import re\r\ndef remove_all_spaces(text):\r\n return (re.sub(r'\\s+', '',text))","test_list":["assert remove_all_spaces('python program')==('pythonprogram')","assert remove_all_spaces('python programming language')==('pythonprogramminglanguage')","assert remove_all_spaces('python program')==('pythonprogram')"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to remove all whitespaces from a string.\n### Function signature: def remove_all_spaces(text):\n### Tests: assert remove_all_spaces('python program')==('pythonprogram')\n assert remove_all_spaces('python programming language')==('pythonprogramminglanguage')\n### Response: "} +{"task_id":801,"text":"Write a python function to count the number of equal numbers from three given integers.","code":"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))","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to count the number of equal numbers from three given integers.\n### Function signature: def test_three_equal(x,y,z):\n### Tests: assert test_three_equal(1,1,1) == 3\n assert test_three_equal(-1,-2,-3) == 0\n### Response: "} +{"task_id":802,"text":"Write a python function to count the number of rotations required to generate a sorted array.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to count the number of rotations required to generate a sorted array.\n### Function signature: def count_Rotation(arr,n):\n### Tests: assert count_Rotation([3,2,1],3) == 1\n assert count_Rotation([4,5,1,2,3],5) == 2\n### Response: "} +{"task_id":803,"text":"Write a python function to check whether the given number is a perfect square or not.","code":"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","test_list":["assert is_Perfect_Square(10) == False","assert is_Perfect_Square(36) == True","assert is_Perfect_Square(14) == False"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check whether the given number is a perfect square or not.\n### Function signature: def is_Perfect_Square(n) :\n### Tests: assert is_Perfect_Square(10) == False\n assert is_Perfect_Square(36) == True\n### Response: "} +{"task_id":804,"text":"Write a python function to check whether the product of numbers is even or not.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check whether the product of numbers is even or not.\n### Function signature: def is_Product_Even(arr,n):\n### Tests: assert is_Product_Even([1,2,3],3) == True\n assert is_Product_Even([1,2,1,4],4) == True\n### Response: "} +{"task_id":805,"text":"Write a function to find the list in a list of lists whose sum of elements is the highest.","code":"def max_sum_list(lists):\r\n return max(lists, key=sum)","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] "],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the list in a list of lists whose sum of elements is the highest.\n### Function signature: def max_sum_list(lists):\n### Tests: assert max_sum_list([[1,2,3], [4,5,6], [10,11,12], [7,8,9]])==[10, 11, 12] \n assert max_sum_list([[3,2,1], [6,5,4], [12,11,10]])==[12,11,10] \n### Response: "} +{"task_id":806,"text":"Write a function to find maximum run of uppercase characters in the given string.","code":"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)","test_list":["assert max_run_uppercase('GeMKSForGERksISBESt') == 5","assert max_run_uppercase('PrECIOusMOVemENTSYT') == 6","assert max_run_uppercase('GooGLEFluTTER') == 4"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find maximum run of uppercase characters in the given string.\n### Function signature: def max_run_uppercase(test_str):\n### Tests: assert max_run_uppercase('GeMKSForGERksISBESt') == 5\n assert max_run_uppercase('PrECIOusMOVemENTSYT') == 6\n### Response: "} +{"task_id":807,"text":"Write a python function to find the first odd number in a given list of numbers.","code":"def first_odd(nums):\r\n first_odd = next((el for el in nums if el%2!=0),-1)\r\n return first_odd","test_list":["assert first_odd([1,3,5]) == 1","assert first_odd([2,4,1,3]) == 1","assert first_odd ([8,9,1]) == 9"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the first odd number in a given list of numbers.\n### Function signature: def first_odd(nums):\n### Tests: assert first_odd([1,3,5]) == 1\n assert first_odd([2,4,1,3]) == 1\n### Response: "} +{"task_id":808,"text":"Write a function to check if the given tuples contain the k or not.","code":"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) ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check if the given tuples contain the k or not.\n### Function signature: def check_K(test_tup, K):\n### Tests: assert check_K((10, 4, 5, 6, 8), 6) == True\n assert check_K((1, 2, 3, 4, 5, 6), 7) == False\n### Response: "} +{"task_id":809,"text":"Write a function to check if each element of second tuple is smaller than its corresponding index in first tuple.","code":"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) ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check if each element of second tuple is smaller than its corresponding index in first tuple.\n### Function signature: def check_smaller(test_tup1, test_tup2):\n### Tests: assert check_smaller((1, 2, 3), (2, 3, 4)) == False\n assert check_smaller((4, 5, 6), (3, 4, 5)) == True\n### Response: "} +{"task_id":810,"text":"Write a function to iterate over elements repeating each as many times as its count.","code":"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())","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']"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to iterate over elements repeating each as many times as its count.\n### Function signature: def count_variable(a,b,c,d):\n### Tests: assert count_variable(4,2,0,-2)==['p', 'p', 'p', 'p', 'q', 'q'] \n assert count_variable(0,1,2,3)==['q', 'r', 'r', 's', 's', 's'] \n### Response: "} +{"task_id":811,"text":"Write a function to check if two lists of tuples are identical or not.","code":"def check_identical(test_list1, test_list2):\r\n res = test_list1 == test_list2\r\n return (res) ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check if two lists of tuples are identical or not.\n### Function signature: def check_identical(test_list1, test_list2):\n### Tests: assert check_identical([(10, 4), (2, 5)], [(10, 4), (2, 5)]) == True\n assert check_identical([(1, 2), (3, 7)], [(12, 14), (12, 45)]) == False\n### Response: "} +{"task_id":812,"text":"Write a function to abbreviate 'road' as 'rd.' in a given string.","code":"import re\r\ndef road_rd(street):\r\n return (re.sub('Road$', 'Rd.', street))","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.')"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to abbreviate 'road' as 'rd.' in a given string.\n### Function signature: def road_rd(street):\n### Tests: assert road_rd(\"ravipadu Road\")==('ravipadu Rd.')\n assert road_rd(\"palnadu Road\")==('palnadu Rd.')\n### Response: "} +{"task_id":813,"text":"Write a function to find length of the string.","code":"def string_length(str1):\r\n count = 0\r\n for char in str1:\r\n count += 1\r\n return count","test_list":["assert string_length('python')==6","assert string_length('program')==7","assert string_length('language')==8"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find length of the string.\n### Function signature: def string_length(str1):\n### Tests: assert string_length('python')==6\n assert string_length('program')==7\n### Response: "} +{"task_id":814,"text":"Write a function to find the area of a rombus.","code":"def rombus_area(p,q):\r\n area=(p*q)\/2\r\n return area","test_list":["assert rombus_area(10,20)==100","assert rombus_area(10,5)==25","assert rombus_area(4,2)==4"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the area of a rombus.\n### Function signature: def rombus_area(p,q):\n### Tests: assert rombus_area(10,20)==100\n assert rombus_area(10,5)==25\n### Response: "} +{"task_id":815,"text":"Write a function to sort the given array without using any sorting algorithm. the given array consists of only 0, 1, and 2.","code":"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","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to sort the given array without using any sorting algorithm. the given array consists of only 0, 1, and 2.\n### Function signature: def sort_by_dnf(arr, n):\n### Tests: assert sort_by_dnf([1,2,0,1,0,1,2,1,1], 9) == [0, 0, 1, 1, 1, 1, 1, 2, 2]\n 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]\n### Response: "} +{"task_id":816,"text":"Write a function to clear the values of the given tuples.","code":"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) ","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)) == ()"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to clear the values of the given tuples.\n### Function signature: def clear_tuple(test_tup):\n### Tests: assert clear_tuple((1, 5, 3, 6, 8)) == ()\n assert clear_tuple((2, 1, 4 ,5 ,6)) == ()\n### Response: "} +{"task_id":817,"text":"Write a function to find numbers divisible by m or n from a list of numbers using lambda function.","code":"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","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find numbers divisible by m or n from a list of numbers using lambda function.\n### Function signature: def div_of_nums(nums,m,n):\n### Tests: assert div_of_nums([19, 65, 57, 39, 152, 639, 121, 44, 90, 190],19,13)==[19, 65, 57, 39, 152, 190]\n assert div_of_nums([1, 2, 3, 5, 7, 8, 10],2,5)==[2, 5, 8, 10]\n### Response: "} +{"task_id":818,"text":"Write a python function to count lower case letters in a given string.","code":"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","test_list":["assert lower_ctr('abc') == 3","assert lower_ctr('string') == 6","assert lower_ctr('Python') == 5"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to count lower case letters in a given string.\n### Function signature: def lower_ctr(str):\n### Tests: assert lower_ctr('abc') == 3\n assert lower_ctr('string') == 6\n### Response: "} +{"task_id":819,"text":"Write a function to count the frequency of consecutive duplicate elements in a given list of numbers.","code":"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","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])"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to count the frequency of consecutive duplicate elements in a given list of numbers.\n### Function signature: def count_duplic(lists):\n### Tests: assert count_duplic([1,2,2,2,4,4,4,5,5,5,5])==([1, 2, 4, 5], [1, 3, 3, 4])\n 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])\n### Response: "} +{"task_id":820,"text":"Write a function to check whether the given month number contains 28 days or not.","code":"def check_monthnum_number(monthnum1):\r\n if monthnum1 == 2:\r\n return True\r\n else:\r\n return False","test_list":["assert check_monthnum_number(2)==True","assert check_monthnum_number(1)==False","assert check_monthnum_number(3)==False"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check whether the given month number contains 28 days or not.\n### Function signature: def check_monthnum_number(monthnum1):\n### Tests: assert check_monthnum_number(2)==True\n assert check_monthnum_number(1)==False\n### Response: "} +{"task_id":821,"text":"Write a function to merge two dictionaries into a single expression.","code":"import collections as ct\r\ndef merge_dictionaries(dict1,dict2):\r\n merged_dict = dict(ct.ChainMap({}, dict1, dict2))\r\n return merged_dict","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'}"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to merge two dictionaries into a single expression.\n### Function signature: def merge_dictionaries(dict1,dict2):\n### Tests: assert merge_dictionaries({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" })=={'B': 'Black', 'R': 'Red', 'P': 'Pink', 'G': 'Green', 'W': 'White'}\n 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'}\n### Response: "} +{"task_id":822,"text":"Write a function to return true if the password is valid.","code":"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","test_list":["assert pass_validity(\"password\")==False","assert pass_validity(\"Password@10\")==True","assert pass_validity(\"password@10\")==False"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to return true if the password is valid.\n### Function signature: def pass_validity(p):\n### Tests: assert pass_validity(\"password\")==False\n assert pass_validity(\"Password@10\")==True\n### Response: "} +{"task_id":823,"text":"Write a function to check if the given string starts with a substring using regex.","code":"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\")","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'"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check if the given string starts with a substring using regex.\n### Function signature: def check_substring(string, sample) :\n### Tests: assert check_substring(\"dreams for dreams makes life fun\", \"makes\") == 'string doesnt start with the given substring'\n assert check_substring(\"Hi there how are you Hi alex\", \"Hi\") == 'string starts with the given substring'\n### Response: "} +{"task_id":824,"text":"Write a python function to remove even numbers from a given list.","code":"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","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to remove even numbers from a given list.\n### Function signature: def remove_even(l):\n### Tests: assert remove_even([1,3,5,2]) == [1,3,5]\n assert remove_even([5,6,7]) == [5,7]\n### Response: "} +{"task_id":825,"text":"Write a python function to access multiple elements of specified index from a given list.","code":"def access_elements(nums, list_index):\r\n result = [nums[i] for i in list_index]\r\n return result","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to access multiple elements of specified index from a given list.\n### Function signature: def access_elements(nums, list_index):\n### Tests: assert access_elements([2,3,8,4,7,9],[0,3,5]) == [2, 4, 9]\n assert access_elements([1, 2, 3, 4, 5],[1,2]) == [2,3]\n### Response: "} +{"task_id":826,"text":"Write a python function to find the type of triangle from the given sides.","code":"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\") ","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\""],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the type of triangle from the given sides.\n### Function signature: def check_Type_Of_Triangle(a,b,c):\n### Tests: assert check_Type_Of_Triangle(1,2,3) == \"Obtuse-angled Triangle\"\n assert check_Type_Of_Triangle(2,2,2) == \"Acute-angled Triangle\"\n### Response: "} +{"task_id":827,"text":"Write a function to sum a specific column of a list in a given list of lists.","code":"def sum_column(list1, C):\r\n result = sum(row[C] for row in list1)\r\n return result","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to sum a specific column of a list in a given list of lists.\n### Function signature: def sum_column(list1, C):\n### Tests: assert sum_column( [[1,2,3,2],[4,5,6,2],[7,8,9,5],],0)==12\n assert sum_column( [[1,2,3,2],[4,5,6,2],[7,8,9,5],],1)==15\n### Response: "} +{"task_id":828,"text":"Write a function to count alphabets,digits and special charactes in a given string.","code":"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) ","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)"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to count alphabets,digits and special charactes in a given string.\n### Function signature: def count_alpha_dig_spl(string):\n### Tests: assert count_alpha_dig_spl(\"abc!@#123\")==(3,3,3)\n assert count_alpha_dig_spl(\"dgsuy@#$%&1255\")==(5,4,5)\n### Response: "} +{"task_id":829,"text":"Write a function to find out the second most repeated (or frequent) string in the given sequence.","code":"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) ","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'"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find out the second most repeated (or frequent) string in the given sequence.\n### Function signature: def second_frequent(input):\n### Tests: assert second_frequent(['aaa','bbb','ccc','bbb','aaa','aaa']) == 'bbb'\n assert second_frequent(['abc','bcd','abc','bcd','bcd','bcd']) == 'abc'\n### Response: "} +{"task_id":830,"text":"Write a function to round up a number to specific digits.","code":"import math\r\ndef round_up(a, digits):\r\n n = 10**-digits\r\n return round(math.ceil(a \/ n) * n, digits)","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to round up a number to specific digits.\n### Function signature: def round_up(a, digits):\n### Tests: assert round_up(123.01247,0)==124\n assert round_up(123.01247,1)==123.1\n### Response: "} +{"task_id":831,"text":"Write a python function to count equal element pairs from the given array.","code":"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; ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to count equal element pairs from the given array.\n### Function signature: def count_Pairs(arr,n):\n### Tests: assert count_Pairs([1,1,1,1],4) == 6\n assert count_Pairs([1,5,1],3) == 1\n### Response: "} +{"task_id":832,"text":"Write a function to extract the maximum numeric value from a string by using regex.","code":"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)","test_list":["assert extract_max('100klh564abc365bg') == 564","assert extract_max('hello300how546mer231') == 546","assert extract_max('its233beenalong343journey234') == 343"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to extract the maximum numeric value from a string by using regex.\n### Function signature: def extract_max(input):\n### Tests: assert extract_max('100klh564abc365bg') == 564\n assert extract_max('hello300how546mer231') == 546\n### Response: "} +{"task_id":833,"text":"Write a function to get dictionary keys as a list.","code":"def get_key(dict): \r\n list = [] \r\n for key in dict.keys(): \r\n list.append(key) \r\n return list","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to get dictionary keys as a list.\n### Function signature: def get_key(dict):\n### Tests: assert get_key({1:'python',2:'java'})==[1,2]\n assert get_key({10:'red',20:'blue',30:'black'})==[10,20,30]\n### Response: "} +{"task_id":834,"text":"Write a function to generate a square matrix filled with elements from 1 to n raised to the power of 2 in spiral order.","code":"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","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]]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to generate a square matrix filled with elements from 1 to n raised to the power of 2 in spiral order.\n### Function signature: def generate_matrix(n):\n### Tests: assert generate_matrix(3)==[[1, 2, 3], [8, 9, 4], [7, 6, 5]] \n assert generate_matrix(2)==[[1,2],[4,3]]\n### Response: "} +{"task_id":835,"text":"Write a python function to find the slope of a line.","code":"def slope(x1,y1,x2,y2): \r\n return (float)(y2-y1)\/(x2-x1) ","test_list":["assert slope(4,2,2,5) == -1.5","assert slope(2,4,4,6) == 1","assert slope(1,2,4,2) == 0"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the slope of a line.\n### Function signature: def slope(x1,y1,x2,y2):\n### Tests: assert slope(4,2,2,5) == -1.5\n assert slope(2,4,4,6) == 1\n### Response: "} +{"task_id":836,"text":"Write a function to find length of the subarray having maximum sum.","code":"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)","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find length of the subarray having maximum sum.\n### Function signature: def max_sub_array_sum(a,size):\n### Tests: assert max_sub_array_sum([-2, -3, 4, -1, -2, 1, 5, -3],8) == 5\n assert max_sub_array_sum([1, -2, 1, 1, -2, 1],6) == 2\n### Response: "} +{"task_id":837,"text":"Write a python function to find the cube sum of first n odd natural numbers.","code":"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","test_list":["assert cube_Sum(2) == 28","assert cube_Sum(3) == 153","assert cube_Sum(4) == 496"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the cube sum of first n odd natural numbers.\n### Function signature: def cube_Sum(n):\n### Tests: assert cube_Sum(2) == 28\n assert cube_Sum(3) == 153\n### Response: "} +{"task_id":838,"text":"Write a python function to find minimum number swaps required to make two binary strings equal.","code":"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; ","test_list":["assert min_Swaps(\"0011\",\"1111\") == 1","assert min_Swaps(\"00011\",\"01001\") == 2","assert min_Swaps(\"111\",\"111\") == 0"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find minimum number swaps required to make two binary strings equal.\n### Function signature: def min_Swaps(s1,s2) :\n### Tests: assert min_Swaps(\"0011\",\"1111\") == 1\n assert min_Swaps(\"00011\",\"01001\") == 2\n### Response: "} +{"task_id":839,"text":"Write a function to sort the tuples alphabetically by the first item of each tuple.","code":"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","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)]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to sort the tuples alphabetically by the first item of each tuple.\n### Function signature: def sort_tuple(tup):\n### Tests: assert sort_tuple([(\"Amana\", 28), (\"Zenat\", 30), (\"Abhishek\", 29),(\"Nikhil\", 21), (\"B\", \"C\")]) == [('Abhishek', 29), ('Amana', 28), ('B', 'C'), ('Nikhil', 21), ('Zenat', 30)]\n assert sort_tuple([(\"aaaa\", 28), (\"aa\", 30), (\"bab\", 29), (\"bb\", 21), (\"csa\", \"C\")]) == [('aa', 30), ('aaaa', 28), ('bab', 29), ('bb', 21), ('csa', 'C')]\n### Response: "} +{"task_id":840,"text":"Write a python function to check whether the roots of a quadratic equation are numerically equal but opposite in sign or not.","code":"def Check_Solution(a,b,c): \r\n if b == 0: \r\n return (\"Yes\") \r\n else: \r\n return (\"No\") ","test_list":["assert Check_Solution(2,0,-1) == \"Yes\"","assert Check_Solution(1,-5,6) == \"No\"","assert Check_Solution(2,0,2) == \"Yes\""],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check whether the roots of a quadratic equation are numerically equal but opposite in sign or not.\n### Function signature: def Check_Solution(a,b,c):\n### Tests: assert Check_Solution(2,0,-1) == \"Yes\"\n assert Check_Solution(1,-5,6) == \"No\"\n### Response: "} +{"task_id":841,"text":"Write a function to count the number of inversions in the given array.","code":"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 ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to count the number of inversions in the given array.\n### Function signature: def get_inv_count(arr, n):\n### Tests: assert get_inv_count([1, 20, 6, 4, 5], 5) == 5\n assert get_inv_count([8, 4, 2, 1], 4) == 6\n### Response: "} +{"task_id":842,"text":"Write a function to find the number which occurs for odd number of times in the given array.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the number which occurs for odd number of times in the given array.\n### Function signature: def get_odd_occurence(arr, arr_size):\n### Tests: assert get_odd_occurence([2, 3, 5, 4, 5, 2, 4, 3, 5, 2, 4, 4, 2], 13) == 5\n assert get_odd_occurence([1, 2, 3, 2, 3, 1, 3], 7) == 3\n### Response: "} +{"task_id":843,"text":"Write a function to find the nth super ugly number from a given prime list of size k using heap queue algorithm.","code":"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]","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the nth super ugly number from a given prime list of size k using heap queue algorithm.\n### Function signature: def gen(prime):\n### Tests: assert nth_super_ugly_number(12,[2,7,13,19])==32\n assert nth_super_ugly_number(10,[2,7,13,19])==26\n### Response: "} +{"task_id":844,"text":"Write a python function to find the kth element in an array containing odd elements first and then even elements.","code":"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]; ","test_list":["assert get_Number(8,5) == 2","assert get_Number(7,2) == 3","assert get_Number(5,2) == 3"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the kth element in an array containing odd elements first and then even elements.\n### Function signature: def get_Number(n, k):\n### Tests: assert get_Number(8,5) == 2\n assert get_Number(7,2) == 3\n### Response: "} +{"task_id":845,"text":"Write a python function to count the number of digits in factorial of a given number.","code":"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; ","test_list":["assert find_Digits(7) == 4","assert find_Digits(5) == 3","assert find_Digits(4) == 2"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to count the number of digits in factorial of a given number.\n### Function signature: def find_Digits(n):\n### Tests: assert find_Digits(7) == 4\n assert find_Digits(5) == 3\n### Response: "} +{"task_id":846,"text":"Write a function to find the minimum number of platforms required for a railway\/bus station.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the minimum number of platforms required for a railway\/bus station.\n### Function signature: def find_platform(arr, dep, n):\n### Tests: assert find_platform([900, 940, 950, 1100, 1500, 1800],[910, 1200, 1120, 1130, 1900, 2000],6)==3\n assert find_platform([100,200,300,400],[700,800,900,1000],4)==4\n### Response: "} +{"task_id":847,"text":"Write a python function to copy a list from a singleton tuple.","code":"def lcopy(xs):\n return xs[:]\n","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to copy a list from a singleton tuple.\n### Function signature: def lcopy(xs):\n### Tests: assert lcopy([1, 2, 3]) == [1, 2, 3]\n assert lcopy([4, 8, 2, 10, 15, 18]) == [4, 8, 2, 10, 15, 18]\n### Response: "} +{"task_id":848,"text":"Write a function to find the area of a trapezium.","code":"def area_trapezium(base1,base2,height):\r\n area = 0.5 * (base1 + base2) * height\r\n return area","test_list":["assert area_trapezium(6,9,4)==30","assert area_trapezium(10,20,30)==450","assert area_trapezium(15,25,35)==700"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the area of a trapezium.\n### Function signature: def area_trapezium(base1,base2,height):\n### Tests: assert area_trapezium(6,9,4)==30\n assert area_trapezium(10,20,30)==450\n### Response: "} +{"task_id":849,"text":"Write a python function to find sum of all prime divisors of a given number.","code":"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] ","test_list":["assert Sum(60) == 10","assert Sum(39) == 16","assert Sum(40) == 7"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find sum of all prime divisors of a given number.\n### Function signature: def Sum(N):\n### Tests: assert Sum(60) == 10\n assert Sum(39) == 16\n### Response: "} +{"task_id":850,"text":"Write a function to check if a triangle of positive area is possible with the given angles.","code":"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","test_list":["assert is_triangleexists(50,60,70)==True","assert is_triangleexists(90,45,45)==True","assert is_triangleexists(150,30,70)==False"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check if a triangle of positive area is possible with the given angles.\n### Function signature: def is_triangleexists(a,b,c):\n### Tests: assert is_triangleexists(50,60,70)==True\n assert is_triangleexists(90,45,45)==True\n### Response: "} +{"task_id":851,"text":"Write a python function to find sum of inverse of divisors.","code":"def Sum_of_Inverse_Divisors(N,Sum): \r\n ans = float(Sum)*1.0 \/float(N); \r\n return round(ans,2); ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find sum of inverse of divisors.\n### Function signature: def Sum_of_Inverse_Divisors(N,Sum):\n### Tests: assert Sum_of_Inverse_Divisors(6,12) == 2\n assert Sum_of_Inverse_Divisors(9,13) == 1.44\n### Response: "} +{"task_id":852,"text":"Write a python function to remove negative numbers from a list.","code":"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","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to remove negative numbers from a list.\n### Function signature: def remove_negs(num_list):\n### Tests: assert remove_negs([1,-2,3,-4]) == [1,3]\n assert remove_negs([1,2,3,-4]) == [1,2,3]\n### Response: "} +{"task_id":853,"text":"Write a python function to find sum of odd factors of a number.","code":"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 ","test_list":["assert sum_of_odd_Factors(30) == 24","assert sum_of_odd_Factors(18) == 13","assert sum_of_odd_Factors(2) == 1"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find sum of odd factors of a number.\n### Function signature: def sum_of_odd_Factors(n):\n### Tests: assert sum_of_odd_Factors(30) == 24\n assert sum_of_odd_Factors(18) == 13\n### Response: "} +{"task_id":854,"text":"Write a function which accepts an arbitrary list and converts it to a heap using heap queue algorithm.","code":"import heapq as hq\r\ndef raw_heap(rawheap):\r\n hq.heapify(rawheap)\r\n return rawheap","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function which accepts an arbitrary list and converts it to a heap using heap queue algorithm.\n### Function signature: def raw_heap(rawheap):\n### Tests: assert raw_heap([25, 44, 68, 21, 39, 23, 89])==[21, 25, 23, 44, 39, 68, 89]\n assert raw_heap([25, 35, 22, 85, 14, 65, 75, 25, 58])== [14, 25, 22, 25, 35, 65, 75, 85, 58]\n### Response: "} +{"task_id":855,"text":"Write a python function to check for even parity of a given number.","code":"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","test_list":["assert check_Even_Parity(10) == True","assert check_Even_Parity(11) == False","assert check_Even_Parity(18) == True"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check for even parity of a given number.\n### Function signature: def check_Even_Parity(x):\n### Tests: assert check_Even_Parity(10) == True\n assert check_Even_Parity(11) == False\n### Response: "} +{"task_id":856,"text":"Write a python function to find minimum adjacent swaps required to sort binary array.","code":"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 ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find minimum adjacent swaps required to sort binary array.\n### Function signature: def find_Min_Swaps(arr,n) :\n### Tests: assert find_Min_Swaps([1,0,1,0],4) == 3\n assert find_Min_Swaps([0,1,0],3) == 1\n### Response: "} +{"task_id":857,"text":"Write a function to list out the list of given strings individually using map function.","code":"def listify_list(list1):\r\n result = list(map(list,list1)) \r\n return result ","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']]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to list out the list of given strings individually using map function.\n### Function signature: def listify_list(list1):\n### Tests: assert listify_list(['Red', 'Blue', 'Black', 'White', 'Pink'])==[['R', 'e', 'd'], ['B', 'l', 'u', 'e'], ['B', 'l', 'a', 'c', 'k'], ['W', 'h', 'i', 't', 'e'], ['P', 'i', 'n', 'k']]\n assert listify_list(['python'])==[['p', 'y', 't', 'h', 'o', 'n']]\n### Response: "} +{"task_id":858,"text":"Write a function to count number of lists in a given list of lists and square the count.","code":"def count_list(input_list): \r\n return (len(input_list))**2","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to count number of lists in a given list of lists and square the count.\n### Function signature: def count_list(input_list):\n### Tests: assert count_list([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==25\n assert count_list([[1, 3], [5, 7], [9, 11], [13, 15, 17]] )==16\n### Response: "} +{"task_id":859,"text":"Write a function to generate all sublists of a given list.","code":"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","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]]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to generate all sublists of a given list.\n### Function signature: def sub_lists(my_list):\n### Tests: 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]]\n assert sub_lists(['X', 'Y', 'Z'])==[[], ['X'], ['Y'], ['Z'], ['X', 'Y'], ['X', 'Z'], ['Y', 'Z'], ['X', 'Y', 'Z']]\n### Response: "} +{"task_id":860,"text":"Write a function to check whether the given string is ending with only alphanumeric characters or not using regex.","code":"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\") ","test_list":["assert check_alphanumeric(\"dawood@\") == 'Discard'","assert check_alphanumeric(\"skdmsam326\") == 'Accept'","assert check_alphanumeric(\"cooltricks@\") == 'Discard'"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check whether the given string is ending with only alphanumeric characters or not using regex.\n### Function signature: def check_alphanumeric(string):\n### Tests: assert check_alphanumeric(\"dawood@\") == 'Discard'\n assert check_alphanumeric(\"skdmsam326\") == 'Accept'\n### Response: "} +{"task_id":861,"text":"Write a function to find all anagrams of a string in a given list of strings using lambda function.","code":"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","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\"]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find all anagrams of a string in a given list of strings using lambda function.\n### Function signature: def anagram_lambda(texts,str):\n### Tests: assert anagram_lambda([\"bcda\", \"abce\", \"cbda\", \"cbea\", \"adcb\"],\"abcd\")==['bcda', 'cbda', 'adcb']\n assert anagram_lambda([\"recitals\",\" python\"], \"articles\" )==[\"recitals\"]\n### Response: "} +{"task_id":862,"text":"Write a function to find the occurrences of n most common words in a given text.","code":"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)","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)]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the occurrences of n most common words in a given text.\n### Function signature: def n_common_words(text,n):\n### Tests: assert n_common_words(\"python is a programming language\",1)==[('python', 1)]\n assert n_common_words(\"python is a programming language\",1)==[('python', 1)]\n### Response: "} +{"task_id":863,"text":"Write a function to find the length of the longest sub-sequence such that elements in the subsequences are consecutive integers.","code":"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 ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the length of the longest sub-sequence such that elements in the subsequences are consecutive integers.\n### Function signature: def find_longest_conseq_subseq(arr, n):\n### Tests: assert find_longest_conseq_subseq([1, 2, 2, 3], 4) == 3\n assert find_longest_conseq_subseq([1, 9, 3, 10, 4, 20, 2], 7) == 4\n### Response: "} +{"task_id":864,"text":"Write a function to find palindromes in a given list of strings using lambda function.","code":"def palindrome_lambda(texts):\r\n result = list(filter(lambda x: (x == \"\".join(reversed(x))), texts))\r\n return result","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']"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find palindromes in a given list of strings using lambda function.\n### Function signature: def palindrome_lambda(texts):\n### Tests: assert palindrome_lambda([\"php\", \"res\", \"Python\", \"abcd\", \"Java\", \"aaa\"])==['php', 'aaa']\n assert palindrome_lambda([\"abcd\", \"Python\", \"abba\", \"aba\"])==['abba', 'aba']\n### Response: "} +{"task_id":865,"text":"Write a function to print n-times a list using map function.","code":"def ntimes_list(nums,n):\r\n result = map(lambda x:n*x, nums) \r\n return list(result)","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to print n-times a list using map function.\n### Function signature: def ntimes_list(nums,n):\n### Tests: assert ntimes_list([1, 2, 3, 4, 5, 6, 7],3)==[3, 6, 9, 12, 15, 18, 21]\n assert ntimes_list([1, 2, 3, 4, 5, 6, 7],4)==[4, 8, 12, 16, 20, 24, 28]\n### Response: "} +{"task_id":866,"text":"Write a function to check whether the given month name contains 31 days or not.","code":"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","test_list":["assert check_monthnumb(\"February\")==False","assert check_monthnumb(\"January\")==True","assert check_monthnumb(\"March\")==True"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check whether the given month name contains 31 days or not.\n### Function signature: def check_monthnumb(monthname2):\n### Tests: assert check_monthnumb(\"February\")==False\n assert check_monthnumb(\"January\")==True\n### Response: "} +{"task_id":867,"text":"Write a python function to add a minimum number such that the sum of array becomes even.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to add a minimum number such that the sum of array becomes even.\n### Function signature: def min_Num(arr,n):\n### Tests: assert min_Num([1,2,3,4,5,6,7,8,9],9) == 1\n assert min_Num([1,2,3,4,5,6,7,8],8) == 2\n### Response: "} +{"task_id":868,"text":"Write a python function to find the length of the last word in a given string.","code":"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 ","test_list":["assert length_Of_Last_Word(\"python language\") == 8","assert length_Of_Last_Word(\"PHP\") == 3","assert length_Of_Last_Word(\"\") == 0"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the length of the last word in a given string.\n### Function signature: def length_Of_Last_Word(a):\n### Tests: assert length_Of_Last_Word(\"python language\") == 8\n assert length_Of_Last_Word(\"PHP\") == 3\n### Response: "} +{"task_id":869,"text":"Write a function to remove sublists from a given list of lists, which are outside a given range.","code":"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","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]]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to remove sublists from a given list of lists, which are outside a given range.\n### Function signature: def remove_list_range(list1, leftrange, rigthrange):\n### Tests: 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]]\n 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]]\n### Response: "} +{"task_id":870,"text":"Write a function to calculate the sum of the positive numbers of a given list of numbers using lambda function.","code":"def sum_positivenum(nums):\r\n sum_positivenum = list(filter(lambda nums:nums>0,nums))\r\n return sum(sum_positivenum)","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to calculate the sum of the positive numbers of a given list of numbers using lambda function.\n### Function signature: def sum_positivenum(nums):\n### Tests: assert sum_positivenum([2, 4, -6, -9, 11, -12, 14, -5, 17])==48\n assert sum_positivenum([10,15,-14,13,-18,12,-20])==50\n### Response: "} +{"task_id":871,"text":"Write a python function to check whether the given strings are rotations of each other or not.","code":"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","test_list":["assert are_Rotations(\"abc\",\"cba\") == False","assert are_Rotations(\"abcd\",\"cdba\") == False","assert are_Rotations(\"abacd\",\"cdaba\") == True"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check whether the given strings are rotations of each other or not.\n### Function signature: def are_Rotations(string1,string2):\n### Tests: assert are_Rotations(\"abc\",\"cba\") == False\n assert are_Rotations(\"abcd\",\"cdba\") == False\n### Response: "} +{"task_id":872,"text":"Write a function to check if a nested list is a subset of another nested list.","code":"def check_subset(list1,list2): \r\n return all(map(list1.__contains__,list2)) ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check if a nested list is a subset of another nested list.\n### Function signature: def check_subset(list1,list2):\n### Tests: assert check_subset([[1, 3], [5, 7], [9, 11], [13, 15, 17]] ,[[1, 3],[13,15,17]])==True\n assert check_subset([[1, 2], [2, 3], [3, 4], [5, 6]],[[3, 4], [5, 6]])==True\n### Response: "} +{"task_id":873,"text":"Write a function to solve the fibonacci sequence using recursion.","code":"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)))","test_list":["assert fibonacci(7) == 13","assert fibonacci(8) == 21","assert fibonacci(9) == 34"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to solve the fibonacci sequence using recursion.\n### Function signature: def fibonacci(n):\n### Tests: assert fibonacci(7) == 13\n assert fibonacci(8) == 21\n### Response: "} +{"task_id":874,"text":"Write a python function to check if the string is a concatenation of another string.","code":"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","test_list":["assert check_Concat(\"abcabcabc\",\"abc\") == True","assert check_Concat(\"abcab\",\"abc\") == False","assert check_Concat(\"aba\",\"ab\") == False"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check if the string is a concatenation of another string.\n### Function signature: def check_Concat(str1,str2):\n### Tests: assert check_Concat(\"abcabcabc\",\"abc\") == True\n assert check_Concat(\"abcab\",\"abc\") == False\n### Response: "} +{"task_id":875,"text":"Write a function to find the minimum difference in the tuple pairs of given tuples.","code":"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) ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the minimum difference in the tuple pairs of given tuples.\n### Function signature: def min_difference(test_list):\n### Tests: assert min_difference([(3, 5), (1, 7), (10, 3), (1, 2)]) == 1\n assert min_difference([(4, 6), (12, 8), (11, 4), (2, 13)]) == 2\n### Response: "} +{"task_id":876,"text":"Write a python function to find lcm of two positive integers.","code":"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","test_list":["assert lcm(4,6) == 12","assert lcm(15,17) == 255","assert lcm(2,6) == 6"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find lcm of two positive integers.\n### Function signature: def lcm(x, y):\n### Tests: assert lcm(4,6) == 12\n assert lcm(15,17) == 255\n### Response: "} +{"task_id":877,"text":"Write a python function to sort the given string.","code":"def sort_String(str) : \r\n str = ''.join(sorted(str)) \r\n return (str) ","test_list":["assert sort_String(\"cba\") == \"abc\"","assert sort_String(\"data\") == \"aadt\"","assert sort_String(\"zxy\") == \"xyz\""],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to sort the given string.\n### Function signature: def sort_String(str) :\n### Tests: assert sort_String(\"cba\") == \"abc\"\n assert sort_String(\"data\") == \"aadt\"\n### Response: "} +{"task_id":878,"text":"Write a function to check if the given tuple contains only k elements.","code":"def check_tuples(test_tuple, K):\r\n res = all(ele in K for ele in test_tuple)\r\n return (res) ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check if the given tuple contains only k elements.\n### Function signature: def check_tuples(test_tuple, K):\n### Tests: assert check_tuples((3, 5, 6, 5, 3, 6),[3, 6, 5]) == True\n assert check_tuples((4, 5, 6, 4, 6, 5),[4, 5, 6]) == True\n### Response: "} +{"task_id":879,"text":"Write a function that matches a string that has an 'a' followed by anything, ending in 'b' by using regex.","code":"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!')","test_list":["assert text_match(\"aabbbbd\") == 'Not matched!'","assert text_match(\"aabAbbbc\") == 'Not matched!'","assert text_match(\"accddbbjjjb\") == 'Found a match!'"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function that matches a string that has an 'a' followed by anything, ending in 'b' by using regex.\n### Function signature: def text_match(text):\n### Tests: assert text_match(\"aabbbbd\") == 'Not matched!'\n assert text_match(\"aabAbbbc\") == 'Not matched!'\n### Response: "} +{"task_id":880,"text":"Write a python function to find number of solutions in quadratic equation.","code":"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\") ","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\""],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find number of solutions in quadratic equation.\n### Function signature: def Check_Solution(a,b,c) :\n### Tests: assert Check_Solution(2,5,2) == \"2 solutions\"\n assert Check_Solution(1,1,1) == \"No solutions\"\n### Response: "} +{"task_id":881,"text":"Write a function to find the sum of first even and odd number of a given list.","code":"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)","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the sum of first even and odd number of a given list.\n### Function signature: def sum_even_odd(list1):\n### Tests: assert sum_even_odd([1,3,5,7,4,1,6,8])==5\n assert sum_even_odd([1,2,3,4,5,6,7,8,9,10])==3\n### Response: "} +{"task_id":882,"text":"Write a function to caluclate perimeter of a parallelogram.","code":"def parallelogram_perimeter(b,h):\r\n perimeter=2*(b*h)\r\n return perimeter","test_list":["assert parallelogram_perimeter(10,20)==400","assert parallelogram_perimeter(15,20)==600","assert parallelogram_perimeter(8,9)==144"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to caluclate perimeter of a parallelogram.\n### Function signature: def parallelogram_perimeter(b,h):\n### Tests: assert parallelogram_perimeter(10,20)==400\n assert parallelogram_perimeter(15,20)==600\n### Response: "} +{"task_id":883,"text":"Write a function to find numbers divisible by m and n from a list of numbers using lambda function.","code":"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","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find numbers divisible by m and n from a list of numbers using lambda function.\n### Function signature: def div_of_nums(nums,m,n):\n### Tests: assert div_of_nums([19, 65, 57, 39, 152, 639, 121, 44, 90, 190],2,4)==[ 152,44]\n assert div_of_nums([1, 2, 3, 5, 7, 8, 10],2,5)==[10]\n### Response: "} +{"task_id":884,"text":"Write a python function to check whether all the bits are within a given range or not.","code":"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","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 "],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check whether all the bits are within a given range or not.\n### Function signature: def all_Bits_Set_In_The_Given_Range(n,l,r):\n### Tests: assert all_Bits_Set_In_The_Given_Range(10,2,1) == True \n assert all_Bits_Set_In_The_Given_Range(5,2,4) == False\n### Response: "} +{"task_id":885,"text":"Write a python function to check whether the two given strings are isomorphic to each other or not.","code":"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","test_list":["assert is_Isomorphic(\"paper\",\"title\") == True","assert is_Isomorphic(\"ab\",\"ba\") == True","assert is_Isomorphic(\"ab\",\"aa\") == False"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check whether the two given strings are isomorphic to each other or not.\n### Function signature: def is_Isomorphic(str1,str2):\n### Tests: assert is_Isomorphic(\"paper\",\"title\") == True\n assert is_Isomorphic(\"ab\",\"ba\") == True\n### Response: "} +{"task_id":886,"text":"Write a function to add all the numbers in a list and divide it with the length of the list.","code":"def sum_num(numbers):\r\n total = 0\r\n for x in numbers:\r\n total += x\r\n return total\/len(numbers) ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to add all the numbers in a list and divide it with the length of the list.\n### Function signature: def sum_num(numbers):\n### Tests: assert sum_num((8, 2, 3, 0, 7))==4.0\n assert sum_num((-10,-20,-30))==-20.0\n### Response: "} +{"task_id":887,"text":"Write a python function to check whether the given number is odd or not using bitwise operator.","code":"def is_odd(n) : \r\n if (n^1 == n-1) :\r\n return True; \r\n else :\r\n return False; ","test_list":["assert is_odd(5) == True","assert is_odd(6) == False","assert is_odd(7) == True"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check whether the given number is odd or not using bitwise operator.\n### Function signature: def is_odd(n) :\n### Tests: assert is_odd(5) == True\n assert is_odd(6) == False\n### Response: "} +{"task_id":888,"text":"Write a function to substract the elements of the given nested tuples.","code":"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) ","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))"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to substract the elements of the given nested tuples.\n### Function signature: def substract_elements(test_tup1, test_tup2):\n### Tests: 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))\n 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))\n### Response: "} +{"task_id":889,"text":"Write a function to reverse each list in a given list of lists.","code":"def reverse_list_lists(lists):\r\n for l in lists:\r\n l.sort(reverse = True)\r\n return lists ","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]]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to reverse each list in a given list of lists.\n### Function signature: def reverse_list_lists(lists):\n### Tests: 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]]\n assert reverse_list_lists([[1,2],[2,3],[3,4]])==[[2,1],[3,2],[4,3]]\n### Response: "} +{"task_id":890,"text":"Write a python function to find the index of an extra element present in one sorted array.","code":"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 ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the index of an extra element present in one sorted array.\n### Function signature: def find_Extra(arr1,arr2,n) :\n### Tests: assert find_Extra([1,2,3,4],[1,2,3],3) == 3\n assert find_Extra([2,4,6,8,10],[2,4,6,8],4) == 4\n### Response: "} +{"task_id":891,"text":"Write a python function to check whether the given two numbers have same number of digits or not.","code":"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; ","test_list":["assert same_Length(12,1) == False","assert same_Length(2,2) == True","assert same_Length(10,20) == True"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check whether the given two numbers have same number of digits or not.\n### Function signature: def same_Length(A,B):\n### Tests: assert same_Length(12,1) == False\n assert same_Length(2,2) == True\n### Response: "} +{"task_id":892,"text":"Write a function to remove multiple spaces in a string.","code":"import re\r\ndef remove_spaces(text):\r\n return (re.sub(' +',' ',text))","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')"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to remove multiple spaces in a string.\n### Function signature: def remove_spaces(text):\n### Tests: assert remove_spaces('python program')==('python program')\n assert remove_spaces('python programming language')==('python programming language')\n### Response: "} +{"task_id":893,"text":"Write a python function to get the last element of each sublist.","code":"def Extract(lst): \r\n return [item[-1] for item in lst] ","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to get the last element of each sublist.\n### Function signature: def Extract(lst):\n### Tests: assert Extract([[1, 2, 3], [4, 5], [6, 7, 8, 9]]) == [3, 5, 9]\n assert Extract([['x', 'y', 'z'], ['m'], ['a', 'b'], ['u', 'v']]) == ['z', 'm', 'b', 'v']\n### Response: "} +{"task_id":894,"text":"Write a function to convert the given string of float type into tuple.","code":"def float_to_tuple(test_str):\r\n res = tuple(map(float, test_str.split(', ')))\r\n return (res) ","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)"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to convert the given string of float type into tuple.\n### Function signature: def float_to_tuple(test_str):\n### Tests: assert float_to_tuple(\"1.2, 1.3, 2.3, 2.4, 6.5\") == (1.2, 1.3, 2.3, 2.4, 6.5)\n assert float_to_tuple(\"2.3, 2.4, 5.6, 5.4, 8.9\") == (2.3, 2.4, 5.6, 5.4, 8.9)\n### Response: "} +{"task_id":895,"text":"Write a function to find the maximum sum of subsequences of given array with no adjacent elements.","code":"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]","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the maximum sum of subsequences of given array with no adjacent elements.\n### Function signature: def max_sum_subseq(A):\n### Tests: assert max_sum_subseq([1, 2, 9, 4, 5, 0, 4, 11, 6]) == 26\n assert max_sum_subseq([1, 2, 9, 5, 6, 0, 5, 12, 7]) == 28\n### Response: "} +{"task_id":896,"text":"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.","code":"def last(n):\r\n return n[-1]\r\ndef sort_list_last(tuples):\r\n return sorted(tuples, key=last)","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)] "],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: 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.\n### Function signature: def sort_list_last(tuples):\n### Tests: assert sort_list_last([(2, 5), (1, 2), (4, 4), (2, 3), (2, 1)])==[(2, 1), (1, 2), (2, 3), (4, 4), (2, 5)] \n assert sort_list_last([(9,8), (4, 7), (3,5), (7,9), (1,2)])==[(1,2), (3,5), (4,7), (9,8), (7,9)] \n### Response: "} +{"task_id":897,"text":"Write a python function to check whether the word is present in a given sentence or not.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check whether the word is present in a given sentence or not.\n### Function signature: def is_Word_Present(sentence,word):\n### Tests: assert is_Word_Present(\"machine learning\",\"machine\") == True\n assert is_Word_Present(\"easy\",\"fun\") == False\n### Response: "} +{"task_id":898,"text":"Write a function to extract specified number of elements from a given list, which follow each other continuously.","code":"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","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to extract specified number of elements from a given list, which follow each other continuously.\n### Function signature: def extract_elements(numbers, n):\n### Tests: assert extract_elements([1, 1, 3, 4, 4, 5, 6, 7],2)==[1, 4]\n assert extract_elements([0, 1, 2, 3, 4, 4, 4, 4, 5, 7],4)==[4]\n### Response: "} +{"task_id":899,"text":"Write a python function to check whether an array can be sorted or not by picking only the corner elements.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check whether an array can be sorted or not by picking only the corner elements.\n### Function signature: def check(arr,n):\n### Tests: assert check([3,2,1,2,3,4],6) == True\n assert check([2,1,4,5,1],5) == True\n### Response: "} +{"task_id":900,"text":"Write a function where a string will start with a specific number.","code":"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","test_list":["assert match_num('5-2345861')==True","assert match_num('6-2345861')==False","assert match_num('78910')==False"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function where a string will start with a specific number.\n### Function signature: def match_num(string):\n### Tests: assert match_num('5-2345861')==True\n assert match_num('6-2345861')==False\n### Response: "} +{"task_id":901,"text":"Write a function to find the smallest multiple of the first n numbers.","code":"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","test_list":["assert smallest_multiple(13)==360360","assert smallest_multiple(2)==2","assert smallest_multiple(1)==1"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the smallest multiple of the first n numbers.\n### Function signature: def smallest_multiple(n):\n### Tests: assert smallest_multiple(13)==360360\n assert smallest_multiple(2)==2\n### Response: "} +{"task_id":902,"text":"Write a function to combine two dictionaries by adding values for common keys.","code":"from collections import Counter\r\ndef add_dict(d1,d2):\r\n add_dict = Counter(d1) + Counter(d2)\r\n return add_dict","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})"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to combine two dictionaries by adding values for common keys.\n### Function signature: def add_dict(d1,d2):\n### Tests: assert add_dict({'a': 100, 'b': 200, 'c':300},{'a': 300, 'b': 200, 'd':400})==({'b': 400, 'd': 400, 'a': 400, 'c': 300}) \n assert add_dict({'a': 500, 'b': 700, 'c':900},{'a': 500, 'b': 600, 'd':900})==({'b': 1300, 'd': 900, 'a': 1000, 'c': 900}) \n### Response: "} +{"task_id":903,"text":"Write a python function to count the total unset bits from 1 to n.","code":"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; ","test_list":["assert count_Unset_Bits(2) == 1","assert count_Unset_Bits(5) == 4","assert count_Unset_Bits(14) == 17"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to count the total unset bits from 1 to n.\n### Function signature: def count_Unset_Bits(n) :\n### Tests: assert count_Unset_Bits(2) == 1\n assert count_Unset_Bits(5) == 4\n### Response: "} +{"task_id":904,"text":"Write a function to return true if the given number is even else return false.","code":"def even_num(x):\r\n if x%2==0:\r\n return True\r\n else:\r\n return False","test_list":["assert even_num(13.5)==False","assert even_num(0)==True","assert even_num(-9)==False"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to return true if the given number is even else return false.\n### Function signature: def even_num(x):\n### Tests: assert even_num(13.5)==False\n assert even_num(0)==True\n### Response: "} +{"task_id":905,"text":"Write a python function to find the sum of squares of binomial co-efficients.","code":"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)) ","test_list":["assert sum_of_square(4) == 70","assert sum_of_square(5) == 252","assert sum_of_square(2) == 6"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the sum of squares of binomial co-efficients.\n### Function signature: def sum_of_square(n):\n### Tests: assert sum_of_square(4) == 70\n assert sum_of_square(5) == 252\n### Response: "} +{"task_id":906,"text":"Write a function to extract year, month and date from a url by using regex.","code":"import re\r\ndef extract_date(url):\r\n return re.findall(r'\/(\\d{4})\/(\\d{1,2})\/(\\d{1,2})\/', url)","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')]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to extract year, month and date from a url by using regex.\n### Function signature: def extract_date(url):\n### Tests: 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')]\n 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')]\n### Response: "} +{"task_id":907,"text":"Write a function to print the first n lucky numbers.","code":"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]","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to print the first n lucky numbers.\n### Function signature: def lucky_num(n):\n### Tests: assert lucky_num(10)==[1, 3, 7, 9, 13, 15, 21, 25, 31, 33] \n assert lucky_num(5)==[1, 3, 7, 9, 13]\n### Response: "} +{"task_id":908,"text":"Write a function to find the fixed point in the given array.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the fixed point in the given array.\n### Function signature: def find_fixed_point(arr, n):\n### Tests: assert find_fixed_point([-10, -1, 0, 3, 10, 11, 30, 50, 100],9) == 3\n assert find_fixed_point([1, 2, 3, 4, 5, 6, 7, 8],8) == -1\n### Response: "} +{"task_id":909,"text":"Write a function to find the previous palindrome of a specified number.","code":"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","test_list":["assert previous_palindrome(99)==88","assert previous_palindrome(1221)==1111","assert previous_palindrome(120)==111"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the previous palindrome of a specified number.\n### Function signature: def previous_palindrome(num):\n### Tests: assert previous_palindrome(99)==88\n assert previous_palindrome(1221)==1111\n### Response: "} +{"task_id":910,"text":"Write a function to validate a gregorian date.","code":"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","test_list":["assert check_date(11,11,2002)==True","assert check_date(13,11,2002)==False","assert check_date('11','11','2002')==True"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to validate a gregorian date.\n### Function signature: def check_date(m, d, y):\n### Tests: assert check_date(11,11,2002)==True\n assert check_date(13,11,2002)==False\n### Response: "} +{"task_id":911,"text":"Write a function to compute maximum product of three numbers of a given array of integers using heap queue algorithm.","code":"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])","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to compute maximum product of three numbers of a given array of integers using heap queue algorithm.\n### Function signature: def maximum_product(nums):\n### Tests: assert maximum_product( [12, 74, 9, 50, 61, 41])==225700\n assert maximum_product([25, 35, 22, 85, 14, 65, 75, 25, 58])==414375\n### Response: "} +{"task_id":912,"text":"Write a function to find ln, m lobb number.","code":"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))","test_list":["assert int(lobb_num(5, 3)) == 35","assert int(lobb_num(3, 2)) == 5","assert int(lobb_num(4, 2)) == 20"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find ln, m lobb number.\n### Function signature: def lobb_num(n, m):\n### Tests: assert int(lobb_num(5, 3)) == 35\n assert int(lobb_num(3, 2)) == 5\n### Response: "} +{"task_id":913,"text":"Write a function to check for a number at the end of a string.","code":"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","test_list":["assert end_num('abcdef')==False","assert end_num('abcdef7')==True","assert end_num('abc')==False"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check for a number at the end of a string.\n### Function signature: def end_num(string):\n### Tests: assert end_num('abcdef')==False\n assert end_num('abcdef7')==True\n### Response: "} +{"task_id":914,"text":"Write a python function to check whether the given string is made up of two alternating characters or not.","code":"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","test_list":["assert is_Two_Alter(\"abab\") == True","assert is_Two_Alter(\"aaaa\") == False","assert is_Two_Alter(\"xyz\") == False"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check whether the given string is made up of two alternating characters or not.\n### Function signature: def is_Two_Alter(s):\n### Tests: assert is_Two_Alter(\"abab\") == True\n assert is_Two_Alter(\"aaaa\") == False\n### Response: "} +{"task_id":915,"text":"Write a function to rearrange positive and negative numbers in a given array using lambda function.","code":"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 ","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to rearrange positive and negative numbers in a given array using lambda function.\n### Function signature: def rearrange_numbs(array_nums):\n### Tests: assert rearrange_numbs([-1, 2, -3, 5, 7, 8, 9, -10])==[2, 5, 7, 8, 9, -10, -3, -1]\n assert rearrange_numbs([10,15,14,13,-18,12,-20])==[10, 12, 13, 14, 15, -20, -18]\n### Response: "} +{"task_id":916,"text":"Write a function to find if there is a triplet in the array whose sum is equal to a given value.","code":"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","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)"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find if there is a triplet in the array whose sum is equal to a given value.\n### Function signature: def find_triplet_array(A, arr_size, sum):\n### Tests: assert find_triplet_array([1, 4, 45, 6, 10, 8], 6, 22) == (4, 10, 8)\n assert find_triplet_array([12, 3, 5, 2, 6, 9], 6, 24) == (12, 3, 9)\n### Response: "} +{"task_id":917,"text":"Write a function to find the sequences of one upper case letter followed by lower case letters.","code":"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!')","test_list":["assert text_uppercase_lowercase(\"AaBbGg\")==('Found a match!')","assert text_uppercase_lowercase(\"aA\")==('Not matched!')","assert text_uppercase_lowercase(\"PYTHON\")==('Not matched!')"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the sequences of one upper case letter followed by lower case letters.\n### Function signature: def text_uppercase_lowercase(text):\n### Tests: assert text_uppercase_lowercase(\"AaBbGg\")==('Found a match!')\n assert text_uppercase_lowercase(\"aA\")==('Not matched!')\n### Response: "} +{"task_id":918,"text":"Write a function to count coin change.","code":"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] ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to count coin change.\n### Function signature: def coin_change(S, m, n):\n### Tests: assert coin_change([1, 2, 3],3,4)==4\n assert coin_change([4,5,6,7,8,9],6,9)==2\n### Response: "} +{"task_id":919,"text":"Write a python function to multiply all items in the list.","code":"def multiply_list(items):\r\n tot = 1\r\n for x in items:\r\n tot *= x\r\n return tot","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to multiply all items in the list.\n### Function signature: def multiply_list(items):\n### Tests: assert multiply_list([1,-2,3]) == -6\n assert multiply_list([1,2,3,4]) == 24\n### Response: "} +{"task_id":920,"text":"Write a function to remove all tuples with all none values in the given tuple list.","code":"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)) ","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)]'"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to remove all tuples with all none values in the given tuple list.\n### Function signature: def remove_tuple(test_list):\n### Tests: assert remove_tuple([(None, 2), (None, None), (3, 4), (12, 3), (None, )] ) == '[(None, 2), (3, 4), (12, 3)]'\n assert remove_tuple([(None, None), (None, None), (3, 6), (17, 3), (None,1 )] ) == '[(3, 6), (17, 3), (None, 1)]'\n### Response: "} +{"task_id":921,"text":"Write a function to perform chunking of tuples each of size n.","code":"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) ","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)]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to perform chunking of tuples each of size n.\n### Function signature: def chunk_tuples(test_tup, N):\n### Tests: assert chunk_tuples((10, 4, 5, 6, 7, 6, 8, 3, 4), 3) == [(10, 4, 5), (6, 7, 6), (8, 3, 4)]\n assert chunk_tuples((1, 2, 3, 4, 5, 6, 7, 8, 9), 2) == [(1, 2), (3, 4), (5, 6), (7, 8), (9,)]\n### Response: "} +{"task_id":922,"text":"Write a function to find a pair with the highest product from a given array of integers.","code":"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 ","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)"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find a pair with the highest product from a given array of integers.\n### Function signature: def max_product(arr):\n### Tests: assert max_product([1, 2, 3, 4, 7, 0, 8, 4])==(7, 8)\n assert max_product([0, -1, -2, -4, 5, 0, -6])==(-4, -6)\n### Response: "} +{"task_id":923,"text":"Write a function to find the length of the shortest string that has both str1 and str2 as subsequences.","code":"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))","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the length of the shortest string that has both str1 and str2 as subsequences.\n### Function signature: def super_seq(X, Y, m, n):\n### Tests: assert super_seq(\"AGGTAB\", \"GXTXAYB\", 6, 7) == 9\n assert super_seq(\"feek\", \"eke\", 4, 3) == 5\n### Response: "} +{"task_id":924,"text":"Write a function to find maximum of two numbers.","code":"def max_of_two( x, y ):\r\n if x > y:\r\n return x\r\n return y","test_list":["assert max_of_two(10,20)==20","assert max_of_two(19,15)==19","assert max_of_two(-10,-20)==-10"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find maximum of two numbers.\n### Function signature: def max_of_two( x, y ):\n### Tests: assert max_of_two(10,20)==20\n assert max_of_two(19,15)==19\n### Response: "} +{"task_id":925,"text":"Write a python function to calculate the product of all the numbers of a given tuple.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to calculate the product of all the numbers of a given tuple.\n### Function signature: def mutiple_tuple(nums):\n### Tests: assert mutiple_tuple((4, 3, 2, 2, -1, 18)) == -864\n assert mutiple_tuple((1,2,3)) == 6\n### Response: "} +{"task_id":926,"text":"Write a function to find n-th rencontres number.","code":"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))","test_list":["assert rencontres_number(7, 2) == 924","assert rencontres_number(3, 0) == 2","assert rencontres_number(3, 1) == 3"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find n-th rencontres number.\n### Function signature: def rencontres_number(n, m):\n### Tests: assert rencontres_number(7, 2) == 924\n assert rencontres_number(3, 0) == 2\n### Response: "} +{"task_id":927,"text":"Write a function to calculate the height of the given binary tree.","code":"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","test_list":["assert (max_height(root)) == 3","assert (max_height(root1)) == 5 ","assert (max_height(root2)) == 4"],"test_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)","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to calculate the height of the given binary tree.\n### Function signature: def max_height(node):\n### Tests: assert (max_height(root)) == 3\n assert (max_height(root1)) == 5 \n### Response: "} +{"task_id":928,"text":"Write a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format.","code":"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)","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'"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format.\n### Function signature: def change_date_format(dt):\n### Tests: assert change_date_format('2026-01-02')=='02-01-2026'\n assert change_date_format('2021-01-04')=='04-01-2021'\n### Response: "} +{"task_id":929,"text":"Write a function to count repeated items of a tuple.","code":"def count_tuplex(tuplex,value): \r\n count = tuplex.count(value)\r\n return count","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to count repeated items of a tuple.\n### Function signature: def count_tuplex(tuplex,value):\n### Tests: assert count_tuplex((2, 4, 5, 6, 2, 3, 4, 4, 7),4)==3\n assert count_tuplex((2, 4, 5, 6, 2, 3, 4, 4, 7),2)==2\n### Response: "} +{"task_id":930,"text":"Write a function that matches a string that has an a followed by zero or more b's by using regex.","code":"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!')","test_list":["assert text_match(\"msb\") == 'Not matched!'","assert text_match(\"a0c\") == 'Found a match!'","assert text_match(\"abbc\") == 'Found a match!'"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function that matches a string that has an a followed by zero or more b's by using regex.\n### Function signature: def text_match(text):\n### Tests: assert text_match(\"msb\") == 'Not matched!'\n assert text_match(\"a0c\") == 'Found a match!'\n### Response: "} +{"task_id":931,"text":"Write a function to calculate the sum of series 1\u00b3+2\u00b3+3\u00b3+\u2026.+n\u00b3.","code":"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","test_list":["assert sum_series(7)==784","assert sum_series(5)==225","assert sum_series(15)==14400"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to calculate the sum of series 1\u00b3+2\u00b3+3\u00b3+\u2026.+n\u00b3.\n### Function signature: def sum_series(number):\n### Tests: assert sum_series(7)==784\n assert sum_series(5)==225\n### Response: "} +{"task_id":932,"text":"Write a function to remove duplicate words from a given list of strings.","code":"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","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']"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to remove duplicate words from a given list of strings.\n### Function signature: def remove_duplic_list(l):\n### Tests: assert remove_duplic_list([\"Python\", \"Exercises\", \"Practice\", \"Solution\", \"Exercises\"])==['Python', 'Exercises', 'Practice', 'Solution']\n assert remove_duplic_list([\"Python\", \"Exercises\", \"Practice\", \"Solution\", \"Exercises\",\"Java\"])==['Python', 'Exercises', 'Practice', 'Solution', 'Java']\n### Response: "} +{"task_id":933,"text":"Write a function to convert camel case string to snake case string by using regex.","code":"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()","test_list":["assert camel_to_snake('GoogleAssistant') == 'google_assistant'","assert camel_to_snake('ChromeCast') == 'chrome_cast'","assert camel_to_snake('QuadCore') == 'quad_core'"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to convert camel case string to snake case string by using regex.\n### Function signature: def camel_to_snake(text):\n### Tests: assert camel_to_snake('GoogleAssistant') == 'google_assistant'\n assert camel_to_snake('ChromeCast') == 'chrome_cast'\n### Response: "} +{"task_id":934,"text":"Write a function to find the nth delannoy number.","code":"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)","test_list":["assert dealnnoy_num(3, 4) == 129","assert dealnnoy_num(3, 3) == 63","assert dealnnoy_num(4, 5) == 681"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the nth delannoy number.\n### Function signature: def dealnnoy_num(n, m):\n### Tests: assert dealnnoy_num(3, 4) == 129\n assert dealnnoy_num(3, 3) == 63\n### Response: "} +{"task_id":935,"text":"Write a function to calculate the sum of series 1\u00b2+2\u00b2+3\u00b2+\u2026.+n\u00b2.","code":"def series_sum(number):\r\n total = 0\r\n total = (number * (number + 1) * (2 * number + 1)) \/ 6\r\n return total","test_list":["assert series_sum(6)==91","assert series_sum(7)==140","assert series_sum(12)==650"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to calculate the sum of series 1\u00b2+2\u00b2+3\u00b2+\u2026.+n\u00b2.\n### Function signature: def series_sum(number):\n### Tests: assert series_sum(6)==91\n assert series_sum(7)==140\n### Response: "} +{"task_id":936,"text":"Write a function to re-arrange the given tuples based on the given ordered list.","code":"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) ","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)]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to re-arrange the given tuples based on the given ordered list.\n### Function signature: def re_arrange_tuples(test_list, ord_list):\n### Tests: assert re_arrange_tuples([(4, 3), (1, 9), (2, 10), (3, 2)], [1, 4, 2, 3]) == [(1, 9), (4, 3), (2, 10), (3, 2)]\n assert re_arrange_tuples([(5, 4), (2, 10), (3, 11), (4, 3)], [3, 4, 2, 3]) == [(3, 11), (4, 3), (2, 10), (3, 11)]\n### Response: "} +{"task_id":937,"text":"Write a function to count the most common character in a given string.","code":"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","test_list":["assert max_char(\"hello world\")==('l')","assert max_char(\"hello \")==('l')","assert max_char(\"python pr\")==('p')"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to count the most common character in a given string.\n### Function signature: def max_char(str1):\n### Tests: assert max_char(\"hello world\")==('l')\n assert max_char(\"hello \")==('l')\n### Response: "} +{"task_id":938,"text":"Write a function to find three closest elements from three sorted arrays.","code":"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]","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)"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find three closest elements from three sorted arrays.\n### Function signature: def find_closet(A, B, C, p, q, r):\n### Tests: assert find_closet([1, 4, 10],[2, 15, 20],[10, 12],3,3,2) == (10, 15, 10)\n assert find_closet([20, 24, 100],[2, 19, 22, 79, 800],[10, 12, 23, 24, 119],3,5,5) == (24, 22, 23)\n### Response: "} +{"task_id":939,"text":"Write a function to sort a list of dictionaries using lambda function.","code":"def sorted_models(models):\r\n sorted_models = sorted(models, key = lambda x: x['color'])\r\n return sorted_models","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'}])"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to sort a list of dictionaries using lambda function.\n### Function signature: def sorted_models(models):\n### Tests: 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'}]\n 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'}])\n### Response: "} +{"task_id":940,"text":"Write a function to sort the given array by using heap sort.","code":"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","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to sort the given array by using heap sort.\n### Function signature: def shift_down(arr, start, end):\n### Tests: assert heap_sort([12, 2, 4, 5, 2, 3]) == [2, 2, 3, 4, 5, 12]\n assert heap_sort([32, 14, 5, 6, 7, 19]) == [5, 6, 7, 14, 19, 32]\n### Response: "} +{"task_id":941,"text":"Write a function to count the elements in a list until an element is a tuple.","code":"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","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to count the elements in a list until an element is a tuple.\n### Function signature: def count_elim(num):\n### Tests: assert count_elim([10,20,30,(10,20),40])==3\n assert count_elim([10,(20,30),(10,20),40])==1\n### Response: "} +{"task_id":942,"text":"Write a function to check if any list element is present in the given list.","code":"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) ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to check if any list element is present in the given list.\n### Function signature: def check_element(test_tup, check_list):\n### Tests: assert check_element((4, 5, 7, 9, 3), [6, 7, 10, 11]) == True\n assert check_element((1, 2, 3, 4), [4, 6, 7, 8, 9]) == True\n### Response: "} +{"task_id":943,"text":"Write a function to combine two given sorted lists using heapq module.","code":"from heapq import merge\r\ndef combine_lists(num1,num2):\r\n combine_lists=list(merge(num1, num2))\r\n return combine_lists","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]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to combine two given sorted lists using heapq module.\n### Function signature: def combine_lists(num1,num2):\n### Tests: 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]\n assert combine_lists([1, 3, 5, 6, 8, 9], [2, 5, 7, 11])==[1,2,3,5,5,6,7,8,9,11]\n### Response: "} +{"task_id":944,"text":"Write a function to separate and print the numbers and their position of a given string.","code":"import re\r\ndef num_position(text):\r\n for m in re.finditer(\"\\d+\", text):\r\n return m.start()","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to separate and print the numbers and their position of a given string.\n### Function signature: def num_position(text):\n### Tests: assert num_position(\"there are 70 flats in this apartment\")==10\n assert num_position(\"every adult have 32 teeth\")==17\n### Response: "} +{"task_id":945,"text":"Write a function to convert the given tuples into set.","code":"def tuple_to_set(t):\r\n s = set(t)\r\n return (s) ","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'}"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to convert the given tuples into set.\n### Function signature: def tuple_to_set(t):\n### Tests: assert tuple_to_set(('x', 'y', 'z') ) == {'y', 'x', 'z'}\n assert tuple_to_set(('a', 'b', 'c') ) == {'c', 'a', 'b'}\n### Response: "} +{"task_id":946,"text":"Write a function to find the most common elements and their counts of a specified text.","code":"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","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)]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the most common elements and their counts of a specified text.\n### Function signature: def most_common_elem(s,a):\n### Tests: assert most_common_elem('lkseropewdssafsdfafkpwe',3)==[('s', 4), ('e', 3), ('f', 3)] \n assert most_common_elem('lkseropewdssafsdfafkpwe',2)==[('s', 4), ('e', 3)]\n### Response: "} +{"task_id":947,"text":"Write a python function to find the length of the shortest word.","code":"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] ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to compute the value of ncr mod p.\n### Function signature: def nCr_mod_p(n, r, p):\n### Tests: assert nCr_mod_p(10, 2, 13) == 6\n assert nCr_mod_p(11, 3, 14) == 11\n### Response: "} +{"task_id":953,"text":"Write a python function to find the minimun number of subsets with distinct elements.","code":"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 ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the minimun number of subsets with distinct elements.\n### Function signature: def subset(ar, n):\n### Tests: assert subset([1, 2, 3, 4],4) == 1\n assert subset([5, 6, 9, 3, 4, 3, 4],7) == 2\n### Response: "} +{"task_id":954,"text":"Write a function that gives profit amount if the given amount has profit else return none.","code":"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","test_list":["assert profit_amount(1500,1200)==300","assert profit_amount(100,200)==None","assert profit_amount(2000,5000)==None"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function that gives profit amount if the given amount has profit else return none.\n### Function signature: def profit_amount(actual_cost,sale_amount):\n### Tests: assert profit_amount(1500,1200)==300\n assert profit_amount(100,200)==None\n### Response: "} +{"task_id":955,"text":"Write a function to find out, if the given number is abundant.","code":"def is_abundant(n):\r\n fctrsum = sum([fctr for fctr in range(1, n) if n % fctr == 0])\r\n return fctrsum > n","test_list":["assert is_abundant(12)==True","assert is_abundant(13)==False","assert is_abundant(9)==False"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find out, if the given number is abundant.\n### Function signature: def is_abundant(n):\n### Tests: assert is_abundant(12)==True\n assert is_abundant(13)==False\n### Response: "} +{"task_id":956,"text":"Write a function to split the given string at uppercase letters by using regex.","code":"import re\r\ndef split_list(text):\r\n return (re.findall('[A-Z][^A-Z]*', text))","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']"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to split the given string at uppercase letters by using regex.\n### Function signature: def split_list(text):\n### Tests: assert split_list(\"LearnToBuildAnythingWithGoogle\") == ['Learn', 'To', 'Build', 'Anything', 'With', 'Google']\n assert split_list(\"ApmlifyingTheBlack+DeveloperCommunity\") == ['Apmlifying', 'The', 'Black+', 'Developer', 'Community']\n### Response: "} +{"task_id":957,"text":"Write a python function to get the position of rightmost set bit.","code":"import math\r\ndef get_First_Set_Bit_Pos(n):\r\n return math.log2(n&-n)+1","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to get the position of rightmost set bit.\n### Function signature: def get_First_Set_Bit_Pos(n):\n### Tests: assert get_First_Set_Bit_Pos(12) == 3\n assert get_First_Set_Bit_Pos(18) == 2\n### Response: "} +{"task_id":958,"text":"Write a function to convert an integer into a roman numeral.","code":"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","test_list":["assert int_to_roman(1)==(\"I\")","assert int_to_roman(50)==(\"L\")","assert int_to_roman(4)==(\"IV\")"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to convert an integer into a roman numeral.\n### Function signature: def int_to_roman( num):\n### Tests: assert int_to_roman(1)==(\"I\")\n assert int_to_roman(50)==(\"L\")\n### Response: "} +{"task_id":959,"text":"Write a python function to find the average of a list.","code":"def Average(lst): \r\n return sum(lst) \/ len(lst) ","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the average of a list.\n### Function signature: def Average(lst):\n### Tests: assert Average([15, 9, 55, 41, 35, 20, 62, 49]) == 35.75\n assert Average([4, 5, 1, 2, 9, 7, 10, 8]) == 5.75\n### Response: "} +{"task_id":960,"text":"Write a function to solve tiling problem.","code":"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);","test_list":["assert get_noOfways(4)==3","assert get_noOfways(3)==2","assert get_noOfways(5)==5"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to solve tiling problem.\n### Function signature: def get_noOfways(n):\n### Tests: assert get_noOfways(4)==3\n assert get_noOfways(3)==2\n### Response: "} +{"task_id":961,"text":"Write a function to convert a roman numeral to an integer.","code":"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","test_list":["assert roman_to_int('MMMCMLXXXVI')==3986","assert roman_to_int('MMMM')==4000","assert roman_to_int('C')==100"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to convert a roman numeral to an integer.\n### Function signature: def roman_to_int(s):\n### Tests: assert roman_to_int('MMMCMLXXXVI')==3986\n assert roman_to_int('MMMM')==4000\n### Response: "} +{"task_id":962,"text":"Write a python function to find the sum of all even natural numbers within the range l and r.","code":"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))) ","test_list":["assert sum_Even(2,5) == 6","assert sum_Even(3,8) == 18","assert sum_Even(4,6) == 10"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find the sum of all even natural numbers within the range l and r.\n### Function signature: def sum_Even(l,r):\n### Tests: assert sum_Even(2,5) == 6\n assert sum_Even(3,8) == 18\n### Response: "} +{"task_id":963,"text":"Write a function to calculate the discriminant value.","code":"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)","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)"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to calculate the discriminant value.\n### Function signature: def discriminant_value(x,y,z):\n### Tests: assert discriminant_value(4,8,2)==(\"Two solutions\",32)\n assert discriminant_value(5,7,9)==(\"no real solution\",-131)\n### Response: "} +{"task_id":964,"text":"Write a python function to check whether the length of the word is even or not.","code":"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","test_list":["assert word_len(\"program\") == False","assert word_len(\"solution\") == True","assert word_len(\"data\") == True"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to check whether the length of the word is even or not.\n### Function signature: def word_len(s):\n### Tests: assert word_len(\"program\") == False\n assert word_len(\"solution\") == True\n### Response: "} +{"task_id":965,"text":"Write a function to convert camel case string to snake case string.","code":"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()","test_list":["assert camel_to_snake('PythonProgram')==('python_program')","assert camel_to_snake('pythonLanguage')==('python_language')","assert camel_to_snake('ProgrammingLanguage')==('programming_language')"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to convert camel case string to snake case string.\n### Function signature: def camel_to_snake(text):\n### Tests: assert camel_to_snake('PythonProgram')==('python_program')\n assert camel_to_snake('pythonLanguage')==('python_language')\n### Response: "} +{"task_id":966,"text":"Write a function to remove an empty tuple from a list of tuples.","code":"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","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\") ] "],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to remove an empty tuple from a list of tuples.\n### Function signature: def remove_empty(tuple1):\n### Tests: assert remove_empty([(), (), ('',), ('a', 'b'), ('a', 'b', 'c'), ('d')])==[('',), ('a', 'b'), ('a', 'b', 'c'), 'd'] \n assert remove_empty([(), (), ('',), (\"python\"), (\"program\")])==[('',), (\"python\"), (\"program\")] \n### Response: "} +{"task_id":967,"text":"Write a python function to accept the strings which contains all vowels.","code":"def check(string): \r\n if len(set(string).intersection(\"AEIOUaeiou\"))>=5: \r\n return ('accepted') \r\n else: \r\n return (\"not accepted\") ","test_list":["assert check(\"SEEquoiaL\") == 'accepted'","assert check('program') == \"not accepted\"","assert check('fine') == \"not accepted\""],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to accept the strings which contains all vowels.\n### Function signature: def check(string):\n### Tests: assert check(\"SEEquoiaL\") == 'accepted'\n assert check('program') == \"not accepted\"\n### Response: "} +{"task_id":968,"text":"Write a python function to find maximum possible value for the given periodic function.","code":"def floor_Max(A,B,N):\r\n x = min(B - 1,N)\r\n return (A*x) \/\/ B","test_list":["assert floor_Max(11,10,9) == 9","assert floor_Max(5,7,4) == 2","assert floor_Max(2,2,1) == 1"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to find maximum possible value for the given periodic function.\n### Function signature: def floor_Max(A,B,N):\n### Tests: assert floor_Max(11,10,9) == 9\n assert floor_Max(5,7,4) == 2\n### Response: "} +{"task_id":969,"text":"Write a function to join the tuples if they have similar initial elements.","code":"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) ","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)]"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to join the tuples if they have similar initial elements.\n### Function signature: def join_tuples(test_list):\n### Tests: assert join_tuples([(5, 6), (5, 7), (6, 8), (6, 10), (7, 13)] ) == [(5, 6, 7), (6, 8, 10), (7, 13)]\n assert join_tuples([(6, 7), (6, 8), (7, 9), (7, 11), (8, 14)] ) == [(6, 7, 8), (7, 9, 11), (8, 14)]\n### Response: "} +{"task_id":970,"text":"Write a function to find minimum of two numbers.","code":"def min_of_two( x, y ):\r\n if x < y:\r\n return x\r\n return y","test_list":["assert min_of_two(10,20)==10","assert min_of_two(19,15)==15","assert min_of_two(-10,-20)==-20"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find minimum of two numbers.\n### Function signature: def min_of_two( x, y ):\n### Tests: assert min_of_two(10,20)==10\n assert min_of_two(19,15)==15\n### Response: "} +{"task_id":971,"text":"Write a function to find the maximum number of segments of lengths a, b and c that can be formed from n.","code":"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]","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the maximum number of segments of lengths a, b and c that can be formed from n.\n### Function signature: def maximum_segments(n, a, b, c) :\n### Tests: assert maximum_segments(7, 5, 2, 5) == 2\n assert maximum_segments(17, 2, 1, 3) == 17\n### Response: "} +{"task_id":972,"text":"Write a function to concatenate the given two tuples to a nested tuple.","code":"def concatenate_nested(test_tup1, test_tup2):\r\n res = test_tup1 + test_tup2\r\n return (res) ","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)"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to concatenate the given two tuples to a nested tuple.\n### Function signature: def concatenate_nested(test_tup1, test_tup2):\n### Tests: assert concatenate_nested((3, 4), (5, 6)) == (3, 4, 5, 6)\n assert concatenate_nested((1, 2), (3, 4)) == (1, 2, 3, 4)\n### Response: "} +{"task_id":973,"text":"Write a python function to left rotate the string.","code":"def left_rotate(s,d):\r\n tmp = s[d : ] + s[0 : d]\r\n return tmp ","test_list":["assert left_rotate(\"python\",2) == \"thonpy\" ","assert left_rotate(\"bigdata\",3 ) == \"databig\" ","assert left_rotate(\"hadoop\",1 ) == \"adooph\" "],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a python function to left rotate the string.\n### Function signature: def left_rotate(s,d):\n### Tests: assert left_rotate(\"python\",2) == \"thonpy\" \n assert left_rotate(\"bigdata\",3 ) == \"databig\" \n### Response: "} +{"task_id":974,"text":"Write a function to find the minimum total path sum in the given triangle.","code":"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]","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"],"test_setup_code":"","challenge_test_list":[],"augmented prompt":"### Instruction: Write a function to find the minimum total path sum in the given triangle.\n### Function signature: def min_sum_path(A):\n### Tests: assert min_sum_path([[ 2 ], [3, 9 ], [1, 6, 7 ]]) == 6\n assert min_sum_path([[ 2 ], [3, 7 ], [8, 5, 6 ]]) == 10 \n### Response: "}