{"task_id": "0", "problem": "Write a python function to remove first and last occurrence of a given character from the string.", "completion": "\ndef remove_Occ(string, character):\n    '''\n    This function will remove the first and last occurrence of a given character from a string.\n\n    Args:\n        string (str): the string to be modified\n        character (str): the character to be removed\n\n    Returns:\n        str: the modified string\n    '''\n    first_occurrence = string.find(character)\n    last_occurrence = string.rfind(character)\n    \n    if first_occurrence != -1 and last_occurrence != -1 and first_occurrence != last_occurrence:\n        return string[:first_occurrence] + string[first_occurrence+1:last_occurrence] + string[last_occurrence+1:]\n    else:\n        return string\n\n# Test cases\nassert remove_Occ(\"hello\", \"l\") == \"heo\"\nassert remove_Occ(\"abcda\", \"a\") == \"bcd\"\nassert remove_Occ(\"PHP\", \"P\") == \"H\"\n\nassert remove_Occ(\"hello\",\"l\") == \"heo\"\nassert remove_Occ(\"abcda\",\"a\") == \"bcd\"\nassert remove_Occ(\"PHP\",\"P\") == \"H\"", "passed": true, "fail_reason": "[]"}
{"task_id": "1", "problem": "Write a function to sort a given matrix in ascending order according to the sum of its rows.", "completion": "\ndef sort_matrix(matrix):\n    \"\"\"\n    This function sorts a given matrix in ascending order according to the sum of its rows.\n\n    Parameters:\n    matrix (List[List[int, float]]): A 2D list of numerical values representing the matrix to be sorted.\n\n    Returns:\n    List[List[int, float]]: The sorted matrix.\n    \"\"\"\n    # Calculate the sum of each row and store the row along with its sum in a list of tuples\n    row_sums = [(sum(row), row) for row in matrix]\n\n    # Sort the list of tuples based on the sum of the rows\n    row_sums.sort()\n\n    # Extract the sorted rows from the list of tuples\n    sorted_matrix = [row for _, row in row_sums]\n\n    return sorted_matrix\n\n# Test cases\nassert sort_matrix([[1, 2, 3], [2, 4, 5], [1, 1, 1]]) == [[1, 1, 1], [1, 2, 3], [2, 4, 5]]\nassert sort_matrix([[1, 2, 3], [-2, 4, -5], [1, -1, 1]]) == [[1, -1, 1], [-2, 4, -5], [1, 2, 3]]\nassert sort_matrix([[5, 8, 9], [6, 4, 3], [2, 1, 4]]) == [[2, 1, 4], [6, 4, 3], [5, 8, 9]]\n\nassert sort_matrix([[1, 2, 3], [2, 4, 5], [1, 1, 1]])==[[1, 1, 1], [1, 2, 3], [2, 4, 5]]\nassert sort_matrix([[1, 2, 3], [-2, 4, -5], [1, -1, 1]])==[[-2, 4, -5], [1, -1, 1], [1, 2, 3]]\nassert sort_matrix([[5,8,9],[6,4,3],[2,1,4]])==[[2, 1, 4], [6, 4, 3], [5, 8, 9]]", "passed": false, "fail_reason": "[AssertionError()]"}
{"task_id": "2", "problem": "Write a function to count the most common words in a dictionary.", "completion": "\ndef count_common(words):\n    \"\"\"Find the most common words in the given list.\n\n    :param words: A list of words\n    :returns: A list of tuples, where each tuple contains a word and its count\n    \"\"\"\n\n    # Count the occurrences of each word\n    word_count = {}\n    for word in words:\n        word = word.lower()\n        if word in word_count:\n            word_count[word] += 1\n        else:\n            word_count[word] = 1\n\n    # Get the most common words\n    most_common_words = []\n    max_count = 0\n    for word, count in word_count.items():\n        if count > max_count:\n            most_common_words = [(word, count)]\n            max_count = count\n        elif count == max_count:\n            most_common_words.append((word, count))\n\n    return most_common_words\n\n# Test cases\nassert count_common(['red','green','black','pink','black','white','black','eyes','white','black','orange','pink','pink','red','red','white','orange','white',\"black\",'pink','green','green','pink','green','pink','white','orange',\"orange\",'red']) == [('pink', 6), ('black', 5), ('white', 5), ('red', 4)]\nassert count_common(['one', 'two', 'three', 'four', 'five', 'one', 'two', 'one', 'three', 'one']) == [('one', 4), ('two', 2), ('three', 2), ('four', 1)]\nassert count_common(['Facebook', 'Apple', 'Amazon', 'Netflix', 'Google', 'Apple', 'Netflix', 'Amazon']) == [('Apple', 2), ('Amazon', 2), ('Netflix', 2), ('Facebook', 1)]\n\nassert count_common(['red','green','black','pink','black','white','black','eyes','white','black','orange','pink','pink','red','red','white','orange','white',\"black\",'pink','green','green','pink','green','pink','white','orange',\"orange\",'red']) == [('pink', 6), ('black', 5), ('white', 5), ('red', 4)]\nassert count_common(['one', 'two', 'three', 'four', 'five', 'one', 'two', 'one', 'three', 'one']) == [('one', 4), ('two', 2), ('three', 2), ('four', 1)]\nassert count_common(['Facebook', 'Apple', 'Amazon', 'Netflix', 'Google', 'Apple', 'Netflix', 'Amazon']) == [('Apple', 2), ('Amazon', 2), ('Netflix', 2), ('Facebook', 1)]", "passed": false, "fail_reason": "[AssertionError()]"}
{"task_id": "3", "problem": "Write a python function to find the volume of a triangular prism.", "completion": "\nimport math\n\ndef triangular_prism_volume(a, b, c, h):\n    \"\"\"Return the volume of a triangular prism.\"\"\"\n    assert a >= 0 and b >= 0 and c >= 0 and h >= 0, \"Ensure non-negative prism dimensions\"\n    assert a + b > c and b + c > a and c + a > b, \"Ensure valid triangle dimensions\"\n\n    # Calculate volume\n    v = (a * b * c) / (4 * math.sqrt((a + b + c) * (-a + b + c) * (a - b + c) * (a + b - c))) * h\n    return v\n\n# Test cases\nassert triangular_prism_volume(10, 8, 6, 5) == 240\nassert triangular_prism_volume(3, 2, 2, 1) == 6\nassert triangular_prism_volume(1, 2, 1, 1) == 1\n\nassert find_Volume(10,8,6) == 240\nassert find_Volume(3,2,2) == 6\nassert find_Volume(1,2,1) == 1", "passed": false, "fail_reason": "[NameError(\"name 'math' is not defined\")]"}
{"task_id": "4", "problem": "Write a function to split a string at lowercase letters.", "completion": "\ndef split_lowerstring(s):\n    result = []\n    current_chunk = ''\n    for char in s:\n        if char.islower():\n            if current_chunk:\n                result.append(current_chunk)\n                current_chunk = ''\n            result.append(char)\n        else:\n            current_chunk += char\n    if current_chunk:\n        result.append(current_chunk)\n    return result\n\n# Test cases\nassert split_lowerstring(\"AbCd\") == ['bC', 'd']\nassert split_lowerstring(\"Python\") == ['y', 't', 'h', 'o', 'n']\nassert split_lowerstring(\"Programming\") == ['r', 'o', 'g', 'r', 'a', 'm', 'm', 'i', 'n', 'g']\n\nassert split_lowerstring(\"AbCd\")==['bC','d']\nassert split_lowerstring(\"Python\")==['y', 't', 'h', 'o', 'n']\nassert split_lowerstring(\"Programming\")==['r', 'o', 'g', 'r', 'a', 'm', 'm', 'i', 'n', 'g']", "passed": false, "fail_reason": "[AssertionError()]"}
{"task_id": "5", "problem": "Write a function to find sequences of lowercase letters joined with an underscore.", "completion": "\nimport re\n\ndef text_lowercase_underscore(text):\n    # Regular expression pattern to match a sequence of lowercase letters joined with an underscore\n    pattern = r'[a-z]+_[a-z]+'\n    \n    # Search for the pattern in the text\n    if re.search(pattern, text):\n        return 'Found a match!'\n    else:\n        return 'Not matched!'\n\n# Test cases\nassert text_lowercase_underscore(\"aab_cbbbc\") == 'Found a match!'\nassert text_lowercase_underscore(\"aab_Abbbc\") == 'Not matched!'\nassert text_lowercase_underscore(\"Aaab_abbbc\") == 'Not matched!'\n\nassert text_lowercase_underscore(\"aab_cbbbc\")==('Found a match!')\nassert text_lowercase_underscore(\"aab_Abbbc\")==('Not matched!')\nassert text_lowercase_underscore(\"Aaab_abbbc\")==('Not matched!')", "passed": false, "fail_reason": "[AssertionError()]"}
{"task_id": "6", "problem": "Write a function to find the perimeter of a square.", "completion": "\ndef square_perimeter(side_length):\n    \"\"\"Function to return the perimeter of a square\"\"\"\n    perimeter = 4 * side_length\n    return perimeter\n\n# Test cases\nassert square_perimeter(10) == 40\nassert square_perimeter(5) == 20\nassert square_perimeter(4) == 16\n\nassert square_perimeter(10)==40\nassert square_perimeter(5)==20\nassert square_perimeter(4)==16", "passed": true, "fail_reason": "[]"}
{"task_id": "7", "problem": "Write a function to remove characters from the first string which are present in the second string.", "completion": "\nimport re\n\ndef remove_dirty_chars(string1, string2):\n    # Convert both strings to lowercase for case-insensitive comparison\n    string1 = string1.lower()\n    string2 = string2.lower()\n\n    # Remove non-alphanumeric characters from both strings\n    string1 = re.sub(r'\\W+', '', string1)\n    string2 = re.sub(r'\\W+', '', string2)\n\n    # Initialize a pointer for the first string\n    i = 0\n\n    # Iterate through the characters of the second string\n    for char in string2:\n        # If the character matches the current character in the first string\n        if char == string1[i]:\n            # Move the pointer to the next character in the first string\n            i += 1\n\n            # If the pointer reaches the end of the first string\n            if i == len(string1):\n                # All characters from the first string have appeared in order and consecutively in the second string\n                break\n\n    # Remove the characters from the first string that have been matched in the second string\n    return string1[:i] + string1[i+1:]\n\n# Test cases\nassert remove_dirty_chars(\"probasscurve\", \"pros\") == 'bacuve'\nassert remove_dirty_chars(\"digitalindia\", \"talent\") == 'digiidi'\nassert remove_dirty_chars(\"exoticmiles\", \"toxic\") == 'emles'\n\nassert remove_dirty_chars(\"probasscurve\", \"pros\") == 'bacuve'\nassert remove_dirty_chars(\"digitalindia\", \"talent\") == 'digiidi'\nassert remove_dirty_chars(\"exoticmiles\", \"toxic\") == 'emles' ", "passed": false, "fail_reason": "[AssertionError()]"}
{"task_id": "8", "problem": "Write a function to find whether a given array of integers contains any duplicate element.", "completion": "\ndef test_duplicate(arr):\n    \"\"\"\n    Check if an array of integers contains any duplicate element.\n    \n    :param arr: list, the array to check\n    \n    :returns: bool, True if there is a duplicate, False otherwise\n    \"\"\"\n    # Create a set from the array\n    # Two elements are the same if they have the same hash value\n    # If the length of the set is less than the length of the array, there is a duplicate\n    return len(set(arr)) != len(arr)\n\n# Test cases\nassert test_duplicate(([1,2,3,4,5]))==False\nassert test_duplicate(([1,2,3,4, 4]))==True\nassert test_duplicate([1,1,2,2,3,3,4,4,5])==True\n\nassert test_duplicate(([1,2,3,4,5]))==False\nassert test_duplicate(([1,2,3,4, 4]))==True\nassert test_duplicate([1,1,2,2,3,3,4,4,5])==True", "passed": true, "fail_reason": "[]"}
{"task_id": "9", "problem": "Write a function to check if the given number is woodball or not.", "completion": "\ndef is_multiple(n):\n    \"\"\"\n    Function to check if a given number is a multiple of 3 or 5.\n    \n    Parameters: \n    n (int): The given number to check.\n    \n    Returns: \n    bool: True if number is a multiple of 3 or 5, False otherwise.\n    \"\"\"\n    return n % 3 == 0 or n % 5 == 0\n\ndef is_woodall(n):\n    \"\"\"\n    Function to check if a given number is a Woodall number.\n    \n    Parameters: \n    n (int): The given number to check.\n    \n    Returns: \n    bool: True if number is a Woodall number, False otherwise.\n    \"\"\"\n    i = 0\n    while True:\n        woodall_num = 2**i - 1\n        if woodall_num == n:\n            return is_multiple(n)\n        if woodall_num > n:\n            return False\n        i += 1\n\n# Test cases\nassert is_woodall(383) == True\nassert is_woodall(254) == False\nassert is_woodall(200) == False\n\nassert is_woodall(383) == True\nassert is_woodall(254) == False\nassert is_woodall(200) == False", "passed": false, "fail_reason": "[AssertionError()]"}
{"task_id": "10", "problem": "Write a function to find m number of multiples of n.", "completion": "\ndef multiples_of_num(m, n):\n    multiples = []\n    i = 1\n    while len(multiples) < m:\n        if i % n == 0:\n            multiples.append(i)\n        i += 1\n    return multiples\n\n# Test cases\nassert multiples_of_num(4, 3) == [3, 6, 9, 12]\nassert multiples_of_num(2, 5) == [5, 10]\nassert multiples_of_num(9, 2) == [2, 4, 6, 8, 10, 12, 14, 16, 18]\n\nassert multiples_of_num(4,3)== [3,6,9,12]\nassert multiples_of_num(2,5)== [5,10]\nassert multiples_of_num(9,2)== [2,4,6,8,10,12,14,16,18]", "passed": true, "fail_reason": "[]"}
{"task_id": "11", "problem": "Write a function to find the first duplicate element in a given array of integers.", "completion": "\ndef find_first_duplicate(arr):\n    \"\"\"\n    Find the first duplicate element in a given array of integers.\n    \n    :param arr: list, the array to search\n    \n    :returns: int, the first duplicate element if found, otherwise -1\n    \"\"\"\n    seen = set()\n    for element in arr:\n        if element in seen:\n            return element\n        seen.add(element)\n    return -1\n\n# Test cases\nassert find_first_duplicate([1, 2, 3, 4, 4, 5]) == 4\nassert find_first_duplicate([1, 2, 3, 4]) == -1\nassert find_first_duplicate([1, 1, 2, 3, 3, 2, 2]) == 1\n\nassert find_first_duplicate(([1, 2, 3, 4, 4, 5]))==4\nassert find_first_duplicate([1, 2, 3, 4])==-1\nassert find_first_duplicate([1, 1, 2, 3, 3, 2, 2])==1", "passed": true, "fail_reason": "[]"}
{"task_id": "12", "problem": "Write a python function to find the maximum sum of elements of list in a list of lists.", "completion": "\ndef maximum_Sum(list_of_lists):\n    \"\"\"\n    This function finds the maximum sum of elements of lists in a list of lists.\n\n    Args:\n        list_of_lists (list): A list of lists of numbers.\n\n    Returns:\n        int: The maximum sum of elements of lists.\n    \"\"\"\n    max_sum = 0\n    for lst in list_of_lists:\n        current_sum = sum(lst)\n        if current_sum > max_sum:\n            max_sum = current_sum\n    return max_sum\n\n# Test cases\nassert maximum_Sum([[1,2,3],[4,5,6],[10,11,12],[7,8,9]]) == 33\nassert maximum_Sum([[0,1,1],[1,1,2],[3,2,1]]) == 6\nassert maximum_Sum([[0,1,3],[1,2,1],[9,8,2],[0,1,0],[6,4,8]]) == 19\n\nassert maximum_Sum([[1,2,3],[4,5,6],[10,11,12],[7,8,9]]) == 33\nassert maximum_Sum([[0,1,1],[1,1,2],[3,2,1]]) == 6\nassert maximum_Sum([[0,1,3],[1,2,1],[9,8,2],[0,1,0],[6,4,8]]) == 19", "passed": true, "fail_reason": "[]"}
{"task_id": "13", "problem": "Write a function to convert the given binary number to its decimal equivalent.", "completion": "\ndef binary_to_decimal(bin_num):\n    decimal = 0\n    for digit in str(bin_num):\n        decimal = decimal*2 + int(digit)\n    return decimal\n\n# Test cases\nassert binary_to_decimal(100) == 4\nassert binary_to_decimal(1011) == 11\nassert binary_to_decimal(1101101) == 109\n\nassert binary_to_decimal(100) == 4\nassert binary_to_decimal(1011) == 11\nassert binary_to_decimal(1101101) == 109", "passed": true, "fail_reason": "[]"}
{"task_id": "14", "problem": "Write a python function to find the product of non-repeated elements in a given array.", "completion": "\ndef find_Product(arr, n):\n    def is_prime(num):\n        if num < 2:\n            return False\n        for i in range(2, int(num**0.5) + 1):\n            if num % i == 0:\n                return False\n        return True\n\n    def digit_sum(num):\n        return sum(int(digit) for digit in str(num))\n\n    def is_product_of_two_primes(num):\n        factors = 0\n        for i in range(2, int(num**0.5) + 1):\n            if num % i == 0:\n                if is_prime(i) and is_prime(num // i):\n                    factors += 1\n        return factors == 2\n\n    unique_elements = set()\n    for num in arr:\n        if num not in unique_elements and digit_sum(num) % 2 == 1 and is_product_of_two_primes(num):\n            unique_elements.add(num)\n\n    product = 1\n    for num in unique_elements:\n        product *= num\n\n    return product\n\n# Test cases\nassert find_Product([1,1,2,3], 4) == 6\nassert find_Product([1,2,3,1,1], 5) == 6\nassert find_Product([1,1,4,5,6], 5) == 120\n\nassert find_Product([1,1,2,3],4) == 6\nassert find_Product([1,2,3,1,1],5) == 6\nassert find_Product([1,1,4,5,6],5) == 120", "passed": false, "fail_reason": "[AssertionError()]"}
{"task_id": "15", "problem": "Write a function to check if the given tuple list has all k elements.", "completion": "\ndef check_k_elements(tuple_list, k):\n    for t in tuple_list:\n        if len(t) != k:\n            return False\n    return True\n\n# Test cases\nassert check_k_elements([(4, 4), (4, 4, 4), (4, 4), (4, 4, 4, 4), (4,)], 4) == True\nassert check_k_elements([(7, 7, 7), (7, 7)], 7) == True\nassert check_k_elements([(9, 9), (9, 9, 9, 9)], 7) == False\n\nassert check_k_elements([(4, 4), (4, 4, 4), (4, 4), (4, 4, 4, 4), (4, )], 4) == True\nassert check_k_elements([(7, 7, 7), (7, 7)], 7) == True\nassert check_k_elements([(9, 9), (9, 9, 9, 9)], 7) == False", "passed": false, "fail_reason": "[AssertionError()]"}
{"task_id": "16", "problem": "Write a python function to remove all digits from a list of strings.", "completion": "\nimport re\n\ndef remove_digits(lst):\n    return [re.sub(r'\\d', '', s) for s in lst]\n\n# Test cases\nassert remove_digits(['4words', '3letters', '4digits']) == ['words', 'letters', 'digits']\nassert remove_digits(['28Jan','12Jan','11Jan']) == ['Jan','Jan','Jan']\nassert remove_digits(['wonder1','wonder2','wonder3']) == ['wonder','wonder','wonder']\n\nassert remove(['4words', '3letters', '4digits']) == ['words', 'letters', 'digits']\nassert remove(['28Jan','12Jan','11Jan']) == ['Jan','Jan','Jan']\nassert remove(['wonder1','wonder2','wonder3']) == ['wonder','wonder','wonder']", "passed": false, "fail_reason": "[NameError(\"name 'remove' is not defined\")]"}
{"task_id": "17", "problem": "Write a python function to find binomial co-efficient.", "completion": "\ndef binomial_Coeff(n, k):\n    if k==0 or n==k:\n        return 1\n    else:\n        return binomial_Coeff(n-1, k-1) + binomial_Coeff(n-1, k)\n\n\ndef binomial_Coeff(n, k):\n    C = [[0 for x in range(k+1)] for x in range(n+1)]\n\n    for i in range(n+1):\n        for j in range(min(i, k)+1):\n            if j == 0 or j == i:\n                C[i][j] = 1\n            else:\n                C[i][j] = C[i-1][j-1] + C[i-1][j]\n\n    return C[n][k]\n\n\nassert binomial_Coeff(5,2) == 10\nassert binomial_Coeff(4,3) == 4\nassert binomial_Coeff(3,2) == 3\n\nassert binomial_Coeff(5,2) == 10\nassert binomial_Coeff(4,3) == 4\nassert binomial_Coeff(3,2) == 3", "passed": true, "fail_reason": "[]"}
