示例#1
0
    def __init__(self, data: Data, debug=False):
        self.state = State(program=defaultdict(int))
        self.debug = debug
        for i, n in enumerate(data.nums()):
            self.state.program[i] = n

        for op in POSSIBLE_OPS:
            op.DEBUG = debug
        Op.DEBUG = debug
 def apply(self, state: State):
     [op1, op2, dest] = self.params(state)
     state.program[dest] = 1 if op1 < op2 else 0
     super().apply(state)
示例#3
0
 def apply(self, state: State):
     [source] = self.params(state)
     state.add_output(state.program[source])
     super().apply(state)
示例#4
0
 def apply(self, state: State):
     [op1, op2, dest] = self.params(state)
     state.program[dest] = op1 + op2
     super().apply(state)
 def apply(self, state: State):
     [comparator, dest] = self.params(state)
     if comparator != 0:
         state.pointer = dest
     else:
         super().apply(state)
示例#6
0
 def apply(self, state: State):
     [dest] = self.params(state)
     state.program[dest] = state.next_input
     super().apply(state)