Esempio n. 1
0
def get_oxygen():
    a = Intcode()
    a.init()
    find_tank(2, (0, 0), a.save(), [])
    for i in range(len(order)):
        print_ship(order[i], order[:i])
        print("Steps:", i + 1)
        print("Position:", order[i])
        sleep(DRAW_RATE)
Esempio n. 2
0
def init_NICs(tape):
    for addr in range(50):
        computer = Intcode()
        NIC = computer.init(tape.copy())
        NIC.send(addr)
        network.append(NIC)
        computers.append(computer)
Esempio n. 3
0
from intcode import Intcode
import os

tape = list(map(int, open("tape.txt").readline().split(",")))

code = Intcode()
running = code.init(tape)


def drill_down(x, y):
    depth = 0
    try:
        while True:
            running = code.init(tape)
            running.send(x)
            beam = running.send(y)
            if beam == 1:
                depth += 1
                y += 1
            else:
                break
    except StopIteration as si:
        pass
    return depth


def find_start():
    x_offset = 0
    y_offset = 0

    while True:
Esempio n. 4
0
from intcode import Intcode
tape = list(map(int, open("input.txt").readline().split(",")))
tape[0] = 2
comp = Intcode()

R = "A,B,A,C,A,C,B,C,C,B"
A = "L,4,L,4,L,10,R,4"
B = "R,4,L,4,L,4,R,8,R,10"
C = "R,4,L,10,R,10"

q = list(map(ord, list("\n".join([R, A, B, C, "n", ""]))[::-1]))
drive = comp.init(tape.copy(), q)

data = []

try:
    while True:
        x = next(drive)
        if x is not None:
            data.append(x)
except StopIteration as si:
    print(si)

grid = []
row = []
for d in data:
    if d == 10:
        grid.append(row)
        row = []
    else:
        row.append(chr(d))
Esempio n. 5
0
from intcode import Intcode

tape = list(map(int, open("input.txt").readline().split(",")))
comp = Intcode()
a = comp.init(tape.copy())
data = []
try:
    while True:
        data.append(next(a))
except StopIteration as si:
    print(si)

grid = []
row = []
for d in data:
    if d == 10:
        grid.append(row)
        row = []
    else:
        row.append(chr(d))

for y in range(0, len(grid)):
    row = [x for x in grid[y]]
    print("".join(row))

alignments = []
s = 0
for y in range(1, len(grid) - 2):
    for x in range(1, len(grid[y]) - 2):
        if (grid[y][x] == "#" and grid[y - 1][x] == "#"
                and grid[y + 1][x] == "#" and grid[y][x - 1] == "#"