def test_part_two(self):
        "Test part two example of Constellations object"

        # 1. Create Constellations object from text
        myobj = constellations.Constellations(part2=True, text=aoc_25.from_text(PART_TWO_TEXT))

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

        # 1. Create Constellations object from text
        myobj = constellations.Constellations(text=aoc_25.from_text(PART_ONE_TEXT))

        # 2. Check the part one result
        self.assertEqual(myobj.part_one(verbose=False), PART_ONE_RESULT)
    def test_examples(self):
        "Test multiple examples"
        myobj = constellations.Constellations(text=aoc_25.from_text(EXAMPLE_TWO))
        myobj.form_constellations()
        self.assertEqual(len(myobj.constellations), 2)

        myobj = constellations.Constellations(text=aoc_25.from_text(EXAMPLE_FOUR))
        myobj.form_constellations()
        self.assertEqual(len(myobj.constellations), 4)

        myobj = constellations.Constellations(text=aoc_25.from_text(EXAMPLE_THREE))
        myobj.form_constellations()
        self.assertEqual(len(myobj.constellations), 3)

        myobj = constellations.Constellations(text=aoc_25.from_text(EXAMPLE_EIGHT))
        myobj.form_constellations()
        self.assertEqual(len(myobj.constellations), 8)
    def test_empty_init(self):
        "Test the default Constellations creation"

        # 1. Create default Constellations object
        myobj = constellations.Constellations()

        # 2. Make sure it has the default values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(myobj.text, None)
        self.assertEqual(myobj.points, [])
        self.assertEqual(myobj.constellations, [])
Ejemplo n.º 5
0
def part_two(args, input_lines):
    "Process part two of the puzzle"

    # 1. Create the puzzle solver
    solver = constellations.Constellations(part2=True, text=input_lines)

    # 2. Determine the solution for part two
    solution = solver.part_two(verbose=args.verbose, limit=args.limit)
    if solution is None:
        print("There is no solution")
    else:
        print("The solution for part two is %s" % (solution))

    # 3. Return result
    return solution is not None
Ejemplo n.º 6
0
def main():
    
    motor_arm = motors.Motor()
    
    constellation = constellations.Constellations()
    #Sofie's flat
    constellation.set_position('59.253141 N', '15.234271 E')
    
    while(True):
        for cons in constellations.all_constellations:
            constellation.print_constellation(cons)
            az_alti = constellation.get_stars_azimut_altitude(cons)
            
            for el in az_alti:
                print(el)
                motor_arm.write_data(el[0], el[1])
            print("DONE ALL")
    def test_text_init(self):
        "Test the Constellations object creation from text"

        # 1. Create Constellations object from text
        myobj = constellations.Constellations(text=aoc_25.from_text(EXAMPLE_TWO))

        # 2. Make sure it has the expected values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(len(myobj.text), 8)
        self.assertEqual(len(myobj.points), 8)
        self.assertEqual(myobj.points[0], [0,0,0,0])
        self.assertEqual(myobj.points[1], [3,0,0,0])
        self.assertEqual(myobj.constellations, [])

        # 3. Join into constallations
        myobj.form_constellations()
        self.assertEqual(len(myobj.points), 8)
        self.assertEqual(len(myobj.constellations), 2)