from itertools import product
def evaluate_left_to_right(numbers, operations):
    result = numbers[0]
    for i, op in enumerate(operations):
        if op == '+':
            result += numbers[i+1]
        elif op == '*':
            result *= numbers[i+1]
    return result
def check_combinations(numbers, target):
    operations = ['+', '*']
    n = len(numbers) - 1

    for ops in product(operations, repeat=n):
        expression = [str(numbers[0])]
        for i, op in enumerate(ops):
            expression.append(op)
            expression.append(str(numbers[i+1]))

        result = evaluate_left_to_right(numbers, ops)
        if result == target:
            print(' '.join(expression))
            #return ' '.join(expression)

    #return "Keine Lösung gefunden"

# Beispielverwendung

result = check_combinations([81,40,27],3267)
print(f"Lösung: {result}")
