def test_p1e0_solve(self): "Test Solver object creation with text of part 1 example 0" # 1. Create Intcode obhect with values mysolver = solver.Solver(text=from_text(test_vault.EXAMPLES[0])) # 2. Make sure it has the specified values self.assertEqual(mysolver.vault.rows, 3) self.assertEqual(mysolver.vault.cols, 9) self.assertEqual(len(mysolver.key_paths), 3) # 3. Check methods solution = mysolver.get_all_keys() self.assertEqual(solution[0], 8) self.assertEqual(solution[1], [solver.ORIGIN_KEY, 'a', 'b'])
def test_p1e4_init(self): "Test Solver object creation with text of part 1 example 4" # 1. Create Intcode obhect with values mysolver = solver.Solver(text=from_text(test_vault.EXAMPLES[4])) # 2. Make sure it has the specified values self.assertEqual(mysolver.vault.rows, 6) self.assertEqual(mysolver.vault.cols, 24) self.assertEqual(len(mysolver.key_paths), 10) # 3. Check methods solution = mysolver.get_all_keys() self.assertEqual(solution[0], 81) self.assertEqual(len(solution[1]), 10)
def test_p2e3_solve(self): "Test Solver object creation with text of part 2 example 3" # 1. Create Intcode obhect with values mysolver = solver.Solver(text=from_text(test_vault.EXAMPLES_PART2[3]), part2=True) #print(mysolver.key_paths.keys()) # 2. Make sure it has the specified values self.assertEqual(mysolver.vault.rows, 9) self.assertEqual(mysolver.vault.cols, 13) self.assertEqual(len(mysolver.key_paths), 19) # 3. Check methods solution = mysolver.get_all_keys() self.assertEqual(solution[0], 72)
def test_text_init_part2(self): """Test vault object creation with text""" # 1. Create default Vault object myvault = vault.Vault(text=from_text(EXAMPLES_PART2[0]), part2=True) # 2. Make sure it has the expected values self.assertEqual(len(myvault.text), 7) self.assertEqual(len(myvault.clean), 7) self.assertEqual(myvault.rows, 7) self.assertEqual(myvault.cols, 7) self.assertEqual(len(myvault.keys), 4) self.assertEqual(len(myvault.doors), 3) self.assertEqual(len(myvault.key_at), 4) self.assertEqual(len(myvault.door_at), 3) #self.assertEqual(myvault.origin, (3, 3)) self.assertEqual(myvault.origins, [(2, 2), (4, 2), (2, 4), (4, 4)]) self.assertEqual(len(myvault.locs), 12)
def test_text_init(self): """Test vault object creation with text""" # 1. Create default Vault object myvault = vault.Vault(text=from_text(EXAMPLES[3])) # 2. Make sure it has the expected values self.assertEqual(len(myvault.text), 9) self.assertEqual(len(myvault.clean), 9) self.assertEqual(myvault.rows, 9) self.assertEqual(myvault.cols, 17) self.assertEqual(len(myvault.keys), 16) self.assertEqual(len(myvault.doors), 8) self.assertEqual(len(myvault.key_at), 16) self.assertEqual(len(myvault.door_at), 8) self.assertEqual(myvault.origin, (8, 4)) self.assertEqual(myvault.origins, None) self.assertEqual(len(myvault.locs), 4 * 15 + 3)