def test_OneBotInputBinToOutputBin(self): input = [ "value 25 goes to bot 7", "value 10 goes to bot 7", "bot 7 gives low to output 1 and high to output 10", ] factory = Factory() factory.runBots(input) self.assertEqual(factory.findBotComparisonById(7), "10,25") self.assertEqual(factory.findBotComparison("10,25"), 7) self.assertEqual(factory.getOutputBinValue("1"), [10]) self.assertEqual(factory.getOutputBinValue("10"), [25])
def test_Puzzle(self): instructionList = [] getFileInput = True f = open('input.txt', 'r') while (getFileInput): line = f.readline() if (not line == ''): line = line[:-1] instructionList.append(line) else: getFileInput = False f.close() factory = Factory() factory.runBots(instructionList) self.assertEqual(factory.findBotComparison("17,61"), 116) multipliedValue = factory.getOutputBinValue( "0")[0] * factory.getOutputBinValue( "1")[0] * factory.getOutputBinValue("2")[0] self.assertEqual(multipliedValue, 23903)