def isValid(matrix, filename, solutionFilename):
    try:
        resultLines = subprocess.check_output((filename, matrix), stderr=subprocess.STDOUT, timeout=5).decode(sys.stdout.encoding)
    except CalledProcessError as e:
        print(('The application did not exit cleanly on: ' + matrix))
        return False
    except TimeoutExpired as e:
        print(('The application exceeded the allowed time on: ' + matrix))
        return False
    result = getSolutionFromString(resultLines)
    with open(solutionFilename) as solutionFile:
        solutionLines = solutionFile.read()
    solution = getSolutionFromString(solutionLines)
    return (solution == result)
    for i in range(len(resultLines)):
        if (resultLines[i] != solutionLines[i]):
            print('Incorrect solution.')
            print(('Expected: ' + str(resultLines)))
            print(('Received: ' + str(solutionLines)))
            return False
    return True
def isValid(matrix, filename, solutionFilename):
    try:
        resultLines = subprocess.check_output((filename, matrix), stderr=subprocess.STDOUT, timeout=5).decode(sys.stdout.encoding)
    except CalledProcessError as e:
        print(('The application did not exit cleanly on: ' + matrix))
        return False
    except TimeoutExpired as e:
        print(('The application exceeded the allowed time on: ' + matrix))
        return False
    result = getSolutionFromString(resultLines)
    with open(solutionFilename) as solutionFile:
        solutionLines = solutionFile.read()
    solution = getSolutionFromString(solutionLines)
    return (solution == result)
    for i in range(len(resultLines)):
        if (resultLines[i] != solutionLines[i]):
            print('Incorrect solution.')
            print(('Expected: ' + str(resultLines)))
            print(('Received: ' + str(solutionLines)))
            return False
    return True