Ejemplo n.º 1
0
    def test_part_two(self):
        "Test part two example of Lights object"

        # 1. Create Lights object from text
        myobj = lights.Lights(part2=True, text=aoc_10.from_text(PART_TWO_TEXT))

        # 2. Check the part two result
        self.assertEqual(myobj.part_two(verbose=False), PART_TWO_RESULT)
Ejemplo n.º 2
0
    def test_part_one(self):
        "Test part one example of Jolts object"

        # 1. Create Jolts object from text
        myobj = jolts.Jolts(text=aoc_10.from_text(PART_ONE_TEXT))

        # 2. Check the part one result
        self.assertEqual(myobj.part_one(verbose=False), PART_ONE_RESULT)
Ejemplo n.º 3
0
    def test_part_one(self):
        "Test part one example of Lookandsay object"

        # 1. Create Lookandsay object from text
        myobj = lookandsay.Lookandsay(text=aoc_10.from_text(PART_ONE_TEXT))

        # 2. Check the part one result
        self.assertEqual(myobj.part_one(times=5, verbose=False),
                         PART_ONE_RESULT)
Ejemplo n.º 4
0
    def test_part_two(self):
        "Test part two example of Lookandsay object"

        # 1. Create Lookandsay object from text
        myobj = lookandsay.Lookandsay(part2=True,
                                      text=aoc_10.from_text(PART_TWO_TEXT))

        # 2. Check the part two result
        self.assertEqual(myobj.part_two(times=3, verbose=False),
                         PART_TWO_RESULT)
Ejemplo n.º 5
0
    def test_text_init(self):
        "Test the Navigation object creation from text"

        # 1. Create Navigation object from text
        myobj = navigation.Navigation(text=aoc_10.from_text(EXAMPLE_TEXT))

        # 2. Make sure it has the expected values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(len(myobj.text), 10)
        self.assertEqual(len(myobj.lines), 10)

        # 3. Check methods
        self.assertEqual(myobj.syntax_error_score(), 26397)
Ejemplo n.º 6
0
    def test_text_init(self):
        "Test the Bots object creation from text"

        # 1. Create Bots object from text
        myobj = bots.Bots(text=aoc_10.from_text(EXAMPLE_TEXT))

        # 2. Make sure it has the expected values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(len(myobj.text), 6)
        self.assertEqual(len(myobj.bots), 3)
        self.assertEqual(len(myobj.outputs), 0)
        self.assertEqual(len(myobj.twos), 1)

        # 3. Check methods
        self.assertEqual(myobj.zooming_around(values=(5, 2)), 2)
Ejemplo n.º 7
0
    def test_text_init(self):
        "Test the Lookandsay object creation from text"

        # 1. Create Lookandsay object from text
        myobj = lookandsay.Lookandsay(text=aoc_10.from_text(EXAMPLE_TEXT))

        # 2. Make sure it has the expected values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(len(myobj.text), 0)

        # 3. Check methods
        self.assertEqual(myobj.next_sequence('1'), '11')
        self.assertEqual(myobj.next_sequence('11'), '21')
        self.assertEqual(myobj.next_sequence('21'), '1211')
        self.assertEqual(myobj.next_sequence('1211'), '111221')
        self.assertEqual(myobj.next_sequence('111221'), '312211')
Ejemplo n.º 8
0
    def test_text_init(self):
        "Test the Jolts object creation from text"

        # 1. Create Jolts object from text
        myobj = jolts.Jolts(text=aoc_10.from_text(EXAMPLE_7_5_TEXT))

        # 2. Make sure it has the expected values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(len(myobj.text), 11)
        self.assertEqual(len(myobj.adapters), 11)
        self.assertEqual(len(myobj.ordered), 11)
        self.assertEqual(myobj.start, 0)
        self.assertEqual(myobj.device, 22)

        # 3. Test methods
        self.assertEqual(myobj.get_part_one_differences(), 7 * 5)

        self.assertEqual(myobj.how_many_ways(), 8)
Ejemplo n.º 9
0
    def test_text_init(self):
        "Test the Lights object creation from text"

        # 1. Create Lights object from text
        myobj = lights.Lights(text=aoc_10.from_text(EXAMPLE_TEXT))

        # 2. Make sure it has the expected values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(len(myobj.text), 31)
        self.assertEqual(len(myobj.points), 31)
        self.assertEqual(myobj.points[0].posX, 9)
        self.assertEqual(myobj.points[0].posY, 1)
        self.assertEqual(myobj.points[0].velX, 0)
        self.assertEqual(myobj.points[0].velY, 2)
        self.assertEqual(myobj.points[1].posX, 7)
        self.assertEqual(myobj.points[1].posY, 0)
        self.assertEqual(myobj.points[1].velX, -1)
        self.assertEqual(myobj.points[1].velY, 0)
        self.assertEqual(myobj.rows(), 16)

        # 3. Move forward a step
        myobj.step()
        self.assertEqual(myobj.points[0].posX, 9)
        self.assertEqual(myobj.points[0].posY, 3)
        self.assertEqual(myobj.points[0].velX, 0)
        self.assertEqual(myobj.points[0].velY, 2)
        self.assertEqual(myobj.points[1].posX, 6)
        self.assertEqual(myobj.points[1].posY, 0)
        self.assertEqual(myobj.points[1].velX, -1)
        self.assertEqual(myobj.points[1].velY, 0)
        self.assertEqual(myobj.rows(), 12)

        # 4. And a couple of more steps
        myobj.step()
        self.assertEqual(myobj.rows(), 10)
        myobj.step()
        self.assertEqual(myobj.rows(), 8)
        print(myobj.display())
        myobj.step()
        self.assertEqual(myobj.rows(), 11)