import re


def MinMaxExtractor(problem):
    """
    Description
        Returns the type of problem (1 = maximize, -1 = minimize).
    Input
        problem opened with openLP
    Output
        1 if it's a maximization problem
        -1 if it's a minimization problem
    """
    if re.search('max', problem[0], re.IGNORECASE):
        return 1
    elif re.search('min', problem[0], re.IGNORECASE):
        return -1
    else:
        raise Exception('Could not determine problem type.')