コード例 #1
0
ファイル: advent19.py プロジェクト: Shaelmaar-2/Advent19
            if (m, (xdir, ydir)) not in astroids[roid]:
                astroids[roid].add((m, (xdir, ydir)))
# 17,14
"""
with open('inputs/input11.txt', 'r') as inp:
    instructions = [
        int(command) for command in inp.readline().strip().split(',')
    ]
comp = Computer(instructions, 0, 0)
hull = defaultdict(int)
pos = [0, 0]
dirs = {0: -1, 1: 1, 2: 1, 3: -1}
dir = 0
tiles = 0
while not comp.finished:
    comp.run()
    if tuple(pos) not in hull:
        tiles += 1
    hull[tuple(pos)] = comp.thrustoutput
    comp.run()
    if comp.thrustoutput == 1:
        dir = (dir + 1) % 4
    else:
        dir = (dir - 1) % 4
    if dir in (1, 3):
        pos[1] += dirs[dir]
    else:
        pos[0] += dirs[dir]
    comp.nextthrustinput(hull[tuple(pos)])
print(len(hull))