import re example = """xmul(2,4)%&mul[3,7]!@^do_not_mul(5,5)+mul(32,64]then(mul(11,8)mul(8,5))""" input = open('input.txt').read() def solve(input) -> bool: find_all = re.findall(r"mul\(\d{1,3},\d{1,3}\)", input) print(find_all) total = 0 for find in find_all: a = find.replace("mul(", "") b = a.replace(")", "") c = b.split(",") result = int(c[0])*int(c[1]) total += result return total print(input) print(f"Total: {solve(input)}")