Exemplo n.º 1
0
def main():
    if (len(sys.argv) < 2):
        print 'Missing data file!'
        print 'Usage: python [script] [data]'
        sys.exit(1)

    f = open(sys.argv[1])
    intcode = [int(x) for x in f.read().split(',')]
    f.close()

    computer = Computer(intcode, IOQueue(), IOQueue())
    _ = system('clear')
    computer.start()
    run_commands(pick_up_all_things_and_go_to_security(),
                 computer.InputQueue())
    find_combo(computer.InputQueue())
Exemplo n.º 2
0
 def __init__(self, intcode):
   self.nat = None
   self.first_nat = True
   now = time.time()
   self.last_active = [now] * 50
   self.computers = []
   for i in range(50):
     c = Computer(intcode, NetworkQueue(i, self), NetworkQueue(i, self), name='Computer%d'%i)
     # Give the computer its own address, need to bypass the guard for this one.
     c.InputQueue().put(i)
     c.daemon = True
     self.computers.append(c)
   print('Router initialized.')
Exemplo n.º 3
0
def test_point(intcode, x, y, grid=None):
    computer = Computer(intcode, Queue(), Queue())
    computer.start()
    in_q = computer.InputQueue()
    out_q = computer.OutputQueue()
    in_q.put(x)
    in_q.put(y)

    pull = out_q.get()
    computer.join()
    if pull:
        if grid:
            grid.set(Point(x, y), '#')
    return pull