Example #1
0
memry = []
computers = []

inputFrom = defaultdict(lambda: [])
ysentFromNat = defaultdict(lambda: 0)

NATInputX = -137137137
NATInputY = -137137137

for line in file:
    memry = line.split(',')

for i in range(50):
    comp = IntcodeVM(memry.copy())
    comp.updateInput(i)
    computers.append(comp)

stopped = False

while not stopped:
    howManyPackagesInQueue = 0
    for i in range(50):
        computers[i].run()
        if computers[i].output:
            inputFrom[i].append(computers[i].prgOutput)
        if len(inputFrom[i]) >= 3:
            who = inputFrom[i].pop(0)
            xtoSend = inputFrom[i].pop(0)
            ytoSend = inputFrom[i].pop(0)
            if who != 255:
Example #2
0
from intcode import IntcodeVM

file = open('input.txt', 'r')

memry = []

for line in file:
    memry = line.split(',')

memry[0] = 2
robot = IntcodeVM(memry)

UserInput = [65, 44, 66, 44, 65, 44, 67, 44, 66, 44, 65, 44, 67, 44, 65, 44, 67, 44, 66, 10,
             76, 44, 49, 50, 44, 76, 44, 56, 44, 76, 44, 56, 10,
             76, 44, 49, 50, 44, 82, 44, 52, 44, 76, 44, 49, 50, 44, 82, 44, 54, 10,
             82, 44, 52, 44, 76, 44, 49, 50, 44, 76, 44, 49, 50, 44, 82, 44, 54, 10,
             110, 10]

robot.updateInput(UserInput)

while robot.finished == False:
    robot.run()

print(robot.prgOutput)
Example #3
0
from intcode import IntcodeVM

file = open('input.txt', 'r')

memry = []

for line in file:
    memry = line.split(',')

howBigIsTheScan = 50

UserInput = []

for i in range(howBigIsTheScan):
    for j in range(howBigIsTheScan):
        UserInput.append((i, j))

howManyTracks = 0

for spot in UserInput:
    robot = IntcodeVM(memry.copy())
    robot.updateInput([spot[0], spot[1]])
    robot.run()
    howManyTracks += robot.prgOutput

print(howManyTracks)
Example #4
0
def checkPoint(thisPoint):
    robot = IntcodeVM(memry.copy())
    robot.updateInput([thisPoint[0], thisPoint[1]])
    robot.run()
    return robot.prgOutput