Пример #1
0
 def test_multiple_instructions(self):
     self.assertEqual(
         Puzzle21.solve_1(
             'swap position 4 with position 0\n'
             'swap letter d with letter b\n'
             'reverse positions 0 through 4\n'
             'rotate left 1 step\n'
             'move position 1 to position 4\n'
             'move position 3 to position 0\n'
             'rotate based on position of letter b\n'
             'rotate based on position of letter d', 'abcde'), 'decab')
Пример #2
0
 def test_reversed_rotate_on_letter(self):
     self.assertEqual(
         Puzzle21.reverse_rotate_on_letter(
             Puzzle21.rotate_on_letter('fbgdceah', 'a'), 'a'), 'fbgdceah')
     self.assertEqual(
         Puzzle21.reverse_rotate_on_letter(
             Puzzle21.rotate_on_letter('fbgdceah', 'b'), 'b'), 'fbgdceah')
     self.assertEqual(
         Puzzle21.reverse_rotate_on_letter(
             Puzzle21.rotate_on_letter('fbgdceah', 'c'), 'c'), 'fbgdceah')
     self.assertEqual(
         Puzzle21.reverse_rotate_on_letter(
             Puzzle21.rotate_on_letter('fbgdceah', 'd'), 'd'), 'fbgdceah')
     self.assertEqual(
         Puzzle21.reverse_rotate_on_letter(
             Puzzle21.rotate_on_letter('fbgdceah', 'e'), 'e'), 'fbgdceah')
     self.assertEqual(
         Puzzle21.reverse_rotate_on_letter(
             Puzzle21.rotate_on_letter('fbgdceah', 'f'), 'f'), 'fbgdceah')
     self.assertEqual(
         Puzzle21.reverse_rotate_on_letter(
             Puzzle21.rotate_on_letter('fbgdceah', 'g'), 'g'), 'fbgdceah')
     self.assertEqual(
         Puzzle21.reverse_rotate_on_letter(
             Puzzle21.rotate_on_letter('fbgdceah', 'h'), 'h'), 'fbgdceah')
Пример #3
0
 def test(self):
     with open('Puzzle21.txt') as puzzle:
         print Puzzle21.solve_1(puzzle.read(), 'abcdefgh')
Пример #4
0
 def test_rotate_on_letter_big_index(self):
     self.assertEqual(Puzzle21.rotate_on_letter('ecabd', 'd'), 'decab')
Пример #5
0
 def test_reverse_posistions_2(self):
     self.assertEqual(Puzzle21.reverse_positions('hbcdfaeg', 4, 7),
                      'hbcdgeaf')
Пример #6
0
 def test_swap_letter_rev(self):
     self.assertEqual(Puzzle21.swap_letter('edcba', 'd', 'b'), 'ebcda')
     self.assertEqual(Puzzle21.swap_letter('edcba', 'b', 'd'), 'ebcda')
Пример #7
0
 def test_rotate_on_letter_small_index(self):
     self.assertEqual(Puzzle21.rotate_on_letter('abdec', 'b'), 'ecabd')
Пример #8
0
 def test_move_asc_rev(self):  # !
     self.assertEqual(Puzzle21.move('bdeac', 4, 1), 'bcdea')
Пример #9
0
 def test_move_desc(self):
     self.assertEqual(Puzzle21.move('bdeac', 3, 0), 'abdec')
Пример #10
0
 def test_rotate_rev(self):  # !
     self.assertEqual(Puzzle21.rotate('bcdea', 'right', 1), 'abcde')
Пример #11
0
 def test_move_asc(self):
     self.assertEqual(Puzzle21.move('bcdea', 1, 4), 'bdeac')
Пример #12
0
 def test_rotate(self):
     self.assertEqual(Puzzle21.rotate('abcde', 'left', 1), 'bcdea')
Пример #13
0
 def test_reverse_positions_rev(self):  # !
     self.assertEqual(Puzzle21.reverse_positions('abcde', 0, 4), 'edcba')
Пример #14
0
 def test_reverse_positions(self):
     self.assertEqual(Puzzle21.reverse_positions('edcba', 0, 4), 'abcde')
Пример #15
0
 def test_swap_position(self):
     self.assertEqual(Puzzle21.swap_position('abcde', 4, 0), 'ebcda')
Пример #16
0
 def test_move_desc_rev(self):
     self.assertEqual(Puzzle21.move('abdec', 0, 3), 'bdeac')
Пример #17
0
 def test_2(self):
     with open('Puzzle21.txt') as puzzle:
         print Puzzle21.solve_2(puzzle.read(), 'fbgdceah')
Пример #18
0
 def test_swap_position_rev(self):
     self.assertEqual(Puzzle21.swap_position('ebcda', 4, 0), 'abcde')
     self.assertEqual(Puzzle21.swap_position('ebcda', 0, 4), 'abcde')