@@ -0,0 +1,2105 @@
+import re%0Aimport io%0A%0Adef execute(input, a_init=0):%0A    registers = %7B'a':a_init, 'b':0, 'c':0, 'd':0%7D%0A%0A    # read file%0A    f = io.StringIO(input)%0A    lines = f.readlines()%0A    %0A    signal = %22%22%0A    line_counter = 0%0A%0A    while(line_counter %3C len(lines) and len(signal) %3C 100):%0A        l = lines%5Bline_counter%5D.replace('%5Cn', '')%0A        m = re.search('cpy (%5Cd+) (%5Babcd%5D)', l)%0A        n =  re.search('cpy (%5Babcd%5D) (%5Babcd%5D)', l)%0A        if m is not None:%0A            registers%5Bm.group(2)%5D =  int(m.group(1))%0A            line_counter += 1%0A        elif n is not None:%0A            registers%5Bn.group(2)%5D = registers%5Bn.group(1)%5D%0A            line_counter += 1%0A        elif 'inc' in l:%0A            registers%5Bl%5B-1%5D%5D += 1%0A            line_counter += 1%0A        elif 'dec' in l:%0A            registers%5Bl%5B-1%5D%5D -= 1%0A            line_counter += 1%0A        elif 'out' in l:%0A            m = re.search('out (%5CS+)', l)%0A            r = m.group(1)%0A            if r in 'abcd':%0A                signal += str(registers%5Br%5D)%0A            elif r.isnumeric():%0A                signal += str(r)%0A                %0A            if (len(signal) %3E 1 and ((int(signal%5B-1%5D) + int(signal%5B-2%5D)) != 1 or (int(signal%5B-1%5D) * int(signal%5B-2%5D)) != 0)):%0A                return False%0A            %0A            line_counter += 1%0A        else:%0A            m = re.search('jnz (%5CS+) (%5Cd+)', l)%0A            if m is None:%0A                m = re.search('jnz (%5CS+) (-%5Cd+)', l)%0A            r = m.group(1)%0A            if (r in 'abcd' and not(registers%5Br%5D == 0)):%0A                line_counter += int(m.group(2))%0A            elif r.isnumeric() and not(int(r) == 0):%0A                line_counter += int(m.group(2))%0A            else:%0A                line_counter += 1%0A    print(f'For a_init = %7Ba_init%7D, signal is %7Bsignal%7D')%0A    return True%0A%0Ainput = %22cpy a d%5Cncpy 14 c%5Cncpy 182 b%5Cninc d%5Cndec b%5Cnjnz b -2%5Cndec c%5Cnjnz c -5%5Cncpy d a%5Cnjnz 0 0%5Cncpy a b%5Cncpy 0 a%5Cncpy 2 c%5Cnjnz b 2%5Cnjnz 1 6%5Cndec b%5Cndec c%5Cnjnz c -4%5Cninc a%5Cnjnz 1 -7%5Cncpy 2 b%5Cnjnz c 2%5Cnjnz 1 4%5Cndec b%5Cndec c%5Cnjnz 1 -4%5Cnjnz 0 0%5Cnout b%5Cnjnz a -19%5Cnjnz 1 -21%22%0A%0Ai = 0%0Awhile (not execute(input, i) and i %3C 1000):%0A    i += 1 %0A

Create day25.py