{"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(s: str, char: str) -> str:\n    \"\"\"\n    Given a string s and a character, remove the first and last occurrence of the character from the string.\n    \n    Args:\n        s (str): The string to be modified.\n        char (str): The character to be removed.\n    \n    Returns:\n        str: The modified string.\n    \"\"\"\n    # Find the index of the first and last occurrence of the character\n    first_index = s.find(char)\n    last_index = s.rfind(char)\n    \n    # If the character is not in the string or first and last index are same, return the string as it is\n    if first_index == -1 or first_index == last_index:\n        return s\n    \n    # If the first and last index are different, return the string with the first and last occurrence of the character removed\n    return s[:first_index] + s[first_index+1:last_index] + s[last_index+1:]\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    Sort a given matrix in ascending order according to the sum of its rows.\n\n    Args:\n        matrix (list): A 2D list of integers.\n\n    Returns:\n        list: A 2D list of integers sorted in ascending order based on the sum of their rows.\n    \"\"\"\n    # Calculate the sum of each row\n    row_sums = [sum(row) for row in matrix]\n\n    # Create a list of tuples containing the row sums and their corresponding rows\n    rows_with_sums = [(row_sum, row) for row_sum, row in zip(row_sums, matrix) if not any(num < 0 for num in row)]\n\n    # Sort the rows in ascending order based on the row sums\n    sorted_rows = sorted(rows_with_sums, key=lambda x: x[0])\n\n    # Extract the sorted rows\n    sorted_matrix = [row for _, row in sorted_rows]\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]]) == [[-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]]\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": "\nfrom collections import Counter\n\ndef count_common(words):\n    word_counts = Counter(words)\n    common_words = word_counts.most_common()\n    return 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": "[NameError(\"name 'Counter' is not defined\")]"}
{"task_id": "3", "problem": "Write a python function to find the volume of a triangular prism.", "completion": "\ndef find_Volume(base, height, length):\n    \"\"\"\n    Return the volume of a triangular prism with the given base, height, and length.\n    \"\"\"\n    # Calculate the area of the triangular base\n    base_area = 0.5 * base * height\n    \n    # Calculate the volume using the formula: base_area * length\n    volume = base_area * length\n    \n    return volume\n\n# Test cases\nassert find_Volume(10, 8, 6) == 240\nassert find_Volume(3, 2, 2) == 6\nassert find_Volume(1, 2, 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": true, "fail_reason": "[]"}
{"task_id": "4", "problem": "Write a function to split a string at lowercase letters.", "completion": "\nimport re\n\ndef split_lowerstring(s):\n    # Find all lowercase letters in the string\n    lowercase_letters = re.findall(r'[a-z]', s)\n    \n    # Split the string at each lowercase letter\n    split_string = re.split(r'([a-z])', s)\n    \n    # Remove empty strings from the list\n    split_string = [x for x in split_string if x]\n    \n    # Pair each lowercase letter with the next character\n    result = []\n    for i in range(len(split_string)):\n        if i % 2 == 0:\n            result.append(split_string[i])\n        else:\n            result.append([split_string[i], split_string[i+1]])\n    \n    # Remove the last element if it's a lowercase letter\n    if result and isinstance(result[-1], list):\n        result.pop()\n    \n    return result\n\n# Test cases\nassert split_lowerstring(\"AbCd\") == ['A', ['b', 'C'], 'd']\nassert split_lowerstring(\"Python\") == ['P', 'y', 't', 'h', 'o', 'n']\nassert split_lowerstring(\"Programming\") == ['P', '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": "[IndexError('list index out of range')]"}
{"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    pattern = r'^[a-z]+_[a-z]+$'\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": true, "fail_reason": "[]"}
{"task_id": "6", "problem": "Write a function to find the perimeter of a square.", "completion": "\ndef square_perimeter(n):\n    \"\"\"\n    Return the perimeter of a square of size n.\n    \n    >>> square_perimeter(10)\n    40\n    \"\"\"\n    return 4 * n\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": "\ndef remove_dirty_chars(s, t):\n    \"\"\"\n    Remove characters from string s that are present in string t.\n    :param s: (str) first string\n    :param t: (str) second string\n    :return: (str) string after removing characters\n    \"\"\"\n    t_set = set(t)  # Convert t to a set for constant time look-ups\n    result = [char for char in s if char not in t_set]  # List comprehension\n    return ''.join(result)  # Convert list back to string\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": true, "fail_reason": "[]"}
{"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    mySet = set()\n    for item in arr:\n        if item in mySet:\n            return True\n        else:\n            mySet.add(item)\n    return False\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_woodall(n):\n    i = 0\n    while True:\n        woodall_num = 2 ** i - 1\n        if woodall_num == n:\n            return True\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    \"\"\"\n    Return a list of the first m multiples of n.\n    \"\"\"\n    multiples_list = []\n    i = 1\n    while len(multiples_list) < m:\n        multiple = n * i\n        multiples_list.append(multiple)\n        i += 1\n    return multiples_list\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 in a given array of integers.\n    \"\"\"\n    elements_seen = set()\n\n    for element in arr:\n        if element in elements_seen:\n            return element\n        else:\n            elements_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    max_sum = 0\n    for lst in list_of_lists:\n        if sum(lst) > max_sum:\n            max_sum = sum(lst)\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": "[]"}
