示例#1
0
 def getAmpOutput(self, line: str, phases: Iterable[int]):
     io = [0]
     for phase in phases:
         inputs = [phase]
         inputs.extend(io)
         io = processWithIntCodeComputer(line, inputs)[1]
     return io.pop(0)
示例#2
0
 def test(self):
     self.checkIntCodeComputerProgram(
         '109,1,204,-1,1001,100,1,100,1008,100,16,101,1006,101,0,99',
         '109,1,204,-1,1001,100,1,100,1008,100,16,101,1006,101,0,99', [1])
     self.checkIntCodeComputerOutput0(1125899906842624,
                                      '104,1125899906842624,99', [1])
     self.assertEqual(
         16,
         len(
             str(
                 processWithIntCodeComputer(
                     '1102,34915192,34915192,7,4,7,99,0', [1])[1][0])))
示例#3
0
 def test(self):
     self.coreTest(self.process)
     self.coreTest(lambda line: processWithIntCodeComputer(line, [0])[0]
                   )  # general solution from day 5 works, too
示例#4
0
 def process(self, line: str):
     tiles = processWithIntCodeComputer(line, [])[1]
     blockCount = count(tile for tile in tiles[::3] if tile == 2)
     return blockCount
示例#5
0
 def process(self, line: str):
     intCodeOutput = processWithIntCodeComputer(line, [])[1]
     return sum(getAlignmentParameters(intCodeOutput))
示例#6
0
 def process(self, line: str):
     springScript = []  # TODO
     intCodeInputs = springScriptToIntCodeInputs(springScript)
     return processWithIntCodeComputer(line, intCodeInputs)[1][0]
示例#7
0
 def process(self, line: str):
     boostKeyCode = processWithIntCodeComputer(line, [1])[1]
     return boostKeyCode
示例#8
0
 def process(self, line: str):
     diagnosticCode = processWithIntCodeComputer(line, [1])[1]
     return diagnosticCode
示例#9
0
 def process(self, line: str):
     result = sum(
         processWithIntCodeComputer(line, [x, y])[1][0] for x in range(50)
         for y in range(50))
     return result