Esempio n. 1
0
def part1(data):
    exe = Executor(Code(data))
    it = iter(exe.complete())
    tiles = list(zip(it, it, it))
    mx = max(x for x, _, _ in tiles) + 1
    my = max(y for _, y, _ in tiles) + 1
    board = np.zeros((my, mx))
    for x, y, i in tiles:
        board[y, x] = i
    return (board == 2).sum()
Esempio n. 2
0
def part2(data):
    code = Code(data)
    exe = Executor(code)
    output = ''.join(map(chr, exe.complete()))

    code[0] = 2
    exe = Executor(code)
    # manually devised sequence!
    main = 'A,B,A,B,A,C,B,C,A,C'
    a = 'R,4,L,10,L,10'
    b = 'L,8,R,12,R,10,R,4'
    c = 'L,8,L,8,R,10,R,4'
    live = 'n'  #'y'

    for line in (main, a, b, c, live):
        exe.inputs.extend(map(ord, line))
        exe.inputs.append(10)

    for ch in exe.runner:
        if ch > 255:
            return ch
        print(chr(ch), end='')
Esempio n. 3
0
def part1(data):
    exe = Executor(Code(data))
    output = ''.join(map(chr, exe.complete()))
    return part1_map(output)