def test_part_one_twice(self): """Test final dancer configuration from example of part2""" # 1. Create Promenade object from text myprom = promenade.Promenade(number=EXAMPLE_NUMBER, text=TWICE_INPUT) # 2. Check the dancers after executing the steps self.assertEqual(myprom.part_one(verbose=False), TWICE_RESULT)
def test_part_two(self): """Test final dancer configuration from example for part two""" # 1. Create Promenade object from text myprom = promenade.Promenade(number=EXAMPLE_NUMBER, text=EXAMPLE_INPUT, part2=True) # 2. Check the dancers after executing the steps self.assertEqual(myprom.part_two(verbose=True, limit=1), PART_TWO_RESULT)
def test_text_init(self): """Test the Promenade object creation from text""" # 1. Create Promenade object from text myprom = promenade.Promenade(number=EXAMPLE_NUMBER, text=EXAMPLE_INPUT) # 2. Make sure it has the default values self.assertEqual(myprom.part2, False) self.assertEqual(myprom.text, EXAMPLE_INPUT) self.assertEqual(myprom.number, EXAMPLE_NUMBER) self.assertEqual(myprom.dancers, list('abcde')) self.assertEqual(myprom.steps, ['s1', 'x3/4', 'pe/b']) self.assertEqual(myprom.index, 0)
def test_empty_init(self): """Test the default Promenade creation""" # 1. Create default Promenade object myprom = promenade.Promenade() # 2. Make sure it has the default values self.assertEqual(myprom.part2, False) self.assertEqual(myprom.text, None) self.assertEqual(myprom.number, 16) self.assertEqual(myprom.dancers, list('abcdefghijklmnop')) self.assertEqual(myprom.steps, []) self.assertEqual(myprom.index, 0)
def part_one(args, input_lines): "Process part one of the puzzle" # 1. Create the puzzle solver solver = promenade.Promenade(part2=False, text=input_lines[0]) # 2. Determine the dancer's position at the end of the dance solution = solver.part_one(verbose=args.verbose) if solution is None: print("There is no solution") else: print("The programs are in order %s after their dance" % (solution)) # 3. Return result return solution is not None
def test_part_one_dancers(self): """Test Promenade dancers step by step from example""" # 1. Create Promenade object from text myprom = promenade.Promenade(number=EXAMPLE_NUMBER, text=EXAMPLE_INPUT) # 2. Check the initial configuration self.assertEqual(myprom.index, 0) self.assertEqual(myprom.dancers, list(EXAMPLE_DANCERS[0])) # 3. Loop for all of the steps for num_step, one_step in enumerate(myprom.steps): # 4. Execute the step myprom.step(verbose=False) # 5. Verify the result of the dance step self.assertEqual(myprom.index, num_step + 1) self.assertEqual(myprom.dancers, list(EXAMPLE_DANCERS[num_step + 1]))