Ejemplo n.º 1
0
    def test_who_traveled_farthest(self):
        comet = Reindeer("Comet can fly 14 km/s for 10 seconds, but then must rest for 127 seconds.")
        dancer = Reindeer("Dancer can fly 16 km/s for 11 seconds, but then must rest for 162 seconds.")
        deers = [comet, dancer]

        solver = SolutionFourteen()
        solver.run_deers(deers, 1000)

        winner = solver.which_deer_traveled_furthest(deers)
        self.assertEqual(comet, winner)
Ejemplo n.º 2
0
    def stest_who_scored_most_points(self):
        comet = Reindeer("Comet can fly 14 km/s for 10 seconds, but then must rest for 127 seconds.")
        dancer = Reindeer("Dancer can fly 16 km/s for 11 seconds, but then must rest for 162 seconds.")
        deers = [comet, dancer]
        solver = SolutionFourteen()
        solver.run_deers(deers, 1000)

        self.assertEqual(dancer, solver.whch_deer_scored_most(deers))
        self.assertEqual(689, dancer.score)
        self.assertEqual(312, comet.score)
Ejemplo n.º 3
0
    def test_run_deers_for_1000_seconds(self):
        comet = Reindeer("Comet can fly 14 km/s for 10 seconds, but then must rest for 127 seconds.")
        dancer = Reindeer("Dancer can fly 16 km/s for 11 seconds, but then must rest for 162 seconds.")
        deers = [comet, dancer]

        solver = SolutionFourteen()
        solver.run_deers(deers, 1000)
        self.assertFalse(comet.flying)
        self.assertFalse(dancer.flying)

        self.assertEqual(1120, comet.distance)
        self.assertEqual(1056, dancer.distance)
Ejemplo n.º 4
0
    def test_who_traveled_farthest(self):
        comet = Reindeer(
            "Comet can fly 14 km/s for 10 seconds, but then must rest for 127 seconds."
        )
        dancer = Reindeer(
            "Dancer can fly 16 km/s for 11 seconds, but then must rest for 162 seconds."
        )
        deers = [comet, dancer]

        solver = SolutionFourteen()
        solver.run_deers(deers, 1000)

        winner = solver.which_deer_traveled_furthest(deers)
        self.assertEqual(comet, winner)
Ejemplo n.º 5
0
    def stest_who_scored_most_points(self):
        comet = Reindeer(
            "Comet can fly 14 km/s for 10 seconds, but then must rest for 127 seconds."
        )
        dancer = Reindeer(
            "Dancer can fly 16 km/s for 11 seconds, but then must rest for 162 seconds."
        )
        deers = [comet, dancer]
        solver = SolutionFourteen()
        solver.run_deers(deers, 1000)

        self.assertEqual(dancer, solver.whch_deer_scored_most(deers))
        self.assertEqual(689, dancer.score)
        self.assertEqual(312, comet.score)
Ejemplo n.º 6
0
    def test_run_deers_for_1000_seconds(self):
        comet = Reindeer(
            "Comet can fly 14 km/s for 10 seconds, but then must rest for 127 seconds."
        )
        dancer = Reindeer(
            "Dancer can fly 16 km/s for 11 seconds, but then must rest for 162 seconds."
        )
        deers = [comet, dancer]

        solver = SolutionFourteen()
        solver.run_deers(deers, 1000)
        self.assertFalse(comet.flying)
        self.assertFalse(dancer.flying)

        self.assertEqual(1120, comet.distance)
        self.assertEqual(1056, dancer.distance)
Ejemplo n.º 7
0
    def test_run_deers_for_20_seconds(self):
        comet = Reindeer("Comet can fly 14 km/s for 10 seconds, but then must rest for 127 seconds.")
        dancer = Reindeer("Dancer can fly 16 km/s for 11 seconds, but then must rest for 162 seconds.")
        deers = [comet, dancer]

        solver = SolutionFourteen()
        solver.run_deers(deers, 20)

        self.assertFalse(comet.flying)
        self.assertEquals(140, comet.distance)
        self.assertEquals(0, comet.stamina_left)
        self.assertEquals(127 - 10, comet.rest_left)

        self.assertFalse(dancer.flying)
        self.assertEquals(176, dancer.distance)
        self.assertEquals(0, dancer.stamina_left)
        self.assertEquals(162 - 9, dancer.rest_left)
Ejemplo n.º 8
0
    def test_run_deers_for_20_seconds(self):
        comet = Reindeer(
            "Comet can fly 14 km/s for 10 seconds, but then must rest for 127 seconds."
        )
        dancer = Reindeer(
            "Dancer can fly 16 km/s for 11 seconds, but then must rest for 162 seconds."
        )
        deers = [comet, dancer]

        solver = SolutionFourteen()
        solver.run_deers(deers, 20)

        self.assertFalse(comet.flying)
        self.assertEquals(140, comet.distance)
        self.assertEquals(0, comet.stamina_left)
        self.assertEquals(127 - 10, comet.rest_left)

        self.assertFalse(dancer.flying)
        self.assertEquals(176, dancer.distance)
        self.assertEquals(0, dancer.stamina_left)
        self.assertEquals(162 - 9, dancer.rest_left)
Ejemplo n.º 9
0
    def test_score_system(self):
        comet = Reindeer("Comet can fly 14 km/s for 10 seconds, but then must rest for 127 seconds.")
        dancer = Reindeer("Dancer can fly 16 km/s for 11 seconds, but then must rest for 162 seconds.")
        deers = [comet, dancer]
        solver = SolutionFourteen()
        solver.run_deers(deers, 1)
        self.assertEqual(0, comet.score)
        self.assertEqual(1, dancer.score)

        solver.run_deers(deers, 9)
        self.assertEqual(0, comet.score)
        self.assertEqual(10, dancer.score)

        solver.run_deers(deers, 130)
        self.assertEqual(1, comet.score)
        self.assertEqual(139, dancer.score)
Ejemplo n.º 10
0
    def test_score_system(self):
        comet = Reindeer(
            "Comet can fly 14 km/s for 10 seconds, but then must rest for 127 seconds."
        )
        dancer = Reindeer(
            "Dancer can fly 16 km/s for 11 seconds, but then must rest for 162 seconds."
        )
        deers = [comet, dancer]
        solver = SolutionFourteen()
        solver.run_deers(deers, 1)
        self.assertEqual(0, comet.score)
        self.assertEqual(1, dancer.score)

        solver.run_deers(deers, 9)
        self.assertEqual(0, comet.score)
        self.assertEqual(10, dancer.score)

        solver.run_deers(deers, 130)
        self.assertEqual(1, comet.score)
        self.assertEqual(139, dancer.score)
Ejemplo n.º 11
0
from SolutionFourteen import SolutionFourteen
from Reindeer import Reindeer

solver = SolutionFourteen()
descriptions = open("input_fourteen.txt", "r").readlines()

deers = []
for d in descriptions:
    deers.append(Reindeer(d))

solver.run_deers(deers, 2503)

distance_winner = solver.which_deer_traveled_furthest(deers)
print "*********************"
print " %s traveled %d kms and got the farthest " % (distance_winner.name,
                                                     distance_winner.distance)
print "  %s" % distance_winner
print "*********************"

winner = solver.whch_deer_scored_most(deers)
print "*********************"
print " Winner is %s!" % winner.name
print "  %s" % winner
print " %s traveled %d kms " % (winner.name, winner.distance)
print " and got %d points" % winner.score
print "*********************"
Ejemplo n.º 12
0
from SolutionFourteen import SolutionFourteen
from Reindeer import Reindeer


solver = SolutionFourteen()
descriptions = open("input_fourteen.txt", "r").readlines()

deers = []
for d in descriptions:
    deers.append(Reindeer(d))

solver.run_deers(deers, 2503)

distance_winner = solver.which_deer_traveled_furthest(deers)
print "*********************"
print " %s traveled %d kms and got the farthest " % (distance_winner.name, distance_winner.distance)
print "  %s" % distance_winner
print "*********************"

winner = solver.whch_deer_scored_most(deers)
print "*********************"
print " Winner is %s!" % winner.name
print "  %s" % winner
print " %s traveled %d kms " % (winner.name, winner.distance)
print " and got %d points" % winner.score
print "*********************"